2026-01-16 19:45:15 +01:00
|
|
|
#ifndef PARSING_UTILS_H
|
|
|
|
|
#define PARSING_UTILS_H
|
|
|
|
|
|
|
|
|
|
// === Macros
|
|
|
|
|
|
|
|
|
|
#define PEEK_TOKEN() \
|
|
|
|
|
peek_token(); \
|
|
|
|
|
if (token == NULL) \
|
|
|
|
|
{ \
|
|
|
|
|
puts("Internal error: cannot get the following token"); \
|
|
|
|
|
return NULL; \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define POP_TOKEN() \
|
|
|
|
|
pop_token(); \
|
|
|
|
|
if (token == NULL) \
|
|
|
|
|
{ \
|
|
|
|
|
puts("Internal error: cannot get the following token"); \
|
|
|
|
|
return NULL; \
|
|
|
|
|
}
|
2026-01-13 19:41:37 +01:00
|
|
|
/* @brief Parses a simple list of words (command and arguments)
|
|
|
|
|
* and returns the resulting ast
|
|
|
|
|
*/
|
|
|
|
|
struct ast *parse_simple_command(void);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*/
|
|
|
|
|
struct ast *parse_if_rule(void);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*/
|
|
|
|
|
struct ast *parse_shell_command(void);
|
|
|
|
|
|
2026-01-14 20:53:47 +01:00
|
|
|
/* @brief parses commands inside if/else clauses and returns the corresponding
|
|
|
|
|
* AST list
|
2026-01-13 19:41:37 +01:00
|
|
|
*/
|
|
|
|
|
struct ast* parse_compound_list(void);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*/
|
|
|
|
|
struct ast* parse_and_or(void);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*/
|
2026-01-14 20:53:47 +01:00
|
|
|
struct ast* parse_else_clause(void);
|
2026-01-16 19:45:15 +01:00
|
|
|
|
|
|
|
|
#define /* ! PARSING_UTILS_H */
|