Mercurial > hg > Members > masakoha > testcode
changeset 76:d98a036441e2
add createNode comment
author | masa |
---|---|
date | Fri, 28 Aug 2015 20:36:16 +0900 |
parents | 6541eae41a73 |
children | 7f53a587bf97 |
files | c/regexParser/main.cc |
diffstat | 1 files changed, 18 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/c/regexParser/main.cc Fri Aug 28 18:40:33 2015 +0900 +++ b/c/regexParser/main.cc Fri Aug 28 20:36:16 2015 +0900 @@ -10,15 +10,6 @@ #include <stdlib.h> #include <string.h> -typedef struct charClass { - unsigned char table[256]; - struct utf8Range { - unsigned char *begin; - unsigned char *end; - struct utf8Range *next; - } *rangeList; -} CharClass, *CharClassPtr; - typedef struct node { unsigned char type; union value { @@ -31,6 +22,16 @@ struct node *right; } Node, *NodePtr; +typedef struct charClass { + NodePtr nextState[256]; + struct utf8Range { + unsigned char *begin; + unsigned char *end; + struct utf8Range *next; + NodePtr nextState; + } *rangeList; +} CharClass, *CharClassPtr; + unsigned char *ptr; unsigned char tokenType; int tokenValue; @@ -38,12 +39,10 @@ NodePtr charClass(); NodePtr group(); -NodePtr orexp(); -NodePtr asterisk(); NodePtr regex(); NodePtr createNode(unsigned char,NodePtr,NodePtr); -extern void token(); -extern NodePtr regexAtom(); +void token(); +NodePtr regexAtom(); bool isLiteral(char c) { @@ -55,6 +54,12 @@ return true; } +/** + * Create a node of regex parse tree. + * tokenType + * regexPosition(state) + * stateTransitionTable + */ NodePtr createNode(unsigned char character, NodePtr left, NodePtr right) { NodePtr n = (NodePtr)malloc(sizeof(Node)); n->self = n;