home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cmdline.lha / cmdline / src / cmd / syntax.h < prev   
Encoding:
C/C++ Source or Header  |  1992-08-03  |  1.4 KB  |  63 lines

  1. //------------------------------------------------------------------------
  2. // ^FILE: syntax.h - define an object to represent the syntax of a
  3. //                   command-line argument.
  4. //
  5. // ^DESCRIPTION:
  6. //    This file defines an object that parses and records the syntax of
  7. //    a command-line argument.
  8. //
  9. // ^HISTORY:
  10. //    04/29/92    Brad Appleton    <brad@ssd.csd.harris.com>    Created
  11. //-^^---------------------------------------------------------------------
  12.  
  13. #ifndef _syntax_h
  14. #define _syntax_h
  15.  
  16. #include  "fsm.h"
  17.  
  18. class  istream;
  19. class  ArgSyntax {
  20. public:
  21.    ArgSyntax(void)
  22.       : arg_syntax(0), arg_char(0), arg_keyword(0), arg_value(0)
  23.       {}
  24.  
  25.       // Return the syntax flags
  26.    unsigned
  27.    syntax(void) const { return  arg_syntax; }
  28.  
  29.       // Return the option character
  30.    char
  31.    optchar(void) const { return  arg_char; }
  32.  
  33.       // Return the keyword name
  34.    const char *
  35.    keyword(void) const { return  arg_keyword; }
  36.  
  37.       // Return the value name
  38.    const char *
  39.    value(void) const { return  arg_value; }
  40.  
  41.       // Extract the syntax (compile it) from an input stream
  42.    friend  istream &
  43.    operator>>(istream & is, ArgSyntax & arg);
  44.  
  45. private:
  46.    unsigned     arg_syntax ;
  47.    char         arg_char;
  48.    const char * arg_keyword;
  49.    const char * arg_value;
  50.  
  51. private:
  52.    int
  53.    parse_syntax(const char * syntax);
  54.  
  55.    void
  56.    parse_value(const SyntaxFSM & fsm);
  57.  
  58.    istream &
  59.    parse_flag(istream & is);
  60. } ;
  61.  
  62. #endif  /* _syntax_h */
  63.