public bool BuildCode(Grammar grammar, TinyPG.Compiler.Compiler compiler) { this.output.AppendLine("Building code..."); compiler.Compile(grammar); if (!compiler.IsCompiled) { foreach (string err in compiler.Errors) this.output.AppendLine(err); this.output.AppendLine("Compilation contains errors, could not compile."); } new GeneratedFilesWriter(grammar).Generate(false); return compiler.IsCompiled; }
/// <summary> /// a context switch is raised when the caret of the editor moves from one section to another. /// the sections are defined by the highlighter parser. E.g. if the caret moves from the COMMENTBLOCK to /// a CODEBLOCK token, the contextswitch is raised. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void TextHighlighter_SwitchContext(object sender, TinyPG.Highlighter.ContextSwitchEventArgs e) { if (e.NewContext.Token.Type == TinyPG.Highlighter.TokenType.DOTNET_COMMENTBLOCK || e.NewContext.Token.Type == TinyPG.Highlighter.TokenType.DOTNET_COMMENTLINE || e.NewContext.Token.Type == TinyPG.Highlighter.TokenType.DOTNET_STRING || e.NewContext.Token.Type == TinyPG.Highlighter.TokenType.GRAMMARSTRING || e.NewContext.Token.Type == TinyPG.Highlighter.TokenType.DIRECTIVESTRING || e.NewContext.Token.Type == TinyPG.Highlighter.TokenType.GRAMMARCOMMENTBLOCK || e.NewContext.Token.Type == TinyPG.Highlighter.TokenType.GRAMMARCOMMENTLINE) { codecomplete.Enabled = false; // disable autocompletion if user is editing in any of these blocks directivecomplete.Enabled = false; } else if (e.NewContext.Parent.Token.Type == TinyPG.Highlighter.TokenType.GrammarBlock) { directivecomplete.Enabled = false; codecomplete.Enabled = true; //allow autocompletion } else if (e.NewContext.Parent.Token.Type == TinyPG.Highlighter.TokenType.DirectiveBlock) { codecomplete.Enabled = false; directivecomplete.Enabled = true; //allow directives autocompletion } else { codecomplete.Enabled = false; directivecomplete.Enabled = false; } }