home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / turbopas / tlist.lbr / TLIST.PQS / tlist.pas
Encoding:
Pascal/Delphi Source File  |  1985-11-05  |  7.3 KB  |  170 lines

  1. PROGRAM Tlist;
  2. {
  3. Copyright 1985 by Thomas E. Croley II; all commercial rights reserved.
  4.  
  5. Written in TURBO PASCAL, Version 3.00A (CP/M-80, Z80), and released to the
  6. Public Domain 1 November 1985 by:
  7.  
  8.      Thomas E. Croley II
  9.      Great Lakes Environmental Research Laboratory
  10.      National Oceanic and Atmospheric Administration
  11.      U. S. Department of Commerce
  12.      2300 Washtenaw Avenue
  13.      Ann Arbor, Michigan  48104
  14.  
  15.      Text :  7400 bytes     (without INCLUDE files)
  16.      File : 18125 bytes     (CP/M-80 *.COM file size)
  17.      Code :  9962 bytes     (w/o TURBO v. 3.0 library)
  18.      Data :  2058 bytes
  19.  
  20. This program reads the file, supplied when invoked or when prompted for if not
  21. supplied when invoked, identifies 'reserved words', 'standard identifiers', and
  22. 'dedicated identifiers' used by TURBO PASCAL, and replaces them with
  23. 'highlighted' versions.  The "highlights" may consist of bold, double-strike,
  24. expanded print, and so on, as supported by the user's printer.  Upper case
  25. translation is also supported, if desired, as part of the highlight.  The
  26. highlights may be defined as WordStar-oriented and a disk file generated for
  27. printing with WordStar OR they may be printer-specific codes and the program
  28. output can be directed directly to the printer (CP/M's LST: device) or to a
  29. disk file.  The disk filename is formed from the source filename with the
  30. extension of 'PRN'.  Command line options are: direction of output to either a
  31. disk file or to the printer, pause for paper change, and starting page number;
  32. they are automatically documented if TLIST is invoked with no command line.
  33.  
  34. Include files are expanded in the printout but may not be nested (same as TURBO
  35. Pascal).  Reserved words within strings or comments (or any combination of
  36. strings and comments) are not highlighted.  Tabs are expanded should they be
  37. present in the source file (not usually found if the file was created with the
  38. TURBO editor).  A good test of this program's capability is to use it to TLIST
  39. itself!
  40.  
  41. This program can be changed easily to support additional reserved words,
  42. standard identifiers, or dedicated identifiers, or to change the highlighting
  43. to different forms among these groups, or to change the output page format,
  44. margin heading, or footer heading.  All these changes can be made within the
  45. "CONST" declaration sections following in this file.  Special notice also
  46. should be given to routine "User_ConIn" (found in include file MAIN.PAS), which
  47. is specific to the CP/M system, if adapting this program for use with other
  48. operating systems.
  49. }
  50.  
  51. CONST
  52.  Page_Length = 66;              {ala WordStar}
  53.  Margin_Top = 5;
  54.  Margin_Bottom = 5;
  55.  Header_Margin = 2;
  56.  Footer_Margin = 2;
  57.  Header_String                                          {OKIDATA Microline 84}
  58.   = ^]'TURBO PASCAL v. 3.00A, for'^['T CP/M-80, Z80 CPU'^['I,';
  59.  Footer_String = '';
  60.  Page_Offset = 13;
  61.  Line_Width = 82;
  62.  
  63.  Max_word_length = 10;          {maximum for all TURBO PASCAL words}
  64.  Max_no_of_accent_bytes = 5;
  65.  Max_new_word_length = 20;      {allows 5 control codes on each end of word}
  66.  
  67.  Max_line_length = 255;
  68.  No_Reserved_Words = 44;        {TURBO PASCAL, V 3.00A, CP/M-80, Z80}
  69.  No_Standard_Identifiers = 114; {TURBO PASCAL, V 3.00A, CP/M-80, Z80}
  70.  No_Dedicated_Identifiers = 6;  {TURBO PASCAL, V 3.00A, CP/M-80, Z80}
  71.  Max_Table_size = 114;
  72.  Filename_Length = 14;
  73.  
  74.  Res_Word_Hsh_size = 40;
  75.  Stan_Ident_Hsh_size = 100;
  76.  Ded_Ident_Hsh_size = 5;
  77.  Max_Hash_size = 100;
  78.  
  79. TYPE
  80.  Reserved_Word_Type = ARRAY[1..No_Reserved_Words] OF STRING[Max_word_length];
  81.  Standard_Identifier_Type
  82.   = ARRAY[1..No_Standard_Identifiers] OF STRING[Max_word_length];
  83.  Dedicated_Identifier_Type
  84.   = ARRAY[1..No_Dedicated_Identifiers] OF STRING[Max_word_length];
  85.  Symbol_Type = STRING[Max_new_word_length];
  86.  Line_Type = STRING[Max_line_length];  {allows min of 12 substitutions}
  87.  Accent_Type = STRING[Max_no_of_accent_bytes];
  88.  Filename_Type = STRING[Filename_Length];
  89.  
  90. CONST
  91.  Reserved_Word_ST : Reserved_Word_Type =
  92.  ('ABSOLUTE', 'AND', 'ARRAY', 'BEGIN', 'CASE', 'CONST', 'DIV', 'DO', 'DOWNTO',
  93.   'ELSE', 'END', 'EXTERNAL', 'FILE', 'FORWARD', 'FOR', 'FUNCTION', 'GOTO',
  94.   'INLINE', 'IF', 'IN', 'LABEL', 'MOD', 'NIL', 'NOT', 'OVERLAY', 'OF', 'OR',
  95.   'PACKED', 'PROCEDURE', 'PROGRAM', 'RECORD', 'REPEAT', 'SET', 'SHL', 'SHR',
  96.   'STRING', 'THEN', 'TYPE', 'TO', 'UNTIL', 'VAR', 'WHILE', 'WITH', 'XOR');
  97.  
  98.  Standard_Identifier_ST : Standard_Identifier_Type =
  99.  ('ADDR', 'ARCTAN', 'ASSIGN', 'AUX', 'AUXINPTR', 'AUXOUTPTR', 'BLOCKREAD',
  100.   'BLOCKWRITE', 'BOOLEAN', 'BUFLEN', 'BYTE', 'CHAIN', 'CHAR', 'CHR', 'CLOSE',
  101.   'CLREOL', 'CLRSCR', 'CON', 'CONINPTR', 'CONOUTPTR', 'CONCAT', 'CONSTPTR',
  102.   'COPY', 'COS', 'CRTEXIT', 'CRTINIT', 'DELLINE', 'DELAY', 'DELETE', 'EOF',
  103.   'EOLN', 'ERASE', 'EXECUTE', 'EXIT', 'EXP', 'FALSE', 'FILEPOS', 'FILESIZE',
  104.   'FILLCHAR', 'FLUSH', 'FRAC', 'GETMEM', 'GOTOXY', 'HALT', 'HEAPPTR', 'HI',
  105.   'IORESULT', 'INPUT', 'INSLINE', 'INSERT', 'INT', 'INTEGER', 'KBD',
  106.   'KEYPRESSED', 'LENGTH', 'LN', 'LO', 'LOWVIDEO', 'LST', 'LSTOUTPTR', 'MARK',
  107.   'MAXINT', 'MEM', 'MEMAVAIL', 'MOVE', 'NEW', 'NORMVIDEO', 'ODD', 'ORD',
  108.   'OUTPUT', 'PI', 'PORT', 'POS', 'PRED', 'PTR', 'RANDOM', 'RANDOMIZE', 'READ',
  109.   'READLN', 'REAL', 'RELEASE', 'RENAME', 'RESET', 'REWRITE', 'ROUND', 'SEEK',
  110.   'SIN', 'SIZEOF', 'SEEKEOF', 'SEEKEOLN', 'SQR', 'SQRT', 'STR', 'SUCC', 'SWAP',
  111.   'TEXT', 'TRM', 'TRUE', 'TRUNC', 'UPCASE', 'USR', 'USRINPTR', 'USROUTPTR',
  112.   'VAL', 'WRITE', 'WRITELN'
  113.  
  114.  ,'ABS', 'APPEND', 'DISPOSE', 'FREEMEM', 'MAXAVAIL',
  115.   'OVRDRIVE', 'PARAMCOUNT', 'PARAMSTR');
  116.  
  117.  Dedicated_Identifier_ST : Dedicated_Identifier_Type =
  118.  ('BIOS', 'BIOSHL', 'BDOS', 'BDOSHL', 'RECURPTR', 'STACKPTR'); {CP/M version}
  119.  
  120.  {Defaults for OKIDATA Microline 84  printer...}
  121.  Reserved_Word_Accent_begin : Accent_Type = ^['T';        {OKIDATA bold}
  122.  Reserved_Word_Accent_end : Accent_Type = ^['I';
  123.  Standard_Identifier_Accent_begin : Accent_Type = ^['T';  {OKIDATA bold}
  124.  Standard_Identifier_Accent_end : Accent_Type = ^['I';
  125.  Dedicated_Identifier_Accent_begin : Accent_Type = ^['T'; {OKIDATA bold}
  126.  Dedicated_Identifier_Accent_end : Accent_Type = ^['I';
  127.  
  128.  Reserved_Word_Upper_Case : BOOLEAN = TRUE;
  129.  Standard_Identifier_Upper_Case : BOOLEAN = TRUE;
  130.  Dedicated_Identifier_Upper_Case : BOOLEAN = TRUE;
  131.  
  132.  Header : STRING[100]
  133.   = 'TLISTer v1.0 by Thomas E. Croley II, 1-Nov-85  [^C Aborts]';
  134.  
  135. VAR
  136.  CmdLine : STRING[100] ABSOLUTE $80;
  137.  Reserved_Word_HT : ARRAY[1..Res_Word_Hsh_size] OF INTEGER;
  138.  Standard_Identifier_HT : ARRAY[1..Stan_Ident_Hsh_size] OF INTEGER;
  139.  Dedicated_Identifier_HT : ARRAY[1..Ded_Ident_Hsh_size] OF INTEGER;
  140.  
  141.  Reserved_Word_CT : ARRAY[1..No_Reserved_Words] OF INTEGER;
  142.  Standard_Identifier_CT : ARRAY[1..No_Standard_Identifiers] OF INTEGER;
  143.  Dedicated_Identifier_CT : ARRAY[1..No_Dedicated_Identifiers] OF INTEGER;
  144.  
  145.  Text_File, Include_File, List_file : TEXT;
  146.  Count, I, Dummy, Line_number, Page_number, Max_no_lines, LineCount,
  147.   Starting_page_number : INTEGER;
  148.  Symbol : Symbol_Type;
  149.  Include_file_name : Filename_Type;
  150.  Line : Line_Type;
  151.  Comment, Strng, Paginate, DiskFile, Found, Include_file_present,
  152.   Abort : BOOLEAN;
  153.  Ch : CHAR;
  154.  
  155. {$I HASHTBLS.PAS}
  156.  
  157. {$I SEARCHRE.PAS}
  158.  
  159. {$I SETUPHSH.PAS}
  160.  
  161. {$I EXPNDTAB.PAS}
  162.  
  163. {$I PARSER.PAS}
  164.  
  165. {$I INCLUDE.PAS}
  166.  
  167. {$I PROCLINE.PAS}
  168.  
  169. {$I MAIN.PAS}
  170.