Exemplo n.º 1
0
        private void btnParseQuery_Click(object sender, EventArgs e)
        {
            string inputString = txtSqlQuery.Text;
            var    input       = new ANTLRStringStream(inputString);
            var    lexer       = new EntityLexer(input);
            var    tokens      = new CommonTokenStream(lexer);
            var    parser      = new EntityParser(tokens);
            var    result      = parser.prog();
            var    tree        = result.Tree;

            txtParseStringTree.Text = tree.ToStringTree();
            var treeNodeDrawable = new ASTreeNode(tree);

            if (pictureBox1.Image != null)
            {
                pictureBox1.Image.Dispose();
                pictureBox1.Image = null;
            }
            Image image = new VisualAST(treeNodeDrawable).Draw();

            pictureBox1.Image = image;
        }