diff --git a/main.c b/main.c index de27c68..528dcf8 100644 --- a/main.c +++ b/main.c @@ -44,9 +44,7 @@ main(int argc, const char** argv) while(tt != TT_EOF); writeTokenFile(tl); - NodeList* nl = ParseNodes(tl); - - Node* node = nl->first; + Node* node = ParseNodes(tl); printf("nodes:\n"); while(node != NULL) diff --git a/node.c b/node.c index d60a1e9..0dd3118 100644 --- a/node.c +++ b/node.c @@ -10,15 +10,11 @@ static char stringBuff[STRING_BUFF_SIZE]; Node* parseHeader(TokenList** list); Node* parseCodeBlock(TokenList** list); -NodeList* +Node* ParseNodes(TokenList* list) { printf("ParseNodes() start\n"); - NodeList* nl = malloc(sizeof(NodeList)); - nl->first = NULL; - - /*currentNode->next = NULL;*/ - /*currentNode->node = NULL;*/ + Node* first = NULL; TokenList* currentToken = list; Node* prevNode = NULL; @@ -42,7 +38,7 @@ ParseNodes(TokenList* list) case TT_EOF: printf("EOF found\n"); - return nl; + return first; default: // paragraph start? break; @@ -61,14 +57,14 @@ ParseNodes(TokenList* list) prevNode->next = currentNode; } - if (nl->first == NULL) { - nl->first = currentNode; + if (first == NULL) { + first = currentNode; } prevNode = currentNode; } - return nl; + return first; } Node* diff --git a/node.h b/node.h index 6e1c502..26df95c 100644 --- a/node.h +++ b/node.h @@ -31,20 +31,12 @@ typedef enum { NT_Error, } NodeType; -struct NodeList; typedef struct Node { NodeType type; struct Node* next; - /*struct NodeList* children;*/ } Node; -typedef struct NodeList { - struct Node* first; - /*struct Node* node; - struct Node* next;*/ -} NodeList; - typedef struct { NodeType type; struct Node* next; @@ -70,7 +62,7 @@ typedef struct { } ParagraphNode; */ -NodeList* ParseNodes(TokenList* list); +Node* ParseNodes(TokenList* list); char* NodeTypeString(NodeType t); #endif