Closed lucian1900 closed 11 years ago
Rather than a whole new class, let's just make LexerStream
into an iterator. SO change the existing next()
methods to raise StopIteration
, and make the Parser
respect that (it should also handle None
for now).
If you know that no one uses the lexer directly, sure, will do.
The only thing that uses the lexer directly is the parser and tests.
I meant any uses of rply that might be using the lexer directly. I suppose it's not particularly popular yet :)
The lexer is still relatively new, I'm fine changing the API.
Ah, I seem to have broken the RPython version.
It's actually just that test I believe.
Ah, so the problem might be pytest's raises(StopIteration)?
[edit] I was looking at the wrong test.
Well, the problem is you haven't changed the test_ztranslation.py file at all
The tests which do stuff like list(iter(lexer.lex, None))
should be changed to just use list()
directly on the lexer stream.
Do you mean the ones using FakeLexer? They do look like they can be trivially replaced with just the list passed to them.
Those, and the lexer tests.
Changing
LexerStream
'snext
to raise StopIteration would have broken API, so instead I made its__iter__
wrap it in a LexerIterator.