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)); }
public VarRec(AstId id, AstType type, int kind, int idx) { _id = id; _type = type; _kind = kind; _idx = idx; _init = null; }
public VarRec(AstId id, AstType type, int kind, int idx, AstExp e) { _id = id; _type = type; _kind = kind; _idx = idx; _init = e; }
public static void Append(AstExp e) { if (e == null) _astData.Append("(NullExp) "); else e.GenerateAstData(); }
public AstCall(AstExp e, AstId mi, AstExpList el) { obj = e; mid = mi; args = el; }
public AstIf(AstExp ae, AstStmt as1, AstStmt as2) { e = ae; s1 = as1; s2 = as2; }
public void Add(AstExp n) { base.Add(n); }
public AstWhile(AstExp ae, AstStmt _as) { e=ae; s=_as; }
/* 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)); }
/* 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"); }
/* 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 ); }
/* 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; }
/* 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; }
/* 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; }
public AstArrayElm(AstExp e1, AstExp e2) { _array = e1; _idx = e2; }
public AstCallStmt(AstExp astExp, AstId astId, AstExpList astExpList) { _obj = astExp; _mid = astId; _el = astExpList; }
public AstPrint(AstExp ae) { e = ae; }
public AstField(AstExp e, AstId v) { obj = e; var = v; }
public AstUnop(OP o, AstExp ae) { op=o; e=ae; }
public AstArrayLen(AstExp e) { array = e; }
public AstAssign(AstExp e1, AstExp e2) { lhs = e1; rhs = e2; }
public AstVarDecl(AstType at, AstId i, AstExp ae) { t = at; var = i; e = ae; }
public AstRelop(OP o, AstExp ae1, AstExp ae2) { op = o; e1 = ae1; e2 = ae2; }
public AstReturn(AstExp ae) { e = ae; }