예제 #1
0
파일: Program.cs 프로젝트: ALyman/NParse
        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
        }
예제 #2
0
 public Parser(SimpleGrammar grammar, bool verbose = false)
 {
     _verbose = verbose;
     _grammar = grammar;
 }