diff --git a/src/ast/ast.h b/src/ast/ast.h index 0fbc9b3b..816a87e2 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -1,7 +1,7 @@ /** * \file ast.h * \brief Represent a node of the AST. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */ diff --git a/src/execute/ast_eval.c b/src/execute/ast_eval.c index 801645dc..18fb6a94 100644 --- a/src/execute/ast_eval.c +++ b/src/execute/ast_eval.c @@ -1,7 +1,7 @@ /** * \file ast_eval.c * \brief Evaluate the AST. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */ @@ -21,6 +21,7 @@ // error else /** + * \struct builtin_function * \brief Structure representing a builtin function. */ struct builtin_function @@ -29,10 +30,20 @@ struct builtin_function int (*fun)(struct ast_node *); }; +/** + * \struct builtin_function + * \brief Structure representing a builtin function. +*/ struct builtin_function builtin[] = { { .name = "echo", .fun = echo_fun }, { .name = "true", .fun = true_fun }, { .name = "false", .fun = false_fun } }; +/** + * \brief Evaluate the while loop + * \param node The AST to evaluate. + * \param logger_enabled Whether the logger is enabled or not. + * \return The exit status of the last command. +*/ int exec_cmd(struct ast_node *node, bool logger_enabled) { int pid = fork(); @@ -83,6 +94,12 @@ int ast_command(struct ast_node *node, bool logger_enabled) return match_ast(node->children[0], logger_enabled); } +/** + * \brief Evaluate simple command from ast + * \param node The AST to evaluate. + * \param logger_enabled Whether the logger is enabled or not. + * \return The exit status of the last command. +*/ int ast_eval_simple_command(struct ast_node *node, bool logger_enabled) { if (node->children[0]->type == AST_WORD_ASSIGNMENT) @@ -100,6 +117,12 @@ int ast_eval_simple_command(struct ast_node *node, bool logger_enabled) return exec_cmd(node, logger_enabled); } +/** + * \brief Evaluate condition from ast + * \param node The AST to evaluate. + * \param logger_enabled Whether the logger is enabled or not. + * \return The exit status of the last command. +*/ int ast_eval_condition(struct ast_node *node, bool logger_enabled) { int cond = match_ast(node->children[0], logger_enabled); @@ -117,6 +140,12 @@ int ast_eval_condition(struct ast_node *node, bool logger_enabled) } } +/** + * \brief Evaluate command list from ast + * \param node The AST to evaluate. + * \param logger_enabled Whether the logger is enabled or not. + * \return The exit status of the last command. +*/ int ast_eval_command_list(struct ast_node *node, bool logger_enabled) { int status = 0; @@ -158,4 +187,4 @@ int match_ast(struct ast_node *node, bool logger_enabled) default: return -1; } -} \ No newline at end of file +} diff --git a/src/execute/ast_eval.h b/src/execute/ast_eval.h index 5688c088..98b9c52d 100644 --- a/src/execute/ast_eval.h +++ b/src/execute/ast_eval.h @@ -1,7 +1,7 @@ /** * \file ast_eval.h * \brief Evaluate the AST. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */ @@ -15,17 +15,74 @@ #include "options/options.h" /** - * \brief Evaluates the given AST and returns the exit status of the last - * command. \param node The AST to evaluate. \param logger_enabled Whether the - * logger is enabled or not. \return The exit status of the last command. + * \brief Evaluate the given AST + * \param node The AST to evaluate. + * \param logger_enabled Whether the logger is enabled or not. + * \return The exit status of the last command. */ int match_ast(struct ast_node *node, bool logger_enabled); + +/** + * \brief Evaluate the while loop + * \param node The AST to evaluate. + * \param logger_enabled Whether the logger is enabled or not. + * \return The exit status of the last command. + */ int while_loop(struct ast_node *node, bool logger_enabled); + +/** + * \brief Evaluate the until loop + * \param node The AST to evaluate. + * \param logger_enabled Whether the logger is enabled or not. + * \return The exit status of the last command. +*/ int until_loop(struct ast_node *node, bool logger_enabled); + +/** + * \brief Evaluate the for loop + * \param node The AST to evaluate. + * \param logger_enabled Whether the logger is enabled or not. + * \return The exit status of the last command. +*/ int for_loop(struct ast_node *node, bool logger_enabled); + +/** + * \brief Pipeline evaluation. + * \param node The AST to evaluate. + * \param logger_enabled Whether the logger is enabled or not. + * \return The exit status of the last command. +*/ int pipeline_eval(struct ast_node *node, bool logger_enabled); + +/** + * \brief Evaluate and_or + * \param node The AST to evaluate. + * \param logger_enabled Whether the logger is enabled or not. + * \return The exit status of the last command. + */ int ast_and_or(struct ast_node *node, bool logger_enabled); + +/** + * \brief Evaluate the ast assignement + * \param node The AST to evaluate. + * \param logger_enabled Whether the logger is enabled or not. + * \return The exit status of the last command. + */ int ast_eval_assignment(struct ast_node *node, bool logger_enabled); + +/** + * \brief Evaluate command from ast + * \param node The AST to evaluate. + * \param logger_enabled Whether the logger is enabled or not. + * \return The exit status of the last command. + */ int ast_command(struct ast_node *node, bool logger_enabled); + +/** + * \brief Handle word assignment + * \param node The AST to evaluate. + * \return The exit status of the last command. + */ char *handle_word(struct ast_node *node); + #endif /* AST_EVAL_H */ diff --git a/src/execute/ast_variable.c b/src/execute/ast_variable.c index 2ccbc001..9863de36 100644 --- a/src/execute/ast_variable.c +++ b/src/execute/ast_variable.c @@ -1,9 +1,20 @@ +/** + * \file ast_variable.c + * \brief Handle variables. + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat + * \version 1.0 + * \date 12/01/2024 + */ + #include "ast_eval.h" #include "hash_map/hash_map.h" #include "parser/parser.h" struct hash_map *variables = NULL; +/** + * \brief Initialize the variables hash map. +*/ void init_variables() { if (variables == NULL) @@ -12,12 +23,20 @@ void init_variables() } } +/** + * \brief Free the variables hash map. +*/ void free_variables() { if (variables != NULL) hash_map_free(variables); } +/** + * \brief Set a variable in the hash map. + * \param key The key of the variable. + * \param value The value of the variable. +*/ void set_variable(char *key, char *value) { init_variables(); @@ -25,6 +44,11 @@ void set_variable(char *key, char *value) hash_map_insert(variables, key, value, &updated); } +/** + * \brief Get a variable from the hash map. + * \param key The key of the variable. + * \return The value of the variable or NULL if not found. +*/ char *get_variable(char *key) { key++; @@ -51,6 +75,12 @@ char *get_variable(char *key) return ""; } +/** + * \brief Evaluate a node from the AST. + * \param node The AST to evaluate. + * \param logger_enabled Whether the logger is enabled or not. + * \return The exit status of the last command 0 if success, 1 if error. +*/ int ast_eval_assignment(struct ast_node *node, bool logger_enabled) { if (logger_enabled) @@ -63,8 +93,11 @@ int ast_eval_assignment(struct ast_node *node, bool logger_enabled) return 0; } -// Small function for handle variable (just check ast_node type and check the -// hash table) +/** + * \brief Small function for handle variable (just check ast_node type and check the hash table) + * \param node The AST to evaluate. + * \return The value of the variable or NULL if not found. +*/ char *handle_word(struct ast_node *node) { if (node->type == AST_WORD) diff --git a/src/execute/builtin.c b/src/execute/builtin.c index a763e944..feb6951a 100644 --- a/src/execute/builtin.c +++ b/src/execute/builtin.c @@ -1,7 +1,7 @@ /** * \file builtin.c * \brief Builtin functions. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */ @@ -26,6 +26,11 @@ int false_fun(struct ast_node *node) return 1; } +/** + * \brief Print the current working directory. + * \param node The AST to evaluate. + * \return The exit status of the last command 0 if success, 1 if error. +*/ void print_echo(struct ast_node *node, int enable_escapes, int j) { for (int i = j; i < node->children_count; i++) @@ -66,7 +71,11 @@ void print_echo(struct ast_node *node, int enable_escapes, int j) } } -// TO REDUCE +/** + * \brief Echo builtin function and returns the exit status. + * \param node The AST node. + * \return The exit status of the last command 0 if success, 1 if error. +*/ int echo_fun(struct ast_node *node) { int no_newline = 0; diff --git a/src/execute/builtin.h b/src/execute/builtin.h index fb185254..7243051d 100644 --- a/src/execute/builtin.h +++ b/src/execute/builtin.h @@ -1,7 +1,7 @@ /** * \file builtin.h - * \brief Builtin functions. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \brief Header of the builtin functions. + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */ diff --git a/src/execute/hash_map/hash.c b/src/execute/hash_map/hash.c index d1bf964e..d6152b3b 100644 --- a/src/execute/hash_map/hash.c +++ b/src/execute/hash_map/hash.c @@ -1,3 +1,11 @@ +/** + * \file hash.c + * \brief Implement the hash function. + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat + * \version 1.0 + * \date 12/01/2024 + */ + #include #include "hash_map.h" diff --git a/src/execute/hash_map/hash_map.c b/src/execute/hash_map/hash_map.c index c50e2b97..d4624816 100644 --- a/src/execute/hash_map/hash_map.c +++ b/src/execute/hash_map/hash_map.c @@ -1,3 +1,11 @@ +/** + * \file hash_map.c + * \brief Implement the hash map. + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat + * \version 1.0 + * \date 12/01/2024 + */ + #include "hash_map.h" #include diff --git a/src/execute/hash_map/hash_map.h b/src/execute/hash_map/hash_map.h index f11dd4d8..c9502449 100644 --- a/src/execute/hash_map/hash_map.h +++ b/src/execute/hash_map/hash_map.h @@ -1,9 +1,21 @@ +/** + * \file hash_map.h + * \brief Header of the hash map. + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat + * \version 1.0 + * \date 12/01/2024 + */ + #ifndef HASH_MAP_H #define HASH_MAP_H #include #include +/** + * \struct pair_list + * \brief Structure representing a pair of key/value. + */ struct pair_list { const char *key; @@ -11,19 +23,68 @@ struct pair_list struct pair_list *next; }; +/** + * \struct hash_map + * \brief Structure representing a hash map. + */ struct hash_map { struct pair_list **data; size_t size; }; +/** + * \brief Hash a string. + * \param str The string to hash. + * \return The hash. +*/ size_t hash(const char *str); + +/** + * \brief Initialize a hash map. + * \param size The size of the hash map. + * \return The new hash map. + */ struct hash_map *hash_map_init(size_t size); + +/** + * \brief Insert a new pair in the hash map. + * \param hash_map The hash map. + * \param key The key of the pair. + * \param value The value of the pair. + * \param updated A pointer to a boolean that will be set to true if the value + * was updated. + * \return True if the pair was inserted, false otherwise. + */ bool hash_map_insert(struct hash_map *hash_map, const char *key, char *value, bool *updated); + +/** + * \brief Free a hash map. + * \param hash_map The hash map to free. + */ void hash_map_free(struct hash_map *hash_map); + +/** + * \brief Dump a hash map. + * \param hash_map The hash map to dump. + */ void hash_map_dump(struct hash_map *hash_map); + +/** + * \brief Get a value from a hash map. + * \param hash_map The hash map. + * \param key The key of the pair. + * \return The value of the pair. + */ const char *hash_map_get(const struct hash_map *hash_map, const char *key); + +/** + * \brief Remove a pair from a hash map. + * \param hash_map The hash map. + * \param key The key of the pair. + * \return True if the pair was removed, false otherwise. + */ bool hash_map_remove(struct hash_map *hash_map, const char *key); #endif /* ! HASH_MAP_H */ \ No newline at end of file diff --git a/src/execute/loop.c b/src/execute/loop.c index 191eb9d2..0636be21 100644 --- a/src/execute/loop.c +++ b/src/execute/loop.c @@ -1,3 +1,11 @@ +/** + * \file loop.c + * \brief Loop functions. + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat + * \version 1.0 + * \date 12/01/2024 + */ + #include "ast/ast.h" #include "ast_eval.h" @@ -39,4 +47,4 @@ int for_loop(struct ast_node *node, bool logger_enabled) return -1; } return 0; -} \ No newline at end of file +} diff --git a/src/execute/pipeline.c b/src/execute/pipeline.c index 170ce841..59dd4f40 100644 --- a/src/execute/pipeline.c +++ b/src/execute/pipeline.c @@ -1,3 +1,11 @@ +/** + * \file pipeline.c + * \brief Pipeline functions. + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat + * \version 1.0 + * \date 12/01/2024 + */ + #include #include #include diff --git a/src/execute/redirections.c b/src/execute/redirections.c index 98941122..66262617 100644 --- a/src/execute/redirections.c +++ b/src/execute/redirections.c @@ -1,3 +1,11 @@ +/** + * \file redirections.c + * \brief Redirections functions. + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat + * \version 1.0 + * \date 12/01/2024 + */ + #include #include #include @@ -7,6 +15,12 @@ #include "ast/ast.h" #include "ast_eval.h" +/** + * \brief Redirections manager. + * \param ast The AST node. + * \param logger_enabled If true, the logger is enabled. + * \return The exit status 0 if success, 1 if error. +*/ int redir_output(struct ast_node *node, bool logger_enabled) { if (logger_enabled) @@ -40,6 +54,12 @@ int redir_output(struct ast_node *node, bool logger_enabled) return stat; } +/** + * \brief Redirections manager. + * \param ast The AST node. + * \param logger_enabled If true, the logger is enabled. + * \return The exit status 0 if success, 1 if error. +*/ int redir_manager(struct ast_node *ast, bool logger_enabled) { if (logger_enabled) @@ -51,4 +71,4 @@ int redir_manager(struct ast_node *ast, bool logger_enabled) return 0; } return 0; -} \ No newline at end of file +} diff --git a/src/execute/tests/exec_tests.c b/src/execute/tests/exec_tests.c index 02756a6d..0b68da70 100644 --- a/src/execute/tests/exec_tests.c +++ b/src/execute/tests/exec_tests.c @@ -1,7 +1,7 @@ /** * \file exec_tests.c * \brief Tests the exec function. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */ diff --git a/src/io_backend/io_backend.c b/src/io_backend/io_backend.c index 54b73b33..dcf2f928 100644 --- a/src/io_backend/io_backend.c +++ b/src/io_backend/io_backend.c @@ -10,6 +10,7 @@ /** * \brief Read from stdin + * \return The input */ char *io_backend_stdin(void) { @@ -53,6 +54,8 @@ char *io_backend_stdin(void) /** * \brief Read from a file + * \param argv The arguments + * \return The input */ char *io_backend_file(char **argv) { diff --git a/src/io_backend/tests/io_backend_tests.c b/src/io_backend/tests/io_backend_tests.c index 76e9e126..eee15f18 100644 --- a/src/io_backend/tests/io_backend_tests.c +++ b/src/io_backend/tests/io_backend_tests.c @@ -1,7 +1,7 @@ /** * \file io_backend_tests.c * \brief Tests the io_backend function. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */ diff --git a/src/lexer/lexer.c b/src/lexer/lexer.c index 1d502b16..7bec4b33 100644 --- a/src/lexer/lexer.c +++ b/src/lexer/lexer.c @@ -1,7 +1,7 @@ /** * \file lexer.c * \brief Lex the input. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */ diff --git a/src/lexer/lexer.h b/src/lexer/lexer.h index 05dfc386..f3d8cdb7 100644 --- a/src/lexer/lexer.h +++ b/src/lexer/lexer.h @@ -78,7 +78,10 @@ struct token lexer_pop(struct lexer *lexer); /** * \brief Handle the backslash character. - * + * \param lexer The lexer. + * \param is_diactivated A pointer to a boolean that will be set to true if the word is diactivated. + * \param word The word. + * \param word_index The index of the word. * \return false if it's the end of the string, true otherwise. */ void handle_backslash(struct lexer *lexer, bool *is_diactivated, char *word, @@ -86,7 +89,10 @@ void handle_backslash(struct lexer *lexer, bool *is_diactivated, char *word, /** * \brief Handle the simple quote character. - * + * \param lexer The lexer. + * \param is_diactivated A pointer to a boolean that will be set to true if the word is diactivated. + * \param word The word. + * \param word_index The index of the word. * \return false if a closing quote was not found, true otherwise. */ char *handle_simple_quote(struct lexer *lexer, bool *is_diactivated, char *word, @@ -94,11 +100,7 @@ char *handle_simple_quote(struct lexer *lexer, bool *is_diactivated, char *word, /** * \brief Check if the word is a variable assignement. - * - * \param lexer The lexer. * \param word The word to check. - * \param word_index The index of the word. - * * \return if the word is a variable assignement. */ bool check_variable_assignement(char *word); @@ -108,7 +110,7 @@ bool check_variable_assignement(char *word); * \param lexer The lexer. * \param word The word to check. * \param word_index The index of the word. - * + * \param is_in_braces A pointer to a boolean that will be set to true if the word is in braces. * \return if the word is a variable name. */ bool check_variable_name(struct lexer *lexer, char **word, unsigned *word_index, @@ -117,6 +119,9 @@ bool check_variable_name(struct lexer *lexer, char **word, unsigned *word_index, /** * \brief Handle the dollar character. * \param lexer The lexer. + * \param word The word. + * \param word_index The index of the word. + * \param is_in_braces A pointer to a boolean that will be set to true if the word is in braces. * \return The next word. */ bool handle_dollar(struct lexer *lexer, char **word, unsigned *word_index, @@ -125,6 +130,9 @@ bool handle_dollar(struct lexer *lexer, char **word, unsigned *word_index, /** * \brief Handle the double quote character. * \param lexer The lexer. + * \param is_diactivated A pointer to a boolean that will be set to true if the word is diactivated. + * \param word The word. + * \param word_index The index of the word. * \return The next word. */ char *handle_double_quote(struct lexer *lexer, bool *is_diactivated, char *word, @@ -132,7 +140,9 @@ char *handle_double_quote(struct lexer *lexer, bool *is_diactivated, char *word, /** * \brief Handle the comment character. - * + * \param lexer The lexer. + * \param word The word. + * \param word_index The index of the word. * \return The next word. */ char *handle_comment(struct lexer *lexer, char *word, unsigned *word_index); @@ -140,6 +150,7 @@ char *handle_comment(struct lexer *lexer, char *word, unsigned *word_index); /** * \brief Handle the redirection character. * \param lexer The lexer. + * \param word_index The index of the word. * \return The next redirection word. */ char *handle_redir(struct lexer *lexer, unsigned *word_index); @@ -147,8 +158,8 @@ char *handle_redir(struct lexer *lexer, unsigned *word_index); /** * \brief Returns the next word in the input string. * \param lexer The lexer. - * \param is_diactivated A pointer to a boolean that will be set to true if the - * word is diactivated. \return The next word. + * \param is_diactivated A pointer to a boolean that will be set to true if the word is diactivated. + * \return The next word. */ char *get_word(struct lexer *lexer, bool *is_diactivated); diff --git a/src/lexer/tests/lexer_tests.c b/src/lexer/tests/lexer_tests.c index a91bf37d..bead5df4 100644 --- a/src/lexer/tests/lexer_tests.c +++ b/src/lexer/tests/lexer_tests.c @@ -1,7 +1,7 @@ /** * \file lexer_tests.c * \brief Tests the lexer functions. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */ diff --git a/src/options/options.c b/src/options/options.c index 04d72d5e..f46e8473 100644 --- a/src/options/options.c +++ b/src/options/options.c @@ -1,7 +1,7 @@ /** * \file options.c * \brief Options functions. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */ @@ -15,6 +15,13 @@ #include #include +#include "ast/ast.h" + +/** + * \brief Check if the given string is a number. + * \param str The string to check. + * \return 1 if the string is a number, 0 otherwise. +*/ int is_number(char *str) { int i = 0; @@ -105,6 +112,12 @@ int count_digits(int number) return count; } +/** + * \brief Print the AST in a file. + * \param ast The AST to print. + * \param fd The file descriptor. + * \param node_count The number of nodes. +*/ void pp_node(struct ast_node *ast, int fd, int *node_count) { char *buff = malloc(sizeof(char) * 100000); @@ -135,6 +148,13 @@ void pp_node(struct ast_node *ast, int fd, int *node_count) free(buff); } +/** + * \brief Print the AST links in a file. + * \param ast The AST to print. + * \param fd The file descriptor. + * \param node_count The number of nodes. + * \param parent_id The parent id. +*/ void pp_link(struct ast_node *ast, int fd, int *node_count, int parent_id) { char *buff = malloc(sizeof(char) * 100000); diff --git a/src/options/options.h b/src/options/options.h index 20778a36..0c00ee33 100644 --- a/src/options/options.h +++ b/src/options/options.h @@ -1,7 +1,7 @@ /** * \file options.h * \brief Header for options functions. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */ @@ -50,6 +50,9 @@ void logger(char *str, enum logger_step step, bool logger_enabled); /** * \brief Pretty printf of ast. + * \param ast The ast to print. + * \param pretty_print_enabled True if the pretty print is enabled, false otherwise. + * \param depths The depths of the ast. */ void pretty_print(struct ast_node *ast, bool pretty_print_enabled, int *depths); diff --git a/src/options/tests/options_tests.c b/src/options/tests/options_tests.c index 284fcd12..64ba3470 100644 --- a/src/options/tests/options_tests.c +++ b/src/options/tests/options_tests.c @@ -1,7 +1,7 @@ /** * \file options_tests.c * \brief Tests the options functions. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */ diff --git a/src/parser/parser.c b/src/parser/parser.c index 0c331a69..307baa42 100644 --- a/src/parser/parser.c +++ b/src/parser/parser.c @@ -1,7 +1,7 @@ /** * \file parser.c * \brief Parse the input and build the AST. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */ @@ -62,9 +62,6 @@ struct ast_node *parse(struct lexer *lexer) return input(lexer); } -/** - * \brief Parse loop line by line and execute it - */ int parser_loop(struct lexer *lexer, bool logger_enabled, bool pretty_print_enabled) { diff --git a/src/parser/parser.h b/src/parser/parser.h index 7322ee86..9d33b9a2 100644 --- a/src/parser/parser.h +++ b/src/parser/parser.h @@ -21,7 +21,7 @@ * \param lexer The lexer to parse. * \param logger_enabled The option logger. * \param pretty_print_enabled The option pretty_print. - * \return code of execution. + * \return code of execution 0 if success, 1 if error. */ int parser_loop(struct lexer *lexer, bool logger_enabled, bool pretty_print_enabled); @@ -156,6 +156,11 @@ enum token_type parser_peek(struct lexer *lexer); */ enum token_type parser_pop(struct lexer *lexer); +/** + * \brief Return the next token type and consume it if it matches the given + * \param lexer The lexer to parse. + * \return The next token type. + */ struct ast_node *parse_variable(struct lexer *lexer); -#endif /* ! PARSER_H */ \ No newline at end of file +#endif /* ! PARSER_H */ diff --git a/src/parser/parser_condition.c b/src/parser/parser_condition.c index fb0f86d1..211bc9ca 100644 --- a/src/parser/parser_condition.c +++ b/src/parser/parser_condition.c @@ -1,7 +1,7 @@ /** * \file parser_condition.c * \brief Parse the condition rule. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */ @@ -257,4 +257,4 @@ struct ast_node *rule_for(struct lexer *lexer) ERROR: ast_free(current); return NULL; -} \ No newline at end of file +} diff --git a/src/parser/parser_element.c b/src/parser/parser_element.c index fa6aaf7a..19d8b743 100644 --- a/src/parser/parser_element.c +++ b/src/parser/parser_element.c @@ -1,7 +1,7 @@ /** * \file parser_element.c * \brief Parse the element rule. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */ @@ -206,4 +206,4 @@ struct ast_node *element(struct lexer *lexer) } ast_free(current); return NULL; -} \ No newline at end of file +} diff --git a/src/parser/parser_functionnal.c b/src/parser/parser_functionnal.c index bd5834c1..5eeddb2a 100644 --- a/src/parser/parser_functionnal.c +++ b/src/parser/parser_functionnal.c @@ -1,3 +1,11 @@ +/** + * \file parser_functionnal.c + * \brief Parse the functionnal + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat + * \version 1.0 + * \date 12/01/2024 + */ + #include "parser.h" struct ast_node *prefix(struct lexer *lexer) @@ -41,4 +49,4 @@ struct ast_node *redirection(struct lexer *lexer) } ast_free(current); return NULL; -} \ No newline at end of file +} diff --git a/src/parser/parser_variable.c b/src/parser/parser_variable.c index 60a8c818..0378d9dd 100644 --- a/src/parser/parser_variable.c +++ b/src/parser/parser_variable.c @@ -1,3 +1,11 @@ +/** + * \file parser_variable.c + * \brief Parse the variable + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat + * \version 1.0 + * \date 12/01/2024 + */ + #include "parser.h" struct ast_node *parse_variable(struct lexer *lexer) diff --git a/src/parser/tests/parser_tests.c b/src/parser/tests/parser_tests.c index 169d8764..c81d75c9 100644 --- a/src/parser/tests/parser_tests.c +++ b/src/parser/tests/parser_tests.c @@ -1,7 +1,7 @@ /** * \file parser_tests.c * \brief Tests the parser functions. - * \author Erwann Lesech, Valentin Gibert, Ugo Majer, Alexandre Privat + * \author Erwann Lesech, Valentin Gibbe, Ugo Majer, Alexandre Privat * \version 1.0 * \date 12/01/2024 */