Updated nopt.doc for dfa encoded using row displacement

This commit is contained in:
bruce 1987-07-28 10:56:44 +00:00
parent 545bed355d
commit ac20a570cd

View file

@ -415,20 +415,26 @@ Also, after a successful match, a replacement queue is constructed.
If no errors are detected by the parser in the tables it output the following If no errors are detected by the parser in the tables it output the following
files if they have changed from the existing version of the file: files if they have changed from the existing version of the file:
.IP dfa.c 10 .IP dfa.c 10
this consists of a routine for each state in the dfa. Each routine contains this contains the dfa encoded into a number of arrays using the technique
a switch statement that decides on the basis of the current instruction of row displacement for compacted sparse matricies. Given an opcode and
opcode the next state if any in the dfa to make a transition to. the current state, the value of
These routines are called from .I OO_base[OO_state]
.I OO_dfa is consulted to obtain a pointer into the array
declared in .I OO_checknext.
.I OO_dfa.c If this pointer in zero or the
via an array .I check
.I OO_fstate field of the addressed structure does
that is indexed by state. Attempt to implement this code by a large nested not correspond to the curerent state then it is known there is no entry for
switch statement experienced difficulties with compilers that had fixed this opcode/state pair and the
limits on the size of switch statements. A better implementation of this .I OO_default
might be to find some hashing function that mapped state and opcode onto a array is consulted instead.
unique value and then switch on this via an array. If the check field does match then the
.I next
field contains the new state.
After each transition the array
.I OO_ftrans
is consulted to see if this state corresponds to a final state
(i.e. a complete pattern) and if so the corresponding function is called.
.IP trans.c 10 .IP trans.c 10
this contains external declarations of transition routines with names like this contains external declarations of transition routines with names like
.B OO_xxxdotrans .B OO_xxxdotrans
@ -440,10 +446,12 @@ These are called when there a transition to state
that corresponds to a that corresponds to a
complete pattern. Any tests are performed if necessary to confirm that the complete pattern. Any tests are performed if necessary to confirm that the
pattern matches and then the replacement instructions are placed on the pattern matches and then the replacement instructions are placed on the
output queue and backup and freeing of instructions is performed. If there are output queue and the routine
a number of patterns with the same instructions but different tests, these .I OO_mkrepl
will all appear in the same routine and the tests performed in the order they is called to make the replacement and if backup the amount required.
appear in the original If there are a number of patterns with the same instructions but different
tests, these will all appear in the same routine and the tests performed in
the order they appear in the original
.I patterns .I patterns
file. file.
.IP incalls.r 10 .IP incalls.r 10