Exemplo n.º 1
0
        public void AddClassVar(AstId vid, DemiTasse.ast.AstType type, AstExp e)
        {
            if(GetClassVar(vid) != null)
                throw new SymbolException("ClassVar " + vid.s + " already defined");

            _vars.Add(new VarRec(vid, type, VarRec.CLASS, _vars.Count+1, e));
        }
Exemplo n.º 2
0
 public VarRec(AstId id, AstType type, int kind, int idx)
 {
     _id = id;
     _type = type;
     _kind = kind;
     _idx = idx;
     _init = null;
 }
Exemplo n.º 3
0
 public VarRec(AstId id, AstType type, int kind, int idx, AstExp e)
 {
     _id = id;
     _type = type;
     _kind = kind;
     _idx = idx;
     _init = e;
 }
Exemplo n.º 4
0
 public static void Append(AstExp e)
 {
     if (e == null)
         _astData.Append("(NullExp) ");
     else
         e.GenerateAstData();
 }
Exemplo n.º 5
0
 public AstCall(AstExp e, AstId mi, AstExpList el)
 {
     obj = e; mid = mi; args = el;
 }
Exemplo n.º 6
0
 public AstIf(AstExp ae, AstStmt as1, AstStmt as2)
 {
     e = ae; s1 = as1; s2 = as2;
 }
Exemplo n.º 7
0
 public void Add(AstExp n)
 {
     base.Add(n);
 }
Exemplo n.º 8
0
 public AstWhile(AstExp ae, AstStmt _as)
 {
     e=ae; s=_as;
 }
Exemplo n.º 9
0
 /* throws ParseException */
 // --------------------------------------------------------------------------
 // FieldId  ->  Id
 // --------------------------------------------------------------------------
 /* final */
 public static AstExp FieldId(AstExp e)
 {
     AstId id;
     id = Id();
     return e == null ? (AstExp)id : (AstExp)(new AstField(e, id));
 }
Exemplo n.º 10
0
        /* throws ParseException */
        // --------------------------------------------------------------------------
        // Binop  ->  <ADD> | <SUB> | <MUL> | <DIV> | <AND> | <OR>
        // --------------------------------------------------------------------------
        /* final */
        public static AstBinop Binop(AstExp e1, AstExp e2)
        {
            ast.AstBinop.OP op;
            switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk)
            {
                case MpRegExpId.ADD:
                    jj_consume_token(MpRegExpId.ADD);
                    op = ast.AstBinop.OP.ADD;
                    break;

                case MpRegExpId.SUB:
                    jj_consume_token(MpRegExpId.SUB);
                    op = ast.AstBinop.OP.SUB;
                    break;

                case MpRegExpId.MUL:
                    jj_consume_token(MpRegExpId.MUL);
                    op = ast.AstBinop.OP.MUL;
                    break;

                case MpRegExpId.DIV:
                    jj_consume_token(MpRegExpId.DIV);
                    op = ast.AstBinop.OP.DIV;
                    break;

                case MpRegExpId.AND:
                    jj_consume_token(MpRegExpId.AND);
                    op = ast.AstBinop.OP.AND;
                    break;

                case MpRegExpId.OR:
                    jj_consume_token(MpRegExpId.OR);
                    op = ast.AstBinop.OP.OR;
                    return new AstBinop( op, e1, e2 );

                default:
                    jj_la1[44] = jj_gen;
                    jj_consume_token(MpRegExpId.UNDEFINED);
                    throw new MiniParseException();
            }
            throw new Error("Missing return statement in function");
        }
Exemplo n.º 11
0
 /* throws ParseException */
 // --------------------------------------------------------------------------
 // ArrayElm  ->  "[" Expr "]"
 // --------------------------------------------------------------------------
 /* final */
 public static AstExp ArrayElm(AstExp pid)
 {
     AstExp e;
     jj_consume_token(MpRegExpId.LBRACKET);
     e = Expr();
     jj_consume_token(MpRegExpId.RBRACKET);
     return new AstArrayElm( pid, e );
 }
Exemplo n.º 12
0
        /* throws ParseException */
        // ----------------------------------------------------------------
        // ArithTail  ->  [ ( "+" | "-" ) Term ArithTail ]
        // ----------------------------------------------------------------
        /* final */
        public static AstExp ArithTail(AstExp e0)
        {
            AstExp e1 = null;
            AstExp e2 = null;
            DemiTasse.ast.AstBinop.OP op;

            switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk)
            {
                case MpRegExpId.ADD:

                    switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk)
                    {
                        case MpRegExpId.ADD:
                            jj_consume_token(MpRegExpId.ADD);
                            op = DemiTasse.ast.AstBinop.OP.ADD;
                            break;
                        case MpRegExpId.SUB:
                            jj_consume_token(MpRegExpId.SUB);
                            op = DemiTasse.ast.AstBinop.OP.SUB;
                            break;
                        default:
                            jj_la1[30] = jj_gen;
                            jj_consume_token(MpRegExpId.UNDEFINED);
                            throw new MiniParseException();
                    }
                    e1 = Term();
                    e1 = new AstBinop(op, e0, e1);
                    e2 = ArithTail(e1);
                    break;

                case MpRegExpId.SUB:

                    switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk)
                    {
                        case MpRegExpId.ADD:
                            jj_consume_token(MpRegExpId.ADD);
                            op = DemiTasse.ast.AstBinop.OP.ADD;
                            break;
                        case MpRegExpId.SUB:
                            jj_consume_token(MpRegExpId.SUB);
                            op = DemiTasse.ast.AstBinop.OP.SUB;
                            break;
                        default:
                            jj_la1[30] = jj_gen;
                            jj_consume_token(MpRegExpId.UNDEFINED);
                            throw new MiniParseException();
                    }
                    e1 = Term();
                    e1 = new AstBinop( op, e0, e1 );
                    e2 = ArithTail(e1);
                    break;

                default:
                jj_la1[31] = jj_gen;
                break;
            }
            return e2 == null ? e1 : e2;
        }
