Mercurial > hg > Applications > Grep
changeset 116:66c633575b53 pairPro
remove error and warning
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 24 Nov 2015 17:07:08 +0900 |
parents | ca30f8334741 |
children | 166136236891 |
files | c/regexParser/Makefile c/regexParser/bitVector.cc c/regexParser/bitVector.h c/regexParser/bitVectorNode.cc c/regexParser/determinize.cc c/regexParser/error.cc c/regexParser/error.h c/regexParser/main.cc c/regexParser/node.cc c/regexParser/regexParser.cc c/regexParser/regexParser.h c/regexParser/subsetConstraction.cc c/regexParser/transition.cc c/regexParser/transition.h |
diffstat | 14 files changed, 60 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/c/regexParser/Makefile Tue Nov 24 14:38:26 2015 +0900 +++ b/c/regexParser/Makefile Tue Nov 24 17:07:08 2015 +0900 @@ -3,7 +3,7 @@ CC= clang++ SRCS_TMP = $(wildcard *.cc) -SRCS_EXCLUDE = # 除外するファイルを書く +SRCS_EXCLUDE = determinize.cc SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) OBJS = $(SRCS:.cc=.o)
--- a/c/regexParser/bitVector.cc Tue Nov 24 14:38:26 2015 +0900 +++ b/c/regexParser/bitVector.cc Tue Nov 24 17:07:08 2015 +0900 @@ -2,13 +2,8 @@ #include <stdlib.h> #include <string.h> #include "bitVector.h" -#include "regexParser.h" - extern BitVectorListPtr allocateBitVectorList(); -BitVectorListPtr createBitVector(NodePtr,BitVectorListPtr); const BitVectorPtr allocateBitVector(); -BitVectorPtr bitSet(int); -void bitPrint(BitVectorPtr); int bitBlock = sizeof(unsigned long) * 8; @@ -43,7 +38,7 @@ BitVectorPtr bi = allocateBitVector(); - bi->arrayNum = (bitSetPosition + bitBlock - 1) / bitBlock; + bi->arrayNum = (bitSetPosition + bitBlock) / bitBlock; int arrayPosition = bitSetPosition / bitBlock;
--- a/c/regexParser/bitVector.h Tue Nov 24 14:38:26 2015 +0900 +++ b/c/regexParser/bitVector.h Tue Nov 24 17:07:08 2015 +0900 @@ -1,5 +1,6 @@ +#include "regexParser.h" + #define BITBLOCK (sizeof(unsigned long) * 8) - typedef struct bitVector { int arrayNum; unsigned long *bitContainer; @@ -13,3 +14,7 @@ bool isLoopAnker; bool isLoop; }BitVectorList, *BitVectorListPtr; + +BitVectorListPtr createBitVector(NodePtr,BitVectorListPtr); +BitVectorPtr bitSet(int); +void bitPrint(BitVectorPtr);
--- a/c/regexParser/bitVectorNode.cc Tue Nov 24 14:38:26 2015 +0900 +++ b/c/regexParser/bitVectorNode.cc Tue Nov 24 17:07:08 2015 +0900 @@ -2,7 +2,6 @@ #include <stdlib.h> #include <ctype.h> #include "bitVector.h" -#include "regexParser.h" extern BitVectorPtr bitSet(int); BitVectorListPtr allocateBitVectorList();
--- a/c/regexParser/determinize.cc Tue Nov 24 14:38:26 2015 +0900 +++ b/c/regexParser/determinize.cc Tue Nov 24 17:07:08 2015 +0900 @@ -12,5 +12,5 @@ x1->next = createTransition(x->condition, x->nextState); x1 = x1->next; } - return x0; + return x0; }
--- a/c/regexParser/error.cc Tue Nov 24 14:38:26 2015 +0900 +++ b/c/regexParser/error.cc Tue Nov 24 17:07:08 2015 +0900 @@ -1,4 +1,5 @@ #include <stdio.h> +#include "error.h" void mallocFailedMessage() { fprintf(stderr, "Failed to allocate memory.\n");
--- a/c/regexParser/error.h Tue Nov 24 14:38:26 2015 +0900 +++ b/c/regexParser/error.h Tue Nov 24 17:07:08 2015 +0900 @@ -1,1 +1,2 @@ +#include <stdlib.h> void mallocFailedMessage();
--- a/c/regexParser/main.cc Tue Nov 24 14:38:26 2015 +0900 +++ b/c/regexParser/main.cc Tue Nov 24 17:07:08 2015 +0900 @@ -1,15 +1,6 @@ -/* - * <literal> ::= [a-z][A-Z][0-9] - * <charClass> ::= '['<literal>'-'<literal>']' - * <group> ::= '('<regex>')' - * <regexAtom> ::= <literal>|<charClass>|<group> - * <regex> ::= <regexAtom>|<regexAtom>'*'|<regexAtom>'|'<regex>|<regexAtom><regex> - */ - #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "regexParser.h" #include "bitVector.h" extern NodePtr regex(RegexInfoPtr);
--- a/c/regexParser/node.cc Tue Nov 24 14:38:26 2015 +0900 +++ b/c/regexParser/node.cc Tue Nov 24 17:07:08 2015 +0900 @@ -6,17 +6,19 @@ static void descendTree(NodePtr n, int d) { if (n->right != NULL) { - descendTree(n->right, d+1); + d++; + descendTree(n->right, d); d--; } if (n->tokenType == 'a') { - printf("%*c%c(%d)\n",d*4, ' ',n->Value.character,n->nodeNumber); + printf("%*c%c(%lu)\n",d*4, ' ',n->cc->cond->character,n->nodeNumber); } else { - printf("%*c%c\n",d*4, ' ',n->Value.character); + printf("%*c%c\n",d*4, ' ',n->cc->cond->character); } if (n->left != NULL) { - descendTree(n->left, d+1); + d++; + descendTree(n->left, d); d--; } }
--- a/c/regexParser/regexParser.cc Tue Nov 24 14:38:26 2015 +0900 +++ b/c/regexParser/regexParser.cc Tue Nov 24 17:07:08 2015 +0900 @@ -3,13 +3,6 @@ #include "regexParser.h" #include "error.h" -typedef struct regexInfo { - unsigned char *ptr; - unsigned char tokenType; - int tokenValue; - int nodeNumber; -} RegexInfo, *RegexInfoPtr; - static NodePtr createNode(RegexInfoPtr,unsigned char,NodePtr,NodePtr); static NodePtr charClass(RegexInfoPtr); static NodePtr group(RegexInfoPtr); @@ -24,15 +17,22 @@ * stateTransitionTable */ +NodePtr allocateNode() { + NodePtr n = (NodePtr)malloc(sizeof(node)); + n->cc = (CharClassPtr)malloc(sizeof(CharClass)); + n->cc->cond = (ConditionList)malloc(sizeof(Condition)); + return n; +} + static NodePtr createNode(RegexInfoPtr ri,unsigned char character, NodePtr left, NodePtr right) { - NodePtr n = (NodePtr)malloc(sizeof(Node)); + NodePtr n = allocateNode(); if (n == NULL) { mallocFailedMessage(); } n->tokenType = ri->tokenType; - n->cc->conditionList->character = character; + n->cc->cond->character = character; n->left = left; n->right = right;
--- a/c/regexParser/regexParser.h Tue Nov 24 14:38:26 2015 +0900 +++ b/c/regexParser/regexParser.h Tue Nov 24 17:07:08 2015 +0900 @@ -3,17 +3,19 @@ long length; } Word, *WordPtr; +typedef union condition { + struct utf8Range { + unsigned char *begin; + unsigned char *end; + struct utf8Range *next; + } rangeList; + unsigned char character; + WordPtr w; +} Condition, *ConditionList; + typedef struct charClass { unsigned char type; - union condition { - struct utf8Range { - unsigned char *begin; - unsigned char *end; - struct utf8Range *next; - } rangeList; - unsigned char character; - WordPtr w; - } *conditionList; + ConditionList cond; struct charClass *left; struct charClass *right; unsigned long *begin; @@ -27,3 +29,10 @@ struct node *left; struct node *right; } Node, *NodePtr; + +typedef struct regexInfo { + unsigned char *ptr; + unsigned char tokenType; + int tokenValue; + int nodeNumber; +} RegexInfo, *RegexInfoPtr;
--- a/c/regexParser/subsetConstraction.cc Tue Nov 24 14:38:26 2015 +0900 +++ b/c/regexParser/subsetConstraction.cc Tue Nov 24 17:07:08 2015 +0900 @@ -2,8 +2,9 @@ #include <stdlib.h> #include <ctype.h> #include "bitVector.h" -#include "regexParser.h" +extern BitVectorListPtr initBitVector(); +BitVectorListPtr setNextBitVectorList(unsigned char, BitVectorListPtr, BitVectorListPtr); void printBitVectorList (BitVectorListPtr bvl) { bool isFirstPrint = true; @@ -30,7 +31,7 @@ BitVectorListPtr descendTreeNode(NodePtr n,BitVectorListPtr bvl, BitVectorListPtr prev, bool &fromOr, bool &fromAsterisk) { bool leftIsOr, rightIsOr; - if (n->Value.character == '*') { + if (n->cc->cond->character == '*') { bvl = descendTreeNode(n->left, bvl, prev, leftIsOr, fromAsterisk); unsigned char repertChar = 0; for (int i = 0; i < 256; i++) { @@ -41,26 +42,26 @@ fromAsterisk = true; return prev; - } else if (n->Value.character == '|') { + } else if (n->cc->cond->character == '|') { bvl = descendTreeNode(n->left, bvl, prev, leftIsOr, fromAsterisk); - setNextBitVectorList(n->left->Value.character, prev, bvl); + setNextBitVectorList(n->left->cc->cond->character, prev, bvl); bvl = descendTreeNode(n->right, bvl, prev, rightIsOr, fromAsterisk); - setNextBitVectorList(n->right->Value.character, prev, bvl); + setNextBitVectorList(n->right->cc->cond->character, prev, bvl); fromOr = true; return prev; - } else if (n->Value.character == '+') { + } else if (n->cc->cond->character == '+') { bvl = descendTreeNode(n->left, bvl, prev, leftIsOr, fromAsterisk); - setNextBitVectorList(n->left->Value.character, prev, bvl); + setNextBitVectorList(n->left->cc->cond->character, prev, bvl); prev = bvl; bvl = descendTreeNode(n->right, bvl, prev, rightIsOr, fromAsterisk); if (leftIsOr){ for (int i = 0; i < 256; i++) if (prev->next[i] != NULL) - setNextBitVectorList(n->right->Value.character, prev->next[i], bvl); + setNextBitVectorList(n->right->cc->cond->character, prev->next[i], bvl); } else { - setNextBitVectorList(n->right->Value.character, prev, bvl); + setNextBitVectorList(n->right->cc->cond->character, prev, bvl); } fromOr = false;
--- a/c/regexParser/transition.cc Tue Nov 24 14:38:26 2015 +0900 +++ b/c/regexParser/transition.cc Tue Nov 24 17:07:08 2015 +0900 @@ -1,3 +1,4 @@ +#include <stdlib.h> #include "transition.h" TransitionPtr createTransition(CharClass,BitVectorPtr); @@ -15,7 +16,7 @@ TransitionPtr x0 = x; for(;;) { if (x->next == NULL) { - x->next = y + x->next = y; return x0; } }
--- a/c/regexParser/transition.h Tue Nov 24 14:38:26 2015 +0900 +++ b/c/regexParser/transition.h Tue Nov 24 17:07:08 2015 +0900 @@ -1,14 +1,15 @@ +#include "bitVector.h" + typedef struct transition { CharClassPtr condition; BitVectorPtr nextState; struct transition *next; -} Transition, TransitionPtr; - +} Transition, *TransitionPtr; typedef struct state { TransitionPtr transition; struct state *next; -} State; StatePtr; +} State, *StatePtr; /* 正規表現木を辿って transition のList をつくる CharClass のかさなりを判定して重なりのない新しいCharClassをつくる