drop named classes because of no new functionality
This commit is contained in:
2
README
2
README
@@ -41,7 +41,7 @@ TODO
|
|||||||
|
|
||||||
* Support for matching flags like case-insensitive, dot matches all,
|
* Support for matching flags like case-insensitive, dot matches all,
|
||||||
multiline, etc.
|
multiline, etc.
|
||||||
* Support for more assertions like \A, \Z.
|
* Support for wordend & wordbeg assertions
|
||||||
|
|
||||||
Author and License
|
Author and License
|
||||||
==================
|
==================
|
||||||
|
|||||||
40
pike.c
40
pike.c
@@ -80,7 +80,6 @@ enum /* rinst.opcode */
|
|||||||
CHAR = 1,
|
CHAR = 1,
|
||||||
ANY,
|
ANY,
|
||||||
CLASS,
|
CLASS,
|
||||||
NAMEDCLASS,
|
|
||||||
// Assert position
|
// Assert position
|
||||||
BOL,
|
BOL,
|
||||||
EOL,
|
EOL,
|
||||||
@@ -150,24 +149,6 @@ int re_classmatch(const int *pc, const char *sp)
|
|||||||
return !is_positive;
|
return !is_positive;
|
||||||
}
|
}
|
||||||
|
|
||||||
int re_namedclassmatch(const int *pc, const char *sp)
|
|
||||||
{
|
|
||||||
// pc points to name of class
|
|
||||||
int off = (*pc >> 5) & 1;
|
|
||||||
if ((*pc | 0x20) == 'd') {
|
|
||||||
if (!(*sp >= '0' && *sp <= '9'))
|
|
||||||
off ^= 1;
|
|
||||||
} else if ((*pc | 0x20) == 's') {
|
|
||||||
if (!(*sp == ' ' || (*sp >= '\t' && *sp <= '\r')))
|
|
||||||
off ^= 1;
|
|
||||||
} else { // w
|
|
||||||
if (!((*sp >= 'A' && *sp <= 'Z') || (*sp >= 'a' && *sp <= 'z') ||
|
|
||||||
(*sp >= '0' && *sp <= '9') || *sp == '_'))
|
|
||||||
off ^= 1;
|
|
||||||
}
|
|
||||||
return off;
|
|
||||||
}
|
|
||||||
|
|
||||||
void re_dumpcode(rcode *prog)
|
void re_dumpcode(rcode *prog)
|
||||||
{
|
{
|
||||||
int pc = 0;
|
int pc = 0;
|
||||||
@@ -207,9 +188,6 @@ void re_dumpcode(rcode *prog)
|
|||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
break;
|
break;
|
||||||
case NAMEDCLASS:
|
|
||||||
printf("namedclass %c\n", code[pc++]);
|
|
||||||
break;
|
|
||||||
case MATCH:
|
case MATCH:
|
||||||
printf("match\n");
|
printf("match\n");
|
||||||
break;
|
break;
|
||||||
@@ -239,16 +217,6 @@ static int _compilecode(const char **re_loc, rcode *prog, int sizecode)
|
|||||||
case '\\':
|
case '\\':
|
||||||
re++;
|
re++;
|
||||||
if (!*re) goto syntax_error; // Trailing backslash
|
if (!*re) goto syntax_error; // Trailing backslash
|
||||||
c = *re | 0x20;
|
|
||||||
if (c == 'd' || c == 's' || c == 'w') {
|
|
||||||
term = PC;
|
|
||||||
EMIT(PC++, NAMEDCLASS);
|
|
||||||
EMIT(PC++, *re);
|
|
||||||
prog->len++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z'))
|
|
||||||
goto unsupported_escape;
|
|
||||||
default:
|
default:
|
||||||
term = PC;
|
term = PC;
|
||||||
EMIT(PC++, CHAR);
|
EMIT(PC++, CHAR);
|
||||||
@@ -353,7 +321,6 @@ static int _compilecode(const char **re_loc, rcode *prog, int sizecode)
|
|||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
switch (code[term]) {
|
switch (code[term]) {
|
||||||
case CLASS:
|
case CLASS:
|
||||||
case NAMEDCLASS:
|
|
||||||
case JMP:
|
case JMP:
|
||||||
case SPLIT:
|
case SPLIT:
|
||||||
case RSPLIT:
|
case RSPLIT:
|
||||||
@@ -591,7 +558,7 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
|
|||||||
for(sp=s;; sp += l) {
|
for(sp=s;; sp += l) {
|
||||||
if(clist->n == 0)
|
if(clist->n == 0)
|
||||||
break;
|
break;
|
||||||
gen++; uc_len(l, s)
|
gen++; uc_len(l, sp)
|
||||||
for(i=0; i<clist->n; i++) {
|
for(i=0; i<clist->n; i++) {
|
||||||
npc = clist->t[i].pc;
|
npc = clist->t[i].pc;
|
||||||
nsub = clist->t[i].sub;
|
nsub = clist->t[i].sub;
|
||||||
@@ -614,11 +581,6 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
|
|||||||
break;
|
break;
|
||||||
npc += *(npc+1) * 2 + 2;
|
npc += *(npc+1) * 2 + 2;
|
||||||
goto addthread;
|
goto addthread;
|
||||||
case NAMEDCLASS:
|
|
||||||
if (!re_namedclassmatch(npc, sp))
|
|
||||||
break;
|
|
||||||
npc++;
|
|
||||||
goto addthread;
|
|
||||||
case MATCH:
|
case MATCH:
|
||||||
matched = nsub;
|
matched = nsub;
|
||||||
for(i++; i < clist->n; i++)
|
for(i++; i < clist->n; i++)
|
||||||
|
|||||||
15
test.sh
15
test.sh
@@ -14,12 +14,9 @@ abc+
|
|||||||
([0-9]*)(?:([a-z]*)(?:[0-9]*))
|
([0-9]*)(?:([a-z]*)(?:[0-9]*))
|
||||||
(?:)
|
(?:)
|
||||||
1?:
|
1?:
|
||||||
\\\d+
|
[0-9]+
|
||||||
\\\s+
|
[a-zA-Z0-9_]+
|
||||||
\\\w+
|
(([0-9]*)([a-z]*)[a-zA-Z0-9_]*)
|
||||||
(\\\w+)\\\s+(\\\w+)
|
|
||||||
(\\\S+)\\\s+(\\\D+)
|
|
||||||
(([0-9]*)([a-z]*)\\\d*)
|
|
||||||
[a]*
|
[a]*
|
||||||
([yab]*)(e*)([cd])
|
([yab]*)(e*)([cd])
|
||||||
([yab]*)(e*)([^y]?)$
|
([yab]*)(e*)([^y]?)$
|
||||||
@@ -63,11 +60,8 @@ abcccdef
|
|||||||
1234hello568
|
1234hello568
|
||||||
1234hello568
|
1234hello568
|
||||||
1:
|
1:
|
||||||
123abc456
|
|
||||||
123abc456
|
123abc456
|
||||||
123abc_456 abc
|
123abc_456 abc
|
||||||
ABC 123hello456 abc
|
|
||||||
ABC helloabc456 abc
|
|
||||||
123hello456
|
123hello456
|
||||||
a
|
a
|
||||||
xyac
|
xyac
|
||||||
@@ -113,10 +107,7 @@ expect="\
|
|||||||
(0,0)
|
(0,0)
|
||||||
(0,2)
|
(0,2)
|
||||||
(0,3)
|
(0,3)
|
||||||
(0,2)
|
|
||||||
(0,10)
|
(0,10)
|
||||||
(0,16)(0,3)(5,16)
|
|
||||||
(0,13)(0,3)(5,13)
|
|
||||||
(0,11)(0,11)(0,3)(3,8)
|
(0,11)(0,11)(0,3)(3,8)
|
||||||
(0,1)
|
(0,1)
|
||||||
(1,4)(1,3)(3,3)(3,4)
|
(1,4)(1,3)(3,3)(3,4)
|
||||||
|
|||||||
Reference in New Issue
Block a user