~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to tools/gsoap/win32-2.7/src/.svn/text-base/soapcpp2_lex.l.svn-base

  • Committer: Jorge O. Castro
  • Date: 2007-12-03 06:56:46 UTC
  • Revision ID: jorge@ubuntu.com-20071203065646-mupcnjcwgm5mnhyt
* Remove a bunch of .svn directories we no longer need.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 
3
 
soapcpp2_lex.l
4
 
 
5
 
Flex/Lex tokenizer.
6
 
 
7
 
gSOAP XML Web services tools
8
 
Copyright (C) 2004, Robert van Engelen, Genivia, Inc. All Rights Reserved.
9
 
 
10
 
--------------------------------------------------------------------------------
11
 
gSOAP public license.
12
 
 
13
 
The contents of this file are subject to the gSOAP Public License Version 1.3
14
 
(the "License"); you may not use this file except in compliance with the
15
 
License. You may obtain a copy of the License at
16
 
http://www.cs.fsu.edu/~engelen/soaplicense.html
17
 
Software distributed under the License is distributed on an "AS IS" basis,
18
 
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19
 
for the specific language governing rights and limitations under the License.
20
 
 
21
 
The Initial Developer of the Original Code is Robert A. van Engelen.
22
 
Copyright (C) 2000-2004 Robert A. van Engelen, Genivia inc. All Rights Reserved.
23
 
--------------------------------------------------------------------------------
24
 
GPL license.
25
 
 
26
 
This program is free software; you can redistribute it and/or modify it under
27
 
the terms of the GNU General Public License as published by the Free Software
28
 
Foundation; either version 2 of the License, or (at your option) any later
29
 
version.
30
 
 
31
 
This program is distributed in the hope that it will be useful, but WITHOUT ANY
32
 
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
33
 
PARTICULAR PURPOSE. See the GNU General Public License for more details.
34
 
 
35
 
You should have received a copy of the GNU General Public License along with
36
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
37
 
Place, Suite 330, Boston, MA 02111-1307 USA
38
 
 
39
 
Author contact information:
40
 
engelen@genivia.com / engelen@acm.org
41
 
--------------------------------------------------------------------------------
42
 
*/
43
 
 
44
 
%{
45
 
#include "soapcpp2.h"
46
 
#include "soapcpp2_yacc.h"
47
 
#ifdef WITH_BISON
48
 
YYSTYPE soapcpp2lval;
49
 
#undef YY_INPUT
50
 
#define YY_INPUT(buf, result, max_size) \
51
 
        { \
52
 
        int c = getc(yyin); \
53
 
        result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
54
 
        }
55
 
#endif
56
 
 
57
 
#ifndef WITH_LEX
58
 
#define MAX_IMPORT_DEPTH 16
59
 
static struct imported { struct imported *next; char name[1]; } *imported = NULL;
60
 
static char fnstk[MAX_IMPORT_DEPTH][1024];
61
 
static int lnstk[MAX_IMPORT_DEPTH];
62
 
static YY_BUFFER_STATE instk[MAX_IMPORT_DEPTH];
63
 
#endif
64
 
int imports = 0;
65
 
static Token install_id();
66
 
static Token install_int();
67
 
static Token install_hex();
68
 
static Token install_num();
69
 
static Token install_chr();
70
 
static Token install_str();
71
 
static Token install_pragma();
72
 
static void directive(), option();
73
 
static Token error_chr();
74
 
static Token error_str();
75
 
static int convchar(int*);
76
 
static int hexchar(int*);
77
 
static int octchar(int*);
78
 
static void module(const char *name), import(const char *file);
79
 
static void endimport();
80
 
static int magic(const char *name);
81
 
%}
82
 
digit           [0-9]
83
 
alpha           [a-zA-Z_]
84
 
scope           ::
85
 
id              {alpha}({alpha}|{digit}|{scope})*
86
 
int             {digit}+
87
 
hex             0[xX][0-9a-fA-F]+
88
 
