# HG changeset patch # User mir3636 # Date 1462613934 -32400 # Node ID a4484c02cba56c0231a6e1d940c73f345a9fb7b9 # Parent 90ccd94906c07317e9fa56b976014556a630f265 add wordMode in regexParser diff -r 90ccd94906c0 -r a4484c02cba5 regexParser/CeriumGrep.cc --- a/regexParser/CeriumGrep.cc Tue Feb 09 11:02:35 2016 +0900 +++ b/regexParser/CeriumGrep.cc Sat May 07 18:38:54 2016 +0900 @@ -23,6 +23,7 @@ RegexInfo ri; ri.stateNumber = 1; + ri.wordMode = true; for (int i = 1; i < argc; i++) { if (strcmp(argv[i],"-regex") == 0) { ri.ptr = (unsigned char*)argv[i+1]; i++; @@ -40,6 +41,8 @@ s.filename = filename = argv[i+1]; i++; } else if (strcmp(argv[i],"-ts") == 0) { ts = true; + } else if (strcmp(argv[i],"+word") == 0) { + ri.wordMode = false; } } if (!ri.ptr) return s; diff -r 90ccd94906c0 -r a4484c02cba5 regexParser/regexParser.cc --- a/regexParser/regexParser.cc Tue Feb 09 11:02:35 2016 +0900 +++ b/regexParser/regexParser.cc Sat May 07 18:38:54 2016 +0900 @@ -71,7 +71,16 @@ static NodePtr literal(RegexInfoPtr ri) { CharClassPtr cc = createCharClassWord(ri); - token(ri); + if (ri->wordMode) { + unsigned char *word = ri->ptr - 1; + while (ri->tokenType == 'a') { + token(ri); + } + cc->cond.w.length = ri->ptr - word; + if (cc->cond.w.length > 1) + cc->cond.w.word = word; + } else + token(ri); NodePtr n = createNode(ri,'a',cc,0,0); return n; } diff -r 90ccd94906c0 -r a4484c02cba5 regexParser/regexParser.h --- a/regexParser/regexParser.h Tue Feb 09 11:02:35 2016 +0900 +++ b/regexParser/regexParser.h Sat May 07 18:38:54 2016 +0900 @@ -154,6 +154,7 @@ unsigned char tokenType; unsigned char *tokenValue; int stateNumber; + bool wordMode; } RegexInfo, *RegexInfoPtr; typedef struct {