mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
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.
This commit is contained in:
24
ChangeLog
24
ChangeLog
@@ -1,3 +1,27 @@
|
|||||||
|
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>
|
2002-05-02 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/reader.c (copy_at, copy_dollarm parse_braces, parse_action)
|
* src/reader.c (copy_at, copy_dollarm parse_braces, parse_action)
|
||||||
|
|||||||
4
NEWS
4
NEWS
@@ -55,6 +55,10 @@ Changes in version 1.49b:
|
|||||||
%token YYEOF 0
|
%token YYEOF 0
|
||||||
or
|
or
|
||||||
%token YYEOF 0 "end of file"
|
%token YYEOF 0 "end of file"
|
||||||
|
|
||||||
|
* Semantic parser
|
||||||
|
This old option, which has been broken for ages, is removed.
|
||||||
|
|
||||||
|
|
||||||
Changes in version 1.35, 2002-03-25:
|
Changes in version 1.35, 2002-03-25:
|
||||||
|
|
||||||
|
|||||||
1
TODO
1
TODO
@@ -214,7 +214,6 @@ Show reductions. []
|
|||||||
** %no-lines [ok]
|
** %no-lines [ok]
|
||||||
** %no-parser []
|
** %no-parser []
|
||||||
** %pure-parser []
|
** %pure-parser []
|
||||||
** %semantic-parser []
|
|
||||||
** %token-table []
|
** %token-table []
|
||||||
** Options which could use parse_dquoted_param ().
|
** Options which could use parse_dquoted_param ().
|
||||||
Maybe transfered in lex.c.
|
Maybe transfered in lex.c.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
## 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
|
## 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
|
## it under the terms of the GNU General Public License as published by
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
## 02111-1307 USA
|
## 02111-1307 USA
|
||||||
|
|
||||||
dist_pkgdata_DATA = bison.simple bison.hairy bison.c++
|
dist_pkgdata_DATA = bison.simple bison.c++
|
||||||
|
|
||||||
m4sugardir = $(pkgdatadir)/m4sugar
|
m4sugardir = $(pkgdatadir)/m4sugar
|
||||||
dist_m4sugar_DATA = m4sugar/m4sugar.m4 m4sugar/version.m4
|
dist_m4sugar_DATA = m4sugar/m4sugar.m4 m4sugar/version.m4
|
||||||
|
|||||||
336
data/bison.hairy
336
data/bison.hairy
@@ -1,336 +0,0 @@
|
|||||||
%%{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}
|
|
||||||
@@ -116,8 +116,8 @@ m4_divert(0)dnl
|
|||||||
|
|
||||||
/* This is the parser code that is written into each bison parser when
|
/* This is the parser code that is written into each bison parser when
|
||||||
the %semantic_parser declaration is not specified in the grammar.
|
the %semantic_parser declaration is not specified in the grammar.
|
||||||
It was written by Richard Stallman by simplifying the hairy parser
|
It was written by Richard Stallman by simplifying the original so
|
||||||
used when %semantic_parser is specified. */
|
called ``semantic'' parser. */
|
||||||
|
|
||||||
/* All symbols defined below should begin with yy or YY, to avoid
|
/* All symbols defined below should begin with yy or YY, to avoid
|
||||||
infringing on user name space. This should be done even for local
|
infringing on user name space. This should be done even for local
|
||||||
|
|||||||
@@ -5233,7 +5233,6 @@ the output graph filename.
|
|||||||
@node Environment Variables
|
@node Environment Variables
|
||||||
@section Environment Variables
|
@section Environment Variables
|
||||||
@cindex environment variables
|
@cindex environment variables
|
||||||
@cindex BISON_HAIRY
|
|
||||||
@cindex BISON_SIMPLE
|
@cindex BISON_SIMPLE
|
||||||
|
|
||||||
Here is a list of environment variables which affect the way Bison
|
Here is a list of environment variables which affect the way Bison
|
||||||
@@ -5241,18 +5240,11 @@ runs.
|
|||||||
|
|
||||||
@table @samp
|
@table @samp
|
||||||
@item BISON_SIMPLE
|
@item BISON_SIMPLE
|
||||||
@itemx BISON_HAIRY
|
|
||||||
Much of the parser generated by Bison is copied verbatim from a file
|
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
|
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
|
would like to direct Bison to use a different copy, setting the
|
||||||
environment variable @code{BISON_SIMPLE} to the path of the file will
|
environment variable @code{BISON_SIMPLE} to the path of the file will
|
||||||
cause Bison to use that copy instead.
|
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
|
@end table
|
||||||
|
|
||||||
@node Option Cross Key
|
@node Option Cross Key
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ char *spec_defines_file = NULL; /* for --defines. */
|
|||||||
char *parser_file_name = NULL;
|
char *parser_file_name = NULL;
|
||||||
|
|
||||||
char *infile = NULL;
|
char *infile = NULL;
|
||||||
char *attrsfile = NULL;
|
|
||||||
|
|
||||||
static char *full_base_name = NULL;
|
static char *full_base_name = NULL;
|
||||||
|
|
||||||
@@ -423,10 +422,10 @@ compute_output_file_names (void)
|
|||||||
src_extension = ".c";
|
src_extension = ".c";
|
||||||
if (!header_extension)
|
if (!header_extension)
|
||||||
header_extension = ".h";
|
header_extension = ".h";
|
||||||
|
|
||||||
parser_file_name =
|
parser_file_name =
|
||||||
spec_outfile ? spec_outfile : stringappend (full_base_name, src_extension);
|
spec_outfile ? spec_outfile : stringappend (full_base_name, src_extension);
|
||||||
|
|
||||||
/* It the defines filename if not given, we create it. */
|
/* It the defines filename if not given, we create it. */
|
||||||
if (!spec_defines_file)
|
if (!spec_defines_file)
|
||||||
spec_defines_file = stringappend (full_base_name, header_extension);
|
spec_defines_file = stringappend (full_base_name, header_extension);
|
||||||
@@ -436,6 +435,4 @@ compute_output_file_names (void)
|
|||||||
spec_graph_file = stringappend (short_base_name, ".vcg");
|
spec_graph_file = stringappend (short_base_name, ".vcg");
|
||||||
|
|
||||||
spec_verbose_file = stringappend (short_base_name, EXT_OUTPUT);
|
spec_verbose_file = stringappend (short_base_name, EXT_OUTPUT);
|
||||||
|
|
||||||
attrsfile = stringappend (short_base_name, EXT_STYPE_H);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ extern struct obstack post_prologue_obstack;
|
|||||||
extern struct obstack output_obstack;
|
extern struct obstack output_obstack;
|
||||||
|
|
||||||
extern char *infile;
|
extern char *infile;
|
||||||
extern char *attrsfile;
|
|
||||||
|
|
||||||
void compute_output_file_names PARAMS((void));
|
void compute_output_file_names PARAMS((void));
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,6 @@ token_number_t start_symbol = 0;
|
|||||||
|
|
||||||
int max_user_token_number = 256;
|
int max_user_token_number = 256;
|
||||||
|
|
||||||
int semantic_parser = 0;
|
|
||||||
|
|
||||||
int pure_parser = 0;
|
int pure_parser = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
10
src/gram.h
10
src/gram.h
@@ -47,7 +47,7 @@
|
|||||||
Therefore 0 cannot be used, since it would be both the rule number
|
Therefore 0 cannot be used, since it would be both the rule number
|
||||||
0, and the token EOF).
|
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
|
The rules themselves are described by several arrays: amongst which
|
||||||
RITEM, and RULES.
|
RITEM, and RULES.
|
||||||
@@ -150,9 +150,6 @@ typedef struct rule_s
|
|||||||
|
|
||||||
const char *action;
|
const char *action;
|
||||||
int action_line;
|
int action_line;
|
||||||
|
|
||||||
const char *guard;
|
|
||||||
int guard_line;
|
|
||||||
} rule_t;
|
} rule_t;
|
||||||
|
|
||||||
extern struct rule_s *rules;
|
extern struct rule_s *rules;
|
||||||
@@ -166,11 +163,6 @@ extern symbol_t **symbols;
|
|||||||
extern token_number_t *token_translations;
|
extern token_number_t *token_translations;
|
||||||
extern int max_user_token_number;
|
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
|
/* PURE_PARSER is nonzero if should generate a parser that is all pure
|
||||||
and reentrant. */
|
and reentrant. */
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ typedef enum token_e
|
|||||||
tok_percent_left_curly,
|
tok_percent_left_curly,
|
||||||
tok_token,
|
tok_token,
|
||||||
tok_nterm,
|
tok_nterm,
|
||||||
tok_guard,
|
|
||||||
tok_type,
|
tok_type,
|
||||||
tok_union,
|
tok_union,
|
||||||
tok_start,
|
tok_start,
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ const struct option_table_struct option_table[] =
|
|||||||
DRTV ("term", no, NULL, tok_token)
|
DRTV ("term", no, NULL, tok_token)
|
||||||
DRTV ("nterm", no, NULL, tok_nterm)
|
DRTV ("nterm", no, NULL, tok_nterm)
|
||||||
DRTV ("type", no, NULL, tok_type)
|
DRTV ("type", no, NULL, tok_type)
|
||||||
DRTV ("guard", no, NULL, tok_guard)
|
|
||||||
DRTV ("union", no, NULL, tok_union)
|
DRTV ("union", no, NULL, tok_union)
|
||||||
DRTV ("expect", no, NULL, tok_expect)
|
DRTV ("expect", no, NULL, tok_expect)
|
||||||
DRTV ("thong", no, NULL, tok_thong)
|
DRTV ("thong", no, NULL, tok_thong)
|
||||||
@@ -104,7 +103,6 @@ const struct option_table_struct option_table[] =
|
|||||||
BOTH ("name-prefix", required, &spec_name_prefix, tok_stropt, 'p')
|
BOTH ("name-prefix", required, &spec_name_prefix, tok_stropt, 'p')
|
||||||
|
|
||||||
DRTV ("define", no, NULL, tok_define)
|
DRTV ("define", no, NULL, tok_define)
|
||||||
DRTV ("semantic-parser",no, &semantic_parser, tok_intopt)
|
|
||||||
DRTV ("pure-parser", no, &pure_parser, tok_intopt)
|
DRTV ("pure-parser", no, &pure_parser, tok_intopt)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
39
src/output.c
39
src/output.c
@@ -568,30 +568,6 @@ actions_output (FILE *out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------.
|
|
||||||
| 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. |
|
| Output the tokens definition to OOUT. |
|
||||||
`---------------------------------------*/
|
`---------------------------------------*/
|
||||||
@@ -629,10 +605,6 @@ token_definitions_output (FILE *out)
|
|||||||
|
|
||||||
fprintf (out, "%s [[[%s]], [%d]]",
|
fprintf (out, "%s [[[%s]], [%d]]",
|
||||||
first ? "" : ",\n", symbol->tag, number);
|
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;
|
first = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1020,10 +992,6 @@ output_skeleton (void)
|
|||||||
actions_output (out);
|
actions_output (out);
|
||||||
fputs ("]])\n\n", 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);
|
fputs ("m4_define([b4_tokens], \n[", out);
|
||||||
token_definitions_output (out);
|
token_definitions_output (out);
|
||||||
fputs ("])\n\n", out);
|
fputs ("])\n\n", out);
|
||||||
@@ -1099,12 +1067,7 @@ prepare (void)
|
|||||||
|
|
||||||
/* Find the right skeleton file. */
|
/* Find the right skeleton file. */
|
||||||
if (!skeleton)
|
if (!skeleton)
|
||||||
{
|
skeleton = "bison.simple";
|
||||||
if (semantic_parser)
|
|
||||||
skeleton = "bison.hairy";
|
|
||||||
else
|
|
||||||
skeleton = "bison.simple";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Parse the skeleton file and output the needed parsers. */
|
/* Parse the skeleton file and output the needed parsers. */
|
||||||
muscle_insert ("skeleton", skeleton);
|
muscle_insert ("skeleton", skeleton);
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ extern int error_verbose;
|
|||||||
void output PARAMS ((void));
|
void output PARAMS ((void));
|
||||||
|
|
||||||
void actions_output PARAMS ((FILE *out));
|
void actions_output PARAMS ((FILE *out));
|
||||||
void guards_output PARAMS ((FILE *out));
|
|
||||||
void token_definitions_output PARAMS ((FILE *out));
|
void token_definitions_output PARAMS ((FILE *out));
|
||||||
|
|
||||||
extern struct obstack muscle_obstack;
|
extern struct obstack muscle_obstack;
|
||||||
|
|||||||
51
src/reader.c
51
src/reader.c
@@ -45,9 +45,6 @@ typedef struct symbol_list
|
|||||||
const char *action;
|
const char *action;
|
||||||
int action_line;
|
int action_line;
|
||||||
|
|
||||||
/* The guard is attached to the LHS of a rule. */
|
|
||||||
const char *guard;
|
|
||||||
int guard_line;
|
|
||||||
symbol_t *ruleprec;
|
symbol_t *ruleprec;
|
||||||
} symbol_list;
|
} symbol_list;
|
||||||
|
|
||||||
@@ -80,8 +77,6 @@ symbol_list_new (symbol_t *sym)
|
|||||||
res->line = lineno;
|
res->line = lineno;
|
||||||
res->action = NULL;
|
res->action = NULL;
|
||||||
res->action_line = 0;
|
res->action_line = 0;
|
||||||
res->guard = NULL;
|
|
||||||
res->guard_line = 0;
|
|
||||||
res->ruleprec = NULL;
|
res->ruleprec = NULL;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -1273,9 +1268,7 @@ read_declarations (void)
|
|||||||
| values in the current rule so far, which says where to find `$0' |
|
| values in the current rule so far, which says where to find `$0' |
|
||||||
| with respect to the top of the stack. |
|
| with respect to the top of the stack. |
|
||||||
| |
|
| |
|
||||||
| This routine is used both for actions and guards. Only |
|
| This routine is used for actions. |
|
||||||
| ACTION_OBSTACK is used, but this is fine, since we use only |
|
|
||||||
| pointers to relevant portions inside this obstack. |
|
|
||||||
`------------------------------------------------------------------*/
|
`------------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1341,18 +1334,6 @@ parse_action (symbol_list *rule, int rule_length)
|
|||||||
rule->action = obstack_finish (&action_obstack);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------.
|
/*-------------------------------------------------------------------.
|
||||||
@@ -1384,8 +1365,8 @@ gensym (void)
|
|||||||
| null pointer instead of a symbol to terminate the rule. The next |
|
| null pointer instead of a symbol to terminate the rule. The next |
|
||||||
| symbol is the lhs of the following rule. |
|
| symbol is the lhs of the following rule. |
|
||||||
| |
|
| |
|
||||||
| All guards and actions are copied out to the appropriate files, |
|
| All actions are copied out, labelled by the rule number they apply |
|
||||||
| labelled by the rule number they apply to. |
|
| to. |
|
||||||
| |
|
| |
|
||||||
| Bison used to allow some %directives in the rules sections, but |
|
| Bison used to allow some %directives in the rules sections, but |
|
||||||
| this is no longer consider appropriate: (i) the documented grammar |
|
| this is no longer consider appropriate: (i) the documented grammar |
|
||||||
@@ -1582,15 +1563,6 @@ readgram (void)
|
|||||||
t = lex ();
|
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)
|
if (t == tok_left_curly)
|
||||||
{
|
{
|
||||||
/* This case never occurs -wjh */
|
/* This case never occurs -wjh */
|
||||||
@@ -1791,8 +1763,6 @@ packgram (void)
|
|||||||
rules[ruleno].useful = TRUE;
|
rules[ruleno].useful = TRUE;
|
||||||
rules[ruleno].action = p->action;
|
rules[ruleno].action = p->action;
|
||||||
rules[ruleno].action_line = p->action_line;
|
rules[ruleno].action_line = p->action_line;
|
||||||
rules[ruleno].guard = p->guard;
|
|
||||||
rules[ruleno].guard_line = p->guard_line;
|
|
||||||
|
|
||||||
p = p->next;
|
p = p->next;
|
||||||
while (p && p->sym)
|
while (p && p->sym)
|
||||||
@@ -1829,13 +1799,12 @@ packgram (void)
|
|||||||
ritem_print (stderr);
|
ritem_print (stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------.
|
/*------------------------------------------------------------------.
|
||||||
| Read in the grammar specification and record it in the format |
|
| Read in the grammar specification and record it in the format |
|
||||||
| described in gram.h. All guards are copied into the GUARD_OBSTACK |
|
| described in gram.h. All actions are copied into ACTION_OBSTACK, |
|
||||||
| and all actions into ACTION_OBSTACK, in each case forming the body |
|
| in each case forming the body of a C function (YYACTION) which |
|
||||||
| of a C function (YYGUARD or YYACTION) which contains a switch |
|
| contains a switch statement to decide which action to execute. |
|
||||||
| statement to decide which guard or action to execute. |
|
`------------------------------------------------------------------*/
|
||||||
`-------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
void
|
void
|
||||||
reader (void)
|
reader (void)
|
||||||
@@ -1889,7 +1858,7 @@ reader (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read in the grammar, build grammar in list form. Write out
|
/* Read in the grammar, build grammar in list form. Write out
|
||||||
guards and actions. */
|
actions. */
|
||||||
readgram ();
|
readgram ();
|
||||||
/* Some C code is given at the end of the grammar file. */
|
/* Some C code is given at the end of the grammar file. */
|
||||||
read_additionnal_code ();
|
read_additionnal_code ();
|
||||||
|
|||||||
@@ -24,10 +24,7 @@
|
|||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
|
|
||||||
/* Read in the grammar specification and record it in the format
|
/* Read in the grammar specification and record it in the format
|
||||||
described in gram.h. All guards are copied into the FGUARD file
|
described in gram.h. */
|
||||||
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. */
|
|
||||||
|
|
||||||
void reader PARAMS ((void));
|
void reader PARAMS ((void));
|
||||||
|
|
||||||
|
|||||||
@@ -238,21 +238,15 @@ do { \
|
|||||||
/* VMS. */
|
/* VMS. */
|
||||||
# define EXT_TAB "_tab"
|
# define EXT_TAB "_tab"
|
||||||
# define EXT_OUTPUT ".output"
|
# define EXT_OUTPUT ".output"
|
||||||
# define EXT_STYPE_H "_stype"
|
|
||||||
# define EXT_GUARD_C "_guard"
|
|
||||||
#else /* ! VMS */
|
#else /* ! VMS */
|
||||||
# ifdef MSDOS
|
# ifdef MSDOS
|
||||||
/* MS DOS. */
|
/* MS DOS. */
|
||||||
# define EXT_TAB "_tab"
|
# define EXT_TAB "_tab"
|
||||||
# define EXT_OUTPUT ".out"
|
# define EXT_OUTPUT ".out"
|
||||||
# define EXT_STYPE_H ".sth"
|
|
||||||
# define EXT_GUARD_C ".guc"
|
|
||||||
# else /* ! MSDOS */
|
# else /* ! MSDOS */
|
||||||
/* Standard. */
|
/* Standard. */
|
||||||
# define EXT_TAB ".tab"
|
# define EXT_TAB ".tab"
|
||||||
# define EXT_OUTPUT ".output"
|
# define EXT_OUTPUT ".output"
|
||||||
# define EXT_STYPE_H ".stype"
|
|
||||||
# define EXT_GUARD_C ".guard"
|
|
||||||
# endif /* ! MSDOS */
|
# endif /* ! MSDOS */
|
||||||
#endif /* ! VMS */
|
#endif /* ! VMS */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
## Process this file with automake to create Makefile.in.
|
## Process this file with automake to create Makefile.in.
|
||||||
|
|
||||||
## Makefile for Bison testsuite.
|
## 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
|
## 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
|
## it under the terms of the GNU General Public License as published by
|
||||||
@@ -49,8 +49,7 @@ TESTSUITE_AT = \
|
|||||||
output.at sets.at reduce.at \
|
output.at sets.at reduce.at \
|
||||||
synclines.at headers.at actions.at conflicts.at \
|
synclines.at headers.at actions.at conflicts.at \
|
||||||
calc.at \
|
calc.at \
|
||||||
torture.at existing.at regression.at \
|
torture.at existing.at regression.at
|
||||||
semantic.at
|
|
||||||
|
|
||||||
TESTSUITE = $(srcdir)/testsuite
|
TESTSUITE = $(srcdir)/testsuite
|
||||||
|
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
# 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
|
|
||||||
@@ -61,6 +61,3 @@ m4_include([existing.at])
|
|||||||
|
|
||||||
# Some old bugs.
|
# Some old bugs.
|
||||||
m4_include([regression.at])
|
m4_include([regression.at])
|
||||||
|
|
||||||
# Exercising bison.hairy, before it gets really removed...
|
|
||||||
m4_include([semantic.at])
|
|
||||||
|
|||||||
Reference in New Issue
Block a user