Skip to content

Commit 56e513d

Browse files
danghamaanq
authored andcommitted
feat: allow underscores in named capturing groups
1 parent 205dafc commit 56e513d

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

grammar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ module.exports = grammar({
219219
// [+U]uNonSurrogate
220220
// [~U]uHex4Digits
221221
// [+U]u{CodePoint}
222-
group_name: _ => /[A-Za-z0-9]+/,
222+
group_name: _ => /[A-Za-z_][A-Za-z0-9_]*/,
223223

224224
decimal_digits: _ => /\d+/,
225225
},

src/grammar.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/parser.c

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

test/corpus/main.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ hello (.*)
452452
================================================================================
453453
named capturing groups
454454
================================================================================
455-
(?<world>.*)
455+
(?<the_world>.*)
456456
--------------------------------------------------------------------------------
457457

458458
(pattern
@@ -467,7 +467,7 @@ named capturing groups
467467
================================================================================
468468
named capturing groups - backreferences
469469
================================================================================
470-
(?<world>.*)\kworld
470+
(?<the_world>.*)\kthe_world
471471
--------------------------------------------------------------------------------
472472

473473
(pattern

0 commit comments

Comments
 (0)