Mercurial > hg > Members > masakoha > testcode
changeset 132:fb4c8adf3a80 pairPro
fix include '|' in regex
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 02 Dec 2015 23:30:48 +0900 |
parents | a436526756b9 |
children | ccc673449351 |
files | c/regexParser/main.cc c/regexParser/regexParser.cc |
diffstat | 2 files changed, 6 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/c/regexParser/main.cc Wed Dec 02 18:01:32 2015 +0900 +++ b/c/regexParser/main.cc Wed Dec 02 23:30:48 2015 +0900 @@ -12,6 +12,7 @@ { RegexInfoPtr ri = (RegexInfoPtr)malloc(sizeof(RegexInfo)); ri->nodeNumber = 1; + ri->orFlag = 0; for (int i = 1; i < argc; i++) { if (strcmp(argv[i],"-regex") == 0) {
--- a/c/regexParser/regexParser.cc Wed Dec 02 18:01:32 2015 +0900 +++ b/c/regexParser/regexParser.cc Wed Dec 02 23:30:48 2015 +0900 @@ -132,7 +132,7 @@ ri->ptr++; ri->tokenType = '|'; ri->tokenValue = NULL; - ri->orFlag = true; + ri->orFlag++; return; } else if (ri->ptr[0] == '*'){ ri->ptr++; @@ -187,15 +187,15 @@ NodePtr n1 = regex(ri); n = createNode(ri,'|',n,n1); } else if (ri->tokenType == ')') { - if (ri->orFlag == true) { - ri->ptr--; - ri->orFlag = false; + if (ri->orFlag != 0) { + if (ri->ptr[0] != ')') ri->ptr--; + ri->orFlag--; } return n; } else { // return NULL NodePtr n1 = regex(ri); - n = createNode(ri,'a',n,n1); + n = createNode(ri,'+',n,n1); } } return n; }