static int piece(void) { int p; p=atom(); if(sym==SYM_CHR) { switch(val) { case '{': getsym(); p=quantifier(p); chk_get('}',RX_ER_NOLCU); break; case '?': getsym(); p=choice(empty,p); break; case '*': getsym(); p=choice(empty,one_or_more(p)); break; case '+': getsym(); p=one_or_more(p); break; default: break; } } return p; }
static int quantifier(int p0) { int p=empty,n,n0; n=n0=number(); while(n--) p=group(p,p0); if(sym==SYM_CHR) { if(val==',') { getsym(); if(sym==SYM_CHR && val=='}') { p=group(p,choice(empty,one_or_more(p0))); } else { n=number()-n0; if(n<0) {error(RX_ER_DNUOB); n=0;} while(n--) p=group(p,choice(empty,p0)); } } } else error(RX_ER_NODGT); return p; }
str_iter one_or_more(str_iter iter, str_ptr str) { return one_or_more(iter, match, str); }