diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/parser.h | 21 | ||||
-rw-r--r-- | src/include/token.h | 36 |
2 files changed, 35 insertions, 22 deletions
diff --git a/src/include/parser.h b/src/include/parser.h index 59cd0ae..eae09d4 100644 --- a/src/include/parser.h +++ b/src/include/parser.h @@ -5,14 +5,27 @@ #include "tree.h" #include "token.h" +typedef enum PARSER_STATE { + PARSER_STATE_BLOCK, + PARSER_STATE_EXPR, + PARSER_STATE_LINT, + PARSER_STATE_LSTR, + PARSER_STATE_TAG, + PARSER_STATE_DARG, + PARSER_STATE_CARG, + PARSER_STATE_DEF, + PARSER_STATE_CALL, +} parser_state_t; + typedef struct PARSER { + /* What the parser's looking at. */ + parser_state_t state; + /* The token list being consumed. */ token_t* token; /* The AST being produced. */ tree_t* tree; - - /* Pointer to the part of the tree the parser is currently working on. */ } parser_t; /* Creates a new parser. */ @@ -46,7 +59,7 @@ tree_t* parser_parse_lstr(parser_t* parser); /* Return the tree for an expression.*/ tree_t* parser_parse_expr(parser_t* parser); -/* Return the tree for an expression. */ +/* Return the tree for an block. */ tree_t* parser_parse_block(parser_t* parser); /* Return the tree for a definition's arguments. */ @@ -62,7 +75,7 @@ tree_t* parser_parse_carg(parser_t* parser); tree_t* parser_parse_call(parser_t* parser); /* Parse. */ -tree_t* parser_parse(parser_t* parser); +void parser_parse(parser_t* parser); /* Parse with the given parser. */ void parser_run(parser_t* parser); diff --git a/src/include/token.h b/src/include/token.h index f95f066..b4dd74d 100644 --- a/src/include/token.h +++ b/src/include/token.h @@ -4,24 +4,24 @@ #include "util.h" typedef enum TOKEN_TYPE { - TOKEN_UNKNOWN, - TOKEN_CHAR, - TOKEN_STR, - TOKEN_EXPR_END, - TOKEN_SET, - TOKEN_LGROUP, - TOKEN_RGROUP, - TOKEN_APPLY, - TOKEN_LIST_DELIM, - TOKEN_TAG, - TOKEN_NAMESPACE_DELIM, - TOKEN_LBLOCK, - TOKEN_RBLOCK, - TOKEN_RLIST, - TOKEN_LLIST, - TOKEN_ESC, - TOKEN_KWD, - TOKEN_INT + TOKEN_TYPE_UNKNOWN, + TOKEN_TYPE_CHAR, + TOKEN_TYPE_STR, + TOKEN_TYPE_EXPR_END, + TOKEN_TYPE_SET, + TOKEN_TYPE_LGROUP, + TOKEN_TYPE_RGROUP, + TOKEN_TYPE_APPLY, + TOKEN_TYPE_LIST_DELIM, + TOKEN_TYPE_TAG, + TOKEN_TYPE_NAMESPACE_DELIM, + TOKEN_TYPE_LBLOCK, + TOKEN_TYPE_RBLOCK, + TOKEN_TYPE_RLIST, + TOKEN_TYPE_LLIST, + TOKEN_TYPE_ESC, + TOKEN_TYPE_KWD, + TOKEN_TYPE_INT } token_type_t; /* Token struct. */ |