492 views
0 votes
0 votes

The grammar $S\rightarrow a\:S\:a \mid \:a\: a$ generates all even-length strings of $a's$. We can devise a recursive-descent parser with backtrack for this grammar. If we choose to expand by production $S\rightarrow a \:a$ first, then we shall only recognize the string $aa$. Thus, any reasonable recursive-descent parser will try $S\rightarrow a\: S\: a$ first. 

  1. Show that this recursive-descent parser recognizes inputs $aa$, $aaaa$, and $aaaaaaaa$, but not $aaaaaa$. 
  2. What language does this recursive-descent parser recognize? 

The following exercises are useful steps in the construction of a "Chomsky Normal Form" grammar from arbitrary grammars, as defined in Question $4.4.8$. 

Please log in or register to answer this question.

Related questions

0 votes
0 votes
1 answer
2
admin asked Jul 26, 2019
576 views
Construct recursive-descent parsers, starting with the following grammars:$S\rightarrow +SS \mid -SS \mid a$$S\rightarrow S(S)S \mid \epsilon$$S\rightarrow 0S1 \mid 01$