public static void Main(string[] args) { GrammarBase<Expression> grammar = new SimpleGrammar(); #if INTERACTIVE do { Console.ForegroundColor = ConsoleColor.White; Console.Write("> "); Console.ForegroundColor = ConsoleColor.Yellow; var input = Console.ReadLine(); if (input == "exit") { break; } var parser = grammar.CreateParser(); ////parser.Options.Trace = true; var result = parser.Parse(new StringReader(input)); ExecuteExpression(result.Value); } while (true); #else var result = grammar .CreateParser() .Parse(new StringReader("1/x")); ExecuteExpression(result.Value); #endif }
public Parser(SimpleGrammar grammar, bool verbose = false) { _verbose = verbose; _grammar = grammar; }