[antlr-interest] Rewrite rule in Habelitz Java grammar ignored?
jasonveldicott at gmail.com
Fri Jul 20 12:04:29 PDT 2012
I'm trying to get Habelitz's
grammar running, java.g, and have encountered a problem in which the
following top-level parser rule:
-> ^(JAVA_SOURCE compilationUnit)
does not produce an AST rooted with JAVA_SOURCE, but instead with a node
named ANNOTATION_LIST, which comes later in the grammar. A longer listing
of the produced AST appears at end of this post.
It seems the rewrite part of this rule is ignored. I need it not to be,
otherwise the accompanying JavaTreeParser.g (by Habelitz) results in this
JavaTreeParser.g: node from line 0:0 mismatched tree node: ANNOTATION_LIST
Any suggestion as to what my be going wrong here would be much appreciated.
tree=ANNOTATION_LIST (import (. (. java io) File)) (class (MODIFIER_LIST
public) Test1 (CLASS_TOP_LEVEL_SCOPE (VOID_METHOD_DECL (MODIFIER_LIST
public) test FORMAL_PARAM_LIST (BLOCK_SCOPE (EXPR (METHOD_CALL (. (. System
out) println) (ARGUMENT_LIST (EXPR "testing"))))))))
More information about the antlr-interest