]>
jfr.im git - irc/evilnet/x3.git/blob - rx/rxsimp.c
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.
27 /* Could reasonably hashcons instead of in rxunfa.c */
31 rx_simple_rexp (struct rexp_node
** answer
,
33 struct rexp_node
*node
,
34 struct rexp_node
** subexps
)
37 rx_simple_rexp (answer
, cset_size
, node
, subexps
)
38 struct rexp_node
** answer
;
40 struct rexp_node
*node
;
41 struct rexp_node
** subexps
;
61 rx_save_rexp (node
->simplified
);
62 *answer
= node
->simplified
;
72 return -2; /* an internal error, really */
75 stat
= rx_simple_rexp (answer
, cset_size
,
76 node
->params
.pair
.left
,
81 if (isdigit (node
->params
.intval
))
82 stat
= rx_simple_rexp (answer
, cset_size
,
83 subexps
[node
->params
.intval
- '0'],
100 n
= rexp_node (node
->type
);
104 if (node
->params
.cset
)
106 n
->params
.cset
= rx_copy_cset (cset_size
,
114 n
->params
.intval
= node
->params
.intval
;
115 n
->params
.intval2
= node
->params
.intval2
;
119 s
= rx_simple_rexp (&n
->params
.pair
.left
, cset_size
,
120 node
->params
.pair
.left
, subexps
);
122 s
= rx_simple_rexp (&n
->params
.pair
.right
, cset_size
,
123 node
->params
.pair
.right
, subexps
);
141 node
->simplified
= *answer
;
142 rx_save_rexp (node
->simplified
);