fix: new lexer is linked to everything

This commit is contained in:
Matteo Flebus 2026-01-20 20:32:59 +01:00
parent d5a1ec3ca6
commit 71e58e38b8
6 changed files with 26 additions and 22 deletions

View file

@ -15,9 +15,8 @@
// === Functions
struct ast *get_ast()
struct ast *get_ast(struct lexer_context *ctx)
{
struct lexer_context *ctx = calloc(1, sizeof(struct lexer_context));
struct token *token = PEEK_TOKEN();
struct ast *res;
@ -44,8 +43,6 @@ struct ast *get_ast()
return NULL;
}
*/
destroy_lexer_context(&ctx);
return res;
}

View file

@ -1,6 +1,7 @@
#ifndef PARSER_H
#define PARSER_H
#include "lexer/lexer.h"
#include "utils/ast/ast.h"
/* @brief Builds the AST representation of the next command to execute.
@ -10,7 +11,7 @@
*
* @warning NOT IMPLEMENTED
*/
struct ast *get_ast(void);
struct ast *get_ast(struct lexer_context *ctx);
/* @brief Builds the AST representation of the given command string.
*

View file

@ -67,7 +67,7 @@ struct ast *parse_list(struct lexer_context *ctx)
struct token *token = PEEK_TOKEN();
// and_or
current_node = parse_and_or();
current_node = parse_and_or(ctx);
if (current_node == NULL)
return NULL;
result_list = list_append(result_list, current_node);
@ -90,7 +90,7 @@ struct ast *parse_list(struct lexer_context *ctx)
token = PEEK_TOKEN();
}
}
result_list = list_append(result_list, current_node);
// result_list = list_append(result_list, current_node);
return ast_create_list(result_list);
}
@ -337,7 +337,7 @@ struct ast *parse_else_clause(struct lexer_context *ctx)
}
if (result == NULL)
result = ast_create_void(ctx);
result = ast_create_void();
return result;
}

View file

@ -1,6 +1,8 @@
#ifndef PARSING_UTILS_H
#define PARSING_UTILS_H
#include "../lexer/lexer.h"
// === Macros
#define PEEK_TOKEN() \