Evaluates a mathetical expression.
16{
17 int64_t result;
18
25 "Unexpected token inside an expression."
26 );
27
28 return 0;
29 }
30
39 return 0;
40 }
41
42 return result;
46
47 if (is_binary) {
53 );
54 }
55
57 default:
58 return 0;
59 }
60}
int64_t _op_unary_eval(operator_t op, int64_t a)
int64_t _op_binary_eval(int64_t a, operator_t op, int64_t b)
int64_t eval_expression(hashtable_t *variables, module_t *module, ast_node_t *ast)
Evaluates a mathetical expression.
error_code_t hashtable_get(hashtable_t *hashtable, const char *key, int64_t *value)
Get the value of the specified key inside the hashtable.
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 children_count
struct ast_node * children
unsigned int length
The length of the string.
char * data
Pointer for the raw string content (a normal C string).
Struct that represents a Mya module.
long long int value
Integer value of the token.
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