23 unsigned int ntokens = 0;
28 current_token = &
token[ntokens];
30 switch (current_token->
type) {
41 "Open parentheses starting here has not a expected close parentheses matching it."
55 ntokens += _parse_operator(
module, parent, &
stack, current_token);
62 goto finish_expression;
69 "Unexpected token inside an expression."
73 goto finish_expression;
96 "Unexpected expression starting here."
132 "Unrecognized operator here. It's really a valid expression operator?"
150 "Binary operator expects a valid value before it, like in: `value OPERATOR value`."
ast_node_t * ast_insert_children(ast_node_t *parent, ast_node_t *child)
Insert a exitent AST node as children of the given parent node.
void module_add_error(module_t *module, unsigned int line, unsigned int column, unsigned int length, const char *message)
Add error for the given module.
unsigned int parse_expression(module_t *module, ast_node_t *parent, token_t *token)
Parse a mathematical expression adding it as a children on parent AST node.
void stack_init(stack_t *stack)
Initializes the given stack.
ast_node_t * stack_push(stack_t *stack, node_type_t type, token_t *token)
Push a new value on the stack.
error_code_t stack_pop(stack_t *stack, ast_node_t *value)
Pop a value from the stack.
bool stack_isempty(stack_t *stack)
Check if the given stack is empty.
unsigned int length
The length of the string.
Struct that represents a Mya module.
A struct representing a dynamic stack.
long long int value
Integer value of the token on TK_NUMBER tokens.
token_type_t type
Token type.
dstring_t lexeme
Lexeme of the token.
unsigned int line
Token line inside the module.
unsigned int column
Column of the token position on the line.
struct ast_node ast_node_t
struct module module_t
Struct that represents a Mya module.
struct stack stack_t
A struct representing a dynamic stack.
struct token token_t
Struct for a Mya token.