tree-sitter/test
Max Brunsfeld 99d048e016 Simplify error recovery; eliminate recovery states
The previous approach to error recovery relied on special error-recovery
states in the parse table. For each token T, there was an error recovery
state in which the parser looked for *any* token that could follow T.
Unfortunately, sometimes the set of tokens that could follow T contained
conflicts. For example, in JS, the token '}' can be followed by the
open-ended 'template_chars' token, but also by ordinary tokens like
'identifier'. So with the old algorithm, when recovering from an
unexpected '}' token, the lexer had no way to distinguish identifiers
from template_chars.

This commit drops the error recovery states. Instead, when we encounter
an unexpected token T, we recover from the error by finding a previous
state S in the stack in which T would be valid, popping all of the nodes
after S, and wrapping them in an error.

This way, the lexer is always invoked in a normal parse state, in which
it is looking for a non-conflicting set of tokens. Eliminating the error
recovery states also shrinks the lex state machine significantly.

Signed-off-by: Rick Winfrey <rewinfrey@github.com>
2017-09-11 15:22:52 -07:00
..
compiler Move incompatible token map into LexTableBuilder 2017-08-31 15:46:37 -07:00
fixtures Simplify error recovery; eliminate recovery states 2017-09-11 15:22:52 -07:00
fuzz Add libFuzzer support 2017-07-14 13:50:41 -07:00
helpers Make outstanding_allocation_indices return a vector, not a set 2017-09-07 17:48:44 -07:00
integration Disable fuzzing example test for now 2017-08-08 17:35:16 -07:00
runtime Simplify error recovery; eliminate recovery states 2017-09-11 15:22:52 -07:00
benchmarks.cc Add bash examples to benchmarks 2017-07-17 17:50:04 -07:00
test_helper.h Rename spec -> test 2017-03-09 20:40:01 -08:00
tests.cc Use C++ stdlib for random number generation 2017-08-08 12:42:49 -07:00