void Parser() { SimpleParser parser = new SimpleParser(); String script = null; ASTNode tree = null; try { script = "2;int age =3*(45+2); age= 20*2+2; age+10*2;"; Console.WriteLine("解析:" + script); tree = parser.parse(script); parser.DumpAST(tree, ""); } catch (Exception e) { Console.WriteLine(e.Message); } //测试异常语法 try { script = "2+3+;"; Console.WriteLine("解析:" + script); tree = parser.parse(script); parser.DumpAST(tree, ""); } catch (Exception e) { Console.WriteLine(e.Message); } //测试异常语法 try { script = "2+3*;"; Console.WriteLine("解析:" + script); tree = parser.parse(script); parser.DumpAST(tree, ""); } catch (Exception e) { Console.WriteLine(e.Message); } }