...
Code Block | ||||
---|---|---|---|---|
| ||||
public class remoteAstDebugging
{
public static void main(String[] args) throws Exception {
CommonTokenStream tokens = new CommonTokenStream();
{
ANTLRInputStream input = new ANTLRInputStream( System.in );
sampleLexer lexer = new sampleLexer(input);
tokens.setTokenSource(lexer);
}
CommonTreeNodeStream nodes;
{
sampleParser parser = new sampleParser(tokens);
sampleParser.example_return example = parser.example();
CommonTree tree = (CommonTree)example.getTree();
nodes = new CommonTreeNodeStream(tree);
}
{
sampleWalker walker = new sampleWalker(nodes);
// remove these lines if not using templates
FileReader groupFileReader = new FileReader("cpp.stg");
StringTemplateGroup templates = new StringTemplateGroup( groupFileReader );
groupFileReader.close();
walker.setTemplateLib(templates);
sampleWalker.example_return example = walker.example();
System.out.println(example.toString());
}
System.exit(0);
}
}
|
...