static Renode *parserep(struct cstate *g) { Renode *atom; if (accept(g, '^')) return newnode(g, P_BOL); if (accept(g, '$')) return newnode(g, P_EOL); if (accept(g, L_WORD)) return newnode(g, P_WORD); if (accept(g, L_NWORD)) return newnode(g, P_NWORD); atom = parseatom(g); if (g->lookahead == L_COUNT) { int min = g->yymin, max = g->yymax; next(g); if (max < min) die(g, "invalid quantifier"); return newrep(g, atom, accept(g, '?'), min, max); } if (accept(g, '*')) return newrep(g, atom, accept(g, '?'), 0, REPINF); if (accept(g, '+')) return newrep(g, atom, accept(g, '?'), 1, REPINF); if (accept(g, '?')) return newrep(g, atom, accept(g, '?'), 0, 1); return atom; }
static Renode *parserep(void) { Renode *atom; if (re_accept('^')) return newnode(P_BOL); if (re_accept('$')) return newnode(P_EOL); if (re_accept(L_WORD)) return newnode(P_WORD); if (re_accept(L_NWORD)) return newnode(P_NWORD); atom = parseatom(); if (g.lookahead == L_COUNT) { int min = g.yymin, max = g.yymax; next(); if (max < min) die("invalid quantifier"); return newrep(atom, re_accept('?'), min, max); } if (re_accept('*')) return newrep(atom, re_accept('?'), 0, REPINF); if (re_accept('+')) return newrep(atom, re_accept('?'), 1, REPINF); if (re_accept('?')) return newrep(atom, re_accept('?'), 0, 1); return atom; }