num             {int}(\.{int}([Ee][+-]?{int})?|(\.{int})?[Ee][+-]?{int})
89
 
chr             '(\\'|[^'\n])*'
90
 
str             \"(\\\"|\\\n|[^"])*\"
91
 
module          #module[ \t]*{str}.*\n
92
 
import          #import[ \t]*{str}.*\n
93
 
eof             <<EOF>>
94
 
%x MLCOMMENT
95
 
%%
96
 
[ \t\v\n\f\r\x1A\xA0]   { /* skip white space (\x1A is ^Z and \xA0 is HTML non-breakable space) */ }
97
 
"/*"                    { BEGIN(MLCOMMENT); }
98
 
<MLCOMMENT>[^*]         { /* eat anything that's not a '*' */ }
99
 
<MLCOMMENT>"*"[^/]      { /* eat up '*'s not followed by '/'s */ }
100
 
<MLCOMMENT>"*/"         { BEGIN(INITIAL); }
101
 
<MLCOMMENT><<EOF>>      { execerror("Unclosed multiline comment at the end of file"); }
102
 
"//gsoapopt".*\n        { option(); }
103
 
"//gsoap".*\n           { directive(); }
104
 
"//".*\n                { /* skip single line comment */ }
105
 
"+="                    { return PA; }
106
 
"-="                    { return NA; }
107
 
"*="                    { return TA; }
108
 
"/="                    { return DA; }
109
 
"%="                    { return MA; }
110
 
"&="                    { return AA; }
111
 
"^="                    { return XA; }
112
 
"|="                    { return OA; }
113
 
"<<="                   { return LA; }
114
 
">>="                   { return RA; }
115
 
"||"                    { return OR; }
116
 
"&&"                    { return AN; }
117
 
"=="                    { return EQ; }
118
 
"!="                    { return NE; }
119
 
"<="                    { return LE; }
120
 
">="                    { return GE; }
121
 
"<<"                    { return LS; }
122
 
">>"                    { return RS; }
123
 
"++"                    { return PP; }
124
 
"--"                    { return NN; }
125
 
"->"                    { return AR; }
126
 
[;,:=|^&<>+\-*/%!?~(){}\[\].@]  { return yytext[0]; }
127
 
{id}                    { return install_id(); }
128
 
{int}                   { return install_int(); }
129
 
{hex}                   { return install_hex(); }
130
 
{num}                   { return install_num(); }
131
 
{chr}                   { return install_chr(); }
132
 
{str}                   { return install_str(); }
133
 
{module}                { char *s, buf[1024];
134
 
                          s = strchr(yytext, '"');
135
 
                          strcpy(buf, s+1);
136
 
                          s = strchr(buf, '"');
137
 
                          *s = '\0';
138
 
                          module(buf);
139
 
                        }
140
 
{import}                { char *s, buf[1024];
141
 
                          s = strchr(yytext, '"');
142
 
                          strcpy(buf, s+1);
143
 
                          s = strchr(buf, '"');
144
 
                          *s = '\0';
145
 
                          import(buf);
146
 
                        }
147
 
#.*\n                   { return install_pragma(); }
148
 
'[^'\n]*/\n             { return error_chr(); }
149
 
\"[^"\n]*/\n            { return error_str(); }
150
 
.                       { lexerror("Skipping unknown symbol"); }
151
 
{eof}                   { /* in case Lex complains, remove this line */
152
 
#ifndef WITH_LEX
153
 
                          if (--imports < 0)
154
 
                            yyterminate();
155
 
                          else
156
 
                          { yy_delete_buffer(YY_CURRENT_BUFFER);
157
 
                            yy_switch_to_buffer(instk[imports]);
158
 
                            strcpy(filename, fnstk[imports]);
159
 
                            yylineno = lnstk[imports];
160
 
                          }
161
 
#endif
162
 
                        }
163
 
%%
164
 
 
165
 
/*
166
 
        install_id - lookup identifier in symbol table. If found, return token
167
 
        and symbol table entry. If not found, create entry in symbol table and
168
 
        return ID token.
169
 
*/ 
170
 
