Mercurial > hg > Members > masakoha > testcode
changeset 149:f1880f25fabf pairPro
add insertCharClass images
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 16 Dec 2015 15:37:14 +0900 |
parents | d1ebba6e117a |
children | a4940a8dd263 |
files | c/regexParser/Makefile c/regexParser/regexParser.cc |
diffstat | 2 files changed, 48 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/c/regexParser/Makefile Tue Dec 15 18:09:54 2015 +0900 +++ b/c/regexParser/Makefile Wed Dec 16 15:37:14 2015 +0900 @@ -48,8 +48,16 @@ ./$(TARGET) -regex 'a|[a-z]' ./$(TARGET) -regex 'a|[a-z]*' ./$(TARGET) -regex 'a*|[a-z]' - ./$(TARGET) -regex '[a-cb-d]' - ./$(TARGET) -regex '[c-eb-d]' - ./$(TARGET) -regex '[a-db-d]' - ./$(TARGET) -regex '[c-db-d]' - ./$(TARGET) -regex '[b-da-e]' + ./$(TARGET) -regex '[d-ga-c]' + ./$(TARGET) -regex '[d-ga-d]' + ./$(TARGET) -regex '[d-ga-e]' + ./$(TARGET) -regex '[d-ga-f]' + ./$(TARGET) -regex '[d-ga-h]' + ./$(TARGET) -regex '[d-gd-e]' + ./$(TARGET) -regex '[d-gd-f]' + ./$(TARGET) -regex '[d-gd-h]' + ./$(TARGET) -regex '[d-ge-f]' + ./$(TARGET) -regex '[d-ge-g]' + ./$(TARGET) -regex '[d-ge-i]' + ./$(TARGET) -regex '[d-gg-i]' + ./$(TARGET) -regex '[d-gh-i]'
--- a/c/regexParser/regexParser.cc Tue Dec 15 18:09:54 2015 +0900 +++ b/c/regexParser/regexParser.cc Wed Dec 16 15:37:14 2015 +0900 @@ -59,8 +59,35 @@ return cc; } +/* + cond.range.begin cond.range.end + |----------------| + 1.b---e + 2.b------e + 3.b------------e + 4.b-----------------------e + 5.b----------------------------e + + |----------------| + 6. b---------e + 7. b----------------e + 8. b---------------------e + + |----------------| + 9. b-----e + 10. b--------e + 11. b-------------e + + |----------------| + 12. b-----e + + |----------------| + 13. b--e + + */ CharClassPtr insertCharClass(CharClassPtr cc, unsigned char begin, unsigned char end) { - if (end < cc->cond.range.begin ) { + + if (end < cc->cond.range.begin ) { // 1 CharClassPtr cc1 = createCharClassRange(cc->cond.range.begin,cc->cond.range.end,cc->left,cc->right); if (cc->left) { cc1->left = insertCharClass(cc->left,begin,end); @@ -70,13 +97,14 @@ cc1->left = cc2; return cc1; } - } else if (end == cc->cond.range.begin ) { + } else if (end == cc->cond.range.begin ) { // 2 + CharClassPtr cc2 = createCharClassRange(begin,end,0,0); cc->cond.range.begin = begin; - } else if (end <= cc->cond.range.end) { - if (begin < cc->cond.range.begin) { + } else if (end <= cc->cond.range.end) { // 3,4,6,7,9,10 + if (begin < cc->cond.range.begin) { // 3,4 cc->cond.range.begin = begin; } - } else if (begin > cc->cond.range.end ) { + } else if (begin > cc->cond.range.end ) { // 13 CharClassPtr cc1 = createCharClassRange(cc->cond.range.begin,cc->cond.range.end,cc->left,cc->right); if (cc->right) { cc1->right = insertCharClass(cc->right,begin,end); @@ -86,9 +114,9 @@ cc1->right = cc2; return cc1; } - } else if (begin == cc->cond.range.end ) { + } else if (begin == cc->cond.range.end ) { // 12 cc->cond.range.end = end; - } else if (begin < cc->cond.range.begin) { + } else if (begin < cc->cond.range.begin) { // 5 cc->cond.range.begin = begin; } return cc; @@ -115,10 +143,6 @@ continue; } if (ri->ptr[0] == 0 || ri->ptr[0] == ']') break; - if (ri->ptr[0] == rangeList->end + 1) { - rangeList->end = *ri->ptr; - continue; - } rangeList->next = NEW(RangeList); rangeList = rangeList->next; rangeList->begin = *ri->ptr;