Exemplo n.º 1
0
 // IntVal ---
 // int i;
 public IrExp visit(AstIntVal n)
 {
     return new IrConst(n.i);
 }
Exemplo n.º 2
0
 public AstType visit(AstIntVal n)
 {
     return null;
 }
Exemplo n.º 3
0
        /* throws ParseException */
        /* final */
        public static AstExp astExp()
        {
            AstType t;
            AstToken n;
            AstRelop.OP relop;
            AstBinop.OP binop;
            AstUnop.OP unop;
            AstExp e, e1, e2;
            AstExpList el;

            jj_consume_token(AstRegExpId.kw56);
            switch ((jj_ntk == AstRegExpId.UNDEFINED)?jj_ntk_fn():jj_ntk) {
            case AstRegExpId.kwArrayElm:
              jj_consume_token(AstRegExpId.kwArrayElm);
              e1 = astExp();
              e2 = astExp();
                                  e = new AstArrayElm(e1,e2);
              break;
            case AstRegExpId.kwArrayLen:
              jj_consume_token(AstRegExpId.kwArrayLen);
              e1 = astExp();
                                  e = new AstArrayLen(e1);
              break;
            case AstRegExpId.kwBinop:
              jj_consume_token(AstRegExpId.kwBinop);
              binop = binOp();
              e1 = astExp();
              e2 = astExp();
                                  e = new AstBinop(binop,e1,e2);
              break;
            case AstRegExpId.kwBoolVal:
              jj_consume_token(AstRegExpId.kwBoolVal);
              switch ((jj_ntk == AstRegExpId.UNDEFINED)?jj_ntk_fn():jj_ntk) {
              case AstRegExpId.kwTrue:
            jj_consume_token(AstRegExpId.kwTrue);
                                  e = new AstBoolVal(true);
            break;
              case AstRegExpId.kwFalse:
            jj_consume_token(AstRegExpId.kwFalse);
                                  e = new AstBoolVal(false);
            break;
              default:
            jj_la1[12] = jj_gen;
            jj_consume_token(AstRegExpId.UNDEFINED);
            throw new AstParseException();
              }
              break;
            case AstRegExpId.kwCall:
              jj_consume_token(AstRegExpId.kwCall);
              e1 = astExp();
              e2 = astExp();
              el = astExpList();
                                  e = new AstCall(e1,(AstId)e2,el);
              break;
            case AstRegExpId.kwId:
              jj_consume_token(AstRegExpId.kwId);
              n = jj_consume_token(AstRegExpId.ID);
                                  e = new AstId(n.image);
              break;
            case AstRegExpId.kwIntVal:
              jj_consume_token(AstRegExpId.kwIntVal);
              n = jj_consume_token(AstRegExpId.INTVAL);
                                  e = new AstIntVal(int.Parse(n.image));
              break;
            case AstRegExpId.kwField:
              jj_consume_token(AstRegExpId.kwField);
              e1 = astExp();
              e2 = astExp();
                                  e = new AstField(e1,(AstId)e2);
              break;
            case AstRegExpId.kwNewArray:
              jj_consume_token(AstRegExpId.kwNewArray);
              t = astType();
              n = jj_consume_token(AstRegExpId.INTVAL);
              e = new AstNewArray((AstType)t, int.Parse(n.image));
              break;
            case AstRegExpId.kwNewObj:
              jj_consume_token(AstRegExpId.kwNewObj);
              e1 = astExp();
              el = astExpList();
                                  e = new AstNewObj((AstId)e1,el);
              break;
            case AstRegExpId.kwRelop:
              jj_consume_token(AstRegExpId.kwRelop);
              relop = relOp();
              e1 = astExp();
              e2 = astExp();
              e = new AstRelop(relop, e1, e2);
              break;
            case AstRegExpId.kwStrVal:
              jj_consume_token(AstRegExpId.kwStrVal);
              n = jj_consume_token(AstRegExpId.STRVAL);
                                  String s = n.image;
                                  e = new AstStrVal(s.Substring(1, s.Length-2));
              break;
            case AstRegExpId.kwThis:
              jj_consume_token(AstRegExpId.kwThis);
                                  e = new AstThis();
              break;
            case AstRegExpId.kwUnop:
              jj_consume_token(AstRegExpId.kwUnop);
              unop = unOp();
              e1 = astExp();
                                   e = new AstUnop(unop,e1);
              break;
            case AstRegExpId.kwNullExp:
              jj_consume_token(AstRegExpId.kwNullExp);
                                  e = null;
              break;

            default:
              jj_la1[13] = jj_gen;
              jj_consume_token(AstRegExpId.UNDEFINED);
              throw new AstParseException();
            }
            jj_consume_token(AstRegExpId.kw57);
            {if (true) return e;}
            throw new Error("Missing return statement in function");
        }
Exemplo n.º 4
0
 public AstType visit(AstIntVal n)
 {
     return IntType;
 }