[antlr-interest] Questions to Java.g
Andreas
mail.acc at freenet.de
Sun Jul 15 09:38:19 PDT 2007
mail.acc at freenet.de schrieb:
> 2nd:
> I made further tests with this grammar and by chance noticed something weird. This time I have an valid Java file, but Java.g reported an lexer-error (at least I think it is an lexer-error). But it occurs only in this special situation.
> If the last line of the file ends with an single line comment, and if there is no newline after this, I get the following error:
>> line 2:12 mismatched character '<EOF>' expecting 'n'
> Input:
> ---------------------
> public class Code {}
> // End Class
> ---------------------
After a little search in the archives of this mailing list I found a
e-mail which I think is about the same issue.
http://www.antlr.org/pipermail/antlr-interest/2006-January/015126.html
Although his originated question about the EOF Token has not been
answered someone gave an answer about the inline comment <EOF> problem.
http://www.antlr.org/pipermail/antlr-interest/2006-January/015128.html
> Make NewLine at the end of single line comment optional:
> SingleLineComment :"//" ( ~('\r' | '\n') )* ( NewLine )? ;
> It will match NewLine everywhere except
> // comment text <EOF>
If I'm not totaly wrong that is the same issue with Java.g, isn't it?
Best Wishes From Germany
Andreas
More information about the antlr-interest
mailing list