alex/rply

What is the $end token?

Zelatrix opened this issue · 2 comments

I have used the RPLY library to write a compiler and one error seems to be cropping up the most. That error is the following:

ValueError: Token('$end', '$end')

What is the $end token and how can I fix the error?

Check this issue #80 you might find a way to fix it.

@Zelatrix
if you use rply.lexer.Lexer.lex(str) method to get your tokens, it's returning a rply.lexer.LexerStream object.
If you then do anything with that object, such as enumerating it, it runs the stream to its end.

Then, as I understand it, if you try to use the tokens LexerStream object in the parser, it's just getting the $end token- creating your error.

The solution for you might be to just not use the tokens in any way before passing them to the parser, or, resetting the stream if that's possible (I have not tried)