static Token
171
 
install_id()
172
 
{       Symbol *p = lookup(yytext);
173
 
        if (!p)
174
 
                p = install(yytext, ID);
175
 
        yylval.sym = p;
176
 
        return p->token;
177
 
}
178
 
 
179
 
/*
180
 
        install_int - convert digits to integer and return LNG token.
181
 
*/
182
 
static Token
183
 
install_int()
184
 
{
185
 
#ifdef WIN32
186
 
        sscanf(yytext, "%I64u", &yylval.i);
187
 
#else
188
 
        sscanf(yytext, "%llu", &yylval.i);
189
 
#endif
190
 
        return LNG;
191
 
}
192
 
 
193
 
/*
194
 
        install_hex - convert hexadecimal digits to integer and return LNG
195
 
*/
196
 
static Token
197
 
install_hex()
198
 
{
199
 
#ifdef WIN32
200
 
        sscanf(yytext, "%I64x", &yylval.i);
201
 
#else
202
 
        sscanf(yytext, "%llx", &yylval.i);
203
 
#endif
204
 
        return LNG;
205
 
}
206
 
 
207
 
/*
208
 
        install_num - convert digits to floating point number and return DBL
209
 
*/
210
 
static Token
211
 
install_num()
212
 
{       sscanf(yytext, "%lf", &yylval.r);
213
 
        return DBL;
214
 
}
215
 
 
216
 
/*
217
 
        install_chr - convert character constant and return CHR.
218
 
*/
219
 
static Token
220
 
install_chr()
221
 
{       int i = 2;
222
 
        if (yytext[1] == '\\')
223
 
                yylval.c = convchar(&i);
224
 
        else    yylval.c = yytext[i-1];
225
 
        if (yytext[i] != '\'')
226
 
                lexerror("Illegal character constant");
227
 
        return CHR;
228
 
}
229
 
 
230
 
/*
231
 
        install_str - convert and store string in memory. Return STR.
232
 
*/
233
 
static Token
234
 
install_str()
235
 
{       int i, j = 0;
236
 
        yylval.s = emalloc(yyleng-1);   /* yyleng = length(yytext) */
237
 
        for (i = 1; i < yyleng-1; i++)
238
 
                if (yytext[i] == '\\')
239
 
                {       if (yytext[++i] != '\n')
240
 
                        {       yylval.s[j++] = convchar(&i);
241
 
                                i--;
242
 
                        }
243
 
                }
244
 
                else
245
 
                        yylval.s[j++] = yytext[i];
246
 
        yylval.s[j] = '\0';
247
 
        return STR;
248
 
}
249
 
 
250
 
/*
251
 
        install_pragma - store pragma in string. Return PRAGMA.
252
 
*/
253
 
static Token
254
 
install_pragma()
255
 
{       yylval.s = emalloc(yyleng);     /* yyleng = length(yytext) */
256
 
        strncpy(yylval.s, yytext, strlen(yytext)-1);
257
 
        yylval.s[strlen(yytext)-1] = '\0';
258
 
        return PRAGMA;
259
 
}
260
 
 
261
 
static void directive()
262
 
