327
|
1 /* for mc-parse.c */
|
|
2
|
607
|
3
|
|
4 /************************************************************************
|
|
5 ** Copyright (C) 2006 Shinji Kono
|
|
6 ** 連絡先: 琉球大学情報工学科 河野 真治
|
|
7 ** (E-Mail Address: kono@ie.u-ryukyu.ac.jp)
|
|
8 **
|
|
9 ** このソースのいかなる複写,改変,修正も許諾します。ただし、
|
|
10 ** その際には、誰が貢献したを示すこの部分を残すこと。
|
|
11 ** 再配布や雑誌の付録などの問い合わせも必要ありません。
|
|
12 ** 営利利用も上記に反しない範囲で許可します。
|
|
13 ** バイナリの配布の際にはversion messageを保存することを条件とします。
|
|
14 ** このプログラムについては特に何の保証もしない、悪しからず。
|
|
15 **
|
|
16 ** Everyone is permitted to do anything on this program
|
|
17 ** including copying, modifying, improving,
|
|
18 ** as long as you don't try to pretend that you wrote it.
|
|
19 ** i.e., the above copyright notice has to appear in all copies.
|
|
20 ** Binary distribution requires original version messages.
|
|
21 ** You don't have to ask before copying, redistribution or publishing.
|
|
22 ** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
|
|
23 ***********************************************************************/
|
|
24
|
452
|
25 extern int sym; /* next symbol */
|
|
26 extern int type; /* current type */
|
|
27 extern int mode; /* grammer mode (STAT,ADECL) */
|
|
28 extern int stmode; /* storage mode (STATIC,EXTRN) */
|
|
29 extern int ctmode; /* constant mode */
|
454
|
30 extern int inmode; /* inline mode */
|
452
|
31 extern int labelno; /* label number */
|
|
32 extern int gpc; /* global variable size (unused?) */
|
|
33 extern int disp; /* local variable offset */
|
|
34 extern int args; /* function arguments */
|
|
35 extern int init_vars; /* variable initialize list in local decl */
|
|
36 extern int cslabel; /* case label */
|
454
|
37 extern int cslist; /* case list */
|
|
38 extern int clabel; /* continue label */
|
452
|
39 extern int control; /* control is reached */
|
|
40 extern NMTBL *nptr; /* current name table */
|
|
41 extern NMTBL *gnptr; /* currrent global name table (unsed?) */
|
|
42 extern NMTBL *fnptr; /* current function name table */
|
547
|
43 extern NMTBL *local_nptr; /* initialzing local variable nptr */
|
452
|
44 extern int retlabel; /* return label */
|
|
45 extern int retpending; /* jump to return label suspended */
|
|
46 extern int retcont; /* continuation label */
|
|
47 extern int pending_jmp; /* suspended jump label */
|
|
48 extern int chk; /* no code generation */
|
|
49 extern int bit_field_disp; /* bit field bit offset */
|
|
50 extern int fields; /* struct field */
|
|
51 extern int struct_return; /* temporal return structure variable */
|
|
52 extern int lastexp; /* last expression in statement expressoin */
|
|
53 extern int debug; /* debug flag */
|
|
54 extern int decl_str_init; /* partial structure initializer */
|
453
|
55 extern int inline_funcs; /* inline function list */
|
452
|
56
|
|
57 extern int parse; /* parse tree */
|
328
|
58
|
346
|
59 /*
|
|
60 STRING nptr
|
|
61 MACRO nptr
|
|
62 FMACRO nptr
|
|
63 RESERVE nptr
|
|
64 TAG nptr
|
|
65 FIELD nptr
|
|
66 TYPE nptr
|
|
67 */
|
|
68
|
452
|
69 /* memory pool structure */
|
|
70 /* extendable */
|
346
|
71 typedef struct cheap
|
|
72 {
|
452
|
73 char *ptr; /* current pointer */
|
346
|
74 char *last;
|
|
75 char *first;
|
452
|
76 struct cheap *next; /* previous cheap */
|
346
|
77 } CHEAP;
|
|
78
|
327
|
79
|
|
80 /* used in mc-macro.c */
|
|
81
|
452
|
82 extern int asmf; /* assembler generating mode (old) */
|
|
83 extern int ch; /* current character */
|
|
84 extern int chptrsave; /* nested character pointer */
|
|
85 extern int chsave; /* saved current character */
|
|
86 extern char linebuf[LBUFSIZE]; /* line buffer */
|
|
87 extern char *chptr; /* current character pointer */
|
|
88 extern int glineno; /* total lineno */
|
|
89 extern int in_comment; /* tokenizer mode */
|
|
90 extern int in_quote; /* tokenizer mode */
|
|
91 extern int lfree; /* local free heap top */
|
|
92 extern int lineno; /* lineno in current file */
|
|
93 extern int lsrc; /* source listing flag */
|
327
|
94 extern char *include_path[MAX_INCLUDE_PATH_COUNT];
|
|
95
|
|
96 /* used in mc-code-* */
|
|
97
|
|
98 extern NMTBL null_nptr;
|
|
99
|
346
|
100 extern char * make_filename_with_extension(char *filename,char *ext);
|
|
101
|
327
|
102 /* used in mc-switch */
|
|
103
|
|
104 extern void free_glist3(int e1);
|
383
|
105 extern void free_glist3_a(int e1);
|
452
|
106 extern int csvalue1; /* current switch variable */
|
|
107 extern int blabel; /* break label in switch */
|
|
108 extern int dlabel; /* default label in switch */
|
327
|
109
|
|
110 /* used in mc-tree.c */
|
|
111
|
547
|
112 extern int gtypedefed; /* global typedef list */
|
452
|
113 extern int typedefed; /* accumlated typedef name */
|
327
|
114
|
|
115 /* global variable end */
|
|
116
|
|
117 extern void free_glist2(int e1);
|
|
118
|
|
119 /* used in mc-codegen.c */
|
|
120
|
554
|
121 extern NMTBL * anonymous_nptr();
|
327
|
122 extern int append4(int p,int a1,int a2,int a3);
|
|
123 extern void display_ntable(NMTBL *n, char *s);
|
355
|
124 extern NMTBL * lsearch(char *name,int sc);
|
327
|
125 #if FLOAT_CODE
|
440
|
126 extern int dlist2(int e1, double d1);
|
327
|
127 #endif
|
|
128 extern void error(int n);
|
|
129 extern int glist2(int e1,int e2);
|
|
130 extern int glist3(int e1,int e2,int e3);
|
574
|
131 extern int glist4(int e1,int e2,int e3,int e4);
|
327
|
132
|
|
133 extern int insert_ascend(int p,int e,int eq());
|
|
134 extern int length(int list);
|
|
135 extern int list2(int e1, int e2);
|
|
136 extern int list3(int e1, int e2, int e3);
|
|
137 extern int list4(int e1, int e2, int e3, int e4);
|
|
138 extern void extern_define(char *s,int d,int type,int use);
|
447
|
139 extern void set_lfree(int save);
|
327
|
140
|
453
|
141 extern int has_attr(NMTBL *n,int attr);
|
|
142 extern int attr_value(NMTBL *n,int attr);
|
|
143 extern void set_attr(NMTBL *n,int attr,int value);
|
487
|
144 extern int set_type_attr(int type,int attr);
|
488
|
145 extern int gset_type_attr(int type,int attr);
|
487
|
146 extern int get_type_attr(int type);
|
|
147 extern int type_value(int type);
|
|
148 extern int set_type_with_attr(int type,int type_with_attr);
|
488
|
149 extern int gset_type_with_attr(int type,int type_with_attr);
|
487
|
150
|
453
|
151
|
327
|
152 #if LONGLONG_CODE
|
|
153 extern int llist2(int e1, long long d1);
|
|
154 #endif
|
|
155 extern int neqname(char *p,char *q);
|
347
|
156 extern NMTBL *new_static_name(char *name,int delimit);
|
327
|
157 extern int reverse0(int t1);
|
|
158 extern int size(int t);
|
|
159
|
|
160 /* used in mc-macro.c */
|
|
161
|
346
|
162 extern struct cheap *cheap;
|
560
|
163 extern struct cheap *st_cheap, *cheap1; // for ST_COMMENT
|
350
|
164
|
|
165 extern NMTBL *get_name(char *name,int *i,int mode);
|
|
166 #define DEF 1
|
|
167 #define NONDEF 2
|
|
168
|
349
|
169 extern NMTBL * get_name_from_chptr();
|
347
|
170 extern NMTBL *name_space_search(NMTBL *ns,int sc);
|
346
|
171
|
327
|
172 extern int getsym(int sc);
|
|
173 extern int getch(void);
|
|
174 extern int skipspc(void);
|
|
175 extern void copy_current_file_dir(char *name);
|
|
176 extern int expr(int noconv);
|
|
177
|
|
178 extern int alpha(int c);
|
|
179 extern int digit(int c);
|
359
|
180 extern void enter_scope();
|
|
181 extern void leave_scope();
|
|
182 extern NMTBL *make_local_scope();
|
327
|
183
|
346
|
184 extern struct cheap * increment_cheap(struct cheap *cheap,char **save);
|
|
185 extern void save_cheap(struct cheap *scheap,struct cheap *cheap);
|
|
186 extern struct cheap * reset_cheap(struct cheap *scheap);
|
560
|
187 extern struct cheap * new_cheap();
|
453
|
188 extern void pfdecl(NMTBL *nptr);
|
454
|
189 #if CASE_CODE
|
|
190 extern int docase_eq();
|
|
191 #endif
|
|
192 extern NMTBL *l_top_search(char *name,int sc);
|
346
|
193
|
327
|
194 /* end */
|