-
Notifications
You must be signed in to change notification settings - Fork 115
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
Allow java comment after yylexthrow #794
Conversation
``` INFO: Found 2 targets... ERROR: /Users/regisd/Projects/jflex/javatests/jflex/testcase/yylexthrow_comment/BUILD.bazel:3:6: jflex javatests/jflex/testcase/yylexthrow_comment/Yylexthrow.java failed (Exit 1) jflex_bin failed: error executing command bazel-out/host/bin/jflex/jflex_bin -d bazel-out/darwin-fastbuild/bin/javatests/jflex/testcase/yylexthrow_comment javatests/jflex/testcase/yylexthrow_comment/yylexthrow.flex Use --sandbox_debug to see verbose messages from the sandbox Reading "javatests/jflex/testcase/yylexthrow_comment/yylexthrow.flex" Error in file "javatests/jflex/testcase/yylexthrow_comment/yylexthrow.flex" (line 9): %yylexthrow needs a list of (qualified) identifiers %yylexthrow Exception // comment on same line allowed ```
- Add the comment after the exception - Change type of AbstractLexer.lexThrown from String to List<String> Let the emitter do the formatting, instead of concatenating the exceptions in the flex file
3fa6baf
to
cdd90b1
Compare
@lsf37 I think this fixes the described bug. I'm not sure whether There might be other ways, such as dropping the comment and only keep the identifier. Also, there might be other keywords to fix. What do you think? |
@lsf37 Can you have a look at this PR? It's not very complex, but it's changing jflex core and I don't want to submit without review. |
Thanks for doing this, I can look at it tomorrow and finish it off (if there is anything to be changed, which there probably isn't) |
My knownledge of the jflex grammar is not great. |
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.
This looks good. I can't think of a nicer way to include the comments, at least not without a major refactor (the whole section should probably be more in the parser and less in the lexer, but that's for another time).
Happy for you to merge!
Currently the
%lexthrow
keyword can only be followed by identifiersThis change allows the identifier of the exception to be followed by a comment.
However, the emitter must also be adapter to emit one exception per line, otherwise the comment of the first might hide all the following declarations.
Also refactor the
AbstractLexScan.lexThrown
field fromString
toList<String>
, and let the emitter handle the formatting.Add an integration test.