[antlr-interest] Calling directly nonterminals other than top symbol?

Ric Klaren klaren at cs.utwente.nl
Thu Jun 26 06:32:11 PDT 2003


On Thu, Jun 26, 2003 at 02:40:51PM +0200, Hrvoje Nezic wrote:
> Is it safe to call directly methods corresponding
> to nonterminals other than the top symbol of the
> grammar?

It is safe to some extent. Though you have to be aware of lookahead &
follow sets, because you are pulling a rule out of context. Sometimes you
have to add a dummy rule something like:

dummy: my_rule ( . )? ;

So it won't barf if something is following the tree part you're interested
in.

I personally do it a lot with tree walkers.

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  "I don't have anything against Java - it's the best damn implementation
              of UCSD Pascal ever released..." --- Larry Smith

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list