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
|
%{
/*
* lexer.l
*
* (c) Copyright 1988-1994 Adobe Systems Incorporated.
* All rights reserved.
*
* Permission to use, copy, modify, distribute, and sublicense this software
* and its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notices appear in all copies and that
* both those copyright notices and this permission notice appear in
* supporting documentation and that the name of Adobe Systems Incorporated
* not be used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. No trademark license
* to use the Adobe trademarks is hereby granted. If the Adobe trademark
* "Display PostScript"(tm) is used to describe this software, its
* functionality or for any other purpose, such use shall be limited to a
* statement that this software works in conjunction with the Display
* PostScript system. Proper trademark attribution to reflect Adobe's
* ownership of the trademark shall be given whenever any such reference to
* the Display PostScript system is made.
*
* ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
* ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
* ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
* TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
* PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
*
* Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
* Incorporated which may be registered in certain jurisdictions
*
* Author: Adobe Systems Incorporated
*/
/* $XFree86: xc/config/pswrap/lexer.l,v 1.10 2001/10/28 03:32:03 tsi Exp $ */
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "pswpriv.h"
#include "pswparser.h"
/* flex of EMX seems to be too old */
#if defined(FLEX_SCANNER) && !defined(YY_FLEX_LEX_COMPAT) && !defined(__UNIXOS2__)
int yylineno = 1;
#endif
static int parens = 0; /* current paren balancing */
static char *sbody; /* cur pointer into string_temp */
static int curleng = 0; /* current scanned string length */
static int strlineno; /* start line of current string */
static int nonComment = true; /* are we outside C comments? */
static int newLine = true; /* are we starting a new line? */
static int hexstringerrs = 0; /* found an error in this hex string */
int errorCount = 0; /* number of non-fatal errors */
#ifdef PSWDEBUG
int lexdebug = 1; /* debug flag */
#define DEBUGP(x) {if (lexdebug) { fprintf x ; };}
#else /* PSWDEBUG */
#define DEBUGP(x)
#endif /* PSWDEBUG */
#undef YYLMAX
#define YYLMAX 16384
/* ErrIntro prints a standard intro for error messages;
* change it if your system uses something else. We have many options:
*
* to match Macintosh: #define FMT "File \"%s\"; Line %d # "
* to match BSD cc: #define FMT "\"%s\", line %d: "
* to match gcc: #define FMT "%s:%d: "
* to match Mips cc: #define FMT "pswrap: Error: %s, line %d: "
*/
#define INTRO "# In function %s -\n"
#ifdef macintosh
#define FMT "File \"%s\"; Line %d # "
#else /* macintosh */
#define FMT "\"%s\", line %d: "
#endif /* macintosh */
void ErrIntro(int line)
{
if (! reportedPSWName && currentPSWName) {
reportedPSWName = 1;
fprintf(stderr,INTRO,currentPSWName);
}
fprintf(stderr,FMT,ifile,line);
errorCount++;
}
void yyerror(char *errmsg)
{
ErrIntro(yylineno);
fprintf(stderr,"%s near text \"%s\"\n",errmsg,yytext);
}
%}
%o 3500
%a 2500
%START PS STR HEX DEF SUB
DIGIT ([0-9])
HEXDIGIT ([a-fA-F0-9])
RADIXDIGIT ([a-zA-Z0-9])
LETTER ([a-zA-Z])
SIGN ([+-])
EXP ([eE]{SIGN}?{DIGIT}+)
W ([ \t\n\r])
%%
<PS>^defineps { /* inside a wrap - just a PS token */
if (nonComment) {
newLine = false;
yylval.object = psw_malloc(strlen(yytext) + 1);
strcpy(yylval.object, yytext);
DEBUGP((stderr,"PSNAME ->%s\n",yytext));
return PSNAME;
}
}
<DEF>^defineps { /* treat as a C name inside the def part */
if (nonComment) {
yylval.object = psw_malloc(strlen(yytext) + 1);
strcpy(yylval.object, yytext);
DEBUGP((stderr,"CNAME ->%s\n",yytext));
return CNAME;
}
}
<STR>^defineps { /* part of string text */
register int i = yyleng;
register unsigned char *c = (unsigned char *) yytext;
if (yyleng + curleng >= maxstring) {
stringerr(1);
BEGIN PS;
*sbody = '\0';
return PSSTRING;
}
curleng += yyleng;
for (; i > 0; --i) *sbody++ = *c++;
}
^{W}*defineps { /* start of a wrap definition */
if (nonComment) {
BEGIN DEF;
DEBUGP((stderr,"DEFINEPS\n"));
return DEFINEPS;
} else ECHO;
}
<PS>endps { /* end of a wrap */
if (nonComment){
if (newLine) {
newLine = false;
DEBUGP((stderr,"ENDPS\n"));
BEGIN 0;
return ENDPS;
} else {
DEBUGP((stderr,"PSNAME %s\n",yytext));
yylval.object = psw_malloc(strlen(yytext) + 1);
strcpy(yylval.object, yytext);
return PSNAME;
}
}
}
<DEF>^endps { /* treat as a C name inside the def part? */
if (nonComment) {
yylval.object = psw_malloc(strlen(yytext) + 1);
strcpy(yylval.object, yytext);
DEBUGP((stderr,"CNAME ->%s\n",yytext));
return CNAME;
}
}
<STR>^defineps { /* part of string text */
register int i = yyleng;
register unsigned char *c = (unsigned char *) yytext;
if (yyleng + curleng >= maxstring) {
stringerr(1);
BEGIN PS;
*sbody = '\0';
return PSSTRING;
}
curleng += yyleng;
for (; i > 0; --i) *sbody++ = *c++;
}
endps { /* BOGUS end of a wrap */
if (nonComment) {
ErrIntro(yylineno);
fprintf(stderr,"endps without matching defineps\n");
} else ECHO;
}
%{
/* real definition stuff */
%}
<DEF>"/*" { /* C comments on */
nonComment = false;
}
<DEF>"*/" { /* C comments off */
nonComment = true;
}
<DEF>"(" { /* formals start */
if (nonComment) {
DEBUGP((stderr,"DEF ->(\n"));
return '(';
}
}
<DEF>")" { /* formals end */
if (nonComment) {
DEBUGP((stderr,"DEF ->)\n"));
BEGIN PS;
return ')';
}
}
<DEF>[|,;[\]*:] { /* special single chars */
if (nonComment) {
DEBUGP((stderr,"DEF ->%c\n",yytext[0]));
return (yytext[0]);
}
}
%{
/* formals type names */
%}
<DEF>"static" {
if (nonComment) {
DEBUGP((stderr,"DEF ->static\n"));
return STATIC;
}
}
<DEF>"boolean" {
if (nonComment) {
DEBUGP((stderr,"DEF ->boolean\n"));
return BOOLEAN;
}
}
<DEF>"char" {
if (nonComment) {
DEBUGP((stderr,"DEF ->char\n"));
return CHAR;
}
}
<DEF>"int" {
if (nonComment) {
DEBUGP((stderr,"DEF ->int\n"));
return INT;
}
}
<DEF>"short" {
if (nonComment) {
DEBUGP((stderr,"DEF ->short\n"));
return SHORT;
}
}
<DEF>"long" {
if (nonComment) {
DEBUGP((stderr,"DEF ->long\n"));
return LONG;
}
}
<DEF>"unsigned" {
if (nonComment) {
DEBUGP((stderr,"DEF ->unsigned\n"));
return UNSIGNED;
}
}
<DEF>"float" {
if (nonComment) {
DEBUGP((stderr,"DEF ->float\n"));
return FLOAT;
}
}
<DEF>"double" {
if (nonComment) {
DEBUGP((stderr,"DEF ->double\n"));
return DOUBLE;
}
}
<DEF>"userobject" {
if (nonComment) {
DEBUGP((stderr,"DEF ->userobject\n"));
return USEROBJECT;
}
}
<DEF>"numstring" {
if (nonComment) {
DEBUGP((stderr,"DEF ->numstring\n"));
return NUMSTRING;
}
}
<DEF>"DPSContext" {
if (nonComment) {
DEBUGP((stderr,"DEF ->DPScontext\n"));
return PSCONTEXT;
}
}
%{
/* C format numbers in formals part */
%}
<DEF>[1-9]{DIGIT}* { /* base 10 number */
if (nonComment) {
DEBUGP((stderr,"DEF ->CINTEGER %s\n",yytext));
yylval.intobj = atoi((char *) yytext);
return CINTEGER;
}
}
<DEF>0{DIGIT}* { /* octal number (and zero) */
if (nonComment) {
DEBUGP((stderr,"DEF ->CINTEGER %s\n",yytext));
/* I have no idea why the cast is needed in the next line,
but it seems to make the compiler happy on alpha */
sscanf((char *) yytext,"%lo",&yylval.intobj);
return CINTEGER;
}
}
<DEF>0[xX]{HEXDIGIT}+ { /* hex number */
if (nonComment) {
DEBUGP((stderr,"DEF ->CINTEGER %s\n",yytext));
/* See previous comment... */
sscanf((char *) yytext,"0x%lx",&yylval.intobj);
return CINTEGER;
}
}
<DEF>[a-zA-Z_][a-zA-Z0-9_]* { /* C identifier */
if (nonComment) {
DEBUGP((stderr,"DEF ->CNAME %s\n",yytext));
yylval.object = psw_malloc(strlen(yytext) + 1);
strcpy(yylval.object, yytext);
return CNAME;
}
}
<DEF>{W}+ {
}
<DEF>[^a-zA-Z0-9_|,;[\]*:\(\)/ \t\n\r]+ { /* all else - ERROR */
if (nonComment) {
DEBUGP((stderr,"DEF ->JUNK %s\n",yytext));
ErrIntro(yylineno);
fprintf(stderr,"invalid characters '%s' in definition\n",
yytext);
}
}
%{
/* body part - PostScript code */
%}
<PS>\%.* { /* a PS comment, ignore */
if (nonComment) {
newLine = false;
DEBUGP((stderr,"comment %s\n",yytext));
/* yylval = yytext; return PSCOMMENT; */
}
}
<PS>{SIGN}?{DIGIT}+ { /* a decimal integer */
if (nonComment) {
newLine = false;
DEBUGP((stderr,"PSINTEGER ->%s\n",yytext));
yylval.intobj = atoi((char *) yytext);
return PSINTEGER;
}
}
<PS>{DIGIT}+#{RADIXDIGIT}+ { /* a radix number */
#define MAX_ULONG ((unsigned long) -1)
unsigned base = 0;
unsigned char *s = (unsigned char *) yytext;
register unsigned long x, limit;
register unsigned long i = 0;
if (nonComment) {
newLine = false;
DEBUGP((stderr,"PSINTEGER radix->%s\n",yytext));
while (*s != '#') {
base *= 10;
base += *s++ - '0';
if (base > 32) break;
}
if ((base < 2) || (base > 36)) {goto error;}
else {
limit = MAX_ULONG / base;
s++; /* skip # sign */
while (*s != '\0') {
if (i > limit) goto error;
i *= base;
if (isdigit(*s)) { x = *s - '0';}
else { x = (*s | 040) - ('a'-10);}
if (x >= base) goto error;
if (x > (MAX_ULONG - i)) goto error;
i += x;
s++;
}
}
yylval.intobj = i;
return PSINTEGER;
error:;
ErrIntro(yylineno);
fprintf(stderr,"invalid radix number %s\n",yytext);
yylval.intobj = 0; /* ERROR */
return PSINTEGER;
}
}
<PS>(({SIGN}?{DIGIT}+(\.{DIGIT}*)?{EXP}?)|({SIGN}?{DIGIT}*\.{DIGIT}+{EXP}?)) {
/* a float */
if (nonComment) {
newLine = false;
DEBUGP((stderr,"PSREAL ->%s\n",yytext));
yylval.object = psw_malloc(strlen(yytext) + 1);
strcpy(yylval.object,yytext);
return PSREAL;
}
}
<PS>"(" { /* start PS string */
if (nonComment) {
newLine = false;
BEGIN STR;
parens=1;
sbody = string_temp;
curleng = 0;
strlineno = yylineno;
*sbody = '\0';
}
}
%{
/* inside PS strings */
%}
<STR>"(" { /* balancing parens */
if (yyleng + curleng >= maxstring) {
stringerr(1);
BEGIN PS;
*sbody = '\0';
return PSSTRING;
}
curleng += yyleng;
parens++;
*sbody++ = '(';
}
<STR>")" { /* balancing parens or end string */
if ((--parens) == 0) {
BEGIN PS;
*sbody = '\0';
yylval.object = psw_malloc(strlen(string_temp) + 1);
strcpy(yylval.object, string_temp);
DEBUGP((stderr,"PSSTRING ->%s\n",string_temp));
return PSSTRING;
}
else if (yyleng + curleng >= maxstring) {
stringerr(1);
BEGIN PS;
*sbody = '\0';
return PSSTRING;
}
curleng += yyleng;
*sbody++ = ')';
}
<STR>"\\"[0-7]([0-7]?)([0-7]?) { /* quoted octal byte */
if (4 + curleng >= maxstring) {
stringerr(1);
BEGIN PS;
*sbody = '\0';
return PSSTRING;
}
curleng += 4;
sprintf(sbody,"\\%3.3s",(yytext + 1));
while (*sbody) {
if (*sbody == ' ') *sbody = '0';
sbody++;
}
}
<STR>"\\\n" { /* ignore quoted newline */
}
<STR>"\\\\" { /* keep quoted backslashes in */
if (yyleng + curleng >= maxstring) {
stringerr(1);
BEGIN PS;
*sbody = '\0';
return PSSTRING;
}
*sbody++ = '\\';
*sbody++ = '\\';
curleng += 2;
}
<STR>("\\".) { /* other quoted char, including parens */
if (yyleng + curleng >= maxstring) {
stringerr(1);
BEGIN PS;
*sbody = '\0';
return PSSTRING;
}
switch (yytext[1]) {
case 'b':
*sbody++ = '\b';
break;
case 'f':
*sbody++ = '\f';
break;
case 'n':
*sbody++ = '\012';
break;
case 'r':
*sbody++ = '\015';
break;
case 't':
*sbody++ = '\t';
break;
default:
*sbody++ = yytext[1];
break;
}
curleng++;
}
<STR>"\n" { /* newline in a string */
if (yyleng + curleng >= maxstring) {
stringerr(1);
BEGIN PS;
*sbody = '\0';
return PSSTRING;
}
curleng += yyleng;
*sbody++ = '\n';
}
<STR>[^()\\\n]+ { /* anything else */
register int i = yyleng;
register unsigned char *c = (unsigned char *) yytext;
if (yyleng + curleng >= maxstring) {
stringerr(1);
BEGIN PS;
*sbody = '\0';
return PSSTRING;
}
curleng += yyleng;
for (; i > 0; --i) *sbody++ = *c++;
}
%{
/* hexidecimal strings "< >" */
%}
<PS>"<" { /* begin hex string */
if (nonComment) {
newLine = false;
BEGIN HEX;
sbody = string_temp;
*sbody = '\0';
curleng = 0;
strlineno = yylineno;
hexstringerrs = 0;
}
}
<HEX>{W}+ { /* hex whitespace */
/* ignore */
}
<HEX>[0-9A-Fa-f]+ { /* hex string data */
if (yyleng + curleng >= maxstring) {
stringerr(2);
*sbody = '\0';
BEGIN PS;
return PSHEXSTRING;
}
curleng += yyleng;
strcpy(sbody,yytext);
sbody += yyleng;
}
<HEX>">" { /* end hex string */
BEGIN PS;
*sbody = '\0';
DEBUGP((stderr,"PSHEXSTRING ->%s\n",string_temp));
yylval.object = psw_malloc(strlen(string_temp) + 1);
strcpy(yylval.object, string_temp);
return PSHEXSTRING;
}
<HEX>[^a-fA-F0-9> \t\n\r]+ { /* ERROR */
if (hexstringerrs == 0) { /* only complain once per string */
ErrIntro(yylineno);
fprintf(stderr,"invalid characters in hex string '%s'\n",yytext);
hexstringerrs++;
}
}
%{
/* straight postscript */
%}
<PS>"<<" { /* just a PS token (for level 2 compatablity) */
if (nonComment) {
newLine = false;
yylval.object = psw_malloc(strlen(yytext) + 1);
strcpy(yylval.object, yytext);
DEBUGP((stderr,"PSNAME ->%s\n",yytext));
return PSNAME;
}
}
<PS>">>" { /* just a PS token (for level 2 compatablity) */
if (nonComment) {
newLine = false;
yylval.object = psw_malloc(strlen(yytext) + 1);
strcpy(yylval.object, yytext);
DEBUGP((stderr,"PSNAME ->%s\n",yytext));
return PSNAME;
}
}
<PS>[\[\]\{\}] { /* PS self delimiter */
if (nonComment) {
newLine = false;
DEBUGP((stderr,"PS ->%s\n",yytext));
return (yytext[0]);
}
}
<PS>"true"|"false" { /* boolean */
if (nonComment) {
newLine = false;
DEBUGP((stderr,"PSBOOLEAN %s\n",yytext));
yylval.intobj = (*yytext == 't');
return PSBOOLEAN;
}
}
<PS>"/"[^ <>\(\)\[\]\{\}\%\/\t\n\r]* { /* literal name */
if (nonComment) {
newLine = false;
DEBUGP((stderr,"PSLITNAME %s\n",yytext));
yylval.object = psw_malloc(strlen(yytext));
strcpy(yylval.object, yytext+1);
return PSLITNAME;
}
}
<PS>[^ <>\(\)\[\]\{\}\%\/\\\t\n\r]+ { /* executable name */
if (nonComment) {
newLine = false;
DEBUGP((stderr,"PSNAME %s\n",yytext));
yylval.object = psw_malloc(strlen(yytext) + 1);
strcpy(yylval.object, yytext);
return PSNAME;
}
}
<PS>"*/" { /* special case */
if (nonComment) {
newLine = false;
unput('/');
yylval.object = psw_malloc(2);
strcpy(yylval.object, "*");
return PSNAME;
}
}
<PS>"\\"[^ <>\(\)\[\]\{\}\%\/\\\t\n\r]+/"[" { /* \name[index] */
if (nonComment) {
DEBUGP((stderr,"\\PSNAME %s\n",yytext));
yylval.object = psw_malloc(strlen(yytext));
strcpy(yylval.object, yytext+1);
BEGIN SUB;
return PSSUBNAME;
}
}
<SUB>[\[][^ \t\]]*[\]] { /* [index] */
if (nonComment) {
int len = strlen(yytext);
DEBUGP((stderr,"PSINDEX %s\n",yytext));
if (len == 2) {
ErrIntro(yylineno);
fprintf(stderr,"parameter index expression empty\n");
yylval.object = "0";
}
else {
yylval.object = psw_malloc(len);
strncpy(yylval.object, yytext+1, len-2);
yylval.object[len-2] = '\0';
}
BEGIN PS;
return PSINDEX;
}
}
<SUB>[\[][^\]]*[\]] { /* error */
if (nonComment) {
ErrIntro(yylineno);
fprintf(stderr,"parameter index expression error\n");
yylval.object = "0";
BEGIN PS;
return PSINDEX;
}
}
<PS>[\)\>\\]+ { /* ERROR */
if (nonComment) {
newLine = false;
DEBUGP((stderr,"PS JUNK ->%s\n",yytext));
ErrIntro(yylineno);
fprintf(stderr,"invalid characters '%s'\n",yytext);
}
}
<PS>[ \t\r]+ { }
<PS>[\n]+ {
newLine = true;
}
[ \t]+ { /* passthru stuff */
ECHO;
}
\n {
outlineno++;
ECHO;
};
"/*" { /* C comments on */
nonComment = false;
ECHO;
}
"*/" { /* C comments off */
if (!nonComment) {
nonComment = true;
ECHO;
}
}
%%
int yywrap (void) {
if (!feof(yyin))
return (0);
/* The following appears not to work with flex. As it is error
handling code, we just comment it out. */
#if !defined(FLEX_SCANNER)
if (yybgin != (yysvec+1)) { /* make sure we are in state 0 */
ErrIntro(yylineno);
fprintf(stderr,"end of input file/missing endps\n");
}
#endif
return (1);
}
void stringerr(int type)
{
ErrIntro(strlineno);
fprintf(stderr,"%sstring too long (caught at line %d)\n",
((type==1)?"":"hex "),yylineno);
errorCount++;
return;
}
|