77 lines
1.2 KiB
C
77 lines
1.2 KiB
C
#include <stdlib.h>
|
|
|
|
#include "token.h"
|
|
|
|
#ifndef NODE_H
|
|
#define NODE_H
|
|
|
|
typedef enum {
|
|
// Stand-alone elements
|
|
// cannot contain text modifiers
|
|
NT_Header1,
|
|
NT_Header2,
|
|
NT_Header3,
|
|
NT_Header4,
|
|
NT_BlockCode,
|
|
|
|
// Container elements
|
|
// can contain text modifiers
|
|
NT_Paragraph,
|
|
NT_UnorderedList,
|
|
NT_OrderedList,
|
|
NT_BlockQuote,
|
|
|
|
// Contained elements (cannot be bare)
|
|
// text modifiers
|
|
NT_InlineCode,
|
|
NT_Bold,
|
|
NT_Underline,
|
|
|
|
// something went wrong
|
|
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;
|
|
char* rawText;
|
|
} HeaderNode;
|
|
|
|
typedef struct {
|
|
NodeType type;
|
|
struct Node* next;
|
|
char* rawText;
|
|
} CodeBlockNode;
|
|
|
|
typedef struct {
|
|
NodeType type;
|
|
struct Node* next;
|
|
char* error;
|
|
} ErrorNode;
|
|
|
|
/*
|
|
typedef struct {
|
|
NodeType type;
|
|
struct Node* next;
|
|
} ParagraphNode;
|
|
*/
|
|
|
|
NodeList* ParseNodes(TokenList* list);
|
|
char* NodeTypeString(NodeType t);
|
|
|
|
#endif
|