public IType[] InterpretLines(Global environment, string input) { if (input == null) { return new IType[] { } } ; try { AntlrInputStream inputStream = new AntlrInputStream(input); FAILangLexer lexer = new FAILangLexer(inputStream); CommonTokenStream commonTokenStream = new CommonTokenStream(lexer); FAILangParser parser = new FAILangParser(commonTokenStream); parser.ErrorHandler = new BailErrorStrategy(); FAILangParser.CompileUnitContext expressionContext = parser.compileUnit(); FAILangVisitor visitor = new FAILangVisitor(environment); return(visitor.VisitCompileUnit(expressionContext).Select(x => environment.Evaluate(x)).ToArray()); } catch (Antlr4.Runtime.Misc.ParseCanceledException) { return(new IType[] { new Error("ParseError", "The input failed to parse.") }); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } return(new IType[] { }); } }
public new IType[] VisitCompileUnit([NotNull] FAILangParser.CompileUnitContext context) { return(VisitEarlyCalls(context.earlyCalls()).Concat(VisitCalls(context.calls())).ToArray()); }