diff options
author | c+1 | 2023-05-06 09:39:43 -0400 |
---|---|---|
committer | c+1 | 2023-05-06 09:39:43 -0400 |
commit | deb8d97be58847031e7f4ef25d7107cb2dbc35a3 (patch) | |
tree | 9568006267e1f917526ca26dcd0db55aae5b0ddd /src/include | |
parent | 6f2cb8f35da2ddb8e5ad8d81341de6d94139b974 (diff) |
HALK HALK HALK
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/parser.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/include/parser.h b/src/include/parser.h new file mode 100644 index 0000000..5ff8366 --- /dev/null +++ b/src/include/parser.h @@ -0,0 +1,46 @@ +#ifndef PARSER_H +#define PARSER_H + + +#include "token.h" +#include "tree.h" +#include "lexer.h" + + +typedef struct PARSER_STRUC { + lexer_t* lexer; + token_t* token; +} parser_t; + +// initialize a parser +parser_t* parser_init(lexer_t* lexer); + +// check for expected token, or throw syntax error +void parser_check_expect(parser_t* parser, int token_type); + +// creates the abstract syntax tree +tree_t* parser_parse(parser_t* parser); + +tree_t* parser_parse_token_id(parser_t* parser); + +// parse a single chunk +tree_t* parser_parse_chunk(parser_t* parser); + +// parse all in list of chunks +tree_t* parser_parse_chunks(parser_t* parser); + +tree_t* parser_parse_expr(parser_t* parser); + +tree_t* parser_parse_fac(parser_t* parser); + +tree_t* parser_parse_term(parser_t* parser); + +tree_t* parser_parse_fn_call(parser_t* parser); + +tree_t* parser_parse_var(parser_t* parser); +tree_t* parser_parse_var_def(parser_t* parser); + +tree_t* parser_parse_str(parser_t* parser); + + +#endif |