Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tuple members grammar #677

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,47 @@
open:
reference: "OpenParen"
parser:
optional:
reference: "TupleMembers"
reference: "TupleDeconstructionElements"
close:
reference: "CloseParen"
- reference: "Equal"
- reference: "Expression"
terminator:
reference: "Semicolon"

- name: "TupleMembers"
- name: "TupleDeconstructionElements"
kind: "Parser"
unversioned:
separatedBy:
separator:
reference: "Comma"
parser:
reference: "TupleMember"
reference: "TupleDeconstructionElement"

- name: "TupleMember"
- name: "TupleDeconstructionElement"
kind: "Parser"
unversioned:
optional:
choice:
- sequence:
- reference: "TypeName"
- optional:
reference: "DataLocation"
- reference: "Identifier"
- sequence:
- optional:
reference: "DataLocation"
- reference: "Identifier"
- reference: "TypedTupleMember"
- reference: "UntypedTupleMember"

- name: "TypedTupleMember"
kind: "Parser"
unversioned:
sequence:
- reference: "TypeName"
- optional:
reference: "DataLocation"
- reference: "Identifier"

- name: "UntypedTupleMember"
kind: "Parser"
unversioned:
sequence:
- optional:
reference: "DataLocation"
- reference: "Identifier"

- name: "VariableDeclarationStatement"
kind: "Parser"
Expand Down
8 changes: 4 additions & 4 deletions crates/solidity/inputs/language/src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2898,20 +2898,20 @@ codegen_language_macros::compile!(Language(
),
fields = (
open_paren = Required(Terminal([OpenParen])),
members = Required(NonTerminal(TupleMembersDeconstruction)),
elements = Required(NonTerminal(TupleDeconstructionElements)),
close_paren = Required(Terminal([CloseParen])),
equal = Required(Terminal([Equal])),
expression = Required(NonTerminal(Expression)),
semicolon = Required(Terminal([Semicolon]))
)
),
Separated(
name = TupleMembersDeconstruction,
separated = TupleMemberDeconstruction,
name = TupleDeconstructionElements,
separated = TupleDeconstructionElement,
separator = Comma
),
Struct(
name = TupleMemberDeconstruction,
name = TupleDeconstructionElement,
fields = (member = Optional(kind = NonTerminal(TupleMember)))
),
Enum(
Expand Down
10 changes: 7 additions & 3 deletions crates/solidity/inputs/language/src/dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,18 +513,20 @@ slang_grammar! {

parser TryStatement = { introduced in "0.6.0" (TryKeyword Expression (ReturnsDeclaration ?) Block CatchClauses) } ;

parser TupleDeconstructionStatement = ((((TupleMembers ?) delimited by OpenParen and CloseParen) Equal Expression) terminated by Semicolon) ;
parser TupleDeconstructionStatement = (((TupleDeconstructionElements delimited by OpenParen and CloseParen) Equal Expression) terminated by Semicolon) ;

parser TupleExpression = (TupleValues delimited by OpenParen and CloseParen) ;

parser TupleMember = (((TypeName (DataLocation ?) Identifier) | ((DataLocation ?) Identifier)) ?) ;
parser TupleDeconstructionElement = ((TypedTupleMember | UntypedTupleMember) ?) ;

parser TupleMembers = (TupleMember separated by Comma) ;
parser TupleDeconstructionElements = (TupleDeconstructionElement separated by Comma) ;

parser TupleValues = ((Expression ?) separated by Comma) ;

parser TypeExpression = { introduced in "0.5.3" (TypeKeyword (TypeName delimited by OpenParen and CloseParen)) } ;

parser TypedTupleMember = (TypeName (DataLocation ?) Identifier) ;

precedence parser TypeName = (
[
postfix ArrayTypeNameOperator as ArrayTypeName
Expand All @@ -548,6 +550,8 @@ slang_grammar! {

parser UnnamedFunctionDefinition = { removed in "0.6.0" (FunctionKeyword ParametersDeclaration (UnnamedFunctionAttributes ?) (Semicolon | Block)) } ;

parser UntypedTupleMember = ((DataLocation ?) Identifier) ;

parser UserDefinedValueTypeDefinition = { introduced in "0.8.8" ((TypeKeyword Identifier IsKeyword ElementaryType) terminated by Semicolon) } ;

parser UsingDirective = ((UsingKeyword (IdentifierPath | UsingDirectiveDeconstruction) ForKeyword (Asterisk | TypeName) ({ introduced in "0.8.13" GlobalKeyword } ?)) terminated by Semicolon) ;
Expand Down
12 changes: 8 additions & 4 deletions crates/solidity/outputs/cargo/crate/src/generated/kinds.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading