public Expression[] Compile(string s, VariableContext variableContext) { ExpressionCompiler compiler = CreateCompiler(); Lexicon[] lexicons; try { lexicons = new Lexiconizer(LexiconizationRuleTable.GetRule(compiler)).Lexiconize(s); } catch (LexiconizationException e) { throw new CompileException(e.Message); } CompileErrorProvider errorProvider = new CompileErrorProvider(s, lexicons, compiler.PerformTypeChecking); Expression[] roots = compiler.Compile(s, lexicons, errorProvider); if (variableContext == null) { variableContext = new VariableContext(); } foreach (Expression root in roots) { TypeCheckingContext context = new TypeCheckingContext(); OnCreateTypeCheckingContext(context); context.CreateVariableOnAssign = compiler.CreateVariableOnAssing(); context.VariableContext = variableContext; context.LambdaContext = new LambdaContext(); context.ErrorProvider = errorProvider; CreateTypeChecker().PerformTypeChecking(root, context); } return(roots); }
public TypeCheckingContext CreateTypeCheckingContext(VariableContext variableContext) { ExpressionCompiler compiler = CreateCompiler(); TypeCheckingContext context = new TypeCheckingContext(); OnCreateTypeCheckingContext(context); CompileErrorProvider errorProvider = new CompileErrorProvider(null, null, compiler.PerformTypeChecking); if (variableContext == null) { variableContext = new VariableContext(); } context.CreateVariableOnAssign = compiler.CreateVariableOnAssing(); context.VariableContext = variableContext; context.LambdaContext = new LambdaContext(); context.ErrorProvider = errorProvider; return(context); }