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 import statements grammar #678

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,7 +10,7 @@
- choice:
- reference: "PathImport"
- reference: "NamedImport"
- reference: "DeconstructionImport"
- reference: "ImportDeconstruction"
terminator:
reference: "Semicolon"

Expand All @@ -34,30 +34,30 @@
- reference: "FromKeyword"
- reference: "AsciiStringLiteral"

- name: "DeconstructionImport"
- name: "ImportDeconstruction"
kind: "Parser"
unversioned:
sequence:
- delimitedBy:
open:
reference: "OpenBrace"
parser:
reference: "DeconstructionImportSymbols"
reference: "ImportDeconstructionSymbols"
close:
reference: "CloseBrace"
- reference: "FromKeyword"
- reference: "AsciiStringLiteral"

- name: "DeconstructionImportSymbols"
- name: "ImportDeconstructionSymbols"
kind: "Parser"
unversioned:
separatedBy:
separator:
reference: "Comma"
parser:
reference: "DeconstructionImportSymbol"
reference: "ImportDeconstructionSymbol"

- name: "DeconstructionImportSymbol"
- name: "ImportDeconstructionSymbol"
kind: "Parser"
unversioned:
sequence:
Expand All @@ -82,15 +82,15 @@
- reference: "TypeName"
terminator:
reference: "Semicolon"
# Added an optional `global` keyword and `UsingDirectiveDeconstruction`
# Added an optional `global` keyword and `UsingDeconstruction`
0.8.13:
terminatedBy:
parser:
sequence:
- reference: "UsingKeyword"
- choice:
- reference: "IdentifierPath"
- reference: "UsingDirectiveDeconstruction"
- reference: "UsingDeconstruction"
- reference: "ForKeyword"
- choice:
- reference: "Asterisk"
Expand All @@ -100,29 +100,29 @@
terminator:
reference: "Semicolon"

- name: "UsingDirectiveDeconstruction"
- name: "UsingDeconstruction"
kind: "Parser"
versioned:
0.8.13:
delimitedBy:
open:
reference: "OpenBrace"
parser:
reference: "UsingDirectiveSymbols"
reference: "UsingDeconstructionSymbols"
close:
reference: "CloseBrace"

- name: "UsingDirectiveSymbols"
- name: "UsingDeconstructionSymbols"
kind: "Parser"
versioned:
0.8.13:
separatedBy:
separator:
reference: "Comma"
parser:
reference: "UsingDirectiveSymbol"
reference: "UsingDeconstructionSymbol"

