public bool LoadAndCompile(string code, string fileNameHint = null) { Stopwatch watch = Stopwatch.StartNew(); Reinit(); Host.InitRun(this); var comp = BasicCompiler.Parse(code, fileNameHint); this.CompilerErrors = comp.Errors; this.program = comp.Program; this.lines = program.Lines; this.data = program.Data; if (CompilerErrors.Count == 0) { Link(); } if (CompilerErrors.Count > 0) { comp.DumpErrors((s) => Trace.WriteLine(s)); return(false); } watch.Stop(); if (WriteCompileRunMessage) { printer.WriteMessage($"=== {lines.Length} lines compiled into {program.CalcNodeCount():###,##0} nodes in {watch.ElapsedMilliseconds} ms ==="); } return(true); }
public static BasicCompiler Parse(string code, string fileNameHint = null) { if (code.Length == 0 || code[code.Length - 1] != '\n') { code += "\n"; } var comp = new BasicCompiler() { code = code, fileName = fileNameHint, }; comp.Run(); comp.Program.CheckProgram(); return(comp); }