文法
Start → ( Content )
Content → id Content | ( Content ) Content | ε
| 非终结符 |
FIRST集 |
FOLLOW集 |
| Start |
( |
$ |
| Content |
id, (, ε |
) |
| 产生式 |
SELECT集 |
| Start → ( Content ) |
( |
| Content → id Content |
id |
| Content → ( Content ) Content |
( |
| Content → ε |
) |
| 预测分析表 |
id |
( |
) |
$ |
| Start |
|
Start → ( Content ) |
|
|
| Content |
Content → id Content |
Content → ( Content ) Content |
Content → ε |
|
支持案例
(id(id))、((id)id)、(((id)))、(id(id(id)))
扩展
如果需要括号之间容纳其他终结符id',只需要新增产生式Content -> id' Content,然后First(Content)新增id',Select(Content -> id' Content) = {id'}即可
Start → ( Content )
Content → id Content | id' Content | ( Content ) Content | ε