{       int i, j, k;
263
 
        char *s;
264
 
        Service *sp;
265
 
        Method *m;
266
 
        int service;
267
 
        for (i = 7; yytext[i]; i++)
268
 
                if (yytext[i] > 32)
269
 
                        break;
270
 
        for (j = i; yytext[j]; j++)
271
 
                if (yytext[j] <= 32)
272
 
                        break;
273
 
        if (i == j)
274
 
                return;
275
 
        s = (char*)emalloc(j-i+1);
276
 
        strncpy(s, yytext+i, j-i);
277
 
        s[j-i] = '\0';
278
 
        for (sp = services; sp; sp = sp->next)
279
 
                if (!strcmp(sp->ns, s))
280
 
                        break;
281
 
        if (!sp)
282
 
        {       sp = (Service*)emalloc(sizeof(Service));
283
 
                sp->next = services;
284
 
                sp->ns = s;
285
 
                sp->name = NULL;
286
 
                sp->port = NULL;
287
 
                sp->URL = NULL;
288
 
                sp->URI = NULL;
289
 
                sp->WSDL = NULL;
290
 
                sp->style = NULL;
291
 
                sp->encoding = NULL;
292
 
                sp->elementForm = NULL;
293
 
                sp->attributeForm = NULL;
294
 
                sp->executable = NULL;
295
 
                sp->import = NULL;
296
 
                sp->documentation = NULL;
297
 
                sp->list = NULL;
298
 
                services = sp;
299
 
        }
300
 
        for (i = j; yytext[i]; i++)
301
 
                if (yytext[i] > 32)
302
 
                        break;
303
 
        if (!strncmp(yytext+i, "service", 7) || !strncmp(yytext+i, "schema", 6))
304
 
        {       service = strncmp(yytext+i, "schema", 6);
305
 
                for (i += 7; yytext[i]; i++)
306
 
                        if (yytext[i] > 32)
307
 
                                break;
308
 
                for (j = i; yytext[j]; j++)
309
 
                        if (yytext[j] <= 32)
310
 
                                break;
311
 
                for (; yytext[j]; j++)
312
 
                        if (yytext[j] > 32)
313
 
                                break;
314
 
                for (k = j; yytext[k]; k++)
315
 
                        if (yytext[k] <= 32)
316
 
                                break;
317
 
                if (j == k)
318
 
                        return;
319
 
                s = (char*)emalloc(k-j+1);
320
 
                strncpy(s, yytext+j, k-j);
321
 
                s[k-j] = '\0';
322
 
                if (!strncmp(yytext+i, "name:", 5))
323
 
                {       sp->name = s;
324
 
                        for (j = k; yytext[j]; j++)
325
 
                                if (yytext[j] > 32)
326
 
                                        break;
327
 
                        for (k = j; yytext[k]; k++)
328
 
                                if (yytext[k] == 10 || yytext[k] == 13)
329
 
                                        break;
330
 
                        if (j == k)
331
 
                                return;
332
 
                        s = (char*)emalloc(k-j+1);
333
 
                        strncpy(s, yytext+j, k-j);
334
 
                        s[k-j] = '\0';
335
 
                        sp->documentation = s;
336
 
                }
337
 
                else if (!strncmp(yytext+i, "type:", 5))
338
 
                        sp->port = s;
339
 
                else if (!strncmp(yytext+i, "portType:", 9))
340
 
                        sp->port = s;
341
 
                else if (!strncmp(yytext+i, "documentation:", 14))
342
 
                {       for (k = j; yytext[k]; k++)
343
 
                                if (yytext[k] == 10 || yytext[k] == 13)
344
 
                                        break;
345
 
                        if (j == k)
346
 
                                return;
347
 
                        s = (char*)emalloc(k-j+1);
348
 
                        strncpy(s, yytext+j, k-j);
349
 
                        s[k-j] = '\0';
350
 
                        sp->documentation = s;
351
 
                }
352
 
                else if (!strncmp(yytext+i, "location:", 9) || !strncmp(yytext+i, "port:", 5))
353
 
                        sp->URL = s;
354
 
                else if (!strncmp(yytext+i, "executable:", 11))
355
 
                        sp->executable = s;
356
 
                else if (!strncmp(yytext+i, "namespace:", 10))
357
 
                {       if (service)
358
 
                        {       if (!sp->URI)
359
 
                                        sp->URI = s;
360
 
                                sp->WSDL = s;
361
 
                        }
362
 
                        else if (vflag != 0 && !strcmp(sp->ns, "SOAP-ENV"))
363
 
                                sp->URI = envURI;
364
 
                        else if (vflag != 0 && !strcmp(sp->ns, "SOAP-ENC"))
365
 
                                sp->URI = encURI;
366
 
                        else
367
 
                                sp->URI = s;
368
 
                }
369
 
                else if (!strncmp(yytext+i, "form:", 5))
370
 
                {       sp->elementForm = s;
371
 
                        sp->attributeForm = s;
372
 
                }
373
 
                else if (!strncmp(yytext+i, "elementForm:", 12))
374
 
                        sp->elementForm = s;
375
 
                else if (!strncmp(yytext+i, "attributeForm:", 14))
376
 
                        sp->attributeForm = s;
377
 
                else if (!strncmp(yytext+i, "import:", 7))
378
 
                {       if (!sp->URI)
379
 
                                sp->URI = s;
380
 
                        sp->import = s;
381
 
                }
382
 
                else if (!strncmp(yytext+i, "encoding:", 9))
383
 
                {       if (!strcmp(s, "encoded"))
384
 
                                sp->encoding = "";
385
 
                        else
386
 
                                sp->encoding = s;
387
 
                }
388
 
                else if (!strncmp(yytext+i, "style:", 6))
389
 
                        sp->style = s;
390
 
                else if (!strncmp(yytext+i, "method-style:", 13))
391
 
                {       m = (Method*)emalloc(sizeof(Method));
392
 
                        m->name = s;
393
 
                        m->mess = STYLE;
394
 
                        m->part = NULL;
395
 
                        m->next = sp->list;
396
 
                        sp->list = m;
397
 
                        for (j = k; yytext[j]; j++)
398
 
                                if (yytext[j] > 32)
399
 
                                        break;
400
 
                        for (k = j; yytext[k]; k++)
401
 
                                if (yytext[k] == 10 || yytext[k] == 13)
402
 
                                        break;
403
 
                        if (j == k)
404
 
                                return;
405
 
                        s = (char*)emalloc(k-j+1);
406
 
                        strncpy(s, yytext+j, k-j);
407
 
                        s[k-j] = '\0';
408
 
                        m->part = s;
409
 
                }
410
 
                else if (!strncmp(yytext+i, "method-encoding:", 16))
411
 
                {       m = (Method*)emalloc(sizeof(Method));
412
 
                        m->name = s;
413
 
                        m->mess = ENCODING;
414
 
                        m->part = NULL;
415
 
                        m->next = sp->list;
416
 
                        sp->list = m;
417
 
                        for (j = k; yytext[j]; j++)
418
 
                                if (yytext[j] > 32)
419
 
                                        break;
420
 
                        for (k = j; yytext[k]; k++)
421
 
                                if (yytext[k] == 10 || yytext[k] == 13)
422
 
                                        break;
423
 
                        if (j == k)
424
 
                                return;
425
 
                        s = (char*)emalloc(k-j+1);
426
 
                        strncpy(s, yytext+j, k-j);
427
 
                        s[k-j] = '\0';
428
 
                        if (strcmp(s, "encoded"))
429
 
                                m->part = s;
430
 
                        else
431
 
                                m->part = "";
432
 
                }
433
 
                else if (!strncmp(yytext+i, "method-response-encoding:", 25))
434
 
                {       m = (Method*)emalloc(sizeof(Method));
435
 
                        m->name = s;
436
 
                        m->mess = RESPONSE_ENCODING;
437
 
                        m->part = NULL;
438
 
                        m->next = sp->list;
439
 
                        sp->list = m;
440
 
                        for (j = k; yytext[j]; j++)
441
 
                                if (yytext[j] > 32)
442
 
                                        break;
443
 
                        for (k = j; yytext[k]; k++)
444
 
                                if (yytext[k] == 10 || yytext[k] == 13)
445
 
                                        break;
446
 
                        if (j == k)
447
 
                                return;
448
 
                        s = (char*)emalloc(k-j+1);
449
 
                        strncpy(s, yytext+j, k-j);
450
 
                        s[k-j] = '\0';
451
 
                        if (strcmp(s, "encoded"))
452
 
                                m->part = s;
453
 
                        else
454
 
                                m->part = "";
455
 
                }
456
 
                else if (!strncmp(yytext+i, "method-documentation:", 21))
457
 
                {       m = (Method*)emalloc(sizeof(Method));
458
 
                        m->name = s;
459
 
                        m->mess = COMMENT;
460
 
                        m->part = NULL;
461
 
                        m->next = sp->list;
462
 
                        sp->list = m;
463
 
                        for (j = k; yytext[j]; j++)
464
 
                                if (yytext[j] > 32)
465
 
                                        break;
466
 
                        for (k = j; yytext[k]; k++)
467
 
                                if (yytext[k] == 10 || yytext[k] == 13)
468
 
                                        break;
469
 
                        if (j == k)
470
 
                                return;
471
 
                        s = (char*)emalloc(k-j+1);
472
 
                        strncpy(s, yytext+j, k-j);
473
 
                        s[k-j] = '\0';
474
 
                        m->part = s;
475
 
                }
476
 
                else if (!strncmp(yytext+i, "method-action:", 14))
477
 
                {       m = (Method*)emalloc(sizeof(Method));
478
 
                        m->name = s;
479
 
                        m->mess = ACTION;
480
 
                        m->part = NULL;
481
 
                        m->next = sp->list;
482
 
                        sp->list = m;
483
 
                        for (j = k; yytext[j]; j++)
484
 
                                if (yytext[j] > 32)
485
 
                                        break;
486
 
                        for (k = j; yytext[k]; k++)
487
 
                                if (yytext[k] <= 32)
488
 
                                        break;
489
 
                        if (j == k)
490
 
                                return;
491
 
                        s = (char*)emalloc(k-j+1);
492
 
                        strncpy(s, yytext+j, k-j);
493
 
                        s[k-j] = '\0';
494
 
                        m->part = s;
495
 
                }
496
 
                else if (!strncmp(yytext+i, "method-header-part:", 19))
497
 
                {       m = (Method*)emalloc(sizeof(Method));
498
 
                        m->name = s;
499
 
                        m->mess = HDRIN | HDROUT;
500
 
                        m->part = NULL;
501
 
                        m->next = sp->list;
502
 
                        sp->list = m;
503
 
                        for (j = k; yytext[j]; j++)
504
 
                                if (yytext[j] > 32)
505
 
                                        break;
506
 
                        for (k = j; yytext[k]; k++)
507
 
                                if (yytext[k] <= 32)
508
 
                                        break;
509
 
                        if (j == k)
510
 
                                return;
511
 
                        s = (char*)emalloc(k-j+1);
512
 
                        strncpy(s, yytext+j, k-j);
513
 
                        s[k-j] = '\0';
514
 
                        m->part = s;
515
 
                }
516
 
                else if (!strncmp(yytext+i, "method-input-header-part:", 25))
517
 
                {       m = (Method*)emalloc(sizeof(Method));
518
 
                        m->name = s;
519
 
                        m->mess = HDRIN;
520
 
                        m->part = NULL;
521
 
                        m->next = sp->list;
522
 
                        sp->list = m;
523
 
                        for (j = k; yytext[j]; j++)
524
 
                                if (yytext[j] > 32)
525
 
                                        break;
526
 
                        for (k = j; yytext[k]; k++)
527
 
                                if (yytext[k] <= 32)
528
 
                                        break;
529
 
                        if (j == k)
530
 
                                return;
531
 
                        s = (char*)emalloc(k-j+1);
532
 
                        strncpy(s, yytext+j, k-j);
533
 
                        s[k-j] = '\0';
534
 
                        m->part = s;
535
 
                }
536
 
                else if (!strncmp(yytext+i, "method-output-header-part:", 26))
537
 
                {       m = (Method*)emalloc(sizeof(Method));
538
 
                        m->name = s;
539
 
                        m->mess = HDROUT;
540
 
                        m->part = NULL;
541
 
                        m->next = sp->list;
542
 
                        sp->list = m;
543
 
                        for (j = k; yytext[j]; j++)
544
 
                                if (yytext[j] > 32)
545
 
                                        break;
546
 
                        for (k = j; yytext[k]; k++)
547
 
                                if (yytext[k] <= 32)
548
 
                                        break;
549
 
                        if (j == k)
550
 
                                return;
551
 
                        s = (char*)emalloc(k-j+1);
552
 
                        strncpy(s, yytext+j, k-j);
553
 
                        s[k-j] = '\0';
554
 
                        m->part = s;
555
 
                }
556
 
                else if (!strncmp(yytext+i, "method-fault:", 13))
557
 
                {       m = (Method*)emalloc(sizeof(Method));
558
 
                        m->name = s;
559
 
                        m->mess = FAULT;
560
 
                        m->part = NULL;
561
 
                        m->next = sp->list;
562
 
                        sp->list = m;
563
 
                        for (j = k; yytext[j]; j++)
564
 
                                if (yytext[j] > 32)
565
 
                                        break;
566
 
                        for (k = j; yytext[k]; k++)
567
 
                                if (yytext[k] <= 32)
568
 
                                        break;
569
 
                        if (j == k)
570
 
                                return;
571
 
                        s = (char*)emalloc(k-j+1);
572
 
                        strncpy(s, yytext+j, k-j);
573
 
                        s[k-j] = '\0';
574
 
                        m->part = s;
575
 
                }
576
 
                else
577
 
                { sprintf(errbuf, "unrecognized gsoap directive: '%s'", yytext+i);
578
 
                  semwarn(errbuf);
579
 
                }
580
 
        }
581
 
        else
582
 
        { sprintf(errbuf, "unrecognized gsoap directive: '%s'", yytext);
583
 
          semwarn(errbuf);
584
 
        }
585
 
}
586
 
 
587
 
