42sh/src/parser/parsing_utils.h

48 lines
1.5 KiB
C
Raw Normal View History

#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 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);
#define /* ! PARSING_UTILS_H */