Exemplo n.º 13
0
        /* throws ParseException */
        // ----------------------------------------------------------------
        // TermTail  -> ("*" | "/" ) Factor TermTail
        // ----------------------------------------------------------------
        /* final */
        public static AstExp TermTail(AstExp e0)
        {
            AstExp e1 = null;
            AstExp e2 = null;
            DemiTasse.ast.AstBinop.OP op;

            switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk)
            {
                case MpRegExpId.MUL:
                    switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk)
                    {
                        case MpRegExpId.MUL:
                            jj_consume_token(MpRegExpId.MUL);
                            op = DemiTasse.ast.AstBinop.OP.MUL;
                            break;

                        case MpRegExpId.DIV:
                            jj_consume_token(MpRegExpId.DIV);
                            op = DemiTasse.ast.AstBinop.OP.DIV;
                            break;

                        default:
                            jj_la1[32] = jj_gen;
                            jj_consume_token(MpRegExpId.UNDEFINED);
                            throw new MiniParseException();
                    }
                    e1 = Factor();
                    e1 = new AstBinop(op, e0, e1);
                    e2 = TermTail(e1);
                    break;

                case MpRegExpId.DIV:
                    switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk)
                    {
                        case MpRegExpId.MUL:
                            jj_consume_token(MpRegExpId.MUL);
                            op = DemiTasse.ast.AstBinop.OP.MUL;
                            break;

                        case MpRegExpId.DIV:
                            jj_consume_token(MpRegExpId.DIV);
                            op = DemiTasse.ast.AstBinop.OP.DIV;
                            break;

                        default:
                            jj_la1[32] = jj_gen;
                            jj_consume_token(MpRegExpId.UNDEFINED);
                            throw new MiniParseException();
                    }
                    e1 = Factor();
                    e1 = new AstBinop( op, e0, e1 );
                    e2 = TermTail(e1);
                    break;

                default:
                    jj_la1[33] = jj_gen;
                    break;
            }
            return e2 == null ? e1 : e2;
        }
Exemplo n.º 14
0
        /* throws ParseException */
        // ----------------------------------------------------------------
        // AndTail  ->  [ "&&" RelExpr AndTail ]
        // ----------------------------------------------------------------
        /* final */
        public static AstExp AndTail(AstExp e0)
        {
            AstExp e1 = null;
            AstExp e2 = null;

            switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk)
            {
                case MpRegExpId.AND:

                    jj_consume_token(MpRegExpId.AND);
                    e1 = RelExpr();
                    e1 = new AstBinop(DemiTasse.ast.AstBinop.OP.AND, e0, e1);
                    e2 = AndTail(e1);
                    break;

                default:

                    jj_la1[28] = jj_gen;
                    break;
            }
            return e2 == null ? e1 : e2;
        }
Exemplo n.º 15
0
 public AstArrayElm(AstExp e1, AstExp e2)
 {
     _array = e1;
     _idx = e2;
 }
Exemplo n.º 16
0
 public AstCallStmt(AstExp astExp, AstId astId, AstExpList astExpList)
 {
     _obj = astExp;
     _mid = astId;
     _el = astExpList;
 }
Exemplo n.º 17
0
 public AstPrint(AstExp ae)
 {
     e = ae;
 }
Exemplo n.º 18
0
 public AstField(AstExp e, AstId v)
 {
     obj = e; var = v;
 }
Exemplo n.º 19
0
 public AstUnop(OP o, AstExp ae)
 {
     op=o; e=ae;
 }
Exemplo n.º 20
0
 public AstArrayLen(AstExp e)
 {
     array = e;
 }
Exemplo n.º 21
0
 public AstAssign(AstExp e1, AstExp e2)
 {
     lhs = e1; rhs = e2;
 }
Exemplo n.º 22
0
 public AstVarDecl(AstType at, AstId i, AstExp ae)
 {
     t = at;
     var = i;
     e = ae;
 }
Exemplo n.º 23
0
 public AstRelop(OP o, AstExp ae1, AstExp ae2)
 {
     op = o; e1 = ae1; e2 = ae2;
 }
Exemplo n.º 24
0
 public AstReturn(AstExp ae)
 {
     e = ae;
 }