Dec 052017
 
A lexical analyzer written in Modula II for use as a pattern matcher. Includes full Modula II source code.
File PATTERN.ZIP from The Programmer’s Corner in
Category Modula II Source Code
A lexical analyzer written in Modula II for use as a pattern matcher. Includes full Modula II source code.
File Name File Size Zip Size Zip Type
DFAPATTE.DEF 1024 308 deflated
DFAPATTE.MOD 5120 1306 deflated
DFAPATTE.TXT 4096 1252 deflated
FAINPUT.DEF 1024 216 deflated
FAINPUT.MOD 5120 1467 deflated
FAINPUT.TXT 3072 957 deflated
LEX2NFA.EXE 49152 21041 deflated
NFA2DFA.EXE 40960 18543 deflated
NFAPATTE.DEF 1024 349 deflated
NFAPATTE.MOD 11264 2194 deflated
NFAPATTE.TXT 4096 1314 deflated
PATTERN.TXT 32768 10350 deflated

Download File PATTERN.ZIP Here

Contents of the DFAPATTE.TXT file





N.Kitiyakara DFAPattern


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;

CONST
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.
*)

VAR
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


PROCEDURE InitializeDFA;
(*
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
occurs.
*)
END DFAPattern.


































DFAPattern - 2


 December 5, 2017  Add comments

Leave a Reply