Skip to content

Commit

Permalink
support dots in yul identifiers from 0.5.8 till 0.7.0
Browse files Browse the repository at this point in the history
Closes #743
  • Loading branch information
OmarTawfik committed Feb 29, 2024
1 parent f1cdae6 commit 59e2c74
Show file tree
Hide file tree
Showing 15 changed files with 127 additions and 39 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-numbers-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/slang": patch
---

support dots in yul identifiers from `0.5.8` till `0.7.0`
32 changes: 23 additions & 9 deletions crates/solidity/inputs/language/src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3946,14 +3946,12 @@ codegen_language_macros::compile!(Language(
),
Token(
name = Identifier,
definitions = [TokenDefinition(scanner = Fragment(RawIdentifier))]
),
Fragment(
name = RawIdentifier,
scanner = Sequence([
Fragment(IdentifierStart),
ZeroOrMore(Fragment(IdentifierPart))
])
definitions = [TokenDefinition(
scanner = Sequence([
Fragment(IdentifierStart),
ZeroOrMore(Fragment(IdentifierPart))
])
)]
),
Fragment(
name = IdentifierStart,
Expand Down Expand Up @@ -4199,7 +4197,23 @@ codegen_language_macros::compile!(Language(
),
Token(
name = YulIdentifier,
definitions = [TokenDefinition(scanner = Fragment(RawIdentifier))]
definitions = [
// Dots were allowed specifically between these versions:
TokenDefinition(
enabled = Range(from = "0.5.8", till = "0.7.0"),
scanner = Sequence([
Fragment(IdentifierStart),
ZeroOrMore(Choice([Fragment(IdentifierPart), Atom(".")]))
])
),
// Otherwise, parse as a regular identifier:
TokenDefinition(
scanner = Sequence([
Fragment(IdentifierStart),
ZeroOrMore(Fragment(IdentifierPart))
])
)
]
),
Enum(
name = YulBuiltInFunction,
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.

9 changes: 5 additions & 4 deletions 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.

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
@@ -1,12 +1,15 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ foo.bar │ 0..7
1 │ foo . bar │ 0..9
Errors: []

Tree:
- (YulExpression) ► (variant꞉ YulIdentifierPath): # "foo.bar" (0..7)
- (YulExpression) ► (variant꞉ YulIdentifierPath): # "foo . bar\n" (0..10)
- (item꞉ YulIdentifier): "foo" # (0..3)
- (separator꞉ Period): "." # (3..4)
- (item꞉ YulIdentifier): "bar" # (4..7)
- (LeadingTrivia) ► (Whitespace): " " # (3..4)
- (separator꞉ Period): "." # (4..5)
- (LeadingTrivia) ► (Whitespace): " " # (5..6)
- (item꞉ YulIdentifier): "bar" # (6..9)
- (TrailingTrivia) ► (EndOfLine): "\n" # (9..10)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
foo.bar
foo . bar
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ // identifiers with dots were allowed specifically from = "0.5.8" till = "0.7.0": │ 0..81
2 │ foo.bar │ 82..89
Errors: []

Tree:
- (YulExpression) ► (variant꞉ YulIdentifierPath): # "// identifiers with dots were allowed specifically..." (0..90)
- (LeadingTrivia): # "// identifiers with dots were allowed specifically..." (0..82)
- (SingleLineComment): "// identifiers with dots were allowed specifically..." # (0..81)
- (EndOfLine): "\n" # (81..82)
- (item꞉ YulIdentifier): "foo" # (82..85)
- (separator꞉ Period): "." # (85..86)
- (item꞉ YulIdentifier): "bar" # (86..89)
- (TrailingTrivia) ► (EndOfLine): "\n" # (89..90)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ // identifiers with dots were allowed specifically from = "0.5.8" till = "0.7.0": │ 0..81
2 │ foo.bar │ 82..89
Errors: []

Tree:
- (YulExpression) ► (variant꞉ YulIdentifierPath): # "// identifiers with dots were allowed specifically..." (0..90)
- (LeadingTrivia): # "// identifiers with dots were allowed specifically..." (0..82)
- (SingleLineComment): "// identifiers with dots were allowed specifically..." # (0..81)
- (EndOfLine): "\n" # (81..82)
- (item꞉ YulIdentifier): "foo.bar" # (82..89)
- (TrailingTrivia) ► (EndOfLine): "\n" # (89..90)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ // identifiers with dots were allowed specifically from = "0.5.8" till = "0.7.0": │ 0..81
2 │ foo.bar │ 82..89
Errors: []

Tree:
- (YulExpression) ► (variant꞉ YulIdentifierPath): # "// identifiers with dots were allowed specifically..." (0..90)
- (LeadingTrivia): # "// identifiers with dots were allowed specifically..." (0..82)
- (SingleLineComment): "// identifiers with dots were allowed specifically..." # (0..81)
- (EndOfLine): "\n" # (81..82)
- (item꞉ YulIdentifier): "foo" # (82..85)
- (separator꞉ Period): "." # (85..86)
- (item꞉ YulIdentifier): "bar" # (86..89)
- (TrailingTrivia) ► (EndOfLine): "\n" # (89..90)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// identifiers with dots were allowed specifically from = "0.5.8" till = "0.7.0":
foo.bar

0 comments on commit 59e2c74

Please sign in to comment.