annotate GEMBASSY-1.0.3/gsoap/src/soapcpp2_yacc.y @ 1:84a17b3fad1f draft

Uploaded
author ktnyt
date Fri, 26 Jun 2015 05:20:29 -0400
parents 8300eb051bea
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2 soapcpp2_yacc.y
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
4 Yacc/Bison grammar.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
5
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
6 Build notes:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
7
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
8 1. Bison 1.6 is known to crash on Win32 systems if YYINITDEPTH is too
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
9 small Compile with -DYYINITDEPTH=5000
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
10
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
11 2. This grammar has one shift/reduce conflict related to the use of a
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
12 class declaration with a base class (e.g. class Y : public X) and the
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
13 use of a maxOccurs (class Y :10). Internally the conflict is resolved
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
14 in favor of a shift by Bison/Yacc, which leads to the correct parsing
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
15 behavior. Therefore, the warning can be ignored. If this leads to an
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
16 error, then please enable the following directive (around line 121):
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
17
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
18 %expect 1 // Bison: ignore one shift/reduce conflict
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
19
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
20 --------------------------------------------------------------------------------
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
21 gSOAP XML Web services tools
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
22 Copyright (C) 2000-2011, Robert van Engelen, Genivia Inc. All Rights Reserved.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
23 This part of the software is released under ONE of the following licenses:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
24 GPL or Genivia's license for commercial use.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
25 --------------------------------------------------------------------------------
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
26 GPL license.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
27
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
28 This program is free software; you can redistribute it and/or modify it under
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
29 the terms of the GNU General Public License as published by the Free Software
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
30 Foundation; either version 2 of the License, or (at your option) any later
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
31 version.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
32
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
33 This program is distributed in the hope that it will be useful, but WITHOUT ANY
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
34 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
35 PARTICULAR PURPOSE. See the GNU General Public License for more details.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
36
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
37 You should have received a copy of the GNU General Public License along with
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
38 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
39 Place, Suite 330, Boston, MA 02111-1307 USA
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
40
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
41 Author contact information:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
42 engelen@genivia.com / engelen@acm.org
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
43
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
44 This program is released under the GPL with the additional exemption that
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
45 compiling, linking, and/or using OpenSSL is allowed.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
46 --------------------------------------------------------------------------------
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
47 A commercial use license is available from Genivia, Inc., contact@genivia.com
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
48 --------------------------------------------------------------------------------
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
49 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
50
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
51 %{
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
52
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
53 #include "soapcpp2.h"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
54
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
55 #ifdef WIN32
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
56 #ifndef __STDC__
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
57 #define __STDC__
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
58 #endif
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
59 #define YYINCLUDED_STDLIB_H
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
60 #ifdef WIN32_WITHOUT_SOLARIS_FLEX
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
61 extern int soapcpp2lex(void);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
62 #else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
63 extern int yylex(void);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
64 #endif
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
65 #else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
66 extern int yylex(void);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
67 #endif
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
68
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
69 extern int is_XML(Tnode*);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
70
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
71 #define MAXNEST 16 /* max. nesting depth of scopes */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
72
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
73 struct Scope
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
74 { Table *table;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
75 Entry *entry;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
76 Node node;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
77 LONG64 val;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
78 int offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
79 Bool grow; /* true if offset grows with declarations */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
80 Bool mask; /* true if enum is mask */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
81 } stack[MAXNEST], /* stack of tables and offsets */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
82 *sp; /* current scope stack pointer */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
83
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
84 Table *classtable = (Table*)0,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
85 *enumtable = (Table*)0,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
86 *typetable = (Table*)0,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
87 *booltable = (Table*)0,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
88 *templatetable = (Table*)0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
89
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
90 char *namespaceid = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
91 int transient = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
92 int permission = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
93 int custom_header = 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
94 int custom_fault = 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
95 Pragma *pragmas = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
96 Tnode *qname = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
97 Tnode *xml = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
98
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
99 /* function prototypes for support routine section */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
100 static Entry *undefined(Symbol*);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
101 static Tnode *mgtype(Tnode*, Tnode*);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
102 static Node op(const char*, Node, Node), iop(const char*, Node, Node), relop(const char*, Node, Node);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
103 static void mkscope(Table*, int), enterscope(Table*, int), exitscope(void);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
104 static int integer(Tnode*), real(Tnode*), numeric(Tnode*);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
105 static void add_soap(void), add_XML(void), add_qname(void), add_header(Table*), add_fault(Table*), add_response(Entry*, Entry*), add_result(Tnode*);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
106 extern char *c_storage(Storage), *c_type(Tnode*), *c_ident(Tnode*);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
107 extern int is_primitive_or_string(Tnode*), is_stdstr(Tnode*), is_binary(Tnode*), is_external(Tnode*), is_mutable(Tnode*), has_attachment(Tnode*);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
108
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
109 /* Temporaries used in semantic rules */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
110 int i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
111 char *s, *s1, *s2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
112 Symbol *sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
113 Entry *p, *q;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
114 Tnode *t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
115 Node tmp, c;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
116 Pragma **pp;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
117
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
118 %}
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
119
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
120 /* We expect one shift-reduce conflict, see build notes in the header above */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
121 /* %expect 1 */ /* directive is not compatible with Yacc */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
122 /* If Yacc complains then remove the line above to allow Yacc to proceed */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
123
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
124 %union
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
125 { Symbol *sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
126 LONG64 i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
127 double r;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
128 char c;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
129 char *s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
130 Tnode *typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
131 Storage sto;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
132 Node rec;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
133 Entry *e;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
134 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
135
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
136 /* pragmas */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
137 %token <s> PRAGMA
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
138 /* keywords */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
139 %token <sym> AUTO DOUBLE INT STRUCT
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
140 %token <sym> BREAK ELSE LONG SWITCH
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
141 %token <sym> CASE ENUM REGISTER TYPEDEF
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
142 %token <sym> CHAR EXTERN RETURN UNION
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
143 %token <sym> CONST FLOAT SHORT UNSIGNED
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
144 %token <sym> CONTINUE FOR SIGNED VOID
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
145 %token <sym> DEFAULT GOTO SIZEOF VOLATILE
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
146 %token <sym> DO IF STATIC WHILE
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
147 %token <sym> CLASS PRIVATE PROTECTED PUBLIC
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
148 %token <sym> VIRTUAL INLINE OPERATOR LLONG
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
149 %token <sym> BOOL CFALSE CTRUE WCHAR
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
150 %token <sym> TIME USING NAMESPACE ULLONG
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
151 %token <sym> MUSTUNDERSTAND SIZE FRIEND
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
152 %token <sym> TEMPLATE EXPLICIT TYPENAME
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
153 %token <sym> RESTRICT null
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
154 %token <sym> UCHAR USHORT UINT ULONG
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
155 /* */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
156 %token NONE
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
157 /* identifiers (TYPE = typedef identifier) */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
158 %token <sym> ID LAB TYPE
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
159 /* constants */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
160 %token <i> LNG
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
161 %token <r> DBL
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
162 %token <c> CHR
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
163 %token <s> TAG STR
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
164 /* types and related */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
165 %type <typ> type
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
166 %type <sto> store virtual constobj abstract
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
167 %type <e> fname struct class base enum
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
168 %type <sym> id arg name
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
169 %type <s> tag patt
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
170 %type <i> cint
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
171 /* expressions and statements */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
172 %type <rec> expr cexp oexp obex aexp abex rexp lexp pexp init spec tspec ptrs array arrayck texp qexp occurs
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
173 /* terminals */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
174 %left ','
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
175 %right '=' PA NA TA DA MA AA XA OA LA RA /* += -= *= /= %= &= ^= |= <<= >>= */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
176 %right '?'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
177 %right ':'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
178 %left OR /* || */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
179 %left AN /* && */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
180 %left '|'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
181 %left '^'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
182 %left '&'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
183 %left EQ NE /* == != */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
184 %left '<' LE '>' GE /* <= >= */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
185 %left LS RS /* << >> */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
186 %left '+' '-'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
187 %left '*' '/' '%'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
188 %left AR /* -> */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
189 %token PP NN /* ++ -- */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
190
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
191 %%
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
192
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
193 /******************************************************************************\
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
194
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
195 Program syntax
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
196
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
197 \******************************************************************************/
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
198
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
199 prog : s1 exts { if (lflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
200 { custom_header = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
201 custom_fault = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
202 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
203 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
204 { add_header(sp->table);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
205 add_fault(sp->table);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
206 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
207 compile(sp->table);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
208 freetable(classtable);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
209 freetable(enumtable);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
210 freetable(typetable);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
211 freetable(booltable);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
212 freetable(templatetable);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
213 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
214 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
215 s1 : /* empty */ { classtable = mktable((Table*)0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
216 enumtable = mktable((Table*)0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
217 typetable = mktable((Table*)0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
218 booltable = mktable((Table*)0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
219 templatetable = mktable((Table*)0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
220 p = enter(booltable, lookup("false"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
221 p->info.typ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
222 p->info.val.i = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
223 p = enter(booltable, lookup("true"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
224 p->info.typ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
225 p->info.val.i = 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
226 mkscope(mktable(mktable((Table*)0)), 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
227 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
228 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
229 exts : NAMESPACE ID '{' exts1 '}'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
230 { namespaceid = $2->name; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
231 | exts1 { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
232 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
233 exts1 : /* empty */ { add_soap();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
234 add_qname();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
235 add_XML();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
236 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
237 | exts1 ext { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
238 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
239 ext : dclrs ';' { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
240 | pragma { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
241 | error ';' { synerror("input before ; skipped");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
242 while (sp > stack)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
243 { freetable(sp->table);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
244 exitscope();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
245 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
246 yyerrok;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
247 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
248 | t1 { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
249 | t2 { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
250 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
251 pragma : PRAGMA { if ($1[1] >= 'a' && $1[1] <= 'z')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
252 { for (pp = &pragmas; *pp; pp = &(*pp)->next)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
253 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
254 *pp = (Pragma*)emalloc(sizeof(Pragma));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
255 (*pp)->pragma = (char*)emalloc(strlen($1)+1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
256 strcpy((*pp)->pragma, $1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
257 (*pp)->next = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
258 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
259 else if ((i = atoi($1+2)) > 0)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
260 yylineno = i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
261 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
262 { sprintf(errbuf, "directive '%s' ignored (use #import to import files)", $1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
263 semwarn(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
264 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
265 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
266 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
267
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
268 /******************************************************************************\
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
269
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
270 Declarations
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
271
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
272 \******************************************************************************/
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
273
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
274 decls : /* empty */ { transient &= ~6;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
275 permission = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
276 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
277 | dclrs ';' decls
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
278 { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
279 | PRIVATE ':' t3 decls
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
280 { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
281 | PROTECTED ':' t4 decls
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
282 { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
283 | PUBLIC ':' t5 decls
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
284 { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
285 | t1 decls t2 decls
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
286 { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
287 | error ';' { synerror("declaration expected"); yyerrok; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
288 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
289 t1 : '[' { transient |= 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
290 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
291 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
292 t2 : ']' { transient &= ~1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
293 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
294 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
295 t3 : { permission = Sprivate;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
296 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
297 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
298 t4 : { permission = Sprotected;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
299 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
300 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
301 t5 : { permission = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
302 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
303 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
304 dclrs : spec { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
305 | spec dclr { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
306 | spec fdclr func
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
307 { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
308 | constr func { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
309 | destr func { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
310 | dclrs ',' dclr{ }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
311 | dclrs ',' fdclr func
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
312 { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
313 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
314 dclr : ptrs ID arrayck tag occurs init
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
315 { if (($3.sto & Stypedef) && sp->table->level == GLOBAL)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
316 { if (($3.typ->type != Tstruct && $3.typ->type != Tunion && $3.typ->type != Tenum) || strcmp($2->name, $3.typ->id->name))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
317 { p = enter(typetable, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
318 p->info.typ = mksymtype($3.typ, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
319 if ($3.sto & Sextern)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
320 p->info.typ->transient = -1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
321 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
322 p->info.typ->transient = $3.typ->transient;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
323 p->info.sto = $3.sto;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
324 p->info.typ->pattern = $5.pattern;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
325 p->info.typ->minLength = $5.minLength;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
326 p->info.typ->maxLength = $5.maxLength;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
327 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
328 $2->token = TYPE;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
329 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
330 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
331 { p = enter(sp->table, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
332 p->tag = $4;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
333 p->info.typ = $3.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
334 p->info.sto = (Storage)((int)$3.sto | permission);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
335 if ($6.hasval)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
336 { p->info.hasval = True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
337 switch ($3.typ->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
338 { case Tchar:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
339 case Tuchar:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
340 case Tshort:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
341 case Tushort:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
342 case Tint:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
343 case Tuint:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
344 case Tlong:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
345 case Tulong:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
346 case Tllong:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
347 case Tullong:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
348 case Tenum:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
349 case Ttime:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
350 if ($6.typ->type == Tint || $6.typ->type == Tchar || $6.typ->type == Tenum)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
351 sp->val = p->info.val.i = $6.val.i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
352 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
353 { semerror("type error in initialization constant");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
354 p->info.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
355 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
356 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
357 case Tfloat:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
358 case Tdouble:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
359 case Tldouble:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
360 if ($6.typ->type == Tfloat || $6.typ->type == Tdouble || $6.typ->type == Tldouble)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
361 p->info.val.r = $6.val.r;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
362 else if ($6.typ->type == Tint)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
363 p->info.val.r = (double)$6.val.i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
364 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
365 { semerror("type error in initialization constant");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
366 p->info.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
367 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
368 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
369 default:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
370 if ($3.typ->type == Tpointer
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
371 && (((Tnode*)$3.typ->ref)->type == Tchar || ((Tnode*)$3.typ->ref)->type == Twchar)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
372 && $6.typ->type == Tpointer
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
373 && ((Tnode*)$6.typ->ref)->type == Tchar)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
374 p->info.val.s = $6.val.s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
375 else if (bflag
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
376 && $3.typ->type == Tarray
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
377 && ((Tnode*)$3.typ->ref)->type == Tchar
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
378 && $6.typ->type == Tpointer
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
379 && ((Tnode*)$6.typ->ref)->type == Tchar)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
380 { if ($3.typ->width / ((Tnode*)$3.typ->ref)->width - 1 < strlen($6.val.s))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
381 { semerror("char[] initialization constant too long");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
382 p->info.val.s = "";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
383 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
384
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
385 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
386 p->info.val.s = $6.val.s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
387 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
388 else if ($3.typ->type == Tpointer
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
389 && (((Tnode*)$3.typ->ref)->id == lookup("std::string") || ((Tnode*)$3.typ->ref)->id == lookup("std::wstring")))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
390 p->info.val.s = $6.val.s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
391 else if ($3.typ->id == lookup("std::string") || $3.typ->id == lookup("std::wstring"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
392 p->info.val.s = $6.val.s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
393 else if ($3.typ->type == Tpointer
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
394 && $6.typ->type == Tint
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
395 && $6.val.i == 0)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
396 p->info.val.i = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
397 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
398 { semerror("type error in initialization constant");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
399 p->info.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
400 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
401 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
402 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
403 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
404 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
405 p->info.val.i = sp->val;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
406 if ($5.minOccurs < 0)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
407 { if ($6.hasval || ($3.sto & Sattribute) || $3.typ->type == Tpointer || $3.typ->type == Ttemplate || !strncmp($2->name, "__size", 6))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
408 p->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
409 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
410 p->info.minOccurs = 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
411 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
412 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
413 p->info.minOccurs = $5.minOccurs;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
414 p->info.maxOccurs = $5.maxOccurs;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
415 if (sp->mask)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
416 sp->val <<= 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
417 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
418 sp->val++;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
419 p->info.offset = sp->offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
420 if ($3.sto & Sextern)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
421 p->level = GLOBAL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
422 else if ($3.sto & Stypedef)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
423 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
424 else if (sp->grow)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
425 sp->offset += p->info.typ->width;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
426 else if (p->info.typ->width > sp->offset)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
427 sp->offset = p->info.typ->width;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
428 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
429 sp->entry = p;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
430 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
431 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
432 fdclr : ptrs name { if ($1.sto & Stypedef)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
433 { sprintf(errbuf, "invalid typedef qualifier for '%s'", $2->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
434 semwarn(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
435 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
436 p = enter(sp->table, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
437 p->info.typ = $1.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
438 p->info.sto = $1.sto;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
439 p->info.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
440 p->info.offset = sp->offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
441 if (sp->grow)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
442 sp->offset += p->info.typ->width;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
443 else if (p->info.typ->width > sp->offset)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
444 sp->offset = p->info.typ->width;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
445 sp->entry = p;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
446 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
447 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
448 id : ID { $$ = $1; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
449 | TYPE { $$ = $1; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
450 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
451 name : ID { $$ = $1; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
452 | OPERATOR '!' { $$ = lookup("operator!"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
453 | OPERATOR '~' { $$ = lookup("operator~"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
454 | OPERATOR '=' { $$ = lookup("operator="); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
455 | OPERATOR PA { $$ = lookup("operator+="); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
456 | OPERATOR NA { $$ = lookup("operator-="); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
457 | OPERATOR TA { $$ = lookup("operator*="); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
458 | OPERATOR DA { $$ = lookup("operator/="); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
459 | OPERATOR MA { $$ = lookup("operator%="); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
460 | OPERATOR AA { $$ = lookup("operator&="); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
461 | OPERATOR XA { $$ = lookup("operator^="); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
462 | OPERATOR OA { $$ = lookup("operator|="); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
463 | OPERATOR LA { $$ = lookup("operator<<="); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
464 | OPERATOR RA { $$ = lookup("operator>>="); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
465 | OPERATOR OR { $$ = lookup("operator||"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
466 | OPERATOR AN { $$ = lookup("operator&&"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
467 | OPERATOR '|' { $$ = lookup("operator|"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
468 | OPERATOR '^' { $$ = lookup("operator^"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
469 | OPERATOR '&' { $$ = lookup("operator&"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
470 | OPERATOR EQ { $$ = lookup("operator=="); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
471 | OPERATOR NE { $$ = lookup("operator!="); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
472 | OPERATOR '<' { $$ = lookup("operator<"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
473 | OPERATOR LE { $$ = lookup("operator<="); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
474 | OPERATOR '>' { $$ = lookup("operator>"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
475 | OPERATOR GE { $$ = lookup("operator>="); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
476 | OPERATOR LS { $$ = lookup("operator<<"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
477 | OPERATOR RS { $$ = lookup("operator>>"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
478 | OPERATOR '+' { $$ = lookup("operator+"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
479 | OPERATOR '-' { $$ = lookup("operator-"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
480 | OPERATOR '*' { $$ = lookup("operator*"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
481 | OPERATOR '/' { $$ = lookup("operator/"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
482 | OPERATOR '%' { $$ = lookup("operator%"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
483 | OPERATOR PP { $$ = lookup("operator++"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
484 | OPERATOR NN { $$ = lookup("operator--"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
485 | OPERATOR AR { $$ = lookup("operator->"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
486 | OPERATOR'['']'{ $$ = lookup("operator[]"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
487 | OPERATOR'('')'{ $$ = lookup("operator()"); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
488 | OPERATOR texp { s1 = c_storage($2.sto);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
489 s2 = c_type($2.typ);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
490 s = (char*)emalloc(strlen(s1) + strlen(s2) + 10);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
491 strcpy(s, "operator ");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
492 strcat(s, s1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
493 strcat(s, s2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
494 $$ = lookup(s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
495 if (!$$)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
496 $$ = install(s, ID);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
497 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
498 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
499 constr : TYPE { if (!(p = entry(classtable, $1)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
500 semerror("invalid constructor");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
501 sp->entry = enter(sp->table, $1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
502 sp->entry->info.typ = mknone();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
503 sp->entry->info.sto = Snone;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
504 sp->entry->info.offset = sp->offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
505 sp->node.typ = mkvoid();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
506 sp->node.sto = Snone;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
507 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
508 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
509 destr : virtual '~' TYPE
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
510 { if (!(p = entry(classtable, $3)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
511 semerror("invalid destructor");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
512 s = (char*)emalloc(strlen($3->name) + 2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
513 strcpy(s, "~");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
514 strcat(s, $3->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
515 sym = lookup(s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
516 if (!sym)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
517 sym = install(s, ID);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
518 sp->entry = enter(sp->table, sym);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
519 sp->entry->info.typ = mknone();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
520 sp->entry->info.sto = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
521 sp->entry->info.offset = sp->offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
522 sp->node.typ = mkvoid();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
523 sp->node.sto = Snone;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
524 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
525 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
526 func : fname '(' s6 fargso ')' constobj abstract
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
527 { if ($1->level == GLOBAL)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
528 { if (!($1->info.sto & Sextern) && sp->entry && sp->entry->info.typ->type == Tpointer && ((Tnode*)sp->entry->info.typ->ref)->type == Tchar)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
529 { sprintf(errbuf, "last output parameter of remote method function prototype '%s' is a pointer to a char which will only return one byte: use char** instead to return a string", $1->sym->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
530 semwarn(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
531 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
532 if ($1->info.sto & Sextern)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
533 $1->info.typ = mkmethod($1->info.typ, sp->table);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
534 else if (sp->entry && (sp->entry->info.typ->type == Tpointer || sp->entry->info.typ->type == Treference || sp->entry->info.typ->type == Tarray || is_transient(sp->entry->info.typ)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
535 { if ($1->info.typ->type == Tint)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
536 { sp->entry->info.sto = (Storage)((int)sp->entry->info.sto | (int)Sreturn);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
537 $1->info.typ = mkfun(sp->entry);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
538 $1->info.typ->id = $1->sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
539 if (!is_transient(sp->entry->info.typ))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
540 { if (!is_response(sp->entry->info.typ))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
541 { if (!is_XML(sp->entry->info.typ))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
542 add_response($1, sp->entry);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
543 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
544 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
545 add_result(sp->entry->info.typ);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
546 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
547 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
548 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
549 { sprintf(errbuf, "return type of remote method function prototype '%s' must be integer", $1->sym->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
550 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
551 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
552 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
553 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
554 { sprintf(errbuf, "last output parameter of remote method function prototype '%s' is a return parameter and must be a pointer or reference, or use %s(..., void) for one-way sends", $1->sym->name, $1->sym->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
555 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
556 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
557 if (!($1->info.sto & Sextern))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
558 { unlinklast(sp->table);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
559 if ((p = entry(classtable, $1->sym)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
560 { if (p->info.typ->ref)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
561 { sprintf(errbuf, "remote method name clash: struct/class '%s' already declared at line %d", $1->sym->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
562 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
563 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
564 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
565 { p->info.typ->ref = sp->table;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
566 p->info.typ->width = sp->offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
567 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
568 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
569 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
570 { p = enter(classtable, $1->sym);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
571 p->info.typ = mkstruct(sp->table, sp->offset);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
572 p->info.typ->id = $1->sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
573 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
574 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
575 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
576 else if ($1->level == INTERNAL)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
577 { $1->info.typ = mkmethod($1->info.typ, sp->table);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
578 $1->info.sto = (Storage)((int)$1->info.sto | (int)$6 | (int)$7);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
579 transient &= ~1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
580 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
581 exitscope();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
582 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
583 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
584 fname : { $$ = sp->entry; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
585 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
586 fargso : /* empty */ { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
587 | fargs { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
588 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
589 fargs : farg { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
590 | farg ',' fargs{ }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
591 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
592 farg : tspec ptrs arg arrayck occurs init
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
593 { if ($4.sto & Stypedef)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
594 semwarn("typedef in function argument");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
595 p = enter(sp->table, $3);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
596 p->info.typ = $4.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
597 p->info.sto = $4.sto;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
598 if ($5.minOccurs < 0)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
599 { if ($6.hasval || ($4.sto & Sattribute) || $4.typ->type == Tpointer)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
600 p->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
601 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
602 p->info.minOccurs = 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
603 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
604 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
605 p->info.minOccurs = $5.minOccurs;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
606 p->info.maxOccurs = $5.maxOccurs;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
607 if ($6.hasval)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
608 { p->info.hasval = True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
609 switch ($4.typ->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
610 { case Tchar:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
611 case Tuchar:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
612 case Tshort:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
613 case Tushort:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
614 case Tint:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
615 case Tuint:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
616 case Tlong:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
617 case Tulong:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
618 case Tenum:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
619 case Ttime:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
620 if ($6.typ->type == Tint || $6.typ->type == Tchar || $6.typ->type == Tenum)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
621 sp->val = p->info.val.i = $6.val.i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
622 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
623 { semerror("type error in initialization constant");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
624 p->info.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
625 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
626 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
627 case Tfloat:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
628 case Tdouble:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
629 case Tldouble:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
630 if ($6.typ->type == Tfloat || $6.typ->type == Tdouble || $6.typ->type == Tldouble)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
631 p->info.val.r = $6.val.r;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
632 else if ($6.typ->type == Tint)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
633 p->info.val.r = (double)$6.val.i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
634 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
635 { semerror("type error in initialization constant");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
636 p->info.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
637 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
638 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
639 default:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
640 if ($4.typ->type == Tpointer
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
641 && (((Tnode*)$4.typ->ref)->type == Tchar || ((Tnode*)$4.typ->ref)->type == Twchar)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
642 && $6.typ->type == Tpointer
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
643 && ((Tnode*)$6.typ->ref)->type == Tchar)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
644 p->info.val.s = $6.val.s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
645 else if ($4.typ->type == Tpointer
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
646 && (((Tnode*)$4.typ->ref)->id == lookup("std::string") || ((Tnode*)$4.typ->ref)->id == lookup("std::wstring")))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
647 p->info.val.s = $6.val.s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
648 else if ($4.typ->id == lookup("std::string") || $4.typ->id == lookup("std::wstring"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
649 p->info.val.s = $6.val.s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
650 else if ($4.typ->type == Tpointer
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
651 && $6.typ->type == Tint
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
652 && $6.val.i == 0)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
653 p->info.val.i = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
654 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
655 { semerror("type error in initialization constant");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
656 p->info.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
657 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
658 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
659 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
660 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
661 p->info.offset = sp->offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
662 if ($4.sto & Sextern)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
663 p->level = GLOBAL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
664 else if (sp->grow)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
665 sp->offset += p->info.typ->width;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
666 else if (p->info.typ->width > sp->offset)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
667 sp->offset = p->info.typ->width;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
668 sp->entry = p;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
669 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
670 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
671 arg : /* empty */ { if (sp->table->level != PARAM)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
672 $$ = gensymidx("param", (int)++sp->val);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
673 else if (eflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
674 $$ = gensymidx("_param", (int)++sp->val);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
675 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
676 $$ = gensym("_param");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
677 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
678 | ID { if (vflag == 2 && *$1->name == '_' && sp->table->level == GLOBAL)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
679 { sprintf(errbuf, "SOAP 1.2 does not support anonymous parameters '%s'", $1->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
680 semwarn(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
681 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
682 $$ = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
683 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
684 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
685
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
686 /******************************************************************************\
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
687
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
688 Type specification
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
689
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
690 \******************************************************************************/
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
691
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
692 /* texp : type expression (subset of C) */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
693 texp : tspec ptrs array
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
694 { $$ = $3; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
695 | tspec ptrs ID array
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
696 { $$ = $4; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
697 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
698 spec : /*empty */ { $$.typ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
699 $$.sto = Snone;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
700 sp->node = $$;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
701 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
702 | store spec { if (($1 & Stypedef) && is_external($2.typ) && $2.typ->type != Tstruct && $2.typ->type != Tclass)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
703 $$.typ = mktype($2.typ->type, $2.typ->ref, $2.typ->width);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
704 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
705 $$.typ = $2.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
706 $$.sto = (Storage)((int)$1 | ((int)($2.sto)));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
707 if (($$.sto & Sattribute) && !is_primitive_or_string($2.typ) && !is_stdstr($2.typ) && !is_binary($2.typ) && !is_external($2.typ))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
708 { semwarn("invalid attribute type");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
709 $$.sto = (Storage)((int)$$.sto & ~Sattribute);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
710 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
711 sp->node = $$;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
712 if ($1 & Sextern)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
713 transient = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
714 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
715 | type spec { if ($1->type == Tint)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
716 switch ($2.typ->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
717 { case Tchar: $$.typ = $2.typ; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
718 case Tshort: $$.typ = $2.typ; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
719 case Tint: $$.typ = $1; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
720 case Tlong: $$.typ = $2.typ; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
721 case Tllong: $$.typ = $2.typ; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
722 default: semwarn("illegal use of 'signed'");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
723 $$.typ = $2.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
724 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
725 else if ($1->type == Tuint)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
726 switch ($2.typ->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
727 { case Tchar: $$.typ = mkuchar(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
728 case Tshort: $$.typ = mkushort(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
729 case Tint: $$.typ = $1; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
730 case Tlong: $$.typ = mkulong(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
731 case Tllong: $$.typ = mkullong(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
732 default: semwarn("illegal use of 'unsigned'");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
733 $$.typ = $2.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
734 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
735 else if ($1->type == Tlong)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
736 switch ($2.typ->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
737 { case Tint: $$.typ = $1; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
738 case Tlong: $$.typ = mkllong(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
739 case Tuint: $$.typ = mkulong(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
740 case Tulong: $$.typ = mkullong(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
741 case Tdouble: $$.typ = mkldouble(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
742 default: semwarn("illegal use of 'long'");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
743 $$.typ = $2.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
744 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
745 else if ($1->type == Tulong)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
746 switch ($2.typ->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
747 { case Tint: $$.typ = $1; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
748 case Tlong: $$.typ = mkullong(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
749 case Tuint: $$.typ = $1; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
750 case Tulong: $$.typ = mkullong(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
751 default: semwarn("illegal use of 'long'");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
752 $$.typ = $2.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
753 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
754 else if ($2.typ->type == Tint)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
755 $$.typ = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
756 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
757 semwarn("invalid type (missing ';' or type name used as non-type identifier?)");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
758 $$.sto = $2.sto;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
759 sp->node = $$;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
760 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
761 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
762 tspec : store { $$.typ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
763 $$.sto = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
764 sp->node = $$;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
765 if ($1 & Sextern)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
766 transient = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
767 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
768 | type { $$.typ = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
769 $$.sto = Snone;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
770 sp->node = $$;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
771 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
772 | store tspec { $$.typ = $2.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
773 $$.sto = (Storage)((int)$1 | (int)$2.sto);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
774 if (($$.sto & Sattribute) && !is_primitive_or_string($2.typ) && !is_stdstr($2.typ) && !is_binary($2.typ) && !is_external($2.typ))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
775 { semwarn("invalid attribute type");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
776 $$.sto = (Storage)((int)$$.sto & ~Sattribute);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
777 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
778 sp->node = $$;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
779 if ($1 & Sextern)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
780 transient = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
781 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
782 | type tspec { if ($1->type == Tint)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
783 switch ($2.typ->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
784 { case Tchar: $$.typ = $2.typ; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
785 case Tshort: $$.typ = $2.typ; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
786 case Tint: $$.typ = $1; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
787 case Tlong: $$.typ = $2.typ; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
788 case Tllong: $$.typ = $2.typ; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
789 default: semwarn("illegal use of 'signed'");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
790 $$.typ = $2.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
791 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
792 else if ($1->type == Tuint)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
793 switch ($2.typ->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
794 { case Tchar: $$.typ = mkuchar(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
795 case Tshort: $$.typ = mkushort(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
796 case Tint: $$.typ = $1; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
797 case Tlong: $$.typ = mkulong(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
798 case Tllong: $$.typ = mkullong(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
799 default: semwarn("illegal use of 'unsigned'");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
800 $$.typ = $2.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
801 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
802 else if ($1->type == Tlong)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
803 switch ($2.typ->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
804 { case Tint: $$.typ = $1; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
805 case Tlong: $$.typ = mkllong(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
806 case Tuint: $$.typ = mkulong(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
807 case Tulong: $$.typ = mkullong(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
808 case Tdouble: $$.typ = mkldouble(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
809 default: semwarn("illegal use of 'long'");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
810 $$.typ = $2.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
811 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
812 else if ($1->type == Tulong)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
813 switch ($2.typ->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
814 { case Tint: $$.typ = $1; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
815 case Tlong: $$.typ = mkullong(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
816 case Tuint: $$.typ = $1; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
817 case Tulong: $$.typ = mkullong(); break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
818 default: semwarn("illegal use of 'long'");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
819 $$.typ = $2.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
820 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
821 else if ($2.typ->type == Tint)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
822 $$.typ = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
823 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
824 semwarn("invalid type");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
825 $$.sto = $2.sto;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
826 sp->node = $$;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
827 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
828 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
829 type : VOID { $$ = mkvoid(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
830 | BOOL { $$ = mkbool(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
831 | CHAR { $$ = mkchar(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
832 | WCHAR { $$ = mkwchart(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
833 | SHORT { $$ = mkshort(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
834 | INT { $$ = mkint(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
835 | LONG { $$ = mklong(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
836 | LLONG { $$ = mkllong(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
837 | ULLONG { $$ = mkullong(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
838 | SIZE { $$ = mkulong(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
839 | FLOAT { $$ = mkfloat(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
840 | DOUBLE { $$ = mkdouble(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
841 | SIGNED { $$ = mkint(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
842 | UNSIGNED { $$ = mkuint(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
843 | UCHAR { $$ = mkuchar(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
844 | USHORT { $$ = mkushort(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
845 | UINT { $$ = mkuint(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
846 | ULONG { $$ = mkulong(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
847 | TIME { $$ = mktimet(); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
848 | TEMPLATE '<' tname id '>' CLASS id
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
849 { if (!(p = entry(templatetable, $7)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
850 { p = enter(templatetable, $7);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
851 p->info.typ = mktemplate(NULL, $7);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
852 $7->token = TYPE;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
853 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
854 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
855 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
856 | CLASS '{' s2 decls '}'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
857 { sym = gensym("_Struct");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
858 sprintf(errbuf, "anonymous class will be named '%s'", sym->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
859 semwarn(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
860 if ((p = entry(classtable, sym)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
861 { if (p->info.typ->ref || p->info.typ->type != Tclass)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
862 { sprintf(errbuf, "class '%s' already declared at line %d", sym->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
863 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
864 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
865 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
866 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
867 { p = enter(classtable, sym);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
868 p->info.typ = mkclass((Table*)0, 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
869 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
870 sym->token = TYPE;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
871 sp->table->sym = sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
872 p->info.typ->ref = sp->table;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
873 p->info.typ->width = sp->offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
874 p->info.typ->id = sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
875 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
876 exitscope();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
877 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
878 | class '{' s2 decls '}'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
879 { p = reenter(classtable, $1->sym);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
880 sp->table->sym = p->sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
881 p->info.typ->ref = sp->table;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
882 p->info.typ->width = sp->offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
883 p->info.typ->id = p->sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
884 if (p->info.typ->base)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
885 sp->table->prev = (Table*)entry(classtable, p->info.typ->base)->info.typ->ref;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
886 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
887 exitscope();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
888 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
889 | class ':' base '{' s2 decls '}'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
890 { p = reenter(classtable, $1->sym);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
891 sp->table->sym = p->sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
892 if (!$3)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
893 semerror("invalid base class");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
894 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
895 { sp->table->prev = (Table*)$3->info.typ->ref;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
896 if (!sp->table->prev && !$3->info.typ->transient)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
897 { sprintf(errbuf, "class '%s' has incomplete type", $3->sym->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
898 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
899 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
900 p->info.typ->base = $3->info.typ->id;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
901 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
902 p->info.typ->ref = sp->table;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
903 p->info.typ->width = sp->offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
904 p->info.typ->id = p->sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
905 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
906 exitscope();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
907 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
908 | class { $1->info.typ->id = $1->sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
909 $$ = $1->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
910 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
911 | class ':' base
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
912 { if (!$3)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
913 semerror("invalid base class");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
914 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
915 { if (!$3->info.typ->ref && !$3->info.typ->transient)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
916 { sprintf(errbuf, "class '%s' has incomplete type", $3->sym->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
917 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
918 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
919 $1->info.typ->base = $3->info.typ->id;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
920 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
921 $1->info.typ->id = $1->sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
922 $$ = $1->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
923 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
924 | STRUCT '{' s2 decls '}'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
925 { sym = gensym("_Struct");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
926 sprintf(errbuf, "anonymous struct will be named '%s'", sym->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
927 semwarn(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
928 if ((p = entry(classtable, sym)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
929 { if (p->info.typ->ref || p->info.typ->type != Tstruct)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
930 { sprintf(errbuf, "struct '%s' already declared at line %d", sym->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
931 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
932 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
933 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
934 { p->info.typ->ref = sp->table;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
935 p->info.typ->width = sp->offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
936 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
937 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
938 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
939 { p = enter(classtable, sym);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
940 p->info.typ = mkstruct(sp->table, sp->offset);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
941 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
942 p->info.typ->id = sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
943 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
944 exitscope();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
945 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
946 | struct '{' s2 decls '}'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
947 { if ((p = entry(classtable, $1->sym)) && p->info.typ->ref)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
948 { if (is_mutable(p->info.typ))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
949 { if (merge((Table*)p->info.typ->ref, sp->table))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
950 { sprintf(errbuf, "member name clash in struct '%s' declared at line %d", $1->sym->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
951 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
952 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
953 p->info.typ->width += sp->offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
954 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
955 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
956 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
957 { p = reenter(classtable, $1->sym);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
958 p->info.typ->ref = sp->table;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
959 p->info.typ->width = sp->offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
960 p->info.typ->id = p->sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
961 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
962 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
963 exitscope();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
964 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
965 | STRUCT ID { if ((p = entry(classtable, $2)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
966 { if (p->info.typ->type == Tstruct)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
967 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
968 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
969 { sprintf(errbuf, "'struct %s' redeclaration (line %d)", $2->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
970 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
971 $$ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
972 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
973 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
974 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
975 { p = enter(classtable, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
976 $$ = p->info.typ = mkstruct((Table*)0, 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
977 p->info.typ->id = $2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
978 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
979 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
980 | STRUCT TYPE { if ((p = entry(classtable, $2)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
981 { if (p->info.typ->type == Tstruct)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
982 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
983 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
984 { sprintf(errbuf, "'struct %s' redeclaration (line %d)", $2->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
985 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
986 $$ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
987 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
988 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
989 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
990 { p = enter(classtable, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
991 $$ = p->info.typ = mkstruct((Table*)0, 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
992 p->info.typ->id = $2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
993 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
994 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
995 | UNION '{' s3 decls '}'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
996 { sym = gensym("_Union");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
997 sprintf(errbuf, "anonymous union will be named '%s'", sym->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
998 semwarn(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
999 $$ = mkunion(sp->table, sp->offset);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1000 if ((p = entry(classtable, sym)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1001 { if (p->info.typ->ref)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1002 { sprintf(errbuf, "union or struct '%s' already declared at line %d", sym->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1003 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1004 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1005 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1006 { p->info.typ->ref = sp->table;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1007 p->info.typ->width = sp->offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1008 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1009 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1010 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1011 { p = enter(classtable, sym);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1012 p->info.typ = mkunion(sp->table, sp->offset);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1013 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1014 p->info.typ->id = sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1015 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1016 exitscope();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1017 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1018 | UNION id '{' s3 decls '}'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1019 { if ((p = entry(classtable, $2)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1020 { if (p->info.typ->ref || p->info.typ->type != Tunion)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1021 { sprintf(errbuf, "union '%s' already declared at line %d", $2->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1022 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1023 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1024 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1025 { p = reenter(classtable, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1026 p->info.typ->ref = sp->table;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1027 p->info.typ->width = sp->offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1028 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1029 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1030 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1031 { p = enter(classtable, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1032 p->info.typ = mkunion(sp->table, sp->offset);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1033 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1034 p->info.typ->id = $2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1035 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1036 exitscope();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1037 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1038 | UNION ID { if ((p = entry(classtable, $2)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1039 { if (p->info.typ->type == Tunion)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1040 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1041 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1042 { sprintf(errbuf, "'union %s' redeclaration (line %d)", $2->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1043 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1044 $$ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1045 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1046 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1047 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1048 { p = enter(classtable, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1049 $$ = p->info.typ = mkunion((Table*) 0, 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1050 p->info.typ->id = $2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1051 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1052 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1053 | UNION TYPE { if ((p = entry(classtable, $2)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1054 { if (p->info.typ->type == Tunion)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1055 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1056 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1057 { sprintf(errbuf, "'union %s' redeclaration (line %d)", $2->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1058 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1059 $$ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1060 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1061 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1062 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1063 { p = enter(classtable, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1064 $$ = p->info.typ = mkunion((Table*) 0, 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1065 p->info.typ->id = $2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1066 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1067 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1068 | ENUM '{' s2 dclrs s5 '}'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1069 { sym = gensym("_Enum");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1070 sprintf(errbuf, "anonymous enum will be named '%s'", sym->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1071 semwarn(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1072 if ((p = entry(enumtable, sym)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1073 { if (p->info.typ->ref)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1074 { sprintf(errbuf, "enum '%s' already declared at line %d", sym->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1075 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1076 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1077 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1078 { p->info.typ->ref = sp->table;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1079 p->info.typ->width = 4; /* 4 = enum */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1080 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1081 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1082 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1083 { p = enter(enumtable, sym);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1084 p->info.typ = mkenum(sp->table);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1085 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1086 p->info.typ->id = sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1087 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1088 exitscope();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1089 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1090 | enum '{' s2 dclrs s5 '}'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1091 { if ((p = entry(enumtable, $1->sym)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1092 { if (p->info.typ->ref)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1093 { sprintf(errbuf, "enum '%s' already declared at line %d", $1->sym->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1094 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1095 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1096 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1097 { p->info.typ->ref = sp->table;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1098 p->info.typ->width = 4; /* 4 = enum */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1099 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1100 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1101 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1102 { p = enter(enumtable, $1->sym);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1103 p->info.typ = mkenum(sp->table);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1104 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1105 p->info.typ->id = $1->sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1106 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1107 exitscope();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1108 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1109 | ENUM '*' id '{' s4 dclrs s5 '}'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1110 { if ((p = entry(enumtable, $3)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1111 { if (p->info.typ->ref)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1112 { sprintf(errbuf, "enum '%s' already declared at line %d", $3->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1113 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1114 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1115 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1116 { p->info.typ->ref = sp->table;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1117 p->info.typ->width = 8; /* 8 = mask */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1118 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1119 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1120 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1121 { p = enter(enumtable, $3);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1122 p->info.typ = mkmask(sp->table);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1123 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1124 p->info.typ->id = $3;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1125 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1126 exitscope();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1127 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1128 | ENUM ID { if ((p = entry(enumtable, $2)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1129 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1130 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1131 { p = enter(enumtable, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1132 $$ = p->info.typ = mkenum((Table*)0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1133 p->info.typ->id = $2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1134 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1135 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1136 | ENUM TYPE { if ((p = entry(enumtable, $2)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1137 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1138 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1139 { p = enter(enumtable, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1140 $$ = p->info.typ = mkenum((Table*)0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1141 p->info.typ->id = $2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1142 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1143 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1144 | TYPE { if ((p = entry(typetable, $1)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1145 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1146 else if ((p = entry(classtable, $1)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1147 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1148 else if ((p = entry(enumtable, $1)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1149 $$ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1150 else if ($1 == lookup("std::string") || $1 == lookup("std::wstring"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1151 { p = enter(classtable, $1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1152 $$ = p->info.typ = mkclass((Table*)0, 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1153 p->info.typ->id = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1154 if (cflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1155 p->info.typ->transient = 1; /* make std::string transient in C */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1156 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1157 p->info.typ->transient = -2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1158 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1159 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1160 { sprintf(errbuf, "unknown type '%s'", $1->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1161 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1162 $$ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1163 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1164 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1165 | TYPE '<' texp '>'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1166 { if ((p = entry(templatetable, $1)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1167 { $$ = mktemplate($3.typ, $1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1168 if (has_attachment($3.typ))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1169 { sprintf(errbuf, "template type '%s<%s>' of attachment objects may lead to deserialization failures, use '%s<*%s>' instead", $1->name, $3.typ->id ? $3.typ->id->name : "", $1->name, $3.typ->id ? $3.typ->id->name : "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1170 semwarn(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1171 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1172 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1173 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1174 { sprintf(errbuf, "invalid template '%s'", $1->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1175 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1176 $$ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1177 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1178 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1179 | CLASS error '}'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1180 { synerror("malformed class definition (use spacing around ':' to separate derived : base)");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1181 yyerrok;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1182 $$ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1183 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1184 | STRUCT error '}'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1185 { synerror("malformed struct definition");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1186 yyerrok;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1187 $$ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1188 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1189 | UNION error '}'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1190 { synerror("malformed union definition");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1191 yyerrok;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1192 $$ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1193 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1194 | ENUM error '}'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1195 { synerror("malformed enum definition");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1196 yyerrok;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1197 $$ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1198 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1199 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1200 struct : STRUCT id { if ((p = entry(classtable, $2)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1201 { if (p->info.typ->ref)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1202 { if (!is_mutable(p->info.typ))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1203 { sprintf(errbuf, "struct '%s' already declared at line %d", $2->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1204 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1205 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1206 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1207 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1208 p = reenter(classtable, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1209 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1210 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1211 { p = enter(classtable, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1212 p->info.typ = mkstruct((Table*)0, 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1213 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1214 $$ = p;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1215 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1216 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1217 class : CLASS id { if ((p = entry(classtable, $2)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1218 { if (p->info.typ->ref)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1219 { if (!is_mutable(p->info.typ))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1220 { sprintf(errbuf, "class '%s' already declared at line %d (redundant 'class' specifier here?)", $2->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1221 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1222 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1223 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1224 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1225 p = reenter(classtable, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1226 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1227 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1228 { p = enter(classtable, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1229 p->info.typ = mkclass((Table*)0, 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1230 p->info.typ->id = p->sym;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1231 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1232 $2->token = TYPE;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1233 $$ = p;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1234 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1235 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1236 enum : ENUM id { if ((p = entry(enumtable, $2)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1237 { if (p->info.typ->ref)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1238 { sprintf(errbuf, "enum '%s' already declared at line %d", $2->name, p->lineno);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1239 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1240 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1241 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1242 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1243 p = reenter(classtable, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1244 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1245 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1246 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1247 { p = enter(enumtable, $2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1248 p->info.typ = mkenum(0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1249 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1250 $$ = p;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1251 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1252 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1253 tname : CLASS { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1254 | TYPENAME { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1255 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1256 base : PROTECTED base{ $$ = $2; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1257 | PRIVATE base { $$ = $2; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1258 | PUBLIC base { $$ = $2; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1259 | TYPE { $$ = entry(classtable, $1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1260 if (!$$)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1261 { p = entry(typetable, $1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1262 if (p && (p->info.typ->type == Tclass || p->info.typ->type == Tstruct))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1263 $$ = p;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1264 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1265 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1266 | STRUCT ID { $$ = entry(classtable, $2); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1267 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1268 s2 : /* empty */ { if (transient == -2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1269 transient = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1270 permission = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1271 enterscope(mktable(NULL), 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1272 sp->entry = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1273 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1274 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1275 s3 : /* empty */ { if (transient == -2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1276 transient = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1277 permission = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1278 enterscope(mktable(NULL), 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1279 sp->entry = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1280 sp->grow = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1281 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1282 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1283 s4 : /* empty */ { enterscope(mktable(NULL), 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1284 sp->entry = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1285 sp->mask = True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1286 sp->val = 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1287 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1288 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1289 s5 : /* empty */ { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1290 | ',' { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1291 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1292 s6 : /* empty */ { if (sp->table->level == INTERNAL)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1293 transient |= 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1294 permission = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1295 enterscope(mktable(NULL), 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1296 sp->entry = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1297 sp->table->level = PARAM;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1298 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1299 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1300 store : AUTO { $$ = Sauto; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1301 | REGISTER { $$ = Sregister; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1302 | STATIC { $$ = Sstatic; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1303 | EXPLICIT { $$ = Sexplicit; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1304 | EXTERN { $$ = Sextern; transient = 1; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1305 | TYPEDEF { $$ = Stypedef; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1306 | VIRTUAL { $$ = Svirtual; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1307 | CONST { $$ = Sconst; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1308 | FRIEND { $$ = Sfriend; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1309 | INLINE { $$ = Sinline; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1310 | MUSTUNDERSTAND{ $$ = SmustUnderstand; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1311 | RETURN { $$ = Sreturn; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1312 | '@' { $$ = Sattribute;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1313 if (eflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1314 semwarn("SOAP RPC encoding does not support XML attributes");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1315 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1316 | '$' { $$ = Sspecial; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1317 | VOLATILE { $$ = Sextern; transient = -2; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1318 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1319 constobj: /* empty */ { $$ = Snone; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1320 | CONST { $$ = Sconstobj; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1321 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1322 abstract: /* empty */ { $$ = Snone; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1323 | '=' LNG { $$ = Sabstract; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1324 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1325 virtual : /* empty */ { $$ = Snone; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1326 | VIRTUAL { $$ = Svirtual; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1327 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1328 ptrs : /* empty */ { $$ = tmp = sp->node; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1329 | ptrs '*' { /* handle const pointers, such as const char* */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1330 if ((tmp.sto & Sconst))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1331 tmp.sto = (Storage)(((int)tmp.sto & ~Sconst) | Sconstptr);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1332 tmp.typ = mkpointer(tmp.typ);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1333 tmp.typ->transient = transient;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1334 $$ = tmp;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1335 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1336 | ptrs '&' { tmp.typ = mkreference(tmp.typ);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1337 tmp.typ->transient = transient;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1338 $$ = tmp;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1339 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1340 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1341 array : /* empty */ { $$ = tmp; /* tmp is inherited */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1342 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1343 | '[' cexp ']' array
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1344 { if (!bflag && $4.typ->type == Tchar)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1345 { sprintf(errbuf, "char[" SOAP_LONG_FORMAT "] will be serialized as an array of " SOAP_LONG_FORMAT " bytes: use soapcpp2 option -b to enable char[] string serialization or use char* for strings", $2.val.i, $2.val.i);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1346 semwarn(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1347 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1348 if ($2.hasval && $2.typ->type == Tint && $2.val.i > 0 && $4.typ->width > 0)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1349 $$.typ = mkarray($4.typ, (int) $2.val.i * $4.typ->width);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1350 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1351 { $$.typ = mkarray($4.typ, 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1352 semerror("undetermined array size");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1353 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1354 $$.sto = $4.sto;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1355 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1356 | '[' ']' array { $$.typ = mkpointer($3.typ); /* zero size array = pointer */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1357 $$.sto = $3.sto;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1358 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1359 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1360 arrayck : array { if ($1.typ->type == Tstruct || $1.typ->type == Tclass)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1361 if (!$1.typ->ref && !$1.typ->transient && !($1.sto & Stypedef))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1362 { sprintf(errbuf, "struct/class '%s' has incomplete type", $1.typ->id->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1363 semerror(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1364 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1365 $$ = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1366 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1367 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1368 init : /* empty */ { $$.hasval = False; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1369 | '=' cexp { if ($2.hasval)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1370 { $$.typ = $2.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1371 $$.hasval = True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1372 $$.val = $2.val;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1373 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1374 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1375 { $$.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1376 semerror("initialization expression not constant");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1377 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1378 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1379 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1380 tag : /* empty */ { $$ = NULL; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1381 | TAG { $$ = $1; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1382 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1383 occurs : patt
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1384 { $$.minOccurs = -1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1385 $$.maxOccurs = 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1386 $$.minLength = MINLONG64;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1387 $$.maxLength = MAXLONG64;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1388 $$.pattern = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1389 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1390 | patt cint
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1391 { $$.minOccurs = (LONG64)$2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1392 $$.maxOccurs = 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1393 $$.minLength = (LONG64)$2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1394 $$.maxLength = MAXLONG64;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1395 $$.pattern = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1396 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1397 | patt cint ':'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1398 { $$.minOccurs = (LONG64)$2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1399 $$.maxOccurs = 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1400 $$.minLength = (LONG64)$2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1401 $$.maxLength = MAXLONG64;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1402 $$.pattern = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1403 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1404 | patt cint ':' cint
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1405 { $$.minOccurs = (LONG64)$2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1406 $$.maxOccurs = (LONG64)$4;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1407 $$.minLength = (LONG64)$2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1408 $$.maxLength = (LONG64)$4;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1409 $$.pattern = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1410 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1411 | patt ':' cint
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1412 { $$.minOccurs = -1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1413 $$.maxOccurs = (LONG64)$3;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1414 $$.minLength = MINLONG64;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1415 $$.maxLength = (LONG64)$3;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1416 $$.pattern = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1417 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1418 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1419 patt : /* empty */ { $$ = NULL; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1420 | STR { $$ = $1; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1421 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1422 cint : LNG { $$ = $1; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1423 | '+' LNG { $$ = $2; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1424 | '-' LNG { $$ = -$2; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1425 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1426
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1427 /******************************************************************************\
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1428
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1429 Expressions
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1430
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1431 \******************************************************************************/
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1432
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1433 expr : expr ',' expr { $$ = $3; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1434 | cexp { $$ = $1; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1435 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1436 /* cexp : conditional expression */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1437 cexp : obex '?' qexp ':' cexp
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1438 { $$.typ = $3.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1439 $$.sto = Snone;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1440 $$.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1441 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1442 | oexp
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1443 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1444 /* qexp : true-branch of ? : conditional expression */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1445 qexp : expr { $$ = $1; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1446 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1447 /* oexp : or-expression */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1448 oexp : obex OR aexp { $$.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1449 $$.typ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1450 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1451 | aexp { $$ = $1; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1452 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1453 obex : oexp { $$ = $1; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1454 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1455 /* aexp : and-expression */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1456 aexp : abex AN rexp { $$.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1457 $$.typ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1458 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1459 | rexp { $$ = $1; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1460 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1461 abex : aexp { $$ = $1; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1462 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1463 /* rexp : relational expression */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1464 rexp : rexp '|' rexp { $$ = iop("|", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1465 | rexp '^' rexp { $$ = iop("^", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1466 | rexp '&' rexp { $$ = iop("&", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1467 | rexp EQ rexp { $$ = relop("==", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1468 | rexp NE rexp { $$ = relop("!=", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1469 | rexp '<' rexp { $$ = relop("<", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1470 | rexp LE rexp { $$ = relop("<=", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1471 | rexp '>' rexp { $$ = relop(">", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1472 | rexp GE rexp { $$ = relop(">=", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1473 | rexp LS rexp { $$ = iop("<<", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1474 | rexp RS rexp { $$ = iop(">>", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1475 | rexp '+' rexp { $$ = op("+", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1476 | rexp '-' rexp { $$ = op("-", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1477 | rexp '*' rexp { $$ = op("*", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1478 | rexp '/' rexp { $$ = op("/", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1479 | rexp '%' rexp { $$ = iop("%", $1, $3); }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1480 | lexp { $$ = $1; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1481 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1482 /* lexp : lvalue kind of expression with optional prefix contructs */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1483 lexp : '!' lexp { if ($2.hasval)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1484 $$.val.i = !$2.val.i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1485 $$.typ = $2.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1486 $$.hasval = $2.hasval;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1487 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1488 | '~' lexp { if ($2.hasval)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1489 $$.val.i = ~$2.val.i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1490 $$.typ = $2.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1491 $$.hasval = $2.hasval;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1492 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1493 | '-' lexp { if ($2.hasval) {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1494 if (integer($2.typ))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1495 $$.val.i = -$2.val.i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1496 else if (real($2.typ))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1497 $$.val.r = -$2.val.r;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1498 else typerror("string?");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1499 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1500 $$.typ = $2.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1501 $$.hasval = $2.hasval;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1502 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1503 | '+' lexp { $$ = $2; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1504 | '*' lexp { if ($2.typ->type == Tpointer) {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1505 $$.typ = (Tnode*)$2.typ->ref;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1506 } else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1507 typerror("dereference of non-pointer type");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1508 $$.sto = Snone;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1509 $$.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1510 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1511 | '&' lexp { $$.typ = mkpointer($2.typ);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1512 $$.sto = Snone;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1513 $$.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1514 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1515 | SIZEOF '(' texp ')'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1516 { $$.hasval = True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1517 $$.typ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1518 $$.val.i = $3.typ->width;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1519 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1520 | pexp { $$ = $1; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1521 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1522 /* pexp : primitive expression with optional postfix constructs */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1523 pexp : '(' expr ')' { $$ = $2; }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1524 | ID { if ((p = enumentry($1)) == (Entry*) 0)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1525 p = undefined($1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1526 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1527 $$.hasval = True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1528 $$.typ = p->info.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1529 $$.val = p->info.val;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1530 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1531 | LNG { $$.typ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1532 $$.hasval = True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1533 $$.val.i = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1534 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1535 | null { $$.typ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1536 $$.hasval = True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1537 $$.val.i = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1538 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1539 | DBL { $$.typ = mkfloat();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1540 $$.hasval = True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1541 $$.val.r = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1542 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1543 | CHR { $$.typ = mkchar();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1544 $$.hasval = True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1545 $$.val.i = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1546 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1547 | STR { $$.typ = mkstring();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1548 $$.hasval = True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1549 $$.val.s = $1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1550 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1551 | CFALSE { $$.typ = mkbool();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1552 $$.hasval = True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1553 $$.val.i = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1554 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1555 | CTRUE { $$.typ = mkbool();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1556 $$.hasval = True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1557 $$.val.i = 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1558 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1559 ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1560
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1561 %%
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1562
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1563 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1564 * ???
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1565 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1566 int
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1567 yywrap(void)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1568 { return 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1569 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1570
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1571 /******************************************************************************\
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1572
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1573 Support routines
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1574
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1575 \******************************************************************************/
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1576
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1577 static Node
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1578 op(const char *op, Node p, Node q)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1579 { Node r;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1580 Tnode *typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1581 r.typ = p.typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1582 r.sto = Snone;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1583 if (p.hasval && q.hasval) {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1584 if (integer(p.typ) && integer(q.typ))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1585 switch (op[0]) {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1586 case '|': r.val.i = p.val.i | q.val.i; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1587 case '^': r.val.i = p.val.i ^ q.val.i; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1588 case '&': r.val.i = p.val.i & q.val.i; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1589 case '<': r.val.i = p.val.i << q.val.i; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1590 case '>': r.val.i = p.val.i >> q.val.i; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1591 case '+': r.val.i = p.val.i + q.val.i; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1592 case '-': r.val.i = p.val.i - q.val.i; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1593 case '*': r.val.i = p.val.i * q.val.i; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1594 case '/': r.val.i = p.val.i / q.val.i; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1595 case '%': r.val.i = p.val.i % q.val.i; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1596 default: typerror(op);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1597 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1598 else if (real(p.typ) && real(q.typ))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1599 switch (op[0]) {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1600 case '+': r.val.r = p.val.r + q.val.r; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1601 case '-': r.val.r = p.val.r - q.val.r; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1602 case '*': r.val.r = p.val.r * q.val.r; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1603 case '/': r.val.r = p.val.r / q.val.r; break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1604 default: typerror(op);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1605 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1606 else semerror("illegal constant operation");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1607 r.hasval = True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1608 } else {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1609 typ = mgtype(p.typ, q.typ);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1610 r.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1611 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1612 return r;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1613 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1614
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1615 static Node
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1616 iop(const char *iop, Node p, Node q)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1617 { if (integer(p.typ) && integer(q.typ))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1618 return op(iop, p, q);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1619 typerror("integer operands only");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1620 return p;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1621 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1622
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1623 static Node
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1624 relop(const char *op, Node p, Node q)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1625 { Node r;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1626 Tnode *typ;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1627 r.typ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1628 r.sto = Snone;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1629 r.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1630 if (p.typ->type != Tpointer || p.typ != q.typ)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1631 typ = mgtype(p.typ, q.typ);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1632 return r;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1633 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1634
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1635 /******************************************************************************\
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1636
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1637 Scope management
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1638
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1639 \******************************************************************************/
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1640
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1641 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1642 mkscope - initialize scope stack with a new table and offset
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1643 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1644 static void
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1645 mkscope(Table *table, int offset)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1646 { sp = stack-1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1647 enterscope(table, offset);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1648 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1649
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1650 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1651 enterscope - enter a new scope by pushing a new table and offset on the stack
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1652 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1653 static void
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1654 enterscope(Table *table, int offset)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1655 { if (++sp == stack+MAXNEST)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1656 execerror("maximum scope depth exceeded");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1657 sp->table = table;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1658 sp->val = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1659 sp->offset = offset;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1660 sp->grow = True; /* by default, offset grows */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1661 sp->mask = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1662 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1663
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1664 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1665 exitscope - exit a scope by popping the table and offset from the stack
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1666 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1667 static void
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1668 exitscope(void)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1669 { check(sp-- != stack, "exitscope() has no matching enterscope()");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1670 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1671
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1672 /******************************************************************************\
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1673
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1674 Undefined symbol
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1675
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1676 \******************************************************************************/
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1677
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1678 static Entry*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1679 undefined(Symbol *sym)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1680 { Entry *p;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1681 sprintf(errbuf, "undefined identifier '%s'", sym->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1682 semwarn(errbuf);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1683 p = enter(sp->table, sym);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1684 p->level = GLOBAL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1685 p->info.typ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1686 p->info.sto = Sextern;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1687 p->info.hasval = False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1688 return p;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1689 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1690
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1691 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1692 mgtype - return most general type among two numerical types
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1693 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1694 Tnode*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1695 mgtype(Tnode *typ1, Tnode *typ2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1696 { if (numeric(typ1) && numeric(typ2)) {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1697 if (typ1->type < typ2->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1698 return typ2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1699 } else typerror("non-numeric type");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1700 return typ1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1701 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1702
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1703 /******************************************************************************\
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1704
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1705 Type checks
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1706
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1707 \******************************************************************************/
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1708
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1709 static int
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1710 integer(Tnode *typ)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1711 { switch (typ->type) {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1712 case Tchar:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1713 case Tshort:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1714 case Tint:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1715 case Tlong: return True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1716 default: break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1717 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1718 return False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1719 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1720
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1721 static int
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1722 real(Tnode *typ)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1723 { switch (typ->type) {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1724 case Tfloat:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1725 case Tdouble:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1726 case Tldouble: return True;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1727 default: break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1728 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1729 return False;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1730 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1731
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1732 static int
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1733 numeric(Tnode *typ)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1734 { return integer(typ) || real(typ);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1735 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1736
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1737 static void
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1738 add_fault(Table *gt)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1739 { Table *t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1740 Entry *p1, *p2, *p3, *p4;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1741 Symbol *s1, *s2, *s3, *s4;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1742 imported = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1743 s1 = lookup("SOAP_ENV__Code");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1744 p1 = entry(classtable, s1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1745 if (!p1 || !p1->info.typ->ref)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1746 { t = mktable((Table*)0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1747 if (!p1)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1748 { p1 = enter(classtable, s1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1749 p1->info.typ = mkstruct(t, 3*4);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1750 p1->info.typ->id = s1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1751 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1752 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1753 p1->info.typ->ref = t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1754 p2 = enter(t, lookup("SOAP_ENV__Value"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1755 p2->info.typ = qname;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1756 p2->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1757 p2 = enter(t, lookup("SOAP_ENV__Subcode"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1758 p2->info.typ = mkpointer(p1->info.typ);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1759 p2->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1760 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1761 s2 = lookup("SOAP_ENV__Detail");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1762 p2 = entry(classtable, s2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1763 if (!p2 || !p2->info.typ->ref)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1764 { t = mktable((Table*)0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1765 if (!p2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1766 { p2 = enter(classtable, s2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1767 p2->info.typ = mkstruct(t, 3*4);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1768 p2->info.typ->id = s2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1769 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1770 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1771 p2->info.typ->ref = t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1772 p3 = enter(t, lookup("__any"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1773 p3->info.typ = xml;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1774 p3->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1775 p3 = enter(t, lookup("__type"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1776 p3->info.typ = mkint();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1777 p3->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1778 p3 = enter(t, lookup("fault"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1779 p3->info.typ = mkpointer(mkvoid());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1780 p3->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1781 custom_fault = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1782 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1783 s4 = lookup("SOAP_ENV__Reason");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1784 p4 = entry(classtable, s4);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1785 if (!p4 || !p4->info.typ->ref)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1786 { t = mktable((Table*)0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1787 if (!p4)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1788 { p4 = enter(classtable, s4);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1789 p4->info.typ = mkstruct(t, 4);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1790 p4->info.typ->id = s4;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1791 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1792 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1793 p4->info.typ->ref = t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1794 p3 = enter(t, lookup("SOAP_ENV__Text"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1795 p3->info.typ = mkstring();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1796 p3->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1797 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1798 s3 = lookup("SOAP_ENV__Fault");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1799 p3 = entry(classtable, s3);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1800 if (!p3 || !p3->info.typ->ref)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1801 { t = mktable(NULL);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1802 if (!p3)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1803 { p3 = enter(classtable, s3);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1804 p3->info.typ = mkstruct(t, 9*4);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1805 p3->info.typ->id = s3;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1806 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1807 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1808 p3->info.typ->ref = t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1809 p3 = enter(t, lookup("faultcode"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1810 p3->info.typ = qname;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1811 p3->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1812 p3 = enter(t, lookup("faultstring"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1813 p3->info.typ = mkstring();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1814 p3->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1815 p3 = enter(t, lookup("faultactor"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1816 p3->info.typ = mkstring();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1817 p3->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1818 p3 = enter(t, lookup("detail"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1819 p3->info.typ = mkpointer(p2->info.typ);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1820 p3->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1821 p3 = enter(t, s1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1822 p3->info.typ = mkpointer(p1->info.typ);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1823 p3->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1824 p3 = enter(t, s4);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1825 p3->info.typ = mkpointer(p4->info.typ);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1826 p3->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1827 p3 = enter(t, lookup("SOAP_ENV__Node"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1828 p3->info.typ = mkstring();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1829 p3->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1830 p3 = enter(t, lookup("SOAP_ENV__Role"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1831 p3->info.typ = mkstring();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1832 p3->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1833 p3 = enter(t, lookup("SOAP_ENV__Detail"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1834 p3->info.typ = mkpointer(p2->info.typ);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1835 p3->info.minOccurs = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1836 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1837 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1838
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1839 static void
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1840 add_soap(void)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1841 { Symbol *s = lookup("soap");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1842 p = enter(classtable, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1843 p->info.typ = mkstruct(NULL, 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1844 p->info.typ->transient = -2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1845 p->info.typ->id = s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1846 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1847
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1848 static void
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1849 add_XML(void)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1850 { Symbol *s = lookup("_XML");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1851 s->token = TYPE;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1852 p = enter(typetable, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1853 xml = p->info.typ = mksymtype(mkstring(), s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1854 p->info.sto = Stypedef;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1855 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1856
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1857 static void
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1858 add_qname(void)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1859 { Symbol *s = lookup("_QName");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1860 s->token = TYPE;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1861 p = enter(typetable, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1862 qname = p->info.typ = mksymtype(mkstring(), s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1863 p->info.sto = Stypedef;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1864 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1865
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1866 static void
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1867 add_header(Table *gt)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1868 { Table *t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1869 Entry *p;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1870 Symbol *s = lookup("SOAP_ENV__Header");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1871 imported = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1872 p = entry(classtable, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1873 if (!p || !p->info.typ->ref)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1874 { t = mktable((Table*)0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1875 if (!p)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1876 p = enter(classtable, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1877 p->info.typ = mkstruct(t, 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1878 p->info.typ->id = s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1879 custom_header = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1880 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1881 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1882
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1883 static void
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1884 add_response(Entry *fun, Entry *ret)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1885 { Table *t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1886 Entry *p, *q;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1887 Symbol *s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1888 size_t i = 0, j, n = strlen(fun->sym->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1889 char *r = (char*)emalloc(n+100);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1890 strcpy(r, fun->sym->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1891 strcat(r, "Response");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1892 do
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1893 { for (j = 0; j < i; j++)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1894 r[n+j+8] = '_';
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1895 r[n+i+8] = '\0';
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1896 if (!(s = lookup(r)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1897 s = install(r, ID);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1898 i++;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1899 } while (entry(classtable, s));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1900 free(r);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1901 t = mktable((Table*)0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1902 q = enter(t, ret->sym);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1903 q->info = ret->info;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1904 if (q->info.typ->type == Treference)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1905 q->info.typ = (Tnode*)q->info.typ->ref;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1906 p = enter(classtable, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1907 p->info.typ = mkstruct(t, 4);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1908 p->info.typ->id = s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1909 fun->info.typ->response = p;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1910 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1911
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1912 static void
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1913 add_result(Tnode *typ)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1914 { Entry *p;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1915 if (!typ->ref || !((Tnode*)typ->ref)->ref)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1916 { semwarn("response struct/class must be declared before used in function prototype");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1917 return;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1918 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1919 for (p = ((Table*)((Tnode*)typ->ref)->ref)->list; p; p = p->next)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1920 if (p->info.sto & Sreturn)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1921 return;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1922 for (p = ((Table*)((Tnode*)typ->ref)->ref)->list; p; p = p->next)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1923 { if (p->info.typ->type != Tfun && !(p->info.sto & Sattribute) && !is_transient(p->info.typ) && !(p->info.sto & (Sprivate|Sprotected)))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1924 p->info.sto = (Storage)((int)p->info.sto | (int)Sreturn);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1925 return;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1926 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1927 }