Make the ' Operator
This commit is contained in:
25
pikevm.h
25
pikevm.h
@@ -85,6 +85,7 @@ enum
|
|||||||
/* Other (special) instructions */
|
/* Other (special) instructions */
|
||||||
SAVE,
|
SAVE,
|
||||||
/* Instructions which take relative offset as arg */
|
/* Instructions which take relative offset as arg */
|
||||||
|
NORAC,
|
||||||
JMP,
|
JMP,
|
||||||
SPLIT,
|
SPLIT,
|
||||||
RSPLIT,
|
RSPLIT,
|
||||||
@@ -131,6 +132,10 @@ void re_dumpcode(rcode *prog)
|
|||||||
printf("jmp %d (%d)\n", pc + code[pc] + 1, code[pc]);
|
printf("jmp %d (%d)\n", pc + code[pc] + 1, code[pc]);
|
||||||
pc++;
|
pc++;
|
||||||
break;
|
break;
|
||||||
|
case NORAC:
|
||||||
|
printf("norac %d (%d)\n", pc + code[pc] + 1, code[pc]);
|
||||||
|
pc++;
|
||||||
|
break;
|
||||||
case CHAR:
|
case CHAR:
|
||||||
printf("char %c\n", code[pc]);
|
printf("char %c\n", code[pc]);
|
||||||
pc++;
|
pc++;
|
||||||
@@ -315,6 +320,14 @@ static int compilecode(const char *re_loc, rcode *prog, int sizecode)
|
|||||||
if (nojmp == 2)
|
if (nojmp == 2)
|
||||||
goto zcase;
|
goto zcase;
|
||||||
break;
|
break;
|
||||||
|
case '\'':
|
||||||
|
INSERT_CODE(term, 3, PC);
|
||||||
|
EMIT(PC++, MATCH);
|
||||||
|
EMIT(term, NORAC);
|
||||||
|
EMIT(term + 1, REL(term, PC));
|
||||||
|
EMIT(term + 2, BOL);
|
||||||
|
EMIT(PC++, ANY);
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
if (PC == term)
|
if (PC == term)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -419,6 +432,7 @@ static int reg_comp(rcode *prog, const char *re, int nsubs)
|
|||||||
case RSPLIT:
|
case RSPLIT:
|
||||||
prog->insts[i] = -scnt;
|
prog->insts[i] = -scnt;
|
||||||
scnt += 2;
|
scnt += 2;
|
||||||
|
case NORAC:
|
||||||
case JMP:
|
case JMP:
|
||||||
case SAVE:
|
case SAVE:
|
||||||
case CHAR:
|
case CHAR:
|
||||||
@@ -526,6 +540,11 @@ if (spc > JMP) { \
|
|||||||
npc += 2; \
|
npc += 2; \
|
||||||
pcs[si] = npc + npc[-1]; \
|
pcs[si] = npc + npc[-1]; \
|
||||||
fastrec(nn, list, listidx) \
|
fastrec(nn, list, listidx) \
|
||||||
|
} else if (spc == NORAC) { \
|
||||||
|
if (re_pikevm(prog, _sp, NULL, 0, 2 + npc)) \
|
||||||
|
deccheck(nn) \
|
||||||
|
npc += 2 + npc[1]; \
|
||||||
|
goto rec##nn; \
|
||||||
} else if (spc == SAVE) { \
|
} else if (spc == SAVE) { \
|
||||||
save##list() \
|
save##list() \
|
||||||
nsub->sub[npc[1]] = _sp; \
|
nsub->sub[npc[1]] = _sp; \
|
||||||
@@ -570,12 +589,10 @@ clistidx = nlistidx; \
|
|||||||
|
|
||||||
#define deccont() { decref(nsub) continue; }
|
#define deccont() { decref(nsub) continue; }
|
||||||
|
|
||||||
static int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
|
static int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp, int * start)
|
||||||
{
|
{
|
||||||
if (!*s)
|
|
||||||
return 0;
|
|
||||||
const char *sp = s, *_sp = s;
|
const char *sp = s, *_sp = s;
|
||||||
int *pcs[prog->splits], *npc, *pc, *insts = prog->insts;
|
int *pcs[prog->splits], *npc, *pc, *insts = start?start:prog->insts;
|
||||||
rsub *subs[prog->splits];
|
rsub *subs[prog->splits];
|
||||||
rsub *nsub, *sub, *matched = NULL, *freesub = NULL;
|
rsub *nsub, *sub, *matched = NULL, *freesub = NULL;
|
||||||
rthread _clist[prog->len], _nlist[prog->len];
|
rthread _clist[prog->len], _nlist[prog->len];
|
||||||
|
|||||||
Reference in New Issue
Block a user