The tt(lex) function works as follows:

itemization(
it() All its variables have been initialized at construction time. In
    particular, initially the run-time variable tt(d_atBOL) is set to
    tt(true). 
it() In a loop (until EOF) characters are retrieved until a rule is matched
    (see below)
it() Once a rule has been matched its matching code block is executed.
)

Processing characters:

The next character from the input is obtained in tt(d_char). At the beginning
of the character processing loop tt(d_char) must have received a value.
At EOF the character is given the (pseudo) character value tt(AT_EOF). 

Next, the associated range (tt(d_range)) is determined as
tt(s_ranges[d_char]).

The variable tt(d_dfaBase) points at the dfa currently used. The variable
tt(d_dfaIdx) holds the index of the current row in the current dfa. 

The expression 
        verb(
    nextIdx = (d_dfa + d_dfaIdx)[d_range];
        ) 
    provides the next tt(d_dfaIdx) value. If unequal -1 do:
        verb(
    d_dfaIdx = nextIdx;
    d_char = nextChar();
        )
    If equal -1 then there is no continuation for the current rule. 


Depending on the current state and action several action types can be returned
by the run-time function tt(actionType__):
    itemization(
    itt(CONTINUE): there exists a continuation from the current state/range
            combination; 
    itt(MATCH): a final state has been reached and there's no continuation
            possible. In this case a rule has been matched
    itt(ECHO1ST): no continuation is possible for the current range, and no
            final state was reached, the input buffer contains one or more
            characters.
    itt(ECHOCHAR): no continuation is possible for the current range, no
            final state was reached and the input buffer is still empty
    itt(RETURN): input exhausted, tt(lex) returns 0.
    )

The following table shows how actions are determined by tt(actionType__). The
function tt(actionType__) starts it tests at the first row of the table, and
stops as soon as a condition hold true, returning the action type:
    center(
    table(3)(lll)(
    row(cells(3)(Action determined by tt(actionType__)))
    rowline()
    row(cell()cells(2)(Input Character))
    columnline(2)(2)
    row(cellsp(Performed Test)cell(not AT_EOF)cell(AT_EOF))
    rowline()
    row(cell(transition OK)     cell(CONTINUE)    cell(CONTINUE))
    row(cell(match found)       cell(MATCH)       cell(MATCH))
    row(cell(buffer size)       cell(ECHO1ST)     cell(ECHO1ST))
    row(cell(buffer empty)      cell(ECHOCHAR)    cell(RETURN))
    rowline()
    ))


For each of the returned action types actions must be performed:

itemization(
    itt(CONTINUE:) store the input character (not being tt(AT_EOF)) in the
        buffer, continue scanning
    itt(MATCH:) push the just read char back to the input, copy the non-pseudo
        character (i.e., other than AT_EOF) to the match-buffer, set
        tt(d_atBOL) to tt(true) if the last character in the tt(d_matched)
        buffer is tt('\n'), execute the rule's actions, continue scanning (but
        the action may end tt(lex)'s call).
    itt(ECHO1ST:) echo the 1st char. of the buffer to stderr, set tt(d_atBOL)
        to tt(true) if that character equals tt('\n'), otherwise to tt(false),
        return all but the first character in the buffer back to the input,
        continue scanning.
    itt(ECHOCHAR:) echo the just read character to stderr, set tt(d_atBOL)
        to tt(true) if that character equals tt('\n'), otherwise to tt(false),
        continue scanning.
    itt(RETURN:) the function tt(lex) returns with token value 0.
)

The data member tt(d_atBOL) is also set to tt(true) at a stream-switch: when
switching to another stream or returning to a stacked stream. This handles the
borderline case where a file's last line is not properly terminated with a
tt('\n') character.

quote(TODO: Subsequent text of this section may require extensive
editing/rewriting) 


In em(all) case where the last two elements of the current  tt(s_dfa) row
are unequal special actions must be performed. Using the last but one's value
as tt(d_finAcIdx) do as follows:
    itemization(
    it() If there is a continuation for the current character range (so
tt((d_dfaBase + d_dfaIdx)[d_charRange]) is unequal -1) then inspect the
tt(s_finAcInfo + d_finAcIdx)'s A and I values.
    itemization(
    it() If I equals 1 store A's value and increment it at each next
        transition until a rule has been matched. This determines the LA
        tail-length;
    )
    it() Otherwise (no continuation):
        itemization(
        it() If I equals 1 then the A count incremented so far is the LA's
            tail length.
        it() If I equals 0 and A is non-negative then A's value is the LA's
            tail length
        it() If F is positive then it is the accept count of the current rule
            quote(TODO: 
                maybe this and the previous option are mutually exclusive and
                only one of them occurs in practice.
            )
            If F equals -1 then accept the matched text as is.nl()
            If it equals -2 we're not at a final state. If there's no
            continuation, push back all but the first character, echo the 1st
            char and continue scanning with the INITAL scanner at state 0.
        )
    )
If a final state has been reached then possibly push back the LA tail and
execute the actions of the rule that was matched. Using the currently active
miniscanner, start matching the next rule.

        
    




