fix: changed puts to perror + redirections in parser
This commit is contained in:
parent
96626d9850
commit
d52f603eec
5 changed files with 26 additions and 24 deletions
|
|
@ -160,7 +160,7 @@ struct ast *parse_command(struct lexer_context *ctx)
|
|||
}
|
||||
else
|
||||
{
|
||||
puts("Syntax error: unexpected token");
|
||||
perror("Syntax error: unexpected token");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -173,7 +173,7 @@ struct ast *parse_simple_command(struct lexer_context *ctx)
|
|||
struct token *token = POP_TOKEN();
|
||||
if (token->type != TOKEN_WORD)
|
||||
{
|
||||
puts("Expected a command but got a different token type");
|
||||
perror("Expected a command but got a different token type");
|
||||
return NULL;
|
||||
}
|
||||
char *command = strdup(token->data);
|
||||
|
|
@ -202,12 +202,12 @@ struct ast *parse_simple_command(struct lexer_context *ctx)
|
|||
else if (ast_is_redir(element))
|
||||
{
|
||||
// TODO
|
||||
puts("NOT IMPLEMENTED");
|
||||
perror("NOT IMPLEMENTED");
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
puts("Internal error: unexpected return value from parse_element "
|
||||
perror("Internal error: unexpected return value from parse_element "
|
||||
"in parse_simple_command");
|
||||
list_deep_destroy(command_elements);
|
||||
return NULL;
|
||||
|
|
@ -241,7 +241,7 @@ struct ast *parse_element(struct lexer_context *ctx)
|
|||
}
|
||||
else
|
||||
{
|
||||
puts("Syntax error: unexpected token at parse_element");
|
||||
perror("Syntax error: unexpected token at parse_element");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -257,7 +257,7 @@ struct ast *parse_if_rule(struct lexer_context *ctx)
|
|||
struct token *token = POP_TOKEN();
|
||||
if (token->type != TOKEN_IF)
|
||||
{
|
||||
puts("Internal error: expected a if rule but token has different "
|
||||
perror("Internal error: expected a if rule but token has different "
|
||||
"type");
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -270,7 +270,7 @@ struct ast *parse_if_rule(struct lexer_context *ctx)
|
|||
if (token->type != TOKEN_THEN)
|
||||
{
|
||||
ast_free(&condition_content);
|
||||
puts("Expected the 'then' keyword but token has different type");
|
||||
perror("Expected the 'then' keyword but token has different type");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ struct ast *parse_if_rule(struct lexer_context *ctx)
|
|||
ast_free(&condition_content);
|
||||
ast_free(&then_content);
|
||||
ast_free(&else_content);
|
||||
puts("Expected the 'fi' keyword but token has different type");
|
||||
perror("Expected the 'fi' keyword but token has different type");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ struct ast *parse_if_rule(struct lexer_context *ctx)
|
|||
ast_free(&condition_content);
|
||||
ast_free(&then_content);
|
||||
ast_free(&else_content);
|
||||
puts("Internal error: could not create a new AST (AST_IF)");
|
||||
perror("Internal error: could not create a new AST (AST_IF)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -396,7 +396,7 @@ struct ast *parse_else_clause(struct lexer_context *ctx)
|
|||
token = POP_TOKEN();
|
||||
if (token->type != TOKEN_THEN)
|
||||
{
|
||||
puts("Expected the 'then' keyword but got a different token type");
|
||||
perror("Expected the 'then' keyword but got a different token type");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue