kach / nearley

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

Unexpected "\r" #522

Open Freddson opened 4 years ago

Freddson commented 4 years ago

I'm making a nearley parser, and when I try to do a basic var + math with it, like n=1 + 1 in code, it shows this error:

`An error has occured while parsing! Syntax error at line 1 col 8:

n=1 + 1 ^ Unexpected "\r". Instead, I was expecting to see one of the following:`

The code is: https://pastebin.com/D3NzWhLc

If someone would help me, i'd be really grateful.

darthtrevino commented 3 years ago

FYI; I ran into this issue in my Jest tests, and I was able to resolve it by creating a new parser instance for each test. It looks like the parser is stateful and you have to create a new one every time