static void option()
588
 
{       int i;
589
 
        for (i = 10; yytext[i]; i++)
590
 
                if (yytext[i] > 32)
591
 
                        break;
592
 
        for (; yytext[i]; i++)
593
 
                switch (yytext[i])
594
 
                {       case 'c':
595
 
                                cflag = 1;
596
 
                                break;
597
 
                        case 'e':
598
 
                                eflag = 1;
599
 
                                break;
600
 
                        case 'n':
601
 
                                nflag = 1;
602
 
                                break;
603
 
                        case 'l':
604
 
                                lflag = 1;
605
 
                                break;
606
 
                        case 'w':
607
 
                                wflag = 1;
608
 
                                break;
609
 
                        default:
610
 
                                if (yytext[i] <= 32)
611
 
                                        return;
612
 
                }
613
 
}
614
 
 
615
 
/*
616
 
        error_chr - lexical error in character constant. Return character 0 to
617
 
        allow parsing to continue
618
 
*/
619
 
static Token
620
 
error_chr()
621
 
{       lexerror("Ending-' missing in character constant");
622
 
        yylval.c = '\0';
623
 
        return CHR;
624
 
}
625
 
 
626
 
/*
627
 
        error_str - lexical error in string. Return empty string to allow
628
 
        parsing to continue
629
 
*/
630
 
