[antlr-interest] "!" operator and hidden tokens
Ric Klaren
klaren at cs.utwente.nl
Thu Jul 22 02:21:50 PDT 2004
On Wed, Jul 21, 2004 at 10:12:34PM -0000, johnj1984 wrote:
> Now I have a question with regards to maintaining comments:
> When using CommonASTWithHiddenTokens ast nodes, does the "!"
> operator transfer the hidden tokens to the surrounding non-matched
> nodes?
No it leaves out these tokens completely.
> If the "!" operator does not link the hidden tokens to the
> surrounding tokens, what is the general strategy for dealing with
> this? Override the match() method to copy the links?
All the examples I've seen (see also in the distro
examples/java/preserveWhitespace) people used a TokenStream filter to mask
out certain tokens. See TokenStreamHiddenTokenFilter.java in the antlr
sources. You could probably combine that filter with Monty's TokenFiltering
approach for fancier stuff:
http://www.codetransform.com/filterexample.html
> Also defined as, are there any examples of spitting out comments in
> across AST tree translation/manipulations?
I'm only aware of the above preserveWhitespace example.
Cheers,
Ric
--
-----+++++*****************************************************+++++++++-------
---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755 ----
-----+++++*****************************************************+++++++++-------
"I think we better split up."
"Good idea. We can do more damage that way."
--- Ghostbusters
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