Improved native substring capabilities
This commit is contained in:
parent
9295a4d2b4
commit
4322d96ee2
|
@ -39,11 +39,13 @@ compare (abc abc abc) (#t) test
|
||||||
|
|
||||||
replace-empty abc = ?y test
|
replace-empty abc = ?y test
|
||||||
|
|
||||||
?(?-) (Connecting register output)
|
?(?-) (Substring registers)
|
||||||
|
|
||||||
<> (connect ?x ?y ?z) (?x-?y?z)
|
<> (connect ?x ?y ?z) (?x-?y?z)
|
||||||
|
<> (prefix-?x) (?x-suffix)
|
||||||
|
|
||||||
connect foo bar baz = foo-barbaz test
|
connect foo bar baz = foo-barbaz test
|
||||||
|
prefix-anything = anything-suffix test
|
||||||
|
|
||||||
?(?-) (Inline register)
|
?(?-) (Inline register)
|
||||||
|
|
||||||
|
|
|
@ -97,20 +97,22 @@ static char *
|
||||||
match_rule(Rule *r, char *p)
|
match_rule(Rule *r, char *p)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char c, last = 0, *a = r->a, *b = p;
|
char c, *a = r->a, *b = p;
|
||||||
if(rmax) {
|
if(rmax) {
|
||||||
for(i = rmin; i <= rmax; i++)
|
for(i = rmin; i <= rmax; i++)
|
||||||
regs[i] = 0;
|
regs[i] = 0;
|
||||||
rmin = 0xff, rmax = 0x00;
|
rmin = 0xff, rmax = 0x00;
|
||||||
}
|
}
|
||||||
while((c = *a)) {
|
while((c = *a)) {
|
||||||
if(c == '?' && spacer(last) && spacer(a[2])) {
|
if(c == '?') {
|
||||||
if(!set_reg(*(++a), b)) return NULL;
|
if(!set_reg(*(++a), b)) return NULL;
|
||||||
a++, b = walk(b);
|
a++, b = walk(b);
|
||||||
|
if(!spacer(*a))
|
||||||
|
while((c = *a) && !spacer(c)) a++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(c != *b) return NULL;
|
if(c != *b) return NULL;
|
||||||
a++, b++, last = c;
|
a++, b++;
|
||||||
}
|
}
|
||||||
c = *b;
|
c = *b;
|
||||||
return spacer(c) ? b : NULL;
|
return spacer(c) ? b : NULL;
|
||||||
|
|
Loading…
Reference in New Issue