Mercurial > hg > Applications > Grep
changeset 145:50217a0545e8 pairPro
fix charClass()
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 14 Dec 2015 19:39:16 +0900 |
parents | d8a4922eceae |
children | 1c74ac7d56ec |
files | c/regexParser/main.cc c/regexParser/node.cc c/regexParser/regexParser.cc c/regexParser/regexParser.h |
diffstat | 4 files changed, 11 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/c/regexParser/main.cc Mon Dec 14 17:14:33 2015 +0900 +++ b/c/regexParser/main.cc Mon Dec 14 19:39:16 2015 +0900 @@ -10,8 +10,6 @@ { RegexInfoPtr ri = (RegexInfoPtr)malloc(sizeof(RegexInfo)); ri->nodeNumber = 1; - ri->orNum = 0; - ri->asterFlag = false; for (int i = 1; i < argc; i++) { if (strcmp(argv[i],"-regex") == 0) {
--- a/c/regexParser/node.cc Mon Dec 14 17:14:33 2015 +0900 +++ b/c/regexParser/node.cc Mon Dec 14 19:39:16 2015 +0900 @@ -4,8 +4,13 @@ static void printCharacterClass(CharClassPtr cc, long nodeNumber,int d) { if (cc->type == 'r') { printf("%*c",d*4, ' '); - for (RangeList range = cc->cond.range; range.begin != 0; range = *range.next) { + for (RangeList range = cc->cond.range; range.begin != 0;) { printf("[%c-%c] ",(unsigned char)range.begin,(unsigned char)range.end); + if (range.next != NULL) { + range = *range.next; + } else { + break; + } } printf("(%lu)\n",nodeNumber); }
--- a/c/regexParser/regexParser.cc Mon Dec 14 17:14:33 2015 +0900 +++ b/c/regexParser/regexParser.cc Mon Dec 14 19:39:16 2015 +0900 @@ -63,22 +63,23 @@ RangeListPtr rangeList = &cc->cond.range; rangeList->begin = (unsigned long)*ri->ptr; rangeList->end = (unsigned long)*ri->ptr; + rangeList->next = NULL; for (ri->ptr++; *ri->ptr && *ri->ptr != ']'; ri->ptr++) { if (*ri->ptr == '-') { - rangeList->end = (unsigned long)(ri->ptr + 1); + rangeList->end = (unsigned long)*(ri->ptr + 1); ri->ptr++; continue; } if (ri->ptr[0] == 0 || ri->ptr[0] == ']') break; if (ri->ptr[0] == rangeList->end + 1) { - rangeList->end = (unsigned long)ri->ptr; + rangeList->end = (unsigned long)*ri->ptr; continue; } rangeList->next = NEW(RangeList); rangeList = rangeList->next; - rangeList->begin = (unsigned long)ri->ptr; - rangeList->end = (unsigned long)ri->ptr; + rangeList->begin = (unsigned long)*ri->ptr; + rangeList->end = (unsigned long)*ri->ptr; rangeList->next = NULL; } // TODO literal support @@ -119,7 +120,6 @@ ri->ptr++; ri->tokenType = '|'; ri->tokenValue = NULL; - ri->orNum++; return; } else if (ri->ptr[0] == '*'){ ri->ptr++;