feat(parser): adapted to new lexer without static var
This commit is contained in:
parent
f1955f0532
commit
c3ab2585e1
4 changed files with 30 additions and 30 deletions
|
|
@ -4,7 +4,7 @@
|
|||
// === Macros
|
||||
|
||||
#define PEEK_TOKEN() \
|
||||
peek_token(); \
|
||||
peek_token(ctx); \
|
||||
if (token == NULL) \
|
||||
{ \
|
||||
puts("Internal error: cannot get the following token"); \
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
}
|
||||
|
||||
#define POP_TOKEN() \
|
||||
pop_token(); \
|
||||
pop_token(ctx); \
|
||||
if (token == NULL) \
|
||||
{ \
|
||||
puts("Internal error: cannot get the following token"); \
|
||||
|
|
@ -27,26 +27,26 @@
|
|||
* | EOF
|
||||
* ;
|
||||
*/
|
||||
struct ast* parse_input(void);
|
||||
struct ast *parse_input(struct lexer_context *ctx);
|
||||
|
||||
/* @brief: parses a list of [and_or] rules separated by semicolons and that
|
||||
* ends by a newline
|
||||
*
|
||||
* @code list = and_or { ';' and_or } [ ';' ] ;
|
||||
*/
|
||||
struct ast *parse_list(void);
|
||||
struct ast *parse_list(struct lexer_context *ctx);
|
||||
|
||||
/* @brief Only parses a pipeline rule for the moment
|
||||
*
|
||||
* @code and_or = pipeline ;
|
||||
*/
|
||||
struct ast *parse_and_or(void);
|
||||
struct ast *parse_and_or(struct lexer_context *ctx);
|
||||
|
||||
/* @brief Only parses a command rule for the moment
|
||||
*
|
||||
* @code pipeline = command ;
|
||||
*/
|
||||
struct ast* parse_pipeline(void);
|
||||
struct ast *parse_pipeline(struct lexer_context *ctx);
|
||||
|
||||
/* @brief Parses a simple command rule or a shell command rule depending on
|
||||
* the first token.
|
||||
|
|
@ -58,36 +58,34 @@ struct ast* parse_pipeline(void);
|
|||
* | shell_command
|
||||
* ;
|
||||
*/
|
||||
struct ast* parse_command(void);
|
||||
struct ast *parse_command(struct lexer_context *ctx);
|
||||
|
||||
/* @brief Parses a simple list of words (command and arguments)
|
||||
* ending by a separator
|
||||
*
|
||||
* @code simple_command = WORD { element } ;
|
||||
*/
|
||||
struct ast *parse_simple_command(void);
|
||||
|
||||
struct ast *parse_simple_command(struct lexer_context *ctx);
|
||||
|
||||
/* @brief Only parses if rules for the moment
|
||||
*
|
||||
* @code shell_command = if_rule ;
|
||||
*/
|
||||
struct ast *parse_shell_command(void);
|
||||
|
||||
struct ast *parse_shell_command(struct lexer_context *ctx);
|
||||
|
||||
/* @brief Parses a if rule (condition, then-clause, elif-clause, else-clause)
|
||||
*
|
||||
* @code if_rule = 'if' compound_list 'then' compound_list [else_clause] 'fi' ;
|
||||
*/
|
||||
struct ast *parse_if_rule(void);
|
||||
|
||||
struct ast *parse_if_rule(struct lexer_context *ctx);
|
||||
|
||||
/* @brief parses commands inside if/else clauses and returns the corresponding
|
||||
* AST list
|
||||
*
|
||||
* @code compound_list = {'\n'} and_or { ( ';' | '\n' ) {'\n'} and_or } [';'] {'\n'} ;
|
||||
* @code compound_list = {'\n'} and_or { ( ';' | '\n' ) {'\n'} and_or } [';']
|
||||
* {'\n'} ;
|
||||
*/
|
||||
struct ast* parse_compound_list(void);
|
||||
struct ast *parse_compound_list(struct lexer_context *ctx);
|
||||
|
||||
/* @brief
|
||||
*
|
||||
|
|
@ -95,6 +93,6 @@ struct ast* parse_compound_list(void);
|
|||
* | 'elif' compound_list 'then' compound_list [else_clause]
|
||||
* ;
|
||||
*/
|
||||
struct ast *parse_else_clause(void);
|
||||
struct ast *parse_else_clause(struct lexer_context *ctx);
|
||||
|
||||
#endif /* ! PARSING_UTILS_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue