fix: now compiles and works for simple commands + clang format
This commit is contained in:
parent
6099bbb9e3
commit
352c122549
23 changed files with 168 additions and 150 deletions
|
|
@ -7,8 +7,8 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "lexer/lexer.h"
|
||||
#include "utils/lists/lists.h"
|
||||
#include "parser/parsing_utils.h"
|
||||
#include "utils/lists/lists.h"
|
||||
|
||||
// === Static functions
|
||||
// ...
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
#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"
|
||||
|
|
@ -58,7 +60,8 @@ struct ast *parse_simple_command(void)
|
|||
while (!isterminator(token))
|
||||
{
|
||||
token = POP_TOKEN();
|
||||
command_elements = list_append(command_elements, token->data);
|
||||
char *word = strdup(token->data);
|
||||
command_elements = list_append(command_elements, word);
|
||||
token = PEEK_TOKEN();
|
||||
}
|
||||
|
||||
|
|
@ -86,6 +89,7 @@ struct ast *parse_list(void)
|
|||
}
|
||||
token = PEEK_TOKEN();
|
||||
}
|
||||
result_list = list_append(result_list, current_node);
|
||||
|
||||
return ast_create_list(result_list);
|
||||
}
|
||||
|
|
@ -163,7 +167,9 @@ struct ast *parse_compound_list(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
command_elements = list_append(command_elements, token->data);
|
||||
char *word = strdup(token->data);
|
||||
|
||||
command_elements = list_append(command_elements, word);
|
||||
token = POP_TOKEN();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ struct ast *parse_list(void);
|
|||
*/
|
||||
struct ast *parse_simple_command(void);
|
||||
|
||||
/*
|
||||
/*
|
||||
*/
|
||||
struct ast *parse_if_rule(void);
|
||||
|
||||
|
|
@ -39,14 +39,14 @@ struct ast *parse_shell_command(void);
|
|||
/* @brief parses commands inside if/else clauses and returns the corresponding
|
||||
* AST list
|
||||
*/
|
||||
struct ast* parse_compound_list(void);
|
||||
struct ast *parse_compound_list(void);
|
||||
|
||||
/*
|
||||
*/
|
||||
struct ast* parse_and_or(void);
|
||||
struct ast *parse_and_or(void);
|
||||
|
||||
/*
|
||||
*/
|
||||
struct ast* parse_else_clause(void);
|
||||
struct ast *parse_else_clause(void);
|
||||
|
||||
#endif /* ! PARSING_UTILS_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue