示例#1
0
        static void Main(string[] args)
        {
            var parser = new SimpleParser();

            do
            {
                Console.WriteLine("Input:");
                var input  = Console.ReadLine();
                var result = parser.Parse(input);
                Console.WriteLine($"Result: {result}\n");
            } while (true);
        }
示例#2
0
        private Node<string> CallParse()
        {
            if (txtInput.Text.Length == 0)
            {
                AddTextLineToOutput("No input specified", Color.Red);
                return null;
            }

            var parser = new SimpleParser(lexer);

            try
            {
                parser.Parse(txtInput.Text);
                RenderTree(parser.SyntaxTree);
                AddTextLineToOutput("Parsing succeeded", Color.DarkGreen);
                return parser.SyntaxTree;
            }
            catch (ParserException ex)
            {
                AddTextLineToOutput(ex.Message, Color.Red);
                return null;
            }
        }