[antlr-interest] Layout processing
Daniel Shane
lachinois at hotmail.com
Tue Jan 13 07:05:38 PST 2004
Hi all,
I'm rather new to ANTLR processing and I was wondering if ANTLR could solve
my problem.
The language that I am trying to parse contains layout characters (mainly
whitespaces). As I understand in ANTLR, these layout characters should be
handled in the lexer and ignored at the source. The problem is that I would
like to keep them in the parse tree without having to sparkle them all over
the grammar.
Would it be possible to override LA() and match() to be able to skip
(ignore) layout tokens while at the same time keeping them in the parse
tree?
I know that stated this way, it is ambigous, how can ANTLR, without further
information, know where to place the WS in the parse tree? In my example, I
would like WS to be "factored" out of rules as much as possible so that they
are only present in the body of a rule, not at the start nor at the end of
them.
State that way, there is only one place for every WS present in the instance
to parse. Not knowing that much about ANTLR, is there a way to automagically
override a certain function to obtain this behaviour?
My only alternative is to sprinkle (WS)? elements nearly everywhere in the
grammar... Certainly there is a better way to do this since this would beef
up my grammar by 50% (in characters) and also give me the headache of a
lifetime figuring out the right k because of all the optional WS that could
happen.
Thanks in advance!
Daniel Shane
_________________________________________________________________
MSN Search, le moteur de recherche qui pense comme vous !
http://fr.ca.search.msn.com/
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