Lines Matching refs:token
59 static Idx fetch_number (re_string_t *input, re_token_t *token,
61 static int peek_token (re_token_t *token, re_string_t *input,
66 re_token_t *token, reg_syntax_t syntax,
69 re_token_t *token, reg_syntax_t syntax,
72 re_token_t *token, reg_syntax_t syntax,
75 re_token_t *token, reg_syntax_t syntax,
78 re_dfa_t *dfa, re_token_t *token,
81 re_token_t *token, reg_syntax_t syntax,
85 re_token_t *token, int token_len,
91 re_token_t *token);
121 const re_token_t *token);
1295 if (node->token.type == OP_BACK_REF && dfa->subexp_map) in optimize_subexps()
1297 int idx = node->token.opr.idx; in optimize_subexps()
1298 node->token.opr.idx = dfa->subexp_map[idx]; in optimize_subexps()
1299 dfa->used_bkref_map |= 1 << node->token.opr.idx; in optimize_subexps()
1302 else if (node->token.type == SUBEXP in optimize_subexps()
1303 && node->left && node->left->token.type == SUBEXP) in optimize_subexps()
1305 Idx other_idx = node->left->token.opr.idx; in optimize_subexps()
1311 dfa->subexp_map[other_idx] = dfa->subexp_map[node->token.opr.idx]; in optimize_subexps()
1327 if (node->left && node->left->token.type == SUBEXP) in lower_subexps()
1333 if (node->right && node->right->token.type == SUBEXP) in lower_subexps()
1356 && (node->token.opr.idx >= BITSET_WORD_BITS in lower_subexp()
1358 & ((bitset_word_t) 1 << node->token.opr.idx)))) in lower_subexp()
1374 op->token.opr.idx = cls->token.opr.idx = node->token.opr.idx; in lower_subexp()
1375 op->token.opt_subexp = cls->token.opt_subexp = node->token.opt_subexp; in lower_subexp()
1385 if (node->token.type == CONCAT) in calc_first()
1393 node->node_idx = re_dfa_add_node (dfa, node->token); in calc_first()
1396 if (node->token.type == ANCHOR) in calc_first()
1397 dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type; in calc_first()
1406 switch (node->token.type) in calc_next()
1433 switch (node->token.type) in link_nfa_nodes()
1469 if (node->token.type == OP_BACK_REF) in link_nfa_nodes()
1474 DEBUG_ASSERT (!IS_EPSILON_NODE (node->token.type)); in link_nfa_nodes()
1781 peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) in peek_token() argument
1787 token->type = END_OF_RE; in peek_token()
1792 token->opr.c = c; in peek_token()
1794 token->word_char = 0; in peek_token()
1796 token->mb_partial = 0; in peek_token()
1800 token->type = CHARACTER; in peek_token()
1801 token->mb_partial = 1; in peek_token()
1810 token->type = BACK_SLASH; in peek_token()
1815 token->opr.c = c2; in peek_token()
1816 token->type = CHARACTER; in peek_token()
1822 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; in peek_token()
1826 token->word_char = IS_WORD_CHAR (c2) != 0; in peek_token()
1832 token->type = OP_ALT; in peek_token()
1838 token->type = OP_BACK_REF; in peek_token()
1839 token->opr.idx = c2 - '1'; in peek_token()
1845 token->type = ANCHOR; in peek_token()
1846 token->opr.ctx_type = WORD_FIRST; in peek_token()
1852 token->type = ANCHOR; in peek_token()
1853 token->opr.ctx_type = WORD_LAST; in peek_token()
1859 token->type = ANCHOR; in peek_token()
1860 token->opr.ctx_type = WORD_DELIM; in peek_token()
1866 token->type = ANCHOR; in peek_token()
1867 token->opr.ctx_type = NOT_WORD_DELIM; in peek_token()
1872 token->type = OP_WORD; in peek_token()
1876 token->type = OP_NOTWORD; in peek_token()
1880 token->type = OP_SPACE; in peek_token()
1884 token->type = OP_NOTSPACE; in peek_token()
1889 token->type = ANCHOR; in peek_token()
1890 token->opr.ctx_type = BUF_FIRST; in peek_token()
1896 token->type = ANCHOR; in peek_token()
1897 token->opr.ctx_type = BUF_LAST; in peek_token()
1902 token->type = OP_OPEN_SUBEXP; in peek_token()
1906 token->type = OP_CLOSE_SUBEXP; in peek_token()
1910 token->type = OP_DUP_PLUS; in peek_token()
1914 token->type = OP_DUP_QUESTION; in peek_token()
1918 token->type = OP_OPEN_DUP_NUM; in peek_token()
1922 token->type = OP_CLOSE_DUP_NUM; in peek_token()
1930 token->type = CHARACTER; in peek_token()
1935 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; in peek_token()
1939 token->word_char = IS_WORD_CHAR (token->opr.c); in peek_token()
1945 token->type = OP_ALT; in peek_token()
1949 token->type = OP_ALT; in peek_token()
1952 token->type = OP_DUP_ASTERISK; in peek_token()
1956 token->type = OP_DUP_PLUS; in peek_token()
1960 token->type = OP_DUP_QUESTION; in peek_token()
1964 token->type = OP_OPEN_DUP_NUM; in peek_token()
1968 token->type = OP_CLOSE_DUP_NUM; in peek_token()
1972 token->type = OP_OPEN_SUBEXP; in peek_token()
1976 token->type = OP_CLOSE_SUBEXP; in peek_token()
1979 token->type = OP_OPEN_BRACKET; in peek_token()
1982 token->type = OP_PERIOD; in peek_token()
1992 token->type = ANCHOR; in peek_token()
1993 token->opr.ctx_type = LINE_FIRST; in peek_token()
2006 token->type = ANCHOR; in peek_token()
2007 token->opr.ctx_type = LINE_LAST; in peek_token()
2019 peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax) in peek_token_bracket() argument
2024 token->type = END_OF_RE; in peek_token_bracket()
2028 token->opr.c = c; in peek_token_bracket()
2034 token->type = CHARACTER; in peek_token_bracket()
2046 token->opr.c = c2; in peek_token_bracket()
2047 token->type = CHARACTER; in peek_token_bracket()
2058 token->opr.c = c2; in peek_token_bracket()
2063 token->type = OP_OPEN_COLL_ELEM; in peek_token_bracket()
2067 token->type = OP_OPEN_EQUIV_CLASS; in peek_token_bracket()
2073 token->type = OP_OPEN_CHAR_CLASS; in peek_token_bracket()
2078 token->type = CHARACTER; in peek_token_bracket()
2079 token->opr.c = c; in peek_token_bracket()
2088 token->type = OP_CHARSET_RANGE; in peek_token_bracket()
2091 token->type = OP_CLOSE_BRACKET; in peek_token_bracket()
2094 token->type = OP_NON_MATCH_LIST; in peek_token_bracket()
2097 token->type = CHARACTER; in peek_token_bracket()
2151 parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, in parse_reg_exp() argument
2157 tree = parse_branch (regexp, preg, token, syntax, nest, err); in parse_reg_exp()
2161 while (token->type == OP_ALT) in parse_reg_exp()
2163 fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE); in parse_reg_exp()
2164 if (token->type != OP_ALT && token->type != END_OF_RE in parse_reg_exp()
2165 && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) in parse_reg_exp()
2169 branch = parse_branch (regexp, preg, token, syntax, nest, err); in parse_reg_exp()
2200 parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token, in parse_branch() argument
2205 tree = parse_expression (regexp, preg, token, syntax, nest, err); in parse_branch()
2209 while (token->type != OP_ALT && token->type != END_OF_RE in parse_branch()
2210 && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) in parse_branch()
2212 expr = parse_expression (regexp, preg, token, syntax, nest, err); in parse_branch()
2245 parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, in parse_expression() argument
2250 switch (token->type) in parse_expression()
2253 tree = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2266 fetch_token (token, regexp, syntax); in parse_expression()
2267 mbc_remain = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2280 tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err); in parse_expression()
2286 tree = parse_bracket_exp (regexp, dfa, token, syntax, err); in parse_expression()
2292 if (!__glibc_likely (dfa->completed_bkref_map & (1 << token->opr.idx))) in parse_expression()
2297 dfa->used_bkref_map |= 1 << token->opr.idx; in parse_expression()
2298 tree = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2325 fetch_token (token, regexp, syntax); in parse_expression()
2326 return parse_expression (regexp, preg, token, syntax, nest, err); in parse_expression()
2330 if ((token->type == OP_CLOSE_SUBEXP) in parse_expression()
2341 token->type = CHARACTER; in parse_expression()
2344 tree = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2353 if ((token->opr.ctx_type in parse_expression()
2357 if (token->opr.ctx_type == WORD_DELIM in parse_expression()
2358 || token->opr.ctx_type == NOT_WORD_DELIM) in parse_expression()
2361 if (token->opr.ctx_type == WORD_DELIM) in parse_expression()
2363 token->opr.ctx_type = WORD_FIRST; in parse_expression()
2364 tree_first = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2365 token->opr.ctx_type = WORD_LAST; in parse_expression()
2369 token->opr.ctx_type = INSIDE_WORD; in parse_expression()
2370 tree_first = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2371 token->opr.ctx_type = INSIDE_NOTWORD; in parse_expression()
2373 tree_last = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2384 tree = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2395 fetch_token (token, regexp, syntax); in parse_expression()
2399 tree = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2414 token->type == OP_NOTWORD, err); in parse_expression()
2424 token->type == OP_NOTSPACE, err); in parse_expression()
2442 fetch_token (token, regexp, syntax); in parse_expression()
2444 while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS in parse_expression()
2445 || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM) in parse_expression()
2447 bin_tree_t *dup_tree = parse_dup_op (tree, regexp, dfa, token, in parse_expression()
2458 && (token->type == OP_DUP_ASTERISK in parse_expression()
2459 || token->type == OP_OPEN_DUP_NUM)) in parse_expression()
2479 parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, in parse_sub_exp() argument
2487 fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE); in parse_sub_exp()
2490 if (token->type == OP_CLOSE_SUBEXP) in parse_sub_exp()
2494 tree = parse_reg_exp (regexp, preg, token, syntax, nest, err); in parse_sub_exp()
2496 && token->type != OP_CLOSE_SUBEXP)) in parse_sub_exp()
2515 tree->token.opr.idx = cur_nsub; in parse_sub_exp()
2523 re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err) in parse_dup_op() argument
2527 re_token_t start_token = *token; in parse_dup_op()
2529 if (token->type == OP_OPEN_DUP_NUM) in parse_dup_op()
2532 start = fetch_number (regexp, token, syntax); in parse_dup_op()
2535 if (token->type == CHARACTER && token->opr.c == ',') in parse_dup_op()
2546 end = ((token->type == OP_CLOSE_DUP_NUM) ? start in parse_dup_op()
2547 : ((token->type == CHARACTER && token->opr.c == ',') in parse_dup_op()
2548 ? fetch_number (regexp, token, syntax) : -2)); in parse_dup_op()
2555 if (token->type == END_OF_RE) in parse_dup_op()
2565 *token = start_token; in parse_dup_op()
2566 token->type = CHARACTER; in parse_dup_op()
2573 || token->type != OP_CLOSE_DUP_NUM)) in parse_dup_op()
2588 start = (token->type == OP_DUP_PLUS) ? 1 : 0; in parse_dup_op()
2589 end = (token->type == OP_DUP_QUESTION) ? 1 : -1; in parse_dup_op()
2592 fetch_token (token, regexp, syntax); in parse_dup_op()
2626 if (elem->token.type == SUBEXP) in parse_dup_op()
2628 uintptr_t subidx = elem->token.opr.idx; in parse_dup_op()
3095 parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, in parse_bracket_exp() argument
3153 token_len = peek_token_bracket (token, regexp, syntax); in parse_bracket_exp()
3154 if (__glibc_unlikely (token->type == END_OF_RE)) in parse_bracket_exp()
3159 if (token->type == OP_NON_MATCH_LIST) in parse_bracket_exp()
3168 token_len = peek_token_bracket (token, regexp, syntax); in parse_bracket_exp()
3169 if (__glibc_unlikely (token->type == END_OF_RE)) in parse_bracket_exp()
3177 if (token->type == OP_CLOSE_BRACKET) in parse_bracket_exp()
3178 token->type = CHARACTER; in parse_bracket_exp()
3192 ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa, in parse_bracket_exp()
3202 token_len = peek_token_bracket (token, regexp, syntax); in parse_bracket_exp()
3207 if (__glibc_unlikely (token->type == END_OF_RE)) in parse_bracket_exp()
3212 if (token->type == OP_CHARSET_RANGE) in parse_bracket_exp()
3225 token->type = CHARACTER; in parse_bracket_exp()
3244 token_len = peek_token_bracket (token, regexp, syntax); in parse_bracket_exp()
3323 if (__glibc_unlikely (token->type == END_OF_RE)) in parse_bracket_exp()
3328 if (token->type == OP_CLOSE_BRACKET) in parse_bracket_exp()
3410 re_token_t *token, int token_len, re_dfa_t *dfa, in parse_bracket_element() argument
3425 if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS in parse_bracket_element()
3426 || token->type == OP_OPEN_EQUIV_CLASS) in parse_bracket_element()
3427 return parse_bracket_symbol (elem, regexp, token); in parse_bracket_element()
3428 if (__glibc_unlikely (token->type == OP_CHARSET_RANGE) && !accept_hyphen) in parse_bracket_element()
3440 elem->opr.ch = token->opr.c; in parse_bracket_element()
3450 re_token_t *token) in parse_bracket_symbol() argument
3452 unsigned char ch, delim = token->opr.c; in parse_bracket_symbol()
3460 if (token->type == OP_OPEN_CHAR_CLASS) in parse_bracket_symbol()
3472 switch (token->type) in parse_bracket_symbol()
3771 fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax) in fetch_number() argument
3777 fetch_token (token, input, syntax); in fetch_number()
3778 c = token->opr.c; in fetch_number()
3779 if (__glibc_unlikely (token->type == END_OF_RE)) in fetch_number()
3781 if (token->type == OP_CLOSE_DUP_NUM || c == ',') in fetch_number()
3783 num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2) in fetch_number()
3822 const re_token_t *token) in create_token_tree() argument
3840 tree->token = *token; in create_token_tree()
3841 tree->token.duplicated = 0; in create_token_tree()
3842 tree->token.opt_subexp = 0; in create_token_tree()
3861 if (node->token.type == SUBEXP && node->token.opr.idx == idx) in mark_opt_subexp()
3862 node->token.opt_subexp = 1; in mark_opt_subexp()
3887 free_token (&node->token); in free_tree()
3907 *p_new = create_token_tree (dfa, NULL, NULL, &node->token); in duplicate_tree()
3911 (*p_new)->token.duplicated = 1; in duplicate_tree()