DEADSOFTWARE

Добавлены выражения
[dsw-obn.git] / oberon.h
1 #ifndef EMBEDED_OBERON_SCRIPT_H
2 #define EMBEDED_OBERON_SCRIPT_H
4 typedef struct oberon_var_s oberon_var_t;
5 typedef struct oberon_type_s oberon_type_t;
6 typedef struct oberon_module_s oberon_module_t;
7 typedef struct oberon_context_s oberon_context_t;
9 enum {
10 OBERON_TYPE_INTEGER,
11 OBERON_TYPE_BOOLEAN,
12 };
14 struct oberon_type_s
15 {
16 char * name;
17 int class;
18 int size;
19 oberon_type_t * next;
21 void * gen_type;
22 };
24 struct oberon_var_s
25 {
26 char * name;
27 oberon_type_t * type;
28 oberon_var_t * next;
30 void * gen_var;
31 };
33 struct oberon_module_s
34 {
35 char * name;
36 oberon_var_t * vars;
38 void (* begin)();
39 };
41 struct oberon_context_s
42 {
43 const char * code;
44 int code_index;
46 char c;
47 int token;
48 char * string;
49 int integer;
51 oberon_module_t * mod;
52 oberon_type_t * types;
54 oberon_type_t * int_type;
55 oberon_type_t * bool_type;
57 void * gen_context;
58 };
60 enum {
61 MODE_VAR,
62 MODE_INTEGER,
63 MODE_BOOLEAN
64 };
66 enum {
67 OP_LOGIC_NOT,
68 OP_UNARY_MINUS,
69 OP_ADD,
70 OP_SUB,
71 OP_MUL,
72 OP_DIV,
73 OP_MOD,
74 OP_LOGIC_AND,
75 OP_LOGIC_OR,
76 OP_EQ,
77 OP_NEQ,
78 OP_LSS,
79 OP_LEQ,
80 OP_GRT,
81 OP_GEQ
82 };
84 typedef struct oberon_item_s oberon_item_t;
85 typedef struct oberon_oper_s oberon_oper_t;
86 typedef union oberon_expr_u oberon_expr_t;
88 struct oberon_item_s
89 {
90 int is_item;
91 oberon_type_t * result;
93 int mode;
94 int integer;
95 int boolean;
96 oberon_var_t * var;
97 };
99 struct oberon_oper_s
101 int is_item;
102 oberon_type_t * result;
104 int op;
105 oberon_expr_t * left;
106 oberon_expr_t * right;
107 };
109 union oberon_expr_u
111 struct {
112 int is_item;
113 oberon_type_t * result;
114 };
116 oberon_item_t item;
117 oberon_oper_t oper;
118 };
120 oberon_context_t * oberon_create_context();
121 void oberon_destroy_context(oberon_context_t * ctx);
122 void oberon_register_global_type(oberon_context_t * ctx, oberon_type_t * type);
123 oberon_module_t * oberon_compile_module(oberon_context_t * ctx, const char * code);
124 void oberon_error(oberon_context_t * ctx, const char * fmt, ...);
126 #endif // EMBEDED_OBERON_SCRIPT_H