diff c/regexParser/regexParser.cc @ 130:7925e9abb078 pairPro

add or flag
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Wed, 02 Dec 2015 17:51:02 +0900
parents b930be74a16e
children fb4c8adf3a80
line wrap: on
line diff
--- a/c/regexParser/regexParser.cc	Tue Dec 01 23:05:53 2015 +0900
+++ b/c/regexParser/regexParser.cc	Wed Dec 02 17:51:02 2015 +0900
@@ -79,7 +79,7 @@
     int i = 0;
 
     RangeListPtr rangeList = cc->cond->range;
-  
+
     while (ri->ptr[i] != ']') {
         if (ri->ptr[i] == '-') i++;
 
@@ -132,6 +132,7 @@
             ri->ptr++;
             ri->tokenType = '|';
             ri->tokenValue = NULL;
+            ri->orFlag = true;
             return;
         } else if (ri->ptr[0] == '*'){
             ri->ptr++;
@@ -153,13 +154,16 @@
             while (isalnum(ri->ptr[0])) {
                 ri->ptr++;
             }
+            if (ri->ptr[0] == '*') {
+                ri->astarFlag = true;
+            }
             return;
         }
     }
     return;
 }
 
-// <regexAtom> ::= <literal>|<charClass>
+// <regexAtom> ::= <literal>|<charClass>|<group>
 static
 NodePtr regexAtom(RegexInfoPtr ri) {
 
@@ -172,7 +176,7 @@
     return n;
 }
 
-// <regex> ::= <regexAtom> | <regexAtom>'*' | <regexAtom>'|'<regex> | <regexAtom><regex> | '(' regex ')'
+// <regex> ::= <regexAtom> | <regexAtom>'*'<regex> | <regexAtom>'|'<regex> | <regexAtom><regex> |
 NodePtr regex(RegexInfoPtr ri) {
     NodePtr n = regexAtom(ri);
     while (ri->ptr[0]) {
@@ -183,6 +187,10 @@
             NodePtr n1 = regex(ri);
             n = createNode(ri,'|',n,n1);
         } else if (ri->tokenType == ')') {
+            if (ri->orFlag == true) {
+                ri->ptr--;
+                ri->orFlag = false;
+            }
             return n;
         } else {
             // return NULL