public ParseError BuildCache() { foreach (var file in PathsToCache) { HASMSource source = new HASMSource(parrent, new FileInfo(file)); ParseTaskRunner runner = new ParseTaskRunner(source); runner.Run(); if (runner.Status != ParseTaskStatus.Ok) { return(runner.Tasks[runner.FailedTaskIndex].Error); } FileCache.Add(file, new FileCache() { AbsoluteFileName = file, CompiledClasses = source.Assembly == null ? new List <Class>() : source.Assembly.Classes, CompiledDefines = PreprocessorDirective.defines ?? new List <Define>() }); } return(null); }
private void TextBox_TextChangedDelayed(object sender, TextChangedEventArgs e) { TaskRunner.Source = new HASMSource(Parrent.Machine, TextBox.Text, Directory); TaskRunner.Run(); if (TaskRunner.Status == ParseTaskStatus.Failed) { ParseError error = TaskRunner.Tasks[TaskRunner.FailedTaskIndex].Error; try { if (error.FileName.Contains("tmp")) { //Current file if (error.Line != -1) { TextBox.Range.ClearStyle(ErrorStyle); TextBox.Range.SetStyle(ErrorStyle, Regex.Escape(TextBox[error.Line].Text.Trim())); HighlightBaseSyntax(); ErrorString = TextBox[error.Line].Text; } OutputText(error.ToString(Path)); } else { OutputText(error.ToString()); } } catch { } ParseError = error; System.Console.WriteLine(error); return; } OutputText(""); System.Console.WriteLine("Compiled!"); ErrorString = null; ParseError = null; TextBox.Range.ClearStyle(StyleIndex.All); TextBox.Range.SetFoldingMarkers( HASMLib.Parser.SyntaxTokens.Structure.CodeBlock.BlockOpened, HASMLib.Parser.SyntaxTokens.Structure.CodeBlock.BlockClosed); if (TaskRunner.Source.Assembly != null) { var classNames = TaskRunner.Source.Assembly.AllClasses.Select(p => (p.Name, p.AccessModifier)); var functionNames = TaskRunner.Source.Assembly.AllFunctions.Select(p => (p.Name, p.AccessModifier)); var fieldNames = TaskRunner.Source.Assembly.AllFields.Select(p => (p.Name, p.AccessModifier)); Regex classRegex = CreateRegex(classNames.Select(p => p.Name)); Regex functionRegex = CreateRegex(functionNames.Select(p => p.Name)); Regex fieldRegex = CreateRegex(fieldNames.Select(p => p.Name)); TextBox.Range.SetStyle(AssemblyNameStyle, TaskRunner.Source.Assembly.Name); TextBox.Range.SetStyle(ClassNameStyle, classRegex); TextBox.Range.SetStyle(FunctionNameStyle, functionRegex); TextBox.Range.SetStyle(FieldNameStyle, fieldRegex); } HighlightBaseSyntax(); }