feat: redirection rules

This commit is contained in:
Gu://em_ 2026-01-24 15:34:10 +01:00
parent 18c1da6bdf
commit 32f56beb6b
8 changed files with 218 additions and 25 deletions

View file

@ -6,7 +6,8 @@
// === Functions
/* @brief: parses a list of [and_or] rules separated by semicolons and that
/*
* @brief parses a list of [and_or] rules separated by semicolons and that
* ends by a newline
*
* @code list = and_or { ';' and_or } [ ';' ] ;
@ -15,7 +16,8 @@
*/
struct ast *parse_list(struct lexer_context *ctx);
/* @brief Only parses a pipeline rule for the moment
/*
* @brief Only parses a pipeline rule for the moment
*
* @code and_or = pipeline { ( '&&' | '||' ) {'\n'} pipeline } ;
*
@ -23,7 +25,8 @@ struct ast *parse_list(struct lexer_context *ctx);
*/
struct ast *parse_and_or(struct lexer_context *ctx);
/* @brief Only parses a command rule for the moment
/*
* @brief Only parses a command rule for the moment
*
* @code pipeline = command ;
*
@ -31,7 +34,8 @@ struct ast *parse_and_or(struct lexer_context *ctx);
*/
struct ast *parse_pipeline(struct lexer_context *ctx);
/* @brief Parses a simple command rule or a shell command rule depending on
/*
* @brief Parses a simple command rule or a shell command rule depending on
* the first token.
* @note
* TOKEN_WORD => simple_command
@ -44,7 +48,8 @@ struct ast *parse_pipeline(struct lexer_context *ctx);
*/
struct ast *parse_command(struct lexer_context *ctx);
/* @brief Parses a simple list of words (command and arguments)
/*
* @brief Parses a simple list of words (command and arguments)
* ending by a separator
*
* @code simple_command = WORD { element } ;
@ -53,7 +58,19 @@ struct ast *parse_command(struct lexer_context *ctx);
*/
struct ast *parse_simple_command(struct lexer_context *ctx);
/* @brief Only parses if rules for the moment
/*
* @brief Parses an element rule
*
* @code element = WORD
* | redirection
* ;
*
* @first WORD, first(redirection)
*/
struct ast *parse_element(struct lexer_context *ctx);
/*
* @brief Only parses if rules for the moment
*
* @code shell_command = if_rule ;
*
@ -61,7 +78,8 @@ struct ast *parse_simple_command(struct lexer_context *ctx);
*/
struct ast *parse_shell_command(struct lexer_context *ctx);
/* @brief Parses a if rule (condition, then-clause, elif-clause, else-clause)
/*
* @brief Parses a if rule (condition, then-clause, elif-clause, else-clause)
*
* @code if_rule = 'if' compound_list 'then' compound_list [else_clause] 'fi' ;
*
@ -69,7 +87,8 @@ struct ast *parse_shell_command(struct lexer_context *ctx);
*/
struct ast *parse_if_rule(struct lexer_context *ctx);
/* @brief parses commands inside if/else clauses and returns the corresponding
/*
* @brief parses commands inside if/else clauses and returns the corresponding
* AST list
*
* @code compound_list = {'\n'} and_or { ( ';' | '\n' ) {'\n'} and_or } [';']
@ -79,7 +98,8 @@ struct ast *parse_if_rule(struct lexer_context *ctx);
*/
struct ast *parse_compound_list(struct lexer_context *ctx);
/* @brief
/*
* @brief
*
* @code else_clause = 'else' compound_list
* | 'elif' compound_list 'then' compound_list [else_clause]