[antlr-interest] "context sensitivity" of tree parsing

Loring Craymer lgcraymer at yahoo.com
Mon Mar 3 14:11:21 PST 2008


You have discovered the two possible options--replicate rules or use a state flag--for single pass processing.  There are also cases where it is possible to do something with StringTemplates, and you can  add in a tree walker pass that prunes the subtrees for which you do not want to execute actions.  If you are doing complicated analysis, the extra tree walker pass can be the best solution (and it may turn out not be an extra pass)--it never hurts to simplify.

--Loring

----- Original Message ----
> From: Benjamin Shropshire <shro8822 at vandals.uidaho.edu>
> To: Antlr Interest <antlr-interest at antlr.org>
> Sent: Monday, March 3, 2008 1:43:23 PM
> Subject: [antlr-interest] "context sensitivity" of tree parsing
> 
> I known context sensitive has another manging but it is the most 
> descriptive term here:
> 
> I have a tree parser working over an AST and I have a particular rule 
> that gets used in 2 places. In one place I want it to do something and 
> in another I don't want it to do anything. Rather than copy the whole 
> rule (and potentially a pile of referenced rules) and edit out the 
> actions, my first though is to pass a bool in to test on (on true I'm in 
> the one cases, on false I'm in the other) but this seems a bit clunky.
> 
> Is there a better way? If so, what is it called and where can I read up 
> on it?
> 




      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping


More information about the antlr-interest mailing list