feat(parser): implementing redirections...
This commit is contained in:
parent
d52f603eec
commit
7614370d00
2 changed files with 17 additions and 2 deletions
|
|
@ -6,7 +6,19 @@
|
|||
|
||||
#include "grammar_basic.h"
|
||||
|
||||
bool
|
||||
static enum ast_redir_type redir_tok_to_ast_type(enum token_type tok_type)
|
||||
{
|
||||
switch(tok_type)
|
||||
{
|
||||
case TOKEN_REDIR_LEFT:
|
||||
return AST_REDIR_TYPE_LESS;
|
||||
case TOKEN_REDIR_RIGHT:
|
||||
return AST_REDIR_TYPE_GREAT;
|
||||
// TODO finish this
|
||||
default:
|
||||
return AST_REDIR_TYPE_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
struct ast *parse_redirection(struct lexer_context *ctx)
|
||||
{
|
||||
|
|
@ -26,6 +38,8 @@ struct ast *parse_redirection(struct lexer_context *ctx)
|
|||
return NULL;
|
||||
}
|
||||
// char *redir_op = strdup(token->data);
|
||||
|
||||
enum ast_redir_type redir_type = redir_tok_to_ast_type(token->type);
|
||||
POP_TOKEN();
|
||||
|
||||
token = PEEK_TOKEN();
|
||||
|
|
@ -38,7 +52,7 @@ struct ast *parse_redirection(struct lexer_context *ctx)
|
|||
char *target = strdup(token->data);
|
||||
POP_TOKEN();
|
||||
|
||||
return ast_create_redir(io_number, redir_op, target);
|
||||
return ast_create_redir(io_number, redir_type, target);
|
||||
}
|
||||
|
||||
struct ast *parse_prefix(struct lexer_context *ctx)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
enum ast_redir_type
|
||||
{
|
||||
AST_REDIR_TYPE_NULL,
|
||||
AST_REDIR_TYPE_LESS, // <
|
||||
AST_REDIR_TYPE_GREAT, // >
|
||||
AST_REDIR_TYPE_DLESS, // <<
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue