1 /* Copyright (C) 1995, 1996 Tom Lord
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU Library General Public License as published by
5 * the Free Software Foundation; either version 2, or (at your option)
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Library General Public License for more details.
13 * You should have received a copy of the GNU Library General Public License
14 * along with this software; see the file COPYING. If not, write to
15 * the Free Software Foundation, 59 Temple Place - Suite 330,
16 * Boston, MA 02111-1307, USA.
23 #include "rxgnucomp.h"
27 #ifdef HAVE_POSITIONAL_ARRAY_INITS
34 char *node_type_names[] =
37 AT(r_concat) "r_concat",
38 AT(r_alternate) "r_alternate",
42 AT(r_string) "r_string",
45 AT(r_interval) "r_interval",
46 AT(r_parens) "r_parens",
47 AT(r_context) "r_context"
51 print_cset (cset_size, cs)
61 for (x = 0; x < cset_size; ++x)
62 if (RX_bitset_member (cs, x))
74 print_string(struct rx_string *s, char bracket)
83 for (x = 0; x < s->len; ++x)
84 if (isprint(s->contents[x]))
85 putchar (s->contents[x]);
102 print_rexp (cset_size, indent, rexp)
105 struct rexp_node * rexp;
112 printf ("Node %d type %d (%s), iv=%d(%c), iv2=%d, len=%d obs=%d cs=",
113 rexp->id, rexp->type, node_type_names[rexp->type],
115 (isprint (rexp->params.intval)
116 ? rexp->params.intval
118 rexp->params.intval2,
121 print_cset (cset_size, rexp->params.cset);
123 print_string (&(rexp->params.cstr), 1);
125 if (rexp->params.pair.left || rexp->params.pair.right)
127 print_rexp (cset_size, indent + 2, rexp->params.pair.left);
128 print_rexp (cset_size, indent + 2, rexp->params.pair.right);
137 unparse_print_rexp (cset_size, rexp)
139 struct rexp_node * rexp;
147 if (1 != rx_bitset_population (cset_size, rexp->params.cset))
148 print_cset (cset_size, rexp->params.cset);
154 cs = rexp->params.cset;
155 for (x = 0; x < cset_size; ++x)
156 if (RX_bitset_member (cs, x))
161 printf ("\\0%o ", x);
167 print_string (&(rexp->params.cstr), 0);
172 unparse_print_rexp (cset_size, rexp->params.pair.left);
178 putchar (rexp->params.intval);
182 printf ("[[:cut %d:]]", rexp->params.intval);
186 unparse_print_rexp (cset_size, rexp->params.pair.left);
187 unparse_print_rexp (cset_size, rexp->params.pair.right);
191 unparse_print_rexp (cset_size, rexp->params.pair.left);
193 unparse_print_rexp (cset_size, rexp->params.pair.right);
197 unparse_print_rexp (cset_size, rexp->params.pair.left);
202 unparse_print_rexp (cset_size, rexp->params.pair.left);
207 unparse_print_rexp (cset_size, rexp->params.pair.left);
212 unparse_print_rexp (cset_size, rexp->params.pair.left);
213 printf ("{%d,%d}", rexp->params.intval, rexp->params.intval2);
220 print_nfa_state (rx, state)
222 struct rx_nfa_state * state;
224 struct rx_nfa_edge * e;
225 printf ("state %d, is_final %d, is_start %d\n",
226 state->id, state->is_final, state->is_start);
227 for (e = state->edges; e; e = e->next)
229 printf ("\tEdge %s to %d ",
232 : (e->type == ne_epsilon
236 if (e->type == ne_cset)
237 print_cset (rx->local_cset_size, e->params.cset);
239 printf ("%d", (int)e->params.side_effect);
248 struct rx_nfa_state * state;
249 for (state = rx->nfa_states; state; state = state->next)
250 print_nfa_state (rx, state);