mirror of
https://github.com/tree-sitter/tree-sitter.git
synced 2026-09-10 07:36:22 -04:00
This commit adds an `eof()` function for grammars, which is easier to use than the NUL byte directly. It compiles down to a constraint that the enclosing production can only reduce at end of input, not to a shiftable token. BREAKING CHANGE: Public error types for `tree-sitter-generate` were modified. Co-authored-by: Will Lillis <will.lillis24@gmail.com>
14 lines
425 B
JavaScript
14 lines
425 B
JavaScript
// `a` has two productions that reduce identically and differ only in precedence.
|
|
// The higher one has to outrank `c`, which means the duplicate action still has
|
|
// to be compared against rather than skipped.
|
|
export default grammar({
|
|
name: 'duplicate_reduction_precedence',
|
|
|
|
rules: {
|
|
start: $ => choice($.a, $.c),
|
|
a: $ => choice($.x, prec(2, $.x)),
|
|
c: $ => $.x,
|
|
x: _ => 'x',
|
|
}
|
|
})
|