Home | History | Annotate | Line # | Download | only in lib
      1 /*
      2   tre-parse.c - Regexp parser definitions
      3 
      4   This software is released under a BSD-style license.
      5   See the file LICENSE for details and copyright.
      6 
      7 */
      8 
      9 #ifndef TRE_PARSE_H
     10 #define TRE_PARSE_H 1
     11 
     12 /* Parse context. */
     13 typedef struct {
     14   /* Memory allocator.	The AST is allocated using this. */
     15   tre_mem_t mem;
     16   /* Stack used for keeping track of regexp syntax. */
     17   tre_stack_t *stack;
     18   /* The parse result. */
     19   tre_ast_node_t *result;
     20   /* The regexp to parse and its length. */
     21   const tre_char_t *re;
     22   /* The first character of the entire regexp. */
     23   const tre_char_t *re_start;
     24   /* The first character after the end of the regexp. */
     25   const tre_char_t *re_end;
     26   size_t len;
     27   /* Current submatch ID. */
     28   int submatch_id;
     29   /* Current position (number of literal). */
     30   int position;
     31   /* The highest back reference or -1 if none seen so far. */
     32   int max_backref;
     33   /* This flag is set if the regexp uses approximate matching. */
     34   int have_approx;
     35   /* Compilation flags. */
     36   int cflags;
     37   /* If this flag is set the top-level submatch is not captured. */
     38   int nofirstsub;
     39   /* The currently set approximate matching parameters. */
     40   int params[TRE_PARAM_LAST];
     41   /* the CUR_MAX in use */
     42   int cur_max;
     43 } tre_parse_ctx_t;
     44 
     45 /* Parses a wide character regexp pattern into a syntax tree.  This parser
     46    handles both syntaxes (BRE and ERE), including the TRE extensions. */
     47 reg_errcode_t
     48 tre_parse(tre_parse_ctx_t *ctx);
     49 
     50 #endif /* TRE_PARSE_H */
     51 
     52 /* EOF */
     53