kach / nearley

📜🔜🌲 Simple, fast, powerful parser toolkit for JavaScript.
https://nearley.js.org
MIT License
3.59k stars 232 forks source link

nearley-unparse produces strings that throw errors with nearley-test #572

Open correcthorsebatterystaple opened 3 years ago

correcthorsebatterystaple commented 3 years ago

When running nearley-unparse grammar.js the output is a string of brackets, however, this is not a valid string in my grammar and nearley-test grammar.js --input <bracket-string> confirms this by throwing an error.

Grammar: https://pastebin.com/BW5fFChR

Expected: nearley-unparse returns a valid string of the grammar Actual: Returns a string of brackets which is invalid in the grammar

Example run:

> npx nearley-unparse .\src\grammar.js -n 1 -d 15
()()()()()()()
> npx nearley-test .\src\grammar.js --input "()()()()()()()"
C:\Home\node_modules\nearley\lib\nearley.js:346
                throw err;
                ^

Error: Syntax error at line 1 col 2:

  ()
   ^
Unexpected right_para token: ")". Instead, I was expecting to see one of the following:
... (list of all the rules it expected omitted)

Node v12.19.0 nearleyc 2.20.1 nearley-unparse 2.20.1 nearley-test 2.20.1