static Token
631
 
error_str()
632
 
{       lexerror("Ending-\" missing in string");
633
 
        yylval.s = "";
634
 
        return STR;
635
 
}
636
 
 
637
 
/*
638
 
        Character conversion functions
639
 
*/
640
 
static int
641
 
convchar(int *p)
642
 
{       switch (yytext[(*p)++])
643
 
        {       case 'a':       return '\a';
644
 
                case 'b':       return '\b';
645
 
                case 'f':       return '\f';
646
 
                case 'n':       return '\n';
647
 
                case 'r':       return '\r';
648
 
                case 't':       return '\t';
649
 
                case 'v':       return '\v';
650
 
                case 'x':       return hexchar(p);
651
 
                case '0':
652
 
                case '1':
653
 
                case '2':
654
 
                case '3':
655
 
                case '4':
656
 
                case '5':
657
 
                case '6':
658
 
                case '7':       (*p)--;
659
 
                                return octchar(p);
660
 
                default:        return yytext[*p-1];
661
 
        }
662
 
}
663
 
 
664
 
static int
665
 
hexchar(int *p)
666
 
{       int i, d, c = 0;
667
 
        for (i = 0; isxdigit(d = yytext[*p]) && i < 2; i++)
668
 
        {       c = (c << 4) + (d <= '9' ? d - '0' : toupper(d) - '7');
669
 
                (*p)++;
670
 
        }
671
 
        return c;
672
 
}
673
 
 
674
 
