From 572f1c08b6ba43bdd57c5cb99f79a08ecd821c1c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 19:49:26 +0200 Subject: Minor gramamr reorder --- xtask/src/codegen/rust.ungram | 124 +++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 61 deletions(-) (limited to 'xtask') diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index 2e3b45011..27bf563b6 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram @@ -1,3 +1,9 @@ +Name = + 'ident' + +NameRef = + 'ident' | 'int_number' + Path = (qualifier:Path '::')? segment:PathSegment @@ -29,6 +35,21 @@ LifetimeArg = ConstArg = Expr +MacroCall = + Attr* Path '!' Name? TokenTree ';'? + +TokenTree = + '(' ')' +| '{' '}' +| '[' ']' + +MacroItems = + Item* + +MacroStmts = + statements:Stmt* + Expr? + SourceFile = 'shebang'? Attr* @@ -475,41 +496,37 @@ TypeBound = 'lifetime' | '?'? Type -OrPat = - Pat* - -ParenPat = - '(' Pat ')' - -RefPat = - '&' 'mut'? Pat - -BoxPat = - 'box' Path - -BindPat = - Attr* 'ref'? 'mut'? Name ('@' Pat)? - -PlaceholderPat = - '_' +Pat = + BindPat +| BoxPat +| DotDotPat +| LiteralPat +| MacroPat +| OrPat +| ParenPat +| PathPat +| PlaceholderPat +| RangePat +| RecordPat +| RefPat +| SlicePat +| TuplePat +| TupleStructPat -DotDotPat = - '..' +LiteralPat = + Literal PathPat = Path -SlicePat = - '[' args:Pat* ']' +PlaceholderPat = + '_' RangePat = - '..' | '..=' - -LiteralPat = - Literal + start:Pat op:('..' | '..=') end:Pat -MacroPat = - MacroCall +RefPat = + '&' 'mut'? Pat RecordPat = Path RecordFieldPatList @@ -522,46 +539,31 @@ RecordFieldPatList = '}' RecordFieldPat = - Attr* NameRef ':' Pat + Attr* (NameRef ':')? Pat -TupleStructPat = - Path '(' args:Pat* ')' +OrPat = + Pat* -TuplePat = - '(' args:Pat* ')' +ParenPat = + '(' Pat ')' -Name = - 'ident' +BoxPat = + 'box' Path -NameRef = - 'ident' | 'int_number' +BindPat = + Attr* 'ref'? 'mut'? Name ('@' Pat)? -MacroCall = - Attr* Path '!' Name? TokenTree ';'? +DotDotPat = + '..' -TokenTree = - '(' ')' | '{' '}' | '[' ']' +SlicePat = + '[' args:Pat* ']' -MacroItems = - Item* +MacroPat = + MacroCall -MacroStmts = - statements:Stmt* - Expr? +TupleStructPat = + Path '(' args:Pat* ')' -Pat = - OrPat -| ParenPat -| RefPat -| BoxPat -| BindPat -| PlaceholderPat -| DotDotPat -| PathPat -| RecordPat -| TupleStructPat -| TuplePat -| SlicePat -| RangePat -| LiteralPat -| MacroPat +TuplePat = + '(' args:Pat* ')' -- cgit v1.2.3 From 14cb96ec0e6be3b99bfe4ea373c058dcbd2a4f79 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 19:54:16 +0200 Subject: Allign RecordPat with RecordExpr --- xtask/src/ast_src.rs | 4 ++-- xtask/src/codegen/rust.ungram | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'xtask') diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index 762d9265e..869bdaa0d 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs @@ -131,8 +131,8 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { "DOT_DOT_PAT", "PATH_PAT", "RECORD_PAT", - "RECORD_FIELD_PAT_LIST", - "RECORD_FIELD_PAT", + "RECORD_PAT_FIELD_LIST", + "RECORD_PAT_FIELD", "TUPLE_STRUCT_PAT", "TUPLE_PAT", "SLICE_PAT", diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index 27bf563b6..643668863 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram @@ -529,16 +529,15 @@ RefPat = '&' 'mut'? Pat RecordPat = - Path RecordFieldPatList + Path RecordPatFieldList -RecordFieldPatList = +RecordPatFieldList = '{' - record_field_pats:RecordFieldPat* - BindPat* + fields:(RecordPatField (',' RecordPatField)* ','?) '..'? '}' -RecordFieldPat = +RecordPatField = Attr* (NameRef ':')? Pat OrPat = -- cgit v1.2.3 From d7f75db90d99216c13000681ff2c4a887451c4b2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 20:04:40 +0200 Subject: Reorder --- xtask/src/codegen/rust.ungram | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'xtask') diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index 643668863..cb8a307fe 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram @@ -516,8 +516,8 @@ Pat = LiteralPat = Literal -PathPat = - Path +BindPat = + Attr* 'ref'? 'mut'? Name ('@' Pat)? PlaceholderPat = '_' @@ -540,29 +540,29 @@ RecordPatFieldList = RecordPatField = Attr* (NameRef ':')? Pat -OrPat = - Pat* +TupleStructPat = + Path '(' args:(Pat (',' Pat)* ','?)? ')' + +TuplePat = + '(' args:(Pat (',' Pat)* ','?)? ')' ParenPat = '(' Pat ')' -BoxPat = - 'box' Path +SlicePat = + '[' args:(Pat (',' Pat)* ','?)? ']' -BindPat = - Attr* 'ref'? 'mut'? Name ('@' Pat)? +PathPat = + Path + +OrPat = + (Pat ('|' Pat)* '|'?) + +BoxPat = + 'box' Pat DotDotPat = '..' -SlicePat = - '[' args:Pat* ']' - MacroPat = MacroCall - -TupleStructPat = - Path '(' args:Pat* ')' - -TuplePat = - '(' args:Pat* ')' -- cgit v1.2.3 From 6791eb9685375da94556bb910ea71f78b08be5ec Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 20:07:21 +0200 Subject: Rename PalceholderPat -> WildcardPat --- xtask/src/ast_src.rs | 2 +- xtask/src/codegen/rust.ungram | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'xtask') diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index 869bdaa0d..fbe36d2f5 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs @@ -127,7 +127,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { "REF_PAT", "BOX_PAT", "BIND_PAT", - "PLACEHOLDER_PAT", + "WILDCARD_PAT", "DOT_DOT_PAT", "PATH_PAT", "RECORD_PAT", diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index cb8a307fe..7c814240a 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram @@ -505,7 +505,7 @@ Pat = | OrPat | ParenPat | PathPat -| PlaceholderPat +| WildcardPat | RangePat | RecordPat | RefPat @@ -519,7 +519,7 @@ LiteralPat = BindPat = Attr* 'ref'? 'mut'? Name ('@' Pat)? -PlaceholderPat = +WildcardPat = '_' RangePat = -- cgit v1.2.3 From 98181087984157e27faba0b969e384f3c62c39d5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 20:09:09 +0200 Subject: Rename BindPat -> IdentPat --- xtask/src/ast_src.rs | 2 +- xtask/src/codegen/rust.ungram | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'xtask') diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index fbe36d2f5..2ff029158 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs @@ -126,7 +126,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { "PAREN_PAT", "REF_PAT", "BOX_PAT", - "BIND_PAT", + "IDENT_PAT", "WILDCARD_PAT", "DOT_DOT_PAT", "PATH_PAT", diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index 7c814240a..7685f4f06 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram @@ -497,7 +497,7 @@ TypeBound = | '?'? Type Pat = - BindPat + IdentPat | BoxPat | DotDotPat | LiteralPat @@ -516,7 +516,7 @@ Pat = LiteralPat = Literal -BindPat = +IdentPat = Attr* 'ref'? 'mut'? Name ('@' Pat)? WildcardPat = -- cgit v1.2.3