feat(lexer): implementing assignements
This commit is contained in:
parent
e1291107d4
commit
f0a7173b11
3 changed files with 41 additions and 6 deletions
|
|
@ -66,5 +66,17 @@ struct ast *parse_redirection(struct lexer_context *ctx)
|
|||
|
||||
struct ast *parse_prefix(struct lexer_context *ctx)
|
||||
{
|
||||
return parse_redirection(ctx);
|
||||
struct token *token = TOKEN_PEEK();
|
||||
if (token->type == TOKEN_ASSIGNMENT_WORD)
|
||||
{
|
||||
token = TOKEN_POP();
|
||||
return ast_create_assignment_word(token->data);
|
||||
}
|
||||
else if (is_first(*token, RULE_REDIRECTION))
|
||||
return parse_redirection(ctx);
|
||||
else
|
||||
{
|
||||
perror("Syntax error: expected a prefix (redirection or assignment)");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue