[antlr-interest] I just want to know what the previous token was...
charlweed
charlweed at yahoo.com
Mon Aug 9 15:32:07 PDT 2004
I hope this is an intermediate question and not an obvious newbie stumble.
I've read the manual and the FAQ and I just don't have a handle on
syntactic predicates for looking backwards.
I think I merely want to know what the PREVIOUS token actually was, so
I can rewrite the stream.
For example in Java source, I want to replace an identifier with a
getter. However, if the identifier is the operand of a decrement or
increment unary operator, I want to leave it alone:
j = _i ;// becomes j = getI();
_i++; // stays the same. Easy to detect, just look ahead.
--_i; // stays the same. I need to look back to see if the previous
Token is an INC or DEC
The easiest place to put my re-write method is within the identPrimary
rule. But at that point, I need to know if the previous token was an
INC or DEC and must therefore be unmodified. If I add a re-write
method within the rule for pre-increment or decrement, then I need
lots of logic to enable and disable the rewrite at identPrimary.
So, um
what can I do?
Thanks,
Charlweed
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list