#ifndef EMBEDED_OBERON_SCRIPT_H #define EMBEDED_OBERON_SCRIPT_H typedef struct oberon_type_s oberon_type_t; typedef struct oberon_object_s oberon_object_t; typedef struct oberon_module_s oberon_module_t; typedef struct oberon_context_s oberon_context_t; typedef struct oberon_scope_s oberon_scope_t; struct oberon_scope_s { oberon_context_t * ctx; oberon_object_t * list; oberon_scope_t * up; }; enum { OBERON_TYPE_INTEGER, OBERON_TYPE_BOOLEAN, }; struct oberon_type_s { int class; int size; void * gen_type; }; enum { OBERON_CLASS_VAR, OBERON_CLASS_TYPE, OBERON_CLASS_PROC }; struct oberon_object_s { char * name; int class; oberon_type_t * type; void * gen_var; void * gen_proc; oberon_object_t * next; }; struct oberon_module_s { char * name; oberon_scope_t * decl; void (* begin)(); }; struct oberon_context_s { const char * code; int code_index; char c; int token; char * string; int integer; oberon_scope_t * decl; oberon_module_t * mod; oberon_type_t * int_type; oberon_type_t * bool_type; oberon_scope_t * world_scope; void * gen_context; }; enum { MODE_VAR, MODE_INTEGER, MODE_BOOLEAN, MODE_CALL }; enum { OP_LOGIC_NOT, OP_UNARY_MINUS, OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD, OP_LOGIC_AND, OP_LOGIC_OR, OP_EQ, OP_NEQ, OP_LSS, OP_LEQ, OP_GRT, OP_GEQ }; typedef struct oberon_item_s oberon_item_t; typedef struct oberon_oper_s oberon_oper_t; typedef union oberon_expr_u oberon_expr_t; struct oberon_item_s { int is_item; oberon_type_t * result; int mode; int integer; int boolean; oberon_object_t * var; }; struct oberon_oper_s { int is_item; oberon_type_t * result; int op; oberon_expr_t * left; oberon_expr_t * right; }; union oberon_expr_u { struct { int is_item; oberon_type_t * result; }; oberon_item_t item; oberon_oper_t oper; }; oberon_context_t * oberon_create_context(); void oberon_destroy_context(oberon_context_t * ctx); void oberon_register_global_type(oberon_context_t * ctx, oberon_type_t * type); oberon_module_t * oberon_compile_module(oberon_context_t * ctx, const char * code); void oberon_error(oberon_context_t * ctx, const char * fmt, ...); #endif // EMBEDED_OBERON_SCRIPT_H