static int
675
 
octchar(int *p)
676
 
{       int i, d, c = 0;
677
 
        for (i = 0; (d = yytext[*p]) >= '0' && d <= '7' && i < 3; i++)
678
 
        {       c = (c << 3) + d - '0';
679
 
                (*p)++;
680
 
        }
681
 
        return c;
682
 
}
683
 
 
684
 
static void module(const char *name)
685
 
{ if (imports)
686
 
  { if (!lflag)
687
 
    { Pragma **pp;
688
 
      char *s = emalloc(256);
689
 
      sprintf(s, "#include \"%sH.h\"", name);
690
 
      for (pp = &pragmas; *pp; pp = &(*pp)->next)
691
 
        ;
692
 
      *pp = (Pragma*)emalloc(sizeof(Pragma));
693
 
      (*pp)->pragma = s;
694
 
      (*pp)->next = NULL;
695
 
      xflag = 1;
696
 
      fprintf(stderr, "Importing module %s\n", name);
697
 
    }
698
 
  }
699
 
  else
700
 
  { lflag = 1;
701
 
    typeNO = magic(name);
702
 
    prefix = emalloc(strlen(name)+1);
703
 
    strcpy(prefix, name);
704
 
    fprintf(stderr, "Module %s\n", name);
705
 
  }
706
 
}
707
 
 
708
 
