Esempio n. 1
0
 /// <summary>
 /// Converts the passed in string with UBB tokens to XML.
 /// </summary>
 /// <param name="toConvert">The string to convert.</param>
 /// <returns>An XmlDocument object with the string with UBB tokens in Xml format. This XmlDocument is now usable to convert the string to
 /// for example HTML by using a Xslt stylesheet.</returns>
 public static XmlDocument ConvertToXml(string toConvert)
 {
     Parser textParser = new Parser(toConvert);
     List<NonTerminal> parseTree = textParser.StartParseProcess();
     Interpreter tokenInterpreter = new Interpreter(parseTree);
     return tokenInterpreter.Interpret();
 }
Esempio n. 2
0
        private void _startParseButton_Click(object sender, EventArgs e)
        {
            if(_textToParseTextBox.Text.Length <= 0)
            {
                return;
            }

            _logTextBox.Text = string.Empty;
            LogLine("Parsing started.");

            Parser textParser = new Parser(_textToParseTextBox.Text);
            List<NonTerminal> parseTree = textParser.StartParseProcess();
            Interpreter tokenInterpreter = new Interpreter(parseTree);
            XmlDocument result = tokenInterpreter.Interpret();

            LogLine("Parsing ended.");

            string outputfilename = Path.Combine(Environment.CurrentDirectory, _destinationFileTextBox.Text);
            StreamWriter writer = new StreamWriter(outputfilename, false);
            writer.Write(result.OuterXml);
            writer.Close();

            LogLine("Output written as XML to " + outputfilename);

            ViewParseTree(parseTree);
        }