public DAEDefinition CompileDAE(string text) { compilerErrors = new List <ErrorMessage>(); parameters = new Dictionary <string, double>(); variables = new Dictionary <string, Variable>(); FunctionTable.Init(); //variables.Add("t", new Variable { Name = "t", InitialValue = 0.0, Initialized = true,VarType = Variable.Type.Algebraic,Count=0 }); AntlrInputStream inputStream = new AntlrInputStream(text); DAEImplicitGrammarLexer eqLexer = new DAEImplicitGrammarLexer(inputStream); eqLexer.RemoveErrorListeners(); ErrorListener <int> lexerListener = new ErrorListener <int>(); eqLexer.AddErrorListener(lexerListener); CommonTokenStream commonTokenStream = new CommonTokenStream(eqLexer); DAEImplicitGrammarParser eqParser = new DAEImplicitGrammarParser(commonTokenStream); ErrorListener <IToken> parserListener = new ErrorListener <IToken>(); eqParser.RemoveErrorListeners(); eqParser.AddErrorListener(parserListener); DAEImplicitGrammarParser.CompileUnitContext eqContext = eqParser.compileUnit(); compilerErrors = lexerListener.getErrors(); if (compilerErrors.Count > 0) { throw new Exception("Lexer Error"); } compilerErrors = parserListener.getErrors(); if (compilerErrors.Count > 0) { throw new Exception("Parser error"); } DAEImplicitGrammarVisitor visitor = new DAEImplicitGrammarVisitor(); ASTNode root = visitor.VisitCompileUnit(eqContext); return(CompileDAE((RootNode)root)); }