public static IEnumerable <Expression> GetExpression(string input) { var node = new ExpParser(new StringReader(input.TrailingNewline())).Parse(); var extractor = new ExprExtractor(); extractor.Analyze(node); // ExitFacts called backwards to line order because of recursive definition extractor.expressions.Reverse(); return(extractor.expressions); }
static void Main(string[] args) { var input = @"1 1+2 1 + 2 = 3 1+2=3 |123=a"; if (args.Length == 1) { input = File.ReadAllText(args[0]); } var expressions = ExprExtractor.GetExpression(input); Console.WriteLine(string.Join(Environment.NewLine + Environment.NewLine, expressions)); }