[antlr-interest] Parsing a JSP-like language
Michael Peter
michael.peter at crossflare.de
Wed Oct 10 01:14:14 PDT 2007
Hi!
I need to parse a JSP-like language but I have problems finding the correct
lexer rules. My input basically is HTML with special tags ("<%" and "%>")
containing language statements. Here is a short example:
<tr><td>Name</td><td><% Output( Name ) %></td><td>Image</td><td><% Image(
"bullet.gif" ) %></td></tr>
My problem is that I cannot find a lexer rule to properly match the text
outside of the <% ... %> statements. (Text outside of <% %> is written to
the output, so I need to match it)
My best guess so far was this (I'm using a gated semantic predicate to
distinguish between inside and outside of <% %> blocks):
TEXT : {!tagMode }?=> (options {greedy=false;}:.)* '<%';
But this rule obviously does not work there is some additional text after
the last %> and since there is no EOF in the lexer I cannot rewrite the '<%'
to ('<%'|EOF). I tried many other thing, but nothing seemed to work.
Maybe someone can help me?
Best regards,
Michael
More information about the antlr-interest
mailing list