[antlr-interest] A rewrite rule including all children of a parser rule?
Tom Davies
tom at atlassian.com
Tue Oct 9 04:05:06 PDT 2007
Hi,
I'm converting a V2 grammar to V3 (by hand -- should I be using the
automated tool?) and I have a question to do with rewrite rules.
The V2 rule uses the action:
{#module = #(#[MODULE_DEFN, "MODULE_DEFN"], module);}
to create the tree. The rule and my V3 tree rewrite rule is below.
Do I need to explicitly list all the child rules matched by the rule,
or could I say ^(MODULE_DEFN $module) and get exactly the same result
as ^(MODULE_DEFN optionalDocComment moduleNameDecl
importDeclarationList friendDeclarationList outerDefnList) ?
If I had the grammar anywhere near working I'd just test this myself,
but I'd like to know before I waste too much time :-)
Thanks,
Tom
//a start rule for a module.
module
: optionalDocComment moduleNameDecl[input.LT(1), "a valid module
name"]
importDeclarationList[input.LT(1), "a list of import
declarations"]
friendDeclarationList[input.LT(1), "a list of friend
declarations"]
outerDefnList[input.LT(1), "a list of top-level definitions"]
EOF!
-> ^(MODULE_DEFN optionalDocComment moduleNameDecl
importDeclarationList friendDeclarationList outerDefnList)
;
More information about the antlr-interest
mailing list