Mercurial > hg > Members > masakoha > testcode
diff c/regexParser/createRegexParser.cc @ 112:ec485345daf9 pairPro
some function use static
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 23 Nov 2015 15:54:19 +0900 |
parents | 70069d4647a0 |
children |
line wrap: on
line diff
--- a/c/regexParser/createRegexParser.cc Sat Nov 21 18:04:25 2015 +0900 +++ b/c/regexParser/createRegexParser.cc Mon Nov 23 15:54:19 2015 +0900 @@ -2,11 +2,11 @@ #include <stdio.h> #include "regexParser.h" -NodePtr createNode(RegexInfoPtr,unsigned char,NodePtr,NodePtr); -NodePtr charClass(RegexInfoPtr); -NodePtr group(RegexInfoPtr); -void token(RegexInfoPtr); -NodePtr regexAtom(RegexInfoPtr); +static NodePtr createNode(RegexInfoPtr,unsigned char,NodePtr,NodePtr); +static NodePtr charClass(RegexInfoPtr); +static NodePtr group(RegexInfoPtr); +static void token(RegexInfoPtr); +static NodePtr regexAtom(RegexInfoPtr); NodePtr regex(RegexInfoPtr); /** @@ -15,11 +15,12 @@ * regexPosition(state) * stateTransitionTable */ + +static NodePtr createNode(RegexInfoPtr ri,unsigned char character, NodePtr left, NodePtr right) { NodePtr n = (NodePtr)malloc(sizeof(Node)); if (n == NULL) { - fprintf(stderr, "Failed to allocate memory.\n"); - exit(-1); + mallocFailedMessage(); } n->tokenType = ri->tokenType; @@ -44,11 +45,11 @@ } // <charClass> ::= '['<literal>'-'<literal>']' +static NodePtr charClass(RegexInfoPtr ri) { NodePtr n = (NodePtr)malloc(sizeof(Node)); if (n == NULL) { - fprintf(stderr, "Failed to allocate memory.\n"); - exit(-1); + mallocFailedMessage(); } while (ri->ptr[0] == '-') { ri->ptr++; @@ -57,6 +58,7 @@ } // <literal> ::= [a-z][A-Z][0-9] +static NodePtr literal(RegexInfoPtr ri) { NodePtr n = createNode(ri,ri->ptr[0],0,0); ri->ptr++; @@ -64,12 +66,12 @@ } // <group> ::= '('<regex>')' +static NodePtr group(RegexInfoPtr ri) { return regex(ri); } - - +static void token(RegexInfoPtr ri) { while (ri->ptr[0] != '\0') { if (ri->ptr[0] == '('){ @@ -124,6 +126,7 @@ } // <regexAtom> ::= <literal>|<charClass>|<group> +static NodePtr regexAtom(RegexInfoPtr ri) { token(ri);