//build parser with a defined file public Parser() { if (ParserGenerate.closures.Count == 0) { ParserGenerate.GenerateParser(); StrType.BuildMapping(); } this.Goto = ParserGenerate.Goto; this.Action = ParserGenerate.Action; }
public static void Main(string[] argv) { bool Dflag = false; bool Kflag = false; bool Lflag = false; bool Cflag = false; int argc = argv.Length; int j; for (j = 0; argc > 0 && argv[j][0] == '-'; j++, argc--) { switch (argv[j][1]) { case 'D': Dflag = true; Kflag = true; break; // showParser case 'K': Kflag = true; break; // keep going case 'L': Lflag = true; break; // skip LALR phase case 'C': Cflag = true; break; // discard the concrete syntax } } ErrorHandler erh = new ErrorHandler(!Kflag); // by default reduce/reduce errors abort the parser generator ParserGenerate parser = new ParserGenerate(erh); parser.m_showParser = Dflag; parser.m_lalrParser = !Lflag; parser.m_concrete = !Cflag; if (argc == 1) { parser.Create(argv[j]); } else { parser.Create("test.parser"); } if (erh.counter == 0) { Console.WriteLine("ParserGenerate completed successfully"); } else { Console.WriteLine("Parser error count=" + erh.counter); } }
public static void Main(string[] argv) { bool Dflag = false; bool Kflag = false; bool Lflag = false; bool Cflag = false; int argc = argv.Length; int j; for (j = 0; argc>0 && argv[j][0]=='-'; j++,argc--) switch(argv[j][1]) { case 'D': Dflag = true; Kflag = true; break; // showParser case 'K': Kflag = true; break; // keep going case 'L': Lflag = true; break; // skip LALR phase case 'C': Cflag = true; break; // discard the concrete syntax } ErrorHandler erh = new ErrorHandler(!Kflag); // by default reduce/reduce errors abort the parser generator ParserGenerate parser = new ParserGenerate(erh); parser.m_showParser = Dflag; parser.m_lalrParser = !Lflag; parser.m_concrete = !Cflag; if (argc==1) parser.Create(argv[j]); else parser.Create("test.parser"); if (erh.counter==0) Console.WriteLine("ParserGenerate completed successfully"); else Console.WriteLine("Parser error count="+erh.counter); }