• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 import org.antlr.runtime.*;
2 import org.antlr.runtime.tree.*;
3 
4 public class Main {
main(String[] args)5 	public static void main(String[] args) throws Exception {
6 		CharStream input = new ANTLRFileStream(args[0]);
7 		LangLexer lex = new LangLexer(input);
8 		CommonTokenStream tokens = new CommonTokenStream(lex);
9 		LangParser parser = new LangParser(tokens);
10 		//LangParser.decl_return r = parser.decl();
11 		LangParser.start_return r = parser.start();
12 		System.out.println("tree: "+((Tree)r.tree).toStringTree());
13 		CommonTree r0 = ((CommonTree)r.tree);
14 
15 		CommonTreeNodeStream nodes = new CommonTreeNodeStream(r0);
16 		nodes.setTokenStream(tokens);
17 		LangDumpDecl walker = new LangDumpDecl(nodes);
18 		walker.decl();
19 	}
20 }
21