Пример #1
0
    // *** end of global SYN and SEM declarations from ATG ***



    private static void NT_BinaryTree()
    {
        for (;;)
        {
            switch (Syn.Interpret())
            {
            case 0:
                return;

            case 1: // SEM
                tree = new BTree();

                break;

            case 2:
                NT_SubTree(ref tree);
                break;

            case 3: // SEM
                Console.WriteLine("Tree:");
                Console.Write("(");
                if (tree.HasBeenAssigned())
                {
                    Console.Write(tree);
                }
                Console.WriteLine(")");

                break;
            } // switch
        }     // for
    }         // NT_BinaryTree
Пример #2
0
    }         // NT_BinaryTree

    private static void NT_SubTree(ref BTree t)
    {
        BTree left  = new BTree();
        BTree right = new BTree();

        for (;;)
        {
            switch (Syn.Interpret())
            {
            case 0:
                return;

            case 1:
                NT_SubTree(ref left);
                break;

            case 2:
                Lex.GETnumberAttr(out num);
                break;

            case 3: // SEM
                t.Value = num;
                t.Left  = left;
                t.Right = right;

                break;

            case 4:
                NT_SubTree(ref right);
                break;
            } // switch
        }     // for
    }         // NT_SubTree
Пример #3
0
    public static void StartSem()
    {
        //-----------------------------------|----------------------------------------
        for (;;)
        {
            switch (Syn.Interpret())
            {
            case 0:
                return;

            case 1:
                NT_BinaryTree();
                break;
            } // switch
        }     // for
    }         // StartSem