Ejemplo n.º 1
0
Archivo: Visitor.cs Proyecto: mkju19/P4
 public abstract void Visit(SwitchStmt n);
Ejemplo n.º 2
0
        void STMT(out AST e)
        {
            AST        logi, n1, n2; List <AST> stm = new List <AST>();
            List <AST> stm2 = new List <AST>(); string id; AST astid; e = null;

            switch (la.kind)
            {
            case 15: {
                Get();
                IFELSTMT(out e);
                break;
            }

            case 16: {
                Get();
                Expect(17);
                LOGI_EXPR(out logi);
                Expect(18);
                BLOCK(out stm);
                e = new WhileStmt(logi, stm);
                break;
            }

            case 19: {
                Get();
                Expect(17);
                n1 = null;
                if (StartOf(1))
                {
                    DECL(out n1);
                }
                else if (la.kind == 3)
                {
                    Get();
                    n1 = new SymReferencing(t.val);
                    Expect(11);
                }
                else
                {
                    SynErr(54);
                }
                LOGI_EXPR(out logi);
                Expect(11);
                Expect(3);
                astid = new SymReferencing(t.val);
                ASSIG(out n2, astid);
                Expect(18);
                BLOCK(out stm);
                e = new ForStmt(n1, logi, n2, stm);
                break;
            }

            case 20: {
                Get();
                Expect(17);
                Expect(3);
                id = t.val;
                Expect(18);
                Expect(10);
                Expect(21);
                Expect(3);
                id = t.val;
                Expect(22);
                BLOCK(out stm2);
                stm.Add(new SwitchCase(id, stm2));
                while (la.kind == 21)
                {
                    Get();
                    Expect(3);
                    id = t.val;
                    Expect(22);
                    BLOCK(out stm2);
                    stm.Add(new SwitchCase(id, stm2));
                }
                Expect(23);
                Expect(22);
                BLOCK(out stm2);
                stm.Add(new SwitchDefault(stm2));
                Expect(13);
                e = new SwitchStmt(id, stm);
                break;
            }

            case 3: {
                IDENTIFIER(out e);
                CALL(e, out e);
                Expect(11);
                break;
            }

            case 43:
            case 44:
            case 45:
            case 46:
            case 47:
            case 48:
            case 49: {
                DECL(out e);
                break;
            }

            default: SynErr(55); break;
            }
        }