fix(parser): removed unused old version of static function
This commit is contained in:
parent
4d271981df
commit
8ca7a92e7d
1 changed files with 40 additions and 51 deletions
|
|
@ -26,17 +26,6 @@ static enum ast_and_or_type and_or_tok_to_ast(enum token_type tok_type)
|
|||
}
|
||||
}
|
||||
|
||||
/* @brief: frees command_elements and redirections lists (helper func)
|
||||
* @return: NULL
|
||||
*/
|
||||
static void *err_simple_command(struct list *command_elements,
|
||||
struct list *redirections)
|
||||
{
|
||||
list_deep_destroy(command_elements);
|
||||
list_deep_destroy(redirections);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* @brief: frees all the arguments. (helper func)
|
||||
* @return: NULL.
|
||||
*/
|
||||
|
|
@ -49,6 +38,46 @@ static void *err_if_rule(struct ast **cond, struct ast **then_clause,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* @brief: frees command_elements and redirections lists (helper func)
|
||||
* @return: NULL
|
||||
*/
|
||||
static void *err_s_com(struct list *command_elements, struct list *redirections,
|
||||
struct list *assignments)
|
||||
{
|
||||
list_deep_destroy(command_elements);
|
||||
list_deep_destroy(redirections);
|
||||
list_deep_destroy(assignments);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* @brief: used when export keyword is found, and expects an assignment after.
|
||||
* @return: an ast_assignment with the field [global] set to true.
|
||||
*/
|
||||
static struct ast *parse_export(struct lexer_context *ctx)
|
||||
{
|
||||
struct token *token = PEEK_TOKEN();
|
||||
if (token->type != TOKEN_EXPORT)
|
||||
{
|
||||
fprintf(stderr, "expected the export keyword in parse_export");
|
||||
return NULL;
|
||||
}
|
||||
// export
|
||||
POP_TOKEN();
|
||||
|
||||
token = PEEK_TOKEN();
|
||||
|
||||
if (token->type != TOKEN_ASSIGNMENT_WORD)
|
||||
{
|
||||
fprintf(stderr, "in parser: export must be followed by 'x=y'");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// assignment
|
||||
POP_TOKEN();
|
||||
|
||||
return ast_create_assignment(token->data, true);
|
||||
}
|
||||
|
||||
// === Functions
|
||||
|
||||
struct ast *parse_list(struct lexer_context *ctx)
|
||||
|
|
@ -203,46 +232,6 @@ struct ast *parse_command(struct lexer_context *ctx)
|
|||
return result;
|
||||
}
|
||||
|
||||
/* @brief: frees command_elements and redirections lists (helper func)
|
||||
* @return: NULL
|
||||
*/
|
||||
static void *err_s_com(struct list *command_elements, struct list *redirections,
|
||||
struct list *assignments)
|
||||
{
|
||||
list_deep_destroy(command_elements);
|
||||
list_deep_destroy(redirections);
|
||||
list_deep_destroy(assignments);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* @brief: used when export keyword is found, and expects an assignment after.
|
||||
* @return: an ast_assignment with the field [global] set to true.
|
||||
*/
|
||||
static struct ast *parse_export(struct lexer_context *ctx)
|
||||
{
|
||||
struct token *token = PEEK_TOKEN();
|
||||
if (token->type != TOKEN_EXPORT)
|
||||
{
|
||||
fprintf(stderr, "expected the export keyword in parse_export");
|
||||
return NULL;
|
||||
}
|
||||
// export
|
||||
POP_TOKEN();
|
||||
|
||||
token = PEEK_TOKEN();
|
||||
|
||||
if (token->type != TOKEN_ASSIGNMENT_WORD)
|
||||
{
|
||||
fprintf(stderr, "in parser: export must be followed by 'x=y'");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// assignment
|
||||
POP_TOKEN();
|
||||
|
||||
return ast_create_assignment(token->data, true);
|
||||
}
|
||||
|
||||
struct ast *parse_simple_command(struct lexer_context *ctx)
|
||||
{
|
||||
struct list *command_elements = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue