コード例 #1
0
ファイル: irParser.cs プロジェクト: robin5/DemiTasse
        /* throws ParseException */
        public static IrStmt STMT()
        {
            IrToken t;
            IrCJump.OP n;
            IrStmt s;
            IrExp e1 = null, e2, e3;
            IrExpList el=new IrExpList();

            jj_consume_token(RegExpId.kw44);
            switch ((jj_ntk == RegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk)
            {
                case RegExpId.kwMOVE:

                    jj_consume_token(RegExpId.kwMOVE);
                    e1 = EXP();
                    e2 = EXP();
                    s = new IrMove(e1,e2);
                    break;

                case RegExpId.kwJUMP:

                    jj_consume_token(RegExpId.kwJUMP);
                    e1 = EXP();
                    s = new IrJump((IrName)e1);
                    break;

                case RegExpId.kwCJUMP:

                    jj_consume_token(RegExpId.kwCJUMP);
                    n = relopCode();
                    e1 = EXP();
                    e2 = EXP();
                    e3 = EXP();
                    s = new IrCJump(n,e1,e2,(IrName)e3);
                    break;

                case RegExpId.kwLABEL:

                    jj_consume_token(RegExpId.kwLABEL);
                    t = jj_consume_token(RegExpId.ID);
                    s = new IrLabel(t.image);
                    break;

                case RegExpId.kwCALLST:

                    jj_consume_token(RegExpId.kwCALLST);
                    e1 = EXP();
                    jj_consume_token(RegExpId.kw32);

                    RegExpId tmp2;
                    //label_3:
                    while (true)
                    {
                        tmp2 = (jj_ntk == RegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk;
                        switch (tmp2)
                        {
                            case RegExpId.kw32:

                                break;

                            default:
                                jj_la1[3] = jj_gen;
                                goto label_3a; // break label_3;
                        }
                        e2 = EXP();
                        el.add(e2);
                    }

                    label_3a:

                    jj_consume_token(RegExpId.kw35);
                    s = new IrCallst((IrName)e1,el);
                    break;

                case RegExpId.kwRETURN:

                    jj_consume_token(RegExpId.kwRETURN);
                    switch ((jj_ntk == RegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk)
                    {
                        case RegExpId.kw32:
                            e1 = EXP();
                            break;
                        default:
                            jj_la1[4] = jj_gen;
                            break;
                    }
                    s = new IrReturn(e1);
                    break;

                    default:
                        jj_la1[5] = jj_gen;
                        jj_consume_token(RegExpId.UNDEFINED);
                        throw new IrParseException();
                }

            jj_consume_token(RegExpId.kw45);
                return s;

            //throw new Error("Missing return statement in function");
            //return s;
        }
コード例 #2
0
ファイル: InterpVisitor.cs プロジェクト: robin5/DemiTasse
 public int visit(IrLabel t)
 {
     return STATUS_DEFAULT;
 }
コード例 #3
0
ファイル: Canon.cs プロジェクト: robin5/DemiTasse
 public IrStmt visit(IrLabel t)
 {
     return t;
 }