mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-23 03:03:02 +00:00
* bootstrap (gnulib_modules): Add strverscmp.
* lib/.cvsignore: Add strverscmp.c, strverscmp.h. * m4/.cvsignore: Add strverscmp.m4. * src/parse-gram.y (%require): New token, new rule. (version_check): New. * src/scan-gram.l (%require): Adjust. * tests/input.at (AT_REQUIRE): New. Use it. * doc/bison.texinfo (Require Decl): New. (Calc++ Parser): Use %require.
This commit is contained in:
13
ChangeLog
13
ChangeLog
@@ -1,3 +1,16 @@
|
|||||||
|
2005-10-02 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* bootstrap (gnulib_modules): Add strverscmp.
|
||||||
|
* lib/.cvsignore: Add strverscmp.c, strverscmp.h.
|
||||||
|
* m4/.cvsignore: Add strverscmp.m4.
|
||||||
|
* src/parse-gram.y (%require): New token, new rule.
|
||||||
|
(version_check): New.
|
||||||
|
* src/scan-gram.l (%require): Adjust.
|
||||||
|
* tests/input.at (AT_REQUIRE): New.
|
||||||
|
Use it.
|
||||||
|
* doc/bison.texinfo (Require Decl): New.
|
||||||
|
(Calc++ Parser): Use %require.
|
||||||
|
|
||||||
2005-10-02 Akim Demaille <akim@epita.fr>
|
2005-10-02 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* data/location.cc: New.
|
* data/location.cc: New.
|
||||||
|
|||||||
8
NEWS
8
NEWS
@@ -5,6 +5,9 @@ Changes in version 2.1a:
|
|||||||
|
|
||||||
* DJGPP support added.
|
* DJGPP support added.
|
||||||
|
|
||||||
|
* %require "VERSION"
|
||||||
|
To specify the youngest version of Bison accepted by the grammar file.
|
||||||
|
|
||||||
* lalr1.cc: The token and value types are now class members.
|
* lalr1.cc: The token and value types are now class members.
|
||||||
The tokens where defined as free form enums and cpp macros. YYSTYPE
|
The tokens where defined as free form enums and cpp macros. YYSTYPE
|
||||||
was defined as a free form union. Both are now class members:
|
was defined as a free form union. Both are now class members:
|
||||||
@@ -13,8 +16,11 @@ Changes in version 2.1a:
|
|||||||
|
|
||||||
If you do not want or can update to this scheme, the directive
|
If you do not want or can update to this scheme, the directive
|
||||||
`%define "global_tokens_and_yystype" "1"' triggers the global
|
`%define "global_tokens_and_yystype" "1"' triggers the global
|
||||||
definition of tokens and YYSTYPE.
|
definition of tokens and YYSTYPE. This change is suitable both
|
||||||
|
for previous releases of Bison, and this one.
|
||||||
|
|
||||||
|
If you wish to update, then make sure older version of Bison will
|
||||||
|
fail using `%require "2.1a"'.
|
||||||
|
|
||||||
Changes in version 2.1, 2005-09-16:
|
Changes in version 2.1, 2005-09-16:
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ stdio-safer
|
|||||||
stpcpy
|
stpcpy
|
||||||
strerror
|
strerror
|
||||||
strtoul
|
strtoul
|
||||||
|
strverscmp
|
||||||
unistd-safer
|
unistd-safer
|
||||||
verify
|
verify
|
||||||
xalloc
|
xalloc
|
||||||
|
|||||||
@@ -145,9 +145,9 @@ The Concepts of Bison
|
|||||||
|
|
||||||
Writing @acronym{GLR} Parsers
|
Writing @acronym{GLR} Parsers
|
||||||
|
|
||||||
* Simple GLR Parsers:: Using @acronym{GLR} parsers on unambiguous grammars
|
* Simple GLR Parsers:: Using @acronym{GLR} parsers on unambiguous grammars
|
||||||
* Merging GLR Parses:: Using @acronym{GLR} parsers to resolve ambiguities
|
* Merging GLR Parses:: Using @acronym{GLR} parsers to resolve ambiguities
|
||||||
* Compiler Requirements:: @acronym{GLR} parsers require a modern C compiler
|
* Compiler Requirements:: @acronym{GLR} parsers require a modern C compiler
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
|
|
||||||
@@ -225,6 +225,7 @@ Tracking Locations
|
|||||||
|
|
||||||
Bison Declarations
|
Bison Declarations
|
||||||
|
|
||||||
|
* Require Decl:: Requiring a Bison version.
|
||||||
* Token Decl:: Declaring terminal symbols.
|
* Token Decl:: Declaring terminal symbols.
|
||||||
* Precedence Decl:: Declaring terminals with precedence and associativity.
|
* Precedence Decl:: Declaring terminals with precedence and associativity.
|
||||||
* Union Decl:: Declaring the set of all semantic value types.
|
* Union Decl:: Declaring the set of all semantic value types.
|
||||||
@@ -732,9 +733,9 @@ user-defined function on the resulting values to produce an arbitrary
|
|||||||
merged result.
|
merged result.
|
||||||
|
|
||||||
@menu
|
@menu
|
||||||
* Simple GLR Parsers:: Using @acronym{GLR} parsers on unambiguous grammars
|
* Simple GLR Parsers:: Using @acronym{GLR} parsers on unambiguous grammars
|
||||||
* Merging GLR Parses:: Using @acronym{GLR} parsers to resolve ambiguities
|
* Merging GLR Parses:: Using @acronym{GLR} parsers to resolve ambiguities
|
||||||
* Compiler Requirements:: @acronym{GLR} parsers require a modern C compiler
|
* Compiler Requirements:: @acronym{GLR} parsers require a modern C compiler
|
||||||
@end menu
|
@end menu
|
||||||
|
|
||||||
@node Simple GLR Parsers
|
@node Simple GLR Parsers
|
||||||
@@ -3548,6 +3549,7 @@ it explicitly (@pxref{Language and Grammar, ,Languages and Context-Free
|
|||||||
Grammars}).
|
Grammars}).
|
||||||
|
|
||||||
@menu
|
@menu
|
||||||
|
* Require Decl:: Requiring a Bison version.
|
||||||
* Token Decl:: Declaring terminal symbols.
|
* Token Decl:: Declaring terminal symbols.
|
||||||
* Precedence Decl:: Declaring terminals with precedence and associativity.
|
* Precedence Decl:: Declaring terminals with precedence and associativity.
|
||||||
* Union Decl:: Declaring the set of all semantic value types.
|
* Union Decl:: Declaring the set of all semantic value types.
|
||||||
@@ -3560,6 +3562,19 @@ Grammars}).
|
|||||||
* Decl Summary:: Table of all Bison declarations.
|
* Decl Summary:: Table of all Bison declarations.
|
||||||
@end menu
|
@end menu
|
||||||
|
|
||||||
|
@node Require Decl
|
||||||
|
@subsection Require a Version of Bison
|
||||||
|
@cindex version requirement
|
||||||
|
@cindex requiring a version of Bison
|
||||||
|
@findex %require
|
||||||
|
|
||||||
|
You may require the minimum version of Bison to process the grammar. If
|
||||||
|
the requirement is not met, @command{bison} exits with an error.
|
||||||
|
|
||||||
|
@example
|
||||||
|
%require "@var{version}"
|
||||||
|
@end example
|
||||||
|
|
||||||
@node Token Decl
|
@node Token Decl
|
||||||
@subsection Token Type Names
|
@subsection Token Type Names
|
||||||
@cindex declaring token type names
|
@cindex declaring token type names
|
||||||
@@ -4157,6 +4172,12 @@ Request a pure (reentrant) parser program (@pxref{Pure Decl, ,A Pure
|
|||||||
(Reentrant) Parser}).
|
(Reentrant) Parser}).
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
|
@deffn {Directive} %require "@var{version}"
|
||||||
|
Specify that version @var{version} or higher of Bison required for the
|
||||||
|
grammar.
|
||||||
|
@xref{Require Decl, , Require a Version of Bison}.
|
||||||
|
@end deffn
|
||||||
|
|
||||||
@deffn {Directive} %token-table
|
@deffn {Directive} %token-table
|
||||||
Generate an array of token names in the parser file. The name of the
|
Generate an array of token names in the parser file. The name of the
|
||||||
array is @code{yytname}; @code{yytname[@var{i}]} is the name of the
|
array is @code{yytname}; @code{yytname[@var{i}]} is the name of the
|
||||||
@@ -7275,13 +7296,16 @@ calcxx_driver::error (const std::string& m)
|
|||||||
@node Calc++ Parser
|
@node Calc++ Parser
|
||||||
@subsection Calc++ Parser
|
@subsection Calc++ Parser
|
||||||
|
|
||||||
The parser definition file @file{calc++-parser.yy} starts by asking
|
The parser definition file @file{calc++-parser.yy} starts by asking for
|
||||||
for the C++ LALR(1) skeleton, the creation of the parser header file, and
|
the C++ LALR(1) skeleton, the creation of the parser header file, and
|
||||||
specifies the name of the parser class.
|
specifies the name of the parser class. Because the C++ skeleton
|
||||||
|
changed several times, it is safer to require the version you designed
|
||||||
|
the grammar for.
|
||||||
|
|
||||||
@comment file: calc++-parser.yy
|
@comment file: calc++-parser.yy
|
||||||
@example
|
@example
|
||||||
%skeleton "lalr1.cc" /* -*- C++ -*- */
|
%skeleton "lalr1.cc" /* -*- C++ -*- */
|
||||||
|
%require "2.1a"
|
||||||
%defines
|
%defines
|
||||||
%define "parser_class_name" "calcxx_parser"
|
%define "parser_class_name" "calcxx_parser"
|
||||||
@end example
|
@end example
|
||||||
@@ -7968,6 +7992,12 @@ Bison declaration to request a pure (reentrant) parser.
|
|||||||
@xref{Pure Decl, ,A Pure (Reentrant) Parser}.
|
@xref{Pure Decl, ,A Pure (Reentrant) Parser}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
|
@deffn {Directive} %require "@var{version}"
|
||||||
|
Specify that version @var{version} or higher of Bison required for the
|
||||||
|
grammar.
|
||||||
|
@xref{Require Decl, , Require a Version of Bison}.
|
||||||
|
@end deffn
|
||||||
|
|
||||||
@deffn {Directive} %right
|
@deffn {Directive} %right
|
||||||
Bison declaration to assign right associativity to token(s).
|
Bison declaration to assign right associativity to token(s).
|
||||||
@xref{Precedence Decl, ,Operator Precedence}.
|
@xref{Precedence Decl, ,Operator Precedence}.
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ strnlen.c
|
|||||||
strnlen.h
|
strnlen.h
|
||||||
strtol.c
|
strtol.c
|
||||||
strtoul.c
|
strtoul.c
|
||||||
|
strverscmp.c
|
||||||
|
strverscmp.h
|
||||||
unistd--.h
|
unistd--.h
|
||||||
unistd-safer.h
|
unistd-safer.h
|
||||||
unlocked-io.h
|
unlocked-io.h
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ strndup.m4
|
|||||||
strnlen.m4
|
strnlen.m4
|
||||||
strtol.m4
|
strtol.m4
|
||||||
strtoul.m4
|
strtoul.m4
|
||||||
|
strverscmp.m4
|
||||||
unistd-safer.m4
|
unistd-safer.m4
|
||||||
unlocked-io.m4
|
unlocked-io.m4
|
||||||
xalloc.m4
|
xalloc.m4
|
||||||
|
|||||||
697
src/parse-gram.c
697
src/parse-gram.c
File diff suppressed because it is too large
Load Diff
@@ -63,21 +63,22 @@
|
|||||||
PERCENT_OUTPUT = 288,
|
PERCENT_OUTPUT = 288,
|
||||||
PERCENT_PARSE_PARAM = 289,
|
PERCENT_PARSE_PARAM = 289,
|
||||||
PERCENT_PURE_PARSER = 290,
|
PERCENT_PURE_PARSER = 290,
|
||||||
PERCENT_SKELETON = 291,
|
PERCENT_REQUIRE = 291,
|
||||||
PERCENT_START = 292,
|
PERCENT_SKELETON = 292,
|
||||||
PERCENT_TOKEN_TABLE = 293,
|
PERCENT_START = 293,
|
||||||
PERCENT_VERBOSE = 294,
|
PERCENT_TOKEN_TABLE = 294,
|
||||||
PERCENT_YACC = 295,
|
PERCENT_VERBOSE = 295,
|
||||||
TYPE = 296,
|
PERCENT_YACC = 296,
|
||||||
EQUAL = 297,
|
TYPE = 297,
|
||||||
SEMICOLON = 298,
|
EQUAL = 298,
|
||||||
PIPE = 299,
|
SEMICOLON = 299,
|
||||||
ID = 300,
|
PIPE = 300,
|
||||||
ID_COLON = 301,
|
ID = 301,
|
||||||
PERCENT_PERCENT = 302,
|
ID_COLON = 302,
|
||||||
PROLOGUE = 303,
|
PERCENT_PERCENT = 303,
|
||||||
EPILOGUE = 304,
|
PROLOGUE = 304,
|
||||||
BRACED_CODE = 305
|
EPILOGUE = 305,
|
||||||
|
BRACED_CODE = 306
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
/* Tokens. */
|
/* Tokens. */
|
||||||
@@ -115,27 +116,28 @@
|
|||||||
#define PERCENT_OUTPUT 288
|
#define PERCENT_OUTPUT 288
|
||||||
#define PERCENT_PARSE_PARAM 289
|
#define PERCENT_PARSE_PARAM 289
|
||||||
#define PERCENT_PURE_PARSER 290
|
#define PERCENT_PURE_PARSER 290
|
||||||
#define PERCENT_SKELETON 291
|
#define PERCENT_REQUIRE 291
|
||||||
#define PERCENT_START 292
|
#define PERCENT_SKELETON 292
|
||||||
#define PERCENT_TOKEN_TABLE 293
|
#define PERCENT_START 293
|
||||||
#define PERCENT_VERBOSE 294
|
#define PERCENT_TOKEN_TABLE 294
|
||||||
#define PERCENT_YACC 295
|
#define PERCENT_VERBOSE 295
|
||||||
#define TYPE 296
|
#define PERCENT_YACC 296
|
||||||
#define EQUAL 297
|
#define TYPE 297
|
||||||
#define SEMICOLON 298
|
#define EQUAL 298
|
||||||
#define PIPE 299
|
#define SEMICOLON 299
|
||||||
#define ID 300
|
#define PIPE 300
|
||||||
#define ID_COLON 301
|
#define ID 301
|
||||||
#define PERCENT_PERCENT 302
|
#define ID_COLON 302
|
||||||
#define PROLOGUE 303
|
#define PERCENT_PERCENT 303
|
||||||
#define EPILOGUE 304
|
#define PROLOGUE 304
|
||||||
#define BRACED_CODE 305
|
#define EPILOGUE 305
|
||||||
|
#define BRACED_CODE 306
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
||||||
#line 79 "../../src/parse-gram.y"
|
#line 82 "../../src/parse-gram.y"
|
||||||
typedef union YYSTYPE {
|
typedef union YYSTYPE {
|
||||||
symbol *symbol;
|
symbol *symbol;
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
@@ -145,7 +147,7 @@ typedef union YYSTYPE {
|
|||||||
uniqstr uniqstr;
|
uniqstr uniqstr;
|
||||||
} YYSTYPE;
|
} YYSTYPE;
|
||||||
/* Line 1505 of yacc.c. */
|
/* Line 1505 of yacc.c. */
|
||||||
#line 149 "../../src/parse-gram.h"
|
#line 151 "../../src/parse-gram.h"
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||||
# define YYSTYPE_IS_DECLARED 1
|
# define YYSTYPE_IS_DECLARED 1
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "quotearg.h"
|
#include "quotearg.h"
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
#include "symlist.h"
|
#include "symlist.h"
|
||||||
|
#include "strverscmp.h"
|
||||||
|
|
||||||
#define YYLLOC_DEFAULT(Current, Rhs, N) (Current) = lloc_default (Rhs, N)
|
#define YYLLOC_DEFAULT(Current, Rhs, N) (Current) = lloc_default (Rhs, N)
|
||||||
static YYLTYPE lloc_default (YYLTYPE const *, int);
|
static YYLTYPE lloc_default (YYLTYPE const *, int);
|
||||||
@@ -39,6 +40,8 @@ static YYLTYPE lloc_default (YYLTYPE const *, int);
|
|||||||
#define YY_LOCATION_PRINT(File, Loc) \
|
#define YY_LOCATION_PRINT(File, Loc) \
|
||||||
location_print (File, Loc)
|
location_print (File, Loc)
|
||||||
|
|
||||||
|
static void version_check (location const *loc, char const *version);
|
||||||
|
|
||||||
/* Request detailed syntax error messages, and pass them to GRAM_ERROR.
|
/* Request detailed syntax error messages, and pass them to GRAM_ERROR.
|
||||||
FIXME: depends on the undocumented availability of YYLLOC. */
|
FIXME: depends on the undocumented availability of YYLLOC. */
|
||||||
#undef yyerror
|
#undef yyerror
|
||||||
@@ -133,6 +136,7 @@ static int current_prec = 0;
|
|||||||
PERCENT_OUTPUT "%output"
|
PERCENT_OUTPUT "%output"
|
||||||
PERCENT_PARSE_PARAM "%parse-param {...}"
|
PERCENT_PARSE_PARAM "%parse-param {...}"
|
||||||
PERCENT_PURE_PARSER "%pure-parser"
|
PERCENT_PURE_PARSER "%pure-parser"
|
||||||
|
PERCENT_REQUIRE "%require"
|
||||||
PERCENT_SKELETON "%skeleton"
|
PERCENT_SKELETON "%skeleton"
|
||||||
PERCENT_START "%start"
|
PERCENT_START "%start"
|
||||||
PERCENT_TOKEN_TABLE "%token-table"
|
PERCENT_TOKEN_TABLE "%token-table"
|
||||||
@@ -226,6 +230,7 @@ declaration:
|
|||||||
| "%output" "=" string_content { spec_outfile = $3; }
|
| "%output" "=" string_content { spec_outfile = $3; }
|
||||||
| "%parse-param {...}" { add_param ("parse_param", $1, @1); }
|
| "%parse-param {...}" { add_param ("parse_param", $1, @1); }
|
||||||
| "%pure-parser" { pure_parser = true; }
|
| "%pure-parser" { pure_parser = true; }
|
||||||
|
| "%require" string_content { version_check (&@2, $2); }
|
||||||
| "%skeleton" string_content { skeleton = $2; }
|
| "%skeleton" string_content { skeleton = $2; }
|
||||||
| "%token-table" { token_table_flag = true; }
|
| "%token-table" { token_table_flag = true; }
|
||||||
| "%verbose" { report_flag = report_states; }
|
| "%verbose" { report_flag = report_states; }
|
||||||
@@ -530,6 +535,14 @@ add_param (char const *type, char *decl, location loc)
|
|||||||
scanner_last_string_free ();
|
scanner_last_string_free ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
version_check (location const *loc, char const *version)
|
||||||
|
{
|
||||||
|
if (strverscmp (version, PACKAGE_VERSION) > 0)
|
||||||
|
complain_at (*loc, "require bison %s, but have %s",
|
||||||
|
version, PACKAGE_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gram_error (location const *loc, char const *msg)
|
gram_error (location const *loc, char const *msg)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -224,6 +224,7 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
"%prec" rule_length--; return PERCENT_PREC;
|
"%prec" rule_length--; return PERCENT_PREC;
|
||||||
"%printer" token_type = PERCENT_PRINTER; BEGIN SC_PRE_CODE;
|
"%printer" token_type = PERCENT_PRINTER; BEGIN SC_PRE_CODE;
|
||||||
"%pure"[-_]"parser" return PERCENT_PURE_PARSER;
|
"%pure"[-_]"parser" return PERCENT_PURE_PARSER;
|
||||||
|
"%require" return PERCENT_REQUIRE;
|
||||||
"%right" return PERCENT_RIGHT;
|
"%right" return PERCENT_RIGHT;
|
||||||
"%skeleton" return PERCENT_SKELETON;
|
"%skeleton" return PERCENT_SKELETON;
|
||||||
"%start" return PERCENT_START;
|
"%start" return PERCENT_START;
|
||||||
|
|||||||
@@ -297,3 +297,24 @@ exp: "MY TOKEN";
|
|||||||
AT_CHECK([bison -o input.c input.y])
|
AT_CHECK([bison -o input.c input.y])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
|
## --------- ##
|
||||||
|
## Require. ##
|
||||||
|
## --------- ##
|
||||||
|
|
||||||
|
m4_define([AT_CHECK_REQUIRE],
|
||||||
|
[AT_SETUP([Require $1])
|
||||||
|
AT_DATA_GRAMMAR([input.y],
|
||||||
|
[[%require "$1";
|
||||||
|
%%
|
||||||
|
empty_file:;
|
||||||
|
]])
|
||||||
|
AT_CHECK([bison -o input.c input.y], $2, [], ignore)
|
||||||
|
AT_CLEANUP
|
||||||
|
])
|
||||||
|
|
||||||
|
AT_CHECK_REQUIRE(1.0, 0)
|
||||||
|
AT_CHECK_REQUIRE(AT_PACKAGE_VERSION, 0)
|
||||||
|
## FIXME: Some day augment this version number.
|
||||||
|
AT_CHECK_REQUIRE(100.0, 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user