Skip to content

Commit

Permalink
sync inlined enums enums and optionals in v0/v1
Browse files Browse the repository at this point in the history
We made a decision to inline `Enum` items and `Optional` fields in v2 until migration is complete.
However, it is not consistent in v0/v1, and a few of them are not inlined yet.
This makes sure they are consistent across all three.
  • Loading branch information
OmarTawfik committed Nov 24, 2023
1 parent 12176ab commit fbe5c77
Show file tree
Hide file tree
Showing 111 changed files with 1,978 additions and 1,511 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@
sequence:
- reference: "AsciiStringLiteral"
- optional:
sequence:
- reference: "AsKeyword"
- reference: "Identifier"
reference: "ImportAlias"

- name: "NamedImport"
kind: "Parser"
unversioned:
sequence:
- reference: "Asterisk"
- reference: "AsKeyword"
- reference: "Identifier"
- reference: "ImportAlias"
- reference: "FromKeyword"
- reference: "AsciiStringLiteral"

Expand Down Expand Up @@ -63,9 +60,14 @@
sequence:
- reference: "Identifier"
- optional:
sequence:
- reference: "AsKeyword"
- reference: "Identifier"
reference: "ImportAlias"

- name: "ImportAlias"
kind: "Parser"
unversioned:
sequence:
- reference: "AsKeyword"
- reference: "Identifier"

- name: "UsingDirective"
kind: "Parser"
Expand Down Expand Up @@ -131,9 +133,15 @@
sequence:
- reference: "IdentifierPath"
- optional:
sequence:
- reference: "AsKeyword"
- reference: "UsingDirectiveOperator"
reference: "UsingAlias"

- name: "UsingAlias"
kind: "Parser"
versioned:
0.8.19:
sequence:
- reference: "AsKeyword"
- reference: "UsingDirectiveOperator"

- name: "UsingDirectiveOperator"
kind: "Parser"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,18 @@
sequence:
- reference: "OverrideKeyword"
- optional:
delimitedBy:
open:
reference: "OpenParen"
parser:
optional:
reference: "OverridePaths"
close:
reference: "CloseParen"
reference: "OverridePathsDeclaration"

- name: "OverridePathsDeclaration"
kind: "Parser"
unversioned:
delimitedBy:
open:
reference: "OpenParen"
parser:
reference: "OverridePaths"
close:
reference: "CloseParen"

- name: "OverridePaths"
kind: "Parser"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@
reference: "DataLocation"
- reference: "Identifier"
- optional:
sequence:
- reference: "Equal"
- reference: "Expression"
reference: "VariableDeclarationValue"
terminator:
reference: "Semicolon"

Expand All @@ -82,6 +80,13 @@
# removed "VarKeyword"
reference: "TypeName"

- name: "VariableDeclarationValue"
kind: "Parser"
unversioned:
sequence:
- reference: "Equal"
- reference: "Expression"

- name: "DataLocation"
kind: "Parser"
inlined: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,15 @@
- optional:
reference: "Expression"
- optional:
sequence:
- reference: "Colon"
- optional:
reference: "Expression"
reference: "IndexAccessEnd"
close:
reference: "CloseBracket"

- name: "IndexAccessEnd"
kind: "Parser"
inlined: true
unversioned:
sequence:
- reference: "Colon"
- optional:
reference: "Expression"
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- name: "ArgumentsDeclaration"
kind: "Parser"
inlined: true
unversioned:
delimitedBy:
open:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@
separator:
reference: "Comma"
parser:
optional:
reference: "Expression"
reference: "TupleValue"

- name: "TupleValue"
kind: "Parser"
unversioned:
optional:
reference: "Expression"

