简体   繁体   中英

Regular expression for context free grammar

I have this context free grammar : S -> aSb

S -> aSa

S -> bSa

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. 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. The DFA will have 2 states in this case, I think. q1(even) move to q2(odd) after a, b and from q2 move to q1 after a, b. The start and accepting state is q1.

给你。我认为 DFA 看起来像

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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