Exercise 5.1.2(a)

Exercise 5.1.5

S -> S+S | SS | S* | (S) | 0 | 1 | phi | e

The idea is that these productions for S allow any expression to
be, respectively, the sum (union) of two expressions, the concatenation
of two expressions, the star of an expression, a parenthesized
expression, or one of the four basis cases of expressions: 0, 1, phi,
and epsilon.

Exercise 5.4.3

The idea is to introduce another nonterminal T
that cannot generate an
unbalanced a.
That strategy corresponds to the usual rule in programming languages
that an ``else'' is associated with the closest previous, unmatched ``then.''
Here, we force a b to match the previous unmatched a.
The grammar:

S -> aS | aTbS | epsilon
T -> aTbT | epsilon

Exercise 5.4.6

Alas, it is not.
We need to have three
nonterminals, corresponding to the three possible ``strengths''
of expressions:

A factor cannot be broken by any operator.
These are the basis expressions, parenthesized expressions, and these
expressions followed by one or more *'s.

A term can be broken only by a *.
For example, consider 01, where the 0
and 1 are concatenated, but if we follow it by a *, it becomes 0(1*),
and the concatenation has been ``broken'' by the *.

An expression can be broken by concatenation or *, but not by +.
An example is the expression 0+1.
Note that if we concatenate (say) 1 or follow by a *, we parse the
expression 0+(11) or 0+(1*), and in either case the union has been
broken.