Skip to content

Commit

Permalink
fix: disallow empty groupings, alternations
Browse files Browse the repository at this point in the history
Something like `()` or `[]` is a syntax error and it would be nice if
the parser reflected that (even if just with a "missing" node rather
than an error node).
  • Loading branch information
ribru17 authored and amaanq committed Nov 9, 2024
1 parent 3c61bfc commit d0d9126
Show file tree
Hide file tree
Showing 4 changed files with 2,739 additions and 3,280 deletions.
4 changes: 2 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ module.exports = grammar({
string_content: $ => repeat1(choice(token.immediate(prec(PREC.STRING, /[^"\\]+/)), $.escape_sequence)),
parameters: $ => repeat1(choice($.capture, $.string, $._node_identifier)),
comment: _ => token(prec(PREC.COMMENT, seq(";", /.*/))),
list: $ => seq("[", repeat($.definition), "]", quantifier($), captures($)),
list: $ => seq("[", repeat1($.definition), "]", quantifier($), captures($)),

grouping: $ => seq(
"(",
repeat(seq($._group_expression, optional("."))),
repeat1(seq($._group_expression, optional("."))),
")",
quantifier($),
captures($),
Expand Down
4 changes: 2 additions & 2 deletions src/grammar.json

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

4 changes: 2 additions & 2 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 d0d9126

Please sign in to comment.