Mercurial > hg > Members > masakoha > testcode
changeset 119:2f0653f8eabb pairPro
fix
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 26 Nov 2015 18:05:39 +0900 |
parents | 166136236891 |
children | aa266a4db47c |
files | c/regexParser/regexParser.cc |
diffstat | 1 files changed, 11 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/c/regexParser/regexParser.cc Wed Nov 25 14:58:03 2015 +0900 +++ b/c/regexParser/regexParser.cc Thu Nov 26 18:05:39 2015 +0900 @@ -3,7 +3,7 @@ #include "regexParser.h" #include "error.h" -static NodePtr createNode(RegexInfoPtr,unsigned char,NodePtr,NodePtr); +static NodePtr createNode(RegexInfoPtr,NodePtr,NodePtr); static NodePtr charClass(RegexInfoPtr); static NodePtr group(RegexInfoPtr); static void token(RegexInfoPtr); @@ -25,14 +25,14 @@ } static -NodePtr createNode(RegexInfoPtr ri,unsigned char character, NodePtr left, NodePtr right) { +NodePtr createNode(RegexInfoPtr ri, NodePtr left, NodePtr right) { NodePtr n = allocateNode(); if (n == NULL) { mallocFailedMessage(); } n->tokenType = ri->tokenType; - n->cc->cond->character = character; + n->cc->cond->character = ri->tokenValue; n->left = left; n->right = right; @@ -60,7 +60,7 @@ // <literal> ::= [a-z][A-Z][0-9] static NodePtr literal(RegexInfoPtr ri) { - NodePtr n = createNode(ri,ri->ptr[0],0,0); + NodePtr n = createNode(ri,0,0); ri->ptr++; return n; } @@ -98,12 +98,12 @@ } else if (ri->ptr[0] == '|'){ ri->ptr++; ri->tokenType = '|'; - ri->tokenValue = 0; + ri->tokenValue = '|'; return; } else if (ri->ptr[0] == '*'){ ri->ptr++; ri->tokenType = '*'; - ri->tokenValue = 0; + ri->tokenValue = '*'; return; } else if (ri->ptr[0] == '\\'){ // need more proccesing @@ -144,15 +144,17 @@ while (ri->ptr[0]) { token(ri); if (ri->tokenType == '*') { - n = createNode(ri,'*',n,0); + n = createNode(ri,n,0); } else if (ri->tokenType == '|') { NodePtr n1 = regex(ri); - n = createNode(ri,'|',n,n1); + ri->tokenValue = '|'; + n = createNode(ri,n,n1); } else if (ri->tokenType == ')') { return n; } else { NodePtr n1 = regex(ri); - n = createNode(ri,'+',n,n1); + ri->tokenValue = '+'; + n = createNode(ri,n,n1); } } return n; }