I'm trying to implement grammar for jade like syntax with indent/dedent:
div
p id="text"
But i got have problems with EOF:
Error: Parse error on line 4:
div p id="text"
----------------^
Expecting 'DEDENT', 'IDENTIFIER', got 'EOF'
Grammar: https://gist.github.com/antonmedv/7615a5322dec1736db60a87897f17f01
What am i doing wrong?
You generate DEDENT tokens only when you see the first non-whitespace character in a line. At EOF, there is no such character, so the final DEDENTs are never generated. The DEDENTs are required by your grammar, so you get a syntax error at EOF.
Your EOF rule must flush the indent stack before reporting the end of file.