2 * Copyright (c) 1989 The Regents of the University of California.
5 * This code is derived from software contributed to Berkeley by
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 static char sccsid[] = "@(#)reader.c 5.7 (Berkeley) 1/20/91";
43 /* this resolves "unresolved symbol _snprintf" on Windows */
44 #if defined (_MSC_VER)
45 #define snprintf _snprintf
48 /* The line size must be a positive integer. One hundred was chosen */
49 /* because few lines in Yacc input grammars exceed 100 characters. */
50 /* Note that if a line exceeds LINESIZE characters, the line buffer */
51 /* will be expanded to accomodate it. */
81 char *line_format = "\t\t\t\t\t// line %d \"%s\"\n";
82 char *default_line_format = "\t\t\t\t\t// line %d\n";
89 if (cinc >= cache_size)
92 cache = REALLOC(cache, cache_size);
93 if (cache == 0) no_space();
102 register FILE *f = input_file;
106 if (saw_eof || (c = getc(f)) == EOF)
108 if (line) { FREE(line); line = 0; }
114 if (line == 0 || linesize != (LINESIZE + 1))
116 if (line) FREE(line);
117 linesize = LINESIZE + 1;
118 line = MALLOC(linesize);
119 if (line == 0) no_space();
127 if (c == '\n') { cptr = line; return; }
130 linesize += LINESIZE;
131 line = REALLOC(line, linesize);
132 if (line == 0) no_space();
149 register char *p, *s, *t;
151 if (line == 0) return (0);
153 while (*s != '\n') ++s;
154 p = MALLOC(s - line + 1);
155 if (p == 0) no_space();
159 while ((*t++ = *s++) != '\n') continue;
168 int st_lineno = lineno;
169 char *st_line = dup_line();
170 char *st_cptr = st_line + (cptr - line);
175 if (*s == '*' && s[1] == '/')
185 unterminated_comment(st_lineno, st_line, st_cptr);
213 if (line == 0) return (EOF);
239 else if (s[1] == '/')
242 if (line == 0) return (EOF);
270 if (isupper(c)) c = tolower(c);
273 else if (isdigit(c) || c == '_' || c == '.' || c == '$')
281 if (strcmp(cache, "token") == 0 || strcmp(cache, "term") == 0)
283 if (strcmp(cache, "type") == 0)
285 if (strcmp(cache, "left") == 0)
287 if (strcmp(cache, "right") == 0)
289 if (strcmp(cache, "nonassoc") == 0 || strcmp(cache, "binary") == 0)
291 if (strcmp(cache, "start") == 0)
299 if (c == '%' || c == '\\')
310 syntax_error(lineno, line, t_cptr);
320 int need_newline = 0;
321 int t_lineno = lineno;
322 char *t_line = dup_line();
323 char *t_cptr = t_line + (cptr - line - 2);
329 unterminated_text(t_lineno, t_line, t_cptr);
331 fprintf(f, line_format, lineno, input_file_name);
343 unterminated_text(t_lineno, t_line, t_cptr);
348 int s_lineno = lineno;
349 char *s_line = dup_line();
350 char *s_cptr = s_line + (cptr - line - 1);
365 unterminated_string(s_lineno, s_line, s_cptr);
374 unterminated_string(s_lineno, s_line, s_cptr);
386 do putc(c, f); while ((c = *++cptr) != '\n');
391 int c_lineno = lineno;
392 char *c_line = dup_line();
393 char *c_cptr = c_line + (cptr - line - 1);
401 if (c == '*' && *cptr == '/')
412 unterminated_comment(c_lineno, c_line, c_cptr);
423 if (need_newline) putc('\n', f);
441 if (c >= '0' && c <= '9')
443 if (c >= 'A' && c <= 'F')
444 return (c - 'A' + 10);
445 if (c >= 'a' && c <= 'f')
446 return (c - 'a' + 10);
454 register int c, quote;
459 int s_lineno = lineno;
460 char *s_line = dup_line();
461 char *s_cptr = s_line + (cptr - line);
468 if (c == quote) break;
469 if (c == '\n') unterminated_string(s_lineno, s_line, s_cptr);
472 char *c_cptr = cptr - 1;
479 if (line == 0) unterminated_string(s_lineno, s_line, s_cptr);
482 case '0': case '1': case '2': case '3':
483 case '4': case '5': case '6': case '7':
488 n = (n << 3) + (c - '0');
492 n = (n << 3) + (c - '0');
496 if (n > MAXCHAR) illegal_character(c_cptr);
503 if (n < 0 || n >= 16)
504 illegal_character(c_cptr);
509 if (i < 0 || i >= 16) break;
512 if (n > MAXCHAR) illegal_character(c_cptr);
517 case 'a': c = 7; break;
518 case 'b': c = '\b'; break;
519 case 'f': c = '\f'; break;
520 case 'n': c = '\n'; break;
521 case 'r': c = '\r'; break;
522 case 't': c = '\t'; break;
523 case 'v': c = '\v'; break;
532 if (s == 0) no_space();
534 for (i = 0; i < n; ++i)
543 for (i = 0; i < n; ++i)
545 c = ((unsigned char *)s)[i];
546 if (c == '\\' || c == cache[0])
558 case 7: cachec('a'); break;
559 case '\b': cachec('b'); break;
560 case '\f': cachec('f'); break;
561 case '\n': cachec('n'); break;
562 case '\r': cachec('r'); break;
563 case '\t': cachec('t'); break;
564 case '\v': cachec('v'); break;
566 cachec(((c >> 6) & 7) + '0');
567 cachec(((c >> 3) & 7) + '0');
568 cachec((c & 7) + '0');
582 if (n == 1 && bp->value == UNDEFINED)
583 bp->value = *(unsigned char *)s;
596 if (strcmp(name, ".") == 0 ||
597 strcmp(name, "$accept") == 0 ||
598 strcmp(name, "$end") == 0)
601 if (name[0] == '$' && name[1] == '$' && isdigit(name[2]))
604 while (isdigit(*s)) ++s;
605 if (*s == NUL) return (1);
618 for (c = *cptr; IS_IDENT(c); c = *++cptr)
622 if (is_reserved(cache)) used_reserved(cache);
624 return (lookup(cache));
635 for (c = *cptr; isdigit(c); c = *++cptr)
636 n = 10*n + (c - '0');
648 int t_lineno = lineno;
649 char *t_line = dup_line();
650 char *t_cptr = t_line + (cptr - line);
654 if (c == EOF) unexpected_EOF();
655 if (emptyOk && c == '>') {
656 ++cptr; return 0; // 0 indicates empty tag if emptyOk
658 if (!isalpha(c) && c != '_' && c != '$')
659 illegal_tag(t_lineno, t_line, t_cptr);
662 do { cachec(c); c = *++cptr; } while (IS_IDENT(c));
666 if (c == EOF) unexpected_EOF();
668 illegal_tag(t_lineno, t_line, t_cptr);
671 for (i = 0; i < ntags; ++i)
673 if (strcmp(cache, tag_table[i]) == 0)
674 return (tag_table[i]);
680 tag_table = (char **)
681 (tag_table ? REALLOC(tag_table, tagmax*sizeof(char *))
682 : MALLOC(tagmax*sizeof(char *)));
683 if (tag_table == 0) no_space();
687 if (s == 0) no_space();
689 tag_table[ntags] = s;
696 declare_tokens(assoc)
704 if (assoc != TOKEN) ++prec;
707 if (c == EOF) unexpected_EOF();
712 if (c == EOF) unexpected_EOF();
717 if (isalpha(c) || c == '_' || c == '.' || c == '$')
719 else if (c == '\'' || c == '"')
724 if (bp == goal) tokenized_start(bp->name);
729 if (bp->tag && tag != bp->tag)
730 retyped_warning(bp->name);
736 if (bp->prec && prec != bp->prec)
737 reprec_warning(bp->name);
743 if (c == EOF) unexpected_EOF();
747 value = get_number();
748 if (bp->value != UNDEFINED && value != bp->value)
749 revalued_warning(bp->name);
752 if (c == EOF) unexpected_EOF();
765 if (c == EOF) unexpected_EOF();
766 if (c != '<') syntax_error(lineno, line, cptr);
772 if (isalpha(c) || c == '_' || c == '.' || c == '$')
774 else if (c == '\'' || c == '"')
779 if (bp->tag && tag != bp->tag)
780 retyped_warning(bp->name);
792 if (c == EOF) unexpected_EOF();
793 if (!isalpha(c) && c != '_' && c != '.' && c != '$')
794 syntax_error(lineno, line, cptr);
796 if (bp->class == TERM)
797 terminal_start(bp->name);
798 if (goal && goal != bp)
809 cache = MALLOC(cache_size);
810 if (cache == 0) no_space();
815 if (c == EOF) unexpected_EOF();
816 if (c != '%') syntax_error(lineno, line, cptr);
817 switch (k = keyword())
823 copy_text(prolog_file);
849 pitem = (bucket **) MALLOC(maxitems*sizeof(bucket *));
850 if (pitem == 0) no_space();
859 plhs = (bucket **) MALLOC(maxrules*sizeof(bucket *));
860 if (plhs == 0) no_space();
864 rprec = (short *) MALLOC(maxrules*sizeof(short));
865 if (rprec == 0) no_space();
869 rassoc = (char *) MALLOC(maxrules*sizeof(char));
870 if (rassoc == 0) no_space();
880 pitem = (bucket **) REALLOC(pitem, maxitems*sizeof(bucket *));
881 if (pitem == 0) no_space();
882 memset(pitem+maxitems-300, 0, 300*sizeof(bucket *));
889 plhs = (bucket **) REALLOC(plhs, maxrules*sizeof(bucket *));
890 if (plhs == 0) no_space();
891 rprec = (short *) REALLOC(rprec, maxrules*sizeof(short));
892 if (rprec == 0) no_space();
893 rassoc = (char *) REALLOC(rassoc, maxrules*sizeof(char));
894 if (rassoc == 0) no_space();
916 copy_text(local_file);
924 syntax_error(lineno, line, s_cptr);
929 if (!isalpha(c) && c != '_' && c != '.' && c != '_')
930 syntax_error(lineno, line, cptr);
934 if (bp->class == TERM)
935 terminal_start(bp->name);
941 if (c == EOF) unexpected_EOF();
942 if (c != ':') syntax_error(lineno, line, cptr);
943 start_rule(bp, s_lineno);
948 start_rule(bp, s_lineno)
952 if (bp->class == TERM)
953 terminal_lhs(s_lineno);
955 if (nrules >= maxrules)
958 rprec[nrules] = UNDEFINED;
959 rassoc[nrules] = TOKEN;
967 if (nitems >= maxitems) expand_items();
969 if (!last_was_action && plhs[nrules]->tag)
971 for (i = nitems - 1; pitem[i]; --i) continue;
972 if (pitem[i+1] == 0 || pitem[i+1]->tag != plhs[nrules]->tag)
973 default_action_warning(); /** if classes don't match exactly **/
974 } /** bug: could be superclass... **/
985 register bucket *bp, **bpp;
988 sprintf(cache, "$$%d", ++gensym);
989 bp = make_bucket(cache);
990 last_symbol->next = bp;
992 bp->tag = plhs[nrules]->tag;
995 if ((nitems += 2) > maxitems)
997 bpp = pitem + nitems - 1;
999 while (bpp[0] = bpp[-1]) --bpp;
1001 if (++nrules >= maxrules)
1003 plhs[nrules] = plhs[nrules-1];
1004 plhs[nrules-1] = bp;
1005 rprec[nrules] = rprec[nrules-1];
1006 rprec[nrules-1] = 0;
1007 rassoc[nrules] = rassoc[nrules-1];
1008 rassoc[nrules-1] = TOKEN;
1015 register bucket *bp;
1016 int s_lineno = lineno;
1019 if (c == '\'' || c == '"')
1028 start_rule(bp, s_lineno);
1033 if (last_was_action)
1034 insert_empty_rule();
1035 last_was_action = 0;
1037 if (++nitems > maxitems)
1039 pitem[nitems-1] = bp;
1050 FILE *f = action_file;
1051 int a_lineno = lineno;
1052 char *a_line = dup_line();
1053 char *a_cptr = a_line + (cptr - line);
1054 char buffer [10000];
1056 int comment_lines = 0;
1058 memset (buffer, 0, 10000);
1060 if (last_was_action)
1061 insert_empty_rule();
1062 last_was_action = 1;
1064 fprintf(f, "case %d:\n", nrules - 2);
1065 if (*cptr == '=') ++cptr;
1069 for (i = nitems - 1; pitem[i]; --i) ++n;
1078 int d_lineno = lineno;
1079 char *d_line = dup_line();
1080 char *d_cptr = d_line + (cptr - line);
1087 if (tag && strcmp(tag, "Object")) {
1088 len += sprintf(buffer + len, "((%s)yyVal)", tag);
1090 strcat (buffer + len, "yyVal");
1097 else if (isdigit(c))
1100 if (i > n) dollar_warning(d_lineno, i);
1101 if (tag && strcmp(tag, "Object"))
1102 len += sprintf(buffer + len, "((%s)yyVals[%d+yyTop])", tag, i - n);
1104 len += sprintf(buffer + len, "yyVals[%d+yyTop]", i - n);
1108 else if (c == '-' && isdigit(cptr[1]))
1111 i = -get_number() - n;
1112 if (tag && strcmp(tag, "Object"))
1113 len += sprintf(buffer + len, "((%s)yyVals[%d+yyTop])", tag, i);
1115 len += sprintf(buffer + len, "yyVals[%d+yyTop]", i);
1120 dollar_error(d_lineno, d_line, d_cptr);
1122 else if (cptr[1] == '$')
1124 if (ntags && plhs[nrules]->tag == 0)
1126 strcat (buffer, "yyVal");
1131 else if (isdigit(cptr[1]))
1137 if (i <= 0 || i > n)
1139 tag = pitem[nitems + i - n - 1]->tag;
1141 untyped_rhs(i, pitem[nitems + i - n - 1]->name),
1142 len += sprintf(buffer + len, "yyVals[%d+yyTop]", i - n);
1143 else if (strcmp(tag, "Object"))
1144 len += sprintf(buffer + len, "((%s)yyVals[%d+yyTop])", tag, i - n);
1146 len += sprintf(buffer + len, "yyVals[%d+yyTop]", i - n);
1151 dollar_warning(lineno, i);
1153 len += sprintf(buffer + len,"yyVals[%d+yyTop]", i - n);
1157 else if (cptr[1] == '-')
1163 len += sprintf(buffer + len, "yyVals[%d+yyTop]", -i - n);
1167 if (isalpha(c) || c == '_' || c == '$')
1173 } while (isalnum(c) || c == '_' || c == '$');
1183 if (line) goto loop;
1184 unterminated_action(a_lineno, a_line, a_cptr);
1187 if (depth > 0) goto loop;
1195 if (--depth > 0) goto loop;
1201 int s_lineno = lineno;
1202 char *s_line = dup_line();
1203 char *s_cptr = s_line + (cptr - line - 1);
1216 unterminated_string(s_lineno, s_line, s_cptr);
1225 unterminated_string(s_lineno, s_line, s_cptr);
1235 buffer[len++] = '*';
1236 while ((c = *++cptr) != '\n')
1238 if (c == '*' && cptr[1] == '/'){
1239 buffer[len++] = '*';
1240 buffer[len++] = ' ';
1245 buffer[len++] = '*';
1246 buffer[len++] = '/';
1247 buffer[len++] = '\n';
1252 int c_lineno = lineno;
1253 char *c_line = dup_line();
1254 char *c_cptr = c_line + (cptr - line - 1);
1256 buffer[len++] = '*';
1262 if (c == '*' && *cptr == '/')
1264 buffer[len++] = '/';
1274 unterminated_comment(c_lineno, c_line, c_cptr);
1284 if (comment_lines > 0)
1287 if ((lineno - (a_lineno + comment_lines)) > 2)
1292 // the maximum size of of an unsigned int in characters is 20, with 8 for 'case_()\0'
1293 sprintf(mname, "case_%d()", nrules - 2);
1295 putc(' ', f); putc(' ', f);
1301 methods = NEW2(maxmethods, char *);
1303 else if (nmethods == maxmethods)
1306 methods = REALLOC (methods, maxmethods*sizeof(char *));
1309 line_define = NEW2(snprintf(NULL, 0, line_format, a_lineno, input_file_name)+1, char);
1310 sprintf(line_define, line_format, a_lineno, input_file_name);
1312 mbody = NEW2(5+strlen(line_define)+1+strlen(mname)+strlen(buffer)+1, char);
1313 strcpy(mbody, "void ");
1314 strcat(mbody, mname);
1315 strcat(mbody, "\n");
1316 strcat(mbody, line_define);
1317 strcat(mbody, buffer);
1318 methods[nmethods++] = mbody;
1324 fprintf(f, line_format, lineno, input_file_name);
1325 putc(' ', f); putc(' ', f);
1326 fwrite(buffer, 1, len, f);
1329 fprintf(f, "\n break;\n");
1337 register bucket *bp;
1340 if (c == '%' || c == '\\')
1348 else if ((c == 'p' || c == 'P') &&
1349 ((c = cptr[2]) == 'r' || c == 'R') &&
1350 ((c = cptr[3]) == 'e' || c == 'E') &&
1351 ((c = cptr[4]) == 'c' || c == 'C') &&
1352 ((c = cptr[5], !IS_IDENT(c))))
1355 syntax_error(lineno, line, cptr);
1358 if (isalpha(c) || c == '_' || c == '.' || c == '$')
1360 else if (c == '\'' || c == '"')
1364 syntax_error(lineno, line, cptr);
1368 if (rprec[nrules] != UNDEFINED && bp->prec != rprec[nrules])
1371 rprec[nrules] = bp->prec;
1372 rassoc[nrules] = bp->assoc;
1381 initialize_grammar();
1387 if (c == EOF) break;
1388 if (isalpha(c) || c == '_' || c == '.' || c == '$' || c == '\'' ||
1391 else if (c == '{' || c == '=')
1396 start_rule(plhs[nrules-1], 0);
1401 if (mark_symbol()) break;
1404 syntax_error(lineno, line, cptr);
1414 if (tag_table == 0) return;
1416 for (i = 0; i < ntags; ++i)
1418 assert(tag_table[i]);
1427 register bucket *bp;
1428 register char *p, *s, *t;
1430 name_pool_size = 13; /* 13 == sizeof("$end") + sizeof("$accept") */
1431 for (bp = first_symbol; bp; bp = bp->next)
1432 name_pool_size += strlen(bp->name) + 1;
1433 name_pool = MALLOC(name_pool_size);
1434 if (name_pool == 0) no_space();
1436 strcpy(name_pool, "$accept");
1437 strcpy(name_pool+8, "$end");
1439 for (bp = first_symbol; bp; bp = bp->next)
1443 while (*t++ = *s++) continue;
1452 register bucket *bp;
1454 if (goal->class == UNKNOWN)
1455 undefined_goal(goal->name);
1457 for (bp = first_symbol; bp; bp = bp->next)
1459 if (bp->class == UNKNOWN)
1461 undefined_symbol_warning(bp->name);
1470 register bucket *bp;
1471 register bucket **v;
1472 register int i, j, k, n;
1476 for (bp = first_symbol; bp; bp = bp->next)
1479 if (bp->class == TERM) ++ntokens;
1481 start_symbol = ntokens;
1482 nvars = nsyms - ntokens;
1484 symbol_name = (char **) MALLOC(nsyms*sizeof(char *));
1485 if (symbol_name == 0) no_space();
1486 symbol_value = (short *) MALLOC(nsyms*sizeof(short));
1487 if (symbol_value == 0) no_space();
1488 symbol_prec = (short *) MALLOC(nsyms*sizeof(short));
1489 if (symbol_prec == 0) no_space();
1490 symbol_assoc = MALLOC(nsyms);
1491 if (symbol_assoc == 0) no_space();
1493 v = (bucket **) MALLOC(nsyms*sizeof(bucket *));
1494 if (v == 0) no_space();
1497 v[start_symbol] = 0;
1500 j = start_symbol + 1;
1501 for (bp = first_symbol; bp; bp = bp->next)
1503 if (bp->class == TERM)
1508 assert(i == ntokens && j == nsyms);
1510 for (i = 1; i < ntokens; ++i)
1513 goal->index = start_symbol + 1;
1514 k = start_symbol + 2;
1524 for (i = start_symbol + 1; i < nsyms; ++i)
1534 for (i = 1; i < ntokens; ++i)
1539 for (j = k++; j > 0 && symbol_value[j-1] > n; --j)
1540 symbol_value[j] = symbol_value[j-1];
1541 symbol_value[j] = n;
1545 if (v[1]->value == UNDEFINED)
1550 for (i = 2; i < ntokens; ++i)
1552 if (v[i]->value == UNDEFINED)
1554 while (j < k && n == symbol_value[j])
1556 while (++j < k && n == symbol_value[j]) continue;
1564 symbol_name[0] = name_pool + 8;
1565 symbol_value[0] = 0;
1567 symbol_assoc[0] = TOKEN;
1568 for (i = 1; i < ntokens; ++i)
1570 symbol_name[i] = v[i]->name;
1571 symbol_value[i] = v[i]->value;
1572 symbol_prec[i] = v[i]->prec;
1573 symbol_assoc[i] = v[i]->assoc;
1575 symbol_name[start_symbol] = name_pool;
1576 symbol_value[start_symbol] = -1;
1577 symbol_prec[start_symbol] = 0;
1578 symbol_assoc[start_symbol] = TOKEN;
1579 for (++i; i < nsyms; ++i)
1582 symbol_name[k] = v[i]->name;
1583 symbol_value[k] = v[i]->value;
1584 symbol_prec[k] = v[i]->prec;
1585 symbol_assoc[k] = v[i]->assoc;
1597 ritem = (short *) MALLOC(nitems*sizeof(short));
1598 if (ritem == 0) no_space();
1599 rlhs = (short *) MALLOC(nrules*sizeof(short));
1600 if (rlhs == 0) no_space();
1601 rrhs = (short *) MALLOC((nrules+1)*sizeof(short));
1602 if (rrhs == 0) no_space();
1603 rprec = (short *) REALLOC(rprec, nrules*sizeof(short));
1604 if (rprec == 0) no_space();
1605 rassoc = REALLOC(rassoc, nrules);
1606 if (rassoc == 0) no_space();
1609 ritem[1] = goal->index;
1614 rlhs[2] = start_symbol;
1620 for (i = 3; i < nrules; ++i)
1622 rlhs[i] = plhs[i]->index;
1628 ritem[j] = pitem[j]->index;
1629 if (pitem[j]->class == TERM)
1631 prec = pitem[j]->prec;
1632 assoc = pitem[j]->assoc;
1638 if (rprec[i] == UNDEFINED)
1653 register int i, j, k;
1655 register FILE *f = verbose_file;
1660 for (i = 2; i < nrules; ++i)
1662 if (rlhs[i] != rlhs[i-1])
1664 if (i != 2) fprintf(f, "\n");
1665 fprintf(f, "%4d %s :", i - 2, symbol_name[rlhs[i]]);
1666 spacing = strlen(symbol_name[rlhs[i]]) + 1;
1670 fprintf(f, "%4d ", i - 2);
1672 while (--j >= 0) putc(' ', f);
1676 while (ritem[k] >= 0)
1678 fprintf(f, " %s", symbol_name[ritem[k]]);
1689 create_symbol_table();
1690 read_declarations();
1692 free_symbol_table();