[antlr-interest] wildcard in tree grammar
Sam Harwell
sharwell at pixelminegames.com
Wed Nov 26 14:47:12 PST 2008
It does make sense to have the following action:
. as the first child of a multi-child block matches any single node
. in any other position matches any node or subtree
The following modified check in TreeToNFAConverter should correct the
issues people are seeing. Remember I'm using V3 grammars so let me know
if the translation doesn't work right.
Current:
if ( nfa.grammar.type == Grammar.TREE_PARSER )
{
$g = factory.build_WildcardTree( $w );
}
else
{
$g = factory.build_Wildcard( $w );
}
Modified:
if ( nfa.grammar.type == Grammar.TREE_PARSER
&& (w.ChildIndex > 0 || w.Parent.getChild(1).Type == EOA) )
{
$g = factory.build_WildcardTree( $w );
}
else
{
$g = factory.build_Wildcard( $w );
}
Note that when w.ChildIndex == 0 and its next sibling is EOA, it means
the . is the child of a closure such as .* , since the other possibility
^(.) is not allowed in a tree parser.
-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Terence Parr
Sent: Wednesday, November 26, 2008 3:09 PM
To: antlr-interest Interest
Subject: Re: [antlr-interest] wildcard in tree grammar
Hi gang, I've recently fixed how this wildcard thing works in tree
grammars.
October 21, 2008
* Made . in tree grammar look like ^(. .*) to analysis, though ^(. foo)
is illegal (can't have . at root). Wildcard is subtree or node.
Fixed bugs:
http://www.antlr.org:8888/browse/ANTLR-248
http://www.antlr.org:8888/browse/ANTLR-344
Not sure why ^(. foo) is illegal...hmm...weird.
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