aboutsummaryrefslogtreecommitdiff
path: root/xtask/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-30 13:51:08 +0100
committerAleksey Kladov <[email protected]>2020-07-30 14:16:05 +0100
commit1142112c70b705f59b7d559d9d72cdc831865158 (patch)
tree1ca467302b268c800da8b26482e90effcea08229 /xtask/src
parent3e1e6227ca525f8631e0bff2215fa3de1b4f4cc1 (diff)
Rename FnDef -> Fn
Diffstat (limited to 'xtask/src')
-rw-r--r--xtask/src/ast_src.rs2
-rw-r--r--xtask/src/codegen/gen_syntax.rs7
-rw-r--r--xtask/src/codegen/rust.ungram46
3 files changed, 30 insertions, 25 deletions
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs
index 3a58217c4..40693ed17 100644
--- a/xtask/src/ast_src.rs
+++ b/xtask/src/ast_src.rs
@@ -96,7 +96,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
96 "STRUCT_DEF", 96 "STRUCT_DEF",
97 "UNION_DEF", 97 "UNION_DEF",
98 "ENUM_DEF", 98 "ENUM_DEF",
99 "FN_DEF", 99 "FN",
100 "RET_TYPE", 100 "RET_TYPE",
101 "EXTERN_CRATE", 101 "EXTERN_CRATE",
102 "MODULE", 102 "MODULE",
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs
index c77fc8a8d..072527208 100644
--- a/xtask/src/codegen/gen_syntax.rs
+++ b/xtask/src/codegen/gen_syntax.rs
@@ -471,6 +471,7 @@ impl Field {
471 "::" => "coloncolon", 471 "::" => "coloncolon",
472 "#" => "pound", 472 "#" => "pound",
473 "?" => "question_mark", 473 "?" => "question_mark",
474 "," => "comma",
474 _ => name, 475 _ => name,
475 }; 476 };
476 format_ident!("{}_token", name) 477 format_ident!("{}_token", name)
@@ -599,13 +600,9 @@ fn lower_rule(acc: &mut Vec<Field>, grammar: &Grammar, rule: &Rule) {
599 } 600 }
600} 601}
601 602
602// (T (',' T)* ','?)? 603// (T (',' T)* ','?)
603fn lower_comma_list(acc: &mut Vec<Field>, grammar: &Grammar, rule: &Rule) -> bool { 604fn lower_comma_list(acc: &mut Vec<Field>, grammar: &Grammar, rule: &Rule) -> bool {
604 let rule = match rule { 605 let rule = match rule {
605 Rule::Opt(it) => it,
606 _ => return false,
607 };
608 let rule = match &**rule {
609 Rule::Seq(it) => it, 606 Rule::Seq(it) => it,
610 _ => return false, 607 _ => return false,
611 }; 608 };
diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram
index 449b0242f..98968dece 100644
--- a/xtask/src/codegen/rust.ungram
+++ b/xtask/src/codegen/rust.ungram
@@ -8,7 +8,7 @@ Item =
8| EnumDef 8| EnumDef
9| ExternBlock 9| ExternBlock
10| ExternCrate 10| ExternCrate
11| FnDef 11| Fn
12| ImplDef 12| ImplDef
13| MacroCall 13| MacroCall
14| Module 14| Module
@@ -42,12 +42,33 @@ UseTree =
42UseTreeList = 42UseTreeList =
43 '{' (UseTree (',' UseTree)* ','?)? '}' 43 '{' (UseTree (',' UseTree)* ','?)? '}'
44 44
45FnDef = 45Fn =
46 Attr* Visibility? Abi? 'const' 'default' 'async' 'unsafe' 'fn' Name TypeParamList? 46 Attr* Visibility?
47 ParamList RetType? 47 'default'? ('async' | 'const')? 'unsafe'? Abi?
48 'fn' Name TypeParamList? ParamList RetType?
48 WhereClause? 49 WhereClause?
49 (body:BlockExpr | ';') 50 (body:BlockExpr | ';')
50 51
52Abi =
53 'extern' 'string'?
54
55ParamList =
56 '('(
57 (Param (',' Param)* ','?)?
58 | SelfParam ','?
59 | SelfParam ',' (Param (',' Param)* ','?)
60 )')'
61
62SelfParam =
63 Attr* (
64 ('&' 'lifetime'?)? 'mut'? 'self'
65 | 'mut'? 'self' ':' ascribed_type:TypeRef
66 )
67
68Param =
69 Attr* Pat (':' ascribed_type:TypeRef)
70| '...'
71
51RetType = 72RetType =
52 '->' TypeRef 73 '->' TypeRef
53 74
@@ -388,9 +409,6 @@ WherePred =
388WhereClause = 409WhereClause =
389 'where' predicates:WherePred* 410 'where' predicates:WherePred*
390 411
391Abi =
392 'string'
393
394ExprStmt = 412ExprStmt =
395 Attr* Expr ';' 413 Attr* Expr ';'
396 414
@@ -398,16 +416,6 @@ LetStmt =
398 Attr* 'let' Pat (':' ascribed_type:TypeRef) 416 Attr* 'let' Pat (':' ascribed_type:TypeRef)
399 '=' initializer:Expr ';' 417 '=' initializer:Expr ';'
400 418
401ParamList =
402 '(' SelfParam Param* ')'
403
404SelfParam =
405 Attr* ('&' 'lifetime'?)? 'mut'? 'self' (':' ascribed_type:TypeRef)
406
407Param =
408 Attr* Pat (':' ascribed_type:TypeRef)
409| '...'
410
411Path = 419Path =
412 (qualifier:Path '::')? segment:PathSegment 420 (qualifier:Path '::')? segment:PathSegment
413 421
@@ -465,13 +473,13 @@ TypeRef =
465| DynTraitType 473| DynTraitType
466 474
467AssocItem = 475AssocItem =
468 FnDef 476 Fn
469| TypeAliasDef 477| TypeAliasDef
470| ConstDef 478| ConstDef
471| MacroCall 479| MacroCall
472 480
473ExternItem = 481ExternItem =
474 FnDef | StaticDef 482 Fn | StaticDef
475 483
476AttrInput = 484AttrInput =
477 Literal 485 Literal