1 /* $Id: reader.c,v 1.84 2020/09/10 20:26:13 tom Exp $ */
5 /* The line size must be a positive integer. One hundred was chosen */
6 /* because few lines in Yacc input grammars exceed 100 characters. */
7 /* Note that if a line exceeds LINESIZE characters, the line buffer */
8 /* will be expanded to accommodate it. */
19 /* the maximum number of arguments (inherited attributes) to a non-terminal */
20 /* this is a hard limit, but seems more than adequate */
23 static void start_rule(bucket *bp, int s_lineno);
25 static void copy_initial_action(void);
26 static void copy_destructor(void);
27 static char *process_destructor_XX(char *code, char *tag);
30 #define CACHE_SIZE 256
32 static int cinc, cache_size;
35 static int tagmax, havetags;
36 static char **tag_table;
46 static char last_was_action;
48 static int trialaction;
52 static bucket **pitem;
57 static size_t name_pool_size;
58 static char *name_pool;
60 char line_format[] = "#line %d \"%s\"\n";
65 static const char *code_keys[] =
67 "", "requires", "provides", "top", "imports",
70 struct code_lines code_lines[CODE_MAX];
73 int destructor = 0; /* =1 if at least one %destructor */
75 static bucket *default_destructor[3] =
78 #define UNTYPED_DEFAULT 0
79 #define TYPED_DEFAULT 1
80 #define TYPE_SPECIFIED 2
83 lookup_type_destructor(char *tag)
85 const char fmt[] = "%.*s destructor";
86 char name[1024] = "\0";
87 bucket *bp, **bpp = &default_destructor[TYPE_SPECIFIED];
89 while ((bp = *bpp) != NULL)
96 sprintf(name, fmt, (int)(sizeof(name) - sizeof(fmt)), tag);
97 *bpp = bp = make_bucket(name);
102 #endif /* defined(YYBTYACC) */
108 if (cinc >= cache_size)
110 cache_size += CACHE_SIZE;
111 cache = TREALLOC(char, cache, cache_size);
114 cache[cinc] = (char)c;
133 * Expect this pattern:
134 * /^[[:space:]]*#[[:space:]]*
137 * ([[:space:]]*|[[:space:]]+"[^"]+")/
142 #define UNLESS(what) if (what) { ld = ldERR; break; }
147 LINE_DIR ld = ldSPC1;
148 for (n = 0; (ld <= ldOK) && (line[n] != '\0'); ++n)
150 int ch = UCH(line[n]);
154 if (isspace(UCH(ch)))
163 if (isspace(UCH(ch)))
169 UNLESS(strncmp(line + n, "line", 4));
177 UNLESS(!isspace(UCH(line[n])));
181 if (isspace(UCH(ch)))
186 UNLESS(!isdigit(UCH(ch)));
188 ld = ldNUM; /* this is needed, but cppcheck says no... */
191 if (isdigit(UCH(ch)))
196 UNLESS(!isspace(UCH(ch)));
200 if (isspace(UCH(ch)))
206 UNLESS(line[n + 1] == '"');
226 size_t need = (size_t) (name_end - name_1st);
227 if ((long)need > (long)input_file_name_len)
229 input_file_name_len = ((need + 1) * 3) / 2;
230 input_file_name = TREALLOC(char, input_file_name, input_file_name_len);
231 NO_SPACE(input_file_name);
235 memcpy(input_file_name, line + name_1st + 1, need - 1);
236 input_file_name[need - 1] = '\0';
240 input_file_name[0] = '\0';
244 if (ld >= ldNUM && ld < ldERR)
248 lineno = (int)strtol(line + line_1st, NULL, 10) - 1;
263 FILE *f = input_file;
270 if (saw_eof || (c = getc(f)) == EOF)
282 if (line == NULL || linesize != (LINESIZE + 1))
286 linesize = LINESIZE + 1;
287 line = TMALLOC(char, linesize);
298 if ((i + 3) >= linesize)
300 linesize += LINESIZE;
301 line = TREALLOC(char, line, linesize);
314 while (line_directive());
329 p = TMALLOC(char, s - line + 1);
334 while ((*t++ = *s++) != '\n')
345 a.a_line = dup_line();
346 a.a_cptr = a.a_line + (cptr - line);
351 if (*s == '*' && s[1] == '/')
361 unterminated_comment(&a);
394 else if (s[1] == '/')
419 switch (ch = next_inline())
446 static struct keyword
452 { "binary", NONASSOC },
454 { "debug", XXXDEBUG },
455 #if defined(YYBTYACC)
456 { "destructor", DESTRUCTOR },
458 { "error-verbose",ERROR_VERBOSE },
459 { "expect", EXPECT },
460 { "expect-rr", EXPECT_RR },
462 #if defined(YYBTYACC)
463 { "initial-action", INITIAL_ACTION },
466 { "lex-param", LEX_PARAM },
467 #if defined(YYBTYACC)
468 { "locations", LOCATIONS },
470 { "nonassoc", NONASSOC },
471 { "parse-param", PARSE_PARAM },
472 { "pure-parser", PURE_PARSER },
477 { "token-table", TOKEN_TABLE },
480 { "yacc", POSIX_YACC },
485 compare_keys(const void *a, const void *b)
487 const struct keyword *p = (const struct keyword *)a;
488 const struct keyword *q = (const struct keyword *)b;
489 return strcmp(p->name, q->name);
512 else if (isdigit(UCH(c))
521 /* treat keywords spelled with '_' as if it were '-' */
532 if ((key = bsearch(cache, keywords,
533 sizeof(keywords) / sizeof(*key),
534 sizeof(*key), compare_keys)))
542 if (c == '%' || c == '\\')
553 syntax_error(lineno, line, t_cptr);
561 FILE *f = output_file;
567 syntax_error(lineno, line, cptr);
569 fprintf(f, "#ident \"");
589 copy_string(int quote)
591 struct mstring *temp = msnew();
594 a.a_line = dup_line();
595 a.a_cptr = a.a_line + (cptr - line - 1);
608 unterminated_string(&a);
617 unterminated_string(&a);
626 struct mstring *temp = msnew();
633 while ((c = *++cptr) != '\n')
636 if (c == '*' && cptr[1] == '/')
646 a.a_line = dup_line();
647 a.a_cptr = a.a_line + (cptr - line - 1);
655 if (c == '*' && *cptr == '/')
666 unterminated_comment(&a);
676 const char *key = code_keys[pos];
677 while (*cptr && *key)
678 if (*key++ != *cptr++)
680 if (*key || (!isspace(UCH(*cptr)) && *cptr != L_CURL))
693 int pos = CODE_HEADER;
694 struct mstring *code_mstr;
696 /* read %code <keyword> { */
708 if (pos == CODE_HEADER)
728 if (pos == -1 || !check_key(pos))
730 syntax_error(lineno, line, cptr);
736 cptr++; /* skip initial curl */
737 while (*cptr && isspace(UCH(*cptr))) /* skip space */
739 curl = 1; /* nesting count */
742 code_lines[pos].name = code_keys[pos];
743 if ((cline = (int)code_lines[pos].num) != 0)
745 code_mstr = msrenew(code_lines[pos].lines);
752 msprintf(code_mstr, line_format, lineno, input_file_name);
778 mputc(code_mstr, '\n');
781 code_lines[pos].lines = msdone(code_mstr);
782 code_lines[pos].num = (size_t) cline;
799 int need_newline = 0;
802 a.a_line = dup_line();
803 a.a_cptr = a.a_line + (cptr - line - 2);
809 unterminated_text(&a);
812 fprintf(f, line_format, lineno, input_file_name);
824 unterminated_text(&a);
830 char *s = copy_string(c);
840 char *s = copy_comment();
867 puts_both(const char *s)
871 fputs(s, union_file);
889 a.a_line = dup_line();
890 a.a_cptr = a.a_line + (cptr - line - 6);
893 over_unionized(cptr - 6);
896 puts_both("#ifdef YYSTYPE\n");
897 puts_both("#undef YYSTYPE_IS_DECLARED\n");
898 puts_both("#define YYSTYPE_IS_DECLARED 1\n");
899 puts_both("#endif\n");
900 puts_both("#ifndef YYSTYPE_IS_DECLARED\n");
901 puts_both("#define YYSTYPE_IS_DECLARED 1\n");
904 fprintf(text_file, line_format, lineno, input_file_name);
905 puts_both("typedef union");
916 unterminated_union(&a);
926 puts_both(" YYSTYPE;\n");
927 puts_both("#endif /* !YYSTYPE_IS_DECLARED */\n");
936 char *s = copy_string(c);
944 char *s = copy_comment();
956 after_blanks(char *s)
958 while (*s != '\0' && isspace(UCH(*s)))
964 * Trim leading/trailing blanks, and collapse multiple embedded blanks to a
965 * single space. Return index to last character in the buffer.
968 trim_blanks(char *buffer)
973 char *s = after_blanks(d);
975 while ((*d++ = *s++) != '\0')
981 while ((--d != buffer) && isspace(UCH(*d)))
984 for (s = d = buffer; (*d++ = *s++) != '\0';)
986 if (isspace(UCH(*s)))
989 while (isspace(UCH(*s)))
998 return (int)strlen(buffer) - 1;
1002 * Scan forward in the current line-buffer looking for a right-curly bracket.
1004 * Parameters begin with a left-curly bracket, and continue until there are no
1005 * more interesting characters after the last right-curly bracket on the
1006 * current line. Bison documents parameters as separated like this:
1007 * {type param1} {type2 param2}
1008 * but also accepts commas (although some versions of bison mishandle this)
1009 * {type param1, type2 param2}
1019 switch (next_inline())
1038 save_param(int k, char *buffer, int name, int type2)
1042 p = TMALLOC(param, 1);
1045 p->type2 = strdup(buffer + type2);
1047 buffer[type2] = '\0';
1048 (void)trim_blanks(p->type2);
1050 p->name = strdup(buffer + name);
1052 buffer[name] = '\0';
1053 (void)trim_blanks(p->name);
1055 p->type = strdup(buffer);
1057 (void)trim_blanks(p->type);
1081 * Keep a linked list of parameters. This may be multi-line, if the trailing
1082 * right-curly bracket is absent.
1092 size_t buf_size = 0;
1093 int st_lineno = lineno;
1127 if ((curly == 1) && (cptr == line))
1137 if (curly == 0 && !isspace(UCH(c)))
1145 buf_size = (size_t) linesize;
1146 buf = TMALLOC(char, buf_size);
1157 buf_size += (size_t) linesize;
1158 tmp = TREALLOC(char, buf, buf_size);
1164 if ((state == 2) && (c == L_CURL))
1168 else if ((state == 2) && isspace(UCH(c)))
1172 else if ((c != L_CURL) && (c != R_CURL))
1179 while (curly < 2 || more_curly());
1192 (void)trim_blanks(buf);
1197 char *parms = (comma + 1);
1198 comma = strchr(parms, ',');
1202 (void)trim_blanks(parms);
1203 i = (int)strlen(parms) - 1;
1209 if (parms[i] == ']')
1214 char ch = parms[i--];
1237 while (i > 0 && (isalnum(UCH(parms[i])) || UCH(parms[i]) == '_'))
1240 if (!isspace(UCH(parms[i])) && parms[i] != '*')
1245 save_param(k, parms, name, type2);
1253 syntax_error(lineno, line, cptr);
1259 if (c >= '0' && c <= '9')
1261 if (c >= 'A' && c <= 'F')
1262 return (c - 'A' + 10);
1263 if (c >= 'a' && c <= 'f')
1264 return (c - 'a' + 10);
1277 a.a_lineno = lineno;
1278 a.a_line = dup_line();
1279 a.a_cptr = a.a_line + (cptr - line);
1289 unterminated_string(&a);
1292 char *c_cptr = cptr - 1;
1300 unterminated_string(&a);
1315 n = (n << 3) + (c - '0');
1319 n = (n << 3) + (c - '0');
1324 illegal_character(c_cptr);
1331 if (n < 0 || n >= 16)
1332 illegal_character(c_cptr);
1337 if (i < 0 || i >= 16)
1342 illegal_character(c_cptr);
1375 s = TMALLOC(char, n);
1378 for (i = 0; i < n; ++i)
1387 for (i = 0; i < n; ++i)
1390 if (c == '\\' || c == cache[0])
1395 else if (isprint(UCH(c)))
1424 cachec(((c >> 6) & 7) + '0');
1425 cachec(((c >> 3) & 7) + '0');
1426 cachec((c & 7) + '0');
1440 if (n == 1 && bp->value == UNDEFINED)
1441 bp->value = UCH(*s);
1448 is_reserved(char *name)
1450 if (strcmp(name, ".") == 0 ||
1451 strcmp(name, "$accept") == 0 ||
1452 strcmp(name, "$end") == 0)
1455 if (name[0] == '$' && name[1] == '$' && isdigit(UCH(name[2])))
1459 while (isdigit(UCH(*s)))
1474 for (c = *cptr; IS_IDENT(c); c = *++cptr)
1478 if (is_reserved(cache))
1479 used_reserved(cache);
1481 return (lookup(cache));
1492 for (c = *cptr; isdigit(UCH(c)); c = *++cptr)
1494 n = (10 * n + (c - '0'));
1497 syntax_error(lineno, line, base);
1502 return (Value_t)(n);
1506 cache_tag(char *tag, size_t len)
1511 for (i = 0; i < ntags; ++i)
1513 if (strncmp(tag, tag_table[i], len) == 0 &&
1514 tag_table[i][len] == NUL)
1515 return (tag_table[i]);
1518 if (ntags >= tagmax)
1523 ? TREALLOC(char *, tag_table, tagmax)
1524 : TMALLOC(char *, tagmax));
1525 NO_SPACE(tag_table);
1528 s = TMALLOC(char, len + 1);
1531 strncpy(s, tag, len);
1533 tag_table[ntags++] = s;
1541 int t_lineno = lineno;
1542 char *t_line = dup_line();
1543 char *t_cptr = t_line + (cptr - line);
1550 illegal_tag(t_lineno, t_line, t_cptr);
1558 while (IS_IDENT(c));
1565 illegal_tag(t_lineno, t_line, t_cptr);
1570 return cache_tag(cache, (size_t) cinc);
1573 #if defined(YYBTYACC)
1579 while (IS_NAME2(UCH(*cptr)))
1581 return cache_tag(b, (size_t) (cptr - b));
1586 declare_tokens(int assoc)
1609 if (isalpha(UCH(c)) || c == '_' || c == '.' || c == '$')
1611 else if (c == '\'' || c == '"')
1617 tokenized_start(bp->name);
1622 if (bp->tag && tag != bp->tag)
1623 retyped_warning(bp->name);
1629 if (bp->prec && prec != bp->prec)
1630 reprec_warning(bp->name);
1631 bp->assoc = (Assoc_t)assoc;
1639 if (isdigit(UCH(c)))
1641 value = get_number();
1642 if (bp->value != UNDEFINED && value != bp->value)
1643 revalued_warning(bp->name);
1653 * %expect requires special handling
1654 * as it really isn't part of the yacc
1655 * grammar only a flag for yacc proper.
1658 declare_expect(int assoc)
1662 if (assoc != EXPECT && assoc != EXPECT_RR)
1666 * Stay away from nextc - doesn't
1667 * detect EOL and will read to EOF.
1675 if (isdigit(UCH(c)))
1677 if (assoc == EXPECT)
1678 SRexpect = get_number();
1680 RRexpect = get_number();
1684 * Looking for number before EOL.
1685 * Spaces, tabs, and numbers are ok,
1686 * words, punc., etc. are syntax errors.
1688 else if (c == '\n' || isalpha(UCH(c)) || !isspace(UCH(c)))
1690 syntax_error(lineno, line, cptr);
1701 #if defined(YYBTYACC)
1703 declare_argtypes(bucket *bp)
1705 char *tags[MAXARGS];
1709 retyped_warning(bp->name);
1710 cptr++; /* skip open paren */
1717 syntax_error(lineno, line, cptr);
1718 tags[args++] = get_tag();
1725 cptr++; /* skip close paren */
1727 bp->argnames = TMALLOC(char *, args);
1728 NO_SPACE(bp->argnames);
1729 bp->argtags = CALLOC(sizeof(char *), args + 1);
1730 NO_SPACE(bp->argtags);
1733 bp->argtags[args] = tags[args];
1734 bp->argnames[args] = NULL;
1757 if (isalpha(UCH(c)) || c == '_' || c == '.' || c == '$')
1760 #if defined(YYBTYACC)
1761 if (nextc() == L_PAREN)
1762 declare_argtypes(bp);
1767 else if (c == '\'' || c == '"')
1770 #if defined(YYBTYACC)
1779 if (bp->tag && tag != bp->tag)
1780 retyped_warning(bp->name);
1795 if (!isalpha(UCH(c)) && c != '_' && c != '.' && c != '$')
1796 syntax_error(lineno, line, cptr);
1798 if (bp->class == TERM)
1799 terminal_start(bp->name);
1800 if (goal && goal != bp)
1801 restarted_warning();
1806 read_declarations(void)
1808 cache_size = CACHE_SIZE;
1809 cache = TMALLOC(char, cache_size);
1820 syntax_error(lineno, line, cptr);
1821 switch (k = keyword())
1879 #if defined(YYBTYACC)
1888 case INITIAL_ACTION:
1889 copy_initial_action();
1898 /* noop for bison compatibility. byacc is already designed to be posix
1899 * yacc compatible. */
1906 initialize_grammar(void)
1911 pitem = TMALLOC(bucket *, maxitems);
1922 plhs = TMALLOC(bucket *, maxrules);
1929 rprec = TMALLOC(Value_t, maxrules);
1936 rassoc = TMALLOC(Assoc_t, maxrules);
1948 pitem = TREALLOC(bucket *, pitem, maxitems);
1957 plhs = TREALLOC(bucket *, plhs, maxrules);
1960 rprec = TREALLOC(Value_t, rprec, maxrules);
1963 rassoc = TREALLOC(Assoc_t, rassoc, maxrules);
1967 /* set immediately prior to where copy_args() could be called, and incremented by
1968 the various routines that will rescan the argument list as appropriate */
1969 static int rescan_lineno;
1970 #if defined(YYBTYACC)
1973 copy_args(int *alen)
1975 struct mstring *s = msnew();
1976 int depth = 0, len = 1;
1980 a.a_lineno = lineno;
1981 a.a_line = dup_line();
1982 a.a_cptr = a.a_line + (cptr - line - 1);
1984 while ((c = *cptr++) != R_PAREN || depth || quote)
1986 if (c == ',' && !quote && !depth)
1999 unterminated_string(&a);
2001 unterminated_arglist(&a);
2018 else if (c == R_PAREN)
2020 else if (c == '\"' || c == '\'')
2031 parse_id(char *p, char **save)
2035 while (isspace(UCH(*p)))
2038 if (!isalpha(UCH(*p)) && *p != '_')
2041 while (IS_NAME2(UCH(*p)))
2045 *save = cache_tag(b, (size_t) (p - b));
2051 parse_int(char *p, int *save)
2053 int neg = 0, val = 0;
2055 while (isspace(UCH(*p)))
2063 if (!isdigit(UCH(*p)))
2065 while (isdigit(UCH(*p)))
2066 val = val * 10 + *p++ - '0';
2075 parse_arginfo(bucket *a, char *args, int argslen)
2077 char *p = args, *tmp;
2082 if (a->args != argslen)
2083 arg_number_disagree_warning(rescan_lineno, a->name);
2088 if ((a->args = argslen) == 0)
2090 a->argnames = TMALLOC(char *, argslen);
2091 NO_SPACE(a->argnames);
2092 a->argtags = TMALLOC(char *, argslen);
2093 NO_SPACE(a->argtags);
2097 for (i = 0; i < argslen; i++)
2099 while (isspace(UCH(*p)))
2104 while (isspace(UCH(*p)))
2110 if (!(p = parse_id(p + 1, &tmp)))
2112 while (isspace(UCH(*p)))
2119 if (a->argtags[i] != tmp)
2120 arg_type_disagree_warning(rescan_lineno, i + 1, a->name);
2123 a->argtags[i] = tmp;
2126 a->argtags[i] = NULL;
2127 if (!(p = parse_id(p, &a->argnames[i])))
2129 while (isspace(UCH(*p)))
2139 compile_arg(char **theptr, char *yyvaltag)
2142 struct mstring *c = msnew();
2144 Value_t *offsets = NULL, maxoffset;
2149 for (i = nitems - 1; pitem[i]; --i)
2152 if (pitem[i]->class != ARGUMENT)
2159 offsets = TMALLOC(Value_t, maxoffset + 1);
2162 for (j = 0, i++; i < nitems; i++)
2163 if (pitem[i]->class != ARGUMENT)
2164 offsets[++j] = (Value_t)(i - nitems + 1);
2166 rhs = pitem + nitems - 1;
2169 msprintf(c, "yyval.%s = ", yyvaltag);
2171 msprintf(c, "yyval = ");
2178 if (!(p = parse_id(++p, &tag)) || *p++ != '>')
2179 illegal_tag(rescan_lineno, NULL, NULL);
2180 if (isdigit(UCH(*p)) || *p == '-')
2183 if (!(p = parse_int(p, &val)))
2184 dollar_error(rescan_lineno, NULL, NULL);
2187 else if (val > maxoffset)
2189 dollar_warning(rescan_lineno, val);
2190 i = val - maxoffset;
2192 else if (maxoffset > 0)
2195 if (!tag && !(tag = rhs[i]->tag) && havetags)
2196 untyped_rhs(val, rhs[i]->name);
2198 msprintf(c, "yystack.l_mark[%d]", i);
2200 msprintf(c, ".%s", tag);
2204 else if (isalpha(UCH(*p)) || *p == '_')
2207 if (!(p = parse_id(p, &arg)))
2208 dollar_error(rescan_lineno, NULL, NULL);
2209 for (i = plhs[nrules]->args - 1; i >= 0; i--)
2210 if (arg == plhs[nrules]->argnames[i])
2213 unknown_arg_warning(rescan_lineno, "$", arg, NULL, NULL);
2215 tag = plhs[nrules]->argtags[i];
2216 msprintf(c, "yystack.l_mark[%d]",
2217 i - plhs[nrules]->args + 1 - n);
2219 msprintf(c, ".%s", tag);
2221 untyped_arg_warning(rescan_lineno, "$", arg);
2224 dollar_error(rescan_lineno, NULL, NULL);
2228 at_error(rescan_lineno, NULL, NULL);
2244 can_elide_arg(char **theptr, char *yyvaltag)
2249 Value_t *offsets = NULL, maxoffset = 0;
2257 if (!(p = parse_id(++p, &tag)) || *p++ != '>')
2260 for (i = nitems - 1; pitem[i]; --i)
2263 if (pitem[i]->class != ARGUMENT)
2270 offsets = TMALLOC(Value_t, maxoffset + 1);
2273 for (j = 0, i++; i < nitems; i++)
2274 if (pitem[i]->class != ARGUMENT)
2275 offsets[++j] = (Value_t)(i - nitems + 1);
2277 rhs = pitem + nitems - 1;
2279 if (isdigit(UCH(*p)) || *p == '-')
2282 if (!(p = parse_int(p, &val)))
2288 else if (val > maxoffset)
2299 else if (isalpha(UCH(*p)) || *p == '_')
2302 if (!(p = parse_id(p, &arg)))
2307 for (i = plhs[nrules]->args - 1; i >= 0; i--)
2308 if (arg == plhs[nrules]->argnames[i])
2313 tag = plhs[nrules]->argtags[i];
2314 rv = plhs[nrules]->args + n - i;
2317 if (tag && yyvaltag)
2319 if (strcmp(tag, yyvaltag))
2322 else if (tag || yyvaltag)
2326 if (p == 0 || *p || rv <= 0)
2332 #define ARG_CACHE_SIZE 1024
2333 static struct arg_cache
2335 struct arg_cache *next;
2339 *arg_cache[ARG_CACHE_SIZE];
2342 lookup_arg_cache(char *code)
2344 struct arg_cache *entry;
2346 entry = arg_cache[strnshash(code) % ARG_CACHE_SIZE];
2349 if (!strnscmp(entry->code, code))
2351 entry = entry->next;
2357 insert_arg_cache(char *code, int rule)
2359 struct arg_cache *entry = NEW(struct arg_cache);
2363 i = strnshash(code) % ARG_CACHE_SIZE;
2366 entry->next = arg_cache[i];
2367 arg_cache[i] = entry;
2371 clean_arg_cache(void)
2373 struct arg_cache *e, *t;
2376 for (i = 0; i < ARG_CACHE_SIZE; i++)
2378 for (e = arg_cache[i]; (t = e); e = e->next, FREE(t))
2380 arg_cache[i] = NULL;
2383 #endif /* defined(YYBTYACC) */
2386 advance_to_start(void)
2391 #if defined(YYBTYACC)
2422 syntax_error(lineno, line, s_cptr);
2427 if (!isalpha(UCH(c)) && c != '_' && c != '.' && c != '_')
2428 syntax_error(lineno, line, cptr);
2432 if (bp->class == TERM)
2433 terminal_start(bp->name);
2441 rescan_lineno = lineno; /* line# for possible inherited args rescan */
2442 #if defined(YYBTYACC)
2446 args = copy_args(&argslen);
2452 syntax_error(lineno, line, cptr);
2453 start_rule(bp, s_lineno);
2454 #if defined(YYBTYACC)
2455 parse_arginfo(bp, args, argslen);
2461 start_rule(bucket *bp, int s_lineno)
2463 if (bp->class == TERM)
2464 terminal_lhs(s_lineno);
2465 bp->class = NONTERM;
2468 if (nrules >= maxrules)
2471 rprec[nrules] = UNDEFINED;
2472 rassoc[nrules] = TOKEN;
2478 if (!last_was_action && plhs[nrules]->tag)
2480 if (pitem[nitems - 1])
2484 for (i = nitems - 1; (i > 0) && pitem[i]; --i)
2486 if (pitem[i + 1] == 0 || pitem[i + 1]->tag != plhs[nrules]->tag)
2487 default_action_warning(plhs[nrules]->name);
2490 default_action_warning(plhs[nrules]->name);
2493 last_was_action = 0;
2494 if (nitems >= maxitems)
2502 insert_empty_rule(void)
2507 assert(cache_size >= CACHE_SIZE);
2508 sprintf(cache, "$$%d", ++gensym);
2509 bp = make_bucket(cache);
2510 last_symbol->next = bp;
2512 bp->tag = plhs[nrules]->tag;
2514 #if defined(YYBTYACC)
2518 nitems = (Value_t)(nitems + 2);
2519 if (nitems > maxitems)
2521 bpp = pitem + nitems - 1;
2523 while ((bpp[0] = bpp[-1]) != 0)
2526 if (++nrules >= maxrules)
2528 plhs[nrules] = plhs[nrules - 1];
2529 plhs[nrules - 1] = bp;
2530 rprec[nrules] = rprec[nrules - 1];
2531 rprec[nrules - 1] = 0;
2532 rassoc[nrules] = rassoc[nrules - 1];
2533 rassoc[nrules - 1] = TOKEN;
2536 #if defined(YYBTYACC)
2538 insert_arg_rule(char *arg, char *tag)
2540 int line_number = rescan_lineno;
2541 char *code = compile_arg(&arg, tag);
2542 int rule = lookup_arg_cache(code);
2543 FILE *f = action_file;
2548 insert_arg_cache(code, rule);
2549 trialaction = 1; /* arg rules always run in trial mode */
2550 fprintf(f, "case %d:\n", rule - 2);
2552 fprintf(f, line_format, line_number, input_file_name);
2553 fprintf(f, "%s;\n", code);
2554 fprintf(f, "break;\n");
2555 insert_empty_rule();
2556 plhs[rule]->tag = cache_tag(tag, strlen(tag));
2557 plhs[rule]->class = ARGUMENT;
2561 if (++nitems > maxitems)
2563 pitem[nitems - 1] = plhs[rule];
2575 int s_lineno = lineno;
2576 #if defined(YYBTYACC)
2582 if (c == '\'' || c == '"')
2588 rescan_lineno = lineno; /* line# for possible inherited args rescan */
2589 #if defined(YYBTYACC)
2593 args = copy_args(&argslen);
2601 start_rule(bp, s_lineno);
2602 #if defined(YYBTYACC)
2603 parse_arginfo(bp, args, argslen);
2609 if (last_was_action)
2610 insert_empty_rule();
2611 last_was_action = 0;
2613 #if defined(YYBTYACC)
2616 if (argslen == 0 && bp->args > 0 && pitem[nitems - 1] == NULL)
2619 if (plhs[nrules]->args != bp->args)
2620 wrong_number_args_warning("default ", bp->name);
2621 for (i = bp->args - 1; i >= 0; i--)
2622 if (plhs[nrules]->argtags[i] != bp->argtags[i])
2623 wrong_type_for_arg_warning(i + 1, bp->name);
2625 else if (bp->args != argslen)
2626 wrong_number_args_warning("", bp->name);
2631 int elide_cnt = can_elide_arg(&ap, bp->argtags[0]);
2633 if (elide_cnt > argslen)
2637 for (i = 1; i < elide_cnt; i++)
2638 if (can_elide_arg(&ap, bp->argtags[i]) != elide_cnt - i)
2646 assert(i == elide_cnt);
2653 for (; i < argslen; i++)
2654 ap = insert_arg_rule(ap, bp->argtags[i]);
2657 #endif /* defined(YYBTYACC) */
2659 if (++nitems > maxitems)
2661 pitem[nitems - 1] = bp;
2670 #if defined(YYBTYACC)
2674 FILE *f = action_file;
2676 Value_t *offsets = NULL, maxoffset;
2679 a.a_lineno = lineno;
2680 a.a_line = dup_line();
2681 a.a_cptr = a.a_line + (cptr - line);
2683 if (last_was_action)
2684 insert_empty_rule();
2685 last_was_action = 1;
2686 #if defined(YYBTYACC)
2687 trialaction = (*cptr == L_BRAC);
2690 fprintf(f, "case %d:\n", nrules - 2);
2691 #if defined(YYBTYACC)
2695 fprintf(f, " if (!yytrial)\n");
2699 fprintf(f, line_format, lineno, input_file_name);
2703 /* avoid putting curly-braces in first column, to ease editing */
2704 if (*after_blanks(cptr) == L_CURL)
2707 cptr = after_blanks(cptr);
2712 for (i = nitems - 1; pitem[i]; --i)
2715 if (pitem[i]->class != ARGUMENT)
2720 offsets = TMALLOC(Value_t, maxoffset + 1);
2723 for (j = 0, i++; i < nitems; i++)
2725 if (pitem[i]->class != ARGUMENT)
2727 offsets[++j] = (Value_t)(i - nitems + 1);
2731 rhs = pitem + nitems - 1;
2740 int d_lineno = lineno;
2741 char *d_line = dup_line();
2742 char *d_cptr = d_line + (cptr - line);
2749 fprintf(f, "yyval.%s", tag);
2754 else if (isdigit(UCH(c)))
2758 fprintf(f, "yystack.l_mark[%d].%s", -n, tag);
2759 else if (i > maxoffset)
2761 dollar_warning(d_lineno, i);
2762 fprintf(f, "yystack.l_mark[%d].%s", i - maxoffset, tag);
2765 fprintf(f, "yystack.l_mark[%d].%s", offsets[i], tag);
2769 else if (c == '-' && isdigit(UCH(cptr[1])))
2772 i = -get_number() - n;
2773 fprintf(f, "yystack.l_mark[%d].%s", i, tag);
2777 #if defined(YYBTYACC)
2778 else if (isalpha(UCH(c)) || c == '_')
2780 char *arg = scan_id();
2781 for (i = plhs[nrules]->args - 1; i >= 0; i--)
2782 if (arg == plhs[nrules]->argnames[i])
2785 unknown_arg_warning(d_lineno, "$", arg, d_line, d_cptr);
2786 fprintf(f, "yystack.l_mark[%d].%s",
2787 i - plhs[nrules]->args + 1 - n, tag);
2793 dollar_error(d_lineno, d_line, d_cptr);
2795 else if (cptr[1] == '$')
2799 tag = plhs[nrules]->tag;
2802 fprintf(f, "yyval.%s", tag);
2805 fprintf(f, "yyval");
2807 #if defined(YYBTYACC)
2812 else if (isdigit(UCH(cptr[1])))
2816 if (havetags && offsets)
2818 if (i <= 0 || i > maxoffset)
2820 tag = rhs[offsets[i]]->tag;
2822 untyped_rhs(i, rhs[offsets[i]]->name);
2823 fprintf(f, "yystack.l_mark[%d].%s", offsets[i], tag);
2828 fprintf(f, "yystack.l_mark[%d]", -n);
2829 else if (i > maxoffset)
2831 dollar_warning(lineno, i);
2832 fprintf(f, "yystack.l_mark[%d]", i - maxoffset);
2835 fprintf(f, "yystack.l_mark[%d]", offsets[i]);
2839 else if (cptr[1] == '-')
2845 fprintf(f, "yystack.l_mark[%d]", -i - n);
2848 #if defined(YYBTYACC)
2849 else if (isalpha(UCH(cptr[1])) || cptr[1] == '_')
2854 for (i = plhs[nrules]->args - 1; i >= 0; i--)
2855 if (arg == plhs[nrules]->argnames[i])
2858 unknown_arg_warning(lineno, "$", arg, line, cptr);
2859 tag = (i < 0 ? NULL : plhs[nrules]->argtags[i]);
2860 fprintf(f, "yystack.l_mark[%d]", i - plhs[nrules]->args + 1 - n);
2862 fprintf(f, ".%s", tag);
2864 untyped_arg_warning(lineno, "$", arg);
2869 #if defined(YYBTYACC)
2874 int l_lineno = lineno;
2875 char *l_line = dup_line();
2876 char *l_cptr = l_line + (cptr - line);
2877 syntax_error(l_lineno, l_line, l_cptr);
2881 fprintf(f, "yyloc");
2885 else if (isdigit(UCH(cptr[1])))
2890 fprintf(f, "yystack.p_mark[%d]", -n);
2891 else if (i > maxoffset)
2893 at_warning(lineno, i);
2894 fprintf(f, "yystack.p_mark[%d]", i - maxoffset);
2897 fprintf(f, "yystack.p_mark[%d]", offsets[i]);
2900 else if (cptr[1] == '-')
2904 fprintf(f, "yystack.p_mark[%d]", -i - n);
2916 while (IS_NAME2(c));
2920 #if defined(YYBTYACC)
2923 if (trialaction && c == L_BRAC && depth == 0)
2929 if (trialaction && c == R_BRAC && depth == 1)
2934 if (c == L_BRAC && !haveyyval)
2938 if (c == L_CURL && !haveyyval)
2940 fprintf(f, " if (!yytrial)\n");
2942 fprintf(f, line_format, lineno, input_file_name);
2946 fprintf(f, "\nbreak;\n");
2961 unterminated_action(&a);
2966 fprintf(f, "\nbreak;\n");
2972 #if defined(YYBTYACC)
2991 #if defined(YYBTYACC)
2995 if (c == L_BRAC && !haveyyval)
3000 if (c == L_CURL && !haveyyval)
3002 fprintf(f, " if (!yytrial)\n");
3004 fprintf(f, line_format, lineno, input_file_name);
3009 fprintf(f, "\nbreak;\n");
3018 char *s = copy_string(c);
3026 char *s = copy_comment();
3037 #if defined(YYBTYACC)
3039 get_code(struct ainfo *a, const char *loc)
3044 struct mstring *code_mstr = msnew();
3047 msprintf(code_mstr, line_format, lineno, input_file_name);
3049 cptr = after_blanks(cptr);
3050 if (*cptr == L_CURL)
3051 /* avoid putting curly-braces in first column, to ease editing */
3052 mputc(code_mstr, '\t');
3054 syntax_error(lineno, line, cptr);
3056 a->a_lineno = lineno;
3057 a->a_line = dup_line();
3058 a->a_cptr = a->a_line + (cptr - line);
3067 int d_lineno = lineno;
3068 char *d_line = dup_line();
3069 char *d_cptr = d_line + (cptr - line);
3076 msprintf(code_mstr, "(*val).%s", tag);
3082 dollar_error(d_lineno, d_line, d_cptr);
3084 else if (cptr[1] == '$')
3086 /* process '$$' later; replacement is context dependent */
3087 msprintf(code_mstr, "$$");
3092 if (c == '@' && cptr[1] == '$')
3096 int l_lineno = lineno;
3097 char *l_line = dup_line();
3098 char *l_cptr = l_line + (cptr - line);
3099 syntax_error(l_lineno, l_line, l_cptr);
3101 msprintf(code_mstr, "%s", loc);
3109 mputc(code_mstr, c);
3112 while (IS_NAME2(c));
3116 mputc(code_mstr, c);
3123 unterminated_action(a);
3137 char *s = copy_string(c);
3138 msprintf(code_mstr, "%s", s);
3145 char *s = copy_comment();
3146 msprintf(code_mstr, "%s", s);
3155 return msdone(code_mstr);
3159 copy_initial_action(void)
3163 initial_action = get_code(&a, "yyloc");
3168 copy_destructor(void)
3174 code_text = get_code(&a, "(*loc)");
3184 { /* "no semantic type" default destructor */
3186 if ((bp = default_destructor[UNTYPED_DEFAULT]) == NULL)
3188 static char untyped_default[] = "<>";
3189 bp = make_bucket("untyped default");
3190 bp->tag = untyped_default;
3191 default_destructor[UNTYPED_DEFAULT] = bp;
3193 if (bp->destructor != NULL)
3194 destructor_redeclared_warning(&a);
3196 /* replace "$$" with "(*val)" in destructor code */
3197 bp->destructor = process_destructor_XX(code_text, NULL);
3199 else if (cptr[1] == '*' && cptr[2] == '>')
3200 { /* "no per-symbol or per-type" default destructor */
3202 if ((bp = default_destructor[TYPED_DEFAULT]) == NULL)
3204 static char typed_default[] = "<*>";
3205 bp = make_bucket("typed default");
3206 bp->tag = typed_default;
3207 default_destructor[TYPED_DEFAULT] = bp;
3209 if (bp->destructor != NULL)
3210 destructor_redeclared_warning(&a);
3213 /* postpone re-processing destructor $$s until end of grammar spec */
3214 bp->destructor = TMALLOC(char, strlen(code_text) + 1);
3215 NO_SPACE(bp->destructor);
3216 strcpy(bp->destructor, code_text);
3220 { /* "semantic type" default destructor */
3221 char *tag = get_tag();
3222 bp = lookup_type_destructor(tag);
3223 if (bp->destructor != NULL)
3224 destructor_redeclared_warning(&a);
3226 /* replace "$$" with "(*val).tag" in destructor code */
3227 bp->destructor = process_destructor_XX(code_text, tag);
3230 else if (isalpha(UCH(c)) || c == '_' || c == '.' || c == '$')
3231 { /* "symbol" destructor */
3233 if (bp->destructor != NULL)
3234 destructor_redeclared_warning(&a);
3237 /* postpone re-processing destructor $$s until end of grammar spec */
3238 bp->destructor = TMALLOC(char, strlen(code_text) + 1);
3239 NO_SPACE(bp->destructor);
3240 strcpy(bp->destructor, code_text);
3251 process_destructor_XX(char *code, char *tag)
3256 struct mstring *new_code = msnew();
3257 char *codeptr = code;
3260 loop: /* step thru code */
3262 if (c == '$' && codeptr[1] == '$')
3266 msprintf(new_code, "(*val)");
3268 msprintf(new_code, "(*val).%s", tag);
3278 while (IS_NAME2(c));
3292 return msdone(new_code);
3320 if (c == '*' && *codeptr == '/')
3322 mputc(new_code, '/');
3334 #endif /* defined(YYBTYACC) */
3343 if (c == '%' || c == '\\')
3351 else if ((c == 'p' || c == 'P') &&
3352 ((c = cptr[2]) == 'r' || c == 'R') &&
3353 ((c = cptr[3]) == 'e' || c == 'E') &&
3354 ((c = cptr[4]) == 'c' || c == 'C') &&
3355 ((c = cptr[5], !IS_IDENT(c))))
3358 syntax_error(lineno, line, cptr);
3361 if (isalpha(UCH(c)) || c == '_' || c == '.' || c == '$')
3363 else if (c == '\'' || c == '"')
3367 syntax_error(lineno, line, cptr);
3371 if (rprec[nrules] != UNDEFINED && bp->prec != rprec[nrules])
3374 rprec[nrules] = bp->prec;
3375 rassoc[nrules] = bp->assoc;
3382 initialize_grammar();
3398 #if defined(YYBTYACC)
3399 else if (c == L_CURL || c == '=' || (backtrack && c == L_BRAC))
3401 else if (c == L_CURL || c == '=')
3407 start_rule(plhs[nrules - 1], 0);
3416 syntax_error(lineno, line, cptr);
3419 #if defined(YYBTYACC)
3421 start_requires_args(goal->name);
3433 for (i = 0; i < ntags; ++i)
3435 assert(tag_table[i]);
3448 name_pool_size = 13; /* 13 == sizeof("$end") + sizeof("$accept") */
3449 for (bp = first_symbol; bp; bp = bp->next)
3450 name_pool_size += strlen(bp->name) + 1;
3452 name_pool = TMALLOC(char, name_pool_size);
3453 NO_SPACE(name_pool);
3455 strcpy(name_pool, "$accept");
3456 strcpy(name_pool + 8, "$end");
3458 for (bp = first_symbol; bp; bp = bp->next)
3463 while ((*t++ = *s++) != 0)
3475 if (goal->class == UNKNOWN)
3476 undefined_goal(goal->name);
3478 for (bp = first_symbol; bp; bp = bp->next)
3480 if (bp->class == UNKNOWN)
3482 undefined_symbol_warning(bp->name);
3489 protect_string(char *src, char **des)
3502 if ('\\' == *s || '"' == *s)
3508 *des = d = TMALLOC(char, len);
3514 if ('\\' == *s || '"' == *s)
3528 #if defined(YYBTYACC)
3529 Value_t max_tok_pval;
3534 for (bp = first_symbol; bp; bp = bp->next)
3537 if (bp->class == TERM)
3540 start_symbol = (Value_t)ntokens;
3541 nvars = (Value_t)(nsyms - ntokens);
3543 symbol_name = TMALLOC(char *, nsyms);
3544 NO_SPACE(symbol_name);
3546 symbol_value = TMALLOC(Value_t, nsyms);
3547 NO_SPACE(symbol_value);
3549 symbol_prec = TMALLOC(Value_t, nsyms);
3550 NO_SPACE(symbol_prec);
3552 symbol_assoc = TMALLOC(char, nsyms);
3553 NO_SPACE(symbol_assoc);
3555 #if defined(YYBTYACC)
3556 symbol_pval = TMALLOC(Value_t, nsyms);
3557 NO_SPACE(symbol_pval);
3561 symbol_destructor = CALLOC(sizeof(char *), nsyms);
3562 NO_SPACE(symbol_destructor);
3564 symbol_type_tag = CALLOC(sizeof(char *), nsyms);
3565 NO_SPACE(symbol_type_tag);
3569 v = TMALLOC(bucket *, nsyms);
3573 v[start_symbol] = 0;
3576 j = (Value_t)(start_symbol + 1);
3577 for (bp = first_symbol; bp; bp = bp->next)
3579 if (bp->class == TERM)
3584 assert(i == ntokens && j == nsyms);
3586 for (i = 1; i < ntokens; ++i)
3589 goal->index = (Index_t)(start_symbol + 1);
3590 k = (Value_t)(start_symbol + 2);
3600 for (i = (Value_t)(start_symbol + 1); i < nsyms; ++i)
3610 for (i = 1; i < ntokens; ++i)
3615 for (j = k++; j > 0 && symbol_value[j - 1] > n; --j)
3616 symbol_value[j] = symbol_value[j - 1];
3617 symbol_value[j] = n;
3623 if (v[1]->value == UNDEFINED)
3628 for (i = 2; i < ntokens; ++i)
3630 if (v[i]->value == UNDEFINED)
3632 while (j < k && n == symbol_value[j])
3634 while (++j < k && n == symbol_value[j])
3643 symbol_name[0] = name_pool + 8;
3644 symbol_value[0] = 0;
3646 symbol_assoc[0] = TOKEN;
3647 #if defined(YYBTYACC)
3651 for (i = 1; i < ntokens; ++i)
3653 symbol_name[i] = v[i]->name;
3654 symbol_value[i] = v[i]->value;
3655 symbol_prec[i] = v[i]->prec;
3656 symbol_assoc[i] = v[i]->assoc;
3657 #if defined(YYBTYACC)
3658 symbol_pval[i] = v[i]->value;
3659 if (symbol_pval[i] > max_tok_pval)
3660 max_tok_pval = symbol_pval[i];
3663 symbol_destructor[i] = v[i]->destructor;
3664 symbol_type_tag[i] = v[i]->tag;
3668 symbol_name[start_symbol] = name_pool;
3669 symbol_value[start_symbol] = -1;
3670 symbol_prec[start_symbol] = 0;
3671 symbol_assoc[start_symbol] = TOKEN;
3672 #if defined(YYBTYACC)
3673 symbol_pval[start_symbol] = (Value_t)(max_tok_pval + 1);
3675 for (++i; i < nsyms; ++i)
3678 symbol_name[k] = v[i]->name;
3679 symbol_value[k] = v[i]->value;
3680 symbol_prec[k] = v[i]->prec;
3681 symbol_assoc[k] = v[i]->assoc;
3682 #if defined(YYBTYACC)
3683 symbol_pval[k] = (Value_t)((max_tok_pval + 1) + v[i]->value + 1);
3686 symbol_destructor[k] = v[i]->destructor;
3687 symbol_type_tag[k] = v[i]->tag;
3694 symbol_pname = TMALLOC(char *, nsyms);
3695 NO_SPACE(symbol_pname);
3697 for (i = 0; i < nsyms; ++i)
3698 protect_string(symbol_name[i], &(symbol_pname[i]));
3710 ritem = TMALLOC(Value_t, nitems);
3713 rlhs = TMALLOC(Value_t, nrules);
3716 rrhs = TMALLOC(Value_t, nrules + 1);
3719 rprec = TREALLOC(Value_t, rprec, nrules);
3722 rassoc = TREALLOC(Assoc_t, rassoc, nrules);
3726 ritem[1] = goal->index;
3731 rlhs[2] = start_symbol;
3737 for (i = 3; i < nrules; ++i)
3742 #if defined(YYBTYACC)
3743 if (plhs[i]->args > 0)
3745 if (plhs[i]->argnames)
3747 FREE(plhs[i]->argnames);
3748 plhs[i]->argnames = NULL;
3750 if (plhs[i]->argtags)
3752 FREE(plhs[i]->argtags);
3753 plhs[i]->argtags = NULL;
3756 #endif /* defined(YYBTYACC) */
3757 rlhs[i] = plhs[i]->index;
3763 ritem[j] = pitem[j]->index;
3764 if (pitem[j]->class == TERM)
3766 prec2 = pitem[j]->prec;
3767 assoc = pitem[j]->assoc;
3771 ritem[j] = (Value_t)-i;
3773 if (rprec[i] == UNDEFINED)
3783 #if defined(YYBTYACC)
3792 size_t j, spacing = 0;
3793 FILE *f = verbose_file;
3799 for (i = 2; i < nrules; ++i)
3801 if (rlhs[i] != rlhs[i - 1])
3805 fprintf(f, "%4d %s :", i - 2, symbol_name[rlhs[i]]);
3806 spacing = strlen(symbol_name[rlhs[i]]) + 1;
3810 fprintf(f, "%4d ", i - 2);
3817 while (ritem[k] >= 0)
3819 fprintf(f, " %s", symbol_name[ritem[k]]);
3827 #if defined(YYBTYACC)
3829 finalize_destructors(void)
3834 for (i = 2; i < nsyms; ++i)
3836 char *tag = symbol_type_tag[i];
3838 if (symbol_destructor[i] == NULL)
3841 { /* use <> destructor, if there is one */
3842 if ((bp = default_destructor[UNTYPED_DEFAULT]) != NULL)
3844 symbol_destructor[i] = TMALLOC(char,
3845 strlen(bp->destructor) + 1);
3846 NO_SPACE(symbol_destructor[i]);
3847 strcpy(symbol_destructor[i], bp->destructor);
3851 { /* use type destructor for this tag, if there is one */
3852 bp = lookup_type_destructor(tag);
3853 if (bp->destructor != NULL)
3855 symbol_destructor[i] = TMALLOC(char,
3856 strlen(bp->destructor) + 1);
3857 NO_SPACE(symbol_destructor[i]);
3858 strcpy(symbol_destructor[i], bp->destructor);
3861 { /* use <*> destructor, if there is one */
3862 if ((bp = default_destructor[TYPED_DEFAULT]) != NULL)
3863 /* replace "$$" with "(*val).tag" in destructor code */
3864 symbol_destructor[i]
3865 = process_destructor_XX(bp->destructor, tag);
3870 { /* replace "$$" with "(*val)[.tag]" in destructor code */
3871 symbol_destructor[i]
3872 = process_destructor_XX(symbol_destructor[i], tag);
3875 /* 'symbol_type_tag[]' elements are freed by 'free_tags()' */
3876 DO_FREE(symbol_type_tag); /* no longer needed */
3877 if ((bp = default_destructor[UNTYPED_DEFAULT]) != NULL)
3880 /* 'bp->tag' is a static value, don't free */
3881 FREE(bp->destructor);
3884 if ((bp = default_destructor[TYPED_DEFAULT]) != NULL)
3887 /* 'bp->tag' is a static value, don't free */
3888 FREE(bp->destructor);
3891 if ((bp = default_destructor[TYPE_SPECIFIED]) != NULL)
3898 /* 'bp->tag' freed by 'free_tags()' */
3899 FREE(bp->destructor);
3904 #endif /* defined(YYBTYACC) */
3909 write_section(code_file, banner);
3910 create_symbol_table();
3911 read_declarations();
3913 free_symbol_table();
3920 #if defined(YYBTYACC)
3922 finalize_destructors();
3929 free_declarations(param *list)
3933 param *next = list->next;
3946 lex_param = free_declarations(lex_param);
3947 parse_param = free_declarations(parse_param);
3957 DO_FREE(symbol_name);
3958 DO_FREE(symbol_prec);
3959 DO_FREE(symbol_assoc);
3960 DO_FREE(symbol_value);
3961 #if defined(YYBTYACC)
3962 DO_FREE(symbol_pval);
3963 DO_FREE(symbol_destructor);
3964 DO_FREE(symbol_type_tag);