| 2190 | } |
| 2191 | |
| 2192 | /* This function build the following tree, from regular expression |
| 2193 | <exp1><exp2>: |
| 2194 | CAT |
| 2195 | / \ |
| 2196 | / \ |
| 2197 | <exp1> <exp2> |
| 2198 | |
| 2199 | CAT means concatenation. */ |
| 2200 | |
| 2201 | static bin_tree_t * |
| 2202 | parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token, |
| 2203 | reg_syntax_t syntax, int nest, reg_errcode_t *err) |
| 2204 | { |
| 2205 | bin_tree_t *tree, *exp; |
| 2206 | re_dfa_t *dfa = (re_dfa_t *) preg->buffer; |
| 2207 | tree = parse_expression (regexp, preg, token, syntax, nest, err); |
| 2208 | if (BE (*err != REG_NOERROR && tree == NULL, 0)) |
| 2209 | return NULL; |
| 2210 | |
| 2211 | while (token->type != OP_ALT && token->type != END_OF_RE |
| 2212 | && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) |
| 2213 | { |
| 2214 | exp = parse_expression (regexp, preg, token, syntax, nest, err); |
| 2215 | if (BE (*err != REG_NOERROR && exp == NULL, 0)) |
| 2216 | { |
| 2217 | return NULL; |
| 2218 | } |
| 2219 | if (tree != NULL && exp != NULL) |
| 2220 | { |
| 2221 | tree = create_tree (dfa, tree, exp, CONCAT); |
| 2222 | if (tree == NULL) |
| 2223 | { |
| 2224 | *err = REG_ESPACE; |
| 2225 | return NULL; |
| 2226 | } |
| 2227 | } |
no test coverage detected