Give an EBNF grammar for each of the languages below. Use the EBNF extensions wh
ID: 3789444 • Letter: G
Question
Give an EBNF grammar for each of the languages below. Use the EBNF extensions wherever possible to simplify the grammars. In particular, you should eliminate explicit recursion from the grammars wherever possible. Don't forget to put single quotes around and EBNF metasymbol when using it as a token.
<S> :: = ab <S> | <empty>
Explanation / Answer
a) S : = ' [ '+ D * + ' ] '
D : = '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
b)S := D (' , ' D )*
D := '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
c) S := '[ ' + D (' , ' D)* ' ] '
D = '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'