home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume36 / unpost / part07 / regexp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-18  |  2.6 KB  |  65 lines

  1. /******************************************************************************
  2. * Module    :   Regular Expression String Matching --- Defines, typedefs and
  3. *               function prototypes.
  4. *
  5. * Author    :   John Stevens
  6. ******************************************************************************/
  7.  
  8. #if ! defined(REGULAR_EXPRESSION_HEADER_FILE)
  9. #define     REGULAR_EXPRESSION_HEADER_FILE
  10.  
  11. #include    "sets.h"
  12.  
  13. /*  Define the maximum number of sub-expressions supported. */
  14. #define MAX_SUB_EXPRS   20
  15.  
  16. /*  Flags for case sensitivity in string compares.  */
  17. typedef enum    {
  18.     CASE_SENSITIVE,
  19.     IGN_CASE
  20. } CASE_CMP;
  21.  
  22. /*  Type of regular expression node in expression tree. */
  23. typedef enum    {
  24.     NODE_TYPE_NOT_SET,
  25.     OP_ENUM,                /*  Enumeration operator.       */
  26.     OP_OR,                  /*  Alternation operator.       */
  27.     OP_AND,                 /*  Catenation operator.        */
  28.     OP_L_PAREN,             /*  Parentheses.                */
  29.     OP_R_PAREN,             /*  Right parentheses.          */
  30.     END_OR,                 /*  End alternation.            */
  31.     END_ENUM,               /*  End enumeration.            */
  32.     DATA_LEFT_ANCHOR,       /*  Anchor left side.           */
  33.     DATA_RIGHT_ANCHOR,      /*  Anchor right side.          */
  34.     DATA_ANY,               /*  Any single character.       */
  35.     DATA_SPAN,              /*  Match any character.        */
  36.     DATA_STRING,            /*  String data node.           */
  37.     DATA_SET                /*  Set data node.              */
  38. } NODE_TYPE;
  39.  
  40. /*  Type definition for regular expression node in expression tree. */
  41. typedef struct  reg_exp_st
  42. {
  43.     NODE_TYPE           NodeType;   /*  Node type, operator or data.    */
  44.     struct  reg_exp_st  *Left;      /*  Expression tree pointers.       */
  45.     struct  reg_exp_st  *Right;
  46.     unsigned int        MinSpan;    /*  Minimum span.                   */
  47.     unsigned int        MaxSpan;    /*  Maximum span.                   */
  48.     unsigned int        SubExprNo;  /*  Sub-expression number.          */
  49.     union
  50.     {
  51.         char        *MatchStr;      /*  String to match against.        */
  52.         SET_TYPE    *CSet;          /*  Character set to match against. */
  53.     } data;
  54. } REG_EXP_NODE;
  55.  
  56. /*  Function prototypes.    */
  57. extern  REG_EXP_NODE    *ReCompile(char *);
  58. extern  int             ReMatch(char            *Str,
  59.                                 CASE_CMP        Case,
  60.                                 REG_EXP_NODE    *ReExpr,
  61.                                 char            ***SubStrs);
  62. extern  REG_EXP_NODE    *FreeReExpr(REG_EXP_NODE    *ReExpr);
  63.  
  64. #endif
  65.