home *** CD-ROM | disk | FTP | other *** search
- (*---------------------------------------------------------------------*)
- (* Unit: CLPARSER (formerly PARSER) Command_Line_Parser *)
- (* *)
- (* Description: CLParser provides access to the command line switches *)
- (* and arguments by parsing them into individual lists. *)
- (* Parameter file parsing is also included. *)
- (* *)
- (* Modification History: *)
- (* *)
- (* PARSER 04/07/89 Version 1.0 *)
- (* Turbo Pascal v4.0, v5.0 *)
- (* *)
- (* OPARSER 04/14/89 Version 1.1 (TEST OOPS style OBJECT unit) *)
- (* Turbo Pascal v4.0, v5.0 *)
- (* *)
- (* Modified to more closely conform to an *)
- (* OBJECT style programming module. *)
- (* *)
- (* INFORMATION HIDING was implemented by *)
- (* removing the data structure from the *)
- (* interface part of the unit. Procedures *)
- (* were then added to access the structure. *)
- (* *)
- (* DATA ABSTRACTION was implemented by *)
- (* insuring that all PARSER variables and *)
- (* constants were available only through *)
- (* function calls (see above). *)
- (* *)
- (* DYNAMIC BINDING was implemented with the *)
- (* enumerated type PARSER_CLASSES. The *)
- (* caller passes the defined instance class *)
- (* as a named-parameter in the function. This *)
- (* implementation is limited by deficiencies *)
- (* in PASCAL. *)
- (* *)
- (* INHERITANCE is not possible in PASCAL *)
- (* without language improvements, and so no *)
- (* attempt was made to provide it. *)
- (* *)
- (* CLPARSER 06/26/89 Version 2.0 (OOPS OBJECT unit) *)
- (* Turbo Pascal v5.5 *)
- (* *)
- (* Borland's TP v5.5 now supports OOP in *)
- (* PASCAL. Check it out. *)
- (* *)
- (* Altered the functionality of the unit by *)
- (* changing the list from strings to pointers *)
- (* and providing means to free the memory *)
- (* used by the object. (destructors) *)
- (* *)
- (* Added wildcard file list function by *)
- (* using INHERITANCE. Added the INIT method *)
- (* required for wildcards and made the *)
- (* object smart-linkable by excluding it from *)
- (* the INITIALIZATION procedure. *)
- (* *)
- (* CLPARSER 07/26/89 Version 2.1 *)
- (* Turbo Pascal v5.5 *)
- (* *)
- (* Fixed a bug in the Argument.Find method *)
- (* that allowed a target string longer than *)
- (* the item string to match if the first *)
- (* part of the target matched the item. *)
- (* *)
- (* Added the PFile type. This is a parameter *)
- (* file parser that fills the list with *)
- (* valid parameters from the file. Comments *)
- (* are definable and skipped. White space *)
- (* (tabs, spaces and blank lines) is ignored, *)
- (* also. *)
- (* *)
- (* This is the first version released to *)
- (* bulletin boards. *)
- (* *)
- (* (c)1989 by Greg L. Truesdell *)
- (*---------------------------------------------------------------------*)
-
- Unit CLParser;
-
- INTERFACE
-
- const
- CLPARSE_MAXITEMS = 1024; { maximum number of switches or arguments }
- VERSION = 'CLPARSER v2.1 (c)1989 GL Truesdell';
-
- type
- CharSet = set of char;
-
- { list is the data structure }
- List = object
- { pointers to variable length strings}
- item : array [1..CLPARSE_MAXITEMS] of ^String;
- { position of item on command line }
- posn : array [1..CLPARSE_MAXITEMS] of word;
- items, index : word;
-
- constructor Init;
- destructor Erase; virtual;
- function Add( add_item: string; locn: byte ): boolean; virtual;
- function Next: String; virtual;
- function Prev: String; virtual;
- function Count: word; virtual;
- function Position: word; virtual;
- procedure Reset; virtual;
- end;
-
- { argument is a list of arguments }
- Argument = object(List)
- more: boolean;
- constructor Init( LegalChars: CharSet );
- function Find( target : string ): string; virtual;
- function Overflow: boolean; virtual;
- end;
-
- { switch is a list of switch arguments }
- Switch = object(Argument) end;
-
- { Environ is a list of environment variables }
- Environ = object(Argument)
- constructor Init;
- end;
-
- { wild is a special list of filenames }
- Wild = object(argument)
- constructor Init( filemask: string; attributes: word );
- end;
-
- { pfile is a special list of parameter file entries }
- PFile = object(argument)
- constructor Init( filename: string; comment: CharSet );
- end;
-
- var
- Parse_Argument : argument; { list of command line arguments }
- Parse_Switch : switch; { list of command line switches }
- Parse_Wild : wild; { list of filenames matching a wild card }
- Parse_Environ : Environ; { list of all environment variables }
- Parse_File : PFile; { list of parameters from text file }
-
-
- IMPLEMENTATION
-
-