feat(parser): redirections types handled in grammar init
This commit is contained in:
parent
787b1aed35
commit
23f6815162
1 changed files with 17 additions and 6 deletions
|
|
@ -73,6 +73,20 @@ static bool init_firsts_map(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
/* @brief: add all the redirection token_types to the first of [rule].
|
||||
* this also contains IONUMBER
|
||||
*/
|
||||
static void add_first_redir(enum rule rule)
|
||||
{
|
||||
add_first(rule, TOKEN_IONUMBER);
|
||||
add_first(rule, TOKEN_REDIR_LEFT);
|
||||
add_first(rule, TOKEN_REDIR_RIGHT);
|
||||
add_first(rule, TOKEN_REDIR_LEFT_RIGHT);
|
||||
add_first(rule, TOKEN_REDIR_DOUBLE_RIGHT);
|
||||
add_first(rule, TOKEN_REDIR_LEFT_AMP);
|
||||
add_first(rule, TOKEN_REDIR_RIGHT_PIPE);
|
||||
}
|
||||
|
||||
// === Functions
|
||||
|
||||
bool grammar_init(void)
|
||||
|
|
@ -114,14 +128,11 @@ bool grammar_init(void)
|
|||
add_first(RULE_ELSE_CLAUSE, TOKEN_ELIF);
|
||||
|
||||
add_first(RULE_ELEMENT, TOKEN_WORD);
|
||||
add_first(RULE_ELEMENT, TOKEN_IONUMBER);
|
||||
add_first(RULE_ELEMENT, TOKEN_REDIRECTION);
|
||||
add_first_redir(RULE_ELEMENT);
|
||||
|
||||
add_first(RULE_REDIRECTION, TOKEN_IONUMBER);
|
||||
add_first(RULE_REDIRECTION, TOKEN_REDIRECTION);
|
||||
add_first_redir(RULE_REDIRECTION);
|
||||
|
||||
add_first(RULE_PREFIX, TOKEN_IONUMBER);
|
||||
add_first(RULE_PREFIX, TOKEN_REDIRECTION);
|
||||
add_first_redir(RULE_PREFIX);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue