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 */
|
650
|
58 extern int attribute; /* attribute list (in __attribute()) */
|
328
|
59
|
346
|
60 /*
|
|
61 STRING nptr
|
|
62 MACRO nptr
|
|
63 FMACRO nptr
|
|
64 RESERVE nptr
|
|
65 TAG nptr
|
|
66 FIELD nptr
|
|
67 TYPE nptr
|
|
68 */
|
|
69
|
452
|
70 /* memory pool structure */
|
|
71 /* extendable */
|
346
|
72 typedef struct cheap
|
|
73 {
|
452
|
74 char *ptr; /* current pointer */
|
346
|
75 char *last;
|
|
76 char *first;
|
452
|
77 struct cheap *next; /* previous cheap */
|
346
|
78 } CHEAP;
|
|
79
|
327
|
80
|
|
81 /* used in mc-macro.c */
|
|
82
|
452
|
83 extern int asmf; /* assembler generating mode (old) */
|
|
84 extern int ch; /* current character */
|
|
85 extern int chptrsave; /* nested character pointer */
|
|
86 extern int chsave; /* saved current character */
|
|
87 extern char linebuf[LBUFSIZE]; /* line buffer */
|
|
88 extern char *chptr; /* current character pointer */
|
|
89 extern int glineno; /* total lineno */
|
|
90 extern int in_comment; /* tokenizer mode */
|
|
91 extern int in_quote; /* tokenizer mode */
|
|
92 extern int lfree; /* local free heap top */
|
|
93 extern int lineno; /* lineno in current file */
|
|
94 extern int lsrc; /* source listing flag */
|
327
|
95 extern char *include_path[MAX_INCLUDE_PATH_COUNT];
|
|
96
|
|
97 /* used in mc-code-* */
|
|
98
|
|
99 extern NMTBL null_nptr;
|
|
100
|
346
|
101 extern char * make_filename_with_extension(char *filename,char *ext);
|
|
102
|
327
|
103 /* used in mc-switch */
|
|
104
|
|
105 extern void free_glist3(int e1);
|
383
|
106 extern void free_glist3_a(int e1);
|
452
|
107 extern int csvalue1; /* current switch variable */
|
|
108 extern int blabel; /* break label in switch */
|
|
109 extern int dlabel; /* default label in switch */
|
327
|
110
|
|
111 /* used in mc-tree.c */
|
|
112
|
547
|
113 extern int gtypedefed; /* global typedef list */
|
452
|
114 extern int typedefed; /* accumlated typedef name */
|
327
|
115
|
|
116 /* global variable end */
|
|
117
|
|
118 extern void free_glist2(int e1);
|
|
119
|
|
120 /* used in mc-codegen.c */
|
|
121
|
554
|
122 extern NMTBL * anonymous_nptr();
|
327
|
123 extern int append4(int p,int a1,int a2,int a3);
|
|
124 extern void display_ntable(NMTBL *n, char *s);
|
355
|
125 extern NMTBL * lsearch(char *name,int sc);
|
327
|
126 #if FLOAT_CODE
|
440
|
127 extern int dlist2(int e1, double d1);
|
327
|
128 #endif
|
|
129 extern void error(int n);
|
|
130 extern int glist2(int e1,int e2);
|
|
131 extern int glist3(int e1,int e2,int e3);
|
574
|
132 extern int glist4(int e1,int e2,int e3,int e4);
|
609
|
133 extern int glist5(int e1,int e2,int e3,int e4,int e5);
|
327
|
134
|
|
135 extern int insert_ascend(int p,int e,int eq());
|
|
136 extern int length(int list);
|
|
137 extern int list2(int e1, int e2);
|
|
138 extern int list3(int e1, int e2, int e3);
|
|
139 extern int list4(int e1, int e2, int e3, int e4);
|
609
|
140 extern NMTBL * extern_define(char *s,int d,int type,int use);
|
447
|
141 extern void set_lfree(int save);
|
327
|
142
|
453
|
143 extern int has_attr(NMTBL *n,int attr);
|
|
144 extern int attr_value(NMTBL *n,int attr);
|
|
145 extern void set_attr(NMTBL *n,int attr,int value);
|
487
|
146 extern int set_type_attr(int type,int attr);
|
488
|
147 extern int gset_type_attr(int type,int attr);
|
487
|
148 extern int get_type_attr(int type);
|
|
149 extern int type_value(int type);
|
|
150 extern int set_type_with_attr(int type,int type_with_attr);
|
488
|
151 extern int gset_type_with_attr(int type,int type_with_attr);
|
487
|
152
|
453
|
153
|
327
|
154 #if LONGLONG_CODE
|
|
155 extern int llist2(int e1, long long d1);
|
|
156 #endif
|
|
157 extern int neqname(char *p,char *q);
|
347
|
158 extern NMTBL *new_static_name(char *name,int delimit);
|
327
|
159 extern int reverse0(int t1);
|
|
160 extern int size(int t);
|
650
|
161 extern void set_attributes(NMTBL *n, int attr);
|
|
162
|
|
163 extern int attr_value_in_list(int list,int attr);
|
|
164
|
327
|
165
|
|
166 /* used in mc-macro.c */
|
|
167
|
346
|
168 extern struct cheap *cheap;
|
560
|
169 extern struct cheap *st_cheap, *cheap1; // for ST_COMMENT
|
350
|
170
|
|
171 extern NMTBL *get_name(char *name,int *i,int mode);
|
|
172 #define DEF 1
|
|
173 #define NONDEF 2
|
|
174
|
349
|
175 extern NMTBL * get_name_from_chptr();
|
347
|
176 extern NMTBL *name_space_search(NMTBL *ns,int sc);
|
346
|
177
|
327
|
178 extern int getsym(int sc);
|
|
179 extern int getch(void);
|
|
180 extern int skipspc(void);
|
|
181 extern void copy_current_file_dir(char *name);
|
|
182 extern int expr(int noconv);
|
|
183
|
|
184 extern int alpha(int c);
|
|
185 extern int digit(int c);
|
359
|
186 extern void enter_scope();
|
|
187 extern void leave_scope();
|
|
188 extern NMTBL *make_local_scope();
|
327
|
189
|
346
|
190 extern struct cheap * increment_cheap(struct cheap *cheap,char **save);
|
|
191 extern void save_cheap(struct cheap *scheap,struct cheap *cheap);
|
|
192 extern struct cheap * reset_cheap(struct cheap *scheap);
|
560
|
193 extern struct cheap * new_cheap();
|
453
|
194 extern void pfdecl(NMTBL *nptr);
|
454
|
195 #if CASE_CODE
|
|
196 extern int docase_eq();
|
|
197 #endif
|
|
198 extern NMTBL *l_top_search(char *name,int sc);
|
346
|
199
|
327
|
200 /* end */
|