1 /*
2   tre-parse.c - Regexp parser definitions
3 
4   Copyright (c) 2001-2006 Ville Laurikari <vl@iki.fi>
5 
6   This library is free software; you can redistribute it and/or
7   modify it under the terms of the GNU Lesser General Public
8   License as published by the Free Software Foundation; either
9   version 2.1 of the License, or (at your option) any later version.
10 
11   This library is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   Lesser General Public License for more details.
15 
16   You should have received a copy of the GNU Lesser General Public
17   License along with this library; if not, write to the Free Software
18   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 
20 */
21 
22 #ifndef TRE_PARSE_H
23 #define TRE_PARSE_H 1
24 
25 /* Parse context. */
26 typedef struct {
27   /* Memory allocator.	The AST is allocated using this. */
28   tre_mem_t mem;
29   /* Stack used for keeping track of regexp syntax. */
30   tre_stack_t *stack;
31   /* The parse result. */
32   tre_ast_node_t *result;
33   /* The regexp to parse and its length. */
34   const tre_char_t *re;
35   /* The first character of the entire regexp. */
36   const tre_char_t *re_start;
37   /* The first character after the end of the regexp. */
38   const tre_char_t *re_end;
39   int len;
40   /* Current submatch ID. */
41   int submatch_id;
42   /* Current position (number of literal). */
43   int position;
44   /* The highest back reference or -1 if none seen so far. */
45   int max_backref;
46   /* This flag is set if the regexp uses approximate matching. */
47   int have_approx;
48   /* Compilation flags. */
49   int cflags;
50   /* If this flag is set the top-level submatch is not captured. */
51   int nofirstsub;
52   /* The currently set approximate matching parameters. */
53   int params[TRE_PARAM_LAST];
54 } tre_parse_ctx_t;
55 
56 /* Parses a wide character regexp pattern into a syntax tree.  This parser
57    handles both syntaxes (BRE and ERE), including the TRE extensions. */
58 reg_errcode_t
59 tre_parse(tre_parse_ctx_t *ctx);
60 
61 #endif /* TRE_PARSE_H */
62 
63 /* EOF */
64