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

Lexer seems to not understand keep notation, but the parser does #13

Closed
ribbanya opened this issue Aug 10, 2018 · 1 comment
Closed

Comments

@ribbanya
Copy link

ribbanya commented Aug 10, 2018

As far as I can tell, 'keep' expressions (k[hl]?\d+) are being ignored because the lexer does not have the token for it defined. When debugging, parseKeep is skipped. TokenType is missing a Keep entry. (Apparently it should just be an Identifier, but still, the keep functionality does not appear to be accessible).

@tom-wolfe
Copy link
Owner

This was pretty tricky to fix! I eventually traced it back to a couple of bugs. If the input stream ends with an identifier token, the buffer was never terminating because apparently regex.test(null) returns true, so the identifier was ending up "khnull", which obviously wouldn't match anything.

Secondly, there were a couple of key places where the parsing context was switched to parse a dice roll expression (4d6) rather than a dice expression, which includes the additional modifiers. I've fixed it, and added some regression tests as part of my latest update. So as of 1.5.0, which has been published, this should be fixed.

Thanks for your help, and let me know if you have any more trouble!

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

No branches or pull requests

2 participants