fool2fish / dragon-book-exercise-answers

Compilers Principles, Techniques, & Tools (purple dragon book) second edition exercise answers. 编译原理(紫龙书)第2版习题答案。
6.37k stars 1.77k forks source link

Exercise 2.2.2 d #206

Closed Abhilekhgautam closed 1 year ago

Abhilekhgautam commented 1 year ago

How does S -> a S b S | b S a S | epsilon has equal number of a and b?

            S -> a S b S
                -> a a S b S

Now if I used an empty string I'd get 2 a's and 1 b's.

Abhilekhgautam commented 1 year ago

my bad.. made a bluneder S -> a S b S -> a a S b S b S

so we have same number of a's and b's.