From 54fd09a9ca567fc79cae53237dfeedc5baeec635 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 18:27:23 +0200 Subject: Finalize Path grammar --- xtask/src/codegen/rust.ungram | 57 +++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 27 deletions(-) (limited to 'xtask') diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index bc1dd6761..13ad67ca1 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram @@ -1,3 +1,33 @@ +Path = + (qualifier:Path '::')? segment:PathSegment + +PathSegment = + '::' | 'crate' | 'self' | 'super' +| (NameRef ('::'? TypeArgList)?) +| NameRef ParamList RetType? +| '<' PathType ('as' PathType)? '>' + +TypeArgList = + '::'? '<' + TypeArg* + LifetimeArg* + AssocTypeArg* + ConstArg* + '>' + +TypeArg = + Type + +AssocTypeArg = + NameRef (':' TypeBoundList | '=' Type) + +LifetimeArg = + 'lifetime' + +ConstArg = + Literal | BlockExpr BlockExpr + + SourceFile = 'shebang'? Attr* @@ -521,33 +551,6 @@ MacroStmts = statements:Stmt* Expr? -Path = - (qualifier:Path '::')? segment:PathSegment - -PathSegment = - '::' | 'crate' | 'self' | 'super' -| '<' NameRef TypeArgList ParamList RetType PathType '>' - -TypeArgList = - '::'? '<' - TypeArg* - LifetimeArg* - AssocTypeArg* - ConstArg* - '>' - -TypeArg = - Type - -AssocTypeArg = - NameRef (':' TypeBoundList | '=' Type) - -LifetimeArg = - 'lifetime' - -ConstArg = - Literal | BlockExpr BlockExpr - Pat = OrPat | ParenPat -- cgit v1.2.3 From 91781c7ce8201b28afd56b4e35eba47e076a8498 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 18:29:29 +0200 Subject: Rename TypeArgList -> GenericArgList --- xtask/src/ast_src.rs | 2 +- xtask/src/codegen/rust.ungram | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'xtask') diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index 427406249..762d9265e 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs @@ -208,7 +208,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { "LIFETIME_PARAM", "TYPE_PARAM", "CONST_PARAM", - "TYPE_ARG_LIST", + "GENERIC_ARG_LIST", "LIFETIME_ARG", "TYPE_ARG", "ASSOC_TYPE_ARG", diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index 13ad67ca1..8acd02f75 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram @@ -3,11 +3,11 @@ Path = PathSegment = '::' | 'crate' | 'self' | 'super' -| (NameRef ('::'? TypeArgList)?) +| (NameRef ('::'? GenericArgList)?) | NameRef ParamList RetType? | '<' PathType ('as' PathType)? '>' -TypeArgList = +GenericArgList = '::'? '<' TypeArg* LifetimeArg* @@ -348,7 +348,7 @@ ArgList = '(' args:(Expr (',' Expr)* ','?)? ')' MethodCallExpr = - Attr* Expr '.' NameRef TypeArgList? ArgList + Attr* Expr '.' NameRef GenericArgList? ArgList FieldExpr = Attr* Expr '.' NameRef -- cgit v1.2.3 From d21b5db891d605c7c10118daca1f06c09c14b07e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 18:30:02 +0200 Subject: fixup! Finalize Path grammar --- xtask/src/codegen/rust.ungram | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xtask') diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index 8acd02f75..cb4cd49fe 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram @@ -3,7 +3,7 @@ Path = PathSegment = '::' | 'crate' | 'self' | 'super' -| (NameRef ('::'? GenericArgList)?) +| NameRef GenericArgList? | NameRef ParamList RetType? | '<' PathType ('as' PathType)? '>' -- cgit v1.2.3 From 040b4c800d5279e77a6825fc90cb2921d26c7f95 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 18:41:37 +0200 Subject: Fix GenericArgs grammar --- xtask/src/codegen/rust.ungram | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'xtask') diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index cb4cd49fe..fa18acbb3 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram @@ -8,12 +8,13 @@ PathSegment = | '<' PathType ('as' PathType)? '>' GenericArgList = - '::'? '<' - TypeArg* - LifetimeArg* - AssocTypeArg* - ConstArg* - '>' + '::'? '<' (GenericArg (',' GenericArg)* ','?)? '>' + +GenericArg = + TypeArg +| AssocTypeArg +| LifetimeArg +| ConstArg TypeArg = Type @@ -27,7 +28,6 @@ LifetimeArg = ConstArg = Literal | BlockExpr BlockExpr - SourceFile = 'shebang'? Attr* -- cgit v1.2.3 From ddf08daddf7e86d67e8d2e5596f8013b376dd522 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 18:46:07 +0200 Subject: Fix const arguments grammar --- xtask/src/codegen/rust.ungram | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xtask') diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index fa18acbb3..8536b9748 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram @@ -26,7 +26,7 @@ LifetimeArg = 'lifetime' ConstArg = - Literal | BlockExpr BlockExpr + Expr SourceFile = 'shebang'? -- cgit v1.2.3 From c1c97b289662501cea93fdc10760e08702ff5950 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 18:49:42 +0200 Subject: Fix leading colon --- xtask/src/codegen/rust.ungram | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'xtask') diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index 8536b9748..1d8bed0b4 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram @@ -2,7 +2,8 @@ Path = (qualifier:Path '::')? segment:PathSegment PathSegment = - '::' | 'crate' | 'self' | 'super' + 'crate' | 'self' | 'super' +| '::' NameRef | NameRef GenericArgList? | NameRef ParamList RetType? | '<' PathType ('as' PathType)? '>' -- cgit v1.2.3