离散结构-消除左递归,第一和跟随集

时间:2018-10-17 16:57:55

标签: discrete-mathematics left-recursion

我最近遇到了一个有趣的问题,我必须消除左递归,然后找到下面的问题的第一个集并遵循它。有人可以确认我做的正确还是对我做错了?

Eliminate Left Recursion:
A -> B | c
B -> C | a
C -> A | b

Simplified:
A -> A | b | a | c

My answer:
A -> aA' | bA' | cA'
A' -> A' | Epsilon

First & Follow sets:
First (A) = {a, b, c}
First (B) = {a, b, c}
First (C) = {a, b, c}

Follow(A) = {$}
Follow(B) = { }
Follow(C) = { }

0 个答案:

没有答案