- name: "ArrayExpression"
kind: "Parser"
Expand Down
32 changes: 21 additions & 11 deletions crates/solidity/inputs/language/src/dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ slang_grammar! {

inline parser AndOperator = AmpersandAmpersand ;

parser ArgumentsDeclaration = (((PositionalArguments | NamedArgumentsDeclaration) ?) delimited by OpenParen and CloseParen) ;
inline parser ArgumentsDeclaration = (((PositionalArguments | NamedArgumentsDeclaration) ?) delimited by OpenParen and CloseParen) ;

parser ArrayExpression = (ArrayValues delimited by OpenBracket and CloseBracket) ;

Expand Down Expand Up @@ -252,9 +252,11 @@ slang_grammar! {
{ introduced in "0.5.0" CalldataKeyword}
) ;

parser ImportAlias = (AsKeyword Identifier);

parser ImportDeconstruction = ((ImportDeconstructionSymbols delimited by OpenBrace and CloseBrace) FromKeyword AsciiStringLiteral) ;

parser ImportDeconstructionSymbol = (Identifier ((AsKeyword Identifier) ?)) ;
parser ImportDeconstructionSymbol = (Identifier (ImportAlias ?)) ;

parser ImportDeconstructionSymbols = (ImportDeconstructionSymbol separated by Comma) ;

Expand Down Expand Up @@ -366,7 +368,9 @@ slang_grammar! {

parser ImportDirective = ((ImportKeyword (PathImport | NamedImport | ImportDeconstruction)) terminated by Semicolon) ;

inline parser IndexAccessOperator = (((Expression ?) ((Colon (Expression ?)) ?)) delimited by OpenBracket and CloseBracket) ;
parser IndexAccessEnd = (Colon (Expression ?)) ;

inline parser IndexAccessOperator = (((Expression ?) (IndexAccessEnd ?)) delimited by OpenBracket and CloseBracket) ;

parser InheritanceSpecifier = (IsKeyword InheritanceTypes) ;

Expand Down Expand Up @@ -415,7 +419,7 @@ slang_grammar! {

parser NamedArguments = (NamedArgument separated by Comma) ;

parser NamedImport = (Asterisk AsKeyword Identifier FromKeyword AsciiStringLiteral) ;
parser NamedImport = (Asterisk ImportAlias FromKeyword AsciiStringLiteral) ;

parser NewExpression = (NewKeyword TypeName) ;

Expand All @@ -435,15 +439,17 @@ slang_grammar! {

inline parser OrderComparisonOperator = (LessThan | GreaterThan | LessThanEqual | GreaterThanEqual) ;

parser OverrideSpecifier = (OverrideKeyword (((OverridePaths ?) delimited by OpenParen and CloseParen) ?)) ;
parser OverridePathsDeclaration = (OverridePaths delimited by OpenParen and CloseParen) ;

parser OverrideSpecifier = (OverrideKeyword (OverridePathsDeclaration ?)) ;

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

parser ParametersDeclaration = ((Parameters ?) delimited by OpenParen and CloseParen) ;

parser Parameters = (Parameter separated by Comma) ;

parser PathImport = (AsciiStringLiteral ((AsKeyword Identifier) ?)) ;
parser PathImport = (AsciiStringLiteral (ImportAlias ?)) ;

parser PositionalArguments = (Expression separated by Comma) ;

Expand Down Expand Up @@ -521,7 +527,9 @@ slang_grammar! {

parser TupleDeconstructionElements = (TupleDeconstructionElement separated by Comma) ;

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

parser TupleValue = (Expression ?) ;

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

Expand Down Expand Up @@ -554,6 +562,8 @@ slang_grammar! {

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

parser UsingAlias = { introduced in "0.8.19" (AsKeyword UsingDirectiveOperator) };

parser UsingDirective = ((UsingKeyword (IdentifierPath | UsingDeconstruction) ForKeyword (Asterisk | TypeName) ({ introduced in "0.8.13" GlobalKeyword } ?)) terminated by Semicolon) ;

parser UsingDeconstruction = { introduced in "0.8.13" (UsingDeconstructionSymbols delimited by OpenBrace and CloseBrace) };
Expand All @@ -563,16 +573,16 @@ slang_grammar! {
} ;

parser UsingDeconstructionSymbol = {
introduced in "0.8.13" (IdentifierPath { introduced in "0.8.19" ((AsKeyword UsingDirectiveOperator) ?) } )
introduced in "0.8.13" (IdentifierPath { introduced in "0.8.19" (UsingAlias ?) } )
} ;

parser UsingDeconstructionSymbols = (UsingDeconstructionSymbol separated by Comma) ;

parser VariableDeclaration = (VariableDeclarationType (DataLocation ?) Identifier) ;

inline parser VariableDeclarationType = ({ removed in "0.5.0" VarKeyword } | TypeName) ;

parser VariableDeclarationStatement = ((VariableDeclaration ((Equal Expression) ?)) terminated by Semicolon) ;
parser VariableDeclarationStatement = ((VariableDeclarationType (DataLocation ?) Identifier (VariableDeclarationValue ?)) terminated by Semicolon) ;

parser VariableDeclarationValue = (Equal Expression) ;

parser WhileStatement = (WhileKeyword (Expression delimited by OpenParen and CloseParen) Statement) ;

Expand Down
16 changes: 12 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

0 comments on commit fbe5c77

Please sign in to comment.