static int magic(const char *name)
709
 
{ int i, n;
710
 
  if (strlen(name) > 4)
711
 
    semerror("#module name length must not exceed four characters");
712
 
  n = 0;
713
 
  for (i = 0; i < strlen(name); i++)
714
 
    if (name[i] >= 'a' && name[i] <= 'z')
715
 
      n = 26*n + name[i] - 'a';
716
 
    else if (name[i] >= 'A' && name[i] <= 'Z')
717
 
      n = 26*n + name[i] - 'A';
718
 
    else
719
 
      semerror("#module name must be alphabetic and the length must not exceed four characters");
720
 
  return 4699*n + 153424;
721
 
}
722
 
 
723
 
#ifdef WITH_LEX
724
 
static void import(const char *file)
725
 
{ execerror("Cannot #import: soapcpp2 not compiled with flex");
726
 
}
727
 
#else
728
 
static void import(const char *file)
729
 
{ char buf[1024];
730
 
  struct imported *p;
731
 
  for (p = imported; p; p = p->next)
732
 
    if (!strcmp(p->name, file))
733
 
      return;
734
 
  if (imports >= MAX_IMPORT_DEPTH)
735
 
    execerror("Imports nested too deeply");
736
 
  instk[imports] = YY_CURRENT_BUFFER;
737
 
  strcpy(fnstk[imports], filename);
738
 
  lnstk[imports] = yylineno;
739
 
  imports++;
740
 
  if (!(yyin = fopen(file, "r")))
741
 
  { if (importpath)
742
 
    { strcpy(buf, importpath);
743
 
      strcat(buf, "/");
744
 
      strcat(buf, file);
745
 
      yyin = fopen(buf, "r");
746
 
    }
747
 
    if (!yyin)
748
 
    { sprintf(errbuf, "#import: Cannot open file \"%s\" for reading", file);
749
 
      execerror(errbuf);
750
 
    }
751
 
  }
752
 
  p = (struct imported*)malloc(sizeof(struct imported) + strlen(file));
753
 
  strcpy(p->name, file);
754
 
  p->next = imported;
755
 
  imported = p;
756
 
  strcpy(filename, file);
757
 
  yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
758
 
}
759
 
#endif