Skip to content

Commit

Permalink
fix: Introduce a separate, non-empty CallOptions rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Mar 7, 2024
1 parent b1e2828 commit c35a04c
Show file tree
Hide file tree
Showing 21 changed files with 137 additions and 25 deletions.
15 changes: 12 additions & 3 deletions crates/solidity/inputs/language/src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3390,7 +3390,7 @@ codegen_language_macros::compile!(Language(
delimiters = FieldDelimiters(
open = open_brace,
close = close_brace,
// NOTE: Despite `NamedArguments` requiring at least one element,
// NOTE: Despite `CallOptions` requiring at least one element,
// we can only recover if we found at least two tokens (`ident:`)
// in the body, as this may be otherwise ambiguous with
// `try <EXPR> { func() } catch {}`.
Expand All @@ -3399,7 +3399,7 @@ codegen_language_macros::compile!(Language(
),
fields = (
open_brace = Required(OpenBrace),
arguments = Required(NamedArguments),
arguments = Required(CallOptions),
close_brace = Required(CloseBrace)
)
)]
Expand Down Expand Up @@ -3525,7 +3525,16 @@ codegen_language_macros::compile!(Language(
Separated(
name = NamedArguments,
reference = NamedArgument,
separator = Comma
separator = Comma,
allow_empty = true
),
Separated(
name = CallOptions,
reference = NamedArgument,
separator = Comma,
enabled = From("0.6.2"),
// These cannot be empty as they're ambiguous with `try <EXPR> {} catch {}`
allow_empty = false
),
Struct(
name = NamedArgument,
Expand Down

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.

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.

24 changes: 22 additions & 2 deletions crates/solidity/outputs/npm/package/src/ast/generated/ast_types.ts

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.

5 changes: 4 additions & 1 deletion crates/solidity/outputs/spec/generated/grammar.ebnf

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.

Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Tree:
- (period꞉ Period): "." # (234..235)
- (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (235..239)
- (open_brace꞉ OpenBrace): "{" # (239..240)
- (arguments꞉ NamedArguments): # " value: amount" (240..254)
- (arguments꞉ CallOptions): # " value: amount" (240..254)
- (item꞉ NamedArgument): # " value: amount" (240..254)
- (LeadingTrivia) ► (Whitespace): " " # (240..241)
- (name꞉ Identifier): "value" # (241..246)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Tree:
- (period꞉ Period): "." # (179..180)
- (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (180..184)
- (open_brace꞉ OpenBrace): "{" # (184..185)
- (arguments꞉ NamedArguments): # "arg: 1, missing_expr: , no_semicolon," (185..222)
- (arguments꞉ CallOptions): # "arg: 1, missing_expr: , no_semicolon," (185..222)
- (item꞉ NamedArgument): # "arg: 1" (185..191)
- (name꞉ Identifier): "arg" # (185..188)
- (colon꞉ Colon): ":" # (188..189)
Expand Down Expand Up @@ -225,7 +225,7 @@ Tree:
- (period꞉ Period): "." # (242..243)
- (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (243..247)
- (open_brace꞉ OpenBrace): "{" # (247..248)
- (arguments꞉ NamedArguments): # "arg: 1" (248..254)
- (arguments꞉ CallOptions): # "arg: 1" (248..254)
- (item꞉ NamedArgument): # "arg: 1" (248..254)
- (name꞉ Identifier): "arg" # (248..251)
- (colon꞉ Colon): ":" # (251..252)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Tree:
- (period꞉ Period): "." # (179..180)
- (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (180..184)
- (open_brace꞉ OpenBrace): "{" # (184..185)
- (arguments꞉ NamedArguments): # "arg: 1, missing_expr: , no_semicolon," (185..222)
- (arguments꞉ CallOptions): # "arg: 1, missing_expr: , no_semicolon," (185..222)
- (item꞉ NamedArgument): # "arg: 1" (185..191)
- (name꞉ Identifier): "arg" # (185..188)
- (colon꞉ Colon): ":" # (188..189)
Expand Down Expand Up @@ -225,7 +225,7 @@ Tree:
- (period꞉ Period): "." # (242..243)
- (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (243..247)
- (open_brace꞉ OpenBrace): "{" # (247..248)
- (arguments꞉ NamedArguments): # "arg: 1" (248..254)
- (arguments꞉ CallOptions): # "arg: 1" (248..254)
- (item꞉ NamedArgument): # "arg: 1" (248..254)
- (name꞉ Identifier): "arg" # (248..251)
- (colon꞉ Colon): ":" # (251..252)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Tree:
- (period꞉ Period): "." # (179..180)
- (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (180..184)
- (open_brace꞉ OpenBrace): "{" # (184..185)
- (arguments꞉ NamedArguments): # "arg: 1, missing_expr: , no_semicolon," (185..222)
- (arguments꞉ CallOptions): # "arg: 1, missing_expr: , no_semicolon," (185..222)
- (item꞉ NamedArgument): # "arg: 1" (185..191)
- (name꞉ Identifier): "arg" # (185..188)
- (colon꞉ Colon): ":" # (188..189)
Expand Down Expand Up @@ -225,7 +225,7 @@ Tree:
- (period꞉ Period): "." # (242..243)
- (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (243..247)
- (open_brace꞉ OpenBrace): "{" # (247..248)
- (arguments꞉ NamedArguments): # "arg: 1" (248..254)
- (arguments꞉ CallOptions): # "arg: 1" (248..254)
- (item꞉ NamedArgument): # "arg: 1" (248..254)
- (name꞉ Identifier): "arg" # (248..251)
- (colon꞉ Colon): ":" # (251..252)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Tree:
- (period꞉ Period): "." # (1..2)
- (member꞉ MemberAccess) ► (variant꞉ Identifier): "b" # (2..3)
- (open_brace꞉ OpenBrace): "{" # (3..4)
- (arguments꞉ NamedArguments): # "value: 0, gas: 1" (4..20)
- (arguments꞉ CallOptions): # "value: 0, gas: 1" (4..20)
- (item꞉ NamedArgument): # "value: 0" (4..12)
- (name꞉ Identifier): "value" # (4..9)
- (colon꞉ Colon): ":" # (9..10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Tree:
- (period꞉ Period): "." # (1..2)
- (member꞉ MemberAccess) ► (variant꞉ Identifier): "b" # (2..3)
- (open_brace꞉ OpenBrace): "{" # (3..4)
- (arguments꞉ NamedArguments): # "value: 0" (4..12)
- (arguments꞉ CallOptions): # "value: 0" (4..12)
- (item꞉ NamedArgument): # "value: 0" (4..12)
- (name꞉ Identifier): "value" # (4..9)
- (colon꞉ Colon): ":" # (9..10)
Expand All @@ -23,7 +23,7 @@ Tree:
- (literal꞉ DecimalLiteral): "0" # (11..12)
- (close_brace꞉ CloseBrace): "}" # (12..13)
- (open_brace꞉ OpenBrace): "{" # (13..14)
- (arguments꞉ NamedArguments): # "gas: 1" (14..20)
- (arguments꞉ CallOptions): # "gas: 1" (14..20)
- (item꞉ NamedArgument): # "gas: 1" (14..20)
- (name꞉ Identifier): "gas" # (14..17)
- (colon꞉ Colon): ":" # (17..18)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Tree:
- (period꞉ Period): "." # (3..4)
- (member꞉ MemberAccess) ► (variant꞉ Identifier): "deposit" # (4..11)
- (open_brace꞉ OpenBrace): "{" # (11..12)
- (arguments꞉ NamedArguments): # "value: 100" (12..22)
- (arguments꞉ CallOptions): # "value: 100" (12..22)
- (item꞉ NamedArgument): # "value: 100" (12..22)
- (name꞉ Identifier): "value" # (12..17)
- (colon꞉ Colon): ":" # (17..18)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Tree:
- (LeadingTrivia) ► (Whitespace): " " # (3..4)
- (item꞉ Identifier): "Foo" # (4..7)
- (open_brace꞉ OpenBrace): "{" # (7..8)
- (arguments꞉ NamedArguments): # "value: 10" (8..17)
- (arguments꞉ CallOptions): # "value: 10" (8..17)
- (item꞉ NamedArgument): # "value: 10" (8..17)
- (name꞉ Identifier): "value" # (8..13)
- (colon꞉ Colon): ":" # (13..14)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Tree:
- (item꞉ Identifier): "FooBar" # (6..12)
- (close_paren꞉ CloseParen): ")" # (12..13)
- (open_brace꞉ OpenBrace): "{" # (13..14)
- (arguments꞉ NamedArguments): # "value: 5" (14..22)
- (arguments꞉ CallOptions): # "value: 5" (14..22)
- (item꞉ NamedArgument): # "value: 5" (14..22)
- (name꞉ Identifier): "value" # (14..19)
- (colon꞉ Colon): ":" # (19..20)
Expand Down
Loading

0 comments on commit c35a04c

Please sign in to comment.