[antlr-interest] TokenStreamRewriteEngine: possible to use non-terminals instead of tokens?
SainTiss
saintiss at arklinux.org
Wed Feb 4 06:52:15 PST 2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I got the TokenStreamRewriteEngine working so that it just gives back the
original string of what was parsed...
Using the java.g grammar, what I would like to do now is delete the type
specifier from a declaration statement:
"int myInt = 7;" => "myInt = 7;"
This should only be done when the declaration is a statement, and not when it
is a class field for example...
So it should only apply for the rule:
statement
: (declaration)=> declaration SEMI!
However, it seems that the rewriteEngine can only delete a range of tokens.
SEMI is a token, but "declaration" is not so it seems (I guess its type is
"void" since that's the return type of the declaration() method?). Still, I
can't put the replace action where the type token is, because that's in the
"identifier" rule, which would mean all identifiers would be deleted...
So is there a way I can "navigate" from "declaration" to the typeSpec and then
to the identifier token in order to remove it?
Thanks in advance,
Hans
- --
Ark Linux - Linux for the Masses (http://arklinux.org)
Capitalism:
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.
Representative Democracy:
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?
Hans Schippers
2LIC INF
UA 2003-2004
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQFAIQcfXlnUYIbmLOQRAkvAAJ4g4YfP/aj4OiA6dOWsAz3C19TyFACfe9yM
M5Gg79gLUQx2il6VEv8I/Ug=
=VCcE
-----END PGP SIGNATURE-----
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