Runtime Terror
Runtime Terror

Reputation: 6752

Are these grammars left recursive and why?

I've got these grammars to solve the left recursion. But why are these grammars left recursive? They are not following the schema A -> Aa | b:

1., S → 0S1 | 01

2., S → + SS | * SS

Upvotes: 0

Views: 66

Answers (1)

sepp2k
sepp2k

Reputation: 370465

Are these grammars left recursive

No.

and why?

In both cases you can never reach S (which is the only non-terminal) without consuming a terminal first. In the first grammar the only occurrence of S is preceded by the terminal 0 and in the second each occurrence is either preceded by + or *.

Upvotes: 2

Related Questions