1 using System;
2 using System.IO;
3 using antlr;
4 using antlr.collections;
5 
6 class HeteroMain {
Main(string[] args)7 	public static void Main(string[] args) {
8 		new INTNode();
9 		try {
10 			CalcLexer lexer = new CalcLexer(new ByteBuffer(Console.OpenStandardInput()));
11 			CalcParser parser = new CalcParser(lexer);
12 			// Parse the input expression
13 			parser.expr();
14 			CalcAST t = (CalcAST)parser.getAST();
15 
16 			// Print the resulting tree out in LISP notation
17 			Console.Out.WriteLine(t.ToStringTree());
18 
19 			// XML serialize the tree, showing
20 			// different physical node class types
21 			TextWriter w = Console.Out;
22 			t.xmlSerialize(w);
23 			w.Write("\n");
24 			w.Flush();
25 
26 			// Compute value and return
27 			int r = t.Value();
28 			Console.Out.WriteLine("value is "+r);
29 		} catch(Exception e) {
30 			Console.Error.WriteLine("exception: "+e);
31 			Console.Error.WriteLine(e.StackTrace);
32 		}
33 	}
34 }
35