# HG changeset patch # User Masataka Kohagura # Date 1436859907 -32400 # Node ID a49b4a8b8c148358e3f724b397650a304cb711de # Parent 67cade0e35b084af93c04471dd6a6b24dbf3f284 implement isLiteral diff -r 67cade0e35b0 -r a49b4a8b8c14 c/regexParser/main.cc --- a/c/regexParser/main.cc Tue Jul 14 16:00:44 2015 +0900 +++ b/c/regexParser/main.cc Tue Jul 14 16:45:07 2015 +0900 @@ -30,6 +30,13 @@ NodePtr regex(); NodePtr createNode(char,NodePtr,NodePtr); +bool isLiteral(char c) { + if (('a'<=c && c<='z')||('A'<=c && c<='Z')||('0'<=c && c<='9')) { + return true; + } + return false; +} + void printNodeDate(NodePtr n) { puts("---------------------"); printf("Self Node char : %c\n", n->character); @@ -53,7 +60,9 @@ // ::= '[''-'']' NodePtr charClass() { - + ptr++; + NodePtr n = (NodePtr)malloc(sizeof(Node)); + return n; } // ::= [a-z][A-Z][0-9] @@ -64,13 +73,6 @@ return n; } -bool isLiteral(char c) { - if (('a'<=c && c<='z')||('A'<=c && c<='Z')||('0'<=c && c<='9')) { - return true; - } - return false; -} - // ::= * NodePtr string() { char c = *ptr; @@ -93,7 +95,6 @@ ptr++; n = regex(); } - return n; } @@ -131,12 +132,10 @@ regexHeadNode = n; } } - return n; } -int -main(int argc, char **argv) +int main(int argc, char **argv) { for (int i = 1; i < argc; i++) { if (strcmp(argv[i],"-regex") == 0) { @@ -146,6 +145,5 @@ printf("regex : %s\n",ptr); NodePtr n = regex(); - return 0; }