Slide 8.5: Reduction rules for integer arithmetic expressions
Slide 8.7: Reduction rules for integer arithmetic expressions (cont.)
Home

Reduction Rules for Integer Expressions (Cont.)


Reduction rules for integer arithmetic expression are the following:
  1. All the rules for reducing digits to values are in this one rule:
    '0' ⇒ 0;   '1' ⇒ 1;   '2' ⇒ 2;   '3' ⇒ 3;   '4' ⇒ 4;
    '5' ⇒ 5;   '6' ⇒ 6;   '7' ⇒ 7;   '8' ⇒ 8;   '9' ⇒ 9 
  2. The rules for reducing numbers to values are in this one rule:
    V '0' ⇒ 10 * V;          V '1' ⇒ 10 * V + 1;
    V '2' ⇒ 10 * V + 2;      V '3' ⇒ 10 * V + 3;
    V '4' ⇒ 10 * V + 4;      V '5' ⇒ 10 * V + 5;
    V '6' ⇒ 10 * V + 6;      V '7' ⇒ 10 * V + 7;
    V '8' ⇒ 10 * V + 8;      V '9' ⇒ 10 * V + 9 
  3. V1 '+' V2 ⇒ V1 + V2
  4. V1 '–' V2 ⇒ V1 – V2
  5. V1 '*' V2 ⇒ V1 * V2
  6. '(' V ')' ⇒ V
  7.          E ⇒ E1         
    E '+' E2 ⇒ E1 '+' E2
  8.          E ⇒ E1         
    E '–' E2 ⇒ E1 '–' E2
  9.          E ⇒ E1         
    E '*' E2 ⇒ E1 '*' E2
  10.          E ⇒ E1         
    V '+' E ⇒ V '+' E1
  11.          E ⇒ E1         
    V '–' E ⇒ V '–' E1