alex / rply

An attempt to port David Beazley's PLY to RPython, and give it a cooler API.
BSD 3-Clause "New" or "Revised" License
381 stars 60 forks source link

What is the $end token? #97

Open Zelatrix opened 4 years ago

Zelatrix commented 4 years ago

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?

ghost commented 4 years ago

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

chriszumberge commented 4 years ago

@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)