Handle quantifiers in parse_term()
This commit is contained in:
22
lib/parser.c
22
lib/parser.c
@@ -18,6 +18,9 @@ static bool is_special(char c)
|
||||
case '\\':
|
||||
case '(':
|
||||
case ')':
|
||||
case '*':
|
||||
case '+':
|
||||
case '?':
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -67,7 +70,24 @@ static int parse_term(const char *input, int rem, term_t *out)
|
||||
used += result;
|
||||
}
|
||||
|
||||
out->quantifier = QUANTIFIER_NONE;
|
||||
if (used < rem) {
|
||||
switch (input[used]) {
|
||||
case '*':
|
||||
out->quantifier = QUANTIFIER_ZERO_OR_MORE;
|
||||
++used;
|
||||
break;
|
||||
case '+':
|
||||
out->quantifier = QUANTIFIER_ONE_OR_MORE;
|
||||
++used;
|
||||
break;
|
||||
case '?':
|
||||
out->quantifier = QUANTIFIER_ZERO_OR_ONE;
|
||||
++used;
|
||||
break;
|
||||
default:
|
||||
out->quantifier = QUANTIFIER_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user