42sh/src/parser/parsing_utils.h
2026-01-16 20:27:57 +01:00

52 lines
1.6 KiB
C

#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; \
}
/* @brief: parses a list of [and_or] rules, separated by semicolons.
*/
struct ast *parse_list(void);
/* @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);
/* @brief parses commands inside if/else clauses and returns the corresponding
* AST list
*/
struct ast* parse_compound_list(void);
/*
*/
struct ast* parse_and_or(void);
/*
*/
struct ast* parse_else_clause(void);
#endif /* ! PARSING_UTILS_H */