# HG changeset patch # User Masataka Kohagura # Date 1440503786 -32400 # Node ID 58d2b10988c9db908677b921be0e36e21da6fb0d # Parent 87dff3a124abaa171d7c086eb469e4049f9c1e51 move ptr++ in token() diff -r 87dff3a124ab -r 58d2b10988c9 c/regexParser/main.cc --- a/c/regexParser/main.cc Tue Aug 25 13:02:56 2015 +0900 +++ b/c/regexParser/main.cc Tue Aug 25 20:56:26 2015 +0900 @@ -98,11 +98,9 @@ // ::= '('')' NodePtr group() { - ptr++; NodePtr n = regex(); if (*ptr == ')') { n = createNode('(',n,0); - ptr++; } else { // ) reqiured } @@ -110,9 +108,11 @@ } + void token() { while (*ptr != '\0') { if ((*ptr == '(') || (*ptr == ')')) { + ptr++; tokenType = '('; tokenValue = 0; if (ptr[1] == ')') { @@ -120,6 +120,7 @@ } return; } else if (*ptr == '[') { + ptr++; tokenType = '['; tokenValue = *ptr; if (ptr[1] == ']') { @@ -127,10 +128,12 @@ } return; } else if (*ptr == '|'){ + ptr++; tokenType = '|'; tokenValue = 0; return; } else if (*ptr == '*'){ + ptr++; tokenType = '*'; tokenValue = 0; return; @@ -150,6 +153,10 @@ */ } + + tokenType = 0; + tokenValue = 0; + return; } // ::= || @@ -170,9 +177,8 @@ while (*ptr) { token(); if (tokenType == '*') { - n = createNode('*',n,0); ptr++; + n = createNode('*',n,0); } else if (tokenType == '|') { - ptr++; NodePtr n1 = regex(); n = createNode('|',n,n1); } else {