Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the proper grammar for this language?

I have this language:

{an bm | m+n is an even number}

What's the proper grammar for this?

like image 441
Nick.h Avatar asked Oct 02 '10 17:10

Nick.h


1 Answers

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

like image 167
fschmitt Avatar answered Oct 16 '22 15:10

fschmitt