readme: add neatvi ref, pike: misc style fixes

This commit is contained in:
Kyryl Melekhin committed 2021-08-14 13:43:32 +00:00
1 parent 81f0ff252d
commit 158a03c4be
2 files changed
+16 -13

No files matched your search

+3
View File
@@ -43,6 +43,9 @@ or class is a space we want to match not assert at. But the code for it was too
dirty and I scrapped it. Syntax for word assertions are like posix C library, not dirty and I scrapped it. Syntax for word assertions are like posix C library, not
the pcre "\b" which can be used both in front or back of the word, because there is the pcre "\b" which can be used both in front or back of the word, because there is
no distinction, it makes the implementation potentially even uglier. no distinction, it makes the implementation potentially even uglier.
* Assert flags like REG_ICASE,REG_NOTEOL,REG_NOTBOL and lookahead inside
negated bracket are implemented here (also shows use case in real world project):
https://github.com/kyx0r/neatvi/blob/pikevm/regex.c
NOTES NOTES
===== =====
+13 -13
View File
@@ -472,7 +472,7 @@ goto next##nn; \
pc += 2 + pc[1]; \ pc += 2 + pc[1]; \
goto rec##nn; \ goto rec##nn; \
case SPLIT: \ case SPLIT: \
if(plist[pc - insts] == gen) \ if (plist[pc - insts] == gen) \
deccheck(nn) \ deccheck(nn) \
plist[pc - insts] = gen; \ plist[pc - insts] = gen; \
sub->ref++; \ sub->ref++; \
@@ -480,7 +480,7 @@ goto next##nn; \
pcs[i] = pc + pc[-1]; \ pcs[i] = pc + pc[-1]; \
fastrec(nn, list, listidx) \ fastrec(nn, list, listidx) \
case RSPLIT: \ case RSPLIT: \
if(plist[pc - insts] == gen) \ if (plist[pc - insts] == gen) \
deccheck(nn) \ deccheck(nn) \
plist[pc - insts] = gen; \ plist[pc - insts] = gen; \
sub->ref++; \ sub->ref++; \
@@ -490,10 +490,10 @@ goto next##nn; \
fastrec(nn, list, listidx) \ fastrec(nn, list, listidx) \
case SAVE: \ case SAVE: \
if (sub->ref > 1) { \ if (sub->ref > 1) { \
sub->ref--; \
newsub() \ newsub() \
for (j = 0; j < nsubp; j++) \ for (j = 0; j < nsubp; j++) \
s1->sub[j] = sub->sub[j]; \ s1->sub[j] = sub->sub[j]; \
sub->ref--; \
sub = s1; \ sub = s1; \
sub->ref = 1; \ sub->ref = 1; \
} \ } \
@@ -537,15 +537,15 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
rthread *clist = _clist, *nlist = _nlist, *tmp; rthread *clist = _clist, *nlist = _nlist, *tmp;
gen = prog->gen; gen = prog->gen;
goto jmp_start; goto jmp_start;
for(;; sp = _sp) { for (;; sp = _sp) {
gen++; uc_len(i, sp) uc_code(c, sp) gen++; uc_len(i, sp) uc_code(c, sp)
_sp = sp+i; _sp = sp+i;
for(i = 0; i < clistidx; i++) { for (i = 0; i < clistidx; i++) {
npc = clist[i].pc; npc = clist[i].pc;
nsub = clist[i].sub; nsub = clist[i].sub;
switch(*npc++) { switch(*npc++) {
case CHAR: case CHAR:
if(c != *npc++) if (c != *npc++)
break; break;
case ANY: case ANY:
addthread: addthread:
@@ -584,8 +584,8 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
} else if (!clistidx) } else if (!clistidx)
break; break;
} }
if(matched) { if (matched) {
for(i = 0; i < nsubp; i++) for (i = 0; i < nsubp; i++)
subp[i] = matched->sub[i]; subp[i] = matched->sub[i];
_return(1) _return(1)
} }
@@ -620,17 +620,17 @@ int main(int argc, char *argv[])
printf("Done in %f seconds\n", elapsed_time); printf("Done in %f seconds\n", elapsed_time);
if (!sz) if (!sz)
{ printf("-nomatch-\n"); continue; } { printf("-nomatch-\n"); continue; }
for(int k=sub_els; k>0; k--) for (int k=sub_els; k>0; k--)
if(sub[k-1]) if (sub[k-1])
break; break;
for(int l=0; l<sub_els; l+=2) { for (int l=0; l<sub_els; l+=2) {
printf("("); printf("(");
if(sub[l] == NULL) if (sub[l] == NULL)
printf("?"); printf("?");
else else
printf("%d", (int)(sub[l] - argv[i])); printf("%d", (int)(sub[l] - argv[i]));
printf(","); printf(",");
if(sub[l+1] == NULL) if (sub[l+1] == NULL)
printf("?"); printf("?");
else else
printf("%d", (int)(sub[l+1] - argv[i])); printf("%d", (int)(sub[l+1] - argv[i]));