- name: "UsingDirectiveSymbol"
- name: "UsingDeconstructionSymbol"
kind: "Parser"
versioned:
0.8.13:
Expand Down
40 changes: 20 additions & 20 deletions crates/solidity/inputs/language/src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,30 +222,30 @@ codegen_language_macros::compile!(Language(
error_recovery = FieldsErrorRecovery(terminator = semicolon),
fields = (
import_keyword = Required(Terminal([ImportKeyword])),
symbol = Required(NonTerminal(ImportSymbol)),
clause = Required(NonTerminal(ImportClause)),
semicolon = Required(Terminal([Semicolon]))
)
),
Enum(
name = ImportSymbol,
name = ImportClause,
variants = [
EnumVariant(name = Path, reference = PathImportSymbol),
EnumVariant(name = Named, reference = NamedImportSymbol),
EnumVariant(name = Path, reference = PathImport),
EnumVariant(name = Named, reference = NamedImport),
EnumVariant(
name = Deconstruction,
reference = ImportSymbolDeconstruction
reference = ImportDeconstruction
)
]
),
Struct(
name = PathImportSymbol,
name = PathImport,
fields = (
path = Required(Terminal([AsciiStringLiteral])),
alias = Optional(kind = NonTerminal(ImportAlias))
)
),
Struct(
name = NamedImportSymbol,
name = NamedImport,
fields = (
asterisk = Required(Terminal([Asterisk])),
alias = Required(NonTerminal(ImportAlias)),
Expand All @@ -254,26 +254,26 @@ codegen_language_macros::compile!(Language(
)
),
Struct(
name = ImportSymbolDeconstruction,
name = ImportDeconstruction,
error_recovery = FieldsErrorRecovery(
delimiters =
FieldDelimiters(open = open_brace, close = close_brace)
),
fields = (
open_brace = Required(Terminal([OpenBrace])),
fields = Required(NonTerminal(ImportDeconstructionFields)),
symbols = Required(NonTerminal(ImportDeconstructionSymbols)),
close_brace = Required(Terminal([CloseBrace])),
from_keyword = Required(Terminal([FromKeyword])),
path = Required(Terminal([AsciiStringLiteral]))
)
),
Separated(
name = ImportDeconstructionFields,
separated = ImportDeconstructionField,
name = ImportDeconstructionSymbols,
separated = ImportDeconstructionSymbol,
separator = Comma
),
Struct(
name = ImportDeconstructionField,
name = ImportDeconstructionSymbol,
fields = (
name = Required(Terminal([Identifier])),
alias = Optional(kind = NonTerminal(ImportAlias))
Expand All @@ -296,7 +296,7 @@ codegen_language_macros::compile!(Language(
error_recovery = FieldsErrorRecovery(terminator = semicolon),
fields = (
using_keyword = Required(Terminal([UsingKeyword])),
symbol = Required(NonTerminal(UsingSymbol)),
clause = Required(NonTerminal(UsingClause)),
for_keyword = Required(Terminal([ForKeyword])),
target = Required(NonTerminal(UsingTarget)),
global_keyword = Optional(
Expand All @@ -307,37 +307,37 @@ codegen_language_macros::compile!(Language(
)
),
Enum(
name = UsingSymbol,
name = UsingClause,
variants = [
EnumVariant(name = Path, reference = IdentifierPath),
EnumVariant(
name = Deconstruction,
enabled = From("0.8.13"),
reference = UsingSymbolDeconstruction
reference = UsingDeconstruction
)
]
),
Struct(
name = UsingSymbolDeconstruction,
name = UsingDeconstruction,
enabled = From("0.8.13"),
error_recovery = FieldsErrorRecovery(
delimiters =
FieldDelimiters(open = open_brace, close = close_brace)
),
fields = (
open_brace = Required(Terminal([OpenBrace])),
fields = Required(NonTerminal(UsingDeconstructionFields)),
symbols = Required(NonTerminal(UsingDeconstructionSymbols)),
close_brace = Required(Terminal([CloseBrace]))
)
),
Separated(
name = UsingDeconstructionFields,
separated = UsingDeconstructionField,
name = UsingDeconstructionSymbols,
separated = UsingDeconstructionSymbol,
separator = Comma,
enabled = From("0.8.13")
),
Struct(
name = UsingDeconstructionField,
name = UsingDeconstructionSymbol,
enabled = From("0.8.13"),
fields = (
name = Required(NonTerminal(IdentifierPath)),
Expand Down
18 changes: 10 additions & 8 deletions crates/solidity/inputs/language/src/dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ slang_grammar! {
{ introduced in "0.5.0" CalldataKeyword}
) ;

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

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

parser DeconstructionImportSymbols = (DeconstructionImportSymbol separated by Comma) ;
parser ImportDeconstructionSymbols = (ImportDeconstructionSymbol separated by Comma) ;

parser DeleteStatement = ((DeleteKeyword Expression) terminated by Semicolon) ;

Expand Down Expand Up @@ -364,7 +364,7 @@ slang_grammar! {

parser IfStatement = (IfKeyword (Expression delimited by OpenParen and CloseParen) Statement ((ElseKeyword Statement) ?)) ;

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

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

Expand Down Expand Up @@ -550,19 +550,21 @@ slang_grammar! {

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) ;
parser UsingDirective = ((UsingKeyword (IdentifierPath | { introduced in "0.8.13" UsingDeconstruction }) ForKeyword (Asterisk | TypeName) ({ introduced in "0.8.13" GlobalKeyword } ?)) terminated by Semicolon) ;

parser UsingDirectiveDeconstruction = { introduced in "0.8.13" (UsingDirectiveSymbols delimited by OpenBrace and CloseBrace) };
parser UsingDeconstruction = { introduced in "0.8.13" (UsingDeconstructionSymbols delimited by OpenBrace and CloseBrace) };

inline parser UsingDirectiveOperator = {
introduced in "0.8.19" (Ampersand | Asterisk | BangEqual | Bar | Caret | EqualEqual | GreaterThan | GreaterThanEqual | LessThan | LessThanEqual | Minus | Percent | Plus | Slash | Tilde)
} ;

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

parser UsingDirectiveSymbols = (UsingDirectiveSymbol separated by Comma) ;
parser UsingDeconstructionSymbols = {
introduced in "0.8.13" (UsingDeconstructionSymbol separated by Comma)
} ;

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

Expand Down
24 changes: 12 additions & 12 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