I've seen a matching rule like this in many places (the jflex manual, the source of Cup, ..?):
EndOfLineComment = "//" {InputCharacter}* {LineTerminator}
If I'm not mistaken this is broken if the line comment is on the last line. By either removing {LineTerminator} or making it {LineTerminator}? it seems to work as expected. Might be good to fix so the bug doesn't spread further.
But if we remove it, it could consume all input characters until the end of file, including non comment.
The best practice is to append an empty line to the input document, before parsing.
To clarify, I was thinking InputCharacter could be something like [^\r\n].
On May 17, 2014 9:40 AM, Régis Décamps decamps@users.sf.net wrote:
Related
Bugs: #128
I though further about it, and I think you are correct.
In
java.flexexample, we already haveI've updated the JFlex manual.
In,
LexScan.flex, we only haveBut for some reason, Jflex parses the grammar correctly even if it ends with a single EndOfLineComment.
In LexScan.flex this is correct, because EndOfLineComment isn't used in the last section of specs (REGEXP/REGEXPSTART). In this last section, the expression is
and newline is matched/ignored separately.
So if it's Ok in the examples, we only need to update the manual.
Now tracked on https://github.com/jflex-de/jflex/issues/129