Skip to content

Commit

Permalink
feat: Support arbitrary ascii escapes until 0.4.25
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Apr 5, 2024
1 parent d905cf6 commit ea4c5aa
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 13 deletions.
49 changes: 45 additions & 4 deletions crates/solidity/inputs/language/src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3820,9 +3820,21 @@ codegen_language_macros::compile!(Language(
Token(
name = SingleQuotedStringLiteral,
definitions = [
// Allows unicode characters:
// Allows unicode characters and arbitrary ASCII escape sequences:
TokenDefinition(
enabled = Till("0.7.0"),
enabled = Till("0.4.25"),
scanner = Sequence([
Atom("'"),
ZeroOrMore(Choice([
Fragment(EscapeSequenceArbitraryAscii),
Not(['\'', '\\', '\r', '\n'])
])),
Atom("'")
])
),
// Allows unicode characters but allows only known ASCII escape sequences:
TokenDefinition(
enabled = Range(from = "0.4.25", till = "0.7.0"),
scanner = Sequence([
Atom("'"),
ZeroOrMore(Choice([
Expand Down Expand Up @@ -3850,9 +3862,21 @@ codegen_language_macros::compile!(Language(
Token(
name = DoubleQuotedStringLiteral,
definitions = [
// Allows unicode characters:
// Allows unicode characters and arbitrary ASCII escape sequences:
TokenDefinition(
enabled = Till("0.7.0"),
enabled = Till("0.4.25"),
scanner = Sequence([
Atom("\""),
ZeroOrMore(Choice([
Fragment(EscapeSequenceArbitraryAscii),
Not(['"', '\\', '\r', '\n'])
])),
Atom("\"")
])
),
// Allows unicode characters but allows only known ASCII escape sequences:
TokenDefinition(
enabled = Range(from = "0.4.25", till = "0.7.0"),
scanner = Sequence([
Atom("\""),
ZeroOrMore(Choice([
Expand Down Expand Up @@ -3981,6 +4005,18 @@ codegen_language_macros::compile!(Language(
])
])
),
Fragment(
name = EscapeSequenceArbitraryAscii,
enabled = Till("0.4.25"),
scanner = Sequence([
Atom("\\"),
Choice([
Fragment(AsciiEscapeArbitrary),
Fragment(HexByteEscape),
Fragment(UnicodeEscape)
])
])
),
Fragment(
name = AsciiEscape,
scanner = Choice([
Expand All @@ -3995,6 +4031,11 @@ codegen_language_macros::compile!(Language(
Atom("\n")
])
),
Fragment(
name = AsciiEscapeArbitrary,
enabled = Till("0.4.25"),
scanner = Not(['x', 'u'])
),
Fragment(
name = HexByteEscape,
scanner = Sequence([
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.

16 changes: 14 additions & 2 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.

Loading

0 comments on commit ea4c5aa

Please sign in to comment.