Javadoc
From (A)* build
|---|
v |
o->o-A-o--o (Transition 2 from block end points at alt 1; follow is Transition 1)
| ^
o---------| (optional branch is 2nd alt of optional block containing A+)
Meaning that the last (end) NFAState in A points back to A's
left side NFAState and we add 3 new NFAStates (the
optional branch is built just like an optional subrule).
See the Aplus() method for more on the loop back Transition.
The new node on right edge is set to RIGHT_EDGE_OF_CLOSURE so we
can detect nested (A*)* loops and insert an extra node. Previously,
two blocks shared same EOB node.
There are 2 or 3 decision points in a A*. If A is not a block (i.e.,
it only has one alt), then there are two decisions: the optional bypass
and then loopback. If A is a block of alts, then there are three
decisions: bypass, loopback, and A's decision point.
Note that the optional bypass must be outside the loop as (A|B)* is
not the same thing as (A|B|)+.
This is an accurate NFA representation of the meaning of (A)*, but
for generating code, I don't need a DFA for the optional branch by
virtue of how I generate code. The exit-loopback-branch decision
is sufficient to let me make an appropriate enter, exit, loop
determination. See codegen.g