5 /* Copyright (C) 1995, 1996 Tom Lord
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Library General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this software; see the file COPYING. If not, write to
19 * the Free Software Foundation, 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
26 * Tom Lord (lord@cygnus.com, lord@gnu.ai.mit.edu)
37 r_cset = 0, /* Match from a character set. `a' or `[a-z]'*/
38 r_concat = 1, /* Concat two subexpressions. `ab' */
39 r_alternate = 2, /* Choose one of two subexpressions. `a\|b' */
40 r_opt = 3, /* Optional subexpression. `a?' */
41 r_star = 4, /* Repeated subexpression. `a*' */
42 r_plus = 5, /* Nontrivially repeated subexpression. `a+' */
43 r_string = 6, /* Shorthand for a concatenation of characters */
44 r_cut = 7, /* Generates a tagged, final nfa state. */
46 /* see RX_regular_node_type */
48 r_interval = 8, /* Counted subexpression. `a{4, 1000}' */
49 r_parens = 9, /* Parenthesized subexpression */
50 r_context = 10 /* Context-sensative operator such as "^" */
53 #define RX_regular_node_type(T) ((T) <= r_interval)
60 unsigned long reallen;
61 unsigned char *contents;
67 enum rexp_node_type type;
76 struct rexp_node *left;
77 struct rexp_node *right;
79 struct rx_string cstr;
84 struct rexp_node * simplified;
85 struct rx_cached_rexp * cr;
91 extern int rx_adjoin_string (struct rx_string *str, char c);
92 extern struct rexp_node * rexp_node (int type);
93 extern struct rexp_node * rx_mk_r_cset (int type, int size, rx_Bitset b);
94 extern struct rexp_node * rx_mk_r_int (int type, int intval);
95 extern struct rexp_node * rx_mk_r_str (int type, char c);
96 extern struct rexp_node * rx_mk_r_binop (int type, struct rexp_node * a, struct rexp_node * b);
97 extern struct rexp_node * rx_mk_r_monop (int type, struct rexp_node * a);
98 extern void rx_free_rexp (struct rexp_node * node);
99 extern void rx_save_rexp (struct rexp_node * node);
100 extern struct rexp_node * rx_copy_rexp (int cset_size, struct rexp_node *node);
101 extern struct rexp_node * rx_shallow_copy_rexp (int cset_size, struct rexp_node *node);
102 extern int rx_rexp_equal (struct rexp_node * a, struct rexp_node * b);
103 extern unsigned long rx_rexp_hash (struct rexp_node * node, unsigned long seed);
106 extern int rx_adjoin_string ();
107 extern struct rexp_node * rexp_node ();
108 extern struct rexp_node * rx_mk_r_cset ();
109 extern struct rexp_node * rx_mk_r_int ();
110 extern struct rexp_node * rx_mk_r_str ();
111 extern struct rexp_node * rx_mk_r_binop ();
112 extern struct rexp_node * rx_mk_r_monop ();
113 extern void rx_free_rexp ();
114 extern void rx_save_rexp ();
115 extern struct rexp_node * rx_copy_rexp ();
116 extern struct rexp_node * rx_shallow_copy_rexp ();
117 extern int rx_rexp_equal ();
118 extern unsigned long rx_rexp_hash ();