Skip to content
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

Fix saving and resetting queued groups #176

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ictrobot
Copy link

Currently Lexer.prototype.reset and Lexer.prototype.save reference three queued fields: queuedToken, queuedText (added in #169) and queuedThrow.

There only appear to be references to queuedText and queuedGroup elsewhere, so this MR removes queuedToken and
queuedThrow and adds queuedGroup to reset and save.

The below example shows how this could be problematic - on master it prints a token when it probably shouldn't:

const moo = require("./moo")

const lexer = moo.compile({
    number: {match: /\d+/},
    text: moo.fallback
})

lexer.reset('test123')
lexer.next()
lexer.reset()
console.log(lexer.next())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant