Пример #1
0
        private static void Process(Parser parser, string line)
        {
            List <Token> tokens       = parser.Lexer.Tokenize(Plaintext.Line(line)).ToList();
            string       tokensReport = string.Join(" ", tokens.Select(x => $"{x}"));

            Console.WriteLine();
            Console.WriteLine($"Tokens: {tokensReport}");

            ParsingResult result = parser.Parse(line);

            Console.WriteLine();
            Console.WriteLine($"Syntax tree:{Environment.NewLine}{result}");

            Console.WriteLine();
            Console.WriteLine($"{line} = {(result.IsSuccess ? result.Compile(Calculator) : result.ErrorMessage)}");
            Console.WriteLine(new string('-', 50));
        }
Пример #2
0
 public ParsingResult Parse(string input) =>
 this.Parse(this.Lexer.Tokenize(Plaintext.Line(input)));