[antlr-interest] Comment rule matches links
Jenny Balfer
ai06087 at Lehre.BA-Stuttgart.De
Mon Aug 25 09:15:28 PDT 2008
Hi everybody,
I am pretty new to antlr and I am facing a problem that I could not find a
solution for.
I am using the "standard" rule for single line comments:
COMMENT : '//' (options {greedy=false;}: .)* ('\n'|'r') { skip(); }
;
This works pretty well, until I have things like that in my code:
aString = "http://someUrl.com";
Because the url contains two slashes, the lexer treats everything from then
on as a comment and skips the rest of the line; only aString = "http:
remains.
I tried to fight this problem by adding a rule that matches every string
before the comment rule:
STRING : '"' (options {greedy=false;} .)* '"'
;
This temporarily solved the problem, but brought up further issues, so I
would really appreciate to get along without it. Does anyone have a better
solution to prevent my lexer from skipping urls just because they contain
slashes?
Thanks in advance.
Jenny
More information about the antlr-interest
mailing list