forked from jasder/antlr
Down to one issue -- tree::ParseTree and tree:RuleNode aren't related as they are in some tests. Need to find either the right relationship or come up with an alternative test.
This commit is contained in:
parent
ae4dcbabbd
commit
c8e60b7fe0
|
@ -843,6 +843,7 @@ public abstract class BaseCppTest {
|
|||
+ "\n"
|
||||
+ "#include \"ANTLRInputStream.h\"\n"
|
||||
+ "#include \"CommonTokenStream.h\"\n"
|
||||
+ "#include \"tree/ParseTreeWalker.h\"\n"
|
||||
+ "#include \"<lexerName>.h\"\n"
|
||||
+ "#include \"<parserName>.h\"\n"
|
||||
+ "#include \"<listenerName>.h\"\n"
|
||||
|
@ -860,9 +861,14 @@ public abstract class BaseCppTest {
|
|||
+ " void enterEveryRule(Ref\\<ParserRuleContext> ctx) override {\n"
|
||||
+ " for (auto child : ctx->children) {\n"
|
||||
+ " auto parent = child->getParent();\n"
|
||||
+ " if (dynamic_cast\\<tree::RuleNode>(parent) || parent.getRuleContext() != ctx) {\n"
|
||||
+ " raise \"Invalid parse tree shape detected.\";\n"
|
||||
+ " if (!antlrcpp::is\\<tree::RuleNode>(parent)) {\n"
|
||||
+ " throw \"Invalid parse tree shape detected.\";\n"
|
||||
+ " }\n"
|
||||
+ " tree::RuleNode* rule = static_cast\\<tree::RuleNode*>(&parent);\n"
|
||||
+ " if (rule->getRuleContext() != ctx) {\n"
|
||||
+ " throw \"Invalid parse tree shape detected.\";\n"
|
||||
+ " }\n"
|
||||
|
||||
+ " }\n"
|
||||
+ " }\n"
|
||||
+ "};\n"
|
||||
|
@ -877,7 +883,8 @@ public abstract class BaseCppTest {
|
|||
+ "<createParser>"
|
||||
+ "\n"
|
||||
+ " Ref\\<tree::ParseTree> tree = parser.<parserStartRuleName>;\n"
|
||||
+ " ParseTreeWalker.DEFAULT.walk(TreeShapeListener(), tree);\n"
|
||||
+ " Ref\\<TreeShapeListener> listener(new TreeShapeListener());\n"
|
||||
+ " tree::ParseTreeWalker::DEFAULT->walk(listener, tree);\n"
|
||||
+ "\n"
|
||||
+ " return 0;\n"
|
||||
+ "}\n"
|
||||
|
|
|
@ -103,9 +103,13 @@ using namespace org::antlr::v4::runtime;
|
|||
|
||||
<if (file.genPackage)>namespace <file.genPackage> {<endif>
|
||||
|
||||
// TODO(dsisson): See if the following two lines are unnecessary.
|
||||
template \<typename T>
|
||||
class <file.parser.name>Visitor;
|
||||
|
||||
template \<typename T>
|
||||
class <file.grammarName>Visitor;
|
||||
|
||||
<parser>
|
||||
|
||||
<if (file.genPackage)>
|
||||
|
|
Loading…
Reference in New Issue