Skip to content

Commit 8c2aacf

Browse files
committed
feat(grammar): add support for hex string literals in Yul assembly
- Add yul_hex_string_literal rule to support hex"" and hex'' syntax in inline assembly - Include the new literal type in _yul_literal choices - Add test cases for hex string literals with underscores, empty strings, and single quotes Fixes #75
1 parent 322a3dd commit 8c2aacf

File tree

5 files changed

+34169
-33426
lines changed

5 files changed

+34169
-33426
lines changed

grammar.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,18 @@ module.exports = grammar({
408408
$.yul_string_literal,
409409
$.yul_hex_number,
410410
$.yul_boolean,
411+
$.yul_hex_string_literal,
411412
),
412413
yul_decimal_number: $ => /0|([1-9][0-9]*)/,
413414
yul_string_literal: $ => $.string,
414415
yul_hex_number: $ => /0x[0-9A-Fa-f]*/,
415416
yul_boolean: $ => choice('true', 'false'),
417+
yul_hex_string_literal: $ => seq(
418+
'hex',
419+
choice(
420+
seq('"', optional(optionalDashSeparation($._hex_digit)), '"'),
421+
seq("'", optional(optionalDashSeparation($._hex_digit)), "'"),
422+
)),
416423

417424
// -- Yul Statements --
418425
yul_block: $ => seq('{', repeat($._yul_statement), '}'),

src/grammar.json

Lines changed: 126 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)