From d86d70fc7c6751713a6b9f02d9f77814e2f75718 Mon Sep 17 00:00:00 2001 From: Johnny Richard Date: Fri, 21 Apr 2023 15:11:17 +0200 Subject: parser: Parse integers arithmetic expression This patch implements the AST creation for arithmetic expressions. NOTE: The implementation works only for integer numbers. Signed-off-by: Johnny Richard Reviewed-by: Carlos Maniero --- src/lexer.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/lexer.c') diff --git a/src/lexer.c b/src/lexer.c index 2c8ffb9..b641752 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -44,6 +44,7 @@ lexer_define_literal_token_props(lexer_t *lexer, token_t *token, token_kind_t ki token->filepath = lexer->filepath; token->row = lexer->row; token->col = lexer->cur - lexer->bol; + token->bol = lexer->bol; } static void @@ -73,6 +74,7 @@ lexer_tokenize_number(lexer_t *lexer, token_t *token) token->filepath = lexer->filepath; token->row = lexer->row; token->col = begin - lexer->bol; + token->bol = lexer->bol; } static void @@ -88,6 +90,7 @@ lexer_tokenize_name(lexer_t *lexer, token_t *token) token->filepath = lexer->filepath; token->row = lexer->row; token->col = begin - lexer->bol; + token->bol = lexer->bol; } void @@ -196,6 +199,14 @@ lexer_load_file_contents(lexer_t *lexer) } +void +lexer_step_back_to(lexer_t *lexer, token_t *token) +{ + lexer->cur = token->bol + token->col; + lexer->row = token->row; + lexer->bol = token->bol; +} + void lexer_drop_char(lexer_t *lexer) { -- cgit v1.2.3