Lines Matching refs:ps
29 static struct rx_node *_or_term(struct parse_sp *ps);
31 static void _single_char(struct parse_sp *ps, unsigned int c, const char *ptr)
33 ps->type = 0;
34 ps->cursor = ptr + 1;
35 dm_bit_clear_all(ps->charset);
36 dm_bit_set(ps->charset, c);
43 static int _rx_get_token(struct parse_sp *ps)
47 const char *ptr = ps->cursor;
48 if (ptr == ps->rx_end) { /* end of input ? */
49 ps->type = -1;
58 dm_bit_set_all(ps->charset);
61 dm_bit_clear(ps->charset, 0);
66 dm_bit_clear_all(ps->charset);
68 while ((ptr < ps->rx_end) && (*ptr != ']')) {
89 if (ptr == ps->rx_end) {
108 dm_bit_clear(ps->charset, lc);
110 dm_bit_set(ps->charset, lc);
116 dm_bit_clear(ps->charset, c);
118 dm_bit_set(ps->charset, c);
124 if (ptr >= ps->rx_end) {
125 ps->type = -1;
129 ps->type = 0;
130 ps->cursor = ptr + 1;
142 ps->type = (int) *ptr;
143 ps->cursor = ptr + 1;
147 _single_char(ps, HAT_CHAR, ptr);
151 _single_char(ps, DOLLAR_CHAR, ptr);
156 ps->type = 0;
157 ps->cursor = ptr + 1;
158 dm_bit_set_all(ps->charset);
159 dm_bit_clear(ps->charset, (int) '\n');
160 dm_bit_clear(ps->charset, (int) '\r');
161 dm_bit_clear(ps->charset, 0);
167 if (ptr >= ps->rx_end) {
170 ps->type = -1;
174 ps->type = 0;
175 ps->cursor = ptr + 1;
176 dm_bit_clear_all(ps->charset);
179 dm_bit_set(ps->charset, (int) '\n');
182 dm_bit_set(ps->charset, (int) '\r');
185 dm_bit_set(ps->charset, (int) '\t');
188 dm_bit_set(ps->charset, (int) *ptr);
194 ps->type = 0;
195 ps->cursor = ptr + 1;
196 dm_bit_clear_all(ps->charset);
197 dm_bit_set(ps->charset, (int) *ptr);
223 static struct rx_node *_term(struct parse_sp *ps)
227 switch (ps->type) {
229 if (!(n = _node(ps->mem, CHARSET, NULL, NULL))) {
234 dm_bit_copy(n->charset, ps->charset);
235 _rx_get_token(ps); /* match charset */
239 _rx_get_token(ps); /* match '(' */
240 n = _or_term(ps);
241 if (ps->type != ')') {
245 _rx_get_token(ps); /* match ')' */
255 static struct rx_node *_closure_term(struct parse_sp *ps)
259 if (!(l = _term(ps)))
263 switch (ps->type) {
265 n = _node(ps->mem, STAR, l, NULL);
269 n = _node(ps->mem, PLUS, l, NULL);
273 n = _node(ps->mem, QUEST, l, NULL);
285 _rx_get_token(ps);
292 static struct rx_node *_cat_term(struct parse_sp *ps)
296 if (!(l = _closure_term(ps)))
299 if (ps->type == '|')
302 if (!(r = _cat_term(ps)))
305 if (!(n = _node(ps->mem, CAT, l, r)))
311 static struct rx_node *_or_term(struct parse_sp *ps)
315 if (!(l = _cat_term(ps)))
318 if (ps->type != '|')
321 _rx_get_token(ps); /* match '|' */
323 if (!(r = _or_term(ps))) {
328 if (!(n = _node(ps->mem, OR, l, r)))
338 struct parse_sp *ps = dm_pool_zalloc(mem, sizeof(*ps));
340 if (!ps) {
345 ps->mem = mem;
346 ps->charset = dm_bitset_create(mem, 256);
347 ps->cursor = begin;
348 ps->rx_end = end;
349 _rx_get_token(ps); /* load the first token */
351 if (!(r = _or_term(ps))) {
353 dm_pool_free(mem, ps);