Question

I have spent all of yesterday and 7x hours today trying to find a definitive answer to a question in an assignment. I have watched hours of lectures on BNF and EBNF but none have addressed my question. I have learned loads though :)

I hope somebody can point the way:

Given this Grammar

G = {N, T, S, P} 
T = {a, b, c, - , ×} 
N = {<goal>, <expr>, <term>, <factor>} 
S = <goal> 
P = 
<goal> ::= <expr> 
<expr> ::= <term> | <expr> - <term> 
<term> ::= <factor> | <term> × <factor> 
<factor> ::= a|b|c

and then change the rules to:

<goal> ::= <expr>
<expr> ::= <term> | <term> - <expr> 
<term> ::= <factor> | <factor> × <term>
<factor> ::= a|b|c

What effect does it have on the production?

All I can see is it changes the LHS recursion to RHS recursion. I'd really like to know what I'm missing.

Other questions in the assignment changed the order of the rules which I answered: Rules that are lower in the cascade of productions have higher precedence.

Was it helpful?

Solution

After consulting with the lecturer I confirmed the only difference is: it changes the LHS recursion to RHS recursion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top