-
Notifications
You must be signed in to change notification settings - Fork 63
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 line vs. block comment interaction in the saw-script lexer #2191
Conversation
Don't have the lexer match //.*; just match the // part, and extend the same logic that handles dropping the bits between /* and */ to also handle dropping the bits between // and EOL. This requires materializing EOL tokens instead of treating them as whitespace, but that costs ~nothing. Also fix it so we generate explicit messages when there are unclosed comments. A // comment that doesn't have an EOL before EOF generates a warning; a /* comment without a matching */ generates an error. The position for this error is the comment start. (The previous behavior was that unclosed comments commented out the EOF token and that would cause a non-specific "parse error".) Update the lexer call sites to post the messages. There should not be four separate lexer call sites, but that's a problem for a future branch. Add some tests. This includes a new test_parse_errors area akin to the existing test_type_errors.
(interactions of comments and Cryptol blocks) Note: these reflect the current behavior, which as discussed in the issue is not particularly desirable. They should be updated when/if the behavior is improved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach used here looks plausible to me, although I'd like for some of this to be documented further.
src/SAWScript/Token.hs
Outdated
-- EOL End of line | ||
-- EOF End of file/input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- EOL End of line | |
-- EOF End of file/input | |
-- TEOL End of line | |
-- TEOF End of file/input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oy. Fixed...
Prompted by #1225 (which is about the saw-core lexer); closes #2181.