fix(parser): 3098750984535 compilations errors in parsing_utils
This commit is contained in:
parent
5d87e87f2e
commit
c1f1a2fc37
1 changed files with 35 additions and 20 deletions
|
|
@ -1,9 +1,12 @@
|
|||
#define _POSIX_C_SOURCE 200809L
|
||||
|
||||
// === Includes
|
||||
#include "parsing_utils.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lexer/lexer.h"
|
||||
#include "utils/ast/ast.h"
|
||||
|
|
@ -11,7 +14,7 @@
|
|||
// === Static functions
|
||||
|
||||
/* Returns true if c is a command terminator, false otherwise
|
||||
*/
|
||||
*/
|
||||
static bool isterminator(struct token *token)
|
||||
{
|
||||
if (token == NULL)
|
||||
|
|
@ -29,7 +32,10 @@ static bool isterminator(struct token *token)
|
|||
}
|
||||
|
||||
/* @brief: returns true if token is an end of list indicator.
|
||||
* @warning: not used
|
||||
*/
|
||||
|
||||
/*
|
||||
static bool is_end_of_list(struct token *token)
|
||||
{
|
||||
if (token == NULL)
|
||||
|
|
@ -44,6 +50,7 @@ static bool is_end_of_list(struct token *token)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// === Functions
|
||||
|
||||
|
|
@ -215,8 +222,10 @@ struct ast *parse_compound_list(void)
|
|||
struct token *token = PEEK_TOKEN();
|
||||
|
||||
// Skip newlines
|
||||
while (token == TOKEN_NEWLINE)
|
||||
while (token->type == TOKEN_NEWLINE)
|
||||
{
|
||||
token = POP_TOKEN();
|
||||
}
|
||||
|
||||
// and_or
|
||||
current_cmd = parse_and_or();
|
||||
|
|
@ -226,13 +235,15 @@ struct ast *parse_compound_list(void)
|
|||
|
||||
// Following commands
|
||||
token = PEEK_TOKEN();
|
||||
while (token->type == TOKEN_SEMICOLON || token->type TOKEN_NEWLINE)
|
||||
while (token->type == TOKEN_SEMICOLON || token->type == TOKEN_NEWLINE)
|
||||
{
|
||||
POP_TOKEN();
|
||||
|
||||
// Skip newlines
|
||||
while (token == TOKEN_NEWLINE)
|
||||
while (token->type == TOKEN_NEWLINE)
|
||||
{
|
||||
token = POP_TOKEN();
|
||||
}
|
||||
|
||||
// and_or
|
||||
current_cmd = parse_and_or();
|
||||
|
|
@ -245,11 +256,15 @@ struct ast *parse_compound_list(void)
|
|||
|
||||
// Eventual semicolons
|
||||
if (token->type == TOKEN_SEMICOLON)
|
||||
{
|
||||
token = POP_TOKEN();
|
||||
}
|
||||
|
||||
// Skip newlines
|
||||
while (token == TOKEN_NEWLINE)
|
||||
while (token->type == TOKEN_NEWLINE)
|
||||
{
|
||||
token = POP_TOKEN();
|
||||
}
|
||||
|
||||
|
||||
struct ast *result = ast_create_list(result_list);
|
||||
|
|
@ -281,7 +296,7 @@ struct ast *parse_else_clause(void)
|
|||
// Eventual else clause (recursive)
|
||||
struct ast *else_content = NULL;
|
||||
token = PEEK_TOKEN();
|
||||
if (token->type == TOKEN_ELSE || token_type == TOKEN_ELIF)
|
||||
if (token->type == TOKEN_ELSE || token->type == TOKEN_ELIF)
|
||||
{
|
||||
else_content = parse_else_clause();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue