1 /*
2 HEADER: ;
3 TITLE: Frankenstein Cross Assemblers;
4 VERSION: 2.0;
5 DESCRIPTION: " Reconfigurable Cross-assembler producing Intel (TM)
6 Hex format object records. ";
7 KEYWORDS: cross-assemblers, 1805, 2650, 6301, 6502, 6805, 6809,
8 6811, tms7000, 8048, 8051, 8096, z8, z80;
9 SYSTEM: UNIX, MS-Dos ;
10 FILENAME: fryylex.c;
11 WARNINGS: "This software is in the public domain.
12 Any prior copyright claims are relinquished.
13
14 This software is distributed with no warranty whatever.
15 The author takes no responsibility for the consequences
16 of its use.
17
18 Yacc (or Bison) required to compile." ;
19 SEE-ALSO: as*.y (yacc input files);
20 AUTHORS: Mark Zenier;
21 COMPILERS: Microport Sys V/AT, ATT Yacc, Turbo C V1.5, Bison (CUG disk 285)
22 (previous versions Xenix, Unisoft 68000 Version 7, Sun 3);
23 */
24
25
26 /*
27 description lexical analyzer for framework cross assembler
28 usage Framework cross assembler, Unix
29 history September 13, 1987
30 September 14, 1990 Dosify, 6 char unique names
31 October, 1990 hand carved scanner
32 */
33
34 #include "config.h"
35 #include "lzoe/lzoe.h"
36 #include "file/file.h"
37 #include "frasmdat.h"
38 #include "fraytok.h"
39 #include "as1600_types.h"
40 #include "protos.h"
41 #include "intermed.h"
42 #include "../imasm/c_wrap.h"
43
44 #ifndef DEBUG
45 #define DEBUG 0
46 #endif
47
48 extern YYSTYPE yylval;
49
50 enum symflag {Symopcode, Symsym} whichsym = Symopcode;
51
52 enum labelarrayflag { LAno, LAmaybe, LAyes } labelarray = LAno;
53
54 LZFILE *yyin;
55
56 static char *fryybuf = NULL;
57 static int fryy_bs = 0;
58 static char *frainptr = NULL;
59
60 enum readacts nextreadact = Nra_normal;
61
62 enum If_Mode elseifstk[IFSTKDEPTH], endifstk[IFSTKDEPTH];
63 int expmacstk[IFSTKDEPTH];
64 struct fstkel infilestk[FILESTKDPTH];
65 int currfstk;
66
67 struct rptlist
68 {
69 struct rptlist *next;
70 char *buf;
71 int len;
72 int line;
73 };
74
75 struct rptstack
76 {
77 struct rptlist *head;
78 int num;
79 int cnt;
80 int skip;
81 };
82
83 #define MAXRPTNEST (16)
84
85 static struct rptstack rpt[MAXRPTNEST];
86 static int frarptnum = 0, frarptstarting = FALSE;
87
88 static struct rptlist *rpt_curr = NULL, *rpt_head = NULL, *rpt_tail = NULL;
89
frarptpop(void)90 LOCAL void frarptpop(void)
91 /*
92 description: deletes the current "repeat line" buffer
93 return nothing
94 */
95 {
96 struct rptlist *curr, *prev;
97
98 if (frarptact == 0)
99 {
100 fraerror("ENDR without active REPEAT");
101 return;
102 }
103
104 frarptact--;
105
106 frarptnum = rpt[frarptact].num;
107 frarptcnt = rpt[frarptact].cnt;
108 frarptskip = rpt[frarptact].skip;
109
110 /* If popping last level of nested REPEAT, delete loop buffer text */
111 if (!frarptact)
112 {
113 curr = rpt_head;
114
115 while (curr)
116 {
117 prev = curr;
118 curr = curr->next;
119 free(prev->buf);
120 free(prev);
121 }
122
123 rpt_head = rpt_tail = rpt_curr = NULL;
124 }
125 }
126
frarptnxt()127 int frarptnxt()
128 /*
129 description: return next line from repeat buffer.
130 return TRUE got a line
131 FALSE no line available from loop buffer
132 */
133 {
134 /* If no current line, can't return anything from loop buffer. */
135 if (rpt_curr == NULL)
136 return FALSE;
137
138 /* Remember the first line of a REPEAT block. */
139 if (frarptstarting)
140 {
141 assert(frarptact > 0);
142 frarptstarting = FALSE;
143 rpt[frarptact - 1].head = rpt_curr;
144 }
145
146 /* Return next line from loop buffer, if available. */
147 assert(rpt_curr->len < fryy_bs);
148 strcpy(fryybuf, rpt_curr->buf);
149
150 /* Fake our current line number. */
151 infilestk[currfstk].line = rpt_curr->line;
152
153 /* Move to next pointer. */
154 rpt_curr = rpt_curr->next;
155
156 return 1;
157 }
158
frarptadd(char * buf)159 void frarptadd(char *buf)
160 /*
161 description: add a line onto the repeat buffer chain.
162 return nothing
163 */
164 {
165 struct rptlist *line;
166
167 /* Append line to the loop buffer */
168 line = CALLOC(struct rptlist, 1);
169 line->buf = strdup(buf);
170 line->len = strlen(buf);
171 line->line = infilestk[currfstk].line;
172 line->next = NULL;
173
174 if (!rpt_head) rpt_head = line;
175 if ( rpt_tail) rpt_tail->next = line;
176 rpt_tail = line;
177
178 /* Remember the first line of a REPEAT block */
179 if (frarptstarting)
180 {
181 assert(frarptact > 0);
182 frarptstarting = FALSE;
183 rpt[frarptact - 1].head = line;
184 }
185 }
186
frarptbreak(void)187 void frarptbreak(void)
188 {
189 /* If we're breaking out of current iteration, just neuter until ENDR */
190 frarptskip = 1;
191 frarptcnt = 0;
192 emit_comment(0, " Break Taken");
193 }
194
frarptendr()195 void frarptendr() /* begin actually looping repeat block */
196 {
197 if (frarptact <= 0)
198 {
199 fraerror("Unexpected ENDR");
200 return;
201 }
202
203 /* Count down the repeat block, and increment our interation number */
204 frarptcnt--;
205 frarptnum++;
206
207 /* Output what the current loop iteration number is */
208 emit_comment(0, " ;== %d", frarptnum);
209
210 /* If loop expires, pop to previous level. Otherwise, rewind curr to */
211 /* head of current repeat loop. */
212 if (frarptcnt < 0) frarptpop();
213 else rpt_curr = rpt[frarptact - 1].head;
214 }
215
frarptpush(int rptcnt)216 void frarptpush(int rptcnt)
217 {
218 if (frarptact >= MAXRPTNEST)
219 {
220 fraerror("Maximum REPEAT nesting exceeded");
221 return;
222 }
223
224 rpt[frarptact].num = frarptnum;
225 rpt[frarptact].cnt = frarptcnt;
226 rpt[frarptact].skip = frarptskip;
227 frarptact++;
228
229 frarptnum = 0;
230 frarptcnt = rptcnt - 1;
231 frarptskip = rptcnt == 0;
232 frarptstarting = TRUE;
233 }
234
frarptreset(void)235 void frarptreset(void)
236 {
237 while (frarptact > 0)
238 frarptpop();
239 }
240
241 int fraignore = FALSE;
242
fra_reexamine(char * buf,int maxlen,ignore_flags_t * ignore,void * u)243 LOCAL int fra_reexamine(char *buf, int maxlen, ignore_flags_t *ignore, void *u)
244 {
245 extern int fraifskip, frarptskip, fraexpmac;
246 UNUSED(buf);
247 UNUSED(maxlen);
248 UNUSED(u);
249
250 if (ignore)
251 {
252 //printf("reexamining %s (i=%d,%d)\n", buf, ignore->skip_parse, ignore->skip_macro);
253 ignore->skip_parse |= (fraifskip != FALSE) || (frarptskip != FALSE);
254 ignore->skip_macro = ignore->skip_parse && !fraexpmac;
255 //printf("ignore = %d,%d\n", ignore->skip_parse, ignore->skip_macro);
256 }
257
258 return 1;
259 }
260
fra_next_line(char * buf,int maxlen,ignore_flags_t * ignore,void * u)261 int fra_next_line(char *buf, int maxlen, ignore_flags_t *ignore, void *u)
262 /*
263 description read a line, on end of file, pop the include file stack.
264 return TRUE got a line
265 FALSE end of input
266 */
267 {
268 extern int fraifskip, frarptskip, fraexpmac;
269 UNUSED(u);
270
271 if (ignore)
272 {
273 ignore->skip_parse |= (fraifskip != FALSE) || (frarptskip != FALSE);
274 ignore->skip_macro = ignore->skip_parse && !fraexpmac;
275 }
276
277 while( lzoe_fgets(buf, maxlen, yyin) == (char *)NULL)
278 {
279 if(currfstk == 0)
280 {
281 return 0;
282 }
283 else
284 {
285 lzoe_fclose(yyin);
286 yyin = infilestk[--currfstk].fpt;
287 emit_exiting_file(infilestk[currfstk].fnm);
288 }
289 }
290
291 infilestk[currfstk].line++;
292
293 return 1;
294 }
295
fra_get_pos(int * line,void * u)296 const char *fra_get_pos(int *line, void *u)
297 {
298 UNUSED(u);
299 *line = infilestk[currfstk].line;
300 return infilestk[currfstk].fnm;
301 }
302
fra_get_eof(void * u)303 int fra_get_eof(void *u)
304 {
305 UNUSED(u);
306
307 if (currfstk == 0 && lzoe_feof(infilestk[currfstk].fpt))
308 return 1;
309
310 return 0;
311 }
312
fra_rpt_err(const char * buf,void * u)313 void fra_rpt_err(const char *buf, void *u)
314 {
315 UNUSED(u);
316 emit_raw_error(buf);
317 }
318
319 struct parser_callbacks imasm_hooks =
320 {
321 fra_next_line, NULL,
322 fra_get_pos, NULL,
323 fra_get_eof, NULL,
324 fra_reexamine, NULL,
325 fra_rpt_err, NULL
326 };
327
frareadrec(void)328 int frareadrec(void)
329 /*
330 description read a line, on end of file, pop the include file
331 stack.
332 return FALSE got a line
333 TRUE end of input
334 */
335 {
336 ignore_flags_t ignore = { 0, 0 };
337 extern int fraignore;
338
339 fryybuf[0] = 0;
340
341 /* Get next line from loop buffer, if any. */
342 if (frarptact > 0) /* any active loops? */
343 if (frarptnxt())
344 return FALSE;
345
346 if (get_parsed_line(&fryybuf, &fryy_bs, &ignore) == NULL)
347 {
348 if(frarptact > 0)
349 {
350 fraerror("REPEAT block active at EOF. Resetting repeat stack.");
351 frarptreset();
352 }
353 return TRUE;
354 }
355
356 fraignore = ignore.skip_parse != 0 ? TRUE : FALSE;
357
358 if (frarptact > 0 && !ignore.skip_parse)
359 frarptadd(fryybuf);
360
361 return FALSE;
362 }
363
364 static int currtok=0; /* subscript of next token to return */
365 static int intokcnt=0; /* number of tokens in queue */
366
367 enum errtype_t {Yetprint, Yetsymbol, Yetreserved, Yetopcode,
368 Yetconstant, Yetstring, Yetunprint, Yetinvalid };
369
370 typedef struct
371 {
372 char *textstrt, *textend;
373 YYSTYPE lvalv;
374 int tokv;
375 enum errtype_t errtype;
376 } sq_type;
377
378 static sq_type *scanqueue, *lasttokfetch, *nexttokload;
379
380 static char *tempstrpool;
381 static char *tptrstr;
382
383 static int sq_size = 0;
384
385 #define CXC00_SKIP 0
386 #define CXC01_SPACE 1
387 #define CXC02_NL 2
388 #define CXC03_LETTER 3
389 #define CXC04_QUOTE 4
390 #define CXC05_OTHER 5
391 #define CXC06_DOLLAR 6
392 #define CXC07_PERCENT 7
393 #define CXC08_APP 8
394 #define CXC09_BIN 9
395 #define CXC10_OCT 10
396 #define CXC11_DEC 11
397 #define CXC12_SEMIC 12
398 #define CXC13_LT 13
399 #define CXC14_EQ 14
400 #define CXC15_GT 15
401 #define CXC16_AT 16
402 #define CXC17_HEXU 17
403 #define CXC18_B 18
404 #define CXC19_D 19
405 #define CXC20_H 20
406 #define CXC21_OQ 21
407 #define CXC22_HEXL 22
408 #define CXC23_BL 23
409 #define CXC24_DL 24
410 #define CXC25_BSLASH 25
411 #define NUMCHARSETS 26
412
413 #if 0
414 static char chartrantab[128] = {
415 /* 00 nul soh stx etx*/ CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
416 /* 04 eot enq ack bel*/ CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
417 /* 08 bs ht nl vt */ CXC00_SKIP, CXC01_SPACE, CXC02_NL, CXC00_SKIP,
418 /* 0c np cr so si */ CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
419 /* 10 dle dc1 dc2 dc3*/ CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
420 /* 14 dc4 nak syn etb*/ CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
421 /* 18 can em sub esc*/ CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
422 /* 1c fs gs rs us */ CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
423 /* 20 sp ! " # */ CXC01_SPACE, CXC03_LETTER, CXC04_QUOTE, CXC05_OTHER,
424 /* 24 $ % & ' */ CXC06_DOLLAR, CXC07_PERCENT, CXC03_LETTER, CXC08_APP,
425 /* 28 ( ) * + */ CXC05_OTHER, CXC05_OTHER, CXC05_OTHER, CXC05_OTHER,
426 /* 2c , - . / */ CXC05_OTHER, CXC05_OTHER, CXC05_OTHER, CXC05_OTHER,
427 /* 30 0 1 2 3 */ CXC09_BIN, CXC09_BIN, CXC10_OCT, CXC10_OCT,
428 /* 34 4 5 6 7 */ CXC10_OCT, CXC10_OCT, CXC10_OCT, CXC10_OCT,
429 /* 38 8 9 : ; */ CXC11_DEC, CXC11_DEC, CXC05_OTHER, CXC12_SEMIC,
430 /* 3c < = > ? */ CXC13_LT, CXC14_EQ, CXC15_GT, CXC05_OTHER,
431 /* 40 @ A B C */ CXC16_AT, CXC17_HEXU, CXC18_B, CXC17_HEXU,
432 /* 44 D E F G */ CXC19_D, CXC17_HEXU, CXC17_HEXU, CXC03_LETTER,
433 /* 48 H I J K */ CXC20_H, CXC03_LETTER, CXC03_LETTER, CXC03_LETTER,
434 /* 4c L M N O */ CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC21_OQ,
435 /* 50 P Q R S */ CXC03_LETTER, CXC21_OQ, CXC03_LETTER, CXC03_LETTER,
436 /* 54 T U V W */ CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC03_LETTER,
437 /* 58 X Y Z [ */ CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC05_OTHER,
438 /* 5c \ ] ^ _ */ CXC25_BSLASH, CXC05_OTHER, CXC03_LETTER, CXC03_LETTER,
439 /* 60 ` a b c */ CXC05_OTHER, CXC22_HEXL, CXC23_BL, CXC22_HEXL,
440 /* 64 d e f g */ CXC24_DL, CXC22_HEXL, CXC22_HEXL, CXC03_LETTER,
441 /* 68 h i j k */ CXC20_H, CXC03_LETTER, CXC03_LETTER, CXC03_LETTER,
442 /* 6c l m n o */ CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC21_OQ,
443 /* 70 p q r s */ CXC03_LETTER, CXC21_OQ, CXC03_LETTER, CXC03_LETTER,
444 /* 74 t u v w */ CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC03_LETTER,
445 /* 78 x y z { */ CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC05_OTHER,
446 /* 7c vb } ~ del*/ CXC05_OTHER, CXC05_OTHER, CXC03_LETTER, CXC00_SKIP } ;
447 #else
448 static char chartrantab[128] = {
449 /* 00 nul soh stx etx*/ CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
450 /* 04 eot enq ack bel*/ CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
451 /* 08 bs ht nl vt */ CXC00_SKIP, CXC01_SPACE, CXC02_NL, CXC00_SKIP,
452 /* 0c np cr so si */ CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
453 /* 10 dle dc1 dc2 dc3*/ CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
454 /* 14 dc4 nak syn etb*/ CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
455 /* 18 can em sub esc*/ CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
456 /* 1c fs gs rs us */ CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
457 /* 20 sp ! " # */ CXC01_SPACE, CXC03_LETTER, CXC04_QUOTE, CXC05_OTHER,
458 /* 24 $ % & ' */ CXC06_DOLLAR, CXC07_PERCENT, CXC03_LETTER, CXC08_APP,
459 /* 28 ( ) * + */ CXC05_OTHER, CXC05_OTHER, CXC05_OTHER, CXC05_OTHER,
460 /* 2c , - . / */ CXC05_OTHER, CXC05_OTHER, CXC03_LETTER, CXC05_OTHER,
461 /* 30 0 1 2 3 */ CXC09_BIN, CXC09_BIN, CXC10_OCT, CXC10_OCT,
462 /* 34 4 5 6 7 */ CXC10_OCT, CXC10_OCT, CXC10_OCT, CXC10_OCT,
463 /* 38 8 9 : ; */ CXC11_DEC, CXC11_DEC, CXC05_OTHER, CXC12_SEMIC,
464 /* 3c < = > ? */ CXC13_LT, CXC14_EQ, CXC15_GT, CXC05_OTHER,
465 /* 40 @ A B C */ CXC03_LETTER, CXC17_HEXU, CXC18_B, CXC17_HEXU,
466 /* 44 D E F G */ CXC19_D, CXC17_HEXU, CXC17_HEXU, CXC03_LETTER,
467 /* 48 H I J K */ CXC20_H, CXC03_LETTER, CXC03_LETTER, CXC03_LETTER,
468 /* 4c L M N O */ CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC21_OQ,
469 /* 50 P Q R S */ CXC03_LETTER, CXC21_OQ, CXC03_LETTER, CXC03_LETTER,
470 /* 54 T U V W */ CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC03_LETTER,
471 /* 58 X Y Z [ */ CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC05_OTHER,
472 /* 5c \ ] ^ _ */ CXC25_BSLASH, CXC05_OTHER, CXC03_LETTER, CXC03_LETTER,
473 /* 60 ` a b c */ CXC05_OTHER, CXC22_HEXL, CXC23_BL, CXC22_HEXL,
474 /* 64 d e f g */ CXC24_DL, CXC22_HEXL, CXC22_HEXL, CXC03_LETTER,
475 /* 68 h i j k */ CXC20_H, CXC03_LETTER, CXC03_LETTER, CXC03_LETTER,
476 /* 6c l m n o */ CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC21_OQ,
477 /* 70 p q r s */ CXC03_LETTER, CXC21_OQ, CXC03_LETTER, CXC03_LETTER,
478 /* 74 t u v w */ CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC03_LETTER,
479 /* 78 x y z { */ CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC05_OTHER,
480 /* 7c vb } ~ del*/ CXC05_OTHER, CXC05_OTHER, CXC03_LETTER, CXC00_SKIP } ;
481 #endif
482
483
484 #if DEBUG
485
486 static char * statelab[] = {
487 " 0 start of label",
488 " 1 comment",
489 " 2 label",
490 " 3 rest of line",
491 " 4 symbol",
492 " 5 dollar",
493 " 6 hex dollar",
494 " 7 at sign",
495 " 8 octal at",
496 " 9 percent",
497 "10 bin percent",
498 "11 quote string",
499 "12 appos. string",
500 "13 greater than",
501 "14 less than",
502 "15 base 2 maybe",
503 "16 base 8 maybe",
504 "17 base 10 maybe",
505 "18 hex",
506 "19 found b ",
507 "20 found d",
508 "21 bslash quote",
509 "22 bslash appos",
510 "23 greater than (NE)",
511 };
512
513 static char *actlab[] = {
514 " 0 skip/no op",
515 " 1 load EOL token",
516 " 2 start string",
517 " 3 process label",
518 " 4 save string char",
519 " 5 load single char token",
520 " 6 load EQ token",
521 " 7 process symbol",
522 " 8 load $ token",
523 " 9 setup for $hex",
524 "10 accumulate 0-9 constant",
525 "11 accumulate A-F constant",
526 "12 accumulate a-f constant",
527 "13 load Constant token",
528 "14 load @ token",
529 "15 setup for @octal",
530 "16 setup for %binary",
531 "17 load % token",
532 "18 load String token (double quoted)",
533 "19 load GE token",
534 "20 load GT token",
535 "21 load LE token",
536 "22 load NE token",
537 "23 load LT token",
538 "24 save numeric char 0-9",
539 "25 save numeric char A-F",
540 "26 save numeric char a-f",
541 "27 convert numeric string base 2",
542 "28 convert numeric string base 8",
543 "29 convert numeric string base 10",
544 "30 convert numeric string base 16",
545 "31 save numeric 0xb",
546 "32 save numeric 0xd",
547 "33 set text start",
548 "34 token choke",
549 "35 load String token (single-quoted)"
550 };
551
552 #endif /* DEBUG */
553
554 static struct
555 {
556 char action;
557 char nextstate;
558 char contin;
559 } *thisact, characttab [24][NUMCHARSETS] =
560 {
561 /*
562 STATE 0 = {start of label}
563 */
564 {
565 /* SKIP */ /* SPACE */ /* NL */ /* LETTER */
566 /* QUOTE */ /* OTHER */ /* DOLLAR */ /* PERCENT */
567 /* APP */ /* BIN */ /* OCT */ /* DEC */
568 /* SEMIC */ /* LT */ /* EQ */ /* GT */
569 /* AT */ /* HEXU */ /* B */ /* D */
570 /* H */ /* OQ */ /* HEXL */ /* BL */
571 /* DL */ /* BSLASH */
572 {0, 0, FALSE}, {0, 3, FALSE}, {1, 0, FALSE}, {2, 2, TRUE},
573 {2,11, FALSE}, {5, 3, FALSE}, {33, 5, FALSE}, {33, 9, FALSE},
574 {2,12, FALSE}, {2,15, TRUE}, {2,16, TRUE}, {2,17, TRUE},
575 {0, 1, FALSE}, {0,14, FALSE}, {6, 3, FALSE}, {0,13, FALSE},
576 {33, 7, FALSE}, {2, 2, TRUE}, {2, 2, TRUE}, {2, 2, TRUE},
577 {2, 2, TRUE}, {2, 2, TRUE}, {2, 2, TRUE}, {2, 2, TRUE},
578 {2, 2, TRUE}, {5, 3, FALSE}
579 },
580
581 /*
582 STATE 1 = {comment}
583 */
584 {
585 {0, 1, FALSE}, {0, 1, FALSE}, {1, 0, FALSE}, {0, 1, FALSE},
586 {0, 1, FALSE}, {0, 1, FALSE}, {0, 1, FALSE}, {0, 1, FALSE},
587 {0, 1, FALSE}, {0, 1, FALSE}, {0, 1, FALSE}, {0, 1, FALSE},
588 {0, 1, FALSE}, {0, 1, FALSE}, {0, 1, FALSE}, {0, 1, FALSE},
589 {0, 1, FALSE}, {0, 1, FALSE}, {0, 1, FALSE}, {0, 1, FALSE},
590 {0, 1, FALSE}, {0, 1, FALSE}, {0, 1, FALSE}, {0, 1, FALSE},
591 {0, 1, FALSE}, {0, 1, FALSE}
592 },
593
594 /*
595 STATE 2 = {label}
596 */
597 {
598 {0, 2, FALSE}, {3, 3, FALSE}, {3, 3, TRUE}, {4, 2, FALSE},
599 {3, 3, TRUE}, {3, 3, TRUE}, {3, 3, TRUE}, {3, 3, TRUE},
600 {3, 3, TRUE}, {4, 2, FALSE}, {4, 2, FALSE}, {4, 2, FALSE},
601 {3, 1, FALSE}, {3,14, FALSE}, {3, 3, TRUE}, {3,13, FALSE},
602 {3, 3, TRUE}, {4, 2, FALSE}, {4, 2, FALSE}, {4, 2, FALSE},
603 {4, 2, FALSE}, {4, 2, FALSE}, {4, 2, FALSE}, {4, 2, FALSE},
604 {4, 2, FALSE}, {3, 3, TRUE}
605 },
606
607 /*
608 STATE 3 = {rest of line}
609 */
610 {
611 {0, 3, FALSE}, {0, 3, FALSE}, {1, 0, FALSE}, {2, 4, TRUE},
612 {2,11, FALSE}, {5, 3, FALSE}, {33, 5, FALSE}, {33, 9, FALSE},
613 {2,12, FALSE}, {2,15, TRUE}, {2,16, TRUE}, {2,17, TRUE},
614 {0, 1, FALSE}, {0,14, FALSE}, {6, 3, FALSE}, {0,13, FALSE},
615 {33, 7, FALSE}, {2, 4, TRUE}, {2, 4, TRUE}, {2, 4, TRUE},
616 {2, 4, TRUE}, {2, 4, TRUE}, {2, 4, TRUE}, {2, 4, TRUE},
617 {2, 4, TRUE} , {5, 3, FALSE}
618 },
619
620 /*
621 STATE 4 = {symbol}
622 */
623 {
624 {0, 4, FALSE}, {7, 3, FALSE}, {7, 3, TRUE}, {4, 4, FALSE},
625 {7, 3, TRUE}, {7, 3, TRUE}, {7, 3, TRUE}, {7, 3, TRUE},
626 {7, 3, TRUE}, {4, 4, FALSE}, {4, 4, FALSE}, {4, 4, FALSE},
627 {7, 1, FALSE}, {7,14, FALSE}, {7, 3, TRUE}, {7,13, FALSE},
628 {7, 3, TRUE}, {4, 4, FALSE}, {4, 4, FALSE}, {4, 4, FALSE},
629 {4, 4, FALSE}, {4, 4, FALSE}, {4, 4, FALSE}, {4, 4, FALSE},
630 {4, 4, FALSE}, {7, 3, TRUE}
631 },
632
633 /*
634 STATE 5 = {dollar}
635 */
636 {
637 {0, 5, FALSE}, {8, 3, FALSE}, {8, 3, TRUE}, {8, 3, TRUE},
638 {8, 3, TRUE}, {8, 3, TRUE}, {8, 3, TRUE}, {8, 3, TRUE},
639 {8, 3, TRUE}, {9, 6, TRUE}, {9, 6, TRUE}, {9, 6, TRUE},
640 {8, 1, FALSE}, {8,14, FALSE}, {8, 3, TRUE}, {8,13, FALSE},
641 {8, 3, TRUE}, {9, 6, TRUE}, {9, 6, TRUE}, {9, 6, TRUE},
642 {8, 3, TRUE}, {8, 3, TRUE}, {9, 6, TRUE}, {9, 6, TRUE},
643 {9, 6, TRUE} , {8, 3, TRUE}
644 },
645
646 /*
647 STATE 6 = {dollar hex}
648 */
649
650 {
651 {0, 6, FALSE}, {13, 3, FALSE}, {13, 3, TRUE}, {13, 3, TRUE},
652 {13, 3, TRUE}, {13, 3, TRUE}, {13, 3, TRUE}, {13, 3, TRUE},
653 {13, 3, TRUE}, {10, 6, FALSE}, {10, 6, FALSE}, {10, 6, FALSE},
654 {13, 1, FALSE}, {13,14, FALSE}, {13, 3, TRUE}, {13,13, FALSE},
655 {13, 3, TRUE}, {11, 6, FALSE}, {11, 6, FALSE}, {11, 6, FALSE},
656 {13, 3, TRUE}, {13, 3, TRUE}, {12, 6, FALSE}, {12, 6, FALSE},
657 {12, 6, FALSE}, {13, 3, TRUE}
658 },
659 /*
660 STATE 7 = {at sign}
661 */
662 {
663 {0, 7, FALSE}, {14, 3, FALSE}, {14, 3, TRUE}, {14, 3, TRUE},
664 {14, 3, TRUE}, {14, 3, TRUE}, {14, 3, TRUE}, {14, 3, TRUE},
665 {14, 3, TRUE}, {15, 8, TRUE}, {15, 8, TRUE}, {14, 3, TRUE},
666 {14, 1, FALSE}, {14,14, FALSE}, {14, 3, TRUE}, {14,13, FALSE},
667 {14, 3, TRUE}, {14, 3, TRUE}, {14, 3, TRUE}, {14, 3, TRUE},
668 {14, 3, TRUE}, {14, 3, TRUE}, {14, 3, TRUE}, {14, 3, TRUE},
669 {14, 3, TRUE}, {14, 3, TRUE}
670 },
671
672 /*
673 STATE 8 = {at octal}
674 */
675 {
676 {0, 8, FALSE}, {13, 3, FALSE}, {13, 3, TRUE}, {13, 3, TRUE},
677 {13, 3, TRUE}, {13, 3, TRUE}, {13, 3, TRUE}, {13, 3, TRUE},
678 {13, 3, TRUE}, {10, 8, FALSE}, {10, 8, FALSE}, {13, 3, TRUE},
679 {13, 1, FALSE}, {13,14, FALSE}, {13, 3, TRUE}, {13,13, FALSE},
680 {13, 3, TRUE}, {13, 3, TRUE}, {13, 3, TRUE}, {13, 3, TRUE},
681 {13, 3, TRUE}, {13, 3, TRUE}, {13, 3, TRUE}, {13, 3, TRUE},
682 {13, 3, TRUE}, {13, 3, TRUE}
683 },
684
685 /*
686 STATE 9 = {percent}
687 */
688 {
689 {0, 9, FALSE}, {17, 3, FALSE}, {17, 3, TRUE}, {17, 3, TRUE},
690 {17, 3, TRUE}, {17, 3, TRUE}, {17, 3, TRUE}, {17, 3, TRUE},
691 {17, 3, TRUE}, {16,10, TRUE}, {17, 3, TRUE}, {17, 3, TRUE},
692 {17, 1, FALSE}, {17,14, FALSE}, {17, 3, TRUE}, {17,13, FALSE},
693 {17, 3, TRUE}, {17, 3, TRUE}, {17, 3, TRUE}, {17, 3, TRUE},
694 {17, 3, TRUE}, {17, 3, TRUE}, {17, 3, TRUE}, {17, 3, TRUE},
695 {17, 3, TRUE}, {17, 3, TRUE}
696 },
697
698 /*
699 STATE 10 = {percent binary}
700 */
701 {
702 {0,10, FALSE}, {13, 3, FALSE}, {13, 3, TRUE}, {13, 3, TRUE},
703 {13, 3, TRUE}, {13, 3, TRUE}, {13, 3, TRUE}, {13, 3, TRUE},
704 {13, 3, TRUE}, {10,10, FALSE}, {13, 3, TRUE}, {13, 3, TRUE},
705 {13, 1, FALSE}, {13,14, FALSE}, {13, 3, TRUE}, {13,13, FALSE},
706 {13, 3, TRUE}, {13, 3, TRUE}, {13, 3, TRUE}, {13, 3, TRUE},
707 {13, 3, TRUE}, {13, 3, TRUE}, {13, 3, TRUE}, {13, 3, TRUE},
708 {13, 3, TRUE}, {13, 3, TRUE}
709 },
710
711 /*
712 STATE 11 = {quote string}
713 */
714 {
715 {0,11, FALSE}, {4,11, FALSE}, {34, 3, TRUE}, {4,11, FALSE},
716 {18, 3, FALSE}, {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE},
717 {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE},
718 {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE},
719 {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE},
720 {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE},
721 {4,11, FALSE}, {4,21, FALSE}
722 },
723
724 /*
725 STATE 12 = {app string}
726 */
727 {
728 {0,12, FALSE}, {4,12, FALSE}, {34, 3, TRUE}, {4,12, FALSE},
729 {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE},
730 {35,3, FALSE}, {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE},
731 {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE},
732 {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE},
733 {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE},
734 {4,12, FALSE}, {4,22, FALSE}
735 },
736
737 /*
738 STATE 13 = {greater than}
739 */
740 {
741 {0,13, FALSE}, {20, 3, FALSE}, {20, 3, TRUE}, {20, 3, TRUE},
742 {20, 3, TRUE}, {20, 3, TRUE}, {20, 3, TRUE}, {20, 3, TRUE},
743 {20, 3, TRUE}, {20, 3, TRUE}, {20, 3, TRUE}, {20, 3, TRUE},
744 {20, 1, FALSE}, {20,14, FALSE}, {19, 3, FALSE}, {20,13, FALSE},
745 {20, 3, TRUE}, {20, 3, TRUE}, {20, 3, TRUE}, {20, 3, TRUE},
746 {20, 3, TRUE}, {20, 3, TRUE}, {20, 3, TRUE}, {20, 3, TRUE},
747 {20, 3, TRUE}, {20, 3, TRUE}
748 },
749
750 /*
751 STATE 14 = {less than}
752 */
753 {
754 {0,14, FALSE}, {23, 3, FALSE}, {23, 3, TRUE}, {23, 3, TRUE},
755 {23, 3, TRUE}, {23, 3, TRUE}, {23, 3, TRUE}, {23, 3, TRUE},
756 {23, 3, TRUE}, {23, 3, TRUE}, {23, 3, TRUE}, {23, 3, TRUE},
757 {23, 1, FALSE}, {23,14, FALSE}, {21, 3, FALSE}, {22,23, FALSE},
758 {23, 3, TRUE}, {23, 3, TRUE}, {23, 3, TRUE}, {23, 3, TRUE},
759 {23, 3, TRUE}, {23, 3, TRUE}, {23, 3, TRUE}, {23, 3, TRUE},
760 {23, 3, TRUE}, {23, 3, TRUE}
761 },
762
763 /*
764 STATE 15 = {base 2 maybe}
765 */
766 {
767 {0,15, FALSE}, {29, 3, FALSE}, {29, 3, TRUE}, {29, 3, TRUE},
768 {29, 3, TRUE}, {29, 3, TRUE}, {29, 3, TRUE}, {29, 3, TRUE},
769 {29, 3, TRUE}, {24,15, FALSE}, {24,16, FALSE}, {24,17, FALSE},
770 {29, 1, FALSE}, {29,14, FALSE}, {29, 3, TRUE}, {29,13, FALSE},
771 {29, 3, TRUE}, {25,18, FALSE}, {0,19, FALSE}, {0,20, FALSE},
772 {30, 3, FALSE}, {28, 3, FALSE}, {26,18, FALSE}, {0,19, FALSE},
773 {0,20, FALSE}, {29, 3, TRUE}
774 },
775
776 /*
777 STATE 16 = {base 8 maybe}
778 */
779 {
780 {0,16, FALSE}, {29, 3, FALSE}, {29, 3, TRUE}, {29, 3, TRUE},
781 {29, 3, TRUE}, {29, 3, TRUE}, {29, 3, TRUE}, {29, 3, TRUE},
782 {29, 3, TRUE}, {24,16, FALSE}, {24,16, FALSE}, {24,17, FALSE},
783 {29, 1, FALSE}, {29,14, FALSE}, {29, 3, TRUE}, {29,13, FALSE},
784 {29, 3, TRUE}, {25,18, FALSE}, {25,18, FALSE}, {0,20, FALSE},
785 {30, 3, FALSE}, {28, 3, FALSE}, {26,18, FALSE}, {26,18, FALSE},
786 {0,20, FALSE}, {29, 3, TRUE}
787 },
788
789 /*
790 STATE 17 = {base10 maybe}
791 */
792 {
793 {0,17, FALSE}, {29, 3, FALSE}, {29, 3, TRUE}, {29, 3, TRUE},
794 {29, 3, TRUE}, {29, 3, TRUE}, {29, 3, TRUE}, {29, 3, TRUE},
795 {29, 3, TRUE}, {24,17, FALSE}, {24,17, FALSE}, {24,17, FALSE},
796 {29, 1, FALSE}, {29,14, FALSE}, {29, 3, TRUE}, {29,13, FALSE},
797 {29, 3, TRUE}, {25,18, FALSE}, {25,18, FALSE}, {0,20, FALSE},
798 {30, 3, FALSE}, {34, 3, FALSE}, {26,18, FALSE}, {26,18, FALSE},
799 {0,20, FALSE}, {29, 3, TRUE}
800 },
801
802 /*
803 STATE 18 = {hex}
804 */
805 {
806 {0,18, FALSE}, {34, 3, FALSE}, {34, 3, TRUE}, {34, 3, TRUE},
807 {34, 3, TRUE}, {34, 3, TRUE}, {34, 3, TRUE}, {34, 3, TRUE},
808 {34, 3, TRUE}, {24,18, FALSE}, {24,18, FALSE}, {24,18, FALSE},
809 {34, 1, FALSE}, {34,14, FALSE}, {34, 3, TRUE}, {34,13, FALSE},
810 {34, 3, TRUE}, {25,18, FALSE}, {25,18, FALSE}, {25,18, FALSE},
811 {30, 3, FALSE}, {34, 3, TRUE}, {26,18, FALSE}, {26,18, FALSE},
812 {26,18, FALSE}, {34, 3, TRUE}
813 },
814
815 /*
816 STATE 19 = {bin or hex}
817 */
818 {
819 {0,19, FALSE}, {27, 3, FALSE}, {27, 3, TRUE}, {27, 3, TRUE},
820 {27, 3, TRUE}, {27, 3, TRUE}, {27, 3, TRUE}, {27, 3, TRUE},
821 {27, 3, TRUE}, {31,18, TRUE}, {31,18, TRUE}, {31,18, TRUE},
822 {27, 1, FALSE}, {27,14, FALSE}, {27, 3, TRUE}, {27,13, FALSE},
823 {27, 3, TRUE}, {31,18, TRUE}, {31,18, TRUE}, {31,18, TRUE},
824 {31,18, TRUE}, {27, 3, TRUE}, {31,18, TRUE}, {31,18, TRUE},
825 {31,18, TRUE}, {27, 3, TRUE}
826 },
827
828 /*
829 STATE 20 = {dec or hex}
830 */
831 {
832 {0,20, FALSE}, {29, 3, FALSE}, {29, 3, TRUE}, {29, 3, TRUE},
833 {29, 3, TRUE}, {29, 3, TRUE}, {29, 3, TRUE}, {29, 3, TRUE},
834 {29, 3, TRUE}, {32,18, TRUE}, {32,18, TRUE}, {32,18, TRUE},
835 {29, 1, FALSE}, {29,14, FALSE}, {29, 3, TRUE}, {29,13, FALSE},
836 {29, 3, TRUE}, {32,18, TRUE}, {32,18, TRUE}, {32,18, TRUE},
837 {32,18, TRUE}, {29, 3, TRUE}, {32,18, TRUE}, {32,18, TRUE},
838 {32,18, TRUE}, {29, 3, TRUE}
839 },
840
841 /*
842 STATE 21 = {bslash quote}
843 */
844 {
845 {0,21, FALSE}, {4,11, FALSE}, {34, 3, TRUE}, {4,11, FALSE},
846 {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE},
847 {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE},
848 {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE},
849 {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE},
850 {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE}, {4,11, FALSE},
851 {4,11, FALSE}, {4,11, FALSE}
852 },
853
854 /*
855 STATE 22 = {bslash appos}
856 */
857 {
858 {0,22, FALSE}, {4,12, FALSE}, {34, 3, TRUE}, {4,12, FALSE},
859 {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE},
860 {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE},
861 {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE},
862 {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE},
863 {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE}, {4,12, FALSE},
864 {4,12, FALSE}, {4,12, FALSE}
865 },
866 /*
867 STATE 23 = {greater than after NE}
868 */
869 {
870 {0, 23, FALSE}, {0, 3, FALSE}, {0, 3, TRUE}, {0, 3, TRUE},
871 {0, 3, TRUE}, {0, 3, TRUE}, {0, 3, TRUE}, {0, 3, TRUE},
872 {0, 3, TRUE}, {0, 3, TRUE}, {0, 3, TRUE}, {0, 3, TRUE},
873 {0, 1, FALSE}, {0,14, FALSE}, {19, 3, FALSE}, {0,13, FALSE},
874 {0, 3, TRUE}, {0, 3, TRUE}, {0, 3, TRUE}, {0, 3, TRUE},
875 {0, 3, TRUE}, {0, 3, TRUE}, {0, 3, TRUE}, {0, 3, TRUE},
876 {0, 3, TRUE}, {0, 3, TRUE}
877 },
878 };
879
880 #define YEXL 32
881 static char yytext[YEXL];
882
erryytextex(int type)883 static void erryytextex(int type)
884 {
885 char * strptr, *endptr;
886 int charcnt;
887
888 strptr = (lasttokfetch->textstrt) - 1;
889 if(type == STRING)
890 {
891 endptr = (lasttokfetch->textend) - 1;
892 if(*endptr == '\n')
893 endptr --;
894 }
895 else
896 {
897 endptr = (lasttokfetch->textend) - 2;
898 }
899
900 for(charcnt = 0; (strptr <= endptr) && charcnt < (YEXL - 1); charcnt ++)
901 {
902 yytext[charcnt] = *strptr++;
903 }
904 yytext[charcnt] = '\0';
905 }
906
yylex(void)907 int yylex(void)
908 {
909 int scanstate;
910 char *thistokstart = NULL;
911 register char nextchar;
912 int charset;
913 int64_t consaccum = 0;
914 int consbase = 0;
915
916 if (!fryybuf || fryy_bs < 4096)
917 {
918 free(fryybuf);
919 fryy_bs = 4096;
920 fryybuf = (char *)calloc(fryy_bs, 1);
921 frainptr = fryybuf;
922 }
923
924 if(currtok >= intokcnt)
925 {
926 again:
927 switch(nextreadact)
928 {
929 case Nra_new: /* access next file */
930 emit_entering_file(infilestk[++currfstk].fnm);
931 yyin = infilestk[currfstk].fpt;
932 nextreadact = Nra_normal;
933 FALLTHROUGH_INTENDED;
934 case Nra_normal:
935 if(frareadrec())
936 {
937 /* EOF */;
938 return 0;
939 }
940 break;
941
942 case Nra_end: /* pop file and access previous */
943 if(currfstk > 0)
944 {
945 lzoe_fclose(yyin);
946 yyin = infilestk[--currfstk].fpt;
947 emit_exiting_file(infilestk[currfstk].fnm);
948 if(frareadrec())
949 {
950 /* EOF */;
951 return 0;
952 }
953 else
954 {
955 nextreadact = Nra_normal;
956 }
957 }
958 else
959 {
960 /* EOF */;
961 return 0;
962 }
963 break;
964 }
965
966 if(listflag) emit_listed_line(fryybuf);
967 else emit_unlisted_line();
968
969 if (fraignore)
970 goto again; /* don't scan it! */
971
972 /* resize our parsing buffers if the incoming line buffer got huge */
973 if (fryy_bs + 2 > sq_size)
974 {
975 free(scanqueue );
976 free(tempstrpool);
977 scanqueue = (sq_type *)malloc((fryy_bs + 2) * sizeof(sq_type));
978 tempstrpool = (char *)malloc((fryy_bs + 2) * 2);
979
980 sq_size = fryy_bs + 2;
981 }
982
983 /* Scan a line */
984
985 frainptr = fryybuf;
986
987 currtok = intokcnt = 0;
988 nexttokload = & scanqueue[0];
989
990 tptrstr = &tempstrpool[0];
991 scanstate = 0;
992 whichsym = Symopcode;
993 labelarray = LAno;
994
995 while( (nextchar = *frainptr++) != '\0' )
996 {
997 charset = nextchar & 0x80 ? CXC03_LETTER /* Treat > 0x80 as letters */
998 : chartrantab[nextchar & 0x7f];
999 do {
1000 thisact = & characttab [scanstate][charset];
1001
1002 #if DEBUG
1003 if(isprint(nextchar))
1004 printf("%c ", nextchar);
1005 else
1006 printf("0x%2.2X ", nextchar);
1007 printf("%-18s %-33s %-11s %2.2d\n",
1008 statelab[scanstate],
1009 actlab[thisact->action],
1010 thisact->contin ? "Continue" : "Swallow",
1011 thisact->nextstate);
1012 #endif
1013
1014 switch(thisact->action)
1015 {
1016 case 0: /* skip/no op */
1017 break;
1018
1019 case 1: /* load EOL token */
1020 nexttokload->lvalv.longv = 0;
1021 nexttokload->tokv = EOL;
1022 nexttokload->errtype = Yetunprint;
1023 nexttokload++;
1024 intokcnt++;
1025 break;
1026
1027 case 2: /* start string */
1028 thistokstart = tptrstr;
1029 nexttokload->textstrt = frainptr;
1030 break;
1031
1032 case 3: /* process label */
1033 {
1034 struct symel *tempsym;
1035
1036 labelarray = LAmaybe;
1037
1038 *tptrstr++ = '\0';
1039 tempsym = symbentry(thistokstart, SYMBOL);
1040 if((tempsym->seg) != SSG_RESV)
1041 {
1042 nexttokload->tokv = LABEL;
1043 nexttokload->errtype = Yetsymbol;
1044 nexttokload->lvalv.symb = tempsym;
1045 }
1046 else
1047 {
1048 nexttokload->tokv = tempsym->tok;
1049 nexttokload->errtype = Yetreserved;
1050 nexttokload->lvalv.intv = tempsym->value;
1051 }
1052 nexttokload->textend = frainptr;
1053 nexttokload++;
1054 intokcnt++;
1055 }
1056 break;
1057
1058 case 4: /* save string char */
1059 *tptrstr++ = nextchar;
1060 break;
1061
1062 case 5: /* load single char token */
1063 if (labelarray == LAmaybe && nextchar == '['
1064 && whichsym == Symopcode)
1065 {
1066 labelarray = LAyes;
1067 whichsym = Symsym;
1068 }
1069 if (labelarray == LAyes && nextchar == ']')
1070 {
1071 labelarray = LAmaybe;
1072 whichsym = Symopcode;
1073 }
1074 nexttokload->lvalv.longv = 0;
1075 nexttokload->tokv = nextchar;
1076 nexttokload->errtype = Yetprint;
1077 nexttokload++;
1078 intokcnt++;
1079 break;
1080
1081 case 6: /* load EQ token */
1082 nexttokload->lvalv.longv = 0;
1083 nexttokload->tokv = KEOP_EQ;
1084 nexttokload->errtype = Yetunprint;
1085 nexttokload++;
1086 intokcnt++;
1087 break;
1088
1089 case 7: /* process symbol */
1090 {
1091 register struct symel *symp;
1092 register char *ytp;
1093 int tempov;
1094
1095 *tptrstr++ = '\0';
1096 if(whichsym == Symopcode)
1097 {
1098 for(ytp = thistokstart; *ytp != '\0';
1099 ytp++)
1100 {
1101 if(islower(*ytp))
1102 {
1103 *ytp = toupper(*ytp);
1104 }
1105 }
1106 nexttokload->lvalv.intv
1107 = tempov = findop(thistokstart);
1108 nexttokload->tokv =
1109 optab[tempov].token;
1110 nexttokload->errtype = Yetopcode;
1111 whichsym = Symsym;
1112 }
1113 else
1114 {
1115 symp = symbentry(thistokstart,SYMBOL);
1116 if(symp->seg != SSG_RESV)
1117 {
1118 nexttokload->lvalv.symb = symp;
1119 nexttokload->errtype = Yetsymbol;
1120 }
1121 else
1122 {
1123 nexttokload->lvalv.intv
1124 = symp->value;
1125 nexttokload->errtype = Yetreserved;
1126 }
1127
1128 nexttokload->tokv = symp->tok;
1129 }
1130
1131 nexttokload->textend = frainptr;
1132 nexttokload++;
1133 intokcnt++;
1134 }
1135 break;
1136
1137 case 8: /* load $ token */
1138 nexttokload->lvalv.longv = 0;
1139 nexttokload->tokv = '$';
1140 nexttokload->errtype = Yetprint;
1141 nexttokload++;
1142 intokcnt++;
1143 break;
1144
1145 case 9: /* setup for $hex */
1146 consbase = 16;
1147 consaccum = 0;
1148 break;
1149
1150 case 10: /* accumulate 0-9 constant */
1151 consaccum = (consaccum * consbase)
1152 + (nextchar - '0');
1153 break;
1154
1155 case 11: /* accumulate A-F constant */
1156 consaccum = (consaccum * consbase)
1157 + (nextchar - 'A' + 10);
1158 break;
1159
1160 case 12: /* accumulate a-f constant */
1161 consaccum = (consaccum * consbase)
1162 + (nextchar - 'a' + 10);
1163 break;
1164
1165 case 13: /* load Constant token */
1166 nexttokload->lvalv.longv =
1167 consaccum;
1168 nexttokload->tokv = CONSTANT;
1169 nexttokload->errtype = Yetconstant;
1170 nexttokload->textend = frainptr;
1171 nexttokload++;
1172 intokcnt++;
1173 break;
1174
1175 case 14: /* load @ token */
1176 nexttokload->lvalv.longv = 0;
1177 nexttokload->tokv = '@';
1178 nexttokload->errtype = Yetprint;
1179 nexttokload++;
1180 intokcnt++;
1181 break;
1182
1183 case 15: /* setup for @octal */
1184 consbase = 8;
1185 consaccum = 0;
1186 break;
1187
1188 case 16: /* setup for %binary */
1189 consbase = 2;
1190 consaccum = 0;
1191 break;
1192
1193 case 17: /* load % token */
1194 nexttokload->lvalv.longv = 0;
1195 nexttokload->tokv = '%';
1196 nexttokload->errtype = Yetprint;
1197 nexttokload++;
1198 intokcnt++;
1199 break;
1200
1201 case 18: /* load String token (double quoted) */
1202 *tptrstr++ = '\0';
1203 nexttokload->lvalv.strng =
1204 thistokstart;
1205 nexttokload->tokv = STRING;
1206 nexttokload->errtype = Yetstring;
1207 nexttokload->textend = frainptr;
1208 nexttokload++;
1209 intokcnt++;
1210 break;
1211
1212 case 35: /* load String token (single quoted) */
1213 *tptrstr++ = '\0';
1214 if (tptrstr == thistokstart + 2)
1215 {
1216 nexttokload->lvalv.longv = *thistokstart & 0xFF;
1217 nexttokload->tokv = QCHAR;
1218 nexttokload->errtype = Yetconstant;
1219 } else
1220 {
1221 nexttokload->lvalv.strng =
1222 thistokstart;
1223 nexttokload->tokv = STRING;
1224 nexttokload->errtype = Yetstring;
1225 }
1226 nexttokload->textend = frainptr;
1227 nexttokload++;
1228 intokcnt++;
1229 break;
1230
1231 case 19: /* load GE token */
1232 nexttokload->lvalv.longv = 0;
1233 nexttokload->tokv = KEOP_GE;
1234 nexttokload->errtype = Yetunprint;
1235 nexttokload++;
1236 intokcnt++;
1237 break;
1238
1239 case 20: /* load GT token */
1240 nexttokload->lvalv.longv = 0;
1241 nexttokload->tokv = KEOP_GT;
1242 nexttokload->errtype = Yetunprint;
1243 nexttokload++;
1244 intokcnt++;
1245 break;
1246
1247 case 21: /* load LE token */
1248 nexttokload->lvalv.longv = 0;
1249 nexttokload->tokv = KEOP_LE;
1250 nexttokload->errtype = Yetunprint;
1251 nexttokload++;
1252 intokcnt++;
1253 break;
1254
1255 case 22: /* load NE token */
1256 nexttokload->lvalv.longv = 0;
1257 nexttokload->tokv = KEOP_NE;
1258 nexttokload->errtype = Yetunprint;
1259 nexttokload++;
1260 intokcnt++;
1261 break;
1262
1263 case 23: /* load LT token */
1264 nexttokload->lvalv.longv = 0;
1265 nexttokload->tokv = KEOP_LT;
1266 nexttokload->errtype = Yetunprint;
1267 nexttokload++;
1268 intokcnt++;
1269 break;
1270
1271 case 24: /* save numeric char 0-9 */
1272 *tptrstr++ = nextchar - '0';
1273 break;
1274
1275 case 25: /* save numeric char A-F */
1276 *tptrstr++ = nextchar - 'A' + 10;
1277 break;
1278
1279 case 26: /* save numeric char a-f */
1280 *tptrstr++ = nextchar - 'a' + 10;
1281 break;
1282
1283 case 27: /* convert numeric string base 2 */
1284 {
1285 consaccum = 0;
1286 while(thistokstart < tptrstr)
1287 {
1288 consaccum = (consaccum * 2) + *thistokstart++;
1289 }
1290 nexttokload->lvalv.longv = consaccum;
1291 nexttokload->tokv = CONSTANT;
1292 nexttokload->errtype = Yetconstant;
1293 nexttokload->textend = frainptr;
1294 nexttokload++;
1295 intokcnt++;
1296 }
1297 break;
1298
1299 case 28: /* convert numeric string base 8 */
1300 {
1301 consaccum = 0;
1302 while(thistokstart < tptrstr)
1303 {
1304 consaccum = (consaccum * 8) + *thistokstart++;
1305 }
1306 nexttokload->lvalv.longv = consaccum;
1307 nexttokload->tokv = CONSTANT;
1308 nexttokload->errtype = Yetconstant;
1309 nexttokload->textend = frainptr;
1310 nexttokload++;
1311 intokcnt++;
1312 }
1313 break;
1314
1315 case 29: /* convert numeric string base 10 */
1316 {
1317 consaccum = 0;
1318 while(thistokstart < tptrstr)
1319 {
1320 consaccum = (consaccum * 10) + *thistokstart++;
1321 }
1322 nexttokload->lvalv.longv = consaccum;
1323 nexttokload->tokv = CONSTANT;
1324 nexttokload->errtype = Yetconstant;
1325 nexttokload->textend = frainptr;
1326 nexttokload++;
1327 intokcnt++;
1328 }
1329 break;
1330
1331 case 30: /* convert numeric string base 16 */
1332 {
1333 consaccum = 0;
1334 while(thistokstart < tptrstr)
1335 {
1336 consaccum = (consaccum * 16) + *thistokstart++;
1337 }
1338 nexttokload->lvalv.longv = consaccum;
1339 nexttokload->tokv = CONSTANT;
1340 nexttokload->errtype = Yetconstant;
1341 nexttokload->textend = frainptr;
1342 nexttokload++;
1343 intokcnt++;
1344 }
1345 break;
1346
1347 case 31: /* save numeric 0xb */
1348 *tptrstr++ = 0xb;
1349 break;
1350
1351 case 32: /* save numeric 0xd */
1352 *tptrstr++ = 0xd;
1353 break;
1354
1355 case 33: /* set text start */
1356 nexttokload->textstrt = frainptr;
1357 break;
1358
1359 case 34: /* token choke */
1360 nexttokload->lvalv.longv = 0L;
1361 nexttokload->tokv = KTK_invalid;
1362 nexttokload->errtype = Yetinvalid;
1363 nexttokload->textend = frainptr;
1364 nexttokload++;
1365 intokcnt++;
1366 break;
1367 }
1368
1369 scanstate = thisact->nextstate;
1370
1371 } while( thisact->contin);
1372 }
1373
1374 if(intokcnt <= 0)
1375 { /* no tokens in line (comment or whitespace overlength) */
1376 scanqueue[0].tokv = EOL;
1377 scanqueue[0].errtype = Yetunprint;
1378 scanqueue[0].lvalv.longv = 0;
1379 intokcnt = 1;
1380 }
1381
1382 if(scanstate != 0)
1383 { /* no EOL */
1384 fraerror("Overlength/Unterminated Line");
1385 }
1386 }
1387 lasttokfetch = &scanqueue[currtok++];
1388 yylval = lasttokfetch->lvalv;
1389 return lasttokfetch->tokv;
1390 }
1391
1392
yyerror(char * str)1393 int yyerror(char *str)
1394 /*
1395 description first pass - output a parser error to intermediate file
1396 */
1397 {
1398 char * taglab;
1399
1400 if (!lasttokfetch)
1401 {
1402 emit_warnerr
1403 (
1404 infilestk[currfstk].fnm, infilestk[currfstk].line, ERROR,
1405 "%s near start of input (empty file?)",
1406 str
1407 );
1408 return 0;
1409 }
1410
1411 switch(lasttokfetch->errtype)
1412 {
1413 case Yetprint:
1414 if( ! isprint(lasttokfetch->tokv))
1415 {
1416 emit_warnerr
1417 (
1418 infilestk[currfstk].fnm, infilestk[currfstk].line, ERROR,
1419 "%s at/before character \"^%c\"",
1420 str, PRINTCTRL(lasttokfetch->tokv)
1421 );
1422 }
1423 else
1424 {
1425 emit_warnerr
1426 (
1427 infilestk[currfstk].fnm, infilestk[currfstk].line, ERROR,
1428 "%s at/before character \"%c\"",
1429 str, lasttokfetch->tokv
1430 );
1431 }
1432 break;
1433
1434 case Yetsymbol:
1435 case Yetreserved:
1436 case Yetopcode:
1437 case Yetconstant:
1438 erryytextex(SYMBOL);
1439 emit_warnerr
1440 (
1441 infilestk[currfstk].fnm, infilestk[currfstk].line, ERROR,
1442 "%s at/before token \"%s\"",
1443 str, yytext
1444 );
1445 break;
1446
1447 case Yetinvalid:
1448 erryytextex(SYMBOL);
1449 emit_warnerr
1450 (
1451 infilestk[currfstk].fnm, infilestk[currfstk].line, ERROR,
1452 "%s at invalid token \"%s\"",
1453 str, yytext
1454 );
1455 break;
1456
1457 case Yetstring:
1458 erryytextex(STRING);
1459 emit_warnerr
1460 (
1461 infilestk[currfstk].fnm, infilestk[currfstk].line, ERROR,
1462 "%s at/before string %s",
1463 str, yytext
1464 );
1465 break;
1466
1467 case Yetunprint:
1468 switch(lasttokfetch->tokv)
1469 {
1470 case EOL:
1471 taglab = "End of Line";
1472 break;
1473 case KEOP_EQ:
1474 taglab = "\"=\"";
1475 break;
1476 case KEOP_GE:
1477 taglab = "\">=\"";
1478 break;
1479 case KEOP_GT:
1480 taglab = "\">\"";
1481 break;
1482 case KEOP_LE:
1483 taglab = "\"<=\"";
1484 break;
1485 case KEOP_NE:
1486 taglab = "\"<>\"";
1487 break;
1488 case KEOP_LT:
1489 taglab = "\"<\"";
1490 break;
1491 default:
1492 taglab = "Undeterminable Symbol";
1493 break;
1494 }
1495 emit_warnerr
1496 (
1497 infilestk[currfstk].fnm, infilestk[currfstk].line, ERROR,
1498 "%s at/before %s",
1499 str, taglab
1500 );
1501 break;
1502
1503 default:
1504 emit_warnerr
1505 (
1506 infilestk[currfstk].fnm, infilestk[currfstk].line, ERROR,
1507 "%s - undetermined yyerror type", str
1508 );
1509 break;
1510 }
1511 return 0;
1512 }
1513