54 setArray(NULL), setSize(0), size(16), freeState(1), currentPos(0), minimal(false)
56 int bytes =
sizeof(int)*
size;
58 ch = (
int*) malloc(bytes);
59 next1 = (
int*) malloc(bytes);
60 next2 = (
int*) malloc(bytes);
94 if (this->
final != -1)
98 setState(this->
final, 0x00, this->
final+1, this->
final+1);
197 memset(
ch, 0x00,
sizeof(
int)*
size);
247 printf(
"state\tch\tnext1\tnext2\n");
250 if ((
unsigned int)
next1[i] < 32000)
259 printf(
"set %d\t",(
ch[i] & 0x0fff0000) >> 16);
262 printf(
"nset %d\t",(
ch[i] & 0x0fff0000) >> 16);
268 printf(
"%c\t",
ch[i]);
277 printf(
"%d\n",
next1[i]);
478 char stringBuffer[64];
482 bool orExpression = t1!=t2;
489 stringBuffer[i] =
regexp[tempPos];
494 if (
regexp[tempPos] == 0x00)
498 stringBuffer[i] = 0x00;
499 i = atoi(stringBuffer) - 1;
548 int transition =
SET;
552 char *range = (
char*) malloc(
sizeof(
char)*length);
554 int (__cdecl *func)(int) = NULL;
556 int (*func)(int) = NULL;
565 while (*ptr && *ptr !=
']') {
569 if (*ptr ==
'-' && i) {
570 char b=ptr[-1], e=ptr[1];
579 for (
char c=b+1;c<=e;c++) {
582 range = (
char*) realloc(range,length*2);
588 else if (*ptr ==
'\\') {
591 if (
checkRange(range,i,*ptr)) range[i++] = *ptr;
593 range = (
char*) realloc(range,length*2);
599 else if (*ptr ==
':') {
603 while (len<15 && *ptr && *ptr !=
':')
604 buffer[len++] = *ptr++;
610 buffer[len] = toupper((
int) buffer[len]);
614 if (!strcmp(buffer,
"ALPHA"))
617 else if (!strcmp(buffer,
"LOWER"))
620 else if (!strcmp(buffer,
"UPPER"))
623 else if (!strcmp(buffer,
"ALNUM"))
626 else if (!strcmp(buffer,
"DIGIT"))
629 else if (!strcmp(buffer,
"XDIGIT"))
632 else if (!strcmp(buffer,
"BLANK")) {
634 if (
checkRange(range,i,
' ')) range[i++] =
' ';
636 range = (
char*) realloc(range,length*2);
640 if (
checkRange(range,i,0x09)) range[i++] = 0x09;
642 range = (
char*) realloc(range,length*2);
647 else if (!strcmp(buffer,
"SPACE"))
650 else if (!strcmp(buffer,
"CNTRL"))
653 else if (!strcmp(buffer,
"PRINT"))
656 else if (!strcmp(buffer,
"PUNCT"))
659 else if (!strcmp(buffer,
"GRAPH"))
673 range = (
char*) realloc(range,length*2);
682 if (
checkRange(range,i,*ptr)) range[i++] = *ptr;
685 range = (
char*) realloc(range,length*2);
718 while (
size <= position) {
721 ch = (
int*) realloc(
ch,
size*
sizeof(
int));
725 ch[position] = transition;
726 next1[position] = state1;
727 next2[position] = state2;
740 for (
int i=0;i<length;i++)
768 for (
int i=0; i<rangeSize; i++)
788 int state =
next1[0];
804 if (
minimal ==
true && j == N)
break;
806 printf(
"consume %2d %c\n",j,a[j]);
812 switch (
ch[state] &
SCAN) {
817 if (n1 != n2) dq.
push(n2);
821 set = (
ch[state] & 0x0fff0000)>>16;
823 found = (
ch[state]&
NOT)?
true:
false;
825 for (i=1; i<=len; i++) {
841 if (
ch[state] == (
int) a[j]) {
845 if (
ch[state] == (
int) 0) {
852 printf(
"%s",dq.
isEmpty()?
" empty ":
"NOT empty ");
857 if (dq.
isEmpty() || (j>(N+1)) )
break;
866 return state==
EOP?1:0;
int checkRange(char *, int, char)
int match(const char *, int)
int insertSet(char *, int)
void setState(int, int, int, int)
@ E_ILLEGAL_SYMBOLIC_NAME