码迷,mamicode.com
首页 > 其他好文 > 详细

FIRST集和FOLLOW集的求法

时间:2015-12-07 12:25:48      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

FIRST集


$FIRST集合$

------------------------------------------------------------------------

$ S\rightarrow a..., \\
a \ \ \in FIRST(S)\\
$

------------------------------------------------------------------------

$S\rightarrow \epsilon, \\
\epsilon \in FIRST(S)\\
$

 ------------------------------------------------------------------------

$S\rightarrow Y_{1}Y_{2}Y_{3}...Y_{N},\\
FIRST(Y_{1})/\epsilon \subset FIRST(S) \\
if \ \ \epsilon \in FIRST(Y_{1})\\
FIRST(Y_{2})/\epsilon \subset FIRST(S)\\
\\if \ \ \epsilon \in FIRST(Y_{1}),\epsilon \ in FIRST(Y_{2})\\
FIRST(Y{3})/\epsilon \subset FIRST(S)\\
if \ \ \epsilon \in FIRST(Y_{1}),\epsilon \ in FIRST(Y_{2}),\epsilon \in FIRST(Y_{3})\\
FIRST(Y_{4})/\epsilon \subset FIRST(S)\\
.........以此类推\\
if \ \ \epsilon \in FIRST(Y_{1}),\epsilon \ in FIRST(Y_{2}),\epsilon \in FIRST(Y_{3}),...\epsilon \in FIRST(Y_{n})\\
\epsilon \in FIRST(S)\\
\\
\\
$



 

FOLLOW集

$FOLLOW集合$

------------------------------------------------------------------------
$A->xB\\
FOLLOW(A) \subset FOLLOW(B)\\
$

------------------------------------------------------------------------

$A->xBY_{1}Y_{2}...Y_{n}\\
FIRST(Y_{1}) \subset FOLLOW(B)\\
if \ \ \epsilon \in FIRST(Y_{1})\\
FIRST(Y_{2}) \subset FOLLOW(B)\\
if( \\ \epsilon \in FIRST(Y_{1}), \epsilon \in FIRST(Y_{2})\\
FIRST(Y_{3}) \subset FOLLOW(B)\\
.....以此类推\\
if \ \ \epsilon \in FIRST(Y_{1}),\epsilon \ in FIRST(Y_{2}),\epsilon \in FIRST(Y_{3}),...\epsilon \in FIRST(Y_{n})\\
\epsilon \in FIRST(S)\\
FOLLOW(A) \subset FOLLOW(B)\\
$

FIRST集和FOLLOW集的求法

标签:

原文地址:http://www.cnblogs.com/beMaster/p/5025385.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!