简体   繁体   中英

What's the proper grammar for this language?

I have this language:

{a n b m | m+n is an even number}

What's the proper grammar for this?

S -> aaS | aB | bbC | ε
B -> bbB | b
C -> bbC | ε

you see, it is a regular language. 'S' stands for "we have constructed an even number of a's and more a's may follow, 'B' stands for "we have constructed an uneven number of a's and now an uneven number of b's follows. 'C' stands for "we have constructed an even number of a's and now an even number of b's follows.

ε stands for "", the empty string

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