Contents of the DFAPATTE.TXT file
DEFINITION MODULE DFAPattern;
This module provides a simulator for a deterministic finite automa-
ton produced by one of the program which make up the Pattern sys-
tem. The modules may be inter-changed in a program by merely
changing the names of the procedures. (The exception to this is a
machine generated definition of the finite automaton, which must
be exchanged in the source program.) No implementation details
are described here, interested parties should see the appropriate
section of the full description of the Pattern system.
Neither module makes any claim to be a full fledged lexical ana-
lyzer. They are merely exaggerated pattern matchers, which can
serve as the base of a lexical analyzer.
FROM FileSystem IMPORT File;
AcceptingMarker = MAX (CARDINAL);
InvalidMarker = MAX (CARDINAL) - 1;
EndMarker = MAX (CARDINAL);
EmptyTransition = 377C;
These constants appear for complete compatibility with the module
NFAPattern, although they are not used by the DFA simulator.
lastLexeme : ARRAY [0..255] OF CHAR;
This array holds the last lexeme matched by ReadPattern, it should
be considered read-only, although changing it will not affect the
operation of the module.
PROCEDURE DefineIndex (state,cursor : CARDINAL);
PROCEDURE DefineState (state,next,accepting : CARDINAL;
first,last : CHAR);
Both DefineIndex and DefineState are included for the use of mechan-
ically created DFA definitions. Because their use is implementa-
tion dependent, they should only be used with files created by the
PROCEDURE DeterminePosition (VAR pos : Position);
Returns the current position in the input buffer.
DFAPattern - 1
This procedure resets the information concerning the current DFA in
use. It must be called before the definition of a DFA, but it is
called automatically by ReadDFAFromDisk and by mechanically cre-
ated code from DFA2TXT.
PROCEDURE ReadPattern (VAR num : CARDINAL);
This procedure activates the DFA simulator. It will return the num-
ber of the pattern it finds (as determined by the LEX2NFA pro-
gram), or 65535 if it cannot match any pattern.
PROCEDURE ReadDFAFromDisk (VAR f : File);
This procedure can be used to replace the current DFA (if any) with
the DFA represented by the information in the file. It will re-
turn when the DFA has been successfully read, or when a disk error
DFAPattern - 2