Can contextual free grammar remain left and right recursive?

ex.

S-> S + T | T

T-> U - T | U

U → ID | N

associativity is obviously not preserved. But I don’t see it being ambiguous. So is this not an ambiguous cfg?

+3
source share
1 answer

Grammar can have either left or right recursion, as you show, but that doesn't mean much. Any grammar can be rewritten, so all recursions are either left or right (but not always the same, unless the grammar is regular):

A -> B A C

becomes:

A -> B X
X -> A C

, . , .

+4

Source: https://habr.com/ru/post/1789655/


All Articles