[antlr-interest] another lookahead issue with TokenStreamRewriteEngine
saintiss at arklinux.org
Thu Feb 5 09:29:01 PST 2004
-----BEGIN PGP SIGNED MESSAGE-----
In the java.g grammar, I'm trying to parse a list of statements, by repeatedly
calling a rule statementComplete:
A statement, afaik, always ends with SEMI or "}". However, it seems that the
parser sometimes reads beyond that, probably for lookahead reasons.
For example, when parsing the following:
Method method = (Method) m;
final int myInt = 5;
After calling statementComplete once, and then calling the rewriteEngine's
toOriginalString() method, I get:
"Method method = (Method) m;
so the newline and "final" have been read as well, even though they obviously
aren't part of the first statement. Is there a way to get rid of this?
Preferrably a way to make sure no tokens are read beyond the actual
PS Terence: there are a couple of minor bugs in the TokenStreamRewriteEngine
1) In a couple of places, "programName" should be passed on to the
addToSortedRewriteList, but isn't... (e.g. in public void replace(String
programName, Token from, Token to, String text))
2) A delete operation should be defined as replace with text "", not text
null, because the latter will put the characters n-u-l-l in the string...
Ark Linux - Linux for the Masses (http://arklinux.org)
You don't have any cows. The bank will not lend you money to buy cows,
because you don't have any cows to put up as collateral.
You have two cows. Your neighbors pick someone to tell you who gets the milk.
In a world without walls and fences, who needs windows and gates?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
-----END PGP SIGNATURE-----
Yahoo! Groups Links
<*> To visit your group on the web, go to:
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
More information about the antlr-interest