-
Notifications
You must be signed in to change notification settings - Fork 22
/
lex.c
2537 lines (2362 loc) · 63.6 KB
/
lex.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* vim: set ts=8 : */
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include "config.h"
#include "instrs.h"
#include "lint.h"
#include "lang.h"
#include "string.h"
#include "interpret.h"
#include "exec.h"
#include "lex.h"
#include "mstring.h"
#include "mudstat.h"
#include "simulate.h"
#include "efun_table.h"
#include "backend.h"
#include "hash.h"
#define isalunum(c) (isalnum(c) || (c) == '_')
#define NELEM(a) (sizeof (a) / sizeof((a)[0]))
#define WARNING 0
#define ERROR 1
int current_line;
int total_lines; /* Used to compute average compiled lines/s */
char *current_file;
int pragma_strict_types; /* Force usage of strict types. */
int pragma_no_clone;
int pragma_no_inherit;
int pragma_no_shadow;
int pragma_resident;
extern void smart_log (char *, int, char *);
struct lpc_predef_s *lpc_predefs=NULL;
static void handle_define (char *);
static void free_defines (void), add_define (char *, int, char *);
static int expand_define (void);
static void add_input (char *);
static void myungetc (int);
static int lookup_resword (char *);
static int cond_get_exp (int);
static int exgetc (void);
static void refill (void);
static int cmygetc (void);
static int yylex1 (void);
static void skip_comment (void);
static void skip_comment2 (void);
static INLINE int mygetc (void);
static int number (const long long);
static int real (const double);
static int ident (const char *);
static int string (const char *);
static FILE *yyin;
static int lex_fatal;
static char **inc_list;
static int inc_list_size;
struct allocation_pool lex_allocations = EMPTY_ALLOCATION_POOL;
#define EXPANDMAX 25000
static int nexpands;
extern int s_flag;
#ifndef tolower
extern int tolower (int);
#endif
void yyerror(char *);
int yylex (void);
#define MAXLINE 1024
static char yytext[MAXLINE];
static int slast, lastchar;
static int num_incfiles, current_incfile, incdepth;
struct defn {
struct defn *next;
char *name;
int undef;
char *exps;
int nargs;
};
struct defn *lookup_define(char *);
static struct ifstate {
struct ifstate *next;
int state;
} *iftop = 0;
#define EXPECT_ELSE 1
#define EXPECT_ENDIF 2
static struct incstate {
struct incstate *next;
FILE *yyin;
int incfnum;
int line;
char *file;
int slast, lastchar;
int pragma_strict_types;
int nbuf;
char *outp;
} *inctop = 0;
/* DEFMAX must be even. We divide it by 2 in mygetc(). */
#define DEFMAX 20000
static char defbuf[DEFMAX];
static int nbuf;
static char *outp;
static struct {
int token;
int line;
YYSTYPE lval;
} keep1, keep2, keep3, keep4;
static void
calculate_include_path(char *name, char *dest)
{
char *current;
if ( (current = strrchr(dest, '/')) == NULL) /* strip filename */
{
/* current_file is in the root directory */
current = dest;
}
*current = '\0';
while (*name == '/')
{
name++;
current = dest;
*current = '\0'; /* absolute path */
}
while (*name)
{
if (strncmp(name, "../", 3) == 0)
{
if (*dest == '\0') /* including from above mudlib is NOT allowed */
break;
/* Remove previous path element */
while (current > dest)
{
*current-- = '\0';
if (*current == '/')
break;
}
if (current == dest)
{
*current = '\0';
}
name += 3; /* skip "../" */
}
else if (strncmp(name, "./", 2) == 0)
{
name += 2;
}
else
{ /* append first component to dest */
if (*dest)
*current++ = '/'; /* only if dest is not empty !! */
while (*name != '\0' && *name != '/')
*current++ = *name++;
if (*name == '/')
name++;
else
*current = '\0'; /* Last element */
}
}
}
static INLINE int
mygetc(void)
{
if (!nbuf)
{
char buffer[(DEFMAX / 2) + 1];
if (feof(yyin))
{
return EOF;
}
nbuf = (int)fread(buffer, sizeof(char), (DEFMAX / 2), yyin);
if (!nbuf)
{
return EOF;
}
outp -= nbuf;
memcpy(outp, buffer, nbuf);
}
lastchar = slast;
slast = *outp;
nbuf--;
outp++;
return slast;
}
static INLINE int
gobble(int c)
{
int d;
d = mygetc();
if (c == d)
return 1;
*--outp = d;
nbuf++;
return 0;
}
__attribute__((format(printf, 1, 2)))
static void
lexerror(char *fmt, ...)
{
char buffer[1024];
va_list ap;
va_start(ap, fmt);
vsnprintf(buffer, sizeof(buffer), fmt, ap);
yyerror(buffer);
va_end(ap);
lex_fatal++;
}
static void
lexwarning(char *str)
{
(void)fprintf(stderr, "/%s: Warning: %s line %d\n", current_file, str,
current_line);
(void)fflush(stderr);
smart_log(current_file, current_line, str);
}
static int
skip_to(char *token, char *atoken)
{
char b[20], *p;
int c;
int nest;
for (nest = 0;;)
{
c = mygetc();
if (c == '#')
{
do
{
c = mygetc();
} while (isspace(c));
for (p = b; c != '\n' && c != EOF; )
{
if (p < b+sizeof b-1)
*p++ = c;
c = mygetc();
}
*p++ = 0;
for (p = b; *p && !isspace(*p); p++)
;
*p = 0;
/*(void)fprintf(stderr, "skip checks %s\n", b);*/
if (strcmp(b, "if") == 0 || strcmp(b, "ifdef") == 0 ||
strcmp(b, "ifndef") == 0)
{
nest++;
}
else if (nest > 0)
{
if (strcmp(b, "endif") == 0)
nest--;
}
else
{
if (strcmp(b, token) == 0)
return 1;
else if (atoken && strcmp(b, atoken) == 0)
return 0;
}
}
else
{
/*(void)fprintf(stderr, "skipping (%d) %c", c, c);*/
while (c != '\n' && c != EOF)
{
c = mygetc();
/*(void)fprintf(stderr, "%c", c);*/
}
if (c == EOF)
{
lexerror("Unexpected end of file while skipping");
return 1;
}
}
store_line_number_info(current_incfile, current_line);
current_line++;
total_lines++;
}
}
static void
handle_cond(int c)
{
struct ifstate *p;
/*(void)fprintf(stderr, "cond %d\n", c);*/
if (c || skip_to("else", "endif"))
{
p = (struct ifstate *)xalloc(sizeof(struct ifstate));
p->next = iftop;
iftop = p;
p->state = c ? EXPECT_ELSE : EXPECT_ENDIF;
}
if (!c)
{
store_line_number_info(current_incfile, current_line);
current_line++;
total_lines++;
}
}
/* Make sure the path does not have any ".." elements. */
char *
check_valid_compile_path(char *path, char *file_name, char *calling_function)
{
#if 0
struct svalue *ret;
#endif
char *p = path;
while (*p)
{
if (p[0] == '.' && p[1] == '.')
return NULL;
p++;
}
#if 0
push_string(path, STRING_MSTRING);
push_string(file_name, STRING_MSTRING);
push_string(calling_function, STRING_MSTRING);
ret = apply_master_ob(M_VALID_COMPILE_PATH, 3);
if (ret)
path = tmpstring_copy(ret->u.string);
#endif
return path;
}
/* Try to load the file who's full path is specified in buf */
static INLINE FILE *
inc_try(char *buf)
{
struct incstate *inc;
char errbuf[1024];
char *new_name;
FILE *f;
extern void remember_include(char *);
extern char *current_loaded_file;
new_name = check_valid_compile_path(buf, current_loaded_file, "include");
if (!new_name)
{
lexerror("Invalid include.");
return NULL;
}
if (new_name && (f = fopen(new_name, "r")) != NULL)
{
#ifdef WARN_INCLUDES
for (inc = inctop ; inc ; inc = inc->next)
if (strcmp(inc->file, new_name) == 0)
{
(void)snprintf(errbuf, sizeof(errbuf), "File /%s already included,", buf);
lexwarning(errbuf);
}
#endif
if (s_flag)
num_fileread++;
remember_include(new_name);
return f;
}
return NULL;
}
/* Find and open a file that has been specified in a "#include <file>" */
static INLINE FILE *
inc_open(char *buf, size_t len, char *name)
{
int i;
FILE *f;
if (incdepth >= MAX_INCLUDE)
{
lexerror("To deep recursion of includes.");
return NULL;
}
(void)strcpy(buf, current_file);
calculate_include_path(name, buf);
if ((f = inc_try(buf)) != NULL)
return f;
/*
* Search all include dirs specified.
*/
for (i = 0; i < inc_list_size; i++)
{
(void)snprintf(buf, len, "%s%s", inc_list[i], name);
if ((f = inc_try(buf)) != NULL)
return f;
}
return NULL;
}
int
handle_include(char *name, int ignore_errors)
{
char *p;
char buf[1024];
FILE *f;
struct incstate *is;
int delim;
if (*name != '"' && *name != '<')
{
struct defn *d;
if ((d = lookup_define(name)) && d->nargs == -1)
{
char *q;
q = d->exps;
while (isspace(*q))
q++;
return handle_include(q, ignore_errors);
}
else
{
if (!ignore_errors)
lexerror("Missing leading \" or < in #include");
return 0;
}
}
delim = *name++ == '"' ? '"' : '>';
for (p = name; *p && *p != delim; p++)
;
if (!*p)
{
if (!ignore_errors)
lexerror("Missing trailing \" or > in #include");
return 0;
}
if (strlen(name) > sizeof(buf) - 100)
{
if (!ignore_errors)
lexerror("Include name too long.");
return 0;
}
*p = 0;
if ((f = inc_open(buf, sizeof(buf), name)) == NULL)
{
if (!ignore_errors) {
lexerror("Cannot #include %s\n", name);
}
return 0;
}
is = (struct incstate *)xalloc(sizeof(struct incstate));
is->yyin = yyin;
is->line = current_line;
is->file = current_file;
is->incfnum = current_incfile;
is->slast = slast;
is->lastchar = lastchar;
is->next = inctop;
is->pragma_strict_types = pragma_strict_types;
if (nbuf)
{
memcpy(is->outp = (char *)xalloc(nbuf + 1), outp, nbuf);
is->nbuf = nbuf;
nbuf = 0;
outp = defbuf + DEFMAX;
}
else
{
is->nbuf = 0;
is->outp = NULL;
}
pragma_strict_types = 0;
inctop = is;
current_line = 1;
current_file = xalloc(strlen(buf)+1);
current_incfile = ++num_incfiles;
(void)strcpy(current_file, buf);
slast = lastchar = '\n';
yyin = f;
incdepth++;
return 1;
}
static void
handle_exception(int action, char *message)
{
char buf[1024];
(void)strcpy(buf, "\"");
if (strlen(message) < 2)
(void)strcat(buf, "Unspecified condition");
else
(void)strcat(buf, message);
(void)strcat(buf, "\"");
push_number(action);
push_string(buf, STRING_MSTRING);
push_number(current_line);
push_string(current_file, STRING_MSTRING);
(void)apply_master_ob(M_PARSE_EXCEPTION, 4);
if (action == ERROR)
lexerror("Parse aborted on #error statement,");
}
static void
skip_comment(void)
{
int c;
for (;;)
{
while ((c = mygetc()) != '*')
{
if (c == EOF)
{
lexerror("End of file in a comment");
return;
}
if (c == '\n')
{
nexpands=0;
store_line_number_info(current_incfile, current_line);
current_line++;
}
}
do
{
if ((c = mygetc()) == '/')
return;
if (c == '\n')
{
nexpands=0;
store_line_number_info(current_incfile, current_line);
current_line++;
}
} while (c == '*');
}
}
static void
skip_comment2(void)
{
int c;
while ((c = mygetc()) != '\n' && c != EOF)
;
if (c == EOF) {
lexerror("End of file in a // comment");
return;
}
nexpands=0;
store_line_number_info(current_incfile, current_line);
current_line++;
}
#define TRY(c, t) if (gobble(c)) return t
static void
deltrail(char *ap)
{
char *p = ap;
if (!*p)
{
lexerror("Illegal # command");
}
else
{
while (*p && !isspace(*p))
p++;
*p = 0;
}
}
#define SAVEC \
if (yyp < yytext+MAXLINE-5)\
*yyp++ = c;\
else {\
lexerror("Line too long");\
break;\
}
static void
handle_pragma(char *str)
{
if (strcmp(str, "strict_types") == 0)
pragma_strict_types = 1;
else if (strcmp(str, "save_binary") == 0)
;
else if (strcmp(str, "no_clone") == 0)
pragma_no_clone = 1;
else if (strcmp(str, "no_inherit") == 0)
pragma_no_inherit = 1;
else if (strcmp(str, "no_shadow") == 0)
pragma_no_shadow = 1;
else if (strcmp(str, "resident") == 0)
pragma_resident = 1;
else
handle_exception(WARNING, "Unknown pragma");
}
static struct keyword {
char *word;
short token;
short min_args; /* Minimum number of arguments. */
short max_args; /* Maximum number of arguments. */
short ret_type; /* The return type used by the compiler. */
unsigned char arg_type1; /* Type of argument 1 */
unsigned char arg_type2; /* Type of argument 2 */
unsigned char arg_index;
/* Index pointing to where to find arg type */
short Default; /* an efun to use as default for last argument */
} predefs[] =
#include "efun_defs.c"
static struct keyword reswords[] = {
{ "break", F_BREAK, },
{ "case", F_CASE, },
{ "catch", F_CATCH, },
{ "continue", F_CONTINUE, },
{ "default", F_DEFAULT, },
{ "do", F_DO, },
{ "else", F_ELSE, },
{ "float", F_FLOAT, },
{ "for", F_FOR, },
{ "foreach", F_FOREACH, },
{ "function", F_FUNCTION, },
{ "if", F_IF, },
{ "inherit", F_INHERIT, },
{ "int", F_INT, },
{ "mapping", F_MAPPING, },
{ "mixed", F_MIXED, },
{ "nomask", F_NO_MASK, },
{ "object", F_OBJECT, },
{ "operator", F_OPERATOR, },
{ "parse_command", F_PARSE_COMMAND, },
{ "private", F_PRIVATE, },
{ "public", F_PUBLIC, },
{ "return", F_RETURN, },
{ "sscanf", F_SSCANF, },
{ "static", F_STATIC, },
{ "status", F_STATUS, },
{ "string", F_STRING_DECL, },
{ "switch", F_SWITCH, },
{ "throw", F_THROW },
{ "try", F_TRY, },
{ "varargs", F_VARARGS, },
{ "void", F_VOID, },
{ "while", F_WHILE, },
};
struct instr instrs[EFUN_LAST - EFUN_FIRST + 1];
static int
lookupword(char *s, struct keyword *words, int h)
{
int i, l, r;
l = 0;
for (;;)
{
i = (l + h) / 2;
r = strcmp(s, words[i].word);
if (r == 0)
return words[i].token;
else if (l == i)
return -1;
else if (r < 0)
h = i;
else
l = i;
}
}
static INLINE int
lookup_resword(char *s)
{
return lookupword(s, reswords, NELEM(reswords));
}
static int
yylex1(void)
{
register char *yyp;
register int c;
register int c1, c2;
for (;;)
{
if (lex_fatal)
{
return -1;
}
switch(c = mygetc())
{
case EOF:
if (inctop)
{
struct incstate *p;
p = inctop;
(void)fclose(yyin);
/*(void)fprintf(stderr, "popping to %s\n", p->file);*/
free(current_file);
nexpands = 0;
current_file = p->file;
current_line = p->line + 1;
current_incfile = p->incfnum;
pragma_strict_types = p->pragma_strict_types;
yyin = p->yyin;
slast = p->slast;
lastchar = p->lastchar;
inctop = p->next;
if (p->nbuf)
{
nbuf = p->nbuf;
outp = defbuf + DEFMAX - nbuf;
memcpy(outp, p->outp, nbuf);
free((char *)p->outp);
}
else
{
nbuf = 0;
outp = defbuf + DEFMAX;
}
store_line_number_info(current_incfile, current_line);
incdepth--;
free((char *)p);
break;
}
if (iftop)
{
struct ifstate *p = iftop;
lexerror(p->state == EXPECT_ENDIF ? "Missing #endif" : "Missing #else");
while (iftop)
{
p = iftop;
iftop = p->next;
free((char *)p);
}
}
return -1;
case '\n':
{
nexpands=0;
store_line_number_info(current_incfile, current_line);
current_line++;
total_lines++;
}
/* FALLTHROUGH */
case ' ':
case '\t':
case '\f':
case '\v':
break;
case '+':
TRY('+', F_INC);
TRY('=', F_ADD_EQ);
return c;
case '-':
TRY('>', F_ARROW);
TRY('-', F_DEC);
TRY('=', F_SUB_EQ);
return c;
case '&':
TRY('&', F_LAND);
TRY('=', F_AND_EQ);
return c;
case '|':
TRY('|', F_LOR);
TRY('=', F_OR_EQ);
return c;
case '^':
TRY('=', F_XOR_EQ);
return c;
case '<':
if (gobble('<')) {
TRY('=', F_LSH_EQ);
return F_LSH;
}
TRY('=', F_LE);
return c;
case '>':
if (gobble('>'))
{
TRY('=', F_RSH_EQ);
return F_RSH;
}
TRY('=', F_GE);
return c;
case '*':
TRY('=', F_MULT_EQ);
return c;
case '%':
TRY('=', F_MOD_EQ);
return F_MOD;
case '/':
if (gobble('*'))
{
skip_comment();
break;
}
else if (gobble('/'))
{
skip_comment2();
break;
}
TRY('=', F_DIV_EQ);
return c;
case '=':
TRY('=', F_EQ);
return c;
case ';':
case '(':
case ')':
case ',':
case '{':
case '}':
case '~':
case '[':
case ']':
case '?':
case '@':
return c;
case '!':
TRY('=', F_NE);
return F_NOT;
case ':':
TRY(':', F_COLON_COLON);
return ':';
case '.':
if (gobble('.'))
{
if (gobble('.'))
return F_VARARG;
else
return F_RANGE;
}
return c;
case '#':
if (lastchar == '\n')
{
char *ssp = 0;
int quote;
yyp = yytext;
do
{
c = mygetc();
} while (isspace(c));
for (quote = 0;;)
{
if (c == '"')
quote ^= 1;
/*gc - handle comments cpp-like! 1.6.91 @@@*/
while (!quote && c == '/')
{
if (gobble('*'))
{
skip_comment();
c = mygetc();
}
else
break;
}
if (!ssp && isspace(c))
ssp = yyp;
if (c == '\n' || c == EOF)
break;
SAVEC;
c = mygetc();
}
if (ssp)
{
*ssp++ = 0;
while (isspace(*ssp))
ssp++;
}
else
{
ssp = yyp;
}
*yyp = 0;
if (strcmp("define", yytext) == 0)
{
handle_define(ssp);
}
else if (strcmp("if", yytext) == 0)
{
#if 0
short int nega=0; /*@@@ allow #if !VAR gc 1.6.91*/
if (*ssp=='!'){ ssp++; nega=1;}
if (isdigit(*ssp))
{
char *p;
long l;
l = strtol(ssp, &p, 10);
while (isspace(*p))
p++;
if (*p)
lexerror("Condition too complex in #if");
else
handle_cond(nega ? !(int)l : (int)l);
}
else if (isalunum(*ssp))
{
char *p = ssp;
while (isalunum(*p))
p++;
if (*p)
{
*p++ = 0;
while (isspace(*p))
p++;
}
if (*p)
lexerror("Condition too complex in #if");
else
{
struct defn *d;
d = lookup_define(ssp);
if (d)
{
handle_cond(nega ? !atoi(d->exps) : atoi(d->exps));/* a hack! */
}
else
{
handle_cond(nega?1:0); /* cpp-like gc*/
}
}
}
else
lexerror("Condition too complex in #if");
#else
int cond;
myungetc(0);
add_input(ssp);
cond = cond_get_exp(0);
if (mygetc())
{
lexerror("Condition too complex in #if");
while (mygetc())
;
}
else
handle_cond(cond);
#endif
}
else if (strcmp("ifdef", yytext) == 0)
{
deltrail(ssp);
handle_cond(lookup_define(ssp) != 0);
}
else if (strcmp("ifndef", yytext) == 0)
{
deltrail(ssp);
handle_cond(lookup_define(ssp) == 0);
}
else if (strcmp("else", yytext) == 0)
{
if (iftop && iftop->state == EXPECT_ELSE)