Lines Matching refs:token
55 static int fetch_number (re_string_t *input, re_token_t *token,
57 static int peek_token (re_token_t *token, re_string_t *input,
62 re_token_t *token, reg_syntax_t syntax,
65 re_token_t *token, reg_syntax_t syntax,
68 re_token_t *token, reg_syntax_t syntax,
71 re_token_t *token, reg_syntax_t syntax,
74 re_dfa_t *dfa, re_token_t *token,
77 re_token_t *token, reg_syntax_t syntax,
81 re_token_t *token, int token_len,
87 re_token_t *token);
117 const re_token_t *token);
1278 if (node->token.type == OP_BACK_REF && dfa->subexp_map) in optimize_subexps()
1280 int idx = node->token.opr.idx; in optimize_subexps()
1281 node->token.opr.idx = dfa->subexp_map[idx]; in optimize_subexps()
1282 dfa->used_bkref_map |= 1 << node->token.opr.idx; in optimize_subexps()
1285 else if (node->token.type == SUBEXP in optimize_subexps()
1286 && node->left && node->left->token.type == SUBEXP) in optimize_subexps()
1288 int other_idx = node->left->token.opr.idx; in optimize_subexps()
1294 dfa->subexp_map[other_idx] = dfa->subexp_map[node->token.opr.idx]; in optimize_subexps()
1310 if (node->left && node->left->token.type == SUBEXP) in lower_subexps()
1316 if (node->right && node->right->token.type == SUBEXP) in lower_subexps()
1339 && (node->token.opr.idx >= BITSET_WORD_BITS in lower_subexp()
1341 & ((bitset_word_t) 1 << node->token.opr.idx)))) in lower_subexp()
1356 op->token.opr.idx = cls->token.opr.idx = node->token.opr.idx; in lower_subexp()
1357 op->token.opt_subexp = cls->token.opt_subexp = node->token.opt_subexp; in lower_subexp()
1367 if (node->token.type == CONCAT) in calc_first()
1375 node->node_idx = re_dfa_add_node (dfa, node->token); in calc_first()
1378 if (node->token.type == ANCHOR) in calc_first()
1379 dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type; in calc_first()
1388 switch (node->token.type) in calc_next()
1415 switch (node->token.type) in link_nfa_nodes()
1451 if (node->token.type == OP_BACK_REF) in link_nfa_nodes()
1456 assert (!IS_EPSILON_NODE (node->token.type)); in link_nfa_nodes()
1769 peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) in peek_token() argument
1775 token->type = END_OF_RE; in peek_token()
1780 token->opr.c = c; in peek_token()
1782 token->word_char = 0; in peek_token()
1784 token->mb_partial = 0; in peek_token()
1788 token->type = CHARACTER; in peek_token()
1789 token->mb_partial = 1; in peek_token()
1798 token->type = BACK_SLASH; in peek_token()
1803 token->opr.c = c2; in peek_token()
1804 token->type = CHARACTER; in peek_token()
1810 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; in peek_token()
1814 token->word_char = IS_WORD_CHAR (c2) != 0; in peek_token()
1820 token->type = OP_ALT; in peek_token()
1826 token->type = OP_BACK_REF; in peek_token()
1827 token->opr.idx = c2 - '1'; in peek_token()
1833 token->type = ANCHOR; in peek_token()
1834 token->opr.ctx_type = WORD_FIRST; in peek_token()
1840 token->type = ANCHOR; in peek_token()
1841 token->opr.ctx_type = WORD_LAST; in peek_token()
1847 token->type = ANCHOR; in peek_token()
1848 token->opr.ctx_type = WORD_DELIM; in peek_token()
1854 token->type = ANCHOR; in peek_token()
1855 token->opr.ctx_type = NOT_WORD_DELIM; in peek_token()
1860 token->type = OP_WORD; in peek_token()
1864 token->type = OP_NOTWORD; in peek_token()
1868 token->type = OP_SPACE; in peek_token()
1872 token->type = OP_NOTSPACE; in peek_token()
1877 token->type = ANCHOR; in peek_token()
1878 token->opr.ctx_type = BUF_FIRST; in peek_token()
1884 token->type = ANCHOR; in peek_token()
1885 token->opr.ctx_type = BUF_LAST; in peek_token()
1890 token->type = OP_OPEN_SUBEXP; in peek_token()
1894 token->type = OP_CLOSE_SUBEXP; in peek_token()
1898 token->type = OP_DUP_PLUS; in peek_token()
1902 token->type = OP_DUP_QUESTION; in peek_token()
1906 token->type = OP_OPEN_DUP_NUM; in peek_token()
1910 token->type = OP_CLOSE_DUP_NUM; in peek_token()
1918 token->type = CHARACTER; in peek_token()
1923 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; in peek_token()
1927 token->word_char = IS_WORD_CHAR (token->opr.c); in peek_token()
1933 token->type = OP_ALT; in peek_token()
1937 token->type = OP_ALT; in peek_token()
1940 token->type = OP_DUP_ASTERISK; in peek_token()
1944 token->type = OP_DUP_PLUS; in peek_token()
1948 token->type = OP_DUP_QUESTION; in peek_token()
1952 token->type = OP_OPEN_DUP_NUM; in peek_token()
1956 token->type = OP_CLOSE_DUP_NUM; in peek_token()
1960 token->type = OP_OPEN_SUBEXP; in peek_token()
1964 token->type = OP_CLOSE_SUBEXP; in peek_token()
1967 token->type = OP_OPEN_BRACKET; in peek_token()
1970 token->type = OP_PERIOD; in peek_token()
1980 token->type = ANCHOR; in peek_token()
1981 token->opr.ctx_type = LINE_FIRST; in peek_token()
1994 token->type = ANCHOR; in peek_token()
1995 token->opr.ctx_type = LINE_LAST; in peek_token()
2008 peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax) in peek_token_bracket() argument
2013 token->type = END_OF_RE; in peek_token_bracket()
2017 token->opr.c = c; in peek_token_bracket()
2023 token->type = CHARACTER; in peek_token_bracket()
2035 token->opr.c = c2; in peek_token_bracket()
2036 token->type = CHARACTER; in peek_token_bracket()
2047 token->opr.c = c2; in peek_token_bracket()
2052 token->type = OP_OPEN_COLL_ELEM; in peek_token_bracket()
2055 token->type = OP_OPEN_EQUIV_CLASS; in peek_token_bracket()
2060 token->type = OP_OPEN_CHAR_CLASS; in peek_token_bracket()
2065 token->type = CHARACTER; in peek_token_bracket()
2066 token->opr.c = c; in peek_token_bracket()
2075 token->type = OP_CHARSET_RANGE; in peek_token_bracket()
2078 token->type = OP_CLOSE_BRACKET; in peek_token_bracket()
2081 token->type = OP_NON_MATCH_LIST; in peek_token_bracket()
2084 token->type = CHARACTER; in peek_token_bracket()
2138 parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, in parse_reg_exp() argument
2143 tree = parse_branch (regexp, preg, token, syntax, nest, err); in parse_reg_exp()
2147 while (token->type == OP_ALT) in parse_reg_exp()
2149 fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE); in parse_reg_exp()
2150 if (token->type != OP_ALT && token->type != END_OF_RE in parse_reg_exp()
2151 && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) in parse_reg_exp()
2153 branch = parse_branch (regexp, preg, token, syntax, nest, err); in parse_reg_exp()
2179 parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token, in parse_branch() argument
2184 tree = parse_expression (regexp, preg, token, syntax, nest, err); in parse_branch()
2188 while (token->type != OP_ALT && token->type != END_OF_RE in parse_branch()
2189 && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) in parse_branch()
2191 exp = parse_expression (regexp, preg, token, syntax, nest, err); in parse_branch()
2224 parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, in parse_expression() argument
2229 switch (token->type) in parse_expression()
2232 tree = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2245 fetch_token (token, regexp, syntax); in parse_expression()
2246 mbc_remain = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2258 tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err); in parse_expression()
2263 tree = parse_bracket_exp (regexp, dfa, token, syntax, err); in parse_expression()
2268 if (!BE (dfa->completed_bkref_map & (1 << token->opr.idx), 1)) in parse_expression()
2273 dfa->used_bkref_map |= 1 << token->opr.idx; in parse_expression()
2274 tree = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2300 fetch_token (token, regexp, syntax); in parse_expression()
2301 return parse_expression (regexp, preg, token, syntax, nest, err); in parse_expression()
2305 if ((token->type == OP_CLOSE_SUBEXP) && in parse_expression()
2316 token->type = CHARACTER; in parse_expression()
2319 tree = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2327 if ((token->opr.ctx_type in parse_expression()
2331 if (token->opr.ctx_type == WORD_DELIM in parse_expression()
2332 || token->opr.ctx_type == NOT_WORD_DELIM) in parse_expression()
2335 if (token->opr.ctx_type == WORD_DELIM) in parse_expression()
2337 token->opr.ctx_type = WORD_FIRST; in parse_expression()
2338 tree_first = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2339 token->opr.ctx_type = WORD_LAST; in parse_expression()
2343 token->opr.ctx_type = INSIDE_WORD; in parse_expression()
2344 tree_first = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2345 token->opr.ctx_type = INSIDE_NOTWORD; in parse_expression()
2347 tree_last = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2357 tree = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2368 fetch_token (token, regexp, syntax); in parse_expression()
2371 tree = create_token_tree (dfa, NULL, NULL, token); in parse_expression()
2385 token->type == OP_NOTWORD, err); in parse_expression()
2394 token->type == OP_NOTSPACE, err); in parse_expression()
2411 fetch_token (token, regexp, syntax); in parse_expression()
2413 while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS in parse_expression()
2414 || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM) in parse_expression()
2416 tree = parse_dup_op (tree, regexp, dfa, token, syntax, err); in parse_expression()
2421 && (token->type == OP_DUP_ASTERISK in parse_expression()
2422 || token->type == OP_OPEN_DUP_NUM)) in parse_expression()
2440 parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, in parse_sub_exp() argument
2448 fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE); in parse_sub_exp()
2451 if (token->type == OP_CLOSE_SUBEXP) in parse_sub_exp()
2455 tree = parse_reg_exp (regexp, preg, token, syntax, nest, err); in parse_sub_exp()
2456 if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0)) in parse_sub_exp()
2475 tree->token.opr.idx = cur_nsub; in parse_sub_exp()
2483 re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err) in parse_dup_op() argument
2487 re_token_t start_token = *token; in parse_dup_op()
2489 if (token->type == OP_OPEN_DUP_NUM) in parse_dup_op()
2492 start = fetch_number (regexp, token, syntax); in parse_dup_op()
2495 if (token->type == CHARACTER && token->opr.c == ',') in parse_dup_op()
2506 end = ((token->type == OP_CLOSE_DUP_NUM) ? start in parse_dup_op()
2507 : ((token->type == CHARACTER && token->opr.c == ',') in parse_dup_op()
2508 ? fetch_number (regexp, token, syntax) : -2)); in parse_dup_op()
2515 if (token->type == END_OF_RE) in parse_dup_op()
2525 *token = start_token; in parse_dup_op()
2526 token->type = CHARACTER; in parse_dup_op()
2532 if (BE ((end != -1 && start > end) || token->type != OP_CLOSE_DUP_NUM, 0)) in parse_dup_op()
2541 start = (token->type == OP_DUP_PLUS) ? 1 : 0; in parse_dup_op()
2542 end = (token->type == OP_DUP_QUESTION) ? 1 : -1; in parse_dup_op()
2545 fetch_token (token, regexp, syntax); in parse_dup_op()
2577 if (elem->token.type == SUBEXP) in parse_dup_op()
2578 postorder (elem, mark_opt_subexp, (void *) (long) elem->token.opr.idx); in parse_dup_op()
2766 parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, in parse_bracket_exp() argument
3061 token_len = peek_token_bracket (token, regexp, syntax); in parse_bracket_exp()
3062 if (BE (token->type == END_OF_RE, 0)) in parse_bracket_exp()
3067 if (token->type == OP_NON_MATCH_LIST) in parse_bracket_exp()
3076 token_len = peek_token_bracket (token, regexp, syntax); in parse_bracket_exp()
3077 if (BE (token->type == END_OF_RE, 0)) in parse_bracket_exp()
3085 if (token->type == OP_CLOSE_BRACKET) in parse_bracket_exp()
3086 token->type = CHARACTER; in parse_bracket_exp()
3098 ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa, in parse_bracket_exp()
3108 token_len = peek_token_bracket (token, regexp, syntax); in parse_bracket_exp()
3113 if (BE (token->type == END_OF_RE, 0)) in parse_bracket_exp()
3118 if (token->type == OP_CHARSET_RANGE) in parse_bracket_exp()
3131 token->type = CHARACTER; in parse_bracket_exp()
3149 token_len = peek_token_bracket (token, regexp, syntax); in parse_bracket_exp()
3224 if (BE (token->type == END_OF_RE, 0)) in parse_bracket_exp()
3229 if (token->type == OP_CLOSE_BRACKET) in parse_bracket_exp()
3311 re_token_t *token, int token_len, re_dfa_t *dfa, in parse_bracket_element() argument
3326 if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS in parse_bracket_element()
3327 || token->type == OP_OPEN_EQUIV_CLASS) in parse_bracket_element()
3328 return parse_bracket_symbol (elem, regexp, token); in parse_bracket_element()
3329 if (BE (token->type == OP_CHARSET_RANGE, 0) && !accept_hyphen) in parse_bracket_element()
3341 elem->opr.ch = token->opr.c; in parse_bracket_element()
3351 re_token_t *token) in parse_bracket_symbol() argument
3353 unsigned char ch, delim = token->opr.c; in parse_bracket_symbol()
3361 if (token->type == OP_OPEN_CHAR_CLASS) in parse_bracket_symbol()
3373 switch (token->type) in parse_bracket_symbol()
3688 fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax) in fetch_number() argument
3694 fetch_token (token, input, syntax); in fetch_number()
3695 c = token->opr.c; in fetch_number()
3696 if (BE (token->type == END_OF_RE, 0)) in fetch_number()
3698 if (token->type == OP_CLOSE_DUP_NUM || c == ',') in fetch_number()
3700 num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2) in fetch_number()
3738 const re_token_t *token) in create_token_tree() argument
3756 tree->token = *token; in create_token_tree()
3757 tree->token.duplicated = 0; in create_token_tree()
3758 tree->token.opt_subexp = 0; in create_token_tree()
3777 if (node->token.type == SUBEXP && node->token.opr.idx == idx) in mark_opt_subexp()
3778 node->token.opt_subexp = 1; in mark_opt_subexp()
3803 free_token (&node->token); in free_tree()
3823 *p_new = create_token_tree (dfa, NULL, NULL, &node->token); in duplicate_tree()
3827 (*p_new)->token.duplicated = 1; in duplicate_tree()