home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d512 / m2pascal.lha / M2Pascal / src / scan.def < prev    next >
Text File  |  1991-07-20  |  3KB  |  120 lines

  1. DEFINITION MODULE scan;    
  2.  
  3. (* 
  4.                            * SCAN * 
  5.  
  6.                            by - Greg Mumm
  7.  
  8.    This module reads multiple symbols one by one on a per line basis.
  9.    Look-Ahead is possible and it can handle multiple files.
  10. *)
  11.  
  12. FROM FileSystem    IMPORT File;
  13.  
  14.  
  15. CONST  
  16.       StringMax    =  161 ;       (*  160 column support  ( 2 lines )  *)
  17.       SPACE        = ' '  ;
  18.       TAB          = 11C  ;
  19.       EOLN         = 12C  ;
  20.       Q1           = "'"  ; (* single quote string *)
  21.       Q2           = '"'  ; (* double quote string *)
  22.       LPAR         = "("  ;
  23.       RPAR         = ")"  ;
  24.       
  25. TYPE 
  26.       STRING        =  ARRAY [ 0 .. StringMax ]   OF CHAR;
  27.       StringPtrType =  POINTER TO STRING;
  28.       NameString    =  ARRAY [ 0 .. 255       ]   OF CHAR; (*  FileName  *)
  29.  
  30.       SymbolType    =  ( number,  identifier, end, literal, blanks, other, 
  31.                          nothing );    
  32.  
  33.        (* This holds left margin information contained in the invisible
  34.           space before the first symbol. 
  35.        *)
  36.       IndentArray   =  ARRAY [ 1..StringMax ] OF  CHAR ;
  37.  
  38.  
  39.   (* Set 'DeleteFile' to TRUE if you want to automatically delete a file
  40.      if present. ( eg. when WRITING to a file ).
  41.      Set 'DeleteFile' to FALSE for  normal READ operations.
  42.    *)
  43. PROCEDURE OpenInFile    (     FileName        : NameString  ;
  44.                               DeleteFile      : BOOLEAN     ;
  45.                           VAR successful      : BOOLEAN    );
  46. PROCEDURE OpenOutFile   (     FileName        : NameString  ;
  47.                               DeleteFile      : BOOLEAN     ;
  48.                           VAR successful      : BOOLEAN    );
  49. PROCEDURE CloseAllFiles ();
  50.  
  51.  
  52. PROCEDURE eof           () : BOOLEAN;
  53.  
  54. PROCEDURE eoln          () : BOOLEAN;
  55.  
  56.   (* The following two procedures are used to detect eof and eoln
  57.      conditions WHEN READING AHEAD. Do NOT use the above procedures
  58.      when reading ahead. 
  59.   *)
  60. PROCEDURE EofAhead      () : BOOLEAN;
  61.  
  62. PROCEDURE EolnAhead     () : BOOLEAN;
  63.  
  64.  
  65.  (* eof OR eoln
  66.  *)
  67. PROCEDURE HitABrickWall () : BOOLEAN;
  68.  
  69.  
  70.  
  71.  (* Look-ahead buffer is full if this is set
  72.  *)
  73. PROCEDURE TooFar          () : BOOLEAN;
  74.  
  75.  (* Normally after reading ahead, the following read-ahead will return NEW
  76.     unanalized data. ( Previous access is stored ). This proceedure will
  77.     allow the 2'nd read-ahead to read the same data read the first time.
  78.     A FastForward  does the opposite of above. It will automatically signal 
  79.     the next ReadAhead procedure to use new data regardless of whether the
  80.     previous access was a ReadAhead or just a Read.
  81.  *)
  82. PROCEDURE rewind          ();
  83.  
  84. PROCEDURE FastForward     ();
  85.  
  86.  
  87. PROCEDURE ReadLine (VAR indent                : IndentArray ) : BOOLEAN;
  88.  
  89. PROCEDURE ReadAheadLine ( VAR indent          : IndentArray ) : BOOLEAN;
  90.  
  91.  
  92.  
  93.  
  94. PROCEDURE ReadSymbol ( VAR symbol           : STRING;
  95.                        VAR SymbolClass      : SymbolType ) ;
  96.            
  97. PROCEDURE ReadAheadSymbol ( VAR symbol           : STRING;
  98.                             VAR SymbolClass      : SymbolType );  
  99.  
  100.  (* Print currently processing line number to screen.
  101.  *)
  102. PROCEDURE PrintLineNumber ();
  103.  
  104. PROCEDURE write (char : CHAR) ;
  105.  
  106.  
  107.  
  108. (* DEBUG *)
  109.    
  110.   (* Print input line after we read it in.
  111.   *)
  112. PROCEDURE DebugPrintLine ( Indent : IndentArray );
  113.  
  114.   (* Print everything going to a file (write procedure above) to standard
  115.      output too. 
  116.   *)
  117. PROCEDURE DebugOutputToggle ();
  118.  
  119. END scan.
  120.