Java Reference
In-Depth Information
b
a
a
b
b
a
d
a
b
c
c
a
c
b
Figure 3.33: FA for Exerc i se 3.
5. Write a regular expression that defines a C-like, fixed-decimal literal
with no superfluous leading or trailing zeros. That is, 0.0, 123.01,and
123005.0are legal, but 00.0, 001.000,and002345.1000are illegal.
6. Write a regular expression that defines a C-like comment delimited by
/* and */. Individual *'s and /'s may appear in the comment body, but
the pair */may not.
7. Define a token class AlmostReserved to be those identifiers that are not
reserved words but that would be if a single character were changed.
Why is it useful to know that an identifier is “almost” a reserved word?
Howwould you generalize a scanner to recognize AlmostReserved tokens
as well as ordinary reserved words and identifiers?
 
Search WWH ::




Custom Search