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
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include "grammar_basic.h"
|
||||
|
||||
bool
|
||||
|
||||
struct ast *parse_redirection(struct lexer_context *ctx)
|
||||
{
|
||||
struct token *token = PEEK_TOKEN();
|
||||
|
|
@ -17,20 +19,20 @@ struct ast *parse_redirection(struct lexer_context *ctx)
|
|||
token = PEEK_TOKEN();
|
||||
}
|
||||
|
||||
if (token->type != TOKEN_REDIRECTION)
|
||||
if (!is_token_redir(token))
|
||||
{
|
||||
puts("Syntax error: expected a redirection token but got something "
|
||||
perror("Syntax error: expected a redirection token but got something "
|
||||
"else");
|
||||
return NULL;
|
||||
}
|
||||
char *redir_op = strdup(token->data);
|
||||
// char *redir_op = strdup(token->data);
|
||||
POP_TOKEN();
|
||||
|
||||
token = PEEK_TOKEN();
|
||||
if (token->type != TOKEN_WORD)
|
||||
{
|
||||
puts("Syntax error: expected a word after redirection");
|
||||
free(redir_op);
|
||||
perror("Syntax error: expected a word after redirection");
|
||||
// free(redir_op);
|
||||
return NULL;
|
||||
}
|
||||
char *target = strdup(token->data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue