You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
2.3 KiB
129 lines
2.3 KiB
#ifndef INCLUDE_H
|
|
#define INCLUDE_H
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <stdbool.h>
|
|
#include "hashmap/map.h"
|
|
|
|
#define DEON_DEBUGGING 0
|
|
bool _DEON_DEBUG;
|
|
|
|
//--- different variable values
|
|
typedef enum _variable_type
|
|
{
|
|
VAR_INT,
|
|
VAR_SHORT,
|
|
VAR_BYTE,
|
|
VAR_DOUBLE,
|
|
VAR_STRING,
|
|
VAR_VOID
|
|
} variable_type;
|
|
|
|
//--- different function operations
|
|
typedef enum _function_type
|
|
{
|
|
FUNCTION,
|
|
FUNCTION_CALL,
|
|
} function_type;
|
|
|
|
//--- different print operations
|
|
typedef enum _print_type
|
|
{
|
|
PRINT_VARIABLE,
|
|
PRINT_CONSTANT
|
|
} print_type;
|
|
|
|
//--- different logic types
|
|
typedef enum _logic_type
|
|
{
|
|
IF_LOGIC,
|
|
WHILE_LOGIC
|
|
} logic_type;
|
|
|
|
typedef enum _assignment_type
|
|
{
|
|
ASSIGN_FROM_VAR,
|
|
ASSIGN_FROM_CONST
|
|
} assignment_type;
|
|
|
|
//--- all operations in the language
|
|
typedef enum _operation
|
|
{
|
|
ASSIGNMENT_OPERATION,
|
|
LOGIC_OPERATION,
|
|
EXEC_STMT_LIST_OPERATION,
|
|
PRINT_OPERATION,
|
|
FUNCTION_OPERATION,
|
|
} operation;
|
|
|
|
//--- variable value details
|
|
typedef struct _variable_values
|
|
{
|
|
variable_type type;
|
|
void* data_ptr;
|
|
} variable_values;
|
|
|
|
//--- variable details
|
|
typedef struct _variable
|
|
{
|
|
char *name;
|
|
variable_values *value;
|
|
struct variable *next;
|
|
} variable;
|
|
|
|
//--- print data
|
|
typedef struct _print
|
|
{
|
|
enum _variable_type type;
|
|
void* value;
|
|
} print;
|
|
|
|
//--- assignment data
|
|
typedef struct _assignment_operation
|
|
{
|
|
char* from;
|
|
char* to;
|
|
variable* var;
|
|
}assignment_operation;
|
|
|
|
//--- logic operation data
|
|
typedef struct _logic
|
|
{
|
|
logic_type type;
|
|
char* condition_var;
|
|
struct node_info* stmt_list;
|
|
} logic;
|
|
|
|
//--- struct that brings it all together
|
|
typedef struct node_info
|
|
{
|
|
//--- node operation.
|
|
enum _operation operation;
|
|
|
|
//--- sub operations.
|
|
union _operation_type
|
|
{
|
|
logic_type logic;
|
|
function_type func;
|
|
print_type print;
|
|
assignment_type assignment;
|
|
} operation_type;
|
|
|
|
char *name;
|
|
print* print_expr;
|
|
logic* logical_expr;
|
|
assignment_operation* assignment;
|
|
variable* var;
|
|
struct node_info *next;
|
|
struct node_info *function_body;
|
|
struct node_info *statement_list;
|
|
struct node_info *new_scope;
|
|
struct map_void_t *var_map;
|
|
} node_info;
|
|
|
|
//--- globals
|
|
map_void_t* _var_map;
|
|
node_info* _temp_statement_head;
|
|
map_void_t* _function_list;
|
|
#endif
|