简体   繁体   English

关于文法的跟随集

[英]On FOLLOW-Sets of Grammars

Here http://slkpg.byethost7.com/llkparse.html the FOLLOW_k-Sets are defined 此处定义了http://slkpg.byethost7.com/llkparse.html FOLLOW_k-Set

"The FOLLOWk set of a string of symbols in a grammar is a set of k-length terminal symbol strings in the grammar that may follow the string of symbols in some sentential form derivable in the grammar" “文法中的符号串的FOLLOWk集是文法中的k个长度的最终符号串的集合,它们可以跟随语法中可衍生的某种句子形式的符号串。”

First i have a quation regarding the example under the link, there for Grammar 4.2 首先,我对链接下的示例有一个疑问,那里有语法4.2

     A  -->  a <Baa> a a              
     A  -->  b <Bba> b a
 <Baa>  -->  b
 <Baa>  -->
 <Bba>  -->  b
 <Bba>  -->

It is said that: 据说:

FIRST2 ( A ) = { aa, ab, bb }
FIRST2 ( <Baa> ) = { epsilon }
FIRST2 ( <Bba> ) = { epsilon }

FOLLOW2 ( <Baa> ) = { aa }
FOLLOW2 ( <Bba> ) = { ba }

But i am asking myself why not 但是我问自己为什么不

FIRST2 ( <Baa> ) = { epsilon, b }
FIRST2 ( <Bba> ) = { epsilon, b }

because from for example also a single b could be derived. 因为例如也可以从中导出一个b。

Furthermore for the grammar 再说语法

S -> X 
X -> aX
X -> aY
Y -> epsilon

i am unsure of the set 我不确定背景

FOLLOW2(S)

is it empty, { epsilon } , or { a, aa } because these string are derivable, or is it just important what comes after S, and because S is the startsymbol nothing comes behind it, but then should i write FOLLOW2(S) = \\empyset or FOLLOW2(S) = { epsilon }? 是空的,{epsilon}还是{a,aa}是因为这些字符串是可派生的,还是在S之后紧随其后的事情很重要,并且由于S是开始符号,所以后面没有任何内容,但是我应该写FOLLOW2(S) = \\ empyset或FOLLOW2(S)= {epsilon}?

FOLLOWk(S) is empty for any k, because nothing can follow S at all. FOLLOWk(S)对于任何k都是空的,因为没有任何东西可以跟随S。 I don't know what you mean by 'because these strings are derivable', but as they cannot follow S it's irrelevant anyway. 我不知道您的意思是“因为这些字符串是可派生的”,但由于它们不能跟随S,因此无论如何都无关紧要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM