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

Update keyword versions #599

Merged
merged 4 commits into from
Sep 22, 2023
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
5 changes: 5 additions & 0 deletions .changeset/rich-fans-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/slang": patch
---

Use correct versions for the `revert` and `global` keywords
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,38 @@

- name: "UsingDirective"
kind: "Parser"
unversioned:
terminatedBy:
parser:
sequence:
- reference: "UsingKeyword"
- choice:
- reference: "UsingDirectivePath"
- reference: "UsingDirectiveDeconstruction"
- reference: "ForKeyword"
- choice:
- reference: "Asterisk"
- reference: "TypeName"
- optional:
reference: "GlobalKeyword"
terminator:
reference: "Semicolon"
versioned:
0.4.11:
terminatedBy:
parser:
sequence:
- reference: "UsingKeyword"
- choice:
- reference: "UsingDirectivePath"
- reference: "UsingDirectiveDeconstruction"
- reference: "ForKeyword"
- choice:
- reference: "Asterisk"
- reference: "TypeName"
terminator:
reference: "Semicolon"
# Added an optional `global` keyword
0.8.13:
terminatedBy:
parser:
sequence:
- reference: "UsingKeyword"
- choice:
- reference: "UsingDirectivePath"
- reference: "UsingDirectiveDeconstruction"
- reference: "ForKeyword"
- choice:
- reference: "Asterisk"
- reference: "TypeName"
- optional:
reference: "GlobalKeyword"
terminator:
reference: "Semicolon"

- name: "UsingDirectivePath"
kind: "Parser"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,13 @@

- name: "GlobalKeyword"
kind: "Scanner"
unversioned:
trailingContext:
scanner:
terminal: "global"
notFollowedBy:
reference: "IdentifierPart"
versioned:
0.8.13:
trailingContext:
scanner:
terminal: "global"
notFollowedBy:
reference: "IdentifierPart"

- name: "GweiKeyword"
kind: "Scanner"
Expand Down Expand Up @@ -562,12 +563,13 @@

- name: "RevertKeyword"
kind: "Scanner"
unversioned:
trailingContext:
scanner:
terminal: "revert"
notFollowedBy:
reference: "IdentifierPart"
versioned:
0.8.4:
trailingContext:
scanner:
terminal: "revert"
notFollowedBy:
reference: "IdentifierPart"

- name: "SecondsKeyword"
kind: "Scanner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
- reference: "BreakStatement"
- reference: "DeleteStatement"
- reference: "ReturnStatement"
- reference: "RevertStatement"
- reference: "ThrowStatement"
0.4.21:
choice:
Expand All @@ -63,7 +62,6 @@
- reference: "BreakStatement"
- reference: "DeleteStatement"
- reference: "ReturnStatement"
- reference: "RevertStatement"
- reference: "ThrowStatement"
- reference: "EmitStatement"
0.5.0:
Expand All @@ -77,7 +75,6 @@
- reference: "BreakStatement"
- reference: "DeleteStatement"
- reference: "ReturnStatement"
- reference: "RevertStatement"
- reference: "EmitStatement"
0.6.0:
choice:
Expand All @@ -90,6 +87,19 @@
- reference: "BreakStatement"
- reference: "DeleteStatement"
- reference: "ReturnStatement"
- reference: "EmitStatement"
- reference: "TryStatement"
0.8.4:
choice:
# added: "RevertStatement"
- reference: "IfStatement"
- reference: "ForStatement"
- reference: "WhileStatement"
- reference: "DoWhileStatement"
- reference: "ContinueStatement"
- reference: "BreakStatement"
- reference: "DeleteStatement"
- reference: "ReturnStatement"
- reference: "RevertStatement"
- reference: "EmitStatement"
- reference: "TryStatement"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@

