[英]Context free grammar for CFL
enter code here
Hallo, this is my question enter code here
你好,这是我的问题
Give context free grammar for CFL L = {a^nb^mc^n | m, n ∈ N0}
给出CFL的上下文无关文法
L = {a^nb^mc^n | m, n ∈ N0}
L = {a^nb^mc^n | m, n ∈ N0}
My answer is S-> ASC| B A-> aA| a B-> bB| b C-> cC| c
我的答案是
S-> ASC| B A-> aA| a B-> bB| b C-> cC| c
S-> ASC| B A-> aA| a B-> bB| b C-> cC| c
Whether my answer or not ? 是否我的答案? I am not sure about it.
我不确定。 Need some help.
需要一些帮助。 thanks in advance
提前致谢
Your grammar generates the language 您的语法产生语言
L = {a^n b^m c^k | m, n, k ∈ N0}
because the numbers of times that the rules A->aA and C->cC are applied are independent. 因为应用规则A-> aA和C-> cC的次数是独立的。 If you want n=k, then you have to generate the a and c in the same rule.
如果要n = k,则必须在同一规则中生成a和c。 For example like this:
例如这样:
S -> aSc | B .
In a second phase you generate an arbitrary number of b in the middle: 在第二阶段,您会在中间生成任意数量的b:
B -> bB | <empty string> .
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.