00001 #line 8778 "./lpsrc/tre.pak" 00002 /* 00003 tre-parse.c - Regexp parser definitions 00004 00005 Copyright (C) 2001-2004 Ville Laurikari <vl@iki.fi> 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License version 2 (June 00009 1991) as published by the Free Software Foundation. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 00021 #ifndef TRE_PARSE_H 00022 #define TRE_PARSE_H 1 00023 00024 /* Parse context. */ 00025 typedef struct { 00026 /* Memory allocator. The AST is allocated using this. */ 00027 tre_mem_t mem; 00028 /* Stack used for keeping track of regexp syntax. */ 00029 tre_stack_t *stack; 00030 /* The parse result. */ 00031 tre_ast_node_t *result; 00032 /* The regexp to parse and its length. */ 00033 const tre_char_t *re; 00034 /* The first character of the entire regexp. */ 00035 const tre_char_t *re_start; 00036 /* The first character after the end of the regexp. */ 00037 const tre_char_t *re_end; 00038 int len; 00039 /* Current submatch ID. */ 00040 int submatch_id; 00041 /* Current position (number of literal). */ 00042 int position; 00043 /* The highest back reference or -1 if none seen so far. */ 00044 int max_backref; 00045 /* This flag is set if the regexp uses approximate matching. */ 00046 int have_approx; 00047 /* Compilation flags. */ 00048 int cflags; 00049 /* If this flag is set the top-level submatch is not captured. */ 00050 int nofirstsub; 00051 /* The currently set approximate matching parameters. */ 00052 int params[TRE_PARAM_LAST]; 00053 } tre_parse_ctx_t; 00054 00055 /* Parses a wide character regexp pattern into a syntax tree. This parser 00056 handles both syntaxes (BRE and ERE), including the TRE extensions. */ 00057 reg_errcode_t 00058 tre_parse(tre_parse_ctx_t *ctx); 00059 00060 #endif /* TRE_PARSE_H */ 00061 00062 /* EOF */