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 some language definitions in DSL v1/v2 #653

Merged
merged 12 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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 @@ -100,9 +100,9 @@
- reference: "BreakStatement"
- reference: "DeleteStatement"
- reference: "ReturnStatement"
- reference: "RevertStatement"
- reference: "EmitStatement"
- reference: "TryStatement"
- reference: "RevertStatement"

- name: "SimpleStatement"
kind: "Parser"
Expand Down
42 changes: 18 additions & 24 deletions crates/solidity/inputs/language/src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2603,33 +2603,25 @@ codegen_language_macros::compile!(Language(
items = [
Struct(
OmarTawfik marked this conversation as resolved.
Show resolved Hide resolved
name = EventDefinition,
error_recovery = FieldsErrorRecovery(terminator = semicolon),
fields = (
event_keyword = Required(Terminal([EventKeyword])),
name = Required(Terminal([Identifier])),
parameters =
Optional(kind = NonTerminal(EventParametersDeclaration)),
anonymous_keyword = Optional(kind = Terminal([AnonymousKeyword])),
semicolon = Required(Terminal([Semicolon]))
)
),
Struct(
name = EventParametersDeclaration,
error_recovery = FieldsErrorRecovery(
terminator = semicolon,
OmarTawfik marked this conversation as resolved.
Show resolved Hide resolved
delimiters =
FieldDelimiters(open = open_paren, close = close_paren)
),
fields = (
event_keyword = Required(Terminal([EventKeyword])),
name = Required(Terminal([Identifier])),
open_paren = Required(Terminal([OpenParen])),
parameters = Required(NonTerminal(EventParameters)),
close_paren = Required(Terminal([CloseParen]))
parameters = Optional(kind = NonTerminal(EventParameters)),
OmarTawfik marked this conversation as resolved.
Show resolved Hide resolved
close_paren = Required(Terminal([CloseParen])),
anonymous_keyword = Optional(kind = Terminal([AnonymousKeyword])),
semicolon = Required(Terminal([Semicolon]))
)
),
Separated(
name = EventParameters,
separated = EventParameter,
separator = Comma,
allow_empty = true
separator = Comma
),
Struct(
name = EventParameter,
Expand Down Expand Up @@ -2865,14 +2857,17 @@ codegen_language_macros::compile!(Language(
Enum(
name = Statement,
variants = [
EnumVariant(
name = TupleDeconstruction,
reference = TupleDeconstructionStatement
),
// Simple statements
EnumVariant(name = Expression, reference = ExpressionStatement),
OmarTawfik marked this conversation as resolved.
Show resolved Hide resolved
EnumVariant(
name = VariableDeclaration,
reference = VariableDeclarationStatement
),
EnumVariant(
name = TupleDeconstruction,
reference = TupleDeconstructionStatement
),
// Control statements
EnumVariant(name = If, reference = IfStatement),
EnumVariant(name = For, reference = ForStatement),
EnumVariant(name = While, reference = WhileStatement),
Expand Down Expand Up @@ -2907,8 +2902,7 @@ codegen_language_macros::compile!(Language(
name = UncheckedBlock,
enabled = From("0.8.0"),
reference = UncheckedBlock
),
EnumVariant(name = Expression, reference = ExpressionStatement)
)
]
),
Struct(
Expand Down Expand Up @@ -3044,8 +3038,8 @@ codegen_language_macros::compile!(Language(
Struct(
name = ElseBranch,
fields = (
else_keyword = Optional(kind = Terminal([ElseKeyword])),
body = Optional(kind = NonTerminal(Statement))
else_keyword = Required(Terminal([ElseKeyword])),
body = Required(NonTerminal(Statement))
)
),
Struct(
Expand Down
16 changes: 8 additions & 8 deletions crates/solidity/inputs/language/src/dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ slang_grammar! {
lexical context Default = {

inline parser SolidityKeywordsOverAllVersions = (
ABICoderKeyword
AbicoderKeyword
| AbstractKeyword
| AddressKeyword
| AfterKeyword
Expand Down Expand Up @@ -165,7 +165,7 @@ slang_grammar! {
| GlobalKeyword
) ;

parser ABICoderPragma = (ABICoderKeyword Identifier) ;
parser ABICoderPragma = (AbicoderKeyword Identifier) ;

inline parser AddSubOperator = (Plus | Minus) ;

Expand Down Expand Up @@ -554,9 +554,9 @@ slang_grammar! {

parser UsingDirectivePath = IdentifierPath ;

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

parser UsingDirectiveSymbolsList = (UsingDirectiveSymbol separated by Comma) ;

Expand Down Expand Up @@ -664,8 +664,8 @@ slang_grammar! {

parser YulStatement = (
YulBlock | YulFunctionDefinition | YulDeclarationStatement | YulAssignmentStatement | YulIfStatement |
YulForStatement | YulSwitchStatement | YulBreakStatement | YulContinueStatement | YulExpression |
{ introduced in "0.6.0" YulLeaveStatement }
YulForStatement | YulSwitchStatement | { introduced in "0.6.0" YulLeaveStatement } |
YulBreakStatement | YulContinueStatement | YulExpression
) ;

parser YulStatementsList = (YulStatement +) ;
Expand Down Expand Up @@ -852,7 +852,7 @@ slang_grammar! {

// Keywords

scanner ABICoderKeyword = "abicoder" ;
scanner AbicoderKeyword = "abicoder" ;
scanner AbstractKeyword = "abstract" ;
scanner AddressKeyword = "address" ;
scanner AfterKeyword = "after" ;
Expand Down

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

Loading
Loading