private static void ProcessAddition(Parser parser, string line) { ParsingResult result = parser.Parse(line); Console.WriteLine(result.IsSuccess ? $"{result.Compile(new FullAdditiveParenthesizer())} = {result.Compile(new AdditiveCompiler())}" : $"Not an additive expression: {result.ErrorMessage}"); }
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)); }