[antlr-interest] wildcard in tree grammar
Terence Parr
parrt at cs.usfca.edu
Mon Oct 20 11:26:43 PDT 2008
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
More information about the antlr-interest
mailing list