1 /* $NetBSD: reader.c,v 1.7 2011/09/10 21:29:04 christos Exp $ */
2 /* Id: reader.c,v 1.33 2011/09/06 22:56:53 tom Exp */
7 __RCSID("$NetBSD: reader.c,v 1.7 2011/09/10 21:29:04 christos Exp $");
9 /* The line size must be a positive integer. One hundred was chosen */
10 /* because few lines in Yacc input grammars exceed 100 characters. */
11 /* Note that if a line exceeds LINESIZE characters, the line buffer */
12 /* will be expanded to accomodate it. */
19 static void start_rule(bucket
*bp
, int s_lineno
);
22 static int cinc
, cache_size
;
26 static char **tag_table
;
36 static char last_was_action
;
39 static bucket
**pitem
;
44 static size_t name_pool_size
;
45 static char *name_pool
;
47 char line_format
[] = "#line %d \"%s\"\n";
56 if (cinc
>= cache_size
)
59 cache
= REALLOC(cache
, cache_size
);
62 cache
[cinc
] = (char)c
;
73 if (saw_eof
|| (c
= getc(f
)) == EOF
)
85 if (line
== 0 || linesize
!= (LINESIZE
+ 1))
89 linesize
= LINESIZE
+ 1;
90 line
= MALLOC(linesize
);
106 linesize
+= LINESIZE
;
107 line
= REALLOC(line
, linesize
);
131 p
= MALLOC(s
- line
+ 1);
136 while ((*t
++ = *s
++) != '\n')
146 int st_lineno
= lineno
;
147 char *st_line
= dup_line();
148 char *st_cptr
= st_line
+ (cptr
- line
);
153 if (*s
== '*' && s
[1] == '/')
163 unterminated_comment(st_lineno
, st_line
, st_cptr
);
217 else if (s
[1] == '/')
235 * Compare keyword to cached token, treating '_' and '-' the same. Some
236 * grammars rely upon this misfeature.
239 matchec(const char *name
)
241 const char *p
= cache
;
242 const char *q
= name
;
243 int code
= 0; /* assume mismatch */
245 while (*p
!= '\0' && *q
!= '\0')
255 if (*p
== '\0' && *q
== '\0')
298 if (matchec("token") || matchec("term"))
304 if (matchec("right"))
306 if (matchec("nonassoc") || matchec("binary"))
308 if (matchec("start"))
310 if (matchec("union"))
312 if (matchec("ident"))
314 if (matchec("expect"))
316 if (matchec("expect-rr"))
318 if (matchec("pure-parser"))
319 return (PURE_PARSER
);
320 if (matchec("parse-param"))
321 return (PARSE_PARAM
);
322 if (matchec("lex-param"))
332 if (c
== '%' || c
== '\\')
343 syntax_error(lineno
, line
, t_cptr
);
352 FILE *f
= output_file
;
358 syntax_error(lineno
, line
, cptr
);
360 fprintf(f
, "#ident \"");
385 int need_newline
= 0;
386 int t_lineno
= lineno
;
387 char *t_line
= dup_line();
388 char *t_cptr
= t_line
+ (cptr
- line
- 2);
394 unterminated_text(t_lineno
, t_line
, t_cptr
);
397 fprintf(f
, line_format
, lineno
, input_file_name
);
410 unterminated_text(t_lineno
, t_line
, t_cptr
);
415 int s_lineno
= lineno
;
416 char *s_line
= dup_line();
417 char *s_cptr
= s_line
+ (cptr
- line
- 1);
432 unterminated_string(s_lineno
, s_line
, s_cptr
);
441 unterminated_string(s_lineno
, s_line
, s_cptr
);
454 while ((c
= *++cptr
) != '\n')
456 if (c
== '*' && cptr
[1] == '/')
466 int c_lineno
= lineno
;
467 char *c_line
= dup_line();
468 char *c_cptr
= c_line
+ (cptr
- line
- 1);
476 if (c
== '*' && *cptr
== '/')
487 unterminated_comment(c_lineno
, c_line
, c_cptr
);
514 puts_both(const char *s
)
518 fputs(s
, union_file
);
535 int u_lineno
= lineno
;
536 char *u_line
= dup_line();
537 char *u_cptr
= u_line
+ (cptr
- line
- 6);
540 over_unionized(cptr
- 6);
544 fprintf(text_file
, line_format
, lineno
, input_file_name
);
546 puts_both("#ifdef YYSTYPE\n");
547 puts_both("#undef YYSTYPE_IS_DECLARED\n");
548 puts_both("#define YYSTYPE_IS_DECLARED 1\n");
549 puts_both("#endif\n");
550 puts_both("#ifndef YYSTYPE_IS_DECLARED\n");
551 puts_both("#define YYSTYPE_IS_DECLARED 1\n");
552 puts_both("typedef union");
564 unterminated_union(u_lineno
, u_line
, u_cptr
);
574 puts_both(" YYSTYPE;\n");
575 puts_both("#endif /* !YYSTYPE_IS_DECLARED */\n");
584 int s_lineno
= lineno
;
585 char *s_line
= dup_line();
586 char *s_cptr
= s_line
+ (cptr
- line
- 1);
599 unterminated_string(s_lineno
, s_line
, s_cptr
);
608 unterminated_string(s_lineno
, s_line
, s_cptr
);
619 while ((c
= *++cptr
) != '\n')
621 if (c
== '*' && cptr
[1] == '/')
635 int c_lineno
= lineno
;
636 char *c_line
= dup_line();
637 char *c_cptr
= c_line
+ (cptr
- line
- 1);
645 if (c
== '*' && *cptr
== '/')
656 unterminated_comment(c_lineno
, c_line
, c_cptr
);
668 * Keep a linked list of parameters
692 buf
= MALLOC(linesize
);
695 for (i
= 0; (c
= *cptr
++) != '}'; i
++)
708 while (i
>= 0 && isspace(UCH(buf
[i
])))
714 while (i
>= 0 && level
> 0 && buf
[i
] != '[')
718 else if (buf
[i
] == '[')
731 while (i
>= 0 && (isalnum(UCH(buf
[i
])) ||
735 if (!isspace(UCH(buf
[i
])) && buf
[i
] != '*')
740 p
= MALLOC(sizeof(*p
));
743 p
->type2
= strdup(buf
+ type2
);
748 p
->name
= strdup(buf
+ name
);
776 syntax_error(lineno
, line
, cptr
);
782 if (c
>= '0' && c
<= '9')
784 if (c
>= 'A' && c
<= 'F')
785 return (c
- 'A' + 10);
786 if (c
>= 'a' && c
<= 'f')
787 return (c
- 'a' + 10);
799 int s_lineno
= lineno
;
800 char *s_line
= dup_line();
801 char *s_cptr
= s_line
+ (cptr
- line
);
811 unterminated_string(s_lineno
, s_line
, s_cptr
);
814 char *c_cptr
= cptr
- 1;
822 unterminated_string(s_lineno
, s_line
, s_cptr
);
837 n
= (n
<< 3) + (c
- '0');
841 n
= (n
<< 3) + (c
- '0');
846 illegal_character(c_cptr
);
853 if (n
< 0 || n
>= 16)
854 illegal_character(c_cptr
);
859 if (i
< 0 || i
>= 16)
864 illegal_character(c_cptr
);
900 for (i
= 0; i
< n
; ++i
)
909 for (i
= 0; i
< n
; ++i
)
912 if (c
== '\\' || c
== cache
[0])
946 cachec(((c
>> 6) & 7) + '0');
947 cachec(((c
>> 3) & 7) + '0');
948 cachec((c
& 7) + '0');
962 if (n
== 1 && bp
->value
== UNDEFINED
)
970 is_reserved(char *name
)
974 if (strcmp(name
, ".") == 0 ||
975 strcmp(name
, "$accept") == 0 ||
976 strcmp(name
, "$end") == 0)
979 if (name
[0] == '$' && name
[1] == '$' && isdigit(UCH(name
[2])))
982 while (isdigit(UCH(*s
)))
997 for (c
= *cptr
; IS_IDENT(c
); c
= *++cptr
)
1001 if (is_reserved(cache
))
1002 used_reserved(cache
);
1004 return (lookup(cache
));
1014 for (c
= *cptr
; isdigit(c
); c
= *++cptr
)
1015 n
= (Value_t
) (10 * n
+ (c
- '0'));
1026 int t_lineno
= lineno
;
1027 char *t_line
= dup_line();
1028 char *t_cptr
= t_line
+ (cptr
- line
);
1034 if (!isalpha(c
) && c
!= '_' && c
!= '$')
1035 illegal_tag(t_lineno
, t_line
, t_cptr
);
1043 while (IS_IDENT(c
));
1050 illegal_tag(t_lineno
, t_line
, t_cptr
);
1053 for (i
= 0; i
< ntags
; ++i
)
1055 if (strcmp(cache
, tag_table
[i
]) == 0)
1058 return (tag_table
[i
]);
1062 if (ntags
>= tagmax
)
1065 tag_table
= (char **)
1067 ? REALLOC(tag_table
, (unsigned)tagmax
* sizeof(char *))
1068 : MALLOC((unsigned)tagmax
* sizeof(char *)));
1069 NO_SPACE(tag_table
);
1076 tag_table
[ntags
] = s
;
1083 declare_tokens(int assoc
)
1106 if (isalpha(c
) || c
== '_' || c
== '.' || c
== '$')
1108 else if (c
== '\'' || c
== '"')
1114 tokenized_start(bp
->name
);
1119 if (bp
->tag
&& tag
!= bp
->tag
)
1120 retyped_warning(bp
->name
);
1126 if (bp
->prec
&& prec
!= bp
->prec
)
1127 reprec_warning(bp
->name
);
1128 bp
->assoc
= (Assoc_t
) assoc
;
1138 value
= get_number();
1139 if (bp
->value
!= UNDEFINED
&& value
!= bp
->value
)
1140 revalued_warning(bp
->name
);
1150 * %expect requires special handling
1151 * as it really isn't part of the yacc
1152 * grammar only a flag for yacc proper.
1155 declare_expect(int assoc
)
1159 if (assoc
!= EXPECT
&& assoc
!= EXPECT_RR
)
1163 * Stay away from nextc - doesn't
1164 * detect EOL and will read to EOF.
1174 if (assoc
== EXPECT
)
1175 SRexpect
= get_number();
1177 RRexpect
= get_number();
1181 * Looking for number before EOL.
1182 * Spaces, tabs, and numbers are ok,
1183 * words, punc., etc. are syntax errors.
1185 else if (c
== '\n' || isalpha(c
) || !isspace(c
))
1187 syntax_error(lineno
, line
, cptr
);
1209 syntax_error(lineno
, line
, cptr
);
1215 if (isalpha(c
) || c
== '_' || c
== '.' || c
== '$')
1217 else if (c
== '\'' || c
== '"')
1222 if (bp
->tag
&& tag
!= bp
->tag
)
1223 retyped_warning(bp
->name
);
1237 if (!isalpha(c
) && c
!= '_' && c
!= '.' && c
!= '$')
1238 syntax_error(lineno
, line
, cptr
);
1240 if (bp
->class == TERM
)
1241 terminal_start(bp
->name
);
1242 if (goal
&& goal
!= bp
)
1243 restarted_warning();
1248 read_declarations(void)
1253 cache
= MALLOC(cache_size
);
1262 syntax_error(lineno
, line
, cptr
);
1263 switch (k
= keyword())
1310 /* noop for bison compatibility. byacc is already designed to be posix
1311 * yacc compatible. */
1318 initialize_grammar(void)
1323 pitem
= (bucket
**)MALLOC((unsigned)maxitems
* sizeof(bucket
*));
1334 plhs
= (bucket
**)MALLOC((unsigned)maxrules
* sizeof(bucket
*));
1341 rprec
= (short *)MALLOC((unsigned)maxrules
* sizeof(short));
1348 rassoc
= (char *)MALLOC((unsigned)maxrules
* sizeof(char));
1360 pitem
= (bucket
**)REALLOC(pitem
, (unsigned)maxitems
* sizeof(bucket
*));
1369 plhs
= (bucket
**)REALLOC(plhs
, (unsigned)maxrules
* sizeof(bucket
*));
1372 rprec
= (short *)REALLOC(rprec
, (unsigned)maxrules
* sizeof(short));
1375 rassoc
= (char *)REALLOC(rassoc
, (unsigned)maxrules
* sizeof(char));
1380 advance_to_start(void)
1407 syntax_error(lineno
, line
, s_cptr
);
1412 if (!isalpha(c
) && c
!= '_' && c
!= '.' && c
!= '_')
1413 syntax_error(lineno
, line
, cptr
);
1417 if (bp
->class == TERM
)
1418 terminal_start(bp
->name
);
1427 syntax_error(lineno
, line
, cptr
);
1428 start_rule(bp
, s_lineno
);
1433 start_rule(bucket
*bp
, int s_lineno
)
1435 if (bp
->class == TERM
)
1436 terminal_lhs(s_lineno
);
1437 bp
->class = NONTERM
;
1438 if (nrules
>= maxrules
)
1441 rprec
[nrules
] = UNDEFINED
;
1442 rassoc
[nrules
] = TOKEN
;
1450 if (!last_was_action
&& plhs
[nrules
]->tag
)
1452 if (pitem
[nitems
- 1])
1454 for (i
= nitems
- 1; (i
> 0) && pitem
[i
]; --i
)
1456 if (pitem
[i
+ 1] == 0 || pitem
[i
+ 1]->tag
!= plhs
[nrules
]->tag
)
1457 default_action_warning();
1461 default_action_warning();
1465 last_was_action
= 0;
1466 if (nitems
>= maxitems
)
1474 insert_empty_rule(void)
1479 sprintf(cache
, "$$%d", ++gensym
);
1480 bp
= make_bucket(cache
);
1481 last_symbol
->next
= bp
;
1483 bp
->tag
= plhs
[nrules
]->tag
;
1484 bp
->class = NONTERM
;
1486 if ((nitems
+= 2) > maxitems
)
1488 bpp
= pitem
+ nitems
- 1;
1490 while ((bpp
[0] = bpp
[-1]) != 0)
1493 if (++nrules
>= maxrules
)
1495 plhs
[nrules
] = plhs
[nrules
- 1];
1496 plhs
[nrules
- 1] = bp
;
1497 rprec
[nrules
] = rprec
[nrules
- 1];
1498 rprec
[nrules
- 1] = 0;
1499 rassoc
[nrules
] = rassoc
[nrules
- 1];
1500 rassoc
[nrules
- 1] = TOKEN
;
1508 int s_lineno
= lineno
;
1511 if (c
== '\'' || c
== '"')
1520 start_rule(bp
, s_lineno
);
1525 if (last_was_action
)
1526 insert_empty_rule();
1527 last_was_action
= 0;
1529 if (++nitems
> maxitems
)
1531 pitem
[nitems
- 1] = bp
;
1535 after_blanks(char *s
)
1537 while (*s
!= '\0' && isspace(UCH(*s
)))
1550 FILE *f
= action_file
;
1551 int a_lineno
= lineno
;
1552 char *a_line
= dup_line();
1553 char *a_cptr
= a_line
+ (cptr
- line
);
1555 if (last_was_action
)
1556 insert_empty_rule();
1557 last_was_action
= 1;
1559 fprintf(f
, "case %d:\n", nrules
- 2);
1561 fprintf(f
, line_format
, lineno
, input_file_name
);
1565 /* avoid putting curly-braces in first column, to ease editing */
1566 if (*after_blanks(cptr
) == L_CURL
)
1569 cptr
= after_blanks(cptr
);
1573 for (i
= nitems
- 1; pitem
[i
]; --i
)
1583 int d_lineno
= lineno
;
1584 char *d_line
= dup_line();
1585 char *d_cptr
= d_line
+ (cptr
- line
);
1592 fprintf(f
, "yyval.%s", tag
);
1597 else if (isdigit(c
))
1601 dollar_warning(d_lineno
, i
);
1602 fprintf(f
, "yystack.l_mark[%d].%s", i
- n
, tag
);
1606 else if (c
== '-' && isdigit(UCH(cptr
[1])))
1609 i
= -get_number() - n
;
1610 fprintf(f
, "yystack.l_mark[%d].%s", i
, tag
);
1615 dollar_error(d_lineno
, d_line
, d_cptr
);
1617 else if (cptr
[1] == '$')
1621 tag
= plhs
[nrules
]->tag
;
1624 fprintf(f
, "yyval.%s", tag
);
1627 fprintf(f
, "yyval");
1631 else if (isdigit(UCH(cptr
[1])))
1637 if (i
<= 0 || i
> n
)
1639 tag
= pitem
[nitems
+ i
- n
- 1]->tag
;
1641 untyped_rhs(i
, pitem
[nitems
+ i
- n
- 1]->name
);
1642 fprintf(f
, "yystack.l_mark[%d].%s", i
- n
, tag
);
1647 dollar_warning(lineno
, i
);
1648 fprintf(f
, "yystack.l_mark[%d]", i
- n
);
1652 else if (cptr
[1] == '-')
1658 fprintf(f
, "yystack.l_mark[%d]", -i
- n
);
1662 if (isalpha(c
) || c
== '_' || c
== '$')
1669 while (isalnum(c
) || c
== '_' || c
== '$');
1681 unterminated_action(a_lineno
, a_line
, a_cptr
);
1686 fprintf(f
, "\nbreak;\n");
1697 fprintf(f
, "\nbreak;\n");
1704 int s_lineno
= lineno
;
1705 char *s_line
= dup_line();
1706 char *s_cptr
= s_line
+ (cptr
- line
- 1);
1719 unterminated_string(s_lineno
, s_line
, s_cptr
);
1728 unterminated_string(s_lineno
, s_line
, s_cptr
);
1739 while ((c
= *++cptr
) != '\n')
1741 if (c
== '*' && cptr
[1] == '/')
1751 int c_lineno
= lineno
;
1752 char *c_line
= dup_line();
1753 char *c_cptr
= c_line
+ (cptr
- line
- 1);
1761 if (c
== '*' && *cptr
== '/')
1772 unterminated_comment(c_lineno
, c_line
, c_cptr
);
1790 if (c
== '%' || c
== '\\')
1798 else if ((c
== 'p' || c
== 'P') &&
1799 ((c
= cptr
[2]) == 'r' || c
== 'R') &&
1800 ((c
= cptr
[3]) == 'e' || c
== 'E') &&
1801 ((c
= cptr
[4]) == 'c' || c
== 'C') &&
1802 ((c
= cptr
[5], !IS_IDENT(c
))))
1805 syntax_error(lineno
, line
, cptr
);
1808 if (isalpha(c
) || c
== '_' || c
== '.' || c
== '$')
1810 else if (c
== '\'' || c
== '"')
1814 syntax_error(lineno
, line
, cptr
);
1818 if (rprec
[nrules
] != UNDEFINED
&& bp
->prec
!= rprec
[nrules
])
1821 rprec
[nrules
] = bp
->prec
;
1822 rassoc
[nrules
] = bp
->assoc
;
1831 initialize_grammar();
1846 else if (c
== L_CURL
|| c
== '=')
1851 start_rule(plhs
[nrules
- 1], 0);
1860 syntax_error(lineno
, line
, cptr
);
1873 for (i
= 0; i
< ntags
; ++i
)
1875 assert(tag_table
[i
]);
1887 name_pool_size
= 13; /* 13 == sizeof("$end") + sizeof("$accept") */
1888 for (bp
= first_symbol
; bp
; bp
= bp
->next
)
1889 name_pool_size
+= strlen(bp
->name
) + 1;
1891 name_pool
= MALLOC(name_pool_size
);
1892 NO_SPACE(name_pool
);
1894 strlcpy(name_pool
, "$accept", name_pool_size
);
1895 strlcpy(name_pool
+ 8, "$end", name_pool_size
- 8);
1897 for (bp
= first_symbol
; bp
; bp
= bp
->next
)
1901 while ((*t
++ = *s
++) != 0)
1913 if (goal
->class == UNKNOWN
)
1914 undefined_goal(goal
->name
);
1916 for (bp
= first_symbol
; bp
; bp
= bp
->next
)
1918 if (bp
->class == UNKNOWN
)
1920 undefined_symbol_warning(bp
->name
);
1927 protect_string(char *src
, char **des
)
1940 if ('\\' == *s
|| '"' == *s
)
1946 *des
= d
= (char *)MALLOC(len
);
1952 if ('\\' == *s
|| '"' == *s
)
1969 for (bp
= first_symbol
; bp
; bp
= bp
->next
)
1972 if (bp
->class == TERM
)
1975 start_symbol
= (Value_t
) ntokens
;
1976 nvars
= nsyms
- ntokens
;
1978 symbol_name
= (char **)MALLOC((unsigned)nsyms
* sizeof(char *));
1979 NO_SPACE(symbol_name
);
1981 symbol_value
= (short *)MALLOC((unsigned)nsyms
* sizeof(short));
1982 NO_SPACE(symbol_value
);
1984 symbol_prec
= (short *)MALLOC((unsigned)nsyms
* sizeof(short));
1985 NO_SPACE(symbol_prec
);
1987 symbol_assoc
= MALLOC(nsyms
);
1988 NO_SPACE(symbol_assoc
);
1990 v
= (bucket
**)MALLOC((unsigned)nsyms
* sizeof(bucket
*));
1994 v
[start_symbol
] = 0;
1997 j
= (Value_t
) (start_symbol
+ 1);
1998 for (bp
= first_symbol
; bp
; bp
= bp
->next
)
2000 if (bp
->class == TERM
)
2005 assert(i
== ntokens
&& j
== nsyms
);
2007 for (i
= 1; i
< ntokens
; ++i
)
2010 goal
->index
= (Index_t
) (start_symbol
+ 1);
2011 k
= (Value_t
) (start_symbol
+ 2);
2021 for (i
= (Value_t
) (start_symbol
+ 1); i
< nsyms
; ++i
)
2031 for (i
= 1; i
< ntokens
; ++i
)
2036 for (j
= k
++; j
> 0 && symbol_value
[j
- 1] > n
; --j
)
2037 symbol_value
[j
] = symbol_value
[j
- 1];
2038 symbol_value
[j
] = n
;
2044 if (v
[1]->value
== UNDEFINED
)
2049 for (i
= 2; i
< ntokens
; ++i
)
2051 if (v
[i
]->value
== UNDEFINED
)
2053 while (j
< k
&& n
== symbol_value
[j
])
2055 while (++j
< k
&& n
== symbol_value
[j
])
2064 symbol_name
[0] = name_pool
+ 8;
2065 symbol_value
[0] = 0;
2067 symbol_assoc
[0] = TOKEN
;
2068 for (i
= 1; i
< ntokens
; ++i
)
2070 symbol_name
[i
] = v
[i
]->name
;
2071 symbol_value
[i
] = v
[i
]->value
;
2072 symbol_prec
[i
] = v
[i
]->prec
;
2073 symbol_assoc
[i
] = v
[i
]->assoc
;
2075 symbol_name
[start_symbol
] = name_pool
;
2076 symbol_value
[start_symbol
] = -1;
2077 symbol_prec
[start_symbol
] = 0;
2078 symbol_assoc
[start_symbol
] = TOKEN
;
2079 for (++i
; i
< nsyms
; ++i
)
2082 symbol_name
[k
] = v
[i
]->name
;
2083 symbol_value
[k
] = v
[i
]->value
;
2084 symbol_prec
[k
] = v
[i
]->prec
;
2085 symbol_assoc
[k
] = v
[i
]->assoc
;
2090 symbol_pname
= (char **)MALLOC((unsigned)nsyms
* sizeof(char *));
2091 NO_SPACE(symbol_pname
);
2093 for (i
= 0; i
< nsyms
; ++i
)
2094 protect_string(symbol_name
[i
], &(symbol_pname
[i
]));
2108 ritem
= (short *)MALLOC((unsigned)nitems
* sizeof(short));
2111 rlhs
= (short *)MALLOC((unsigned)nrules
* sizeof(short));
2114 rrhs
= (short *)MALLOC((unsigned)(nrules
+ 1) * sizeof(short));
2117 rprec
= (short *)REALLOC(rprec
, (unsigned)nrules
* sizeof(short));
2120 rassoc
= REALLOC(rassoc
, nrules
);
2124 ritem
[1] = goal
->index
;
2129 rlhs
[2] = start_symbol
;
2135 for (i
= 3; i
< nrules
; ++i
)
2137 rlhs
[i
] = plhs
[i
]->index
;
2143 ritem
[j
] = pitem
[j
]->index
;
2144 if (pitem
[j
]->class == TERM
)
2146 prec2
= pitem
[j
]->prec
;
2147 assoc
= pitem
[j
]->assoc
;
2151 ritem
[j
] = (Value_t
) - i
;
2153 if (rprec
[i
] == UNDEFINED
)
2169 size_t j
, spacing
= 0;
2170 FILE *f
= verbose_file
;
2176 for (i
= 2; i
< nrules
; ++i
)
2178 if (rlhs
[i
] != rlhs
[i
- 1])
2182 fprintf(f
, "%4d %s :", i
- 2, symbol_name
[rlhs
[i
]]);
2183 spacing
= strlen(symbol_name
[rlhs
[i
]]) + 1;
2187 fprintf(f
, "%4d ", i
- 2);
2194 while (ritem
[k
] >= 0)
2196 fprintf(f
, " %s", symbol_name
[ritem
[k
]]);
2207 write_section(code_file
, banner
);
2208 create_symbol_table();
2209 read_declarations();
2211 free_symbol_table();
2223 free_declarations(param
* list
)
2227 param
*next
= list
->next
;
2240 lex_param
= free_declarations(lex_param
);
2241 parse_param
= free_declarations(parse_param
);
2251 DO_FREE(symbol_name
);
2252 DO_FREE(symbol_prec
);
2253 DO_FREE(symbol_assoc
);
2254 DO_FREE(symbol_value
);