Answers to Self-Study Questions
Test Yourself #1
Test Yourself #2
The regular expression
is the same as (digit | (letter letter)), and
means "one digit, or two letters".
The regular expression
is the same as (digit | (letter (letter *))), and
means "one digit, or one or more letters".
The regular expression
is the same as (digit | (letter *)), and
means "one digit, or zero or more letters".
Test Yourself #3
Two new tokens, INT_LITERAL and DBL_LITERAL would be defined.
The regular expressions for those tokens are
The finite-state machines are
INT_LITERAL
DBL_LITERAL
The modified finite-state machines are
INT_LITERAL
DBL_LITERAL
The "combined" finite-state machine would be augmented by having one new edge
out of the start state, leading to the node labeled A below.