summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--THANKS1
-rw-r--r--doc/bison.texi4
-rw-r--r--src/parse-gram.y20
-rw-r--r--src/scan-gram.l6
-rw-r--r--tests/actions.at2
-rw-r--r--tests/input.at7
6 files changed, 30 insertions, 10 deletions
diff --git a/THANKS b/THANKS
index eb690d22..50b33f48d 100644
--- a/THANKS
+++ b/THANKS
@@ -179,6 +179,7 @@ Tom Tromey tromey@cygnus.com
Tommy Nordgren tommy.nordgren@chello.se
Troy A. Johnson troyj@ecn.purdue.edu
Tys Lefering gccbison@gmail.com
+Uxio Prego uxio.prego@gmail.com
Valentin Tolmer nitnelave1@gmail.com
wcventure wcventure@126.com
Victor Khomenko victor.khomenko@newcastle.ac.uk
diff --git a/doc/bison.texi b/doc/bison.texi
index 821a5b4c..d5913e8f 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -12416,8 +12416,8 @@ You can create documentation for generated parsers using Javadoc.
Contrary to C parsers, Java parsers do not use global variables; the state
of the parser is always local to an instance of the parser class.
-Therefore, all Java parsers are ``pure'', and the @code{%pure-parser} and
-@code{%define api.pure} directives do nothing when used in Java.
+Therefore, all Java parsers are ``pure'', and the @code{%define api.pure}
+directive does nothing when used in Java.
Push parsers are currently unsupported in Java and @code{%define
api.push-pull} have no effect.
diff --git a/src/parse-gram.y b/src/parse-gram.y
index 175cfd62..c7cc35fd 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -94,6 +94,9 @@
static void handle_name_prefix (location const *loc,
char const *directive, char const *value);
+ /* Handle a %pure-parser directive. */
+ static void handle_pure_parser (location const *loc, char const *directive);
+
/* Handle a %require directive. */
static void handle_require (location const *loc, char const *version);
@@ -181,6 +184,7 @@
PERCENT_NONDETERMINISTIC_PARSER
"%nondeterministic-parser"
PERCENT_OUTPUT "%output"
+ PERCENT_PURE_PARSER "%pure-parser"
PERCENT_REQUIRE "%require"
PERCENT_SKELETON "%skeleton"
PERCENT_START "%start"
@@ -219,7 +223,7 @@
%type <uniqstr>
BRACKETED_ID ID ID_COLON
PERCENT_ERROR_VERBOSE PERCENT_FILE_PREFIX PERCENT_FLAG PERCENT_NAME_PREFIX
- PERCENT_YACC
+ PERCENT_PURE_PARSER PERCENT_YACC
TAG tag tag.opt variable
%printer { fputs ($$, yyo); } <uniqstr>
%printer { fprintf (yyo, "[%s]", $$); } BRACKETED_ID
@@ -343,6 +347,7 @@ prologue_declaration:
| "%nondeterministic-parser" { nondeterministic_parser = true; }
| "%output" STRING { spec_outfile = $2; }
| "%param" { current_param = $1; } params { current_param = param_none; }
+| "%pure-parser" { handle_pure_parser (&@$, $1); }
| "%require" STRING { handle_require (&@2, $2); }
| "%skeleton" STRING { handle_skeleton (&@2, $2); }
| "%token-table" { token_table_flag = true; }
@@ -910,6 +915,7 @@ handle_file_prefix (location const *loc,
deprecated_directive (dir_loc, directive, "%file-prefix");
}
+
static void
handle_name_prefix (location const *loc,
char const *directive, char const *value)
@@ -945,6 +951,16 @@ handle_name_prefix (location const *loc,
static void
+handle_pure_parser (location const *loc, char const *directive)
+{
+ bison_directive (loc, directive);
+ deprecated_directive (loc, directive, "%define api.pure");
+ muscle_percent_define_insert ("api.pure", *loc, muscle_keyword, "",
+ MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
+}
+
+
+static void
handle_require (location const *loc, char const *version)
{
/* Changes of behavior are only on minor version changes, so "3.0.5"
@@ -1006,6 +1022,7 @@ handle_skeleton (location const *loc, char const *skel)
skeleton_arg (skeleton_user, grammar_prio, *loc);
}
+
static void
handle_yacc (location const *loc, char const *directive)
{
@@ -1026,6 +1043,7 @@ handle_yacc (location const *loc, char const *directive)
deprecated_directive (loc, directive, "%fixed-output-files");
}
+
static void
gram_error (location const *loc, char const *msg)
{
diff --git a/src/scan-gram.l b/src/scan-gram.l
index ca4173b8..66a8caa7 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -252,7 +252,6 @@ eqopt ({sp}=)?
"%prec" return PERCENT_PREC;
"%precedence" return BISON_DIRECTIVE (PRECEDENCE);
"%printer" return BISON_DIRECTIVE (PRINTER);
- "%pure-parser" RETURN_PERCENT_FLAG ("api.pure");
"%require" return BISON_DIRECTIVE (REQUIRE);
"%right" return PERCENT_RIGHT;
"%skeleton" return BISON_DIRECTIVE (SKELETON);
@@ -265,6 +264,10 @@ eqopt ({sp}=)?
"%verbose" return BISON_DIRECTIVE (VERBOSE);
"%yacc" RETURN_VALUE (PERCENT_YACC, uniqstr_new (yytext));
+ /* Deprecated since Bison 2.3b (2008-05-27), but the warning is
+ issued only since Bison 3.4. */
+ "%pure"[-_]"parser" RETURN_VALUE (PERCENT_PURE_PARSER, uniqstr_new (yytext));
+
/* Deprecated since Bison 3.0 (2013-07-25), but the warning is
issued only since Bison 3.3. */
"%error-verbose" RETURN_VALUE (PERCENT_ERROR_VERBOSE, uniqstr_new (yytext));
@@ -282,7 +285,6 @@ eqopt ({sp}=)?
"%no"[-_]"default"[-_]"prec" DEPRECATED ("%no-default-prec");
"%no"[-_]"lines" DEPRECATED ("%no-lines");
"%output"{eqopt} DEPRECATED ("%output");
- "%pure"[-_]"parser" DEPRECATED ("%pure-parser");
"%token"[-_]"table" DEPRECATED ("%token-table");
"%"{id} {
diff --git a/tests/actions.at b/tests/actions.at
index 1f279a89..ee49b2ba 100644
--- a/tests/actions.at
+++ b/tests/actions.at
@@ -1870,7 +1870,7 @@ AT_DATA_GRAMMAR([input.y],
[[
%define parse.error verbose
%debug
-%pure-parser
+%define api.pure
%code {
# include <stdio.h>
# include <stdlib.h>
diff --git a/tests/input.at b/tests/input.at
index c2a4478d..cc5e41fb 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -2556,8 +2556,8 @@ input.y:23.1-9: warning: deprecated directive: '%no_lines', use '%no-lines' [-Wd
fix-it:"input.y":{23:1-23:10}:"%no-lines"
input.y:24.1-9: warning: deprecated directive: '%output =', use '%output' [-Wdeprecated]
fix-it:"input.y":{24:1-24:10}:"%output"
-input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%pure-parser' [-Wdeprecated]
-fix-it:"input.y":{25:1-25:13}:"%pure-parser"
+input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%define api.pure' [-Wdeprecated]
+fix-it:"input.y":{25:1-25:13}:"%define api.pure"
input.y:26.1-12: warning: deprecated directive: '%token_table', use '%token-table' [-Wdeprecated]
fix-it:"input.y":{26:1-26:13}:"%token-table"
input.y:27.1-14: warning: %define variable 'parse.error' redefined [-Wother]
@@ -2603,7 +2603,7 @@ AT_CHECK([sed -e '1,8d' input.y], [],
%no-default-prec
%no-lines
%output "output.c"
-%pure-parser
+%define api.pure
%token-table
%glr-parser
%%
@@ -2678,7 +2678,6 @@ AT_DATA_GRAMMAR([[input.y]],
%no-default-prec
%no-lines
%output "foo"
-%pure-parser
%token-table
%% exp : '0'
]])