Category : Modula II Source Code
Archive   : PATTERN.ZIP

Output of file : DFAPATTE.TXT contained in archive : PATTERN.ZIP

N.Kitiyakara 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
DFA2TXT program.

PROCEDURE DeterminePosition (VAR pos : Position);
Returns the current position in the input buffer.

DFAPattern - 1

N.Kitiyakara DFAPattern

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.

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
END DFAPattern.

DFAPattern - 2

  3 Responses to “Category : Modula II Source Code
Archive   : PATTERN.ZIP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: