Consider the NFA with epsilon-transitions below, which is meant to accept strings corresponding to a lexical token id. Here the token digit corresponds to the extended regular expression [0-9] and letter corresponds to [a-z A-Z]. In the diagram, a small incoming edge indicates a start state while a double circle indicates a final state.
Which of the following extended regular expressions corresponds to the token id?
Tap to open full sizeFigure description
An NFA with epsilon-transitions. A start state (small incoming arrow from the left) has an edge labelled 'letter' to a double-circled final state F. From F, two epsilon edges leave: the upper one goes to a state from which an edge labelled 'letter' leads to another state, and the lower one goes to a state from which an edge labelled 'digit' leads to another state. Each of these two end states has an epsilon edge into a common join state at the right. From the join state a long epsilon edge, drawn as an arc over the top, returns to F.
- (A)
letter (letter | digit)*
- (B)
(letter | digit)* letter
- (C)
(letter | digit)*
- (D)
letter (letter* | digit*)