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