From 6951f335ea3622148ebe0532196466086af67eeb Mon Sep 17 00:00:00 2001 From: Michael Tingley Date: Thu, 20 Apr 2017 15:01:45 -0700 Subject: [PATCH] Implement full-fidelity parsing and formatting for the coroutine keyword Summary: Supports parsing the `coroutine` keyword as a modifier for function-like constructs in places where `async` is supported today: 1. Function declarations: ``` coroutine function test(): void {} ``` 2. Anonymous functions: ``` function foo(): int { $x = coroutine function() { return 5; }; return $x(); } ``` 3. Lambdas: ``` function f(): (function(int): int) { return coroutine $v ==> 1; } ``` 4. Blocks: ``` function test(): void { return coroutine { return 1; }; } ``` In addition to parsing, this diff also implements formatting. It does //most// of the lowering as well. However, I have not yet updated `ast.ml` to include the new `coroutine` construct as a `fun_type`. This step has been left as a `TODO` in the code. Reviewed By: ericlippert Differential Revision: D4884746 fbshipit-source-id: 9489e9c11b4d9bcdca44b58a6c69cf2170c96fa0 --- hphp/hack/src/hackfmt/hack_format.ml | 81 +++++++++-- hphp/hack/src/parser/full_fidelity_ast.ml | 69 ++++++--- .../src/parser/full_fidelity_declaration_parser.ml | 25 +++- .../src/parser/full_fidelity_expression_parser.ml | 37 +++-- .../src/parser/full_fidelity_pretty_printer.ml | 49 +++++-- hphp/hack/src/parser/full_fidelity_syntax.ml | 44 ++++++ hphp/hack/src/parser/full_fidelity_token_kind.ml | 3 + hphp/hack/src/parser/js/full_fidelity_editable.js | 122 ++++++++++++++++ hphp/hack/src/parser/js/full_fidelity_schema.json | 8 +- .../hack/src/parser/php/full_fidelity_editable.php | 141 ++++++++++++++++++ .../hack/src/parser/schema/full_fidelity_schema.ml | 7 +- .../full_fidelity/cases/test_array_expression.exp | 54 +------ .../cases/test_array_key_value_precedence.exp | 30 +--- .../full_fidelity/cases/test_attribute_spec.exp | 36 +---- .../cases/test_awaitable_creation.exp | 82 +---------- .../cases/test_class_method_declaration.exp | 93 +----------- .../test/full_fidelity/cases/test_closure_type.exp | 38 +---- .../cases/test_constructor_destructor.exp | 159 +-------------------- .../full_fidelity/cases/test_for_statements.exp | 140 +----------------- .../cases/test_foreach_statements.exp | 49 +------ .../full_fidelity/cases/test_function_call.exp | 33 +---- .../full_fidelity/cases/test_list_precedence.exp | 53 +------ .../test/full_fidelity/cases/test_literals.exp | 22 +-- .../test/full_fidelity/cases/test_namespace.exp | 35 +---- hphp/hack/test/full_fidelity/cases/test_simple.exp | 36 +---- .../test/full_fidelity/cases/test_statements.exp | 76 +--------- .../full_fidelity/cases/test_try_statement.exp | 39 +---- .../full_fidelity/cases/test_types_type_const.exp | 18 +-- .../hackfmt/tests/async_coroutine_function1.php | 5 + .../tests/async_coroutine_function1.php.exp | 6 + .../hackfmt/tests/coroutine_anon_function1.php | 8 ++ .../hackfmt/tests/coroutine_anon_function1.php.exp | 8 ++ hphp/hack/test/hackfmt/tests/coroutine_block1.php | 9 ++ .../test/hackfmt/tests/coroutine_block1.php.exp | 9 ++ .../test/hackfmt/tests/coroutine_function1.php | 3 + .../test/hackfmt/tests/coroutine_function1.php.exp | 4 + hphp/hack/test/hackfmt/tests/coroutine_lambda1.php | 5 + .../test/hackfmt/tests/coroutine_lambda1.php.exp | 5 + hphp/hack/test/hackfmt/tests/coroutine_lambda2.php | 5 + .../test/hackfmt/tests/coroutine_lambda2.php.exp | 5 + hphp/hack/test/hackfmt/tests/coroutine_lambda3.php | 5 + .../test/hackfmt/tests/coroutine_lambda3.php.exp | 5 + 42 files changed, 618 insertions(+), 1043 deletions(-) rewrite hphp/hack/test/full_fidelity/cases/test_array_expression.exp (100%) rewrite hphp/hack/test/full_fidelity/cases/test_array_key_value_precedence.exp (100%) rewrite hphp/hack/test/full_fidelity/cases/test_attribute_spec.exp (100%) rewrite hphp/hack/test/full_fidelity/cases/test_awaitable_creation.exp (100%) rewrite hphp/hack/test/full_fidelity/cases/test_class_method_declaration.exp (100%) rewrite hphp/hack/test/full_fidelity/cases/test_closure_type.exp (94%) rewrite hphp/hack/test/full_fidelity/cases/test_constructor_destructor.exp (99%) rewrite hphp/hack/test/full_fidelity/cases/test_for_statements.exp (100%) rewrite hphp/hack/test/full_fidelity/cases/test_foreach_statements.exp (100%) rewrite hphp/hack/test/full_fidelity/cases/test_function_call.exp (100%) rewrite hphp/hack/test/full_fidelity/cases/test_list_precedence.exp (100%) rewrite hphp/hack/test/full_fidelity/cases/test_literals.exp (100%) rewrite hphp/hack/test/full_fidelity/cases/test_namespace.exp (95%) rewrite hphp/hack/test/full_fidelity/cases/test_simple.exp (100%) rewrite hphp/hack/test/full_fidelity/cases/test_statements.exp (100%) rewrite hphp/hack/test/full_fidelity/cases/test_try_statement.exp (100%) rewrite hphp/hack/test/full_fidelity/cases/test_types_type_const.exp (100%) create mode 100644 hphp/hack/test/hackfmt/tests/async_coroutine_function1.php create mode 100644 hphp/hack/test/hackfmt/tests/async_coroutine_function1.php.exp create mode 100644 hphp/hack/test/hackfmt/tests/coroutine_anon_function1.php create mode 100644 hphp/hack/test/hackfmt/tests/coroutine_anon_function1.php.exp create mode 100644 hphp/hack/test/hackfmt/tests/coroutine_block1.php create mode 100644 hphp/hack/test/hackfmt/tests/coroutine_block1.php.exp create mode 100644 hphp/hack/test/hackfmt/tests/coroutine_function1.php create mode 100644 hphp/hack/test/hackfmt/tests/coroutine_function1.php.exp create mode 100644 hphp/hack/test/hackfmt/tests/coroutine_lambda1.php create mode 100644 hphp/hack/test/hackfmt/tests/coroutine_lambda1.php.exp create mode 100644 hphp/hack/test/hackfmt/tests/coroutine_lambda2.php create mode 100644 hphp/hack/test/hackfmt/tests/coroutine_lambda2.php.exp create mode 100644 hphp/hack/test/hackfmt/tests/coroutine_lambda3.php create mode 100644 hphp/hack/test/hackfmt/tests/coroutine_lambda3.php.exp diff --git a/hphp/hack/src/hackfmt/hack_format.ml b/hphp/hack/src/hackfmt/hack_format.ml index e3daf1ef024..8020ad06010 100644 --- a/hphp/hack/src/hackfmt/hack_format.ml +++ b/hphp/hack/src/hackfmt/hack_format.ml @@ -261,11 +261,24 @@ let rec transform node = Newline; ] | FunctionDeclarationHeader x -> - let (async, kw, amp, name, type_params, leftp, params, rightp, colon, - ret_type, where) = get_function_declaration_header_children x + let ( + async, + coroutine, + kw, + amp, + name, + type_params, + leftp, + params, + rightp, + colon, + ret_type, + where + ) = get_function_declaration_header_children x in Fmt [ - Span (transform_fn_decl_name async kw amp name type_params leftp); + Span ( + transform_fn_decl_name async coroutine kw amp name type_params leftp); transform_fn_decl_args params rightp colon ret_type where; ] | WhereClause x -> @@ -297,11 +310,31 @@ let rec transform node = in let fn_name, args_and_where = match syntax func_decl with | FunctionDeclarationHeader x -> - let (async, kw, amp, name, type_params, leftp, params, rightp, - colon, ret_type, where) = - get_function_declaration_header_children x + let ( + async, + coroutine, + kw, + amp, + name, + type_params, + leftp, + params, + rightp, + colon, + ret_type, + where + ) = get_function_declaration_header_children x in - Fmt (transform_fn_decl_name async kw amp name type_params leftp), + Fmt ( + transform_fn_decl_name + async + coroutine + kw + amp + name + type_params + leftp + ), transform_fn_decl_args params rightp colon ret_type where | _ -> failwith "Expected FunctionDeclarationHeader" in @@ -699,11 +732,23 @@ let rec transform node = Nest [t value]; ] | AnonymousFunction x -> - let (async_kw, fun_kw, lp, params, rp, colon, ret_type, use, body) = - get_anonymous_function_children x in + let ( + async_kw, + coroutine_kw, + fun_kw, + lp, + params, + rp, + colon, + ret_type, + use, + body + ) = get_anonymous_function_children x in Fmt [ t async_kw; when_present async_kw space; + t coroutine_kw; + when_present coroutine_kw space; t fun_kw; transform_argish_with_return_type lp params rp colon ret_type; t use; @@ -720,10 +765,13 @@ let rec transform node = transform_argish left_p vars right_p; ] | LambdaExpression x -> - let (async, signature, arrow, body) = get_lambda_expression_children x in + let (async, coroutine, signature, arrow, body) = + get_lambda_expression_children x in Fmt [ t async; when_present async space; + t coroutine; + when_present coroutine space; t signature; Space; t arrow; @@ -969,10 +1017,13 @@ let rec transform node = transform_braced_item lb expr rb; ] | AwaitableCreationExpression x -> - let (kw, body) = get_awaitable_creation_expression_children x in + let (async_kw, coroutine_kw, body) = + get_awaitable_creation_expression_children x in Fmt [ - t kw; - Space; + t async_kw; + when_present async_kw space; + t coroutine_kw; + when_present coroutine_kw space; (* TODO: rethink possible one line bodies *) (* TODO: correctly handle spacing after the closing brace *) handle_possible_compound_statement ~space:false body; @@ -1533,10 +1584,12 @@ and handle_switch_body left_b sections right_b = ) ] -and transform_fn_decl_name async kw amp name type_params leftp = +and transform_fn_decl_name async coroutine kw amp name type_params leftp = [ transform async; when_present async space; + transform coroutine; + when_present coroutine space; transform kw; Space; transform amp; diff --git a/hphp/hack/src/parser/full_fidelity_ast.ml b/hphp/hack/src/parser/full_fidelity_ast.ml index 8e73cd67b20..a2a59e3920a 100644 --- a/hphp/hack/src/parser/full_fidelity_ast.ml +++ b/hphp/hack/src/parser/full_fidelity_ast.ml @@ -343,14 +343,29 @@ let unesc_xhp_attr s = then matched_group 1 s else s -let mk_fun_kind sync yield = - match sync, yield with - | true, true -> FGenerator - | false, true -> FAsyncGenerator - | true, false -> FSync - | false, false -> FAsync - -let fun_template yielding node is_sync = +type suspension_kind = + | SKSync + | SKAsync + | SKCoroutine + +let mk_suspension_kind async_node coroutine_node = + match is_missing async_node, is_missing coroutine_node with + | true, true -> SKSync + | false, true -> SKAsync + | true, false -> SKCoroutine + | false, false -> raise (Failure "Couroutine functions may not be async") + +let mk_fun_kind suspension_kind yield = + match suspension_kind, yield with + | SKSync, true -> FGenerator + | SKAsync, true -> FAsyncGenerator + | SKSync, false -> FSync + | SKAsync, false -> FAsync + (* TODO(t17335630): Implement an FCoroutine fun_kind *) + | SKCoroutine, false -> assert false + | SKCoroutine, true -> raise (Failure "Couroutine functions may not yield") + +let fun_template yielding node suspension_kind = let p = get_pos node in { f_mode = !(lowerer_state.mode) ; f_tparams = [] @@ -360,7 +375,7 @@ let fun_template yielding node is_sync = ; f_params = [] ; f_body = [] ; f_user_attributes = [] - ; f_fun_kind = mk_fun_kind is_sync yielding + ; f_fun_kind = mk_fun_kind suspension_kind yielding ; f_namespace = Namespace_env.empty !(lowerer_state.popt) ; f_span = p } @@ -547,8 +562,10 @@ and pExpr ?top_level:(top_level=true) : expr parser = fun node env -> let rec pExpr_ : expr_ parser = fun node env -> let pos = get_pos node in match syntax node with - | LambdaExpression { lambda_async; lambda_signature; lambda_body; _ } -> - let is_sync = is_missing lambda_async in + | LambdaExpression { + lambda_async; lambda_coroutine; lambda_signature; lambda_body; _ } -> + let suspension_kind = + mk_suspension_kind lambda_async lambda_coroutine in let f_params, f_ret = match syntax lambda_signature with | LambdaSignature { lambda_parameters; lambda_type; _ } -> @@ -566,7 +583,7 @@ and pExpr ?top_level:(top_level=true) : expr parser = fun node env -> in let f_body, yield = mpYielding pBody lambda_body env in Lfun - { (fun_template yield node is_sync) with f_ret; f_params; f_body } + { (fun_template yield node suspension_kind) with f_ret; f_params; f_body } | BracedExpression { braced_expression_expression = expr; _ } | EmbeddedBracedExpression @@ -777,6 +794,7 @@ and pExpr ?top_level:(top_level=true) : expr parser = fun node env -> *) | AnonymousFunction { anonymous_async_keyword + ; anonymous_coroutine_keyword ; anonymous_parameters ; anonymous_type ; anonymous_use @@ -796,10 +814,13 @@ and pExpr ?top_level:(top_level=true) : expr parser = fun node env -> couldMap ~f:pArg anonymous_use_variables | _ -> fun _env -> [] in - let is_sync = is_missing anonymous_async_keyword in + let suspension_kind = + mk_suspension_kind + anonymous_async_keyword + anonymous_coroutine_keyword in let body, yield = mpYielding pBlock anonymous_body env in Efun - ( { (fun_template yield node is_sync) with + ( { (fun_template yield node suspension_kind) with f_ret = mpOptional pHint anonymous_type env ; f_params = couldMap ~f:pFunParam anonymous_parameters env ; f_body = mk_noop body @@ -808,11 +829,12 @@ and pExpr ?top_level:(top_level=true) : expr parser = fun node env -> ) | AwaitableCreationExpression - { awaitable_async; awaitable_compound_statement } -> - let is_sync = is_missing awaitable_async in + { awaitable_async; awaitable_coroutine; awaitable_compound_statement } -> + let suspension_kind = + mk_suspension_kind awaitable_async awaitable_coroutine in let blk, yld = mpYielding pBlock awaitable_compound_statement env in let body = - { (fun_template yld node is_sync) with f_body = mk_noop blk } + { (fun_template yld node suspension_kind) with f_body = mk_noop blk } in Call ((get_pos node, Lfun body), [], []) | XHPExpression @@ -1079,7 +1101,7 @@ let pTParaml : tparam list parser = fun node env -> | _ -> missing_syntax "type parameter list" node env type fun_hdr = - { fh_is_sync : bool + { fh_suspension_kind : suspension_kind ; fh_name : pstring ; fh_type_parameters : tparam list ; fh_parameters : fun_param list @@ -1089,7 +1111,7 @@ type fun_hdr = } let empty_fun_hdr = - { fh_is_sync = false + { fh_suspension_kind = SKSync ; fh_name = Pos.none, "" ; fh_type_parameters = [] ; fh_parameters = [] @@ -1103,6 +1125,7 @@ let pFunHdr : fun_hdr parser = fun node env -> match syntax node with | FunctionDeclarationHeader { function_async + ; function_coroutine ; function_name ; function_type_parameter_list ; function_parameter_list @@ -1119,7 +1142,9 @@ let pFunHdr : fun_hdr parser = fun node env -> | "__destruct" -> Some (pos, Happly ((pos, "void"), [])), true | _ -> None, false in - { fh_is_sync = is_missing function_async + let fh_suspension_kind = + mk_suspension_kind function_async function_coroutine in + { fh_suspension_kind ; fh_name = pos_name function_name ; fh_type_parameters = pTParaml function_type_parameter_list env ; fh_parameters @@ -1251,7 +1276,7 @@ let pClassElt : class_elt list parser = fun node env -> ; m_ret = hdr.fh_return_type ; m_ret_by_ref = false ; m_span = get_pos node - ; m_fun_kind = mk_fun_kind hdr.fh_is_sync body_has_yield + ; m_fun_kind = mk_fun_kind hdr.fh_suspension_kind body_has_yield }] | TraitUse { trait_use_names; _ } -> couldMap ~f:(fun n e -> ClassUse (pHint n e)) trait_use_names env @@ -1313,7 +1338,7 @@ and pDef : def parser = fun node env -> let hdr = pFunHdr function_declaration_header env in let block, yield = mpYielding (mpOptional pBlock) function_body env in Fun - { (fun_template yield node hdr.fh_is_sync) with + { (fun_template yield node hdr.fh_suspension_kind) with f_tparams = hdr.fh_type_parameters ; f_ret = hdr.fh_return_type ; f_name = hdr.fh_name diff --git a/hphp/hack/src/parser/full_fidelity_declaration_parser.ml b/hphp/hack/src/parser/full_fidelity_declaration_parser.ml index b0fd725d7c0..480f8230c4a 100644 --- a/hphp/hack/src/parser/full_fidelity_declaration_parser.ml +++ b/hphp/hack/src/parser/full_fidelity_declaration_parser.ml @@ -834,6 +834,7 @@ module WithExpressionAndStatementAndTypeParser if is_missing attribute_spec then match peek_token_kind parser with | Async + | Coroutine | Function -> parse_methodish parser attribute_spec modifiers | _ -> parse_property_declaration parser modifiers else @@ -1189,7 +1190,7 @@ module WithExpressionAndStatementAndTypeParser and parse_function_declaration_header parser = (* SPEC function-definition-header: - attribute-specification-opt async-opt function name / + attribute-specification-opt async-opt coroutine-opt function name / generic-type-parameter-list-opt ( parameter-list-opt ) : / return-type where-clause-opt @@ -1202,6 +1203,7 @@ module WithExpressionAndStatementAndTypeParser TODO: Produce an error if this occurs in strict mode, or if it TODO: appears before a special name like __construct, and so on. *) let (parser, async_token) = optional_token parser Async in + let (parser, coroutine_token) = optional_token parser Coroutine in let (parser, function_token) = expect_function parser in let (parser, ampersand_token) = optional_token parser Ampersand in let (parser, label) = @@ -1213,10 +1215,20 @@ module WithExpressionAndStatementAndTypeParser let (parser, colon_token, return_type) = parse_return_type_hint_opt parser in let (parser, where_clause) = parse_where_clause_opt parser in - let syntax = make_function_declaration_header async_token - function_token ampersand_token label generic_type_parameter_list - left_paren_token parameter_list right_paren_token colon_token - return_type where_clause in + let syntax = + make_function_declaration_header + async_token + coroutine_token + function_token + ampersand_token + label + generic_type_parameter_list + left_paren_token + parameter_list + right_paren_token + colon_token + return_type + where_clause in (parser, syntax) (* A function label is either a function name, a __construct label, or a @@ -1313,7 +1325,7 @@ module WithExpressionAndStatementAndTypeParser | Enum -> parse_enum_declaration parser attribute_specification | Type | Newtype -> parse_alias_declaration parser attribute_specification - | Async | Function -> + | Async | Coroutine | Function -> parse_function_declaration parser attribute_specification | Abstract | Final @@ -1345,6 +1357,7 @@ module WithExpressionAndStatementAndTypeParser | Final | Class -> parse_classish_declaration parser(make_missing()) | Async + | Coroutine | Function -> parse_function_declaration parser (make_missing()) | LessThanLessThan -> parse_enum_or_classish_or_function_declaration parser diff --git a/hphp/hack/src/parser/full_fidelity_expression_parser.ml b/hphp/hack/src/parser/full_fidelity_expression_parser.ml index be3c4d326c2..57cf0c732ff 100644 --- a/hphp/hack/src/parser/full_fidelity_expression_parser.ml +++ b/hphp/hack/src/parser/full_fidelity_expression_parser.ml @@ -162,7 +162,8 @@ module WithStatementAndDeclAndTypeParser | Function -> parse_anon parser | DollarDollar -> (parser1, make_pipe_variable_expression (make_token token)) - | Async -> parse_anon_or_lambda_or_awaitable parser + | Async + | Coroutine -> parse_anon_or_lambda_or_awaitable parser | Include | Include_once | Require @@ -861,6 +862,7 @@ TODO: This will need to be fixed to allow situations where the qualified name | Const | Construct | Continue + | Coroutine | Darray | Dict | Default @@ -1128,10 +1130,11 @@ TODO: This will need to be fixed to allow situations where the qualified name async-opt lambda-function-signature ==> lambda-body *) let (parser, async) = optional_token parser Async in + let (parser, coroutine) = optional_token parser Coroutine in let (parser, signature) = parse_lambda_signature parser in let (parser, arrow) = expect_lambda_arrow parser in let (parser, body) = parse_lambda_body parser in - let result = make_lambda_expression async signature arrow body in + let result = make_lambda_expression async coroutine signature arrow body in (parser, result) and parse_lambda_signature parser = @@ -1645,7 +1648,11 @@ TODO: This will need to be fixed to allow situations where the qualified name and parse_anon_or_lambda_or_awaitable parser = (* TODO: The original Hack parser accepts "async" as an identifier, and so we do too. We might consider making it reserved. *) - let (parser1, _) = assert_token parser Async in + (* Skip any async or coroutine declarations that may be present. When we + feed the original parser into the syntax parsers. they will take care of + them as appropriate. *) + let (parser1, _) = optional_token parser Async in + let (parser1, _) = optional_token parser1 Coroutine in match peek_token_kind parser1 with | Function -> parse_anon parser | LeftBrace -> parse_async_block parser @@ -1657,13 +1664,14 @@ TODO: This will need to be fixed to allow situations where the qualified name (* * grammar: * awaitable-creation-expression : - * async compound-statement + * async-opt coroutine-opt compound-statement * TODO awaitable-creation-expression must not be used as the * anonymous-function-body in a lambda-expression *) - let parser, async = assert_token parser Async in + let parser, async = optional_token parser Async in + let parser, coroutine = optional_token parser Coroutine in let parser, stmt = parse_compound_statement parser in - parser, make_awaitable_creation_expression async stmt + parser, make_awaitable_creation_expression async coroutine stmt and parse_anon_use_opt parser = (* SPEC: @@ -1703,7 +1711,7 @@ TODO: This will need to be fixed to allow situations where the qualified name and parse_anon parser = (* SPEC anonymous-function-creation-expression: - async-opt function + async-opt coroutine-opt function ( anonymous-function-parameter-list-opt ) anonymous-function-return-opt anonymous-function-use-clauseopt @@ -1715,14 +1723,25 @@ TODO: This will need to be fixed to allow situations where the qualified name parse an optional parameter list; it already takes care of making the type annotations optional. *) let (parser, async) = optional_token parser Async in + let (parser, coroutine) = optional_token parser Coroutine in let (parser, fn) = assert_token parser Function in let (parser, left_paren, params, right_paren) = parse_parameter_list_opt parser in let (parser, colon, return_type) = parse_optional_return parser in let (parser, use_clause) = parse_anon_use_opt parser in let (parser, body) = parse_compound_statement parser in - let result = make_anonymous_function async fn left_paren params - right_paren colon return_type use_clause body in + let result = + make_anonymous_function + async + coroutine + fn + left_paren + params + right_paren + colon + return_type + use_clause + body in (parser, result) and parse_braced_expression parser = diff --git a/hphp/hack/src/parser/full_fidelity_pretty_printer.ml b/hphp/hack/src/parser/full_fidelity_pretty_printer.ml index e1ea0080d54..7aa07497fa8 100644 --- a/hphp/hack/src/parser/full_fidelity_pretty_printer.ml +++ b/hphp/hack/src/parser/full_fidelity_pretty_printer.ml @@ -460,13 +460,24 @@ let rec get_doc node = let after_attr = handle_compound_inline_brace header body missing in group_doc (attr ^| after_attr) | FunctionDeclarationHeader - { function_async; function_keyword; function_ampersand; function_name; - function_type_parameter_list; function_left_paren; - function_parameter_list; function_right_paren; function_colon; - function_type; function_where_clause } + { function_async; + function_coroutine; + function_keyword; + function_ampersand; + function_name; + function_type_parameter_list; + function_left_paren; + function_parameter_list; + function_right_paren; + function_colon; + function_type; + function_where_clause } -> - let preface = group_doc ( get_doc function_async - ^| get_doc function_keyword) in + let preface = group_doc ( + get_doc function_async + ^| get_doc function_coroutine + ^| get_doc function_keyword + ) in let name_and_generics = let type_params = get_doc function_type_parameter_list in let ampersand = get_doc function_ampersand in @@ -813,12 +824,19 @@ let rec get_doc node = let r = get_doc x.cast_right_paren in let o = get_doc x.cast_operand in group_doc (l ^^^ t ^^^ r ^^^ o) - | LambdaExpression x -> - let async = get_doc x.lambda_async in - let signature = get_doc x.lambda_signature in - let arrow = get_doc x.lambda_arrow in - let body = get_doc x.lambda_body in - group_doc (async ^| signature ^| arrow ^| body) + | LambdaExpression { + lambda_async; + lambda_coroutine; + lambda_signature; + lambda_arrow; + lambda_body; + } -> + let async = get_doc lambda_async in + let coroutine = get_doc lambda_coroutine in + let signature = get_doc lambda_signature in + let arrow = get_doc lambda_arrow in + let body = get_doc lambda_body in + group_doc (async ^| coroutine ^| signature ^| arrow ^| body) | LambdaSignature { lambda_left_paren; lambda_parameters; lambda_right_paren; lambda_colon; lambda_type } -> @@ -830,6 +848,7 @@ let rec get_doc node = group_doc (left ^| params ^| right ^| colon ^| ty) | AnonymousFunction { anonymous_async_keyword; + anonymous_coroutine_keyword; anonymous_function_keyword; anonymous_left_paren; anonymous_parameters; @@ -839,13 +858,14 @@ let rec get_doc node = anonymous_use; anonymous_body } -> let async = get_doc anonymous_async_keyword in + let coroutine = get_doc anonymous_coroutine_keyword in let fn = get_doc anonymous_function_keyword in let left = get_doc anonymous_left_paren in let params = get_doc anonymous_parameters in let right = get_doc anonymous_right_paren in let colon = get_doc anonymous_colon in let return_type = get_doc anonymous_type in - let preface = group_doc ( async ^| fn ) in + let preface = group_doc ( async ^| coroutine ^| fn ) in let parameters = indent_block_no_space left params right indt in let type_declaration = group_doc (colon ^| return_type) in let uses = get_doc anonymous_use in @@ -1102,8 +1122,9 @@ let rec get_doc node = receiver ^^^ left ^^^ index ^^^ right | AwaitableCreationExpression x -> let async = get_doc x.awaitable_async in + let coroutine = get_doc x.awaitable_coroutine in let stmt = x.awaitable_compound_statement in - handle_compound_brace_prefix_indent async stmt indt + handle_compound_brace_prefix_indent (async ^| coroutine) stmt indt | XHPExpression x -> let left = get_doc x.xhp_open in let expr = get_doc x.xhp_body in diff --git a/hphp/hack/src/parser/full_fidelity_syntax.ml b/hphp/hack/src/parser/full_fidelity_syntax.ml index ba88e0119c2..a3e005da108 100644 --- a/hphp/hack/src/parser/full_fidelity_syntax.ml +++ b/hphp/hack/src/parser/full_fidelity_syntax.ml @@ -196,6 +196,7 @@ module WithToken(Token: TokenType) = struct } and function_declaration_header = { function_async: t; + function_coroutine: t; function_keyword: t; function_ampersand: t; function_name: t; @@ -479,6 +480,7 @@ module WithToken(Token: TokenType) = struct } and anonymous_function = { anonymous_async_keyword: t; + anonymous_coroutine_keyword: t; anonymous_function_keyword: t; anonymous_left_paren: t; anonymous_parameters: t; @@ -496,6 +498,7 @@ module WithToken(Token: TokenType) = struct } and lambda_expression = { lambda_async: t; + lambda_coroutine: t; lambda_signature: t; lambda_arrow: t; lambda_body: t; @@ -690,6 +693,7 @@ module WithToken(Token: TokenType) = struct } and awaitable_creation_expression = { awaitable_async: t; + awaitable_coroutine: t; awaitable_compound_statement: t; } and xhp_children_declaration = { @@ -1877,6 +1881,7 @@ module WithToken(Token: TokenType) = struct let get_function_declaration_header_children { function_async; + function_coroutine; function_keyword; function_ampersand; function_name; @@ -1889,6 +1894,7 @@ module WithToken(Token: TokenType) = struct function_where_clause; } = ( function_async, + function_coroutine, function_keyword, function_ampersand, function_name, @@ -2443,6 +2449,7 @@ module WithToken(Token: TokenType) = struct let get_anonymous_function_children { anonymous_async_keyword; + anonymous_coroutine_keyword; anonymous_function_keyword; anonymous_left_paren; anonymous_parameters; @@ -2453,6 +2460,7 @@ module WithToken(Token: TokenType) = struct anonymous_body; } = ( anonymous_async_keyword, + anonymous_coroutine_keyword, anonymous_function_keyword, anonymous_left_paren, anonymous_parameters, @@ -2477,11 +2485,13 @@ module WithToken(Token: TokenType) = struct let get_lambda_expression_children { lambda_async; + lambda_coroutine; lambda_signature; lambda_arrow; lambda_body; } = ( lambda_async, + lambda_coroutine, lambda_signature, lambda_arrow, lambda_body @@ -2865,9 +2875,11 @@ module WithToken(Token: TokenType) = struct let get_awaitable_creation_expression_children { awaitable_async; + awaitable_coroutine; awaitable_compound_statement; } = ( awaitable_async, + awaitable_coroutine, awaitable_compound_statement ) @@ -3465,6 +3477,7 @@ module WithToken(Token: TokenType) = struct ] | FunctionDeclarationHeader { function_async; + function_coroutine; function_keyword; function_ampersand; function_name; @@ -3477,6 +3490,7 @@ module WithToken(Token: TokenType) = struct function_where_clause; } -> [ function_async; + function_coroutine; function_keyword; function_ampersand; function_name; @@ -3984,6 +3998,7 @@ module WithToken(Token: TokenType) = struct ] | AnonymousFunction { anonymous_async_keyword; + anonymous_coroutine_keyword; anonymous_function_keyword; anonymous_left_paren; anonymous_parameters; @@ -3994,6 +4009,7 @@ module WithToken(Token: TokenType) = struct anonymous_body; } -> [ anonymous_async_keyword; + anonymous_coroutine_keyword; anonymous_function_keyword; anonymous_left_paren; anonymous_parameters; @@ -4016,11 +4032,13 @@ module WithToken(Token: TokenType) = struct ] | LambdaExpression { lambda_async; + lambda_coroutine; lambda_signature; lambda_arrow; lambda_body; } -> [ lambda_async; + lambda_coroutine; lambda_signature; lambda_arrow; lambda_body; @@ -4369,9 +4387,11 @@ module WithToken(Token: TokenType) = struct ] | AwaitableCreationExpression { awaitable_async; + awaitable_coroutine; awaitable_compound_statement; } -> [ awaitable_async; + awaitable_coroutine; awaitable_compound_statement; ] | XHPChildrenDeclaration { @@ -4931,6 +4951,7 @@ module WithToken(Token: TokenType) = struct ] | FunctionDeclarationHeader { function_async; + function_coroutine; function_keyword; function_ampersand; function_name; @@ -4943,6 +4964,7 @@ module WithToken(Token: TokenType) = struct function_where_clause; } -> [ "function_async"; + "function_coroutine"; "function_keyword"; "function_ampersand"; "function_name"; @@ -5450,6 +5472,7 @@ module WithToken(Token: TokenType) = struct ] | AnonymousFunction { anonymous_async_keyword; + anonymous_coroutine_keyword; anonymous_function_keyword; anonymous_left_paren; anonymous_parameters; @@ -5460,6 +5483,7 @@ module WithToken(Token: TokenType) = struct anonymous_body; } -> [ "anonymous_async_keyword"; + "anonymous_coroutine_keyword"; "anonymous_function_keyword"; "anonymous_left_paren"; "anonymous_parameters"; @@ -5482,11 +5506,13 @@ module WithToken(Token: TokenType) = struct ] | LambdaExpression { lambda_async; + lambda_coroutine; lambda_signature; lambda_arrow; lambda_body; } -> [ "lambda_async"; + "lambda_coroutine"; "lambda_signature"; "lambda_arrow"; "lambda_body"; @@ -5835,9 +5861,11 @@ module WithToken(Token: TokenType) = struct ] | AwaitableCreationExpression { awaitable_async; + awaitable_coroutine; awaitable_compound_statement; } -> [ "awaitable_async"; + "awaitable_coroutine"; "awaitable_compound_statement"; ] | XHPChildrenDeclaration { @@ -6470,6 +6498,7 @@ module WithToken(Token: TokenType) = struct } | (SyntaxKind.FunctionDeclarationHeader, [ function_async; + function_coroutine; function_keyword; function_ampersand; function_name; @@ -6483,6 +6512,7 @@ module WithToken(Token: TokenType) = struct ]) -> FunctionDeclarationHeader { function_async; + function_coroutine; function_keyword; function_ampersand; function_name; @@ -7036,6 +7066,7 @@ module WithToken(Token: TokenType) = struct } | (SyntaxKind.AnonymousFunction, [ anonymous_async_keyword; + anonymous_coroutine_keyword; anonymous_function_keyword; anonymous_left_paren; anonymous_parameters; @@ -7047,6 +7078,7 @@ module WithToken(Token: TokenType) = struct ]) -> AnonymousFunction { anonymous_async_keyword; + anonymous_coroutine_keyword; anonymous_function_keyword; anonymous_left_paren; anonymous_parameters; @@ -7070,12 +7102,14 @@ module WithToken(Token: TokenType) = struct } | (SyntaxKind.LambdaExpression, [ lambda_async; + lambda_coroutine; lambda_signature; lambda_arrow; lambda_body; ]) -> LambdaExpression { lambda_async; + lambda_coroutine; lambda_signature; lambda_arrow; lambda_body; @@ -7458,10 +7492,12 @@ module WithToken(Token: TokenType) = struct } | (SyntaxKind.AwaitableCreationExpression, [ awaitable_async; + awaitable_coroutine; awaitable_compound_statement; ]) -> AwaitableCreationExpression { awaitable_async; + awaitable_coroutine; awaitable_compound_statement; } | (SyntaxKind.XHPChildrenDeclaration, [ @@ -8133,6 +8169,7 @@ module WithToken(Token: TokenType) = struct let make_function_declaration_header function_async + function_coroutine function_keyword function_ampersand function_name @@ -8146,6 +8183,7 @@ module WithToken(Token: TokenType) = struct = from_children SyntaxKind.FunctionDeclarationHeader [ function_async; + function_coroutine; function_keyword; function_ampersand; function_name; @@ -8746,6 +8784,7 @@ module WithToken(Token: TokenType) = struct let make_anonymous_function anonymous_async_keyword + anonymous_coroutine_keyword anonymous_function_keyword anonymous_left_paren anonymous_parameters @@ -8757,6 +8796,7 @@ module WithToken(Token: TokenType) = struct = from_children SyntaxKind.AnonymousFunction [ anonymous_async_keyword; + anonymous_coroutine_keyword; anonymous_function_keyword; anonymous_left_paren; anonymous_parameters; @@ -8782,12 +8822,14 @@ module WithToken(Token: TokenType) = struct let make_lambda_expression lambda_async + lambda_coroutine lambda_signature lambda_arrow lambda_body = from_children SyntaxKind.LambdaExpression [ lambda_async; + lambda_coroutine; lambda_signature; lambda_arrow; lambda_body; @@ -9205,10 +9247,12 @@ module WithToken(Token: TokenType) = struct let make_awaitable_creation_expression awaitable_async + awaitable_coroutine awaitable_compound_statement = from_children SyntaxKind.AwaitableCreationExpression [ awaitable_async; + awaitable_coroutine; awaitable_compound_statement; ] diff --git a/hphp/hack/src/parser/full_fidelity_token_kind.ml b/hphp/hack/src/parser/full_fidelity_token_kind.ml index f4235adfed8..b8cdf3b7188 100644 --- a/hphp/hack/src/parser/full_fidelity_token_kind.ml +++ b/hphp/hack/src/parser/full_fidelity_token_kind.ml @@ -40,6 +40,7 @@ type t = | Const | Construct | Continue + | Coroutine | Darray | Default | Define @@ -233,6 +234,7 @@ let from_string keyword = | "const" -> Some Const | "__construct" -> Some Construct | "continue" -> Some Continue + | "coroutine" -> Some Coroutine | "darray" -> Some Darray | "default" -> Some Default | "define" -> Some Define @@ -398,6 +400,7 @@ match kind with | Const -> "const" | Construct -> "__construct" | Continue -> "continue" + | Coroutine -> "coroutine" | Darray -> "darray" | Default -> "default" | Define -> "define" diff --git a/hphp/hack/src/parser/js/full_fidelity_editable.js b/hphp/hack/src/parser/js/full_fidelity_editable.js index d2365277b67..b5609530610 100644 --- a/hphp/hack/src/parser/js/full_fidelity_editable.js +++ b/hphp/hack/src/parser/js/full_fidelity_editable.js @@ -693,6 +693,8 @@ class EditableToken extends EditableSyntax return new ConstructToken(leading, trailing); case 'continue': return new ContinueToken(leading, trailing); + case 'coroutine': + return new CoroutineToken(leading, trailing); case 'darray': return new DarrayToken(leading, trailing); case 'default': @@ -1230,6 +1232,13 @@ class ContinueToken extends EditableToken super('continue', leading, trailing, 'continue'); } } +class CoroutineToken extends EditableToken +{ + constructor(leading, trailing) + { + super('coroutine', leading, trailing, 'coroutine'); + } +} class DarrayToken extends EditableToken { constructor(leading, trailing) @@ -4485,6 +4494,7 @@ class FunctionDeclarationHeader extends EditableSyntax { constructor( async, + coroutine, keyword, ampersand, name, @@ -4498,6 +4508,7 @@ class FunctionDeclarationHeader extends EditableSyntax { super('function_declaration_header', { async: async, + coroutine: coroutine, keyword: keyword, ampersand: ampersand, name: name, @@ -4510,6 +4521,7 @@ class FunctionDeclarationHeader extends EditableSyntax where_clause: where_clause }); } get async() { return this.children.async; } + get coroutine() { return this.children.coroutine; } get keyword() { return this.children.keyword; } get ampersand() { return this.children.ampersand; } get name() { return this.children.name; } @@ -4523,6 +4535,22 @@ class FunctionDeclarationHeader extends EditableSyntax with_async(async){ return new FunctionDeclarationHeader( async, + this.coroutine, + this.keyword, + this.ampersand, + this.name, + this.type_parameter_list, + this.left_paren, + this.parameter_list, + this.right_paren, + this.colon, + this.type, + this.where_clause); + } + with_coroutine(coroutine){ + return new FunctionDeclarationHeader( + this.async, + coroutine, this.keyword, this.ampersand, this.name, @@ -4537,6 +4565,7 @@ class FunctionDeclarationHeader extends EditableSyntax with_keyword(keyword){ return new FunctionDeclarationHeader( this.async, + this.coroutine, keyword, this.ampersand, this.name, @@ -4551,6 +4580,7 @@ class FunctionDeclarationHeader extends EditableSyntax with_ampersand(ampersand){ return new FunctionDeclarationHeader( this.async, + this.coroutine, this.keyword, ampersand, this.name, @@ -4565,6 +4595,7 @@ class FunctionDeclarationHeader extends EditableSyntax with_name(name){ return new FunctionDeclarationHeader( this.async, + this.coroutine, this.keyword, this.ampersand, name, @@ -4579,6 +4610,7 @@ class FunctionDeclarationHeader extends EditableSyntax with_type_parameter_list(type_parameter_list){ return new FunctionDeclarationHeader( this.async, + this.coroutine, this.keyword, this.ampersand, this.name, @@ -4593,6 +4625,7 @@ class FunctionDeclarationHeader extends EditableSyntax with_left_paren(left_paren){ return new FunctionDeclarationHeader( this.async, + this.coroutine, this.keyword, this.ampersand, this.name, @@ -4607,6 +4640,7 @@ class FunctionDeclarationHeader extends EditableSyntax with_parameter_list(parameter_list){ return new FunctionDeclarationHeader( this.async, + this.coroutine, this.keyword, this.ampersand, this.name, @@ -4621,6 +4655,7 @@ class FunctionDeclarationHeader extends EditableSyntax with_right_paren(right_paren){ return new FunctionDeclarationHeader( this.async, + this.coroutine, this.keyword, this.ampersand, this.name, @@ -4635,6 +4670,7 @@ class FunctionDeclarationHeader extends EditableSyntax with_colon(colon){ return new FunctionDeclarationHeader( this.async, + this.coroutine, this.keyword, this.ampersand, this.name, @@ -4649,6 +4685,7 @@ class FunctionDeclarationHeader extends EditableSyntax with_type(type){ return new FunctionDeclarationHeader( this.async, + this.coroutine, this.keyword, this.ampersand, this.name, @@ -4663,6 +4700,7 @@ class FunctionDeclarationHeader extends EditableSyntax with_where_clause(where_clause){ return new FunctionDeclarationHeader( this.async, + this.coroutine, this.keyword, this.ampersand, this.name, @@ -4681,6 +4719,7 @@ class FunctionDeclarationHeader extends EditableSyntax let new_parents = parents.slice(); new_parents.push(this); var async = this.async.rewrite(rewriter, new_parents); + var coroutine = this.coroutine.rewrite(rewriter, new_parents); var keyword = this.keyword.rewrite(rewriter, new_parents); var ampersand = this.ampersand.rewrite(rewriter, new_parents); var name = this.name.rewrite(rewriter, new_parents); @@ -4693,6 +4732,7 @@ class FunctionDeclarationHeader extends EditableSyntax var where_clause = this.where_clause.rewrite(rewriter, new_parents); if ( async === this.async && + coroutine === this.coroutine && keyword === this.keyword && ampersand === this.ampersand && name === this.name && @@ -4710,6 +4750,7 @@ class FunctionDeclarationHeader extends EditableSyntax { return rewriter(new FunctionDeclarationHeader( async, + coroutine, keyword, ampersand, name, @@ -4727,6 +4768,9 @@ class FunctionDeclarationHeader extends EditableSyntax let async = EditableSyntax.from_json( json.function_async, position, source); position += async.width; + let coroutine = EditableSyntax.from_json( + json.function_coroutine, position, source); + position += coroutine.width; let keyword = EditableSyntax.from_json( json.function_keyword, position, source); position += keyword.width; @@ -4759,6 +4803,7 @@ class FunctionDeclarationHeader extends EditableSyntax position += where_clause.width; return new FunctionDeclarationHeader( async, + coroutine, keyword, ampersand, name, @@ -4775,6 +4820,7 @@ class FunctionDeclarationHeader extends EditableSyntax if (FunctionDeclarationHeader._children_keys == null) FunctionDeclarationHeader._children_keys = [ 'async', + 'coroutine', 'keyword', 'ampersand', 'name', @@ -9670,6 +9716,7 @@ class AnonymousFunction extends EditableSyntax { constructor( async_keyword, + coroutine_keyword, function_keyword, left_paren, parameters, @@ -9681,6 +9728,7 @@ class AnonymousFunction extends EditableSyntax { super('anonymous_function', { async_keyword: async_keyword, + coroutine_keyword: coroutine_keyword, function_keyword: function_keyword, left_paren: left_paren, parameters: parameters, @@ -9691,6 +9739,7 @@ class AnonymousFunction extends EditableSyntax body: body }); } get async_keyword() { return this.children.async_keyword; } + get coroutine_keyword() { return this.children.coroutine_keyword; } get function_keyword() { return this.children.function_keyword; } get left_paren() { return this.children.left_paren; } get parameters() { return this.children.parameters; } @@ -9702,6 +9751,20 @@ class AnonymousFunction extends EditableSyntax with_async_keyword(async_keyword){ return new AnonymousFunction( async_keyword, + this.coroutine_keyword, + this.function_keyword, + this.left_paren, + this.parameters, + this.right_paren, + this.colon, + this.type, + this.use, + this.body); + } + with_coroutine_keyword(coroutine_keyword){ + return new AnonymousFunction( + this.async_keyword, + coroutine_keyword, this.function_keyword, this.left_paren, this.parameters, @@ -9714,6 +9777,7 @@ class AnonymousFunction extends EditableSyntax with_function_keyword(function_keyword){ return new AnonymousFunction( this.async_keyword, + this.coroutine_keyword, function_keyword, this.left_paren, this.parameters, @@ -9726,6 +9790,7 @@ class AnonymousFunction extends EditableSyntax with_left_paren(left_paren){ return new AnonymousFunction( this.async_keyword, + this.coroutine_keyword, this.function_keyword, left_paren, this.parameters, @@ -9738,6 +9803,7 @@ class AnonymousFunction extends EditableSyntax with_parameters(parameters){ return new AnonymousFunction( this.async_keyword, + this.coroutine_keyword, this.function_keyword, this.left_paren, parameters, @@ -9750,6 +9816,7 @@ class AnonymousFunction extends EditableSyntax with_right_paren(right_paren){ return new AnonymousFunction( this.async_keyword, + this.coroutine_keyword, this.function_keyword, this.left_paren, this.parameters, @@ -9762,6 +9829,7 @@ class AnonymousFunction extends EditableSyntax with_colon(colon){ return new AnonymousFunction( this.async_keyword, + this.coroutine_keyword, this.function_keyword, this.left_paren, this.parameters, @@ -9774,6 +9842,7 @@ class AnonymousFunction extends EditableSyntax with_type(type){ return new AnonymousFunction( this.async_keyword, + this.coroutine_keyword, this.function_keyword, this.left_paren, this.parameters, @@ -9786,6 +9855,7 @@ class AnonymousFunction extends EditableSyntax with_use(use){ return new AnonymousFunction( this.async_keyword, + this.coroutine_keyword, this.function_keyword, this.left_paren, this.parameters, @@ -9798,6 +9868,7 @@ class AnonymousFunction extends EditableSyntax with_body(body){ return new AnonymousFunction( this.async_keyword, + this.coroutine_keyword, this.function_keyword, this.left_paren, this.parameters, @@ -9814,6 +9885,7 @@ class AnonymousFunction extends EditableSyntax let new_parents = parents.slice(); new_parents.push(this); var async_keyword = this.async_keyword.rewrite(rewriter, new_parents); + var coroutine_keyword = this.coroutine_keyword.rewrite(rewriter, new_parents); var function_keyword = this.function_keyword.rewrite(rewriter, new_parents); var left_paren = this.left_paren.rewrite(rewriter, new_parents); var parameters = this.parameters.rewrite(rewriter, new_parents); @@ -9824,6 +9896,7 @@ class AnonymousFunction extends EditableSyntax var body = this.body.rewrite(rewriter, new_parents); if ( async_keyword === this.async_keyword && + coroutine_keyword === this.coroutine_keyword && function_keyword === this.function_keyword && left_paren === this.left_paren && parameters === this.parameters && @@ -9839,6 +9912,7 @@ class AnonymousFunction extends EditableSyntax { return rewriter(new AnonymousFunction( async_keyword, + coroutine_keyword, function_keyword, left_paren, parameters, @@ -9854,6 +9928,9 @@ class AnonymousFunction extends EditableSyntax let async_keyword = EditableSyntax.from_json( json.anonymous_async_keyword, position, source); position += async_keyword.width; + let coroutine_keyword = EditableSyntax.from_json( + json.anonymous_coroutine_keyword, position, source); + position += coroutine_keyword.width; let function_keyword = EditableSyntax.from_json( json.anonymous_function_keyword, position, source); position += function_keyword.width; @@ -9880,6 +9957,7 @@ class AnonymousFunction extends EditableSyntax position += body.width; return new AnonymousFunction( async_keyword, + coroutine_keyword, function_keyword, left_paren, parameters, @@ -9894,6 +9972,7 @@ class AnonymousFunction extends EditableSyntax if (AnonymousFunction._children_keys == null) AnonymousFunction._children_keys = [ 'async_keyword', + 'coroutine_keyword', 'function_keyword', 'left_paren', 'parameters', @@ -10013,23 +10092,35 @@ class LambdaExpression extends EditableSyntax { constructor( async, + coroutine, signature, arrow, body) { super('lambda_expression', { async: async, + coroutine: coroutine, signature: signature, arrow: arrow, body: body }); } get async() { return this.children.async; } + get coroutine() { return this.children.coroutine; } get signature() { return this.children.signature; } get arrow() { return this.children.arrow; } get body() { return this.children.body; } with_async(async){ return new LambdaExpression( async, + this.coroutine, + this.signature, + this.arrow, + this.body); + } + with_coroutine(coroutine){ + return new LambdaExpression( + this.async, + coroutine, this.signature, this.arrow, this.body); @@ -10037,6 +10128,7 @@ class LambdaExpression extends EditableSyntax with_signature(signature){ return new LambdaExpression( this.async, + this.coroutine, signature, this.arrow, this.body); @@ -10044,6 +10136,7 @@ class LambdaExpression extends EditableSyntax with_arrow(arrow){ return new LambdaExpression( this.async, + this.coroutine, this.signature, arrow, this.body); @@ -10051,6 +10144,7 @@ class LambdaExpression extends EditableSyntax with_body(body){ return new LambdaExpression( this.async, + this.coroutine, this.signature, this.arrow, body); @@ -10062,11 +10156,13 @@ class LambdaExpression extends EditableSyntax let new_parents = parents.slice(); new_parents.push(this); var async = this.async.rewrite(rewriter, new_parents); + var coroutine = this.coroutine.rewrite(rewriter, new_parents); var signature = this.signature.rewrite(rewriter, new_parents); var arrow = this.arrow.rewrite(rewriter, new_parents); var body = this.body.rewrite(rewriter, new_parents); if ( async === this.async && + coroutine === this.coroutine && signature === this.signature && arrow === this.arrow && body === this.body) @@ -10077,6 +10173,7 @@ class LambdaExpression extends EditableSyntax { return rewriter(new LambdaExpression( async, + coroutine, signature, arrow, body), parents); @@ -10087,6 +10184,9 @@ class LambdaExpression extends EditableSyntax let async = EditableSyntax.from_json( json.lambda_async, position, source); position += async.width; + let coroutine = EditableSyntax.from_json( + json.lambda_coroutine, position, source); + position += coroutine.width; let signature = EditableSyntax.from_json( json.lambda_signature, position, source); position += signature.width; @@ -10098,6 +10198,7 @@ class LambdaExpression extends EditableSyntax position += body.width; return new LambdaExpression( async, + coroutine, signature, arrow, body); @@ -10107,6 +10208,7 @@ class LambdaExpression extends EditableSyntax if (LambdaExpression._children_keys == null) LambdaExpression._children_keys = [ 'async', + 'coroutine', 'signature', 'arrow', 'body']; @@ -13331,22 +13433,33 @@ class AwaitableCreationExpression extends EditableSyntax { constructor( async, + coroutine, compound_statement) { super('awaitable_creation_expression', { async: async, + coroutine: coroutine, compound_statement: compound_statement }); } get async() { return this.children.async; } + get coroutine() { return this.children.coroutine; } get compound_statement() { return this.children.compound_statement; } with_async(async){ return new AwaitableCreationExpression( async, + this.coroutine, + this.compound_statement); + } + with_coroutine(coroutine){ + return new AwaitableCreationExpression( + this.async, + coroutine, this.compound_statement); } with_compound_statement(compound_statement){ return new AwaitableCreationExpression( this.async, + this.coroutine, compound_statement); } rewrite(rewriter, parents) @@ -13356,9 +13469,11 @@ class AwaitableCreationExpression extends EditableSyntax let new_parents = parents.slice(); new_parents.push(this); var async = this.async.rewrite(rewriter, new_parents); + var coroutine = this.coroutine.rewrite(rewriter, new_parents); var compound_statement = this.compound_statement.rewrite(rewriter, new_parents); if ( async === this.async && + coroutine === this.coroutine && compound_statement === this.compound_statement) { return rewriter(this, parents); @@ -13367,6 +13482,7 @@ class AwaitableCreationExpression extends EditableSyntax { return rewriter(new AwaitableCreationExpression( async, + coroutine, compound_statement), parents); } } @@ -13375,11 +13491,15 @@ class AwaitableCreationExpression extends EditableSyntax let async = EditableSyntax.from_json( json.awaitable_async, position, source); position += async.width; + let coroutine = EditableSyntax.from_json( + json.awaitable_coroutine, position, source); + position += coroutine.width; let compound_statement = EditableSyntax.from_json( json.awaitable_compound_statement, position, source); position += compound_statement.width; return new AwaitableCreationExpression( async, + coroutine, compound_statement); } get children_keys() @@ -13387,6 +13507,7 @@ class AwaitableCreationExpression extends EditableSyntax if (AwaitableCreationExpression._children_keys == null) AwaitableCreationExpression._children_keys = [ 'async', + 'coroutine', 'compound_statement']; return AwaitableCreationExpression._children_keys; } @@ -16918,6 +17039,7 @@ exports.CloneToken = CloneToken; exports.ConstToken = ConstToken; exports.ConstructToken = ConstructToken; exports.ContinueToken = ContinueToken; +exports.CoroutineToken = CoroutineToken; exports.DarrayToken = DarrayToken; exports.DefaultToken = DefaultToken; exports.DefineToken = DefineToken; diff --git a/hphp/hack/src/parser/js/full_fidelity_schema.json b/hphp/hack/src/parser/js/full_fidelity_schema.json index 3163502bb21..ef8ef49432f 100644 --- a/hphp/hack/src/parser/js/full_fidelity_schema.json +++ b/hphp/hack/src/parser/js/full_fidelity_schema.json @@ -1,6 +1,6 @@ { "description" : "Auto-generated JSON schema of the Hack Full Fidelity Parser AST", - "version" : "2017-04-06-0002", + "version" : "2017-04-17-0001", "trivia" : [ { "trivia_kind_name" : "WhiteSpace", "trivia_type_name" : "whitespace" }, @@ -63,6 +63,8 @@ "token_text" : "__construct" }, { "token_kind" : "Continue", "token_text" : "continue" }, + { "token_kind" : "Coroutine", + "token_text" : "coroutine" }, { "token_kind" : "Darray", "token_text" : "darray" }, { "token_kind" : "Default", @@ -582,6 +584,7 @@ "prefix" : "function", "fields" : [ { "field_name" : "async" }, + { "field_name" : "coroutine" }, { "field_name" : "keyword" }, { "field_name" : "ampersand" }, { "field_name" : "name" }, @@ -1053,6 +1056,7 @@ "prefix" : "anonymous", "fields" : [ { "field_name" : "async_keyword" }, + { "field_name" : "coroutine_keyword" }, { "field_name" : "function_keyword" }, { "field_name" : "left_paren" }, { "field_name" : "parameters" }, @@ -1078,6 +1082,7 @@ "prefix" : "lambda", "fields" : [ { "field_name" : "async" }, + { "field_name" : "coroutine" }, { "field_name" : "signature" }, { "field_name" : "arrow" }, { "field_name" : "body" } @@ -1412,6 +1417,7 @@ "prefix" : "awaitable", "fields" : [ { "field_name" : "async" }, + { "field_name" : "coroutine" }, { "field_name" : "compound_statement" } ] }, { "kind_name" : "XHPChildrenDeclaration", diff --git a/hphp/hack/src/parser/php/full_fidelity_editable.php b/hphp/hack/src/parser/php/full_fidelity_editable.php index 4696de34951..d39673d4fa3 100644 --- a/hphp/hack/src/parser/php/full_fidelity_editable.php +++ b/hphp/hack/src/parser/php/full_fidelity_editable.php @@ -798,6 +798,8 @@ abstract class EditableToken extends EditableSyntax { return new ConstructToken($leading, $trailing); case 'continue': return new ContinueToken($leading, $trailing); + case 'coroutine': + return new CoroutineToken($leading, $trailing); case 'darray': return new DarrayToken($leading, $trailing); case 'default': @@ -1509,6 +1511,21 @@ final class ContinueToken extends EditableToken { return new ContinueToken($this->leading(), $trailing); } } +final class CoroutineToken extends EditableToken { + public function __construct( + EditableSyntax $leading, + EditableSyntax $trailing) { + parent::__construct('coroutine', $leading, $trailing, 'coroutine'); + } + + public function with_leading(EditableSyntax $leading): CoroutineToken { + return new CoroutineToken($leading, $this->trailing()); + } + + public function with_trailing(EditableSyntax $trailing): CoroutineToken { + return new CoroutineToken($this->leading(), $trailing); + } +} final class DarrayToken extends EditableToken { public function __construct( EditableSyntax $leading, @@ -6180,6 +6197,7 @@ final class FunctionDeclaration extends EditableSyntax { } final class FunctionDeclarationHeader extends EditableSyntax { private EditableSyntax $_async; + private EditableSyntax $_coroutine; private EditableSyntax $_keyword; private EditableSyntax $_ampersand; private EditableSyntax $_name; @@ -6192,6 +6210,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { private EditableSyntax $_where_clause; public function __construct( EditableSyntax $async, + EditableSyntax $coroutine, EditableSyntax $keyword, EditableSyntax $ampersand, EditableSyntax $name, @@ -6204,6 +6223,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { EditableSyntax $where_clause) { parent::__construct('function_declaration_header'); $this->_async = $async; + $this->_coroutine = $coroutine; $this->_keyword = $keyword; $this->_ampersand = $ampersand; $this->_name = $name; @@ -6218,6 +6238,9 @@ final class FunctionDeclarationHeader extends EditableSyntax { public function async(): EditableSyntax { return $this->_async; } + public function coroutine(): EditableSyntax { + return $this->_coroutine; + } public function keyword(): EditableSyntax { return $this->_keyword; } @@ -6251,6 +6274,22 @@ final class FunctionDeclarationHeader extends EditableSyntax { public function with_async(EditableSyntax $async): FunctionDeclarationHeader { return new FunctionDeclarationHeader( $async, + $this->_coroutine, + $this->_keyword, + $this->_ampersand, + $this->_name, + $this->_type_parameter_list, + $this->_left_paren, + $this->_parameter_list, + $this->_right_paren, + $this->_colon, + $this->_type, + $this->_where_clause); + } + public function with_coroutine(EditableSyntax $coroutine): FunctionDeclarationHeader { + return new FunctionDeclarationHeader( + $this->_async, + $coroutine, $this->_keyword, $this->_ampersand, $this->_name, @@ -6265,6 +6304,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { public function with_keyword(EditableSyntax $keyword): FunctionDeclarationHeader { return new FunctionDeclarationHeader( $this->_async, + $this->_coroutine, $keyword, $this->_ampersand, $this->_name, @@ -6279,6 +6319,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { public function with_ampersand(EditableSyntax $ampersand): FunctionDeclarationHeader { return new FunctionDeclarationHeader( $this->_async, + $this->_coroutine, $this->_keyword, $ampersand, $this->_name, @@ -6293,6 +6334,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { public function with_name(EditableSyntax $name): FunctionDeclarationHeader { return new FunctionDeclarationHeader( $this->_async, + $this->_coroutine, $this->_keyword, $this->_ampersand, $name, @@ -6307,6 +6349,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { public function with_type_parameter_list(EditableSyntax $type_parameter_list): FunctionDeclarationHeader { return new FunctionDeclarationHeader( $this->_async, + $this->_coroutine, $this->_keyword, $this->_ampersand, $this->_name, @@ -6321,6 +6364,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { public function with_left_paren(EditableSyntax $left_paren): FunctionDeclarationHeader { return new FunctionDeclarationHeader( $this->_async, + $this->_coroutine, $this->_keyword, $this->_ampersand, $this->_name, @@ -6335,6 +6379,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { public function with_parameter_list(EditableSyntax $parameter_list): FunctionDeclarationHeader { return new FunctionDeclarationHeader( $this->_async, + $this->_coroutine, $this->_keyword, $this->_ampersand, $this->_name, @@ -6349,6 +6394,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { public function with_right_paren(EditableSyntax $right_paren): FunctionDeclarationHeader { return new FunctionDeclarationHeader( $this->_async, + $this->_coroutine, $this->_keyword, $this->_ampersand, $this->_name, @@ -6363,6 +6409,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { public function with_colon(EditableSyntax $colon): FunctionDeclarationHeader { return new FunctionDeclarationHeader( $this->_async, + $this->_coroutine, $this->_keyword, $this->_ampersand, $this->_name, @@ -6377,6 +6424,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { public function with_type(EditableSyntax $type): FunctionDeclarationHeader { return new FunctionDeclarationHeader( $this->_async, + $this->_coroutine, $this->_keyword, $this->_ampersand, $this->_name, @@ -6391,6 +6439,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { public function with_where_clause(EditableSyntax $where_clause): FunctionDeclarationHeader { return new FunctionDeclarationHeader( $this->_async, + $this->_coroutine, $this->_keyword, $this->_ampersand, $this->_name, @@ -6410,6 +6459,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { $new_parents = $parents ?? []; array_push($new_parents, $this); $async = $this->async()->rewrite($rewriter, $new_parents); + $coroutine = $this->coroutine()->rewrite($rewriter, $new_parents); $keyword = $this->keyword()->rewrite($rewriter, $new_parents); $ampersand = $this->ampersand()->rewrite($rewriter, $new_parents); $name = $this->name()->rewrite($rewriter, $new_parents); @@ -6422,6 +6472,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { $where_clause = $this->where_clause()->rewrite($rewriter, $new_parents); if ( $async === $this->async() && + $coroutine === $this->coroutine() && $keyword === $this->keyword() && $ampersand === $this->ampersand() && $name === $this->name() && @@ -6436,6 +6487,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { } else { return $rewriter(new FunctionDeclarationHeader( $async, + $coroutine, $keyword, $ampersand, $name, @@ -6453,6 +6505,9 @@ final class FunctionDeclarationHeader extends EditableSyntax { $async = EditableSyntax::from_json( $json->function_async, $position, $source); $position += $async->width(); + $coroutine = EditableSyntax::from_json( + $json->function_coroutine, $position, $source); + $position += $coroutine->width(); $keyword = EditableSyntax::from_json( $json->function_keyword, $position, $source); $position += $keyword->width(); @@ -6485,6 +6540,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { $position += $where_clause->width(); return new FunctionDeclarationHeader( $async, + $coroutine, $keyword, $ampersand, $name, @@ -6498,6 +6554,7 @@ final class FunctionDeclarationHeader extends EditableSyntax { } public function children(): Generator { yield $this->_async; + yield $this->_coroutine; yield $this->_keyword; yield $this->_ampersand; yield $this->_name; @@ -11603,6 +11660,7 @@ final class SimpleInitializer extends EditableSyntax { } final class AnonymousFunction extends EditableSyntax { private EditableSyntax $_async_keyword; + private EditableSyntax $_coroutine_keyword; private EditableSyntax $_function_keyword; private EditableSyntax $_left_paren; private EditableSyntax $_parameters; @@ -11613,6 +11671,7 @@ final class AnonymousFunction extends EditableSyntax { private EditableSyntax $_body; public function __construct( EditableSyntax $async_keyword, + EditableSyntax $coroutine_keyword, EditableSyntax $function_keyword, EditableSyntax $left_paren, EditableSyntax $parameters, @@ -11623,6 +11682,7 @@ final class AnonymousFunction extends EditableSyntax { EditableSyntax $body) { parent::__construct('anonymous_function'); $this->_async_keyword = $async_keyword; + $this->_coroutine_keyword = $coroutine_keyword; $this->_function_keyword = $function_keyword; $this->_left_paren = $left_paren; $this->_parameters = $parameters; @@ -11635,6 +11695,9 @@ final class AnonymousFunction extends EditableSyntax { public function async_keyword(): EditableSyntax { return $this->_async_keyword; } + public function coroutine_keyword(): EditableSyntax { + return $this->_coroutine_keyword; + } public function function_keyword(): EditableSyntax { return $this->_function_keyword; } @@ -11662,6 +11725,20 @@ final class AnonymousFunction extends EditableSyntax { public function with_async_keyword(EditableSyntax $async_keyword): AnonymousFunction { return new AnonymousFunction( $async_keyword, + $this->_coroutine_keyword, + $this->_function_keyword, + $this->_left_paren, + $this->_parameters, + $this->_right_paren, + $this->_colon, + $this->_type, + $this->_use, + $this->_body); + } + public function with_coroutine_keyword(EditableSyntax $coroutine_keyword): AnonymousFunction { + return new AnonymousFunction( + $this->_async_keyword, + $coroutine_keyword, $this->_function_keyword, $this->_left_paren, $this->_parameters, @@ -11674,6 +11751,7 @@ final class AnonymousFunction extends EditableSyntax { public function with_function_keyword(EditableSyntax $function_keyword): AnonymousFunction { return new AnonymousFunction( $this->_async_keyword, + $this->_coroutine_keyword, $function_keyword, $this->_left_paren, $this->_parameters, @@ -11686,6 +11764,7 @@ final class AnonymousFunction extends EditableSyntax { public function with_left_paren(EditableSyntax $left_paren): AnonymousFunction { return new AnonymousFunction( $this->_async_keyword, + $this->_coroutine_keyword, $this->_function_keyword, $left_paren, $this->_parameters, @@ -11698,6 +11777,7 @@ final class AnonymousFunction extends EditableSyntax { public function with_parameters(EditableSyntax $parameters): AnonymousFunction { return new AnonymousFunction( $this->_async_keyword, + $this->_coroutine_keyword, $this->_function_keyword, $this->_left_paren, $parameters, @@ -11710,6 +11790,7 @@ final class AnonymousFunction extends EditableSyntax { public function with_right_paren(EditableSyntax $right_paren): AnonymousFunction { return new AnonymousFunction( $this->_async_keyword, + $this->_coroutine_keyword, $this->_function_keyword, $this->_left_paren, $this->_parameters, @@ -11722,6 +11803,7 @@ final class AnonymousFunction extends EditableSyntax { public function with_colon(EditableSyntax $colon): AnonymousFunction { return new AnonymousFunction( $this->_async_keyword, + $this->_coroutine_keyword, $this->_function_keyword, $this->_left_paren, $this->_parameters, @@ -11734,6 +11816,7 @@ final class AnonymousFunction extends EditableSyntax { public function with_type(EditableSyntax $type): AnonymousFunction { return new AnonymousFunction( $this->_async_keyword, + $this->_coroutine_keyword, $this->_function_keyword, $this->_left_paren, $this->_parameters, @@ -11746,6 +11829,7 @@ final class AnonymousFunction extends EditableSyntax { public function with_use(EditableSyntax $use): AnonymousFunction { return new AnonymousFunction( $this->_async_keyword, + $this->_coroutine_keyword, $this->_function_keyword, $this->_left_paren, $this->_parameters, @@ -11758,6 +11842,7 @@ final class AnonymousFunction extends EditableSyntax { public function with_body(EditableSyntax $body): AnonymousFunction { return new AnonymousFunction( $this->_async_keyword, + $this->_coroutine_keyword, $this->_function_keyword, $this->_left_paren, $this->_parameters, @@ -11775,6 +11860,7 @@ final class AnonymousFunction extends EditableSyntax { $new_parents = $parents ?? []; array_push($new_parents, $this); $async_keyword = $this->async_keyword()->rewrite($rewriter, $new_parents); + $coroutine_keyword = $this->coroutine_keyword()->rewrite($rewriter, $new_parents); $function_keyword = $this->function_keyword()->rewrite($rewriter, $new_parents); $left_paren = $this->left_paren()->rewrite($rewriter, $new_parents); $parameters = $this->parameters()->rewrite($rewriter, $new_parents); @@ -11785,6 +11871,7 @@ final class AnonymousFunction extends EditableSyntax { $body = $this->body()->rewrite($rewriter, $new_parents); if ( $async_keyword === $this->async_keyword() && + $coroutine_keyword === $this->coroutine_keyword() && $function_keyword === $this->function_keyword() && $left_paren === $this->left_paren() && $parameters === $this->parameters() && @@ -11797,6 +11884,7 @@ final class AnonymousFunction extends EditableSyntax { } else { return $rewriter(new AnonymousFunction( $async_keyword, + $coroutine_keyword, $function_keyword, $left_paren, $parameters, @@ -11812,6 +11900,9 @@ final class AnonymousFunction extends EditableSyntax { $async_keyword = EditableSyntax::from_json( $json->anonymous_async_keyword, $position, $source); $position += $async_keyword->width(); + $coroutine_keyword = EditableSyntax::from_json( + $json->anonymous_coroutine_keyword, $position, $source); + $position += $coroutine_keyword->width(); $function_keyword = EditableSyntax::from_json( $json->anonymous_function_keyword, $position, $source); $position += $function_keyword->width(); @@ -11838,6 +11929,7 @@ final class AnonymousFunction extends EditableSyntax { $position += $body->width(); return new AnonymousFunction( $async_keyword, + $coroutine_keyword, $function_keyword, $left_paren, $parameters, @@ -11849,6 +11941,7 @@ final class AnonymousFunction extends EditableSyntax { } public function children(): Generator { yield $this->_async_keyword; + yield $this->_coroutine_keyword; yield $this->_function_keyword; yield $this->_left_paren; yield $this->_parameters; @@ -11971,16 +12064,19 @@ final class AnonymousFunctionUseClause extends EditableSyntax { } final class LambdaExpression extends EditableSyntax { private EditableSyntax $_async; + private EditableSyntax $_coroutine; private EditableSyntax $_signature; private EditableSyntax $_arrow; private EditableSyntax $_body; public function __construct( EditableSyntax $async, + EditableSyntax $coroutine, EditableSyntax $signature, EditableSyntax $arrow, EditableSyntax $body) { parent::__construct('lambda_expression'); $this->_async = $async; + $this->_coroutine = $coroutine; $this->_signature = $signature; $this->_arrow = $arrow; $this->_body = $body; @@ -11988,6 +12084,9 @@ final class LambdaExpression extends EditableSyntax { public function async(): EditableSyntax { return $this->_async; } + public function coroutine(): EditableSyntax { + return $this->_coroutine; + } public function signature(): EditableSyntax { return $this->_signature; } @@ -12000,6 +12099,15 @@ final class LambdaExpression extends EditableSyntax { public function with_async(EditableSyntax $async): LambdaExpression { return new LambdaExpression( $async, + $this->_coroutine, + $this->_signature, + $this->_arrow, + $this->_body); + } + public function with_coroutine(EditableSyntax $coroutine): LambdaExpression { + return new LambdaExpression( + $this->_async, + $coroutine, $this->_signature, $this->_arrow, $this->_body); @@ -12007,6 +12115,7 @@ final class LambdaExpression extends EditableSyntax { public function with_signature(EditableSyntax $signature): LambdaExpression { return new LambdaExpression( $this->_async, + $this->_coroutine, $signature, $this->_arrow, $this->_body); @@ -12014,6 +12123,7 @@ final class LambdaExpression extends EditableSyntax { public function with_arrow(EditableSyntax $arrow): LambdaExpression { return new LambdaExpression( $this->_async, + $this->_coroutine, $this->_signature, $arrow, $this->_body); @@ -12021,6 +12131,7 @@ final class LambdaExpression extends EditableSyntax { public function with_body(EditableSyntax $body): LambdaExpression { return new LambdaExpression( $this->_async, + $this->_coroutine, $this->_signature, $this->_arrow, $body); @@ -12033,11 +12144,13 @@ final class LambdaExpression extends EditableSyntax { $new_parents = $parents ?? []; array_push($new_parents, $this); $async = $this->async()->rewrite($rewriter, $new_parents); + $coroutine = $this->coroutine()->rewrite($rewriter, $new_parents); $signature = $this->signature()->rewrite($rewriter, $new_parents); $arrow = $this->arrow()->rewrite($rewriter, $new_parents); $body = $this->body()->rewrite($rewriter, $new_parents); if ( $async === $this->async() && + $coroutine === $this->coroutine() && $signature === $this->signature() && $arrow === $this->arrow() && $body === $this->body()) { @@ -12045,6 +12158,7 @@ final class LambdaExpression extends EditableSyntax { } else { return $rewriter(new LambdaExpression( $async, + $coroutine, $signature, $arrow, $body), $parents ?? []); @@ -12055,6 +12169,9 @@ final class LambdaExpression extends EditableSyntax { $async = EditableSyntax::from_json( $json->lambda_async, $position, $source); $position += $async->width(); + $coroutine = EditableSyntax::from_json( + $json->lambda_coroutine, $position, $source); + $position += $coroutine->width(); $signature = EditableSyntax::from_json( $json->lambda_signature, $position, $source); $position += $signature->width(); @@ -12066,12 +12183,14 @@ final class LambdaExpression extends EditableSyntax { $position += $body->width(); return new LambdaExpression( $async, + $coroutine, $signature, $arrow, $body); } public function children(): Generator { yield $this->_async; + yield $this->_coroutine; yield $this->_signature; yield $this->_arrow; yield $this->_body; @@ -15416,28 +15535,42 @@ final class EmbeddedSubscriptExpression extends EditableSyntax { } final class AwaitableCreationExpression extends EditableSyntax { private EditableSyntax $_async; + private EditableSyntax $_coroutine; private EditableSyntax $_compound_statement; public function __construct( EditableSyntax $async, + EditableSyntax $coroutine, EditableSyntax $compound_statement) { parent::__construct('awaitable_creation_expression'); $this->_async = $async; + $this->_coroutine = $coroutine; $this->_compound_statement = $compound_statement; } public function async(): EditableSyntax { return $this->_async; } + public function coroutine(): EditableSyntax { + return $this->_coroutine; + } public function compound_statement(): EditableSyntax { return $this->_compound_statement; } public function with_async(EditableSyntax $async): AwaitableCreationExpression { return new AwaitableCreationExpression( $async, + $this->_coroutine, + $this->_compound_statement); + } + public function with_coroutine(EditableSyntax $coroutine): AwaitableCreationExpression { + return new AwaitableCreationExpression( + $this->_async, + $coroutine, $this->_compound_statement); } public function with_compound_statement(EditableSyntax $compound_statement): AwaitableCreationExpression { return new AwaitableCreationExpression( $this->_async, + $this->_coroutine, $compound_statement); } @@ -15448,14 +15581,17 @@ final class AwaitableCreationExpression extends EditableSyntax { $new_parents = $parents ?? []; array_push($new_parents, $this); $async = $this->async()->rewrite($rewriter, $new_parents); + $coroutine = $this->coroutine()->rewrite($rewriter, $new_parents); $compound_statement = $this->compound_statement()->rewrite($rewriter, $new_parents); if ( $async === $this->async() && + $coroutine === $this->coroutine() && $compound_statement === $this->compound_statement()) { return $rewriter($this, $parents ?? []); } else { return $rewriter(new AwaitableCreationExpression( $async, + $coroutine, $compound_statement), $parents ?? []); } } @@ -15464,15 +15600,20 @@ final class AwaitableCreationExpression extends EditableSyntax { $async = EditableSyntax::from_json( $json->awaitable_async, $position, $source); $position += $async->width(); + $coroutine = EditableSyntax::from_json( + $json->awaitable_coroutine, $position, $source); + $position += $coroutine->width(); $compound_statement = EditableSyntax::from_json( $json->awaitable_compound_statement, $position, $source); $position += $compound_statement->width(); return new AwaitableCreationExpression( $async, + $coroutine, $compound_statement); } public function children(): Generator { yield $this->_async; + yield $this->_coroutine; yield $this->_compound_statement; yield break; } diff --git a/hphp/hack/src/parser/schema/full_fidelity_schema.ml b/hphp/hack/src/parser/schema/full_fidelity_schema.ml index 2cbb166c713..0e8611749a0 100644 --- a/hphp/hack/src/parser/schema/full_fidelity_schema.ml +++ b/hphp/hack/src/parser/schema/full_fidelity_schema.ml @@ -10,7 +10,7 @@ (* If you make changes to the schema that cause it to serialize / deserialize differently, please update this version number *) -let full_fidelity_schema_version_number = "2017-04-06-0002" +let full_fidelity_schema_version_number = "2017-04-17-0001" (* TODO: Consider basing the version number on an auto-generated hash of a file rather than relying on people remembering to update it. *) (* TODO: It may be worthwhile to investigate how Thrift describes data types @@ -226,6 +226,7 @@ let schema = List.map from_list [ "function_declaration_header"; "function"; "async"; + "coroutine"; "keyword"; "ampersand"; "name"; @@ -603,6 +604,7 @@ let schema = List.map from_list [ "anonymous_function"; "anonymous"; "async_keyword"; + "coroutine_keyword"; "function_keyword"; "left_paren"; "parameters"; @@ -624,6 +626,7 @@ let schema = List.map from_list [ "lambda_expression"; "lambda"; "async"; + "coroutine"; "signature"; "arrow"; "body" ]; @@ -888,6 +891,7 @@ let schema = List.map from_list [ "awaitable_creation_expression"; "awaitable"; "async"; + "coroutine"; "compound_statement" ]; [ "XHPChildrenDeclaration"; "xhp_children_declaration"; @@ -1219,6 +1223,7 @@ let given_text_tokens = List.map token_node_from_list [ [ "Const"; "const" ]; [ "Construct"; "__construct" ]; [ "Continue"; "continue" ]; + [ "Coroutine"; "coroutine" ]; [ "Darray"; "darray" ]; [ "Default"; "default" ]; [ "Define"; "define"]; diff --git a/hphp/hack/test/full_fidelity/cases/test_array_expression.exp b/hphp/hack/test/full_fidelity/cases/test_array_expression.exp dissimilarity index 100% index d10980987d0..2b9ed654b6a 100644 --- a/hphp/hack/test/full_fidelity/cases/test_array_expression.exp +++ b/hphp/hack/test/full_fidelity/cases/test_array_expression.exp @@ -1,53 +1 @@ -(script(header((<))((?))((name)(end_of_line))) -(list -(function_declaration -(missing) -(function_declaration_header -(missing)((function)(whitespace)) -(missing)((name))(missing)((lparen))(missing)((rparen))(missing)(missing)(missing)) -(compound_statement(({)(end_of_line)) - (list( - expression_statement(array_intrinsic_expression( - (whitespace)(array))((lparen))(missing)((rparen)))((;)(end_of_line))) - (expression_statement(array_intrinsic_expression( - (whitespace)(array)) - ((lparen)) - (list - (list_item(variable((variable)))(missing))) - ((rparen)))((;)(end_of_line))) - (expression_statement(array_intrinsic_expression( - (whitespace)(array)) - ((lparen)) - (list - (list_item(variable((variable)))((,)))) - ((rparen)))((;)(end_of_line))) - (expression_statement(array_intrinsic_expression( - (whitespace)(array)) - ((lparen)) - (list - (list_item(variable((variable)))((,)(whitespace))) - (list_item(variable((variable)))((,)(whitespace))) - (list_item(variable((variable)))(missing))) - ((rparen)))((;)(end_of_line))) - (expression_statement(array_creation_expression( - (whitespace)([))(missing)((])))((;)(end_of_line))) - (expression_statement(array_creation_expression( - (whitespace)([)) - (list - (list_item(variable((variable)))(missing)) - ) - ((]))) - ((;)(end_of_line))) - (expression_statement(array_creation_expression( - (whitespace)([)) - (list - (list_item(variable((variable)))((,)))) - ((]))) - ((;)(end_of_line))) - (expression_statement(array_creation_expression( - (whitespace)([))(list( - list_item(variable((variable)))((,))) - (list_item(variable((variable)))((,))) - (list_item(variable((variable)))(missing)) - )((])))((;)(end_of_line)))) -((})))))) +(script(header((<))((?))((name)(end_of_line)))(list(function_declaration(missing)(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name))(missing)((lparen))(missing)((rparen))(missing)(missing)(missing))(compound_statement(({)(end_of_line))(list(expression_statement(array_intrinsic_expression((whitespace)(array))((lparen))(missing)((rparen)))((;)(end_of_line)))(expression_statement(array_intrinsic_expression((whitespace)(array))((lparen))(list(list_item(variable((variable)))(missing)))((rparen)))((;)(end_of_line)))(expression_statement(array_intrinsic_expression((whitespace)(array))((lparen))(list(list_item(variable((variable)))((,))))((rparen)))((;)(end_of_line)))(expression_statement(array_intrinsic_expression((whitespace)(array))((lparen))(list(list_item(variable((variable)))((,)(whitespace)))(list_item(variable((variable)))((,)(whitespace)))(list_item(variable((variable)))(missing)))((rparen)))((;)(end_of_line)))(expression_statement(array_creation_expression((whitespace)([))(missing)((])))((;)(end_of_line)))(expression_statement(array_creation_expression((whitespace)([))(list(list_item(variable((variable)))(missing)))((])))((;)(end_of_line)))(expression_statement(array_creation_expression((whitespace)([))(list(list_item(variable((variable)))((,))))((])))((;)(end_of_line)))(expression_statement(array_creation_expression((whitespace)([))(list(list_item(variable((variable)))((,)))(list_item(variable((variable)))((,)))(list_item(variable((variable)))(missing)))((])))((;)(end_of_line))))((})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_array_key_value_precedence.exp b/hphp/hack/test/full_fidelity/cases/test_array_key_value_precedence.exp dissimilarity index 100% index 49015bb9d42..0c2787cafb4 100644 --- a/hphp/hack/test/full_fidelity/cases/test_array_key_value_precedence.exp +++ b/hphp/hack/test/full_fidelity/cases/test_array_key_value_precedence.exp @@ -1,29 +1 @@ -(script(header((<))((?))((name)(end_of_line))) -(list -(function_declaration -(missing) -(function_declaration_header -(missing)((function)(whitespace))(missing)((name))(missing) -((lparen))(missing)((rparen))(missing)(missing)(missing)) -(compound_statement(({) -(end_of_line)) -(list -(expression_statement( -prefix_unary_expression((whitespace) -(await)(whitespace)) -(binary_expression(variable((variable)(whitespace))) -((.)(whitespace)) -(array_intrinsic_expression( -(array)(whitespace)) -((lparen)) -(list -(list_item -(element_initializer(variable((variable)(whitespace))) -((=>)(whitespace)) -(binary_expression( -qualified_name((name)(whitespace))) -((*=)(whitespace)) -(literal((decimal_literal))))) -(missing))) -((rparen)))))((;)(end_of_line)))) -((})))))) +(script(header((<))((?))((name)(end_of_line)))(list(function_declaration(missing)(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name))(missing)((lparen))(missing)((rparen))(missing)(missing)(missing))(compound_statement(({)(end_of_line))(list(expression_statement(prefix_unary_expression((whitespace)(await)(whitespace))(binary_expression(variable((variable)(whitespace)))((.)(whitespace))(array_intrinsic_expression((array)(whitespace))((lparen))(list(list_item(element_initializer(variable((variable)(whitespace)))((=>)(whitespace))(binary_expression(qualified_name((name)(whitespace)))((*=)(whitespace))(literal((decimal_literal)))))(missing)))((rparen)))))((;)(end_of_line))))((})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_attribute_spec.exp b/hphp/hack/test/full_fidelity/cases/test_attribute_spec.exp dissimilarity index 100% index 5f071077244..2078e4c643b 100644 --- a/hphp/hack/test/full_fidelity/cases/test_attribute_spec.exp +++ b/hphp/hack/test/full_fidelity/cases/test_attribute_spec.exp @@ -1,35 +1 @@ -(script(header((<))((?))((name)(end_of_line))) -(list -(function_declaration -(attribute_specification((<<)) -(list -(list_item(attribute((name)) -((lparen))(missing)((rparen)))((,)(whitespace))) -(list_item -(attribute -((name)) -((lparen)) -(list -(list_item -(binary_expression( -literal((decimal_literal)))((+))(literal((decimal_literal)))) -(missing))) -((rparen))) -((,)(whitespace))) -(list_item -(attribute((name)) -((lparen)) -(list -(list_item(literal((decimal_literal)))((,)(whitespace))) -(list_item(literal((decimal_literal)))((,)(whitespace))) -(list_item(literal((decimal_literal)))((,)(whitespace))) -(list_item(literal((decimal_literal)))(missing))) -((rparen))) -(missing))) -((>>)(whitespace))) -(function_declaration_header -(missing) -((function)(whitespace))(missing)((name))(missing) -((lparen))(missing)((rparen) -(whitespace))(missing)(missing)(missing)) -(compound_statement(({))(missing)((})))))) +(script(header((<))((?))((name)(end_of_line)))(list(function_declaration(attribute_specification((<<))(list(list_item(attribute((name))((lparen))(missing)((rparen)))((,)(whitespace)))(list_item(attribute((name))((lparen))(list(list_item(binary_expression(literal((decimal_literal)))((+))(literal((decimal_literal))))(missing)))((rparen)))((,)(whitespace)))(list_item(attribute((name))((lparen))(list(list_item(literal((decimal_literal)))((,)(whitespace)))(list_item(literal((decimal_literal)))((,)(whitespace)))(list_item(literal((decimal_literal)))((,)(whitespace)))(list_item(literal((decimal_literal)))(missing)))((rparen)))(missing)))((>>)(whitespace)))(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name))(missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({))(missing)((})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_awaitable_creation.exp b/hphp/hack/test/full_fidelity/cases/test_awaitable_creation.exp dissimilarity index 100% index aae9f357b94..0e035778dd1 100644 --- a/hphp/hack/test/full_fidelity/cases/test_awaitable_creation.exp +++ b/hphp/hack/test/full_fidelity/cases/test_awaitable_creation.exp @@ -1,81 +1 @@ -(script(header((<))((?))((name)(end_of_line))) -(list -(function_declaration(missing) -(function_declaration_header(missing) -((function)(whitespace))(missing)((name)(whitespace))(missing) -((lparen))(missing)((rparen)(whitespace)) -(missing)(missing)(missing)) -(compound_statement -(({)(end_of_line)) -(list(expression_statement -(binary_expression(variable((whitespace)(variable)(whitespace))) -((=)(whitespace)) -(awaitable_creation_expression -((async)(whitespace)) -(compound_statement(({))(missing)((})))))((;)(end_of_line))) -(expression_statement -(binary_expression -(variable((whitespace)(variable)(whitespace))) -((=)(whitespace)) -(binary_expression -(awaitable_creation_expression -((async)(whitespace)) -(compound_statement(({))(missing)((})(whitespace)))) -((+)(whitespace)) -(literal((decimal_literal)))))((;)(end_of_line))) -(expression_statement -(binary_expression -(variable((whitespace)(variable)(whitespace))) -((=)(whitespace)) -(binary_expression -(literal((decimal_literal)(whitespace))) -((+)(whitespace)) -(awaitable_creation_expression -((async)(whitespace)) -(compound_statement -(({))(missing)((}))))))((;)(end_of_line))) -(expression_statement -(binary_expression -(variable((whitespace)(variable)(whitespace))) -((=)(whitespace)) -(binary_expression -(awaitable_creation_expression -((async)(whitespace)) -(compound_statement -(({))(missing)((})(whitespace)))) -((+)(whitespace)) -(awaitable_creation_expression -((async)(whitespace)) -(compound_statement(({))(missing)((}))))))((;)(end_of_line))) -(expression_statement -(binary_expression -(variable((whitespace)(variable)(whitespace))) -((=)(whitespace)) -(awaitable_creation_expression -((async)(whitespace)) -(compound_statement -(({)(end_of_line)) -(list -(expression_statement -(binary_expression -(variable((whitespace)(variable)(whitespace))) -((=)(whitespace))(literal((decimal_literal)))) -((;)(end_of_line)))) -((whitespace)(})))))((;)(end_of_line))) -(expression_statement -(binary_expression -(variable((whitespace)(variable)(whitespace)))((=)(whitespace)) -(awaitable_creation_expression((async)(whitespace)) -(compound_statement(({)(end_of_line)) -(list -(expression_statement -(binary_expression(variable((whitespace)(variable)(whitespace))) -((=)(whitespace)) -(binary_expression -(awaitable_creation_expression -((async)(whitespace)) -(compound_statement(({))(missing)((})(whitespace)))) -((+)(whitespace))(literal((decimal_literal))))) -((;)(end_of_line)))) -((whitespace)(}))))) -((;)(end_of_line))))((})))))) +(script(header((<))((?))((name)(end_of_line)))(list(function_declaration(missing)(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name)(whitespace))(missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({)(end_of_line))(list(expression_statement(binary_expression(variable((whitespace)(variable)(whitespace)))((=)(whitespace))(awaitable_creation_expression((async)(whitespace))(missing)(compound_statement(({))(missing)((})))))((;)(end_of_line)))(expression_statement(binary_expression(variable((whitespace)(variable)(whitespace)))((=)(whitespace))(binary_expression(awaitable_creation_expression((async)(whitespace))(missing)(compound_statement(({))(missing)((})(whitespace))))((+)(whitespace))(literal((decimal_literal)))))((;)(end_of_line)))(expression_statement(binary_expression(variable((whitespace)(variable)(whitespace)))((=)(whitespace))(binary_expression(literal((decimal_literal)(whitespace)))((+)(whitespace))(awaitable_creation_expression((async)(whitespace))(missing)(compound_statement(({))(missing)((}))))))((;)(end_of_line)))(expression_statement(binary_expression(variable((whitespace)(variable)(whitespace)))((=)(whitespace))(binary_expression(awaitable_creation_expression((async)(whitespace))(missing)(compound_statement(({))(missing)((})(whitespace))))((+)(whitespace))(awaitable_creation_expression((async)(whitespace))(missing)(compound_statement(({))(missing)((}))))))((;)(end_of_line)))(expression_statement(binary_expression(variable((whitespace)(variable)(whitespace)))((=)(whitespace))(awaitable_creation_expression((async)(whitespace))(missing)(compound_statement(({)(end_of_line))(list(expression_statement(binary_expression(variable((whitespace)(variable)(whitespace)))((=)(whitespace))(literal((decimal_literal))))((;)(end_of_line))))((whitespace)(})))))((;)(end_of_line)))(expression_statement(binary_expression(variable((whitespace)(variable)(whitespace)))((=)(whitespace))(awaitable_creation_expression((async)(whitespace))(missing)(compound_statement(({)(end_of_line))(list(expression_statement(binary_expression(variable((whitespace)(variable)(whitespace)))((=)(whitespace))(binary_expression(awaitable_creation_expression((async)(whitespace))(missing)(compound_statement(({))(missing)((})(whitespace))))((+)(whitespace))(literal((decimal_literal)))))((;)(end_of_line))))((whitespace)(})))))((;)(end_of_line))))((})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_class_method_declaration.exp b/hphp/hack/test/full_fidelity/cases/test_class_method_declaration.exp dissimilarity index 100% index d8954b4b6aa..43b391f34f6 100644 --- a/hphp/hack/test/full_fidelity/cases/test_class_method_declaration.exp +++ b/hphp/hack/test/full_fidelity/cases/test_class_method_declaration.exp @@ -1,92 +1 @@ -(script - (header((<))((?))((name)(end_of_line))) - (list - (classish_declaration - (missing)(missing) - ((class)(whitespace)) - ((name)(whitespace)) - (missing)(missing)(missing)(missing)(missing) - (classish_body - (({)(end_of_line)) - (list - (methodish_declaration - (missing) - (list - ((whitespace)(public)(whitespace)) - ((static)(whitespace))) - (function_declaration_header - (missing) - ((function)(whitespace)) - (missing) - ((name)(whitespace)) - (missing)((lparen)) - (missing)((rparen)(whitespace)) - ((:)(whitespace)) - (simple_type_specifier((void)(whitespace)))(missing)) - (compound_statement - (({))(missing)((})(end_of_line))) - (missing)) - (methodish_declaration - (missing) - (list - ((whitespace)(public) - (whitespace))((abstract) - (whitespace))) - (function_declaration_header - (missing) - ((function)(whitespace)) - (missing) - ((name)(whitespace)) - (missing)((lparen)) - (missing)((rparen)(whitespace)) - (missing)(missing)(missing)) - (missing) - ((;)(end_of_line))) - (methodish_declaration - (attribute_specification - ((whitespace)(<<)) - (list - (list_item - (attribute - ((name))(missing)(missing)(missing)) - (missing))) - ((>>)(whitespace))) - (list((public)(whitespace))) - (function_declaration_header - (missing) - ((function)(whitespace)) - (missing) - ((name)(whitespace))(missing) - ((lparen))(missing) - ((rparen)(whitespace)) - (missing)(missing)(missing)) - (compound_statement - (({))(missing)((})(end_of_line))) - (missing)) - (methodish_declaration - (attribute_specification - ((whitespace)(<<)) - (list - (list_item - (attribute((name)) - (missing) - (missing) - (missing)) - (missing))) - ((>>)(whitespace))) - (list - ((public)(whitespace)) - ((static)(whitespace))) - (function_declaration_header - (missing) - ((function)(whitespace)) - (missing) - ((name)(whitespace))(missing) - ((lparen))(missing) - ((rparen)(whitespace)) - ((:)(whitespace)) - (simple_type_specifier((void)(whitespace)))(missing)) - (compound_statement - (({))(missing)((})(end_of_line))) - (missing))) - ((})))))) +(script(header((<))((?))((name)(end_of_line)))(list(classish_declaration(missing)(missing)((class)(whitespace))((name)(whitespace))(missing)(missing)(missing)(missing)(missing)(classish_body(({)(end_of_line))(list(methodish_declaration(missing)(list((whitespace)(public)(whitespace))((static)(whitespace)))(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name)(whitespace))(missing)((lparen))(missing)((rparen)(whitespace))((:)(whitespace))(simple_type_specifier((void)(whitespace)))(missing))(compound_statement(({))(missing)((})(end_of_line)))(missing))(methodish_declaration(missing)(list((whitespace)(public)(whitespace))((abstract)(whitespace)))(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name)(whitespace))(missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing))(missing)((;)(end_of_line)))(methodish_declaration(attribute_specification((whitespace)(<<))(list(list_item(attribute((name))(missing)(missing)(missing))(missing)))((>>)(whitespace)))(list((public)(whitespace)))(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name)(whitespace))(missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({))(missing)((})(end_of_line)))(missing))(methodish_declaration(attribute_specification((whitespace)(<<))(list(list_item(attribute((name))(missing)(missing)(missing))(missing)))((>>)(whitespace)))(list((public)(whitespace))((static)(whitespace)))(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name)(whitespace))(missing)((lparen))(missing)((rparen)(whitespace))((:)(whitespace))(simple_type_specifier((void)(whitespace)))(missing))(compound_statement(({))(missing)((})(end_of_line)))(missing)))((})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_closure_type.exp b/hphp/hack/test/full_fidelity/cases/test_closure_type.exp dissimilarity index 94% index 9c4cd65aa79..c85a5a7f358 100644 --- a/hphp/hack/test/full_fidelity/cases/test_closure_type.exp +++ b/hphp/hack/test/full_fidelity/cases/test_closure_type.exp @@ -1,37 +1 @@ -(script(header((<))((?))((name)(whitespace)(single_line_comment)(end_of_line))) -(list -(function_declaration(missing) - (function_declaration_header(missing) - ((end_of_line)(function)(whitespace))(missing) - ((name)(whitespace))(missing) - ((lparen)) - (list - (list_item - (parameter_declaration(missing)(missing) - (closure_type_specifier - ((lparen)) - ((function)(whitespace)) - ((lparen)) - (list(list_item(variadic_parameter((...)))(missing))) - ((rparen)(whitespace))((:)(whitespace)) - (simple_type_specifier((int))) - ((rparen)(whitespace))) - ((variable))(missing)) - (missing))) - ((rparen)(whitespace)) - ((:)(whitespace)) - (simple_type_specifier((int)(whitespace)))(missing)) - (compound_statement - (({)(end_of_line)) - (list - (expression_statement - (function_call_expression - (qualified_name - ((whitespace)(name))) - ((lparen)) - (list - (list_item(literal((decimal_literal)))((,)(whitespace))) - (list_item(literal((decimal_literal)))((,)(whitespace))) - (list_item(literal((decimal_literal)))(missing))) - ((rparen)))((;)(end_of_line)))) - ((})))))) +(script(header((<))((?))((name)(whitespace)(single_line_comment)(end_of_line)))(list(function_declaration(missing)(function_declaration_header(missing)(missing)((end_of_line)(function)(whitespace))(missing)((name)(whitespace))(missing)((lparen))(list(list_item(parameter_declaration(missing)(missing)(closure_type_specifier((lparen))((function)(whitespace))((lparen))(list(list_item(variadic_parameter((...)))(missing)))((rparen)(whitespace))((:)(whitespace))(simple_type_specifier((int)))((rparen)(whitespace)))((variable))(missing))(missing)))((rparen)(whitespace))((:)(whitespace))(simple_type_specifier((int)(whitespace)))(missing))(compound_statement(({)(end_of_line))(list(expression_statement(function_call_expression(qualified_name((whitespace)(name)))((lparen))(list(list_item(literal((decimal_literal)))((,)(whitespace)))(list_item(literal((decimal_literal)))((,)(whitespace)))(list_item(literal((decimal_literal)))(missing)))((rparen)))((;)(end_of_line))))((})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_constructor_destructor.exp b/hphp/hack/test/full_fidelity/cases/test_constructor_destructor.exp dissimilarity index 99% index d70a3bb2bb7..037108d3b14 100644 --- a/hphp/hack/test/full_fidelity/cases/test_constructor_destructor.exp +++ b/hphp/hack/test/full_fidelity/cases/test_constructor_destructor.exp @@ -1,158 +1 @@ -(script(header((<))((?))((name)(end_of_line))) -(list -(classish_declaration(missing)(missing) -((end_of_line) -(class)(whitespace))((name)(whitespace)) -(missing)(missing)(missing)(missing)(missing) -(classish_body -(({)(end_of_line)) -(list -(methodish_declaration(missing) - (list((whitespace)(private)(whitespace))) - (function_declaration_header - (missing) - ((function)(whitespace)) - (missing) - ((__construct))(missing) - ((lparen)) - (list - (list_item - (parameter_declaration - (missing)(missing)(missing) - ((variable))(missing))(missing))) - ((rparen)(whitespace))(missing)(missing)(missing)) - (compound_statement(({))(missing)((})(end_of_line)))(missing)) -(methodish_declaration(missing) - (list((whitespace)(public)(whitespace))) - (function_declaration_header - (missing) - ((function)(whitespace)) - (missing) - ((__construct))(missing) - ((lparen)) - (list - (list_item - (parameter_declaration - (missing)(missing)(missing) - ((variable)(whitespace)) - (simple_initializer((=)(whitespace)) - (literal((null)))))(missing))) - ((rparen)(whitespace))(missing)(missing)(missing)) - (compound_statement(({))(missing)((})(end_of_line)))(missing)) -(methodish_declaration(missing) - (list((whitespace)(public)(whitespace))) - (function_declaration_header(missing) - ((function)(whitespace)) - (missing) - ((__construct))(missing) - ((lparen)) - (list - (list_item - (parameter_declaration - (missing)(missing)(missing) - ((variable))(missing))(missing))) - ((rparen)(whitespace)) - (missing)(missing)(missing)) - (compound_statement(({))(missing)((})(end_of_line)))(missing)) -(methodish_declaration(missing) - (list((whitespace)(private)(whitespace))) - (function_declaration_header(missing) - ((function)(whitespace)) - (missing) - ((__construct))(missing) - ((lparen)) - (list - (list_item - (parameter_declaration - (missing)(missing)(missing) - ((variable)(whitespace)) - (simple_initializer - ((=)(whitespace)) - (literal((null)))))(missing))) - ((rparen)(whitespace)) - (missing)(missing)(missing)) - (compound_statement - (({))(missing)((})(end_of_line)))(missing)) -(methodish_declaration - (attribute_specification - ((whitespace)(<<)) - (list - (list_item - (attribute((name))(missing)(missing)(missing)) - (missing))) - ((>>)(whitespace))) - (list((public)(whitespace))) - (function_declaration_header(missing) - ((function)(whitespace)) - (missing) - ((__construct)(whitespace))(missing) - ((lparen)) - (list - (list_item - (parameter_declaration(missing)(missing)(missing)((variable))(missing)) - (missing))) - ((rparen))(missing)(missing)(missing)) - (compound_statement(({))(missing)((})(end_of_line)))(missing)) -(methodish_declaration - (attribute_specification - ((whitespace)(<<)) - (list - (list_item - (attribute((name))(missing)(missing)(missing)) - (missing))) - ((>>)(whitespace))) - (list((public)(whitespace))) - (function_declaration_header(missing) - ((function)(whitespace)) - (missing) - ((__construct)(whitespace))(missing) - ((lparen)) - (list - (list_item - (parameter_declaration(missing)(missing)(missing)((variable))(missing)) - (missing))) - ((rparen)(whitespace))(missing)(missing)(missing)) - (compound_statement(({))(missing)((})(end_of_line)))(missing)) -(methodish_declaration(missing) - (list((whitespace)(public)(whitespace))) - (function_declaration_header - (missing) - ((function)(whitespace)) - (missing) - ((__construct)(whitespace))(missing) - ((lparen)) - (list - (list_item - (parameter_declaration(missing) - ((public)(whitespace))(missing) - ((variable)(whitespace)) - (simple_initializer - ((=)(whitespace)) - (literal((null))))) - (missing))) - ((rparen)(whitespace))(missing)(missing)(missing)) - (compound_statement(({))(missing)((})(end_of_line)))(missing)) -(methodish_declaration(missing) - (list((whitespace)(public)(whitespace))) - (function_declaration_header(missing) - ((function)(whitespace)) - (missing) - ((__destruct)(whitespace))(missing) - ((lparen))(missing) - ((rparen)(whitespace))(missing)(missing)(missing)) - (compound_statement(({))(missing)((})(end_of_line)))(missing)) - (methodish_declaration - (attribute_specification - ((whitespace)(<<)) - (list - (list_item - (attribute((name))(missing)(missing)(missing)) - (missing))) - ((>>)(whitespace))) - (list((public)(whitespace))) - (function_declaration_header(missing) - ((function)(whitespace)) - (missing) - ((__destruct)(whitespace))(missing) - ((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing)) - (compound_statement(({))(missing)((})(end_of_line)))(missing)))((})))))) +(script(header((<))((?))((name)(end_of_line)))(list(classish_declaration(missing)(missing)((end_of_line)(class)(whitespace))((name)(whitespace))(missing)(missing)(missing)(missing)(missing)(classish_body(({)(end_of_line))(list(methodish_declaration(missing)(list((whitespace)(private)(whitespace)))(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((__construct))(missing)((lparen))(list(list_item(parameter_declaration(missing)(missing)(missing)((variable))(missing))(missing)))((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({))(missing)((})(end_of_line)))(missing))(methodish_declaration(missing)(list((whitespace)(public)(whitespace)))(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((__construct))(missing)((lparen))(list(list_item(parameter_declaration(missing)(missing)(missing)((variable)(whitespace))(simple_initializer((=)(whitespace))(literal((null)))))(missing)))((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({))(missing)((})(end_of_line)))(missing))(methodish_declaration(missing)(list((whitespace)(public)(whitespace)))(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((__construct))(missing)((lparen))(list(list_item(parameter_declaration(missing)(missing)(missing)((variable))(missing))(missing)))((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({))(missing)((})(end_of_line)))(missing))(methodish_declaration(missing)(list((whitespace)(private)(whitespace)))(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((__construct))(missing)((lparen))(list(list_item(parameter_declaration(missing)(missing)(missing)((variable)(whitespace))(simple_initializer((=)(whitespace))(literal((null)))))(missing)))((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({))(missing)((})(end_of_line)))(missing))(methodish_declaration(attribute_specification((whitespace)(<<))(list(list_item(attribute((name))(missing)(missing)(missing))(missing)))((>>)(whitespace)))(list((public)(whitespace)))(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((__construct)(whitespace))(missing)((lparen))(list(list_item(parameter_declaration(missing)(missing)(missing)((variable))(missing))(missing)))((rparen))(missing)(missing)(missing))(compound_statement(({))(missing)((})(end_of_line)))(missing))(methodish_declaration(attribute_specification((whitespace)(<<))(list(list_item(attribute((name))(missing)(missing)(missing))(missing)))((>>)(whitespace)))(list((public)(whitespace)))(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((__construct)(whitespace))(missing)((lparen))(list(list_item(parameter_declaration(missing)(missing)(missing)((variable))(missing))(missing)))((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({))(missing)((})(end_of_line)))(missing))(methodish_declaration(missing)(list((whitespace)(public)(whitespace)))(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((__construct)(whitespace))(missing)((lparen))(list(list_item(parameter_declaration(missing)((public)(whitespace))(missing)((variable)(whitespace))(simple_initializer((=)(whitespace))(literal((null)))))(missing)))((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({))(missing)((})(end_of_line)))(missing))(methodish_declaration(missing)(list((whitespace)(public)(whitespace)))(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((__destruct)(whitespace))(missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({))(missing)((})(end_of_line)))(missing))(methodish_declaration(attribute_specification((whitespace)(<<))(list(list_item(attribute((name))(missing)(missing)(missing))(missing)))((>>)(whitespace)))(list((public)(whitespace)))(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((__destruct)(whitespace))(missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({))(missing)((})(end_of_line)))(missing)))((})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_for_statements.exp b/hphp/hack/test/full_fidelity/cases/test_for_statements.exp dissimilarity index 100% index a2514ff74bc..040d44327ad 100644 --- a/hphp/hack/test/full_fidelity/cases/test_for_statements.exp +++ b/hphp/hack/test/full_fidelity/cases/test_for_statements.exp @@ -1,139 +1 @@ -(script(header((<))((?))((name)(end_of_line))) -(list(function_declaration - (missing) - (function_declaration_header - (missing) - ((function)(whitespace)) - (missing) - ((name)) - (missing) - ((lparen)) - (missing) - ((rparen)(whitespace)) - (missing) - (missing) - (missing)) - (compound_statement(({)(end_of_line))(list - (for_statement - ((whitespace)(for)) - ((lparen)) - (list(list_item(variable((variable)))(missing))) - ((;)) - (list(list_item(variable((variable)))(missing))) - ((;)) - (list(list_item(variable((variable)))(missing))) - ((rparen)(whitespace)) - (compound_statement - (({)(end_of_line)) - (list(return_statement - ((whitespace)(return)(whitespace)) - (variable((variable))) - ((;)(end_of_line)))) - ((whitespace)(})(end_of_line)) - ) - ) - (for_statement - ((whitespace)(for)) - ((lparen)) - (list(list_item(variable((variable)))(missing))) - ((;)) - (list(list_item(variable((variable)))(missing))) - ((;)) - (list(list_item(variable((variable)))(missing))) - ((rparen)(whitespace)) - (compound_statement(({))(missing)((})(end_of_line))) - ) - (for_statement - ((whitespace)(for)) - ((lparen)) - (missing) - ((;)) - (list(list_item(variable((variable)))(missing))) - ((;)) - (list(list_item(variable((variable)))(missing))) - ((rparen)(whitespace)) - (compound_statement(({))(missing)((})(end_of_line))) - ) - (for_statement - ((whitespace)(for)) - ((lparen)) - (list(list_item(variable((variable)))(missing))) - ((;)) - (missing) - ((;)) - (list(list_item(variable((variable)))(missing))) - ((rparen)(whitespace)) - (compound_statement(({))(missing)((})(end_of_line))) - ) - (for_statement - ((whitespace)(for)) - ((lparen)) - (list(list_item(variable((variable)))(missing))) - ((;)) - (list(list_item(variable((variable)))(missing))) - ((;)) - (missing) - ((rparen)(whitespace)) - (compound_statement(({))(missing)((})(end_of_line))) - ) - (for_statement - ((whitespace)(for)) - ((lparen)) - (list(list_item(variable((variable)))(missing))) - ((;)) - (missing) - ((;)) - (missing) - ((rparen)(whitespace)) - (compound_statement(({))(missing)((})(end_of_line))) - ) - (for_statement - ((whitespace)(for)) - ((lparen)) - (missing) - ((;)) - (list(list_item(variable((variable)))(missing))) - ((;)) - (missing) - ((rparen)(whitespace)) - (compound_statement(({))(missing)((})(end_of_line))) - ) - (for_statement - ((whitespace)(for)) - ((lparen)) - (missing) - ((;)) - (missing) - ((;)) - (list(list_item(variable((variable)))(missing))) - ((rparen)(whitespace)) - (compound_statement(({))(missing)((})(end_of_line))) - ) - (for_statement - ((whitespace)(for)) - ((lparen)) - (list - (list_item(variable((variable)))((,)(whitespace))) - (list_item(variable((variable)))(missing)) - ) - ((;)) - (missing) - ((;)) - (missing) - ((rparen)(whitespace)) - (compound_statement(({))(missing)((})(end_of_line))) - ) - (for_statement - ((whitespace)(for)) - ((lparen)) - (missing) - ((;)) - (list - (list_item(variable((variable)))((,)(whitespace))) - (list_item(variable((variable)))((,)(whitespace))) - (list_item(variable((variable)))(missing))) - ((;)) - (missing) - ((rparen)(whitespace)) - (compound_statement(({))(missing)((})(end_of_line))))) - ((})))))) +(script(header((<))((?))((name)(end_of_line)))(list(function_declaration(missing)(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name))(missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({)(end_of_line))(list(for_statement((whitespace)(for))((lparen))(list(list_item(variable((variable)))(missing)))((;))(list(list_item(variable((variable)))(missing)))((;))(list(list_item(variable((variable)))(missing)))((rparen)(whitespace))(compound_statement(({)(end_of_line))(list(return_statement((whitespace)(return)(whitespace))(variable((variable)))((;)(end_of_line))))((whitespace)(})(end_of_line))))(for_statement((whitespace)(for))((lparen))(list(list_item(variable((variable)))(missing)))((;))(list(list_item(variable((variable)))(missing)))((;))(list(list_item(variable((variable)))(missing)))((rparen)(whitespace))(compound_statement(({))(missing)((})(end_of_line))))(for_statement((whitespace)(for))((lparen))(missing)((;))(list(list_item(variable((variable)))(missing)))((;))(list(list_item(variable((variable)))(missing)))((rparen)(whitespace))(compound_statement(({))(missing)((})(end_of_line))))(for_statement((whitespace)(for))((lparen))(list(list_item(variable((variable)))(missing)))((;))(missing)((;))(list(list_item(variable((variable)))(missing)))((rparen)(whitespace))(compound_statement(({))(missing)((})(end_of_line))))(for_statement((whitespace)(for))((lparen))(list(list_item(variable((variable)))(missing)))((;))(list(list_item(variable((variable)))(missing)))((;))(missing)((rparen)(whitespace))(compound_statement(({))(missing)((})(end_of_line))))(for_statement((whitespace)(for))((lparen))(list(list_item(variable((variable)))(missing)))((;))(missing)((;))(missing)((rparen)(whitespace))(compound_statement(({))(missing)((})(end_of_line))))(for_statement((whitespace)(for))((lparen))(missing)((;))(list(list_item(variable((variable)))(missing)))((;))(missing)((rparen)(whitespace))(compound_statement(({))(missing)((})(end_of_line))))(for_statement((whitespace)(for))((lparen))(missing)((;))(missing)((;))(list(list_item(variable((variable)))(missing)))((rparen)(whitespace))(compound_statement(({))(missing)((})(end_of_line))))(for_statement((whitespace)(for))((lparen))(list(list_item(variable((variable)))((,)(whitespace)))(list_item(variable((variable)))(missing)))((;))(missing)((;))(missing)((rparen)(whitespace))(compound_statement(({))(missing)((})(end_of_line))))(for_statement((whitespace)(for))((lparen))(missing)((;))(list(list_item(variable((variable)))((,)(whitespace)))(list_item(variable((variable)))((,)(whitespace)))(list_item(variable((variable)))(missing)))((;))(missing)((rparen)(whitespace))(compound_statement(({))(missing)((})(end_of_line)))))((})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_foreach_statements.exp b/hphp/hack/test/full_fidelity/cases/test_foreach_statements.exp dissimilarity index 100% index 494291e997d..358cd0f9e22 100644 --- a/hphp/hack/test/full_fidelity/cases/test_foreach_statements.exp +++ b/hphp/hack/test/full_fidelity/cases/test_foreach_statements.exp @@ -1,48 +1 @@ -(script(header((<))((?))((name)(end_of_line))) -(list -(function_declaration -(missing) -(function_declaration_header -(missing)((function)(whitespace))(missing)((name))(missing) -((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing)) -(compound_statement(({)(end_of_line))(list( - foreach_statement((whitespace) - (foreach)(whitespace))( - (lparen)) - (variable((variable)(whitespace)))(missing) - ((as)(whitespace))(missing)(missing) - (variable((variable))) - ((rparen)) - (compound_statement( - ({)(end_of_line))(missing)((whitespace)(})(end_of_line))) - ) - (foreach_statement((whitespace) - (foreach)(whitespace)) - ((lparen)) - (variable((variable)(whitespace)))(missing) - ((as)(whitespace))(variable((variable)(whitespace))) - ((=>)(whitespace))(variable((variable)))((rparen)) - (compound_statement( - ({)(end_of_line)) - (list(expression_statement( - postfix_unary_expression - (variable((whitespace)(variable))) - ((++)))((;)(end_of_line)))) - ((whitespace) - (})(end_of_line)))) - (foreach_statement((whitespace) - (foreach)(whitespace)) - ((lparen)) - (variable((variable)(whitespace)))((await)(whitespace)) - ((as)(whitespace))(missing)(missing)(variable((variable)))((rparen)) - (compound_statement( - ({)(end_of_line))(missing)((whitespace)(})(end_of_line)))) - (foreach_statement((whitespace) - (foreach)(whitespace)) - ((lparen)) - (variable((variable)(whitespace))) - ((await)(whitespace))((as)(whitespace)) - (variable((variable)(whitespace)))((=>)(whitespace))(variable((variable))) - ((rparen)) - (compound_statement( - ({)(end_of_line))(missing)((whitespace)(})(end_of_line)))))((})))))) +(script(header((<))((?))((name)(end_of_line)))(list(function_declaration(missing)(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name))(missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({)(end_of_line))(list(foreach_statement((whitespace)(foreach)(whitespace))((lparen))(variable((variable)(whitespace)))(missing)((as)(whitespace))(missing)(missing)(variable((variable)))((rparen))(compound_statement(({)(end_of_line))(missing)((whitespace)(})(end_of_line))))(foreach_statement((whitespace)(foreach)(whitespace))((lparen))(variable((variable)(whitespace)))(missing)((as)(whitespace))(variable((variable)(whitespace)))((=>)(whitespace))(variable((variable)))((rparen))(compound_statement(({)(end_of_line))(list(expression_statement(postfix_unary_expression(variable((whitespace)(variable)))((++)))((;)(end_of_line))))((whitespace)(})(end_of_line))))(foreach_statement((whitespace)(foreach)(whitespace))((lparen))(variable((variable)(whitespace)))((await)(whitespace))((as)(whitespace))(missing)(missing)(variable((variable)))((rparen))(compound_statement(({)(end_of_line))(missing)((whitespace)(})(end_of_line))))(foreach_statement((whitespace)(foreach)(whitespace))((lparen))(variable((variable)(whitespace)))((await)(whitespace))((as)(whitespace))(variable((variable)(whitespace)))((=>)(whitespace))(variable((variable)))((rparen))(compound_statement(({)(end_of_line))(missing)((whitespace)(})(end_of_line)))))((})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_function_call.exp b/hphp/hack/test/full_fidelity/cases/test_function_call.exp dissimilarity index 100% index 7a0b5f31b40..71c76cfef84 100644 --- a/hphp/hack/test/full_fidelity/cases/test_function_call.exp +++ b/hphp/hack/test/full_fidelity/cases/test_function_call.exp @@ -1,32 +1 @@ -(script(header((<))((?))((name)(end_of_line))) -(list -(function_declaration -(missing) -(function_declaration_header -(missing)((function)(whitespace))(missing)((name))(missing) -((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing)) -(compound_statement(({) -(end_of_line)) -(list( -expression_statement( -function_call_expression( -qualified_name((whitespace)(name))) -((lparen)) -(list -(list_item -(variable((variable))) -(missing))) -((rparen))) -((;)(end_of_line))) -(expression_statement( -member_selection_expression( -function_call_expression( -qualified_name((whitespace)(name)))((lparen))(missing)((rparen)(whitespace))) -((->)(whitespace))((name))) -((;)(end_of_line))) -(expression_statement(binary_expression( -function_call_expression( -qualified_name((whitespace)(name))) -((lparen))(missing)((rparen)(whitespace))) -((+)(whitespace))(literal((decimal_literal)))) -((;)(end_of_line))))((})))))) +(script(header((<))((?))((name)(end_of_line)))(list(function_declaration(missing)(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name))(missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({)(end_of_line))(list(expression_statement(function_call_expression(qualified_name((whitespace)(name)))((lparen))(list(list_item(variable((variable)))(missing)))((rparen)))((;)(end_of_line)))(expression_statement(member_selection_expression(function_call_expression(qualified_name((whitespace)(name)))((lparen))(missing)((rparen)(whitespace)))((->)(whitespace))((name)))((;)(end_of_line)))(expression_statement(binary_expression(function_call_expression(qualified_name((whitespace)(name)))((lparen))(missing)((rparen)(whitespace)))((+)(whitespace))(literal((decimal_literal))))((;)(end_of_line))))((})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_list_precedence.exp b/hphp/hack/test/full_fidelity/cases/test_list_precedence.exp dissimilarity index 100% index 5de10d1f2e9..ac9ddadfe79 100644 --- a/hphp/hack/test/full_fidelity/cases/test_list_precedence.exp +++ b/hphp/hack/test/full_fidelity/cases/test_list_precedence.exp @@ -1,52 +1 @@ -(script(header((<))((?))((name)(end_of_line))) -(list -(function_declaration -(missing) -(function_declaration_header -(missing) -((function)(whitespace))(missing)((name))(missing) -((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing)) -(compound_statement(({)(end_of_line)) -(list(expression_statement( -binary_expression( -variable((whitespace)(variable)(whitespace))) -((+=)(whitespace)) -(binary_expression( -variable((variable)(whitespace))) -((+)(whitespace)) -(list_expression((list)(whitespace)) -((lparen)) -(list -(list_item(binary_expression(variable((variable)(whitespace))) -((=)(whitespace)) -(literal((decimal_literal)))) -(missing))) -((rparen))))) -((;)(end_of_line))) -(expression_statement( -binary_expression( -variable((whitespace)(variable)(whitespace))) -((+=)(whitespace)) -(binary_expression(variable((variable)(whitespace))) -((+)(whitespace)) -(list_expression( -(list)(whitespace)) -((lparen)) -(list -(list_item( -binary_expression( -variable((variable)(whitespace))) -((=)(whitespace)) -(literal((decimal_literal)))) -((,)(whitespace))) -(list_item -(prefix_unary_expression( -(await)(whitespace)) -(binary_expression( -variable((variable)(whitespace))) -((=)(whitespace)) -(literal((decimal_literal))))) -(missing))) -((rparen))))) -((;)(end_of_line)))) -((})))))) +(script(header((<))((?))((name)(end_of_line)))(list(function_declaration(missing)(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name))(missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({)(end_of_line))(list(expression_statement(binary_expression(variable((whitespace)(variable)(whitespace)))((+=)(whitespace))(binary_expression(variable((variable)(whitespace)))((+)(whitespace))(list_expression((list)(whitespace))((lparen))(list(list_item(binary_expression(variable((variable)(whitespace)))((=)(whitespace))(literal((decimal_literal))))(missing)))((rparen)))))((;)(end_of_line)))(expression_statement(binary_expression(variable((whitespace)(variable)(whitespace)))((+=)(whitespace))(binary_expression(variable((variable)(whitespace)))((+)(whitespace))(list_expression((list)(whitespace))((lparen))(list(list_item(binary_expression(variable((variable)(whitespace)))((=)(whitespace))(literal((decimal_literal))))((,)(whitespace)))(list_item(prefix_unary_expression((await)(whitespace))(binary_expression(variable((variable)(whitespace)))((=)(whitespace))(literal((decimal_literal)))))(missing)))((rparen)))))((;)(end_of_line))))((})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_literals.exp b/hphp/hack/test/full_fidelity/cases/test_literals.exp dissimilarity index 100% index 7c9a99b062e..a9863f3237e 100644 --- a/hphp/hack/test/full_fidelity/cases/test_literals.exp +++ b/hphp/hack/test/full_fidelity/cases/test_literals.exp @@ -1,21 +1 @@ -(script - (header((<))((?))((name)(end_of_line))) - (list - (function_declaration(missing) - (function_declaration_header - (missing)((function)(whitespace))(missing)((name))(missing)((lparen)) - (missing)((rparen)(whitespace))(missing)(missing)(missing)) - (compound_statement - (({)(end_of_line)) - (list - (expression_statement - (binary_expression - (variable((whitespace)(variable)(whitespace)))((=)(end_of_line)) - (literal((heredoc_string_literal)))) - ((;)(end_of_line))) - (expression_statement - (binary_expression - (variable((whitespace)(variable)(whitespace)))((=)(end_of_line)) - (literal((nowdoc_string_literal)(end_of_line)))) - ((;)(end_of_line)))) - ((end_of_line)(})))))) +(script(header((<))((?))((name)(end_of_line)))(list(function_declaration(missing)(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name))(missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({)(end_of_line))(list(expression_statement(binary_expression(variable((whitespace)(variable)(whitespace)))((=)(end_of_line))(literal((heredoc_string_literal))))((;)(end_of_line)))(expression_statement(binary_expression(variable((whitespace)(variable)(whitespace)))((=)(end_of_line))(literal((nowdoc_string_literal)(end_of_line))))((;)(end_of_line))))((end_of_line)(})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_namespace.exp b/hphp/hack/test/full_fidelity/cases/test_namespace.exp dissimilarity index 95% index 00aef709fe0..8382e5f60e8 100644 --- a/hphp/hack/test/full_fidelity/cases/test_namespace.exp +++ b/hphp/hack/test/full_fidelity/cases/test_namespace.exp @@ -1,34 +1 @@ -(script(header((<))((?))((name)(end_of_line))) -(list( -namespace_declaration( -(namespace)(whitespace)) -(missing)(namespace_body(({))(missing)((})(end_of_line)))) -(namespace_declaration((namespace)(whitespace)) -((name)(whitespace))(namespace_body(({))(missing)((})(end_of_line)))) -(namespace_declaration((namespace)(whitespace))((name))((;)(end_of_line))) -(namespace_declaration((namespace)(whitespace))((name)(whitespace)) -(namespace_body(({) -(end_of_line)) -(list( -function_declaration -(missing) -(function_declaration_header -(missing) -((whitespace)(function)(whitespace))(missing) -((name)(whitespace))(missing)((lparen))(missing)((rparen)(whitespace)) -(missing)(missing)(missing))(compound_statement(({))(missing)((})(end_of_line)))) -(classish_declaration(missing)(missing)((whitespace) -(class)(whitespace))((name)(whitespace)) -(missing)(missing)(missing)(missing)(missing) -(classish_body(({))(missing)((})(end_of_line)))))((})(end_of_line)))) -(namespace_declaration((namespace)(whitespace))(missing) -(namespace_body(({)(end_of_line)) -(list( -function_declaration(missing)(function_declaration_header(missing) -((whitespace)(function)(whitespace))(missing)((name)(whitespace))(missing) -((lparen))(missing)((rparen)(whitespace)) -(missing)(missing)(missing))(compound_statement(({))(missing)((})(end_of_line)))) -(classish_declaration(missing)(missing) -((whitespace)(class)(whitespace)) -((name)(whitespace))(missing)(missing)(missing)(missing)(missing) -(classish_body(({))(missing)((})(end_of_line)))))((})))))) +(script(header((<))((?))((name)(end_of_line)))(list(namespace_declaration((namespace)(whitespace))(missing)(namespace_body(({))(missing)((})(end_of_line))))(namespace_declaration((namespace)(whitespace))((name)(whitespace))(namespace_body(({))(missing)((})(end_of_line))))(namespace_declaration((namespace)(whitespace))((name))((;)(end_of_line)))(namespace_declaration((namespace)(whitespace))((name)(whitespace))(namespace_body(({)(end_of_line))(list(function_declaration(missing)(function_declaration_header(missing)(missing)((whitespace)(function)(whitespace))(missing)((name)(whitespace))(missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({))(missing)((})(end_of_line))))(classish_declaration(missing)(missing)((whitespace)(class)(whitespace))((name)(whitespace))(missing)(missing)(missing)(missing)(missing)(classish_body(({))(missing)((})(end_of_line)))))((})(end_of_line))))(namespace_declaration((namespace)(whitespace))(missing)(namespace_body(({)(end_of_line))(list(function_declaration(missing)(function_declaration_header(missing)(missing)((whitespace)(function)(whitespace))(missing)((name)(whitespace))(missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({))(missing)((})(end_of_line))))(classish_declaration(missing)(missing)((whitespace)(class)(whitespace))((name)(whitespace))(missing)(missing)(missing)(missing)(missing)(classish_body(({))(missing)((})(end_of_line)))))((})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_simple.exp b/hphp/hack/test/full_fidelity/cases/test_simple.exp dissimilarity index 100% index f9c72cd41d7..2e043d7696d 100644 --- a/hphp/hack/test/full_fidelity/cases/test_simple.exp +++ b/hphp/hack/test/full_fidelity/cases/test_simple.exp @@ -1,35 +1 @@ -(script - (header((<))((?))((name)(end_of_line))) - (list - (function_declaration - (missing) - (function_declaration_header - (missing) - ((delimited_comment)(whitespace)(function)(whitespace)) - (missing) - ((name))(missing) - ((lparen))(missing) - ((rparen)(whitespace)) - (missing) - (missing) - (missing) - ) - (compound_statement - (({)(end_of_line)) - (list - (expression_statement( - binary_expression( - variable((single_line_comment)(end_of_line)(whitespace)(variable)(end_of_line))) - ((whitespace)(=)(whitespace)) - (binary_expression - (parenthesized_expression - ((lparen)) - (binary_expression( - literal((decimal_literal)(whitespace))) - ((+)(whitespace)) - (variable((variable)))) - ((rparen)(whitespace))) - ((*)(whitespace)) - (variable((variable))))) - ((;)(end_of_line)))) - ((})))))) +(script(header((<))((?))((name)(end_of_line)))(list(function_declaration(missing)(function_declaration_header(missing)(missing)((delimited_comment)(whitespace)(function)(whitespace))(missing)((name))(missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({)(end_of_line))(list(expression_statement(binary_expression(variable((single_line_comment)(end_of_line)(whitespace)(variable)(end_of_line)))((whitespace)(=)(whitespace))(binary_expression(parenthesized_expression((lparen))(binary_expression(literal((decimal_literal)(whitespace)))((+)(whitespace))(variable((variable))))((rparen)(whitespace)))((*)(whitespace))(variable((variable)))))((;)(end_of_line))))((})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_statements.exp b/hphp/hack/test/full_fidelity/cases/test_statements.exp dissimilarity index 100% index 19c201c3484..8b772ebf5a3 100644 --- a/hphp/hack/test/full_fidelity/cases/test_statements.exp +++ b/hphp/hack/test/full_fidelity/cases/test_statements.exp @@ -1,75 +1 @@ -(script(header((<))((?))((name)(end_of_line))) - (list - (function_declaration(missing)(function_declaration_header - (missing)((function)(whitespace))(missing)((name)) - (missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing)) - (compound_statement - (({)(end_of_line)) - (list - (if_statement - ((whitespace)(if)(whitespace)) - ((lparen))(variable((variable))) - ((rparen)(end_of_line)) - (if_statement - ((whitespace)(if)(whitespace)) - ((lparen)) - (variable((variable))) - ((rparen)(end_of_line)) - (switch_statement - ((whitespace)(switch)(whitespace)) - ((lparen)) - (variable((variable))) - ((rparen)(whitespace)) - (({)(end_of_line)) - (list - (switch_section - (list(case_label - ((whitespace)(case)(whitespace)) - (literal((decimal_literal))) - ((:)(whitespace)))) - (missing) - (switch_fallthrough((fallthrough))((;)(whitespace) - (single_line_comment)(end_of_line)))) - (switch_section - (list(default_label - ((whitespace)(default))((:)(whitespace)))) - (list(break_statement((break))(missing)((;)(end_of_line)))) - (missing))) - ((whitespace)(})(end_of_line))) - (missing) - (else_clause - ((whitespace)(else)(end_of_line)) - (return_statement - ((whitespace)(return)(whitespace)) - (variable((variable))) - ((;)(end_of_line))))) - (list(elseif_clause - ((whitespace)(elseif)) - ((lparen)) - (variable((variable))) - ((rparen)(end_of_line)) - (do_statement - ((whitespace)(do)(whitespace)) - (compound_statement - (({)(end_of_line)) - (list - (while_statement - ((whitespace)(while)) - ((lparen)) - (variable((variable))) - ((rparen)(end_of_line)) - (throw_statement - ((whitespace)(throw)(whitespace)) - (variable((variable))) - ((;)(end_of_line)))) - (continue_statement - ((whitespace)(continue)) - (missing)((;)(end_of_line)))) - ((whitespace)(})(whitespace))) - ((while)(whitespace)) - ((lparen)) - (variable((variable))) - ((rparen)) - ((;)(end_of_line))))) - (missing))) - ((})))))) +(script(header((<))((?))((name)(end_of_line)))(list(function_declaration(missing)(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name))(missing)((lparen))(missing)((rparen)(whitespace))(missing)(missing)(missing))(compound_statement(({)(end_of_line))(list(if_statement((whitespace)(if)(whitespace))((lparen))(variable((variable)))((rparen)(end_of_line))(if_statement((whitespace)(if)(whitespace))((lparen))(variable((variable)))((rparen)(end_of_line))(switch_statement((whitespace)(switch)(whitespace))((lparen))(variable((variable)))((rparen)(whitespace))(({)(end_of_line))(list(switch_section(list(case_label((whitespace)(case)(whitespace))(literal((decimal_literal)))((:)(whitespace))))(missing)(switch_fallthrough((fallthrough))((;)(whitespace)(single_line_comment)(end_of_line))))(switch_section(list(default_label((whitespace)(default))((:)(whitespace))))(list(break_statement((break))(missing)((;)(end_of_line))))(missing)))((whitespace)(})(end_of_line)))(missing)(else_clause((whitespace)(else)(end_of_line))(return_statement((whitespace)(return)(whitespace))(variable((variable)))((;)(end_of_line)))))(list(elseif_clause((whitespace)(elseif))((lparen))(variable((variable)))((rparen)(end_of_line))(do_statement((whitespace)(do)(whitespace))(compound_statement(({)(end_of_line))(list(while_statement((whitespace)(while))((lparen))(variable((variable)))((rparen)(end_of_line))(throw_statement((whitespace)(throw)(whitespace))(variable((variable)))((;)(end_of_line))))(continue_statement((whitespace)(continue))(missing)((;)(end_of_line))))((whitespace)(})(whitespace)))((while)(whitespace))((lparen))(variable((variable)))((rparen))((;)(end_of_line)))))(missing)))((})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_try_statement.exp b/hphp/hack/test/full_fidelity/cases/test_try_statement.exp dissimilarity index 100% index b1997e837e9..74f2348ab26 100644 --- a/hphp/hack/test/full_fidelity/cases/test_try_statement.exp +++ b/hphp/hack/test/full_fidelity/cases/test_try_statement.exp @@ -1,38 +1 @@ -(script(header((<))((?))((name)(end_of_line))) -(list -(function_declaration - (missing) - (function_declaration_header - (missing) - ((function)(whitespace))(missing)((name))(missing) - ((lparen))(missing)((rparen))(missing)(missing) - (missing)) - (compound_statement - (({)(end_of_line)) - (list(try_statement((whitespace)(try)(whitespace)) - (compound_statement - (({)(end_of_line)) - (list(expression_statement - (postfix_unary_expression(variable((whitespace)(variable)))((++))) - ((;)(end_of_line)))) - ((whitespace)(})(end_of_line))) - (list - (catch_clause - ((whitespace)(catch)(whitespace)) - ((lparen)) - (simple_type_specifier((name)(whitespace))) - ((variable)) - ((rparen)) - (compound_statement - (({)(end_of_line)) - (list(expression_statement(variable((whitespace)(variable))) - ((;)(end_of_line)))) - ((whitespace)(})(end_of_line))))) - (finally_clause((whitespace)(finally)(whitespace)) - (compound_statement - (({)(end_of_line)) - (list - (expression_statement(variable((whitespace)(variable))) - ((;)(end_of_line)))) - ((whitespace)(})(end_of_line)))))) - ((})))))) +(script(header((<))((?))((name)(end_of_line)))(list(function_declaration(missing)(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name))(missing)((lparen))(missing)((rparen))(missing)(missing)(missing))(compound_statement(({)(end_of_line))(list(try_statement((whitespace)(try)(whitespace))(compound_statement(({)(end_of_line))(list(expression_statement(postfix_unary_expression(variable((whitespace)(variable)))((++)))((;)(end_of_line))))((whitespace)(})(end_of_line)))(list(catch_clause((whitespace)(catch)(whitespace))((lparen))(simple_type_specifier((name)(whitespace)))((variable))((rparen))(compound_statement(({)(end_of_line))(list(expression_statement(variable((whitespace)(variable)))((;)(end_of_line))))((whitespace)(})(end_of_line)))))(finally_clause((whitespace)(finally)(whitespace))(compound_statement(({)(end_of_line))(list(expression_statement(variable((whitespace)(variable)))((;)(end_of_line))))((whitespace)(})(end_of_line))))))((})))))) diff --git a/hphp/hack/test/full_fidelity/cases/test_types_type_const.exp b/hphp/hack/test/full_fidelity/cases/test_types_type_const.exp dissimilarity index 100% index 01f16cb1f93..bae9f0dfa88 100644 --- a/hphp/hack/test/full_fidelity/cases/test_types_type_const.exp +++ b/hphp/hack/test/full_fidelity/cases/test_types_type_const.exp @@ -1,17 +1 @@ -(script(header((<))((?))((name)(end_of_line))) -(list -(function_declaration -(missing) -(function_declaration_header -(missing) -((function)(whitespace))(missing)((name))(missing) -((lparen)) -(list -(list_item -(parameter_declaration(missing)(missing) -(type_constant(type_constant((self))((::))((name)))((::))((name)(whitespace))) -((variable))(missing)) -(missing))) -((rparen)) -(missing)(missing)(missing)) -(compound_statement(({))(missing)((})))))) +(script(header((<))((?))((name)(end_of_line)))(list(function_declaration(missing)(function_declaration_header(missing)(missing)((function)(whitespace))(missing)((name))(missing)((lparen))(list(list_item(parameter_declaration(missing)(missing)(type_constant(type_constant((self))((::))((name)))((::))((name)(whitespace)))((variable))(missing))(missing)))((rparen))(missing)(missing)(missing))(compound_statement(({))(missing)((})))))) diff --git a/hphp/hack/test/hackfmt/tests/async_coroutine_function1.php b/hphp/hack/test/hackfmt/tests/async_coroutine_function1.php new file mode 100644 index 00000000000..0937d8bfa0d --- /dev/null +++ b/hphp/hack/test/hackfmt/tests/async_coroutine_function1.php @@ -0,0 +1,5 @@ + 1; +} diff --git a/hphp/hack/test/hackfmt/tests/coroutine_lambda1.php.exp b/hphp/hack/test/hackfmt/tests/coroutine_lambda1.php.exp new file mode 100644 index 00000000000..fe32e2d522a --- /dev/null +++ b/hphp/hack/test/hackfmt/tests/coroutine_lambda1.php.exp @@ -0,0 +1,5 @@ + 1; +} diff --git a/hphp/hack/test/hackfmt/tests/coroutine_lambda2.php b/hphp/hack/test/hackfmt/tests/coroutine_lambda2.php new file mode 100644 index 00000000000..079e1c0fc48 --- /dev/null +++ b/hphp/hack/test/hackfmt/tests/coroutine_lambda2.php @@ -0,0 +1,5 @@ + 1; +} diff --git a/hphp/hack/test/hackfmt/tests/coroutine_lambda2.php.exp b/hphp/hack/test/hackfmt/tests/coroutine_lambda2.php.exp new file mode 100644 index 00000000000..079e1c0fc48 --- /dev/null +++ b/hphp/hack/test/hackfmt/tests/coroutine_lambda2.php.exp @@ -0,0 +1,5 @@ + 1; +} diff --git a/hphp/hack/test/hackfmt/tests/coroutine_lambda3.php b/hphp/hack/test/hackfmt/tests/coroutine_lambda3.php new file mode 100644 index 00000000000..516f9983421 --- /dev/null +++ b/hphp/hack/test/hackfmt/tests/coroutine_lambda3.php @@ -0,0 +1,5 @@ + 1; +} diff --git a/hphp/hack/test/hackfmt/tests/coroutine_lambda3.php.exp b/hphp/hack/test/hackfmt/tests/coroutine_lambda3.php.exp new file mode 100644 index 00000000000..516f9983421 --- /dev/null +++ b/hphp/hack/test/hackfmt/tests/coroutine_lambda3.php.exp @@ -0,0 +1,5 @@ + 1; +} -- 2.11.4.GIT