fix: new lexer is linked to everything
This commit is contained in:
parent
d5a1ec3ca6
commit
71e58e38b8
6 changed files with 26 additions and 22 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef PARSING_UTILS_H
|
||||
#define PARSING_UTILS_H
|
||||
|
||||
#include "../lexer/lexer.h"
|
||||
|
||||
// === Macros
|
||||
|
||||
#define PEEK_TOKEN() \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue