Now, grammars can handle whitespace by making it another ubiquitous token, like comments. For now, this has the side effect of whitespace being included in the tree that precedes it. This was already an issue for other ubiquitous tokens though, so it needs to be fixed anyway.
40 lines
931 B
Text
40 lines
931 B
Text
==========================================
|
|
recovers from top-level errors
|
|
==========================================
|
|
[}
|
|
---
|
|
(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) (value (number)))
|