Mercurial > hg > Applications > Grep
changeset 164:93d3ad1d20ed pairPro
add mergeTest.cc
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 19 Dec 2015 14:22:17 +0900 |
parents | f0a347cd9c6a |
children | 42f4ee38196e |
files | c/regexParser/Makefile c/regexParser/mergeTest.cc c/regexParser/subsetConstraction.h |
diffstat | 3 files changed, 78 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/c/regexParser/Makefile Fri Dec 18 19:44:07 2015 +0900 +++ b/c/regexParser/Makefile Sat Dec 19 14:22:17 2015 +0900 @@ -1,29 +1,35 @@ TARGET= regexParser +MERGE= mergeTest CFLAGS= -Wall -O0 -g CC= clang++ SRCS_TMP = $(wildcard *.cc) -SRCS_EXCLUDE = determinize.cc +SRCS_EXCLUDE = determinize.cc mergeTest.cc SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) OBJS = $(SRCS:.cc=.o) -.SUFFIXES: .cc .o +SRCS_TMP1_MERGE = $(wildcard *.cc) +SRCS_EXCLUDE1_MERGE = determinize.cc main.cc +SRCS1_MERGE = $(filter-out $(SRCS_EXCLUDE1_MERGE),$(SRCS_TMP1_MERGE)) +OBJS_MERGE = $(SRCS1_MERGE:.cc=.o) .cc.o: $(CC) $(CFLAGS) -c $< -o $@ -all: $(TARGET) +all: $(TARGET) $(MERGE) $(TARGET):$(OBJS) $(CC) -o $@ $(OBJS) -link: - $(CC) -o $(TARGET) $(OBJS) $(TASK_OBJS) $(LIBS) +$(MERGE):$(OBJS_MERGE) + $(CC) -o $@ $(OBJS_MERGE) clean: - rm -f $(TARGET) $(OBJS) + rm -f $(TARGET) $(MERGE) $(OBJS) $(OBJS_MERGE) rm -f *~ \#* +.SUFFIXES: .cc .o + test: ./$(TARGET) -regex 'a' ./$(TARGET) -regex 'ab' @@ -67,4 +73,25 @@ ./$(TARGET) -regex '[d-gh-ja-e]' merge_test: - ./mergetest -regex '[d-gh-ja-e]' -merge '[b-e]' + ./$(MERGE) -regex '[f-i]' -merge '[d-e]' + ./$(MERGE) -regex '[f-i]' -merge '[d-f]' + ./$(MERGE) -regex '[f-i]' -merge '[d-g]' + ./$(MERGE) -regex '[f-i]' -merge '[d-i]' + ./$(MERGE) -regex '[f-i]' -merge '[d-k]' + ./$(MERGE) -regex '[f-i]' -merge '[f-g]' + ./$(MERGE) -regex '[f-i]' -merge '[f-i]' + ./$(MERGE) -regex '[f-i]' -merge '[f-k]' + ./$(MERGE) -regex '[f-i]' -merge '[g-h]' + ./$(MERGE) -regex '[f-i]' -merge '[g-i]' + ./$(MERGE) -regex '[f-i]' -merge '[g-k]' + ./$(MERGE) -regex '[f-i]' -merge '[i-k]' + ./$(MERGE) -regex '[f-i]' -merge '[j-k]' + ./$(MERGE) -regex '[c-e][f-i]' -merge '[d-e]' + ./$(MERGE) -regex '[c-e][f-i]' -merge '[d-f]' + ./$(MERGE) -regex '[c-e][f-i]' -merge '[d-g]' + ./$(MERGE) -regex '[c-e][f-i]' -merge '[d-i]' + ./$(MERGE) -regex '[c-e][f-i][j-m]' -merge '[d-k]' + ./$(MERGE) -regex '[f-i][j-m]' -merge '[f-k]' + ./$(MERGE) -regex '[f-i][j-m]' -merge '[g-k]' + ./$(MERGE) -regex '[f-i][j-m]' -merge '[i-k]' + ./$(MERGE) -regex '[f-i][j-m]' -merge '[j-k]'
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c/regexParser/mergeTest.cc Sat Dec 19 14:22:17 2015 +0900 @@ -0,0 +1,43 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "subsetConstraction.h" + +extern NodePtr regex(RegexInfoPtr); +extern void printTree(NodePtr); + +int main(int argc, char **argv) +{ + RegexInfoPtr ri = (RegexInfoPtr)malloc(sizeof(RegexInfo)); + ri->nodeNumber = 1; + unsigned char* merge = NULL; + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i],"-regex") == 0) { + ri->ptr = (unsigned char*)argv[i+1]; i++; + } else if (strcmp(argv[i],"-merge") == 0) { + merge = (unsigned char*)argv[i+1]; i++; + } + } + printf("regex : %s\n",ri->ptr); + printf("merge : %s\n",merge); + + unsigned char begin, end; + if (merge[0] == '[') merge++; + begin = *merge; + end = *merge; + for (; *merge && *merge != ']'; merge++) { + if (*merge == '-') { + end = *(merge + 1); + merge++; + continue; + } + if (merge[0] == 0 || merge[0] == ']') break; + begin = *merge; + end = *merge; + } + NodePtr n = regex(ri); + printTree(n); + BitVector nextState; + charClassMerge(n->cc,begin,end,nextState); + return 0; +}
--- a/c/regexParser/subsetConstraction.h Fri Dec 18 19:44:07 2015 +0900 +++ b/c/regexParser/subsetConstraction.h Sat Dec 19 14:22:17 2015 +0900 @@ -11,7 +11,4 @@ bool asterisk; } TGValue, *TGValuePtr; -void printTransition(TransitionPtr ts); -TGValue generateTransition(NodePtr n,TransitionGenerator tg); -StatePtr createStateList(NodePtr n); -TransitionGenerator generateTransitionList(NodePtr n); +CharClassPtr charClassMerge(CharClassPtr cc,unsigned long begin, unsigned long end, BitVector nextState);