-
That title probably doesn't help much, but I'm not quite sure how best to categorize the problem. Here's a tiny grammar: module.exports = grammar({
name: 'examples',
extras: ($) => [
/\s/
],
rules: {
source_file: ($) => seq(optional($.prolog), $.rule),
rule: ($) => seq($.name, /[:=]/, $.name, '.'),
prolog: ($) => $.version,
version: ($) => seq("file", "version", $.string, '.'),
name: ($) => /[a-zA-Z]+/,
string: ($) => seq('"', /[^\"]*/, '"'),
}
}); And here's a small corpus:
The first two tests work fine, the last test fails because (I gather) Can this be fixed? I've poked about in various ways with precedence without succes. |
Beta Was this translation helpful? Give feedback.
Answered by
ahlinc
Aug 21, 2023
Replies: 1 comment 1 reply
-
Your case can be fixed simply by defining the name: $ => choice(/[a-zA-Z]+/, "file"), |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ndw
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your case can be fixed simply by defining the
name
rule as: