Beispiel #1
0
        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();
            }
        }
Beispiel #2
0
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        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);
        }
        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;
 }