Skip to content

Commit

Permalink
feat: support inline flags
Browse files Browse the repository at this point in the history
  • Loading branch information
ValdezFOmar authored and amaanq committed Nov 10, 2024
1 parent 6d3703b commit d64ab0e
Show file tree
Hide file tree
Showing 6 changed files with 1,811 additions and 1,170 deletions.
14 changes: 14 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ module.exports = grammar({
$.anonymous_capturing_group,
$.named_capturing_group,
$.non_capturing_group,
$.inline_flags_group,
),
optional(choice(
$.zero_or_more,
Expand Down Expand Up @@ -153,6 +154,19 @@ module.exports = grammar({

non_capturing_group: $ => seq('(?:', $.pattern, ')'),

inline_flags_group: $ => seq(
'(?',
choice(
$.flags,
seq($.flags, '-', $.flags),
seq('-', $.flags),
),
optional(seq(':', $.pattern)),
')',
),

flags: _ => /[a-zA-Z]+/,

zero_or_more: quantifierRule(_ => '*'),
one_or_more: quantifierRule(_ => '+'),
optional: quantifierRule(_ => '?'),
Expand Down
6 changes: 6 additions & 0 deletions queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
"," @punctuation.delimiter
])

(inline_flags_group
"-"? @operator
":"? @punctuation.delimiter)

(flags) @character.special

(character_class
[
"^" @operator
Expand Down
81 changes: 81 additions & 0 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 37 additions & 4 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d64ab0e

Please sign in to comment.