[英]Regular expression for context free grammar
I have this context free grammar : S -> aSb我有这个上下文无关语法:S -> aSb
S -> aSa S -> aSa
S -> bSa S -> bSa
S -> bSb S -> bSb
S -> epsilon I want to show that this grammar describes a regular language ( namely can be represented as a regular expression) but I'm not sure how to do that and get the confident I'm not missing any pattern. S -> epsilon 我想证明这个语法描述了一种正则语言(即可以表示为正则表达式),但我不确定如何做到这一点,并确信我没有遗漏任何模式。 I did not see this exact question and that why I don't think it is duplicate.
我没有看到这个确切的问题,也没有看到为什么我认为它不是重复的。 I'd like an explanation on this relative simple example.
我想解释一下这个相对简单的例子。 It was hard for me to follow more complicated examples.
我很难遵循更复杂的例子。
You must build a DFA or regular expression.您必须构建 DFA 或正则表达式。 The DFA will have 2 states in this case, I think.
我认为,在这种情况下,DFA 将有 2 个状态。 q1(even) move to q2(odd) after a, b and from q2 move to q1 after a, b.
q1(even) 在 a, b 之后移动到 q2(odd) 并且在 a, b 之后从 q2 移动到 q1。 The start and accepting state is q1.
开始和接受状态是 q1。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.