summaryrefslogtreecommitdiff
path: root/src/lexer.c
diff options
context:
space:
mode:
authorJohnny Richard <johnny@johnnyrichard.com>2023-05-17 15:31:24 +0200
committerJohnny Richard <johnny@johnnyrichard.com>2023-05-17 15:31:24 +0200
commit15196aa56339d34af9f74b019e6aeff5816e8dcc (patch)
treeffe7d6ec48bc6018b5eea7e9ef573cd1bbd57c2f /src/lexer.c
parentad54ee1182b1549880eddc8b1969d3992d9f7f1d (diff)
parentea7f65fe1250be8f49edcaaedd3410aed1401648 (diff)
Merge commit 'ea7f65fe1250be8f49edcaaedd3410aed1401648' of https://git.sr.ht/~carlosmaniero/pipac-clone
Diffstat (limited to 'src/lexer.c')
-rw-r--r--src/lexer.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lexer.c b/src/lexer.c
index a6c8ae2..c00c944 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -165,6 +165,12 @@ lexer_next_token(lexer_t *lexer, token_t *token)
return;
}
+ if (lexer_current_char(lexer) == ',') {
+ lexer_define_literal_token_props(lexer, token, TOKEN_COMMA);
+ lexer_drop_char(lexer);
+ return;
+ }
+
if (lexer_current_char(lexer) == ';') {
lexer_define_literal_token_props(lexer, token, TOKEN_SEMICOLON);
lexer_drop_char(lexer);
@@ -343,6 +349,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_lookahead(lexer_t *lexer, token_t *token, size_t level)
{
uint32_t cur = lexer->cur;
@@ -412,6 +426,8 @@ token_kind_to_str(token_kind_t kind)
return ")";
case TOKEN_COLON:
return ":";
+ case TOKEN_COMMA:
+ return ",";
case TOKEN_SEMICOLON:
return ";";
case TOKEN_OCURLY: