home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / comline / clparse / clparser.hdr < prev    next >
Encoding:
Text File  |  1989-12-18  |  7.3 KB  |  143 lines

  1. (*---------------------------------------------------------------------*)
  2. (*  Unit: CLPARSER (formerly PARSER) Command_Line_Parser               *)
  3. (*                                                                     *)
  4. (*  Description: CLParser provides access to the command line switches *)
  5. (*               and arguments by parsing them into individual lists.  *)
  6. (*               Parameter file parsing is also included.              *)
  7. (*                                                                     *)
  8. (*  Modification History:                                              *)
  9. (*                                                                     *)
  10. (*    PARSER     04/07/89   Version 1.0                                *)
  11. (*                          Turbo Pascal v4.0, v5.0                    *)
  12. (*                                                                     *)
  13. (*    OPARSER    04/14/89   Version 1.1  (TEST OOPS style OBJECT unit) *)
  14. (*                          Turbo Pascal v4.0, v5.0                    *)
  15. (*                                                                     *)
  16. (*                          Modified to more closely conform to an     *)
  17. (*                          OBJECT style programming module.           *)
  18. (*                                                                     *)
  19. (*                          INFORMATION HIDING was implemented by      *)
  20. (*                          removing the data structure from the       *)
  21. (*                          interface part of the unit.  Procedures    *)
  22. (*                          were then added to access the structure.   *)
  23. (*                                                                     *)
  24. (*                          DATA ABSTRACTION was implemented by        *)
  25. (*                          insuring that all PARSER variables and     *)
  26. (*                          constants were available only through      *)
  27. (*                          function calls (see above).                *)
  28. (*                                                                     *)
  29. (*                          DYNAMIC BINDING was implemented with the   *)
  30. (*                          enumerated type PARSER_CLASSES.  The       *)
  31. (*                          caller passes the defined instance class   *)
  32. (*                          as a named-parameter in the function. This *)
  33. (*                          implementation is limited by deficiencies  *)
  34. (*                          in PASCAL.                                 *)
  35. (*                                                                     *)
  36. (*                          INHERITANCE is not possible in PASCAL      *)
  37. (*                          without language improvements, and so no   *)
  38. (*                          attempt was made to provide it.            *)
  39. (*                                                                     *)
  40. (*    CLPARSER   06/26/89   Version 2.0  (OOPS OBJECT unit)            *)
  41. (*                          Turbo Pascal v5.5                          *)
  42. (*                                                                     *)
  43. (*                          Borland's TP v5.5 now supports OOP in      *)
  44. (*                          PASCAL. Check it out.                      *)
  45. (*                                                                     *)
  46. (*                          Altered the functionality of the unit by   *)
  47. (*                          changing the list from strings to pointers *)
  48. (*                          and providing means to free the memory     *)
  49. (*                          used by the object.  (destructors)         *)
  50. (*                                                                     *)
  51. (*                          Added wildcard file list function by       *)
  52. (*                          using INHERITANCE.  Added the INIT method  *)
  53. (*                          required for wildcards and made the        *)
  54. (*                          object smart-linkable by excluding it from *)
  55. (*                          the INITIALIZATION procedure.              *)
  56. (*                                                                     *)
  57. (*    CLPARSER   07/26/89   Version 2.1                                *)
  58. (*                          Turbo Pascal v5.5                          *)
  59. (*                                                                     *)
  60. (*                          Fixed a bug in the Argument.Find method    *)
  61. (*                          that allowed a target string longer than   *)
  62. (*                          the item string to match if the first      *)
  63. (*                          part of the target matched the item.       *)
  64. (*                                                                     *)
  65. (*                          Added the PFile type.  This is a parameter *)
  66. (*                          file parser that fills the list with       *)
  67. (*                          valid parameters from the file. Comments   *)
  68. (*                          are definable and skipped.  White space    *)
  69. (*                          (tabs, spaces and blank lines) is ignored, *)
  70. (*                          also.                                      *)
  71. (*                                                                     *)
  72. (*                          This is the first version released to      *)
  73. (*                          bulletin boards.                           *)
  74. (*                                                                     *)
  75. (*  (c)1989 by Greg L. Truesdell                                       *)
  76. (*---------------------------------------------------------------------*)
  77.  
  78. Unit CLParser;
  79.  
  80. INTERFACE
  81.  
  82. const
  83.     CLPARSE_MAXITEMS = 1024;  { maximum number of switches or arguments }
  84.     VERSION = 'CLPARSER v2.1 (c)1989 GL Truesdell';
  85.  
  86. type
  87.     CharSet = set of char;
  88.  
  89.     { list is the data structure }
  90.     List = object
  91.         { pointers to variable length strings}
  92.         item : array [1..CLPARSE_MAXITEMS] of ^String;
  93.         { position of item on command line }
  94.         posn : array [1..CLPARSE_MAXITEMS] of word;
  95.         items, index : word;
  96.  
  97.         constructor Init;
  98.         destructor Erase; virtual;
  99.         function Add( add_item: string; locn: byte ): boolean; virtual;
  100.         function Next: String; virtual;
  101.         function Prev: String; virtual;
  102.         function Count: word; virtual;
  103.         function Position: word; virtual;
  104.         procedure Reset; virtual;
  105.     end;
  106.  
  107.     { argument is a list of arguments }
  108.     Argument = object(List)
  109.         more: boolean;
  110.         constructor Init( LegalChars: CharSet );
  111.         function Find( target : string ): string; virtual;
  112.         function Overflow: boolean; virtual;
  113.     end;
  114.  
  115.     { switch is a list of switch arguments }
  116.     Switch = object(Argument) end;
  117.  
  118.     { Environ is a list of environment variables }
  119.     Environ = object(Argument)
  120.         constructor Init;
  121.     end;
  122.  
  123.     { wild is a special list of filenames }
  124.     Wild = object(argument)
  125.         constructor Init( filemask: string; attributes: word );
  126.     end;
  127.  
  128.     { pfile is a special list of parameter file entries }
  129.     PFile = object(argument)
  130.         constructor Init( filename: string; comment: CharSet );
  131.     end;
  132.  
  133. var
  134.     Parse_Argument : argument;  { list of command line arguments }
  135.     Parse_Switch   : switch;    { list of command line switches }
  136.     Parse_Wild     : wild;      { list of filenames matching a wild card }
  137.     Parse_Environ  : Environ;   { list of all environment variables }
  138.     Parse_File     : PFile;     { list of parameters from text file }
  139.  
  140.  
  141. IMPLEMENTATION
  142.  
  143.