Figure 1.9
EXERCISES
1. Give a grammar for the set of integer numbers in C.
2. Design an accepter for integers in C.
3. Give a grammar that generates all real constants in C.
4. Suppose that a certain programming language permits only identifiers that
begin with a letter, contain at least one but no more than three digits, and can
have any number of letters. Give a grammar and an accepter for such a set of
identifiers.
5. Modify the grammar in Example 1.15 so that the identifiers satisfy the
following rules:
(a) C rules, except that an underscore cannot be the leftmost symbol.
(b) C rules, except that there can be at most one underscore.
EXERCISES
1. Give a grammar for the set of integer numbers in C.
2. Design an accepter for integers in C.
3. Give a grammar that generates all real constants in C.
4. Suppose that a certain programming language permits only identifiers that
begin with a letter, contain at least one but no more than three digits, and can
have any number of letters. Give a grammar and an accepter for such a set of
identifiers.
5. Modify the grammar in Example 1.15 so that the identifiers satisfy the
following rules:
(a) C rules, except that an underscore cannot be the leftmost symbol.
(b) C rules, except that there can be at most one underscore.
