mirror of
https://github.com/tree-sitter/tree-sitter.git
synced 2026-09-10 07:26:23 -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>
11 lines
330 B
JavaScript
11 lines
330 B
JavaScript
// A repeat item ending in `eof()` can match at most once. The EOF-gated
|
|
// reduce must survive table minimization, so a second `text` is a parse
|
|
// error rather than being silently accepted.
|
|
export default grammar({
|
|
name: 'eof_repeat_terminated',
|
|
|
|
rules: {
|
|
source_file: $ => repeat(seq('text', eof())),
|
|
}
|
|
});
|