protected void OnCompileError(CompilerErrorEventArgs e) { _compileErrors += 1; if (CompileError != null) { CompileError(this, e); } else { throw new Exception(string.Format( "Compile Error: {0}", e.Message )); } }
/// <summary> /// Compiles a script /// </summary> public void Compile(TextReader tr) { Compiler c = new Compiler(tr); c.Error += new CompilerErrorEventHandler(Compile_Error); c.Compile(this); if (_compileErrors < 1) { _engine = new InferenceEngine( c.KnowledgeBase, c.RuleBase ); _hasCompiledEngine = true; } else { CompilerErrorEventArgs e = new CompilerErrorEventArgs(string.Format( "{0} error{1} found during compilation", _compileErrors, _compileErrors > 1 ? "s were" : " was" )); Compile_Error(this, e); } }
private void scriptHostCompilerErrorEvent(object sender, CompilerErrorEventArgs e) { System.Console.WriteLine(e.LineText); System.String message = System.String.Format("Error on line {0}:\t{1}\n", e.Line, e.Description); System.Console.WriteLine(message); }
/// <summary> /// The compiler error handler. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void CompilerErrorHandler(object sender, CompilerErrorEventArgs e) { this.logWriter.Write(e.Message); }
static void MyEngine_CompileError(object sender, CompilerErrorEventArgs e) { Console.WriteLine(e.Message); }
public static Diagnostic ToDiagnostic(this CompilerErrorEventArgs e) { return(new Diagnostic(DiagnosticLevel.Error, e.Message, new Range())); }
private void Compile_Error(object sender, CompilerErrorEventArgs e) { OnCompileError(e); }