- name: "RevertStatement"
kind: "Parser"
unversioned:
terminatedBy:
parser:
sequence:
- reference: "RevertKeyword"
- optional:
reference: "IdentifierPath"
- reference: "ArgumentsDeclaration"
terminator:
reference: "Semicolon"
versioned:
0.8.4:
terminatedBy:
parser:
sequence:
- reference: "RevertKeyword"
- optional:
reference: "IdentifierPath"
- reference: "ArgumentsDeclaration"
terminator:
reference: "Semicolon"

- name: "ThrowStatement"
kind: "Parser"
Expand Down
22 changes: 13 additions & 9 deletions crates/solidity/inputs/language/src/dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ slang_grammar! {
| ForKeyword
| FromKeyword
| FunctionKeyword
| GlobalKeyword
| HexKeyword
| HoursKeyword
| IfKeyword
Expand Down Expand Up @@ -97,7 +96,6 @@ slang_grammar! {
| RelocatableKeyword
| ReturnKeyword
| ReturnsKeyword
| RevertKeyword
| SecondsKeyword
| SolidityKeyword
| StaticKeyword
Expand Down Expand Up @@ -160,6 +158,10 @@ slang_grammar! {

// Introduced in 0.8.4
| ErrorKeyword
| RevertKeyword

// Introduced in 0.8.13
| GlobalKeyword
) ;

parser ABICoderPragma = (ABICoderKeyword Identifier) ;
Expand Down Expand Up @@ -235,10 +237,11 @@ slang_grammar! {
parser ContractMembersList = (ContractMember +) ;

inline parser ControlStatement = (
IfStatement | ForStatement | WhileStatement | DoWhileStatement | ContinueStatement | BreakStatement | DeleteStatement | ReturnStatement | RevertStatement |
{ introduced in "0.4.21" EmitStatement} |
IfStatement | ForStatement | WhileStatement | DoWhileStatement | ContinueStatement | BreakStatement | DeleteStatement | ReturnStatement |
{ introduced in "0.4.21" EmitStatement } |
{ removed in "0.5.0" ThrowStatement } |
{ introduced in "0.6.0" TryStatement}
{ introduced in "0.6.0" TryStatement } |
{ introduced in "0.8.4" RevertStatement }
) ;

inline parser DataLocation = (
Expand Down Expand Up @@ -539,7 +542,7 @@ slang_grammar! {

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

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

parser UsingDirectiveDeconstruction = (UsingDirectiveSymbolsList delimited by OpenBrace and CloseBrace) ;

Expand Down Expand Up @@ -887,7 +890,6 @@ slang_grammar! {
scanner ForKeyword = "for" ;
scanner FromKeyword = "from" ;
scanner FunctionKeyword = "function" ;
scanner GlobalKeyword = "global" ;
scanner HexKeyword = "hex" ;
scanner HoursKeyword = "hours" ;
scanner IfKeyword = "if" ;
Expand Down Expand Up @@ -918,7 +920,6 @@ slang_grammar! {
scanner RelocatableKeyword = "relocatable" ;
scanner ReturnKeyword = "return" ;
scanner ReturnsKeyword = "returns" ;
scanner RevertKeyword = "revert" ;
scanner SecondsKeyword = "seconds" ;
scanner SolidityKeyword = "solidity" ;
scanner StaticKeyword = "static" ;
Expand Down Expand Up @@ -979,6 +980,9 @@ slang_grammar! {
scanner UncheckedKeyword = { introduced in "0.8.0" "unchecked" } ;

// Introduced in 0.8.4
scanner ErrorKeyword = { introduced in "0.8.4" "error" } ;
scanner ErrorKeyword = { introduced in "0.8.4" "error" } ;
scanner RevertKeyword = { introduced in "0.8.4" "revert" } ;

// Introduced in 0.8.13
scanner GlobalKeyword = { introduced in "0.8.13" "global" } ;
}
34 changes: 25 additions & 9 deletions crates/solidity/outputs/cargo/crate/src/generated/language.rs

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

34 changes: 25 additions & 9 deletions crates/solidity/outputs/npm/crate/src/generated/language.rs

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

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

Loading
Loading