public exprAST parseExpr() { listAddopTermAST temp = null; listAddopTermAST result = null; termAST term = null; addopAST addop = null; termAST term2 = null; //Expr = [ "-" ] Term { Addop Term } Boolean ind = false; Boolean ind2 = false; if (currentToken.sym == sym.RES) { acceptIt(); ind = true; } term = parseTerm(); while (currentToken.sym == sym.SUM || currentToken.sym == sym.RES) { if (ind2 == false) { addop = parseAddop(); term2 = parseTerm(); result = new unAddopTermAST(addop, term2); ind2 = true; } else { addop = parseAddop(); term2 = parseTerm(); temp = new unAddopTermAST(addop, term2); result = new varAddopTermAST(result, temp); } } if (ind == false && result == null) { return(new expreSoloTermAST(term)); } else if (ind == true && result == null) { return(new exprNegativaTermAST(term)); } else if (ind == false && result != null) { return(new exprAddopTermAST(term, result)); } else if (ind == true && result != null) { return(new exprNegativaAddopTermAST(result, term)); } return(null); }
public exprAddopTermAST(termAST t, listAddopTermAST l) { listAddopTerm = l; term = t; }
public varAddopTermAST(listAddopTermAST hh1, listAddopTermAST hh2) { h1 = hh1; h1 = hh2; }
public exprNegativaAddopTermAST(listAddopTermAST l, termAST t) { listAddopTerm = l; term = t; }
public exprNegativaAddopTermAST(listAddopTermAST l, termAST t) { listAddopTerm = l; term = t; }