-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use case for rewind #12
Comments
Interesting point! I guess that is currently true. The idea is so moo can be used as part of a syntax highlighting framework (e.g. a custom CodeMirror mode). You can feed() a line at a time; when the input changes, CodeMirror restarts syntax highlighting from the first changed line. I suppose if we had a way to save / get a handle to the current internal state (line number, state stack), rewind() wouldn't be needed? I'm not sure. |
Perhaps we could allow passing a previous Token to reset()? The lexer could copy the line number off of the Token. This shifts the responsibility for keeping track of past tokens / line numbers onto the user, and avoids the need for rewind(). It would, however, mean keeping a reference to the state stack on the Token. |
From #14:
|
Why do
rewind
/rewindLines
exist? They have no effect on the token stream other than truncating it, and it seems like the following is semantically identical to the current implementation:That passes all the tests other than checks against
lexer.buffer
, which seems like it should not be part of the public API anyway.The text was updated successfully, but these errors were encountered: