DEFINITION MODULE VLCGlobal; (* Title : VLCGlobal.MOD Author : Kim Moser System : JPI TopSpeed Modula-2 with PMI Repertoire 1.5c Descrip : Global variables, types, procedures, etc. for VLC *) CONST MaxMC=3; (*Most operands that any operator can have [+1 for operator]*) MaxSymbolLength=8; TYPE LineType=ARRAY[0..79] OF CHAR; VAR TheLine: LineType; (*Used to hold lines of text from source file*) Operator: ARRAY[0..79] OF CHAR; (*First parsed word from TheLine [could be a label]*) Operands: ARRAY[0..MaxMC],[0..79] OF CHAR; (*Parsed words after first*) MC: ARRAY[1..MaxMC] OF CARDINAL; (*Machine code for Operands[n]*) MCCount: CARDINAL; (*Counter of how much MC has been generated for this line*) SourceErrors: CARDINAL; (*Counts number of source errors (updated by procedure VLCGlobal.SourceError)*) LC: CARDINAL; (*Location counter*) Debug: BOOLEAN; (*For debugging during developing*) ShowMC: BOOLEAN; (*Indicates to WriteMC [in main] whether or not to write MC; set to FALSE by SourceError]*) (****************************************************************************** PROCEDURES ******************************************************************************) (* These are necessary because JPI uses non-standard procedures to do the following: *) PROCEDURE WriteString( s: ARRAY OF CHAR ); PROCEDURE WriteLn(); PROCEDURE WriteStringLn( s: ARRAY OF CHAR ); PROCEDURE WriteCard( c, w: CARDINAL ); PROCEDURE WriteInt( i, w: CARDINAL ); PROCEDURE InternalError(TheMessage: ARRAY OF CHAR); (* Writes a message describing an internal error in the VLC code *) PROCEDURE SourceError(TheColumn: CARDINAL; TheMessage: ARRAY OF CHAR); (* If TheColumn > 0 then writes a caret (^) in column (TheColumn), followed by a newline. Writes TheMessage regardless. *) PROCEDURE ParseWord(TheLine: ARRAY OF CHAR; VAR TheIndex: CARDINAL; VAR TheWord: ARRAY OF CHAR): BOOLEAN; (* Read a word starting at first valid char (i.e. not " " or ",") at or after TheLine[TheIndex]; set TheIndex to position AFTER last char in word, if any, or to HIGH(TheLine) if string is not properly terminated; returns TRUE if any valid chars were found, else sets TheWord to NULL and returns FALSE [Assumes that commas and/or spaces are used as word delimiters] *) PROCEDURE WriteDebug(TheString: ARRAY OF CHAR); (* Writes TheString preceeded by "***" to indicate that is a debug message. Used only for debugging during developing. *) END VLCGlobal.