* 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:
Akim Demaille
2005-10-02 18:49:15 +00:00
parent 21667f64cd
commit b50d2359d7
11 changed files with 491 additions and 380 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -63,21 +63,22 @@
PERCENT_OUTPUT = 288,
PERCENT_PARSE_PARAM = 289,
PERCENT_PURE_PARSER = 290,
PERCENT_SKELETON = 291,
PERCENT_START = 292,
PERCENT_TOKEN_TABLE = 293,
PERCENT_VERBOSE = 294,
PERCENT_YACC = 295,
TYPE = 296,
EQUAL = 297,
SEMICOLON = 298,
PIPE = 299,
ID = 300,
ID_COLON = 301,
PERCENT_PERCENT = 302,
PROLOGUE = 303,
EPILOGUE = 304,
BRACED_CODE = 305
PERCENT_REQUIRE = 291,
PERCENT_SKELETON = 292,
PERCENT_START = 293,
PERCENT_TOKEN_TABLE = 294,
PERCENT_VERBOSE = 295,
PERCENT_YACC = 296,
TYPE = 297,
EQUAL = 298,
SEMICOLON = 299,
PIPE = 300,
ID = 301,
ID_COLON = 302,
PERCENT_PERCENT = 303,
PROLOGUE = 304,
EPILOGUE = 305,
BRACED_CODE = 306
};
#endif
/* Tokens. */
@@ -115,27 +116,28 @@
#define PERCENT_OUTPUT 288
#define PERCENT_PARSE_PARAM 289
#define PERCENT_PURE_PARSER 290
#define PERCENT_SKELETON 291
#define PERCENT_START 292
#define PERCENT_TOKEN_TABLE 293
#define PERCENT_VERBOSE 294
#define PERCENT_YACC 295
#define TYPE 296
#define EQUAL 297
#define SEMICOLON 298
#define PIPE 299
#define ID 300
#define ID_COLON 301
#define PERCENT_PERCENT 302
#define PROLOGUE 303
#define EPILOGUE 304
#define BRACED_CODE 305
#define PERCENT_REQUIRE 291
#define PERCENT_SKELETON 292
#define PERCENT_START 293
#define PERCENT_TOKEN_TABLE 294
#define PERCENT_VERBOSE 295
#define PERCENT_YACC 296
#define TYPE 297
#define EQUAL 298
#define SEMICOLON 299
#define PIPE 300
#define ID 301
#define ID_COLON 302
#define PERCENT_PERCENT 303
#define PROLOGUE 304
#define EPILOGUE 305
#define BRACED_CODE 306
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 79 "../../src/parse-gram.y"
#line 82 "../../src/parse-gram.y"
typedef union YYSTYPE {
symbol *symbol;
symbol_list *list;
@@ -145,7 +147,7 @@ typedef union YYSTYPE {
uniqstr uniqstr;
} YYSTYPE;
/* 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_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1

View File

@@ -32,6 +32,7 @@
#include "quotearg.h"
#include "reader.h"
#include "symlist.h"
#include "strverscmp.h"
#define YYLLOC_DEFAULT(Current, Rhs, N) (Current) = lloc_default (Rhs, N)
static YYLTYPE lloc_default (YYLTYPE const *, int);
@@ -39,6 +40,8 @@ static YYLTYPE lloc_default (YYLTYPE const *, int);
#define YY_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.
FIXME: depends on the undocumented availability of YYLLOC. */
#undef yyerror
@@ -133,6 +136,7 @@ static int current_prec = 0;
PERCENT_OUTPUT "%output"
PERCENT_PARSE_PARAM "%parse-param {...}"
PERCENT_PURE_PARSER "%pure-parser"
PERCENT_REQUIRE "%require"
PERCENT_SKELETON "%skeleton"
PERCENT_START "%start"
PERCENT_TOKEN_TABLE "%token-table"
@@ -226,6 +230,7 @@ declaration:
| "%output" "=" string_content { spec_outfile = $3; }
| "%parse-param {...}" { add_param ("parse_param", $1, @1); }
| "%pure-parser" { pure_parser = true; }
| "%require" string_content { version_check (&@2, $2); }
| "%skeleton" string_content { skeleton = $2; }
| "%token-table" { token_table_flag = true; }
| "%verbose" { report_flag = report_states; }
@@ -530,6 +535,14 @@ add_param (char const *type, char *decl, location loc)
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
gram_error (location const *loc, char const *msg)
{

View File

@@ -224,6 +224,7 @@ splice (\\[ \f\t\v]*\n)*
"%prec" rule_length--; return PERCENT_PREC;
"%printer" token_type = PERCENT_PRINTER; BEGIN SC_PRE_CODE;
"%pure"[-_]"parser" return PERCENT_PURE_PARSER;
"%require" return PERCENT_REQUIRE;
"%right" return PERCENT_RIGHT;
"%skeleton" return PERCENT_SKELETON;
"%start" return PERCENT_START;