[antlr-interest] syntactic predicate and line/column information

Ovidio Mallo malloovidio at bluewin.ch
Fri Aug 18 05:28:25 PDT 2006


Hi everyone,

I'm very new to ANTLR. I'm currently using ANTLR to extent a Java grammar
by adding Java 1.5 support to it. My problem is that I want to use the
"syntactic predicate" construct to see whether I have to parse a normal
Java for-statement or an enhanced-for-statement as supported by Java 1.5.

Actually, everything works fine but the problem I have is that while the
syntactic predicate is evaluated by the parser, the line and column information
seem to be altered. Therefore, once the parser knows which of the two
for-statements to parse, this information is actually wrong which gets
reflected in the errors eventually produced by the compiler.

Therefore, I wanted to ask whether it is possible to avoid that line/column
information is altered while evaluating a syntactic predicate or, alternatively,
if it is possible to save this information and restore if after having evaluated
the syntactic predicate...

Of course, I could also gather the line/column information before the
syntactic predicate and then pass it but this does not work too well in my
case.

Well, I guess my explanation is a bit weird but I hope it's clear what I
mean... :-)

In any case, thanks a lot in advance for any help!

Best regards,
   Ovidio



More information about the antlr-interest mailing list