Some problems with the C++ target:
- Following code crashes with the deletion of the parse tree
- If I use Ref with the parse tree then the program also crashes when the shared_ptr deletes the ptr.
- Not deleting and not using the Ref obviously leads to memory leaks.
Anybody know how to fix this?
void parse(std::ifstream& stream) {
if (stream.is_open())
{
ANTLRInputStream input(stream);
textworldLexer lexer(&input);
CommonTokenStream tokens(&lexer);
textworldParser parser(&tokens);
tree::ParseTree* tree = parser.world();
Ref<textworldVisitor> visitor(new MyVisitor());
visitor->visit(tree);
delete tree;
getchar();
}
}