Mercurial > hg > Applications > Grep
comparison c/regexParser/regexParser.cc @ 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 | 84d32375383a |
comparison
equal
deleted
inserted
replaced
144:d8a4922eceae | 145:50217a0545e8 |
---|---|
61 cc->type = 'r'; | 61 cc->type = 'r'; |
62 cc->nextState.bitContainer = 0; | 62 cc->nextState.bitContainer = 0; |
63 RangeListPtr rangeList = &cc->cond.range; | 63 RangeListPtr rangeList = &cc->cond.range; |
64 rangeList->begin = (unsigned long)*ri->ptr; | 64 rangeList->begin = (unsigned long)*ri->ptr; |
65 rangeList->end = (unsigned long)*ri->ptr; | 65 rangeList->end = (unsigned long)*ri->ptr; |
66 rangeList->next = NULL; | |
66 | 67 |
67 for (ri->ptr++; *ri->ptr && *ri->ptr != ']'; ri->ptr++) { | 68 for (ri->ptr++; *ri->ptr && *ri->ptr != ']'; ri->ptr++) { |
68 if (*ri->ptr == '-') { | 69 if (*ri->ptr == '-') { |
69 rangeList->end = (unsigned long)(ri->ptr + 1); | 70 rangeList->end = (unsigned long)*(ri->ptr + 1); |
70 ri->ptr++; | 71 ri->ptr++; |
71 continue; | 72 continue; |
72 } | 73 } |
73 if (ri->ptr[0] == 0 || ri->ptr[0] == ']') break; | 74 if (ri->ptr[0] == 0 || ri->ptr[0] == ']') break; |
74 if (ri->ptr[0] == rangeList->end + 1) { | 75 if (ri->ptr[0] == rangeList->end + 1) { |
75 rangeList->end = (unsigned long)ri->ptr; | 76 rangeList->end = (unsigned long)*ri->ptr; |
76 continue; | 77 continue; |
77 } | 78 } |
78 rangeList->next = NEW(RangeList); | 79 rangeList->next = NEW(RangeList); |
79 rangeList = rangeList->next; | 80 rangeList = rangeList->next; |
80 rangeList->begin = (unsigned long)ri->ptr; | 81 rangeList->begin = (unsigned long)*ri->ptr; |
81 rangeList->end = (unsigned long)ri->ptr; | 82 rangeList->end = (unsigned long)*ri->ptr; |
82 rangeList->next = NULL; | 83 rangeList->next = NULL; |
83 } | 84 } |
84 // TODO literal support | 85 // TODO literal support |
85 // merge rangeList here | 86 // merge rangeList here |
86 if (*ri->ptr) ri->ptr++; | 87 if (*ri->ptr) ri->ptr++; |
117 return; | 118 return; |
118 } else if (ri->ptr[0] == '|'){ | 119 } else if (ri->ptr[0] == '|'){ |
119 ri->ptr++; | 120 ri->ptr++; |
120 ri->tokenType = '|'; | 121 ri->tokenType = '|'; |
121 ri->tokenValue = NULL; | 122 ri->tokenValue = NULL; |
122 ri->orNum++; | |
123 return; | 123 return; |
124 } else if (ri->ptr[0] == '*'){ | 124 } else if (ri->ptr[0] == '*'){ |
125 ri->ptr++; | 125 ri->ptr++; |
126 ri->tokenType = '*'; | 126 ri->tokenType = '*'; |
127 ri->tokenValue = NULL; | 127 ri->tokenValue = NULL; |