private void Parse_Click(object sender, RoutedEventArgs e) { AntlrInputStream stream = new AntlrInputStream(this._tbInput.Text); QSLexer lex = new QSLexer(stream); CommonTokenStream tokens = new CommonTokenStream(lex); QSParser parser = new QSParser(tokens); IParseTree tree = parser.form(); MyListener listener = new MyListener(parser); ParseTreeWalker walker = new ParseTreeWalker(); walker.Walk(listener, tree); IVisitor<bool> check = TypeChecker.StartVisit(listener.Root); if (check.Result) { GUIBuilder builder = GUIBuilder.BuildGUI(listener.Root); System.Windows.Window wind = new Window(); wind.Width = 500; wind.Content = builder.Result; wind.Show(); } else this._tbOutput.Text = ((TypeChecker)check).Output.ToString(); }
private Form init_parse(string text) { AntlrInputStream stream = new AntlrInputStream(text); QSLexer lex = new QSLexer(stream); CommonTokenStream tokens = new CommonTokenStream(lex); QSParser parser = new QSParser(tokens); IParseTree tree = parser.form(); MyListener listener = new MyListener(parser); ParseTreeWalker walker = new ParseTreeWalker(); walker.Walk(listener, tree); return listener.Root; }