diff options
author | c+1 | 2023-11-21 10:16:23 -0500 |
---|---|---|
committer | c+1 | 2023-11-21 10:16:23 -0500 |
commit | c3c0f8f78085bdc4698263513aea0c9b2d33bae4 (patch) | |
tree | 178ec7bafbfcfbf9a8204f8e9738e537c371bda7 /src/include/parser.h | |
parent | 000658c8405f93bf8ce1e03a9055e6944e730534 (diff) |
Basic block, expression, and number parsing.
Diffstat (limited to 'src/include/parser.h')
-rw-r--r-- | src/include/parser.h | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/include/parser.h b/src/include/parser.h index b39f481..59bbbb5 100644 --- a/src/include/parser.h +++ b/src/include/parser.h @@ -11,6 +11,8 @@ typedef struct PARSER { /* 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. */ @@ -26,26 +28,31 @@ void parser_destroy(parser_t* parser); /* Step the parser forward by 1 token. */ int parser_nxt_token(parser_t* parser); -/* Check whether the current token matches the given type. */ +/* + Check whether the current token matches the given type. + - If it doesn't, return 0 and throw error. +*/ int parser_match(parser_t* parser, token_type_t type); -/* - parse lit: converting everything from strings to value in the tree - parse expr: (For now) call parse lit - parse blk: loop over all expressions until reaching an end block. +/* Steps the parser forward by one token, then check whether the new token matches the given type. */ +int parser_nxt_token_match(parser_t* parser, token_type_t type); +/* + Parse a single literal value. + - Only does integers for now. */ +tree_t* parser_parse_lit(parser_t* parser); + +/* Return a tree for a single semicolon-separated expression.*/ +tree_t* parser_parse_expr(parser_t* parser); -/* Parse a single literal value. */ -void parser_parse_lit(parser_t* parser); +/* Return a tree for a single curly-brace-separated expression. */ +tree_t* parser_parse_block(parser_t* parser); -/* Parse a single expression. */ -void parser_parse_expr(parser_t* parser); -/* Parse a single block. */ -void parser_parse_blk(parser_t* parser); +tree_t* parser_parse(parser_t* parser); -/* Parse the given tokens. */ -void parser_parse(parser_t* parser); +/* Parse with the given parser. */ +void parser_run(parser_t* parser); #endif |