指定语法的语言
是否有任何特定的方法来指定给定语法的语言?即是否有必要运行语法中给出的所有产生式规则来确定它所代表的语言?我没有这样的例子,因为我正在研究的是一个家庭作业问题。
[edit]: adding an example, Describe, in English, the language defined by the grammar
<S> -> <A> <B> <C>
<A> -> a <A> | a
<B> -> b <B> | b
<C> -> c <C> | c
问候,
黑暗 15
Is there any specific methodology followed to specify a language for given grammar ?? i.e. Is it necessary to run all the production rules given in a grammar to determine the language it represents? I don't have an example as such since the one I am working on is a homework question.
[edit]: adding an example, Describe, in English, the language defined by the grammar
<S> -> <A> <B> <C>
<A> -> a <A> | a
<B> -> b <B> | b
<C> -> c <C> | c
Regards,
darkie15
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的示例中,该部分
完全识别
a
的非空列表其他两个产生式
和
也是如此,分别为b
和c.
因此,用
->,您可以推断此语法识别的语言是a
的任何非空列表,后跟b
的非空列表,然后是 ac
的非空列表,对应正则表达式a+b+c+
。从那里可以很容易地证明正则表达式识别的每个实例都可以使用归纳法被语法识别。
In you example, the part
recognizes exactly non empty lists of
a
The same goes for the two other productions,
<B>
and<C>
, with respectivelyb
andc
.Thus, with
<S> -> <A> <B> <C>
, you deduce that the language this grammar recognizes is any non empty list ofa
, followed by a non empty list ofb
, then a non empty list ofc
, corresponding to the regular expressiona+b+c+
.Proof is quite easy from there to show that each instance recognized by the regular expression is recognized by the grammar, using induction.