| 2115 | Parse the regular expression REGEXP and return the structure tree. |
| 2116 | If an error has occurred, ERR is set by error code, and return NULL. |
| 2117 | This function build the following tree, from regular expression <reg_exp>: |
| 2118 | CAT |
| 2119 | / \ |
| 2120 | / \ |
| 2121 | <reg_exp> EOR |
| 2122 | |
| 2123 | CAT means concatenation. |
| 2124 | EOR means end of regular expression. */ |
| 2125 | |
| 2126 | static bin_tree_t * |
| 2127 | parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax, |
| 2128 | reg_errcode_t *err) |
| 2129 | { |
| 2130 | re_dfa_t *dfa = (re_dfa_t *) preg->buffer; |
| 2131 | bin_tree_t *tree, *eor, *root; |
| 2132 | re_token_t current_token; |
| 2133 | dfa->syntax = syntax; |
| 2134 | fetch_token (¤t_token, regexp, syntax | RE_CARET_ANCHORS_HERE); |
| 2135 | tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err); |
| 2136 | if (BE (*err != REG_NOERROR && tree == NULL, 0)) |
| 2137 | return NULL; |
| 2138 | eor = create_tree (dfa, NULL, NULL, END_OF_RE); |
| 2139 | if (tree != NULL) |
| 2140 | root = create_tree (dfa, tree, eor, CONCAT); |
| 2141 | else |
| 2142 | root = eor; |
| 2143 | if (BE (eor == NULL || root == NULL, 0)) |
no test coverage detected