1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 #define YYERROR_VERBOSE
13 #define YYSTYPE struct node *
16 extern void yyerror(char const *s);
17 extern struct node *mk_node(char const *name, int n, ...);
18 extern struct node *mk_atom(char *text);
19 extern struct node *mk_none();
20 extern struct node *ext_node(struct node *nd, int n, ...);
21 extern void push_back(char c);
57 %token LIT_BYTE_STR_RAW
101 %token INNER_DOC_COMMENT
102 %token OUTER_DOC_COMMENT
106 %token STATIC_LIFETIME
109 Quoting from the Bison manual:
111 "Finally, the resolution of conflicts works by comparing the precedence
112 of the rule being considered with that of the lookahead token. If the
113 token's precedence is higher, the choice is to shift. If the rule's
114 precedence is higher, the choice is to reduce. If they have equal
115 precedence, the choice is made based on the associativity of that
116 precedence level. The verbose output file made by ā-vā (see Invoking
117 Bison) says how each conflict was resolved"
120 // We expect no shift/reduce or reduce/reduce conflicts in this grammar;
121 // all potential ambiguities are scrutinized and eliminated manually.
124 // fake-precedence symbol to cause '|' bars in lambda context to parse
125 // at low precedence, permit things like |x| foo = bar, where '=' is
126 // otherwise lower-precedence than '|'. Also used for proc() to cause
127 // things like proc() a + b to parse as proc() { a + b }.
132 // MUT should be lower precedence than IDENT so that in the pat rule,
133 // "& MUT pat" has higher precedence than "binding_mode ident [@ pat]"
136 // IDENT needs to be lower than '{' so that 'foo {' is shifted when
137 // trying to decide if we've got a struct-construction expr (esp. in
138 // contexts like 'if foo { .')
140 // IDENT also needs to be lower precedence than '<' so that '<' in
141 // 'foo:bar . <' is shifted (in a trait reference occurring in a
142 // bounds list), parsing as foo:(bar<baz>) rather than (foo:bar)<baz>.
145 // A couple fake-precedence symbols to use in rules associated with +
146 // and < in trailing type contexts. These come up when you have a type
147 // in the RHS of operator-AS, such as "foo as bar<baz>". The "<" there
148 // has to be shifted so the parser keeps trying to parse a type, even
149 // though it might well consider reducing the type "bar" and then
150 // going on to "<" as a subsequent binop. The "+" case is with
151 // trailing type-bounds ("foo as bar:A+B"), for the same reason.
152 %precedence SHIFTPLUS
155 %precedence RARROW ':'
157 // In where clauses, "for" should have greater precedence when used as
158 // a higher ranked constraint than when used as the beginning of a
159 // for_in_type (which is a ty)
163 // Binops & unops, and their precedences
168 // RETURN needs to be lower-precedence than tokens that start
172 %right '=' SHLEQ SHREQ MINUSEQ ANDEQ OREQ PLUSEQ STAREQ SLASHEQ CARETEQ PERCENTEQ
187 %precedence '{' '[' '(' '.'
195 ////////////////////////////////////////////////////////////////////////
196 // Part 1: Items and attributes
197 ////////////////////////////////////////////////////////////////////////
200 : maybe_shebang inner_attrs maybe_mod_items { mk_node("crate", 2, $2, $3); }
201 | maybe_shebang maybe_mod_items { mk_node("crate", 1, $2); }
211 | %empty { $$ = mk_none(); }
215 : inner_attr { $$ = mk_node("InnerAttrs", 1, $1); }
216 | inner_attrs inner_attr { $$ = ext_node($1, 1, $2); }
220 : SHEBANG '[' meta_item ']' { $$ = mk_node("InnerAttr", 1, $3); }
221 | INNER_DOC_COMMENT { $$ = mk_node("InnerAttr", 1, mk_node("doc-comment", 1, mk_atom(yytext))); }
226 | %empty { $$ = mk_none(); }
230 : outer_attr { $$ = mk_node("OuterAttrs", 1, $1); }
231 | outer_attrs outer_attr { $$ = ext_node($1, 1, $2); }
235 : '#' '[' meta_item ']' { $$ = $3; }
236 | OUTER_DOC_COMMENT { $$ = mk_node("doc-comment", 1, mk_atom(yytext)); }
240 : ident { $$ = mk_node("MetaWord", 1, $1); }
241 | ident '=' lit { $$ = mk_node("MetaNameValue", 2, $1, $3); }
242 | ident '(' meta_seq ')' { $$ = mk_node("MetaList", 2, $1, $3); }
243 | ident '(' meta_seq ',' ')' { $$ = mk_node("MetaList", 2, $1, $3); }
247 : %empty { $$ = mk_none(); }
248 | meta_item { $$ = mk_node("MetaItems", 1, $1); }
249 | meta_seq ',' meta_item { $$ = ext_node($1, 1, $3); }
254 | %empty { $$ = mk_none(); }
258 : mod_item { $$ = mk_node("Items", 1, $1); }
259 | mod_items mod_item { $$ = ext_node($1, 1, $2); }
263 : maybe_outer_attrs visibility { $$ = mk_node("AttrsAndVis", 2, $1, $2); }
267 : attrs_and_vis item { $$ = mk_node("Item", 2, $1, $2); }
270 // items that can appear outside of a fn block
276 // items that can appear in "stmts"
286 : STATIC ident ':' ty '=' expr ';' { $$ = mk_node("ItemStatic", 3, $2, $4, $6); }
287 | STATIC MUT ident ':' ty '=' expr ';' { $$ = mk_node("ItemStatic", 3, $3, $5, $7); }
291 : CONST ident ':' ty '=' expr ';' { $$ = mk_node("ItemConst", 3, $2, $4, $6); }
295 : path_expr '!' maybe_ident parens_delimited_token_trees ';' { $$ = mk_node("ItemMacro", 3, $1, $3, $4); }
296 | path_expr '!' maybe_ident braces_delimited_token_trees { $$ = mk_node("ItemMacro", 3, $1, $3, $4); }
297 | path_expr '!' maybe_ident brackets_delimited_token_trees ';'{ $$ = mk_node("ItemMacro", 3, $1, $3, $4); }
303 | EXTERN CRATE ident ';' { $$ = mk_node("ViewItemExternCrate", 1, $3); }
304 | EXTERN CRATE ident AS ident ';' { $$ = mk_node("ViewItemExternCrate", 2, $3, $5); }
308 : EXTERN maybe_abi item_fn { $$ = mk_node("ViewItemExternFn", 2, $2, $3); }
312 : USE view_path ';' { $$ = mk_node("ViewItemUse", 1, $2); }
316 : path_no_types_allowed { $$ = mk_node("ViewPathSimple", 1, $1); }
317 | path_no_types_allowed MOD_SEP '{' '}' { $$ = mk_node("ViewPathList", 2, $1, mk_atom("ViewPathListEmpty")); }
318 | MOD_SEP '{' '}' { $$ = mk_node("ViewPathList", 1, mk_atom("ViewPathListEmpty")); }
319 | path_no_types_allowed MOD_SEP '{' idents_or_self '}' { $$ = mk_node("ViewPathList", 2, $1, $4); }
320 | MOD_SEP '{' idents_or_self '}' { $$ = mk_node("ViewPathList", 1, $3); }
321 | path_no_types_allowed MOD_SEP '{' idents_or_self ',' '}' { $$ = mk_node("ViewPathList", 2, $1, $4); }
322 | MOD_SEP '{' idents_or_self ',' '}' { $$ = mk_node("ViewPathList", 1, $3); }
323 | path_no_types_allowed MOD_SEP '*' { $$ = mk_node("ViewPathGlob", 1, $1); }
324 | '{' '}' { $$ = mk_atom("ViewPathListEmpty"); }
325 | '{' idents_or_self '}' { $$ = mk_node("ViewPathList", 1, $2); }
326 | '{' idents_or_self ',' '}' { $$ = mk_node("ViewPathList", 1, $2); }
327 | path_no_types_allowed AS ident { $$ = mk_node("ViewPathSimple", 2, $1, $3); }
334 | item_foreign_mod { $$ = mk_node("ItemForeignMod", 1, $1); }
342 : ':' ty_sum { $$ = $2; }
343 | %empty { $$ = mk_none(); }
347 : '=' expr { $$ = $2; }
348 | %empty { $$ = mk_none(); }
353 : STRUCT ident generic_params maybe_where_clause struct_decl_args
355 $$ = mk_node("ItemStruct", 4, $2, $3, $4, $5);
357 | STRUCT ident generic_params struct_tuple_args maybe_where_clause ';'
359 $$ = mk_node("ItemStruct", 4, $2, $3, $4, $5);
361 | STRUCT ident generic_params maybe_where_clause ';'
363 $$ = mk_node("ItemStruct", 3, $2, $3, $4);
368 : '{' struct_decl_fields '}' { $$ = $2; }
369 | '{' struct_decl_fields ',' '}' { $$ = $2; }
373 : '(' struct_tuple_fields ')' { $$ = $2; }
374 | '(' struct_tuple_fields ',' ')' { $$ = $2; }
378 : struct_decl_field { $$ = mk_node("StructFields", 1, $1); }
379 | struct_decl_fields ',' struct_decl_field { $$ = ext_node($1, 1, $3); }
380 | %empty { $$ = mk_none(); }
384 : attrs_and_vis ident ':' ty_sum { $$ = mk_node("StructField", 3, $1, $2, $4); }
388 : struct_tuple_field { $$ = mk_node("StructFields", 1, $1); }
389 | struct_tuple_fields ',' struct_tuple_field { $$ = ext_node($1, 1, $3); }
393 : attrs_and_vis ty_sum { $$ = mk_node("StructField", 2, $1, $2); }
398 : ENUM ident generic_params maybe_where_clause '{' enum_defs '}' { $$ = mk_node("ItemEnum", 0); }
399 | ENUM ident generic_params maybe_where_clause '{' enum_defs ',' '}' { $$ = mk_node("ItemEnum", 0); }
403 : enum_def { $$ = mk_node("EnumDefs", 1, $1); }
404 | enum_defs ',' enum_def { $$ = ext_node($1, 1, $3); }
405 | %empty { $$ = mk_none(); }
409 : attrs_and_vis ident enum_args { $$ = mk_node("EnumDef", 3, $1, $2, $3); }
413 : '{' struct_decl_fields '}' { $$ = mk_node("EnumArgs", 1, $2); }
414 | '{' struct_decl_fields ',' '}' { $$ = mk_node("EnumArgs", 1, $2); }
415 | '(' maybe_ty_sums ')' { $$ = mk_node("EnumArgs", 1, $2); }
416 | '=' expr { $$ = mk_node("EnumArgs", 1, $2); }
417 | %empty { $$ = mk_none(); }
421 : MOD ident ';' { $$ = mk_node("ItemMod", 1, $2); }
422 | MOD ident '{' maybe_mod_items '}' { $$ = mk_node("ItemMod", 2, $2, $4); }
423 | MOD ident '{' inner_attrs maybe_mod_items '}' { $$ = mk_node("ItemMod", 3, $2, $4, $5); }
427 : EXTERN maybe_abi '{' maybe_foreign_items '}' { $$ = mk_node("ItemForeignMod", 1, $4); }
428 | EXTERN maybe_abi '{' inner_attrs maybe_foreign_items '}' { $$ = mk_node("ItemForeignMod", 2, $4, $5); }
433 | %empty { $$ = mk_none(); }
438 | %empty { $$ = mk_none(); }
442 : foreign_item { $$ = mk_node("ForeignItems", 1, $1); }
443 | foreign_items foreign_item { $$ = ext_node($1, 1, $2); }
447 : attrs_and_vis STATIC item_foreign_static { $$ = mk_node("ForeignItem", 2, $1, $3); }
448 | attrs_and_vis item_foreign_fn { $$ = mk_node("ForeignItem", 2, $1, $2); }
449 | attrs_and_vis UNSAFE item_foreign_fn { $$ = mk_node("ForeignItem", 2, $1, $3); }
453 : maybe_mut ident ':' ty ';' { $$ = mk_node("StaticItem", 3, $1, $2, $4); }
457 : FN ident generic_params fn_decl_allow_variadic maybe_where_clause ';' { $$ = mk_node("ForeignFn", 4, $2, $3, $4, $5); }
460 fn_decl_allow_variadic
461 : fn_params_allow_variadic ret_ty { $$ = mk_node("FnDecl", 2, $1, $2); }
464 fn_params_allow_variadic
465 : '(' ')' { $$ = mk_none(); }
466 | '(' params ')' { $$ = $2; }
467 | '(' params ',' ')' { $$ = $2; }
468 | '(' params ',' DOTDOTDOT ')' { $$ = $2; }
472 : PUB { $$ = mk_atom("Public"); }
473 | %empty { $$ = mk_atom("Inherited"); }
477 : ident_or_self { $$ = mk_node("IdentsOrSelf", 1, $1); }
478 | ident_or_self AS ident { $$ = mk_node("IdentsOrSelf", 2, $1, $3); }
479 | idents_or_self ',' ident_or_self { $$ = ext_node($1, 1, $3); }
484 | SELF { $$ = mk_atom(yytext); }
488 : TYPE ident generic_params maybe_where_clause '=' ty_sum ';' { $$ = mk_node("ItemTy", 4, $2, $3, $4, $6); }
492 : FOR '?' ident { $$ = mk_node("ForSized", 1, $3); }
493 | FOR ident '?' { $$ = mk_node("ForSized", 1, $2); }
494 | %empty { $$ = mk_none(); }
498 : maybe_unsafe TRAIT ident generic_params for_sized maybe_ty_param_bounds maybe_where_clause '{' maybe_trait_items '}'
500 $$ = mk_node("ItemTrait", 7, $1, $3, $4, $5, $6, $7, $9);
506 | %empty { $$ = mk_none(); }
510 : trait_item { $$ = mk_node("TraitItems", 1, $1); }
511 | trait_items trait_item { $$ = ext_node($1, 1, $2); }
521 : maybe_outer_attrs CONST ident maybe_ty_ascription maybe_const_default ';' { $$ = mk_node("ConstTraitItem", 4, $1, $3, $4, $5); }
525 : '=' expr { $$ = mk_node("ConstDefault", 1, $2); }
526 | %empty { $$ = mk_none(); }
530 : maybe_outer_attrs TYPE ty_param ';' { $$ = mk_node("TypeTraitItem", 2, $1, $3); }
534 : UNSAFE { $$ = mk_atom("Unsafe"); }
535 | %empty { $$ = mk_none(); }
538 maybe_default_maybe_unsafe
539 : DEFAULT UNSAFE { $$ = mk_atom("DefaultUnsafe"); }
540 | DEFAULT { $$ = mk_atom("Default"); }
541 | UNSAFE { $$ = mk_atom("Unsafe"); }
542 | %empty { $$ = mk_none(); }
545 : type_method { $$ = mk_node("Required", 1, $1); }
546 | method { $$ = mk_node("Provided", 1, $1); }
550 : attrs_and_vis maybe_unsafe FN ident generic_params fn_decl_with_self_allow_anon_params maybe_where_clause ';'
552 $$ = mk_node("TypeMethod", 6, $1, $2, $4, $5, $6, $7);
554 | attrs_and_vis maybe_unsafe EXTERN maybe_abi FN ident generic_params fn_decl_with_self_allow_anon_params maybe_where_clause ';'
556 $$ = mk_node("TypeMethod", 7, $1, $2, $4, $6, $7, $8, $9);
561 : attrs_and_vis maybe_unsafe FN ident generic_params fn_decl_with_self_allow_anon_params maybe_where_clause inner_attrs_and_block
563 $$ = mk_node("Method", 7, $1, $2, $4, $5, $6, $7, $8);
565 | attrs_and_vis maybe_unsafe EXTERN maybe_abi FN ident generic_params fn_decl_with_self_allow_anon_params maybe_where_clause inner_attrs_and_block
567 $$ = mk_node("Method", 8, $1, $2, $4, $6, $7, $8, $9, $10);
572 : attrs_and_vis maybe_unsafe FN ident generic_params fn_decl_with_self maybe_where_clause inner_attrs_and_block
574 $$ = mk_node("Method", 7, $1, $2, $4, $5, $6, $7, $8);
576 | attrs_and_vis maybe_unsafe EXTERN maybe_abi FN ident generic_params fn_decl_with_self maybe_where_clause inner_attrs_and_block
578 $$ = mk_node("Method", 8, $1, $2, $4, $6, $7, $8, $9, $10);
582 // There are two forms of impl:
584 // impl (<...>)? TY { ... }
585 // impl (<...>)? TRAIT for TY { ... }
587 // Unfortunately since TY can begin with '<' itself -- as part of a
588 // TyQualifiedPath type -- there's an s/r conflict when we see '<' after IMPL:
589 // should we reduce one of the early rules of TY (such as maybe_once)
590 // or shall we continue shifting into the generic_params list for the
593 // The production parser disambiguates a different case here by
594 // permitting / requiring the user to provide parens around types when
595 // they are ambiguous with traits. We do the same here, regrettably,
596 // by splitting ty into ty and ty_prim.
598 : maybe_default_maybe_unsafe IMPL generic_params ty_prim_sum maybe_where_clause '{' maybe_inner_attrs maybe_impl_items '}'
600 $$ = mk_node("ItemImpl", 6, $1, $3, $4, $5, $7, $8);
602 | maybe_default_maybe_unsafe IMPL generic_params '(' ty ')' maybe_where_clause '{' maybe_inner_attrs maybe_impl_items '}'
604 $$ = mk_node("ItemImpl", 6, $1, $3, 5, $6, $9, $10);
606 | maybe_default_maybe_unsafe IMPL generic_params trait_ref FOR ty_sum maybe_where_clause '{' maybe_inner_attrs maybe_impl_items '}'
608 $$ = mk_node("ItemImpl", 6, $3, $4, $6, $7, $9, $10);
610 | maybe_default_maybe_unsafe IMPL generic_params '!' trait_ref FOR ty_sum maybe_where_clause '{' maybe_inner_attrs maybe_impl_items '}'
612 $$ = mk_node("ItemImplNeg", 7, $1, $3, $5, $7, $8, $10, $11);
614 | maybe_default_maybe_unsafe IMPL generic_params trait_ref FOR DOTDOT '{' '}'
616 $$ = mk_node("ItemImplDefault", 3, $1, $3, $4);
618 | maybe_default_maybe_unsafe IMPL generic_params '!' trait_ref FOR DOTDOT '{' '}'
620 $$ = mk_node("ItemImplDefaultNeg", 3, $1, $3, $4);
626 | %empty { $$ = mk_none(); }
630 : impl_item { $$ = mk_node("ImplItems", 1, $1); }
631 | impl_item impl_items { $$ = ext_node($1, 1, $2); }
636 | attrs_and_vis item_macro { $$ = mk_node("ImplMacroItem", 2, $1, $2); }
642 : attrs_and_vis item_const { $$ = mk_node("ImplConst", 1, $1, $2); }
646 : attrs_and_vis TYPE ident generic_params '=' ty_sum ';' { $$ = mk_node("ImplType", 4, $1, $3, $4, $6); }
650 : FN ident generic_params fn_decl maybe_where_clause inner_attrs_and_block
652 $$ = mk_node("ItemFn", 5, $2, $3, $4, $5, $6);
657 : UNSAFE FN ident generic_params fn_decl maybe_where_clause inner_attrs_and_block
659 $$ = mk_node("ItemUnsafeFn", 5, $3, $4, $5, $6, $7);
661 | UNSAFE EXTERN maybe_abi FN ident generic_params fn_decl maybe_where_clause inner_attrs_and_block
663 $$ = mk_node("ItemUnsafeFn", 6, $3, $5, $6, $7, $8, $9);
668 : fn_params ret_ty { $$ = mk_node("FnDecl", 2, $1, $2); }
672 : fn_params_with_self ret_ty { $$ = mk_node("FnDecl", 2, $1, $2); }
675 fn_decl_with_self_allow_anon_params
676 : fn_anon_params_with_self ret_ty { $$ = mk_node("FnDecl", 2, $1, $2); }
680 : '(' maybe_params ')' { $$ = $2; }
684 : '(' anon_param anon_params_allow_variadic_tail ')' { $$ = ext_node($2, 1, $3); }
685 | '(' ')' { $$ = mk_none(); }
689 : '(' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfValue", 3, $2, $4, $5); }
690 | '(' '&' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfRegion", 3, $3, $5, $6); }
691 | '(' '&' lifetime maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfRegion", 4, $3, $4, $6, $7); }
692 | '(' maybe_params ')' { $$ = mk_node("SelfStatic", 1, $2); }
695 fn_anon_params_with_self
696 : '(' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfValue", 3, $2, $4, $5); }
697 | '(' '&' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfRegion", 3, $3, $5, $6); }
698 | '(' '&' lifetime maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfRegion", 4, $3, $4, $6, $7); }
699 | '(' maybe_anon_params ')' { $$ = mk_node("SelfStatic", 1, $2); }
705 | %empty { $$ = mk_none(); }
709 : param { $$ = mk_node("Args", 1, $1); }
710 | params ',' param { $$ = ext_node($1, 1, $3); }
714 : pat ':' ty_sum { $$ = mk_node("Arg", 2, $1, $3); }
718 : inferrable_param { $$ = mk_node("InferrableParams", 1, $1); }
719 | inferrable_params ',' inferrable_param { $$ = ext_node($1, 1, $3); }
723 : pat maybe_ty_ascription { $$ = mk_node("InferrableParam", 2, $1, $2); }
726 maybe_unboxed_closure_kind
733 : ',' { $$ = mk_none(); }
734 | ',' params { $$ = $2; }
735 | ',' params ',' { $$ = $2; }
736 | %empty { $$ = mk_none(); }
739 maybe_comma_anon_params
740 : ',' { $$ = mk_none(); }
741 | ',' anon_params { $$ = $2; }
742 | ',' anon_params ',' { $$ = $2; }
743 | %empty { $$ = mk_none(); }
749 | %empty { $$ = mk_none(); }
753 : anon_param { $$ = mk_node("Args", 1, $1); }
754 | anon_params ',' anon_param { $$ = ext_node($1, 1, $3); }
757 // anon means it's allowed to be anonymous (type-only), but it can
760 : named_arg ':' ty { $$ = mk_node("Arg", 2, $1, $3); }
764 anon_params_allow_variadic_tail
765 : ',' DOTDOTDOT { $$ = mk_none(); }
766 | ',' anon_param anon_params_allow_variadic_tail { $$ = mk_node("Args", 2, $2, $3); }
767 | %empty { $$ = mk_none(); }
772 | UNDERSCORE { $$ = mk_atom("PatWild"); }
773 | '&' ident { $$ = $2; }
774 | '&' UNDERSCORE { $$ = mk_atom("PatWild"); }
775 | ANDAND ident { $$ = $2; }
776 | ANDAND UNDERSCORE { $$ = mk_atom("PatWild"); }
777 | MUT ident { $$ = $2; }
781 : RARROW '!' { $$ = mk_none(); }
782 | RARROW ty { $$ = mk_node("ret-ty", 1, $2); }
783 | %prec IDENT %empty { $$ = mk_none(); }
787 : '<' lifetimes '>' { $$ = mk_node("Generics", 2, $2, mk_none()); }
788 | '<' lifetimes ',' '>' { $$ = mk_node("Generics", 2, $2, mk_none()); }
789 | '<' lifetimes SHR { push_back('>'); $$ = mk_node("Generics", 2, $2, mk_none()); }
790 | '<' lifetimes ',' SHR { push_back('>'); $$ = mk_node("Generics", 2, $2, mk_none()); }
791 | '<' lifetimes ',' ty_params '>' { $$ = mk_node("Generics", 2, $2, $4); }
792 | '<' lifetimes ',' ty_params ',' '>' { $$ = mk_node("Generics", 2, $2, $4); }
793 | '<' lifetimes ',' ty_params SHR { push_back('>'); $$ = mk_node("Generics", 2, $2, $4); }
794 | '<' lifetimes ',' ty_params ',' SHR { push_back('>'); $$ = mk_node("Generics", 2, $2, $4); }
795 | '<' ty_params '>' { $$ = mk_node("Generics", 2, mk_none(), $2); }
796 | '<' ty_params ',' '>' { $$ = mk_node("Generics", 2, mk_none(), $2); }
797 | '<' ty_params SHR { push_back('>'); $$ = mk_node("Generics", 2, mk_none(), $2); }
798 | '<' ty_params ',' SHR { push_back('>'); $$ = mk_node("Generics", 2, mk_none(), $2); }
799 | %empty { $$ = mk_none(); }
803 : %empty { $$ = mk_none(); }
808 : WHERE where_predicates { $$ = mk_node("WhereClause", 1, $2); }
809 | WHERE where_predicates ',' { $$ = mk_node("WhereClause", 1, $2); }
813 : where_predicate { $$ = mk_node("WherePredicates", 1, $1); }
814 | where_predicates ',' where_predicate { $$ = ext_node($1, 1, $3); }
818 : maybe_for_lifetimes lifetime ':' bounds { $$ = mk_node("WherePredicate", 3, $1, $2, $4); }
819 | maybe_for_lifetimes ty ':' ty_param_bounds { $$ = mk_node("WherePredicate", 3, $1, $2, $4); }
823 : FOR '<' lifetimes '>' { $$ = mk_none(); }
824 | %prec FORTYPE %empty { $$ = mk_none(); }
827 : ty_param { $$ = mk_node("TyParams", 1, $1); }
828 | ty_params ',' ty_param { $$ = ext_node($1, 1, $3); }
831 // A path with no type parameters; e.g. `foo::bar::Baz`
833 // These show up in 'use' view-items, because these are processed
834 // without respect to types.
835 path_no_types_allowed
836 : ident { $$ = mk_node("ViewPath", 1, $1); }
837 | MOD_SEP ident { $$ = mk_node("ViewPath", 1, $2); }
838 | SELF { $$ = mk_node("ViewPath", 1, mk_atom("Self")); }
839 | MOD_SEP SELF { $$ = mk_node("ViewPath", 1, mk_atom("Self")); }
840 | path_no_types_allowed MOD_SEP ident { $$ = ext_node($1, 1, $3); }
843 // A path with a lifetime and type parameters, with no double colons
844 // before the type parameters; e.g. `foo::bar<'a>::Baz<T>`
846 // These show up in "trait references", the components of
847 // type-parameter bounds lists, as well as in the prefix of the
848 // path_generic_args_and_bounds rule, which is the full form of a
849 // named typed expression.
851 // They do not have (nor need) an extra '::' before '<' because
852 // unlike in expr context, there are no "less-than" type exprs to
853 // be ambiguous with.
854 path_generic_args_without_colons
856 ident { $$ = mk_node("components", 1, $1); }
858 ident generic_args { $$ = mk_node("components", 2, $1, $2); }
860 ident '(' maybe_ty_sums ')' ret_ty { $$ = mk_node("components", 2, $1, $3); }
862 path_generic_args_without_colons MOD_SEP ident { $$ = ext_node($1, 1, $3); }
864 path_generic_args_without_colons MOD_SEP ident generic_args { $$ = ext_node($1, 2, $3, $4); }
866 path_generic_args_without_colons MOD_SEP ident '(' maybe_ty_sums ')' ret_ty { $$ = ext_node($1, 2, $3, $5); }
870 : '<' generic_values '>' { $$ = $2; }
871 | '<' generic_values SHR { push_back('>'); $$ = $2; }
872 | '<' generic_values GE { push_back('='); $$ = $2; }
873 | '<' generic_values SHREQ { push_back('>'); push_back('='); $$ = $2; }
874 // If generic_args starts with "<<", the first arg must be a
875 // TyQualifiedPath because that's the only type that can start with a
876 // '<'. This rule parses that as the first ty_sum and then continues
877 // with the rest of generic_values.
878 | SHL ty_qualified_path_and_generic_values '>' { $$ = $2; }
879 | SHL ty_qualified_path_and_generic_values SHR { push_back('>'); $$ = $2; }
880 | SHL ty_qualified_path_and_generic_values GE { push_back('='); $$ = $2; }
881 | SHL ty_qualified_path_and_generic_values SHREQ { push_back('>'); push_back('='); $$ = $2; }
885 : maybe_lifetimes maybe_ty_sums_and_or_bindings { $$ = mk_node("GenericValues", 2, $1, $2); }
888 maybe_ty_sums_and_or_bindings
891 | ty_sums ',' bindings { $$ = mk_node("TySumsAndBindings", 2, $1, $3); }
894 | %empty { $$ = mk_none(); }
898 : ',' bindings { $$ = $2; }
899 | %empty { $$ = mk_none(); }
902 ////////////////////////////////////////////////////////////////////////
904 ////////////////////////////////////////////////////////////////////////
907 : UNDERSCORE { $$ = mk_atom("PatWild"); }
908 | '&' pat { $$ = mk_node("PatRegion", 1, $2); }
909 | '&' MUT pat { $$ = mk_node("PatRegion", 1, $3); }
910 | ANDAND pat { $$ = mk_node("PatRegion", 1, mk_node("PatRegion", 1, $2)); }
911 | '(' ')' { $$ = mk_atom("PatUnit"); }
912 | '(' pat_tup ')' { $$ = mk_node("PatTup", 1, $2); }
913 | '(' pat_tup ',' ')' { $$ = mk_node("PatTup", 1, $2); }
914 | '[' pat_vec ']' { $$ = mk_node("PatVec", 1, $2); }
916 | lit_or_path DOTDOTDOT lit_or_path { $$ = mk_node("PatRange", 2, $1, $3); }
917 | path_expr '{' pat_struct '}' { $$ = mk_node("PatStruct", 2, $1, $3); }
918 | path_expr '(' DOTDOT ')' { $$ = mk_node("PatEnum", 1, $1); }
919 | path_expr '(' pat_tup ')' { $$ = mk_node("PatEnum", 2, $1, $3); }
920 | path_expr '!' maybe_ident delimited_token_trees { $$ = mk_node("PatMac", 3, $1, $3, $4); }
921 | binding_mode ident { $$ = mk_node("PatIdent", 2, $1, $2); }
922 | ident '@' pat { $$ = mk_node("PatIdent", 3, mk_node("BindByValue", 1, mk_atom("MutImmutable")), $1, $3); }
923 | binding_mode ident '@' pat { $$ = mk_node("PatIdent", 3, $1, $2, $4); }
924 | BOX pat { $$ = mk_node("PatUniq", 1, $2); }
925 | '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident { $$ = mk_node("PatQualifiedPath", 3, $2, $3, $6); }
926 | SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident
928 $$ = mk_node("PatQualifiedPath", 3, mk_node("PatQualifiedPath", 3, $2, $3, $6), $7, $10);
933 : pat { $$ = mk_node("Pats", 1, $1); }
934 | pats_or '|' pat { $$ = ext_node($1, 1, $3); }
938 : REF { $$ = mk_node("BindByRef", 1, mk_atom("MutImmutable")); }
939 | REF MUT { $$ = mk_node("BindByRef", 1, mk_atom("MutMutable")); }
940 | MUT { $$ = mk_node("BindByValue", 1, mk_atom("MutMutable")); }
944 : path_expr { $$ = mk_node("PatLit", 1, $1); }
945 | lit { $$ = mk_node("PatLit", 1, $1); }
946 | '-' lit { $$ = mk_node("PatLit", 1, $2); }
950 : ident { $$ = mk_node("PatField", 1, $1); }
951 | binding_mode ident { $$ = mk_node("PatField", 2, $1, $2); }
952 | BOX ident { $$ = mk_node("PatField", 2, mk_atom("box"), $2); }
953 | BOX binding_mode ident { $$ = mk_node("PatField", 3, mk_atom("box"), $2, $3); }
954 | ident ':' pat { $$ = mk_node("PatField", 2, $1, $3); }
955 | binding_mode ident ':' pat { $$ = mk_node("PatField", 3, $1, $2, $4); }
959 : pat_field { $$ = mk_node("PatFields", 1, $1); }
960 | pat_fields ',' pat_field { $$ = ext_node($1, 1, $3); }
964 : pat_fields { $$ = mk_node("PatStruct", 2, $1, mk_atom("false")); }
965 | pat_fields ',' { $$ = mk_node("PatStruct", 2, $1, mk_atom("false")); }
966 | pat_fields ',' DOTDOT { $$ = mk_node("PatStruct", 2, $1, mk_atom("true")); }
967 | DOTDOT { $$ = mk_node("PatStruct", 1, mk_atom("true")); }
971 : pat { $$ = mk_node("pat_tup", 1, $1); }
972 | pat_tup ',' pat { $$ = ext_node($1, 1, $3); }
976 : pat_vec_elts { $$ = mk_node("PatVec", 2, $1, mk_none()); }
977 | pat_vec_elts ',' { $$ = mk_node("PatVec", 2, $1, mk_none()); }
978 | pat_vec_elts DOTDOT { $$ = mk_node("PatVec", 2, $1, mk_none()); }
979 | pat_vec_elts ',' DOTDOT { $$ = mk_node("PatVec", 2, $1, mk_none()); }
980 | pat_vec_elts DOTDOT ',' pat_vec_elts { $$ = mk_node("PatVec", 2, $1, $4); }
981 | pat_vec_elts DOTDOT ',' pat_vec_elts ',' { $$ = mk_node("PatVec", 2, $1, $4); }
982 | pat_vec_elts ',' DOTDOT ',' pat_vec_elts { $$ = mk_node("PatVec", 2, $1, $5); }
983 | pat_vec_elts ',' DOTDOT ',' pat_vec_elts ',' { $$ = mk_node("PatVec", 2, $1, $5); }
984 | DOTDOT ',' pat_vec_elts { $$ = mk_node("PatVec", 2, mk_none(), $3); }
985 | DOTDOT ',' pat_vec_elts ',' { $$ = mk_node("PatVec", 2, mk_none(), $3); }
986 | DOTDOT { $$ = mk_node("PatVec", 2, mk_none(), mk_none()); }
987 | %empty { $$ = mk_node("PatVec", 2, mk_none(), mk_none()); }
991 : pat { $$ = mk_node("PatVecElts", 1, $1); }
992 | pat_vec_elts ',' pat { $$ = ext_node($1, 1, $3); }
995 ////////////////////////////////////////////////////////////////////////
997 ////////////////////////////////////////////////////////////////////////
1002 | '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident { $$ = mk_node("TyQualifiedPath", 3, $2, $3, $6); }
1003 | SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident { $$ = mk_node("TyQualifiedPath", 3, mk_node("TyQualifiedPath", 3, $2, $3, $6), $7, $10); }
1004 | '(' ty_sums ')' { $$ = mk_node("TyTup", 1, $2); }
1005 | '(' ty_sums ',' ')' { $$ = mk_node("TyTup", 1, $2); }
1006 | '(' ')' { $$ = mk_atom("TyNil"); }
1010 : %prec IDENT path_generic_args_without_colons { $$ = mk_node("TyPath", 2, mk_node("global", 1, mk_atom("false")), $1); }
1011 | %prec IDENT MOD_SEP path_generic_args_without_colons { $$ = mk_node("TyPath", 2, mk_node("global", 1, mk_atom("true")), $2); }
1012 | %prec IDENT SELF MOD_SEP path_generic_args_without_colons { $$ = mk_node("TyPath", 2, mk_node("self", 1, mk_atom("true")), $3); }
1013 | BOX ty { $$ = mk_node("TyBox", 1, $2); }
1014 | '*' maybe_mut_or_const ty { $$ = mk_node("TyPtr", 2, $2, $3); }
1015 | '&' ty { $$ = mk_node("TyRptr", 2, mk_atom("MutImmutable"), $2); }
1016 | '&' MUT ty { $$ = mk_node("TyRptr", 2, mk_atom("MutMutable"), $3); }
1017 | ANDAND ty { $$ = mk_node("TyRptr", 1, mk_node("TyRptr", 2, mk_atom("MutImmutable"), $2)); }
1018 | ANDAND MUT ty { $$ = mk_node("TyRptr", 1, mk_node("TyRptr", 2, mk_atom("MutMutable"), $3)); }
1019 | '&' lifetime maybe_mut ty { $$ = mk_node("TyRptr", 3, $2, $3, $4); }
1020 | ANDAND lifetime maybe_mut ty { $$ = mk_node("TyRptr", 1, mk_node("TyRptr", 3, $2, $3, $4)); }
1021 | '[' ty ']' { $$ = mk_node("TyVec", 1, $2); }
1022 | '[' ty ',' DOTDOT expr ']' { $$ = mk_node("TyFixedLengthVec", 2, $2, $5); }
1023 | '[' ty ';' expr ']' { $$ = mk_node("TyFixedLengthVec", 2, $2, $4); }
1024 | TYPEOF '(' expr ')' { $$ = mk_node("TyTypeof", 1, $3); }
1025 | UNDERSCORE { $$ = mk_atom("TyInfer"); }
1032 : FN ty_fn_decl { $$ = $2; }
1033 | UNSAFE FN ty_fn_decl { $$ = $3; }
1034 | EXTERN maybe_abi FN ty_fn_decl { $$ = $4; }
1035 | UNSAFE EXTERN maybe_abi FN ty_fn_decl { $$ = $5; }
1039 : generic_params fn_anon_params ret_ty { $$ = mk_node("TyFnDecl", 3, $1, $2, $3); }
1043 : UNSAFE '|' anon_params '|' maybe_bounds ret_ty { $$ = mk_node("TyClosure", 3, $3, $5, $6); }
1044 | '|' anon_params '|' maybe_bounds ret_ty { $$ = mk_node("TyClosure", 3, $2, $4, $5); }
1045 | UNSAFE OROR maybe_bounds ret_ty { $$ = mk_node("TyClosure", 2, $3, $4); }
1046 | OROR maybe_bounds ret_ty { $$ = mk_node("TyClosure", 2, $2, $3); }
1050 : PROC generic_params fn_params maybe_bounds ret_ty { $$ = mk_node("TyProc", 4, $2, $3, $4, $5); }
1054 : FOR '<' maybe_lifetimes '>' for_in_type_suffix { $$ = mk_node("ForInType", 2, $3, $5); }
1065 : MUT { $$ = mk_atom("MutMutable"); }
1066 | %prec MUT %empty { $$ = mk_atom("MutImmutable"); }
1070 : MUT { $$ = mk_atom("MutMutable"); }
1071 | CONST { $$ = mk_atom("MutImmutable"); }
1072 | %empty { $$ = mk_atom("MutImmutable"); }
1075 ty_qualified_path_and_generic_values
1076 : ty_qualified_path maybe_bindings
1078 $$ = mk_node("GenericValues", 3, mk_none(), mk_node("TySums", 1, mk_node("TySum", 1, $1)), $2);
1080 | ty_qualified_path ',' ty_sums maybe_bindings
1082 $$ = mk_node("GenericValues", 3, mk_none(), mk_node("TySums", 2, $1, $3), $4);
1087 : ty_sum AS trait_ref '>' MOD_SEP ident { $$ = mk_node("TyQualifiedPath", 3, $1, $3, $6); }
1088 | ty_sum AS trait_ref '>' MOD_SEP ident '+' ty_param_bounds { $$ = mk_node("TyQualifiedPath", 3, $1, $3, $6); }
1094 | %empty { $$ = mk_none(); }
1098 : ty_sum { $$ = mk_node("TySums", 1, $1); }
1099 | ty_sums ',' ty_sum { $$ = ext_node($1, 1, $3); }
1103 : ty { $$ = mk_node("TySum", 1, $1); }
1104 | ty '+' ty_param_bounds { $$ = mk_node("TySum", 2, $1, $3); }
1108 : ty_prim { $$ = mk_node("TySum", 1, $1); }
1109 | ty_prim '+' ty_param_bounds { $$ = mk_node("TySum", 2, $1, $3); }
1112 maybe_ty_param_bounds
1113 : ':' ty_param_bounds { $$ = $2; }
1114 | %empty { $$ = mk_none(); }
1119 | %empty { $$ = mk_none(); }
1124 | boundseq '+' polybound { $$ = ext_node($1, 1, $3); }
1128 : FOR '<' maybe_lifetimes '>' bound { $$ = mk_node("PolyBound", 2, $3, $5); }
1130 | '?' bound { $$ = $2; }
1134 : binding { $$ = mk_node("Bindings", 1, $1); }
1135 | bindings ',' binding { $$ = ext_node($1, 1, $3); }
1139 : ident '=' ty { mk_node("Binding", 2, $1, $3); }
1143 : ident maybe_ty_param_bounds maybe_ty_default { $$ = mk_node("TyParam", 3, $1, $2, $3); }
1144 | ident '?' ident maybe_ty_param_bounds maybe_ty_default { $$ = mk_node("TyParam", 4, $1, $3, $4, $5); }
1149 ':' bounds { $$ = $2; }
1150 | %prec SHIFTPLUS %empty { $$ = mk_none(); }
1154 : bound { $$ = mk_node("bounds", 1, $1); }
1155 | bounds '+' bound { $$ = ext_node($1, 1, $3); }
1165 ':' ltbounds { $$ = $2; }
1166 | %empty { $$ = mk_none(); }
1170 : lifetime { $$ = mk_node("ltbounds", 1, $1); }
1171 | ltbounds '+' lifetime { $$ = ext_node($1, 1, $3); }
1175 : '=' ty_sum { $$ = mk_node("TyDefault", 1, $2); }
1176 | %empty { $$ = mk_none(); }
1182 | %empty { $$ = mk_none(); }
1186 : lifetime_and_bounds { $$ = mk_node("Lifetimes", 1, $1); }
1187 | lifetimes ',' lifetime_and_bounds { $$ = ext_node($1, 1, $3); }
1191 : LIFETIME maybe_ltbounds { $$ = mk_node("lifetime", 2, mk_atom(yytext), $2); }
1192 | STATIC_LIFETIME { $$ = mk_atom("static_lifetime"); }
1196 : LIFETIME { $$ = mk_node("lifetime", 1, mk_atom(yytext)); }
1197 | STATIC_LIFETIME { $$ = mk_atom("static_lifetime"); }
1201 : %prec IDENT path_generic_args_without_colons
1202 | %prec IDENT MOD_SEP path_generic_args_without_colons { $$ = $2; }
1205 ////////////////////////////////////////////////////////////////////////
1206 // Part 4: Blocks, statements, and expressions
1207 ////////////////////////////////////////////////////////////////////////
1209 inner_attrs_and_block
1210 : '{' maybe_inner_attrs maybe_stmts '}' { $$ = mk_node("ExprBlock", 2, $2, $3); }
1214 : '{' maybe_stmts '}' { $$ = mk_node("ExprBlock", 1, $2); }
1219 | stmts nonblock_expr { $$ = ext_node($1, 1, $2); }
1221 | %empty { $$ = mk_none(); }
1224 // There are two sub-grammars within a "stmts: exprs" derivation
1225 // depending on whether each stmt-expr is a block-expr form; this is to
1226 // handle the "semicolon rule" for stmt sequencing that permits
1229 // if foo { bar } 10
1231 // as a sequence of two stmts (one if-expr stmt, one lit-10-expr
1232 // stmt). Unfortunately by permitting juxtaposition of exprs in
1233 // sequence like that, the non-block expr grammar has to have a
1234 // second limited sub-grammar that excludes the prefix exprs that
1235 // are ambiguous with binops. That is to say:
1239 // should parse as (progn (progn 10) (- 1)) not (- (progn 10) 1), that
1240 // is to say, two statements rather than one, at least according to
1241 // the mainline rust parser.
1243 // So we wind up with a 3-way split in exprs that occur in stmt lists:
1244 // block, nonblock-prefix, and nonblock-nonprefix.
1246 // In non-stmts contexts, expr can relax this trichotomy.
1248 // There is also one other expr subtype: nonparen_expr disallows exprs
1249 // surrounded by parens (including tuple expressions), this is
1250 // necessary for BOX (place) expressions, so a parens expr following
1251 // the BOX is always parsed as the place.
1254 : stmt { $$ = mk_node("stmts", 1, $1); }
1255 | stmts stmt { $$ = ext_node($1, 1, $2); }
1261 | PUB stmt_item { $$ = $2; }
1262 | outer_attrs stmt_item { $$ = $2; }
1263 | outer_attrs PUB stmt_item { $$ = $3; }
1267 | ';' { $$ = mk_none(); }
1273 | %empty { $$ = mk_none(); }
1278 | %empty { $$ = mk_none(); }
1282 : expr { $$ = mk_node("exprs", 1, $1); }
1283 | exprs ',' expr { $$ = ext_node($1, 1, $3); }
1287 : path_generic_args_with_colons
1288 | MOD_SEP path_generic_args_with_colons { $$ = $2; }
1289 | SELF MOD_SEP path_generic_args_with_colons { $$ = mk_node("SelfPath", 1, $3); }
1292 // A path with a lifetime and type parameters with double colons before
1293 // the type parameters; e.g. `foo::bar::<'a>::Baz::<T>`
1295 // These show up in expr context, in order to disambiguate from "less-than"
1297 path_generic_args_with_colons
1298 : ident { $$ = mk_node("components", 1, $1); }
1299 | path_generic_args_with_colons MOD_SEP ident { $$ = ext_node($1, 1, $3); }
1300 | path_generic_args_with_colons MOD_SEP generic_args { $$ = ext_node($1, 1, $3); }
1303 // the braces-delimited macro is a block_expr so it doesn't appear here
1305 : path_expr '!' maybe_ident parens_delimited_token_trees { $$ = mk_node("MacroExpr", 3, $1, $3, $4); }
1306 | path_expr '!' maybe_ident brackets_delimited_token_trees { $$ = mk_node("MacroExpr", 3, $1, $3, $4); }
1310 : lit { $$ = mk_node("ExprLit", 1, $1); }
1312 path_expr { $$ = mk_node("ExprPath", 1, $1); }
1313 | SELF { $$ = mk_node("ExprPath", 1, mk_node("ident", 1, mk_atom("self"))); }
1314 | macro_expr { $$ = mk_node("ExprMac", 1, $1); }
1315 | path_expr '{' struct_expr_fields '}' { $$ = mk_node("ExprStruct", 2, $1, $3); }
1316 | nonblock_expr '.' path_generic_args_with_colons { $$ = mk_node("ExprField", 2, $1, $3); }
1317 | nonblock_expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
1318 | nonblock_expr '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 2, $1, $3); }
1319 | nonblock_expr '(' maybe_exprs ')' { $$ = mk_node("ExprCall", 2, $1, $3); }
1320 | '[' vec_expr ']' { $$ = mk_node("ExprVec", 1, $2); }
1321 | '(' maybe_exprs ')' { $$ = mk_node("ExprParen", 1, $2); }
1322 | CONTINUE { $$ = mk_node("ExprAgain", 0); }
1323 | CONTINUE lifetime { $$ = mk_node("ExprAgain", 1, $2); }
1324 | RETURN { $$ = mk_node("ExprRet", 0); }
1325 | RETURN expr { $$ = mk_node("ExprRet", 1, $2); }
1326 | BREAK { $$ = mk_node("ExprBreak", 0); }
1327 | BREAK lifetime { $$ = mk_node("ExprBreak", 1, $2); }
1328 | nonblock_expr LARROW expr { $$ = mk_node("ExprInPlace", 2, $1, $3); }
1329 | nonblock_expr '=' expr { $$ = mk_node("ExprAssign", 2, $1, $3); }
1330 | nonblock_expr SHLEQ expr { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
1331 | nonblock_expr SHREQ expr { $$ = mk_node("ExprAssignShr", 2, $1, $3); }
1332 | nonblock_expr MINUSEQ expr { $$ = mk_node("ExprAssignSub", 2, $1, $3); }
1333 | nonblock_expr ANDEQ expr { $$ = mk_node("ExprAssignBitAnd", 2, $1, $3); }
1334 | nonblock_expr OREQ expr { $$ = mk_node("ExprAssignBitOr", 2, $1, $3); }
1335 | nonblock_expr PLUSEQ expr { $$ = mk_node("ExprAssignAdd", 2, $1, $3); }
1336 | nonblock_expr STAREQ expr { $$ = mk_node("ExprAssignMul", 2, $1, $3); }
1337 | nonblock_expr SLASHEQ expr { $$ = mk_node("ExprAssignDiv", 2, $1, $3); }
1338 | nonblock_expr CARETEQ expr { $$ = mk_node("ExprAssignBitXor", 2, $1, $3); }
1339 | nonblock_expr PERCENTEQ expr { $$ = mk_node("ExprAssignRem", 2, $1, $3); }
1340 | nonblock_expr OROR expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiOr"), $1, $3); }
1341 | nonblock_expr ANDAND expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiAnd"), $1, $3); }
1342 | nonblock_expr EQEQ expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiEq"), $1, $3); }
1343 | nonblock_expr NE expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiNe"), $1, $3); }
1344 | nonblock_expr '<' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiLt"), $1, $3); }
1345 | nonblock_expr '>' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiGt"), $1, $3); }
1346 | nonblock_expr LE expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiLe"), $1, $3); }
1347 | nonblock_expr GE expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiGe"), $1, $3); }
1348 | nonblock_expr '|' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiBitOr"), $1, $3); }
1349 | nonblock_expr '^' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiBitXor"), $1, $3); }
1350 | nonblock_expr '&' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiBitAnd"), $1, $3); }
1351 | nonblock_expr SHL expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiShl"), $1, $3); }
1352 | nonblock_expr SHR expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiShr"), $1, $3); }
1353 | nonblock_expr '+' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiAdd"), $1, $3); }
1354 | nonblock_expr '-' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiSub"), $1, $3); }
1355 | nonblock_expr '*' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiMul"), $1, $3); }
1356 | nonblock_expr '/' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiDiv"), $1, $3); }
1357 | nonblock_expr '%' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiRem"), $1, $3); }
1358 | nonblock_expr DOTDOT { $$ = mk_node("ExprRange", 2, $1, mk_none()); }
1359 | nonblock_expr DOTDOT expr { $$ = mk_node("ExprRange", 2, $1, $3); }
1360 | DOTDOT expr { $$ = mk_node("ExprRange", 2, mk_none(), $2); }
1361 | DOTDOT { $$ = mk_node("ExprRange", 2, mk_none(), mk_none()); }
1362 | nonblock_expr AS ty { $$ = mk_node("ExprCast", 2, $1, $3); }
1363 | BOX nonparen_expr { $$ = mk_node("ExprBox", 1, $2); }
1364 | %prec BOXPLACE BOX '(' maybe_expr ')' nonblock_expr { $$ = mk_node("ExprBox", 2, $3, $5); }
1365 | expr_qualified_path
1366 | nonblock_prefix_expr
1370 : lit { $$ = mk_node("ExprLit", 1, $1); }
1372 path_expr { $$ = mk_node("ExprPath", 1, $1); }
1373 | SELF { $$ = mk_node("ExprPath", 1, mk_node("ident", 1, mk_atom("self"))); }
1374 | macro_expr { $$ = mk_node("ExprMac", 1, $1); }
1375 | path_expr '{' struct_expr_fields '}' { $$ = mk_node("ExprStruct", 2, $1, $3); }
1376 | expr '.' path_generic_args_with_colons { $$ = mk_node("ExprField", 2, $1, $3); }
1377 | expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
1378 | expr '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 2, $1, $3); }
1379 | expr '(' maybe_exprs ')' { $$ = mk_node("ExprCall", 2, $1, $3); }
1380 | '(' maybe_exprs ')' { $$ = mk_node("ExprParen", 1, $2); }
1381 | '[' vec_expr ']' { $$ = mk_node("ExprVec", 1, $2); }
1382 | CONTINUE { $$ = mk_node("ExprAgain", 0); }
1383 | CONTINUE ident { $$ = mk_node("ExprAgain", 1, $2); }
1384 | RETURN { $$ = mk_node("ExprRet", 0); }
1385 | RETURN expr { $$ = mk_node("ExprRet", 1, $2); }
1386 | BREAK { $$ = mk_node("ExprBreak", 0); }
1387 | BREAK ident { $$ = mk_node("ExprBreak", 1, $2); }
1388 | expr LARROW expr { $$ = mk_node("ExprInPlace", 2, $1, $3); }
1389 | expr '=' expr { $$ = mk_node("ExprAssign", 2, $1, $3); }
1390 | expr SHLEQ expr { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
1391 | expr SHREQ expr { $$ = mk_node("ExprAssignShr", 2, $1, $3); }
1392 | expr MINUSEQ expr { $$ = mk_node("ExprAssignSub", 2, $1, $3); }
1393 | expr ANDEQ expr { $$ = mk_node("ExprAssignBitAnd", 2, $1, $3); }
1394 | expr OREQ expr { $$ = mk_node("ExprAssignBitOr", 2, $1, $3); }
1395 | expr PLUSEQ expr { $$ = mk_node("ExprAssignAdd", 2, $1, $3); }
1396 | expr STAREQ expr { $$ = mk_node("ExprAssignMul", 2, $1, $3); }
1397 | expr SLASHEQ expr { $$ = mk_node("ExprAssignDiv", 2, $1, $3); }
1398 | expr CARETEQ expr { $$ = mk_node("ExprAssignBitXor", 2, $1, $3); }
1399 | expr PERCENTEQ expr { $$ = mk_node("ExprAssignRem", 2, $1, $3); }
1400 | expr OROR expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiOr"), $1, $3); }
1401 | expr ANDAND expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiAnd"), $1, $3); }
1402 | expr EQEQ expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiEq"), $1, $3); }
1403 | expr NE expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiNe"), $1, $3); }
1404 | expr '<' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiLt"), $1, $3); }
1405 | expr '>' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiGt"), $1, $3); }
1406 | expr LE expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiLe"), $1, $3); }
1407 | expr GE expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiGe"), $1, $3); }
1408 | expr '|' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiBitOr"), $1, $3); }
1409 | expr '^' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiBitXor"), $1, $3); }
1410 | expr '&' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiBitAnd"), $1, $3); }
1411 | expr SHL expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiShl"), $1, $3); }
1412 | expr SHR expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiShr"), $1, $3); }
1413 | expr '+' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiAdd"), $1, $3); }
1414 | expr '-' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiSub"), $1, $3); }
1415 | expr '*' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiMul"), $1, $3); }
1416 | expr '/' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiDiv"), $1, $3); }
1417 | expr '%' expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiRem"), $1, $3); }
1418 | expr DOTDOT { $$ = mk_node("ExprRange", 2, $1, mk_none()); }
1419 | expr DOTDOT expr { $$ = mk_node("ExprRange", 2, $1, $3); }
1420 | DOTDOT expr { $$ = mk_node("ExprRange", 2, mk_none(), $2); }
1421 | DOTDOT { $$ = mk_node("ExprRange", 2, mk_none(), mk_none()); }
1422 | expr AS ty { $$ = mk_node("ExprCast", 2, $1, $3); }
1423 | BOX nonparen_expr { $$ = mk_node("ExprBox", 1, $2); }
1424 | %prec BOXPLACE BOX '(' maybe_expr ')' expr { $$ = mk_node("ExprBox", 2, $3, $5); }
1425 | expr_qualified_path
1428 | nonblock_prefix_expr
1432 : lit { $$ = mk_node("ExprLit", 1, $1); }
1434 path_expr { $$ = mk_node("ExprPath", 1, $1); }
1435 | SELF { $$ = mk_node("ExprPath", 1, mk_node("ident", 1, mk_atom("self"))); }
1436 | macro_expr { $$ = mk_node("ExprMac", 1, $1); }
1437 | path_expr '{' struct_expr_fields '}' { $$ = mk_node("ExprStruct", 2, $1, $3); }
1438 | nonparen_expr '.' path_generic_args_with_colons { $$ = mk_node("ExprField", 2, $1, $3); }
1439 | nonparen_expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
1440 | nonparen_expr '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 2, $1, $3); }
1441 | nonparen_expr '(' maybe_exprs ')' { $$ = mk_node("ExprCall", 2, $1, $3); }
1442 | '[' vec_expr ']' { $$ = mk_node("ExprVec", 1, $2); }
1443 | CONTINUE { $$ = mk_node("ExprAgain", 0); }
1444 | CONTINUE ident { $$ = mk_node("ExprAgain", 1, $2); }
1445 | RETURN { $$ = mk_node("ExprRet", 0); }
1446 | RETURN expr { $$ = mk_node("ExprRet", 1, $2); }
1447 | BREAK { $$ = mk_node("ExprBreak", 0); }
1448 | BREAK ident { $$ = mk_node("ExprBreak", 1, $2); }
1449 | nonparen_expr LARROW nonparen_expr { $$ = mk_node("ExprInPlace", 2, $1, $3); }
1450 | nonparen_expr '=' nonparen_expr { $$ = mk_node("ExprAssign", 2, $1, $3); }
1451 | nonparen_expr SHLEQ nonparen_expr { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
1452 | nonparen_expr SHREQ nonparen_expr { $$ = mk_node("ExprAssignShr", 2, $1, $3); }
1453 | nonparen_expr MINUSEQ nonparen_expr { $$ = mk_node("ExprAssignSub", 2, $1, $3); }
1454 | nonparen_expr ANDEQ nonparen_expr { $$ = mk_node("ExprAssignBitAnd", 2, $1, $3); }
1455 | nonparen_expr OREQ nonparen_expr { $$ = mk_node("ExprAssignBitOr", 2, $1, $3); }
1456 | nonparen_expr PLUSEQ nonparen_expr { $$ = mk_node("ExprAssignAdd", 2, $1, $3); }
1457 | nonparen_expr STAREQ nonparen_expr { $$ = mk_node("ExprAssignMul", 2, $1, $3); }
1458 | nonparen_expr SLASHEQ nonparen_expr { $$ = mk_node("ExprAssignDiv", 2, $1, $3); }
1459 | nonparen_expr CARETEQ nonparen_expr { $$ = mk_node("ExprAssignBitXor", 2, $1, $3); }
1460 | nonparen_expr PERCENTEQ nonparen_expr { $$ = mk_node("ExprAssignRem", 2, $1, $3); }
1461 | nonparen_expr OROR nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiOr"), $1, $3); }
1462 | nonparen_expr ANDAND nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiAnd"), $1, $3); }
1463 | nonparen_expr EQEQ nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiEq"), $1, $3); }
1464 | nonparen_expr NE nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiNe"), $1, $3); }
1465 | nonparen_expr '<' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiLt"), $1, $3); }
1466 | nonparen_expr '>' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiGt"), $1, $3); }
1467 | nonparen_expr LE nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiLe"), $1, $3); }
1468 | nonparen_expr GE nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiGe"), $1, $3); }
1469 | nonparen_expr '|' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiBitOr"), $1, $3); }
1470 | nonparen_expr '^' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiBitXor"), $1, $3); }
1471 | nonparen_expr '&' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiBitAnd"), $1, $3); }
1472 | nonparen_expr SHL nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiShl"), $1, $3); }
1473 | nonparen_expr SHR nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiShr"), $1, $3); }
1474 | nonparen_expr '+' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiAdd"), $1, $3); }
1475 | nonparen_expr '-' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiSub"), $1, $3); }
1476 | nonparen_expr '*' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiMul"), $1, $3); }
1477 | nonparen_expr '/' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiDiv"), $1, $3); }
1478 | nonparen_expr '%' nonparen_expr { $$ = mk_node("ExprBinary", 3, mk_atom("BiRem"), $1, $3); }
1479 | nonparen_expr DOTDOT { $$ = mk_node("ExprRange", 2, $1, mk_none()); }
1480 | nonparen_expr DOTDOT nonparen_expr { $$ = mk_node("ExprRange", 2, $1, $3); }
1481 | DOTDOT nonparen_expr { $$ = mk_node("ExprRange", 2, mk_none(), $2); }
1482 | DOTDOT { $$ = mk_node("ExprRange", 2, mk_none(), mk_none()); }
1483 | nonparen_expr AS ty { $$ = mk_node("ExprCast", 2, $1, $3); }
1484 | BOX nonparen_expr { $$ = mk_node("ExprBox", 1, $2); }
1485 | %prec BOXPLACE BOX '(' maybe_expr ')' expr { $$ = mk_node("ExprBox", 1, $3, $5); }
1486 | expr_qualified_path
1489 | nonblock_prefix_expr
1493 : lit { $$ = mk_node("ExprLit", 1, $1); }
1495 path_expr { $$ = mk_node("ExprPath", 1, $1); }
1496 | SELF { $$ = mk_node("ExprPath", 1, mk_node("ident", 1, mk_atom("self"))); }
1497 | macro_expr { $$ = mk_node("ExprMac", 1, $1); }
1498 | expr_nostruct '.' path_generic_args_with_colons { $$ = mk_node("ExprField", 2, $1, $3); }
1499 | expr_nostruct '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
1500 | expr_nostruct '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 2, $1, $3); }
1501 | expr_nostruct '(' maybe_exprs ')' { $$ = mk_node("ExprCall", 2, $1, $3); }
1502 | '[' vec_expr ']' { $$ = mk_node("ExprVec", 1, $2); }
1503 | '(' maybe_exprs ')' { $$ = mk_node("ExprParen", 1, $2); }
1504 | CONTINUE { $$ = mk_node("ExprAgain", 0); }
1505 | CONTINUE ident { $$ = mk_node("ExprAgain", 1, $2); }
1506 | RETURN { $$ = mk_node("ExprRet", 0); }
1507 | RETURN expr { $$ = mk_node("ExprRet", 1, $2); }
1508 | BREAK { $$ = mk_node("ExprBreak", 0); }
1509 | BREAK ident { $$ = mk_node("ExprBreak", 1, $2); }
1510 | expr_nostruct LARROW expr_nostruct { $$ = mk_node("ExprInPlace", 2, $1, $3); }
1511 | expr_nostruct '=' expr_nostruct { $$ = mk_node("ExprAssign", 2, $1, $3); }
1512 | expr_nostruct SHLEQ expr_nostruct { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
1513 | expr_nostruct SHREQ expr_nostruct { $$ = mk_node("ExprAssignShr", 2, $1, $3); }
1514 | expr_nostruct MINUSEQ expr_nostruct { $$ = mk_node("ExprAssignSub", 2, $1, $3); }
1515 | expr_nostruct ANDEQ expr_nostruct { $$ = mk_node("ExprAssignBitAnd", 2, $1, $3); }
1516 | expr_nostruct OREQ expr_nostruct { $$ = mk_node("ExprAssignBitOr", 2, $1, $3); }
1517 | expr_nostruct PLUSEQ expr_nostruct { $$ = mk_node("ExprAssignAdd", 2, $1, $3); }
1518 | expr_nostruct STAREQ expr_nostruct { $$ = mk_node("ExprAssignMul", 2, $1, $3); }
1519 | expr_nostruct SLASHEQ expr_nostruct { $$ = mk_node("ExprAssignDiv", 2, $1, $3); }
1520 | expr_nostruct CARETEQ expr_nostruct { $$ = mk_node("ExprAssignBitXor", 2, $1, $3); }
1521 | expr_nostruct PERCENTEQ expr_nostruct { $$ = mk_node("ExprAssignRem", 2, $1, $3); }
1522 | expr_nostruct OROR expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiOr"), $1, $3); }
1523 | expr_nostruct ANDAND expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiAnd"), $1, $3); }
1524 | expr_nostruct EQEQ expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiEq"), $1, $3); }
1525 | expr_nostruct NE expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiNe"), $1, $3); }
1526 | expr_nostruct '<' expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiLt"), $1, $3); }
1527 | expr_nostruct '>' expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiGt"), $1, $3); }
1528 | expr_nostruct LE expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiLe"), $1, $3); }
1529 | expr_nostruct GE expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiGe"), $1, $3); }
1530 | expr_nostruct '|' expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiBitOr"), $1, $3); }
1531 | expr_nostruct '^' expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiBitXor"), $1, $3); }
1532 | expr_nostruct '&' expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiBitAnd"), $1, $3); }
1533 | expr_nostruct SHL expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiShl"), $1, $3); }
1534 | expr_nostruct SHR expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiShr"), $1, $3); }
1535 | expr_nostruct '+' expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiAdd"), $1, $3); }
1536 | expr_nostruct '-' expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiSub"), $1, $3); }
1537 | expr_nostruct '*' expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiMul"), $1, $3); }
1538 | expr_nostruct '/' expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiDiv"), $1, $3); }
1539 | expr_nostruct '%' expr_nostruct { $$ = mk_node("ExprBinary", 3, mk_atom("BiRem"), $1, $3); }
1540 | expr_nostruct DOTDOT %prec RANGE { $$ = mk_node("ExprRange", 2, $1, mk_none()); }
1541 | expr_nostruct DOTDOT expr_nostruct { $$ = mk_node("ExprRange", 2, $1, $3); }
1542 | DOTDOT expr_nostruct { $$ = mk_node("ExprRange", 2, mk_none(), $2); }
1543 | DOTDOT { $$ = mk_node("ExprRange", 2, mk_none(), mk_none()); }
1544 | expr_nostruct AS ty { $$ = mk_node("ExprCast", 2, $1, $3); }
1545 | BOX nonparen_expr { $$ = mk_node("ExprBox", 1, $2); }
1546 | %prec BOXPLACE BOX '(' maybe_expr ')' expr_nostruct { $$ = mk_node("ExprBox", 1, $3, $5); }
1547 | expr_qualified_path
1550 | nonblock_prefix_expr_nostruct
1553 nonblock_prefix_expr_nostruct
1554 : '-' expr_nostruct { $$ = mk_node("ExprUnary", 2, mk_atom("UnNeg"), $2); }
1555 | '!' expr_nostruct { $$ = mk_node("ExprUnary", 2, mk_atom("UnNot"), $2); }
1556 | '*' expr_nostruct { $$ = mk_node("ExprUnary", 2, mk_atom("UnDeref"), $2); }
1557 | '&' maybe_mut expr_nostruct { $$ = mk_node("ExprAddrOf", 2, $2, $3); }
1558 | ANDAND maybe_mut expr_nostruct { $$ = mk_node("ExprAddrOf", 1, mk_node("ExprAddrOf", 2, $2, $3)); }
1559 | lambda_expr_nostruct
1560 | MOVE lambda_expr_nostruct { $$ = $2; }
1561 | proc_expr_nostruct
1564 nonblock_prefix_expr
1565 : '-' expr { $$ = mk_node("ExprUnary", 2, mk_atom("UnNeg"), $2); }
1566 | '!' expr { $$ = mk_node("ExprUnary", 2, mk_atom("UnNot"), $2); }
1567 | '*' expr { $$ = mk_node("ExprUnary", 2, mk_atom("UnDeref"), $2); }
1568 | '&' maybe_mut expr { $$ = mk_node("ExprAddrOf", 2, $2, $3); }
1569 | ANDAND maybe_mut expr { $$ = mk_node("ExprAddrOf", 1, mk_node("ExprAddrOf", 2, $2, $3)); }
1571 | MOVE lambda_expr { $$ = $2; }
1576 : '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_qpath_params
1578 $$ = mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7);
1580 | SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident
1582 $$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 3, $2, $3, $6), $7, $10);
1584 | SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args maybe_as_trait_ref '>' MOD_SEP ident
1586 $$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7), $8, $11);
1588 | SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident generic_args
1590 $$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 3, $2, $3, $6), $7, $10, $11);
1592 | SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args maybe_as_trait_ref '>' MOD_SEP ident generic_args
1594 $$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7), $8, $11, $12);
1598 : MOD_SEP generic_args { $$ = $2; }
1599 | %empty { $$ = mk_none(); }
1603 : AS trait_ref { $$ = $2; }
1604 | %empty { $$ = mk_none(); }
1609 OROR ret_ty expr { $$ = mk_node("ExprFnBlock", 3, mk_none(), $2, $3); }
1611 '|' maybe_unboxed_closure_kind '|' ret_ty expr { $$ = mk_node("ExprFnBlock", 3, mk_none(), $4, $5); }
1613 '|' inferrable_params '|' ret_ty expr { $$ = mk_node("ExprFnBlock", 3, $2, $4, $5); }
1615 '|' '&' maybe_mut ':' inferrable_params '|' ret_ty expr { $$ = mk_node("ExprFnBlock", 3, $5, $7, $8); }
1617 '|' ':' inferrable_params '|' ret_ty expr { $$ = mk_node("ExprFnBlock", 3, $3, $5, $6); }
1620 lambda_expr_nostruct
1622 OROR expr_nostruct { $$ = mk_node("ExprFnBlock", 2, mk_none(), $2); }
1624 '|' maybe_unboxed_closure_kind '|' expr_nostruct { $$ = mk_node("ExprFnBlock", 2, mk_none(), $4); }
1626 '|' inferrable_params '|' expr_nostruct { $$ = mk_node("ExprFnBlock", 2, $2, $4); }
1628 '|' '&' maybe_mut ':' inferrable_params '|' expr_nostruct { $$ = mk_node("ExprFnBlock", 2, $5, $7); }
1630 '|' ':' inferrable_params '|' expr_nostruct { $$ = mk_node("ExprFnBlock", 2, $3, $5); }
1636 PROC '(' ')' expr { $$ = mk_node("ExprProc", 2, mk_none(), $4); }
1638 PROC '(' inferrable_params ')' expr { $$ = mk_node("ExprProc", 2, $3, $5); }
1643 PROC '(' ')' expr_nostruct { $$ = mk_node("ExprProc", 2, mk_none(), $4); }
1645 PROC '(' inferrable_params ')' expr_nostruct { $$ = mk_node("ExprProc", 2, $3, $5); }
1650 | exprs ';' expr { $$ = mk_node("VecRepeat", 2, $1, $3); }
1656 | maybe_field_inits default_field_init { $$ = ext_node($1, 1, $2); }
1662 | %empty { $$ = mk_none(); }
1666 : field_init { $$ = mk_node("FieldInits", 1, $1); }
1667 | field_inits ',' field_init { $$ = ext_node($1, 1, $3); }
1671 : ident ':' expr { $$ = mk_node("FieldInit", 2, $1, $3); }
1675 : DOTDOT expr { $$ = mk_node("DefaultFieldInit", 1, $2); }
1686 | UNSAFE block { $$ = mk_node("UnsafeBlock", 1, $2); }
1687 | path_expr '!' maybe_ident braces_delimited_token_trees { $$ = mk_node("Macro", 3, $1, $3, $4); }
1692 | full_block_expr '.' path_generic_args_with_colons %prec IDENT { $$ = mk_node("ExprField", 2, $1, $3); }
1693 | full_block_expr '.' path_generic_args_with_colons '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 3, $1, $3, $5); }
1694 | full_block_expr '.' path_generic_args_with_colons '(' maybe_exprs ')' { $$ = mk_node("ExprCall", 3, $1, $3, $5); }
1695 | full_block_expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
1699 : MATCH expr_nostruct '{' '}' { $$ = mk_node("ExprMatch", 1, $2); }
1700 | MATCH expr_nostruct '{' match_clauses '}' { $$ = mk_node("ExprMatch", 2, $2, $4); }
1701 | MATCH expr_nostruct '{' match_clauses nonblock_match_clause '}' { $$ = mk_node("ExprMatch", 2, $2, ext_node($4, 1, $5)); }
1702 | MATCH expr_nostruct '{' nonblock_match_clause '}' { $$ = mk_node("ExprMatch", 2, $2, mk_node("Arms", 1, $4)); }
1706 : match_clause { $$ = mk_node("Arms", 1, $1); }
1707 | match_clauses match_clause { $$ = ext_node($1, 1, $2); }
1711 : nonblock_match_clause ','
1712 | block_match_clause
1713 | block_match_clause ','
1716 nonblock_match_clause
1717 : maybe_outer_attrs pats_or maybe_guard FAT_ARROW nonblock_expr { $$ = mk_node("Arm", 4, $1, $2, $3, $5); }
1718 | maybe_outer_attrs pats_or maybe_guard FAT_ARROW full_block_expr { $$ = mk_node("Arm", 4, $1, $2, $3, $5); }
1722 : maybe_outer_attrs pats_or maybe_guard FAT_ARROW block { $$ = mk_node("Arm", 4, $1, $2, $3, $5); }
1726 : IF expr_nostruct { $$ = $2; }
1727 | %empty { $$ = mk_none(); }
1731 : IF expr_nostruct block { $$ = mk_node("ExprIf", 2, $2, $3); }
1732 | IF expr_nostruct block ELSE block_or_if { $$ = mk_node("ExprIf", 3, $2, $3, $5); }
1736 : IF LET pat '=' expr_nostruct block { $$ = mk_node("ExprIfLet", 3, $3, $5, $6); }
1737 | IF LET pat '=' expr_nostruct block ELSE block_or_if { $$ = mk_node("ExprIfLet", 4, $3, $5, $6, $8); }
1747 : maybe_label WHILE expr_nostruct block { $$ = mk_node("ExprWhile", 3, $1, $3, $4); }
1751 : maybe_label WHILE LET pat '=' expr_nostruct block { $$ = mk_node("ExprWhileLet", 4, $1, $4, $6, $7); }
1755 : maybe_label LOOP block { $$ = mk_node("ExprLoop", 2, $1, $3); }
1759 : maybe_label FOR pat IN expr_nostruct block { $$ = mk_node("ExprForLoop", 4, $1, $3, $5, $6); }
1764 | %empty { $$ = mk_none(); }
1768 : LET pat maybe_ty_ascription maybe_init_expr ';' { $$ = mk_node("DeclLocal", 3, $2, $3, $4); }
1771 ////////////////////////////////////////////////////////////////////////
1772 // Part 5: Macros and misc. rules
1773 ////////////////////////////////////////////////////////////////////////
1776 : LIT_BYTE { $$ = mk_node("LitByte", 1, mk_atom(yytext)); }
1777 | LIT_CHAR { $$ = mk_node("LitChar", 1, mk_atom(yytext)); }
1778 | LIT_INTEGER { $$ = mk_node("LitInteger", 1, mk_atom(yytext)); }
1779 | LIT_FLOAT { $$ = mk_node("LitFloat", 1, mk_atom(yytext)); }
1780 | TRUE { $$ = mk_node("LitBool", 1, mk_atom(yytext)); }
1781 | FALSE { $$ = mk_node("LitBool", 1, mk_atom(yytext)); }
1786 : LIT_STR { $$ = mk_node("LitStr", 1, mk_atom(yytext), mk_atom("CookedStr")); }
1787 | LIT_STR_RAW { $$ = mk_node("LitStr", 1, mk_atom(yytext), mk_atom("RawStr")); }
1788 | LIT_BYTE_STR { $$ = mk_node("LitByteStr", 1, mk_atom(yytext), mk_atom("ByteStr")); }
1789 | LIT_BYTE_STR_RAW { $$ = mk_node("LitByteStr", 1, mk_atom(yytext), mk_atom("RawByteStr")); }
1793 : %empty { $$ = mk_none(); }
1798 : IDENT { $$ = mk_node("ident", 1, mk_atom(yytext)); }
1802 : SHL { $$ = mk_atom(yytext); }
1803 | SHR { $$ = mk_atom(yytext); }
1804 | LE { $$ = mk_atom(yytext); }
1805 | EQEQ { $$ = mk_atom(yytext); }
1806 | NE { $$ = mk_atom(yytext); }
1807 | GE { $$ = mk_atom(yytext); }
1808 | ANDAND { $$ = mk_atom(yytext); }
1809 | OROR { $$ = mk_atom(yytext); }
1810 | LARROW { $$ = mk_atom(yytext); }
1811 | SHLEQ { $$ = mk_atom(yytext); }
1812 | SHREQ { $$ = mk_atom(yytext); }
1813 | MINUSEQ { $$ = mk_atom(yytext); }
1814 | ANDEQ { $$ = mk_atom(yytext); }
1815 | OREQ { $$ = mk_atom(yytext); }
1816 | PLUSEQ { $$ = mk_atom(yytext); }
1817 | STAREQ { $$ = mk_atom(yytext); }
1818 | SLASHEQ { $$ = mk_atom(yytext); }
1819 | CARETEQ { $$ = mk_atom(yytext); }
1820 | PERCENTEQ { $$ = mk_atom(yytext); }
1821 | DOTDOT { $$ = mk_atom(yytext); }
1822 | DOTDOTDOT { $$ = mk_atom(yytext); }
1823 | MOD_SEP { $$ = mk_atom(yytext); }
1824 | RARROW { $$ = mk_atom(yytext); }
1825 | FAT_ARROW { $$ = mk_atom(yytext); }
1826 | LIT_BYTE { $$ = mk_atom(yytext); }
1827 | LIT_CHAR { $$ = mk_atom(yytext); }
1828 | LIT_INTEGER { $$ = mk_atom(yytext); }
1829 | LIT_FLOAT { $$ = mk_atom(yytext); }
1830 | LIT_STR { $$ = mk_atom(yytext); }
1831 | LIT_STR_RAW { $$ = mk_atom(yytext); }
1832 | LIT_BYTE_STR { $$ = mk_atom(yytext); }
1833 | LIT_BYTE_STR_RAW { $$ = mk_atom(yytext); }
1834 | IDENT { $$ = mk_atom(yytext); }
1835 | UNDERSCORE { $$ = mk_atom(yytext); }
1836 | LIFETIME { $$ = mk_atom(yytext); }
1837 | SELF { $$ = mk_atom(yytext); }
1838 | STATIC { $$ = mk_atom(yytext); }
1839 | AS { $$ = mk_atom(yytext); }
1840 | BREAK { $$ = mk_atom(yytext); }
1841 | CRATE { $$ = mk_atom(yytext); }
1842 | ELSE { $$ = mk_atom(yytext); }
1843 | ENUM { $$ = mk_atom(yytext); }
1844 | EXTERN { $$ = mk_atom(yytext); }
1845 | FALSE { $$ = mk_atom(yytext); }
1846 | FN { $$ = mk_atom(yytext); }
1847 | FOR { $$ = mk_atom(yytext); }
1848 | IF { $$ = mk_atom(yytext); }
1849 | IMPL { $$ = mk_atom(yytext); }
1850 | IN { $$ = mk_atom(yytext); }
1851 | LET { $$ = mk_atom(yytext); }
1852 | LOOP { $$ = mk_atom(yytext); }
1853 | MATCH { $$ = mk_atom(yytext); }
1854 | MOD { $$ = mk_atom(yytext); }
1855 | MOVE { $$ = mk_atom(yytext); }
1856 | MUT { $$ = mk_atom(yytext); }
1857 | PRIV { $$ = mk_atom(yytext); }
1858 | PUB { $$ = mk_atom(yytext); }
1859 | REF { $$ = mk_atom(yytext); }
1860 | RETURN { $$ = mk_atom(yytext); }
1861 | STRUCT { $$ = mk_atom(yytext); }
1862 | TRUE { $$ = mk_atom(yytext); }
1863 | TRAIT { $$ = mk_atom(yytext); }
1864 | TYPE { $$ = mk_atom(yytext); }
1865 | UNSAFE { $$ = mk_atom(yytext); }
1866 | USE { $$ = mk_atom(yytext); }
1867 | WHILE { $$ = mk_atom(yytext); }
1868 | CONTINUE { $$ = mk_atom(yytext); }
1869 | PROC { $$ = mk_atom(yytext); }
1870 | BOX { $$ = mk_atom(yytext); }
1871 | CONST { $$ = mk_atom(yytext); }
1872 | WHERE { $$ = mk_atom(yytext); }
1873 | TYPEOF { $$ = mk_atom(yytext); }
1874 | INNER_DOC_COMMENT { $$ = mk_atom(yytext); }
1875 | OUTER_DOC_COMMENT { $$ = mk_atom(yytext); }
1876 | SHEBANG { $$ = mk_atom(yytext); }
1877 | STATIC_LIFETIME { $$ = mk_atom(yytext); }
1878 | ';' { $$ = mk_atom(yytext); }
1879 | ',' { $$ = mk_atom(yytext); }
1880 | '.' { $$ = mk_atom(yytext); }
1881 | '@' { $$ = mk_atom(yytext); }
1882 | '#' { $$ = mk_atom(yytext); }
1883 | '~' { $$ = mk_atom(yytext); }
1884 | ':' { $$ = mk_atom(yytext); }
1885 | '$' { $$ = mk_atom(yytext); }
1886 | '=' { $$ = mk_atom(yytext); }
1887 | '?' { $$ = mk_atom(yytext); }
1888 | '!' { $$ = mk_atom(yytext); }
1889 | '<' { $$ = mk_atom(yytext); }
1890 | '>' { $$ = mk_atom(yytext); }
1891 | '-' { $$ = mk_atom(yytext); }
1892 | '&' { $$ = mk_atom(yytext); }
1893 | '|' { $$ = mk_atom(yytext); }
1894 | '+' { $$ = mk_atom(yytext); }
1895 | '*' { $$ = mk_atom(yytext); }
1896 | '/' { $$ = mk_atom(yytext); }
1897 | '^' { $$ = mk_atom(yytext); }
1898 | '%' { $$ = mk_atom(yytext); }
1902 : %empty { $$ = mk_node("TokenTrees", 0); }
1903 | token_trees token_tree { $$ = ext_node($1, 1, $2); }
1907 : delimited_token_trees
1908 | unpaired_token { $$ = mk_node("TTTok", 1, $1); }
1911 delimited_token_trees
1912 : parens_delimited_token_trees
1913 | braces_delimited_token_trees
1914 | brackets_delimited_token_trees
1917 parens_delimited_token_trees
1918 : '(' token_trees ')'
1920 $$ = mk_node("TTDelim", 3,
1921 mk_node("TTTok", 1, mk_atom("(")),
1923 mk_node("TTTok", 1, mk_atom(")")));
1927 braces_delimited_token_trees
1928 : '{' token_trees '}'
1930 $$ = mk_node("TTDelim", 3,
1931 mk_node("TTTok", 1, mk_atom("{")),
1933 mk_node("TTTok", 1, mk_atom("}")));
1937 brackets_delimited_token_trees
1938 : '[' token_trees ']'
1940 $$ = mk_node("TTDelim", 3,
1941 mk_node("TTTok", 1, mk_atom("[")),
1943 mk_node("TTTok", 1, mk_atom("]")));