X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=oberon.h;h=b2f0965f3c6acadd009dd22e99d4e5a1df8bc270;hb=7f3e5aeb0348e6c0af28869bad6acc13fe483177;hp=7fee329106ba6f15a64fa07afbeaf1deff994f35;hpb=b752043cfbb49243ca3727dbfc9be5b614a8c9c2;p=dsw-obn.git diff --git a/oberon.h b/oberon.h index 7fee329..b2f0965 100644 --- a/oberon.h +++ b/oberon.h @@ -1,22 +1,25 @@ #ifndef EMBEDED_OBERON_SCRIPT_H #define EMBEDED_OBERON_SCRIPT_H -enum { - OBERON_TYPE_INTEGER, - OBERON_TYPE_BOOLEAN, -}; - typedef struct oberon_var_s oberon_var_t; typedef struct oberon_type_s oberon_type_t; +typedef struct oberon_proc_s oberon_proc_t; typedef struct oberon_module_s oberon_module_t; typedef struct oberon_context_s oberon_context_t; +enum { + OBERON_TYPE_INTEGER, + OBERON_TYPE_BOOLEAN, +}; + struct oberon_type_s { char * name; int class; int size; oberon_type_t * next; + + void * gen_type; }; struct oberon_var_s @@ -24,12 +27,27 @@ struct oberon_var_s char * name; oberon_type_t * type; oberon_var_t * next; + + void * gen_var; +}; + +struct oberon_proc_s +{ + char * name; + + oberon_proc_t * next; + + void * gen_proc; }; struct oberon_module_s { char * name; + oberon_var_t * vars; + oberon_proc_t * procs; + + void (* begin)(); }; struct oberon_context_s @@ -43,12 +61,78 @@ struct oberon_context_s int integer; oberon_module_t * mod; - oberon_type_t * types; + + oberon_type_t * int_type; + oberon_type_t * bool_type; + + void * gen_context; +}; + +enum { + MODE_VAR, + MODE_INTEGER, + MODE_BOOLEAN +}; + +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_var_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