* src/system.h (EXT_GUARD_C, EXT_STYPE_H): Remove.
* src/gram.h, src/gram.c (semantic_parser): Remove.
(rule_t): Remove the guard and guard_line members.
* src/lex.h (token_t): remove tok_guard.
* src/options.c (option_table): Remove %guard and %semantic_parser
support.
* src/output.c, src/output.h (guards_output): Remove.
(prepare): Adjust.
(token_definitions_output): Don't output the `T'
tokens (???).
(output_skeleton): Don't output the guards.
* src/files.c, src/files.c (attrsfile): Remove.
* src/reader.c (symbol_list): Remove the guard and guard_line
members.
Adjust dependencies.
(parse_guard): Remove.
* data/bison.hairy: Remove.
* doc/bison.texinfo (Environment Variables): Remove occurrences of
BISON_HAIRY.
+2002-05-02 Akim Demaille <akim@epita.fr>
+
+ Remove the so called hairy (semantic) parsers.
+
+ * src/system.h (EXT_GUARD_C, EXT_STYPE_H): Remove.
+ * src/gram.h, src/gram.c (semantic_parser): Remove.
+ (rule_t): Remove the guard and guard_line members.
+ * src/lex.h (token_t): remove tok_guard.
+ * src/options.c (option_table): Remove %guard and %semantic_parser
+ support.
+ * src/output.c, src/output.h (guards_output): Remove.
+ (prepare): Adjust.
+ (token_definitions_output): Don't output the `T'
+ tokens (???).
+ (output_skeleton): Don't output the guards.
+ * src/files.c, src/files.c (attrsfile): Remove.
+ * src/reader.c (symbol_list): Remove the guard and guard_line
+ members.
+ Adjust dependencies.
+ (parse_guard): Remove.
+ * data/bison.hairy: Remove.
+ * doc/bison.texinfo (Environment Variables): Remove occurrences of
+ BISON_HAIRY.
+
2002-05-02 Akim Demaille <akim@epita.fr>
* src/reader.c (copy_at, copy_dollarm parse_braces, parse_action)
%token YYEOF 0
or
%token YYEOF 0 "end of file"
+
+* Semantic parser
+ This old option, which has been broken for ages, is removed.
+
\f
Changes in version 1.35, 2002-03-25:
** %no-lines [ok]
** %no-parser []
** %pure-parser []
-** %semantic-parser []
** %token-table []
** Options which could use parse_dquoted_param ().
Maybe transfered in lex.c.
-## Copyright 2002 Free Software Foundation, Inc.
+## Copyright (C) 2002 Free Software Foundation, Inc.
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
## 02111-1307 USA
-dist_pkgdata_DATA = bison.simple bison.hairy bison.c++
+dist_pkgdata_DATA = bison.simple bison.c++
m4sugardir = $(pkgdatadir)/m4sugar
dist_m4sugar_DATA = m4sugar/m4sugar.m4 m4sugar/version.m4
+++ /dev/null
-%%{section} %%{output-prefix} %%{output-infix} %%".c"
- /* -*- C -*- */
-
-/* YYERROR and YYCOST are set by guards. If yyerror is set to a
- nonzero value by a guard, the reduction with which the guard is
- associated is not performed, and the error recovery mechanism is
- invoked. Yycost indicates the cost of performing the reduction
- given the attributes of the symbols. */
-static int yyerror;
-static int yycost;
-
-/* YYMAXDEPTH indicates the size of the parser's state and value
- stacks. */
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 500
-#endif
-
-/* YYMAXRULES must be at least as large as the number of rules that
- could be placed in the rule queue. That number could be determined
- from the grammar and the size of the stack, but, as yet, it is not.
- */
-
-#ifndef YYMAXRULES
-# define YYMAXRULES 100
-#endif
-
-#ifndef YYMAXBACKUP
-# define YYMAXBACKUP 100
-#endif
-
-
-/* The state stack. */
-static short yyss[YYMAXDEPTH];
-/* The semantic value stack. */
-static YYSTYPE yyvs[YYMAXDEPTH];
-/* The location stack. */
-static YYLTYPE yyls[YYMAXDEPTH];
-/* The rule queue. */
-static short yyrq[YYMAXRULES];
-/* The lookahead symbol. */
-static int yychar;
-
-/* the semantic value of the lookahead symbol. */
-static YYSTYPE yylval;
-
-/* the semantic value for the state at the top of the state stack. */
-static YYSTYPE yytval;
-
-/* the variable used to return semantic values from the action
- routines. */
-static YYSTYPE yyval;
-
-/* location data for the lookahead symbol. */
-static YYLTYPE yylloc;
-
-/* location data for the state at the top of the state stack. */
-static YYLTYPE yytloc;
-
-
-static int yynunlexed;
-static short yyunchar[YYMAXBACKUP];
-static YYSTYPE yyunval[YYMAXBACKUP];
-static YYLTYPE yyunloc[YYMAXBACKUP];
-
-/* a pointer to the top of the state stack; only set during error
- recovery. */
-static short *yygssp;
-
-/* a pointer to the top of the value stack; only set during error
- recovery. */
-static YYSTYPE *yygvsp;
-
-/* a pointer to the top of the location stack; only set during error
- recovery. */
-static YYLTYPE *yyglsp;
-
-
-/*--------------------------------------------------------------------.
-| Yyget is an interface between the parser and the lexical analyzer. |
-| It is costly to provide such an interface, but it avoids requiring |
-| the lexical analyzer to be able to back up the scan. |
-`--------------------------------------------------------------------*/
-
-static inline void
-yyget (void)
-{
- if (yynunlexed > 0)
- {
- yynunlexed--;
- yychar = yyunchar[yynunlexed];
- yylval = yyunval[yynunlexed];
- yylloc = yyunloc[yynunlexed];
- }
- else if (yychar <= 0)
- yychar = 0;
- else
- {
- yychar = yylex ();
- if (yychar < 0)
- yychar = 0;
- else
- yychar = YYTRANSLATE (yychar);
- }
-}
-
-
-static inline void
-yyunlex (int chr, YYSTYPE val, YYLTYPE loc)
-{
- yyunchar[yynunlexed] = chr;
- yyunval[yynunlexed] = val;
- yyunloc[yynunlexed] = loc;
- yynunlexed++;
-}
-
-
-static inline void
-yyrestore (short *first, short *last)
-{
- short *ssp;
- short *rp;
- int symbol;
- int state;
- int tvalsaved;
-
- ssp = yygssp;
- yyunlex (yychar, yylval, yylloc);
-
- tvalsaved = 0;
- while (first != last)
- {
- symbol = yystos[*ssp];
- if (symbol < YYNTBASE)
- {
- yyunlex (symbol, yytval, yytloc);
- tvalsaved = 1;
- ssp--;
- }
-
- ssp--;
-
- if (first == yyrq)
- first = yyrq + YYMAXRULES;
-
- first--;
-
- for (rp = yyrhs + yyprhs[*first]; symbol = *rp; rp++)
- {
- if (symbol < YYNTBASE)
- state = yytable[yypact[*ssp] + symbol];
- else
- {
- state = yypgoto[symbol - YYNTBASE] + *ssp;
-
- if (state >= 0 && state <= YYLAST && yycheck[state] == *ssp)
- state = yytable[state];
- else
- state = yydefgoto[symbol - YYNTBASE];
- }
-
- *++ssp = state;
- }
- }
-
- if (!tvalsaved && ssp > yyss)
- {
- yyunlex (yystos[*ssp], yytval, yytloc);
- ssp--;
- }
-
- yygssp = ssp;
-}
-
-
-
-int
-yyparse (void)
-{
- int yystate;
- int yyn;
- short *yyssp;
- short *yyrq0;
- short *yyptr;
- YYSTYPE *yyvsp;
-
- int yylen;
- YYLTYPE *yylsp;
- short *yyrq1;
- short *yyrq2;
-
- yystate = 0;
- yyssp = yyss - 1;
- yyvsp = yyvs - 1;
- yylsp = yyls - 1;
- yyrq0 = yyrq;
- yyrq1 = yyrq0;
- yyrq2 = yyrq0;
-
- yychar = yylex ();
- if (yychar < 0)
- yychar = 0;
- else
- yychar = YYTRANSLATE (yychar);
-
-yynewstate:
-
- if (yyssp >= yyss + YYMAXDEPTH - 1)
- {
- yyabort ("Parser Stack Overflow");
- YYABORT;
- }
-
- *++yyssp = yystate;
-
-yyresume:
-
- yyn = yypact[yystate];
- if (yyn == YYFLAG)
- goto yydefault;
-
- yyn += yychar;
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar)
- goto yydefault;
-
- yyn = yytable[yyn];
- if (yyn < 0)
- {
- yyn = -yyn;
- goto yyreduce;
- }
- else if (yyn == 0)
- goto yyerrlab;
-
- yystate = yyn;
-
- yyptr = yyrq2;
- while (yyptr != yyrq1)
- {
- yyn = *yyptr++;
- yylen = yyr2[yyn];
- yyvsp -= yylen;
- yylsp -= yylen;
-
- yyguard (yyn, yyvsp, yylsp);
- if (yyerror)
- goto yysemerr;
-
- yyaction (yyn, yyvsp, yylsp);
- *++yyvsp = yyval;
-
- yylsp++;
- if (yylen == 0)
- {
- yylsp->first_line = yytloc.first_line;
- yylsp->first_column = yytloc.first_column;
- yylsp->last_line = (yylsp - 1)->last_line;
- yylsp->last_column = (yylsp - 1)->last_column;
- yylsp->text = 0;
- }
- else
- {
- yylsp->last_line = (yylsp + yylen - 1)->last_line;
- yylsp->last_column = (yylsp + yylen - 1)->last_column;
- }
-
- if (yyptr == yyrq + YYMAXRULES)
- yyptr = yyrq;
- }
-
- if (yystate == YYFINAL)
- YYACCEPT;
-
- yyrq2 = yyptr;
- yyrq1 = yyrq0;
-
- *++yyvsp = yytval;
- *++yylsp = yytloc;
- yytval = yylval;
- yytloc = yylloc;
- yyget ();
-
- goto yynewstate;
-
-yydefault:
-
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
-
-yyreduce:
-
- *yyrq0++ = yyn;
-
- if (yyrq0 == yyrq + YYMAXRULES)
- yyrq0 = yyrq;
-
- if (yyrq0 == yyrq2)
- {
- yyabort ("Parser Rule Queue Overflow");
- YYABORT;
- }
-
- yyssp -= yyr2[yyn];
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
- if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTBASE];
-
- goto yynewstate;
-
-yysemerr:
- *--yyptr = yyn;
- yyrq2 = yyptr;
- yyvsp += yyr2[yyn];
-
-yyerrlab:
-
- yygssp = yyssp;
- yygvsp = yyvsp;
- yyglsp = yylsp;
- yyrestore (yyrq0, yyrq2);
- yyrecover ();
- yystate = *yygssp;
- yyssp = yygssp;
- yyvsp = yygvsp;
- yyrq0 = yyrq;
- yyrq1 = yyrq0;
- yyrq2 = yyrq0;
- goto yyresume;
-}
-
-%%{actions}
/* This is the parser code that is written into each bison parser when
the %semantic_parser declaration is not specified in the grammar.
- It was written by Richard Stallman by simplifying the hairy parser
- used when %semantic_parser is specified. */
+ It was written by Richard Stallman by simplifying the original so
+ called ``semantic'' parser. */
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
@node Environment Variables
@section Environment Variables
@cindex environment variables
-@cindex BISON_HAIRY
@cindex BISON_SIMPLE
Here is a list of environment variables which affect the way Bison
@table @samp
@item BISON_SIMPLE
-@itemx BISON_HAIRY
Much of the parser generated by Bison is copied verbatim from a file
called @file{bison.simple}. If Bison cannot find that file, or if you
would like to direct Bison to use a different copy, setting the
environment variable @code{BISON_SIMPLE} to the path of the file will
cause Bison to use that copy instead.
-
-When the @samp{%semantic-parser} declaration is used, Bison copies from
-a file called @file{bison.hairy} instead. The location of this file can
-also be specified or overridden in a similar fashion, with the
-@code{BISON_HAIRY} environment variable.
-
@end table
@node Option Cross Key
char *parser_file_name = NULL;
char *infile = NULL;
-char *attrsfile = NULL;
static char *full_base_name = NULL;
src_extension = ".c";
if (!header_extension)
header_extension = ".h";
-
+
parser_file_name =
spec_outfile ? spec_outfile : stringappend (full_base_name, src_extension);
-
+
/* It the defines filename if not given, we create it. */
if (!spec_defines_file)
spec_defines_file = stringappend (full_base_name, header_extension);
spec_graph_file = stringappend (short_base_name, ".vcg");
spec_verbose_file = stringappend (short_base_name, EXT_OUTPUT);
-
- attrsfile = stringappend (short_base_name, EXT_STYPE_H);
}
extern struct obstack output_obstack;
extern char *infile;
-extern char *attrsfile;
void compute_output_file_names PARAMS((void));
int max_user_token_number = 256;
-int semantic_parser = 0;
-
int pure_parser = 0;
Therefore 0 cannot be used, since it would be both the rule number
0, and the token EOF).
- Actions and guards are accessed via the rule number.
+ Actions are accessed via the rule number.
The rules themselves are described by several arrays: amongst which
RITEM, and RULES.
const char *action;
int action_line;
-
- const char *guard;
- int guard_line;
} rule_t;
extern struct rule_s *rules;
extern token_number_t *token_translations;
extern int max_user_token_number;
-/* SEMANTIC_PARSER is nonzero if the input file says to use the hairy
- parser that provides for semantic error recovery. If it is zero,
- the yacc-compatible simplified parser is used. */
-
-extern int semantic_parser;
/* PURE_PARSER is nonzero if should generate a parser that is all pure
and reentrant. */
tok_percent_left_curly,
tok_token,
tok_nterm,
- tok_guard,
tok_type,
tok_union,
tok_start,
DRTV ("term", no, NULL, tok_token)
DRTV ("nterm", no, NULL, tok_nterm)
DRTV ("type", no, NULL, tok_type)
- DRTV ("guard", no, NULL, tok_guard)
DRTV ("union", no, NULL, tok_union)
DRTV ("expect", no, NULL, tok_expect)
DRTV ("thong", no, NULL, tok_thong)
BOTH ("name-prefix", required, &spec_name_prefix, tok_stropt, 'p')
DRTV ("define", no, NULL, tok_define)
- DRTV ("semantic-parser",no, &semantic_parser, tok_intopt)
DRTV ("pure-parser", no, &pure_parser, tok_intopt)
/*
}
-/*----------------------------.
-| Output the guards to OOUT. |
-`----------------------------*/
-
-void
-guards_output (FILE *out)
-{
- int rule;
- for (rule = 1; rule < nrules + 1; ++rule)
- if (rules[rule].guard)
- {
- fprintf (out, " case %d:\n", rule);
-
- if (!no_lines_flag)
- fprintf (out, muscle_find ("linef"),
- rules[rule].guard_line,
- quotearg_style (c_quoting_style,
- muscle_find ("filename")));
- fprintf (out, "{ %s; }\n break;\n\n",
- rules[rule].guard);
- }
-}
-
-
/*---------------------------------------.
| Output the tokens definition to OOUT. |
`---------------------------------------*/
fprintf (out, "%s [[[%s]], [%d]]",
first ? "" : ",\n", symbol->tag, number);
- if (semantic_parser)
- /* FIXME: This is probably wrong, and should be just as
- above. --akim. */
- fprintf (out, "# define T%s\t%d\n", symbol->tag, symbol->number);
first = 0;
}
}
actions_output (out);
fputs ("]])\n\n", out);
- fputs ("m4_define([b4_guards], \n[[", out);
- guards_output (out);
- fputs ("]])\n\n", out);
-
fputs ("m4_define([b4_tokens], \n[", out);
token_definitions_output (out);
fputs ("])\n\n", out);
/* Find the right skeleton file. */
if (!skeleton)
- {
- if (semantic_parser)
- skeleton = "bison.hairy";
- else
- skeleton = "bison.simple";
- }
+ skeleton = "bison.simple";
/* Parse the skeleton file and output the needed parsers. */
muscle_insert ("skeleton", skeleton);
void output PARAMS ((void));
void actions_output PARAMS ((FILE *out));
-void guards_output PARAMS ((FILE *out));
void token_definitions_output PARAMS ((FILE *out));
extern struct obstack muscle_obstack;
const char *action;
int action_line;
- /* The guard is attached to the LHS of a rule. */
- const char *guard;
- int guard_line;
symbol_t *ruleprec;
} symbol_list;
res->line = lineno;
res->action = NULL;
res->action_line = 0;
- res->guard = NULL;
- res->guard_line = 0;
res->ruleprec = NULL;
return res;
}
| values in the current rule so far, which says where to find `$0' |
| with respect to the top of the stack. |
| |
-| This routine is used both for actions and guards. Only |
-| ACTION_OBSTACK is used, but this is fine, since we use only |
-| pointers to relevant portions inside this obstack. |
+| This routine is used for actions. |
`------------------------------------------------------------------*/
static void
rule->action = obstack_finish (&action_obstack);
}
-
-static void
-parse_guard (symbol_list *rule, int rule_length)
-{
- token_t t = lex ();
- if (t != tok_left_curly)
- complain (_("invalid %s declaration"), "%guard");
- rule->guard_line = lineno;
- parse_braces (rule, rule_length);
- rule->guard = obstack_finish (&action_obstack);
-}
-
\f
/*-------------------------------------------------------------------.
| null pointer instead of a symbol to terminate the rule. The next |
| symbol is the lhs of the following rule. |
| |
-| All guards and actions are copied out to the appropriate files, |
-| labelled by the rule number they apply to. |
+| All actions are copied out, labelled by the rule number they apply |
+| to. |
| |
| Bison used to allow some %directives in the rules sections, but |
| this is no longer consider appropriate: (i) the documented grammar |
t = lex ();
}
- if (t == tok_guard)
- {
- if (!semantic_parser)
- complain (_("%%guard present but %%semantic_parser not specified"));
-
- parse_guard (crule, rulelength);
- t = lex ();
- }
-
if (t == tok_left_curly)
{
/* This case never occurs -wjh */
rules[ruleno].useful = TRUE;
rules[ruleno].action = p->action;
rules[ruleno].action_line = p->action_line;
- rules[ruleno].guard = p->guard;
- rules[ruleno].guard_line = p->guard_line;
p = p->next;
while (p && p->sym)
ritem_print (stderr);
}
\f
-/*-------------------------------------------------------------------.
-| Read in the grammar specification and record it in the format |
-| described in gram.h. All guards are copied into the GUARD_OBSTACK |
-| and all actions into ACTION_OBSTACK, in each case forming the body |
-| of a C function (YYGUARD or YYACTION) which contains a switch |
-| statement to decide which guard or action to execute. |
-`-------------------------------------------------------------------*/
+/*------------------------------------------------------------------.
+| Read in the grammar specification and record it in the format |
+| described in gram.h. All actions are copied into ACTION_OBSTACK, |
+| in each case forming the body of a C function (YYACTION) which |
+| contains a switch statement to decide which action to execute. |
+`------------------------------------------------------------------*/
void
reader (void)
}
/* Read in the grammar, build grammar in list form. Write out
- guards and actions. */
+ actions. */
readgram ();
/* Some C code is given at the end of the grammar file. */
read_additionnal_code ();
#include "symtab.h"
/* Read in the grammar specification and record it in the format
- described in gram.h. All guards are copied into the FGUARD file
- and all actions into FACTION, in each case forming the body of a C
- function (YYGUARD or YYACTION) which contains a switch statement to
- decide which guard or action to execute. */
+ described in gram.h. */
void reader PARAMS ((void));
/* VMS. */
# define EXT_TAB "_tab"
# define EXT_OUTPUT ".output"
-# define EXT_STYPE_H "_stype"
-# define EXT_GUARD_C "_guard"
#else /* ! VMS */
# ifdef MSDOS
/* MS DOS. */
# define EXT_TAB "_tab"
# define EXT_OUTPUT ".out"
-# define EXT_STYPE_H ".sth"
-# define EXT_GUARD_C ".guc"
# else /* ! MSDOS */
/* Standard. */
# define EXT_TAB ".tab"
# define EXT_OUTPUT ".output"
-# define EXT_STYPE_H ".stype"
-# define EXT_GUARD_C ".guard"
# endif /* ! MSDOS */
#endif /* ! VMS */
## Process this file with automake to create Makefile.in.
## Makefile for Bison testsuite.
-## Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
+## Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
output.at sets.at reduce.at \
synclines.at headers.at actions.at conflicts.at \
calc.at \
- torture.at existing.at regression.at \
- semantic.at
+ torture.at existing.at regression.at
TESTSUITE = $(srcdir)/testsuite
+++ /dev/null
-# Bison Semantic Parsers. -*- Autotest -*-
-# Copyright 2001 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-AT_BANNER([[Semantic Parsers.]])
-
-# Well, nothing, or almost, is known about semantic parsers. For the
-# time being, just make sure we still parse them properly.
-
-## ---------------- ##
-## Parsing Guards. ##
-## ---------------- ##
-
-
-AT_SETUP([Parsing Guards])
-
-AT_DATA([input.y],
-[[%semantic-parser
-%union {
- int ival;
-}
-%token <ival> INT
-%type <ival> exp
-%%
-exp: exp '+' exp { $$ = $1 + $3 }
- | exp '/' exp %guard { if ($3 == 0) yyerror = 1 } { $$ = $1 / $3 }
- | INT;
-%%
-]])
-
-AT_CHECK([bison -v input.y -o input.c], 0, ignore, ignore)
-
-AT_CLEANUP
# Some old bugs.
m4_include([regression.at])
-
-# Exercising bison.hairy, before it gets really removed...
-m4_include([semantic.at])