1 | #define OPENFILES 16 |
---|
2 | #define HASHSIZE 1024 |
---|
3 | #define STACKSIZE 10 |
---|
4 | enum aisc_commands { |
---|
5 | no_command, |
---|
6 | IF, |
---|
7 | ENDIF, |
---|
8 | ELSE, |
---|
9 | FOR, |
---|
10 | NEXT, |
---|
11 | ENDFOR, |
---|
12 | ELSEIF, |
---|
13 | FUNCTION, |
---|
14 | LABEL, |
---|
15 | MAX_COM }; |
---|
16 | |
---|
17 | struct hash_entry { |
---|
18 | char *key; |
---|
19 | char *val; |
---|
20 | struct hash_entry *next; |
---|
21 | }; |
---|
22 | typedef struct hash_struct { |
---|
23 | int size; |
---|
24 | struct hash_entry **entries; |
---|
25 | } hash; |
---|
26 | |
---|
27 | |
---|
28 | typedef struct acm_data { |
---|
29 | struct acm_data *next_item; |
---|
30 | struct acm_data *next_line; |
---|
31 | struct acm_data *first_item; |
---|
32 | struct acm_data *first_line; |
---|
33 | struct acm_data *father; |
---|
34 | const char *key; |
---|
35 | struct acm_data *sub; |
---|
36 | char *val; |
---|
37 | } AD; |
---|
38 | |
---|
39 | typedef struct header_struct { |
---|
40 | struct header_struct *next; |
---|
41 | char *key; |
---|
42 | } HS; |
---|
43 | |
---|
44 | struct for_data_struct { |
---|
45 | char *forstr; |
---|
46 | AD *forcursor; |
---|
47 | long forval; |
---|
48 | long forend; |
---|
49 | struct for_data_struct *next; |
---|
50 | }; |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | typedef struct command_lines { |
---|
55 | struct command_lines *next; |
---|
56 | char *str; |
---|
57 | int linenr; |
---|
58 | char *path; |
---|
59 | enum aisc_commands command; |
---|
60 | struct for_data_struct *fd; |
---|
61 | struct command_lines *IF; |
---|
62 | struct command_lines *ELSE; |
---|
63 | struct command_lines *ENDIF; |
---|
64 | struct command_lines *FOR; |
---|
65 | struct command_lines *NEXT; |
---|
66 | struct command_lines *ENDFOR; |
---|
67 | } CL; |
---|
68 | |
---|
69 | struct stack_struct { |
---|
70 | AD *cursor; |
---|
71 | CL *pc; |
---|
72 | hash *hs; |
---|
73 | struct stack_struct *next; |
---|
74 | }; |
---|
75 | |
---|
76 | struct param_struct { |
---|
77 | char *param; |
---|
78 | struct param_struct *next; |
---|
79 | }; |
---|
80 | |
---|
81 | struct global_struct { |
---|
82 | int error_flag; |
---|
83 | char b_tab[256]; |
---|
84 | char s_tab[256]; |
---|
85 | char s2_tab[256]; |
---|
86 | char s3_tab[256]; |
---|
87 | char c_tab[256]; |
---|
88 | char outtab[256]; |
---|
89 | AD *cursor; |
---|
90 | AD *root; |
---|
91 | CL *prg; |
---|
92 | CL *pc; |
---|
93 | CL *nextpc; |
---|
94 | struct stack_struct *st; |
---|
95 | int sp; |
---|
96 | int line_cnt; |
---|
97 | char *line_path; |
---|
98 | int lastchar; |
---|
99 | char *linebuf; |
---|
100 | int bufsize; |
---|
101 | int s_pos; |
---|
102 | FILE *out; |
---|
103 | FILE *outs[OPENFILES]; |
---|
104 | char *fouts[OPENFILES]; // type of file |
---|
105 | char *fouts_name[OPENFILES]; // file-system-name of file |
---|
106 | |
---|
107 | int tabstop; |
---|
108 | int tabs[10]; |
---|
109 | hash *fns; |
---|
110 | int tabpos; |
---|
111 | }; |
---|
112 | |
---|
113 | extern struct global_struct *gl; |
---|
114 | extern char string_buf[256]; |
---|
115 | #define READ_SPACES(var) while(gl->s3_tab[(unsigned)(*var)]) var++; |
---|
116 | #define READ_RSPACES(var) while(gl->s3_tab[(unsigned)(*(--var))]); |
---|
117 | |
---|
118 | #define EOSTR 0 |
---|
119 | #define BEG_STR1 '(' |
---|
120 | #define BEG_STR2 '~' |
---|
121 | #define END_STR1 '~' |
---|
122 | #define END_STR2 ')' |
---|
123 | |
---|
124 | #include "aisc_proto.h" |
---|
125 | |
---|
126 | #define aisc_assert(cond) do { if (!(cond)) { *(char*)NULL = 0; } } while(0) /* core dump */ |
---|
127 | |
---|
128 | // #define SHOW_CALLER // show where error was raised |
---|
129 | |
---|
130 | #ifdef SHOW_CALLER |
---|
131 | #define print_error(err) print_error_internal(err, __FILE__, __LINE__) |
---|
132 | #define print_warning(err) print_warning_internal(err, __FILE__, __LINE__) |
---|
133 | #define printf_error(format, arg) print_error_internal(formatted(format, arg), __FILE__, __LINE__) |
---|
134 | #else |
---|
135 | #define print_error(err) print_error_internal(err, NULL, 0) |
---|
136 | #define print_warning(err) print_warning_internal(err, NULL, 0) |
---|
137 | #define printf_error(format, arg) print_error_internal(formatted(format, arg), NULL, 0) |
---|
138 | #endif |
---|