private void buttonCompile_Click(object sender, EventArgs e) { GeneratorLexer lexer = new GeneratorLexer(false); try { using (StringReader reader = new StringReader(textScript.Text)) { _generator = new ScriptParserGenerator(lexer.ParseText(reader)); } } catch (Exception ex) { setText(textMessage, ex.Message); setText(textParser, ""); setText(textUtility, ""); setText(textTemplates, ""); return; } try { listSettings.Items.Clear(); foreach (var pair in _generator.GetSettingsContent()) { ListViewItem item = new ListViewItem(new string[] { pair.Key, pair.Value }); listSettings.Items.Add(item); } StringWriter outputParser = new StringWriter(); StringWriter outputUtility = new StringWriter(); StringWriter outputTemplate = new StringWriter(); StringWriter message = new StringWriter(); foreach (string line in _generator.GetHeader()) { outputParser.WriteLine(line); } foreach (string line in _generator.GetBaseOutputClassHeader()) { outputParser.WriteLine(line); } foreach (string line in _generator.GetAbstractReturnMethods()) { outputParser.WriteLine(line); } foreach (var def in _generator.Source.Defs) { def.WriteParseCode(outputParser, _generator); outputParser.WriteLine(); } foreach (string line in _generator.GetOutputClassFooter()) { outputParser.WriteLine(line); } foreach (string line in _generator.GetFooter()) { outputParser.WriteLine(line); } foreach (string line in _generator.GetHeader()) { outputUtility.WriteLine(line); } foreach (string line in _generator.GetUtility()) { outputUtility.WriteLine(line); } foreach (string line in _generator.GetFooter()) { outputUtility.WriteLine(line); } foreach (string line in _generator.GetHeader()) { outputTemplate.WriteLine(line); } foreach (string line in _generator.GetReturnClassTemplates()) { outputTemplate.WriteLine(line); } foreach (string line in _generator.GetOutputClassHeader()) { outputTemplate.WriteLine(line); } foreach (string line in _generator.GetNotImplementedReturnMethods()) { outputTemplate.WriteLine(line); } foreach (string line in _generator.GetOutputClassFooter()) { outputTemplate.WriteLine(line); } foreach (string line in _generator.GetFooter()) { outputTemplate.WriteLine(line); } message.Write(_generator.ReadWarningMessage()); message.WriteLine("Done."); setText(textMessage, message.ToString()); setText(textParser, outputParser.ToString()); setText(textUtility, outputUtility.ToString()); setText(textTemplates, outputTemplate.ToString()); } catch (NotSupportedException ex) { setText(textStatus, ex.Message); textMessage.AppendText(ex.StackTrace); } }