45 lines
1.1 KiB
C
45 lines
1.1 KiB
C
#ifndef PARSER_H
|
|
#define PARSER_H
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "../lexer/lexer.h"
|
|
#include "../utils/ast/ast.h"
|
|
|
|
enum parser_state
|
|
{
|
|
PARSER_STATE_NOT_INITIALIZED = 0,
|
|
PARSER_STATE_READY,
|
|
PARSER_STATE_CLOSED
|
|
};
|
|
|
|
/* @brief Initializes the parser module
|
|
* @warning parser needs to be closed after use with parser_close()
|
|
*
|
|
* @return Returns false on error and true on success
|
|
*/
|
|
bool parser_init(void);
|
|
|
|
/* @brief Closes the parser module after use
|
|
*/
|
|
void parser_close(void);
|
|
|
|
/* @brief Builds the AST representation of the next command to execute.
|
|
*
|
|
* @return Returns the AST representation of the next command to execute.
|
|
* If there is no command left to execute, retuns an AST_END node.
|
|
*
|
|
* @warning NOT IMPLEMENTED
|
|
*/
|
|
struct ast *get_ast(struct lexer_context *ctx);
|
|
|
|
/* @brief Builds the AST representation of the given command string.
|
|
*
|
|
* @return Returns the AST representation of the given command string.
|
|
* Returns an AST_END node if the given command is empty.
|
|
*
|
|
* @warning NOT IMPLEMENTED
|
|
*/
|
|
struct ast *get_ast_str(char *command);
|
|
|
|
#endif /* ! PARSER_H */
|