The lexer doesn't know the expected symbols, so it doesn't have enough information to construct error nodes. Now, when it encounters an invalid character, it returns NULL and the parser builds a correct error node.
40 lines
935 B
Text
40 lines
935 B
Text
==========================================
|
|
recovers from top-level errors
|
|
==========================================
|
|
[}
|
|
---
|
|
(ERROR '}') (ERROR '}')
|
|
|
|
==========================================
|
|
recovers from unexpected tokens
|
|
==========================================
|
|
barf
|
|
---
|
|
(ERROR 'b')
|
|
|
|
==========================================
|
|
recovers from errors inside arrays
|
|
==========================================
|
|
[1, , 2]
|
|
---
|
|
(array
|
|
(number)
|
|
(ERROR ',')
|
|
(number))
|
|
|
|
==========================================
|
|
recovers from errors inside objects
|
|
==========================================
|
|
{ "key1": 1, oops }
|
|
---
|
|
(object (string) (number) (ERROR 'o'))
|
|
|
|
==========================================
|
|
recovers from errors inside nested objects
|
|
==========================================
|
|
{ "key1": { "key2": 1, 2 }, [, "key3": 3 }
|
|
---
|
|
(object
|
|
(string) (object (string) (number) (ERROR '2'))
|
|
(ERROR '[')
|
|
(string) (number))
|