Category : Modula II Source Code
Archive   : PATTERN.ZIP

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

N.Kitiyakara NFAPattern

This module provides a simulator for a non-deterministic finite au-
tomaton produced by one of the program which make up the Pattern
system. 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 are for use by the mechanical code generator
NFA2TXT. Naturally, one should not try to take advantage of the

StateRecord = RECORD
next1,next2 : CARDINAL;
char : CHAR;
END; (* StateRecord *)
This represents the definition of a single state. It is included
here for information only, and should not be used by any program.

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.

NFAPattern - 1

N.Kitiyakara NFAPattern

PROCEDURE DefineConstant (num,start : CARDINAL);

PROCEDURE DefineState (num,n1,n2 : CARDINAL; ch : CHAR);
Both DefineConstant and DefineState are included for the use of me-
chanically created NFA definitions. Because their use is imple-
mentation dependent, they should only be used with files created
by the NFA2TXT program.

This procedure resets the information concerning the current NFA in
use. It must be called before the definition of a NFA, but it is
called automatically by ReadNFAFromDisk and by mechanically cre-
ated code from NFA2TXT.

This procedure activates the NFA 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 ReadNFAFromDisk (VAR f : File);
This procedure can be used to replace the current NFA (if any) with
the NFA represented by the information in the file. It will re-
turn when the NFA has been successfully read, or when a disk error
END NFAPattern.

NFAPattern - 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: