Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Start with the grammar G6, repeated here: G6: <exp> ::= <exp> + <mulexp> | <mule

ID: 3569574 • Letter: S

Question

Start with the grammar G6, repeated here:

G6:      <exp> ::= <exp> + <mulexp> | <mulexp>
            <mulexp> ::= <mulexp> * <rootexp> | <rootexp>
            <rootexp> ::= (<exp>) | a | b | c

Modify it in the following ways:

a. Add subtraction and division operators (- and /) with the customary precedence and associativity.

b. Then add left-associative operator % between + and * in precedence.

c. Then add right-associative operator = at lower precedence than any of the other operators.

Explanation / Answer

1.

<exp> ::= <exp> + <mulexp> | <exp> - <mulexp> | <mulexp>

<mulexp> ::= <mulexp> * <rootexp> | <mulexp> / <rootexp> | <rootexp>

<rootexp> ::= (<exp>) | a | b | c

2.

<exp> ::= <exp> + <modexp> | <exp> - <modexp> | <modexp>

<modexp> ::= <exp> % <mulexp> | <mulexp>

<mulexp> ::= <mulexp> * <rootexp> | <mulexp> / <rootexp> | <rootexp>

<rootexp> ::= (<exp>) | a | b | c

3.

<exp> ::= <exp> = <equalop>

<equalop> ::= <equalop> + <modexp> | <equalop> - <modexp> | <modexp>

<modexp> ::= <exp> % <mulexp> | <mulexp>

<mulexp> ::= <mulexp> * <rootexp> | <mulexp> / <rootexp> | <rootexp>

<rootexp> ::= (<exp>) | a | b | c

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote