// TermOp -> * SignedFactor TermOp // TermOp -> / SignedFactor TermOp // TermOp -> EPSILON Factor TermOp(Factor factor) { switch (lookahead.type) { case TokenType.MULTI: GetNextToken(); factor.Multiply(SignedFactor()); return(TermOp(factor)); case TokenType.DEV: GetNextToken(); factor.Divide(SignedFactor()); return(TermOp(factor)); default: return(factor); } }
//SignedFactor -> + Factor | - Factor | Factor Factor SignedFactor() { switch (lookahead.type) { case TokenType.ADD: GetNextToken(); return(Factor()); case TokenType.SUB: GetNextToken(); Factor t = Factor(); t.Multiply(new Term(-1)); return(t); default: return(Factor()); } }
// TermOp -> * SignedFactor TermOp // TermOp -> / SignedFactor TermOp // TermOp -> EPSILON Factor TermOp(Factor factor) { switch (lookahead.type) { case TokenType.MULTI: GetNextToken (); factor.Multiply (SignedFactor ()); return TermOp (factor); case TokenType.DEV: GetNextToken (); factor.Divide (SignedFactor ()); return TermOp (factor); default: return factor; } }