Merge branch 'vendor/TCSH'
[dragonfly.git] / contrib / tre / lib / tre-parse.h
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 #include "xlocale_private.h"
13
14 /* Parse context. */
15 typedef struct {
16   /* Memory allocator.  The AST is allocated using this. */
17   tre_mem_t mem;
18   /* Stack used for keeping track of regexp syntax. */
19   tre_stack_t *stack;
20   /* The parse result. */
21   tre_ast_node_t *result;
22   /* The regexp to parse and its length. */
23   const tre_char_t *re;
24   /* The first character of the entire regexp. */
25   const tre_char_t *re_start;
26   /* The first character after the end of the regexp. */
27   const tre_char_t *re_end;
28   /* The current locale */
29   locale_t loc;
30   int len;
31   /* Current submatch ID. */
32   int submatch_id;
33   /* Current invisible submatch ID. */
34   int submatch_id_invisible;
35   /* Current position (number of literal). */
36   int position;
37   /* The highest back reference or -1 if none seen so far. */
38   int max_backref;
39   /* Number of tags that need reordering. */
40   int num_reorder_tags;
41   /* This flag is set if the regexp uses approximate matching. */
42   int have_approx;
43   /* Compilation flags. */
44   int cflags;
45   /* If this flag is set the top-level submatch is not captured. */
46   int nofirstsub;
47   /* The currently set approximate matching parameters. */
48   int params[TRE_PARAM_LAST];
49 } tre_parse_ctx_t;
50
51 /* Parses a wide character regexp pattern into a syntax tree.  This parser
52    handles both syntaxes (BRE and ERE), including the TRE extensions. */
53 reg_errcode_t
54 tre_parse(tre_parse_ctx_t *ctx);
55
56 #endif /* TRE_PARSE_H */
57
58 /* EOF */