Question: Add a factorial operator: use a suffix ! operator to represent factorial. For example, the expression 7! means 7 * 6 * 5 * 4
Add a factorial operator: use a suffix ! operator to represent “factorial.” For example, the expression 7! means 7 * 6 * 5 * 4 * 3 * 2 * 1. Make ! bind tighter than * and /; that is, 7*8! means 7*(8!) rather than (7*8)!. Begin by modifying the grammar to account for a higher-level operator. To agree with the standard mathematical definition of factorial, let 0! evaluate to 1.
Step by Step Solution
3.36 Rating (162 Votes )
There are 3 Steps involved in it
Add an additional rule to expr The recursivedescent parser is about to reduce the entire expression to a single value but the code for multiplication ... View full answer
Get step-by-step solutions from verified subject matter experts
