[antlr-interest] wildcard in tree grammar

Sam Harwell sharwell at pixelminegames.com
Mon Oct 20 11:41:12 PDT 2008


Since ^(. item) is valid, I think ^. as a dedicated operator is more
appropriate than ^(.).

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Terence Parr
Sent: Monday, October 20, 2008 1:27 PM
To: antlr-interest Interest
Subject: [antlr-interest] wildcard in tree grammar

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".

Ter

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-addr
ess



More information about the antlr-interest mailing list