Mercurial > hg > Applications > Grep
changeset 126:639b0b437ebf pairPro
remove error (do not work)
author | masa |
---|---|
date | Tue, 01 Dec 2015 21:42:05 +0900 |
parents | 4d6ac69801ad |
children | b061cd8205cc |
files | c/regexParser/regexParser.cc c/regexParser/regexParser.h |
diffstat | 2 files changed, 23 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/c/regexParser/regexParser.cc Tue Dec 01 21:11:27 2015 +0900 +++ b/c/regexParser/regexParser.cc Tue Dec 01 21:42:05 2015 +0900 @@ -6,7 +6,7 @@ #include "error.h" static NodePtr allocateNode(); -static NodePtr createNode(RegexInfoPtr,unsigned char*,NodePtr,NodePtr); +static NodePtr createNode(RegexInfoPtr,unsigned char,NodePtr,NodePtr); static NodePtr charClass(RegexInfoPtr); static NodePtr group(RegexInfoPtr); static void token(RegexInfoPtr); @@ -30,13 +30,15 @@ } static -CharClassPtr createChaClassWord(RegexInfoPtr ri) { +CharClassPtr createCharClassWord(RegexInfoPtr ri) { CharClassPtr cc = NEW(CharClass); cc->type = 'a'; cc->cond = NEW(Condition); cc->cond->w = NEW(Word); cc->cond->w->word = ri->tokenValue; cc->cond->w->length = ri->ptr - ri->tokenValue; + + return cc; } static @@ -67,29 +69,29 @@ ri->nodeNumber++; CharClassPtr cc = NEW(CharClass); + cc->type = 'r'; cc->cond = NEW(Condition); - cc->cond->type = 'r'; - cc->cond->rangeList = NEW(struct utf8Range); - cc->cond->rangeList->begin = ri->ptr; - cc->cond->rangeList->end = ri->ptr + 1; - cc->cond->rangeList->next = NULL; + cc->cond->range = NEW(RangeList); + cc->cond->range->begin = ri->ptr; + cc->cond->range->end = ri->ptr + 1; + cc->cond->range->next = NULL; int i = 0; - struct utf8Range *rangeList= cc->cond->rangeList; + RangeListPtr rangeList = cc->cond->range; while (ri->ptr[i] != ']') { if (ri->ptr[i] == '-') i++; rangeList->end = ri->ptr + i; - rangeList->next = NEW(struct utf8Range); + rangeList->next = NEW(RangeList); rangeList = rangeList->next; rangeList->begin = ri->ptr+i+1; rangeList->next = NULL; i++; } - rangeList->end = ri->ptr[i-1]; + rangeList->end = ri->ptr + i - 1; return n; } @@ -97,7 +99,7 @@ // <literal> ::= [a-z][A-Z][0-9] static NodePtr literal(RegexInfoPtr ri) { - NodePtr n = createNode(ri,ri->ptr,0,0); + NodePtr n = createNode(ri,'a',0,0); return n; }
--- a/c/regexParser/regexParser.h Tue Dec 01 21:11:27 2015 +0900 +++ b/c/regexParser/regexParser.h Tue Dec 01 21:42:05 2015 +0900 @@ -1,11 +1,16 @@ #include "word.h" #include "error.h" + +#define NEW(type) (type*)malloc(sizeof(type)) + +typedef struct utf8Range { + unsigned char *begin; + unsigned char *end; + struct utf8Range *next; +} RangeList , *RangeListPtr; + typedef union condition { - struct utf8Range { - unsigned char *begin; - unsigned char *end; - struct utf8Range *next; - } *rangeList; + RangeListPtr range; unsigned char character; WordPtr w; } Condition, *ConditionList;