diff options
| author | Mel <mel@rnrd.eu> | 2025-05-21 16:19:59 +0200 |
|---|---|---|
| committer | Mel <mel@rnrd.eu> | 2025-05-21 16:19:59 +0200 |
| commit | 1e07cecafc62d18ba05f21101e13b131a10e8c45 (patch) | |
| tree | e036129c57b734292ff15b71a1d193aa0a97c678 /boot/catboot.c | |
| parent | 8c8d65f026121b4d75a31bff8a91c3fbf969fca5 (diff) | |
| download | catskill-1e07cecafc62d18ba05f21101e13b131a10e8c45.tar.zst catskill-1e07cecafc62d18ba05f21101e13b131a10e8c45.zip | |
Basic expression parser with operator precedence and associativity
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'boot/catboot.c')
| -rw-r--r-- | boot/catboot.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/boot/catboot.c b/boot/catboot.c index fec47c0..23b649e 100644 --- a/boot/catboot.c +++ b/boot/catboot.c @@ -23,6 +23,7 @@ #include "common.c" #include "lex.c" #include "tree.c" +#include "parse.c" const ascii* read_file(const ascii* path) @@ -57,10 +58,27 @@ main(const int32 argc, const ascii* argv[]) lexer_new(&lexer, source); struct Token token; + printf("tokens: "); do { token = lexer_next(&lexer); printf("%s ", token_kind_to_string(token.kind)); } while (token.kind != TOKEN_END_OF_FILE); + printf("\n"); + + // reset lexer + lexer_new(&lexer, source); + + struct Parser parser; + parser_new(&parser, &lexer); + + struct Parser_Error parser_error = parser_error_none(); + struct Tree tree = parser_do_your_thing(&parser, &parser_error); + if (!parser_error_is_none(&parser_error)) { + printf("parser error: %s\n", parser_error_to_string(&parser_error)); + return EXIT_FAILURE; + } + + tree_print(&tree); return EXIT_SUCCESS; } |
