Mercurial > hg > Members > masakoha > testcode
changeset 62:a49b4a8b8c14
implement isLiteral
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 14 Jul 2015 16:45:07 +0900 |
parents | 67cade0e35b0 |
children | 8fd3d35e9861 |
files | c/regexParser/main.cc |
diffstat | 1 files changed, 11 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ // <charClass> ::= '['<literal>'-'<literal>']' NodePtr charClass() { - + ptr++; + NodePtr n = (NodePtr)malloc(sizeof(Node)); + return n; } // <literal> ::= [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; -} - // <string> ::= <literal><literal>* 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; }