diff options
author | Johnny Richard <johnny@johnnyrichard.com> | 2023-04-14 23:10:25 +0200 |
---|---|---|
committer | Johnny Richard <johnny@johnnyrichard.com> | 2023-04-15 02:16:29 +0200 |
commit | e927a4b22115e0461db6feeee891256b10650c0e (patch) | |
tree | 60ce1c87160a6465dd717459e8b430a8908fdc1f /src/lexer.h | |
parent | 7d1db093bc3af0d4252bf7c613c8d2a8d7d935b4 (diff) |
parser: Create parser for function with return statements
This is a very limited parser implementation which parses a single
function with return type i32 and body containing a return number statement.
The parser doesn't show the 'filepath:row:col' when it fails, a future
improvement would be display it to easy find where the compilation
problem is located.
The ast_nodes are taking the token.value ownership (which is a really
bad design since not all token.value ownership has been taken causing
memory leaking) but we never free them. For a future fix we could use a
string_view instead since we never change the original source code. The
string_view will also improve the performance a lot avoiding unnecessary
heap memory allocation.
Signed-off-by: Johnny Richard <johnny@johnnyrichard.com>
Diffstat (limited to 'src/lexer.h')
-rw-r--r-- | src/lexer.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/lexer.h b/src/lexer.h index 29cfc11..f5333a0 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -64,5 +64,7 @@ bool lexer_is_not_eof(lexer_t *lexer); void lexer_drop_char(lexer_t *lexer); +char * token_kind_to_str(token_kind_t kind); + #endif /* LEXER_H */ |