[antlr-interest] wildcard in tree grammar

Johannes Luber jaluber at gmx.de
Mon Oct 20 11:33:29 PDT 2008


Terence Parr schrieb:
> Hi gang.  We have a problem in terms of wildcards. bug:
> 
> http://www.antlr.org:8888/browse/ANTLR-248
> 
> says it all:
> 
> wildcard is single node in tree grammar analysis but node or tree at  
> runtime
> 
> We need both single node wildcard and tree wildcard. DFA analysis sees  
> '.' as a single node.
> 
> If you say ^('+' . .), that expects two single nodes as children at  
> analysis time. The problem is that at runtime we want wildcard to  
> match a subtree as well. We need to tell the analysis specifically  
> which one we mean. I can see a situation where you want to match  
> literally a single node versus a subtree. I don't want to flip  
> wildcard mean subtree.
> 
> I proposed a syntax to mean wildcard subtree: ^. instead of simple .  
> or, perhaps ^(.) as special syntax, which might be a bit more explicit  
> right? The new syntax would force the analysis to see ". DOWN .+ UP".   
> Ack, the way to do this is actually to make the grammar create the  
> appropriate NFA rather than tweaking the analysis.
> 
> Anyway, those in favor of ^(.) and . to mean wild-card tree (must be a  
> tree) and wildcard (single node)?  those opposed?
> 
> I need to fix this for the new book examples. I'm doing this really  
> cool filter mode for trees where you can say "for any addition you  
> find in the tree, do this".

I don't see anything wrong with this suggestion, even if it creates some
work on my side. ;) Looking at the nature of the bug, fixing it this way
won't change the behaviour of already generated and written grammars, right?

Johannes
> 
> Ter
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 



More information about the antlr-interest mailing list