[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/9] muscle: check the kind of api.prefix, api.location.type
From: |
Akim Demaille |
Subject: |
[PATCH 1/9] muscle: check the kind of api.prefix, api.location.type |
Date: |
Thu, 18 Apr 2013 17:28:00 +0200 |
* data/bison.m4: Check api.prefix.
* data/c++.m4: Check api.location.type.
* doc/bison.texi: Fix uses of api.value.type, api.prefix, api.location.type.
Document {...} values for %define.
* src/parse-gram.y: Fix use of api.prefix.
* tests/calc.at: Fix uses of api.location.type.
* tests/input.at: Check api.prefix, and api.location.type.
---
data/bison.m4 | 1 +
data/c++.m4 | 1 +
doc/bison.texi | 27 ++++++++++++++-------------
src/parse-gram.y | 2 +-
tests/calc.at | 4 ++--
tests/input.at | 14 +++++++++-----
6 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/data/bison.m4 b/data/bison.m4
index fc33d56..64f1bac 100644
--- a/data/bison.m4
+++ b/data/bison.m4
@@ -1027,6 +1027,7 @@ m4_define_default([b4_location_initial_line], [1])
## --------------- ##
# api.prefix >< %name-prefix.
+b4_percent_define_check_kind([api.prefix], [code], [deprecated])
b4_percent_define_ifdef([api.prefix],
[m4_ifdef([b4_prefix],
[b4_complain_at(b4_percent_define_get_loc([api.prefix]),
diff --git a/data/c++.m4 b/data/c++.m4
index 2d686b6..7a74380 100644
--- a/data/c++.m4
+++ b/data/c++.m4
@@ -29,6 +29,7 @@ m4_define([b4_comment],
## Checks. ##
## -------- ##
+b4_percent_define_check_kind([api.location.type], [code], [deprecated])
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
## ---------------- ##
diff --git a/doc/bison.texi b/doc/bison.texi
index bb6465f..bd03ee1 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -2160,7 +2160,7 @@ the same as the declarations for the infix notation
calculator.
address@hidden
/* Bison declarations. */
-%define api.value.type int
+%define api.value.type @address@hidden
%token NUM
%left '-' '+'
@@ -3885,7 +3885,7 @@ and then your grammar can use the following instead of
@code{%union}:
address@hidden
#include "parser.h"
address@hidden
-%define api.value.type "union YYSTYPE"
+%define api.value.type @{union address@hidden
%type <val> expr
%token <tptr> ID
@end group
@@ -5450,6 +5450,7 @@ parse.trace}.
@deffn {Directive} %define @var{variable}
@deffnx {Directive} %define @var{variable} @var{value}
address@hidden {Directive} %define @var{variable} @address@hidden@}
@deffnx {Directive} %define @var{variable} "@var{value}"
Define a variable to adjust Bison's behavior. @xref{%define Summary}.
@end deffn
@@ -5499,7 +5500,7 @@ preprocessor guard: @address@hidden@var{FILE}_INCLUDED},
where
uppercase, with each series of non alphanumerical characters converted to a
single underscore.
-For instance with @samp{%define api.prefix "calc"} and @samp{%defines
+For instance with @samp{%define api.prefix @address@hidden and @samp{%defines
"lib/parse.h"}, the header will be guarded as follows.
@example
#ifndef YY_CALC_LIB_PARSE_H_INCLUDED
@@ -5661,17 +5662,17 @@ features are associated with variables, which are
assigned by the
@deffn {Directive} %define @var{variable}
@deffnx {Directive} %define @var{variable} @var{value}
address@hidden {Directive} %define @var{variable} @address@hidden@}
@deffnx {Directive} %define @var{variable} "@var{value}"
Define @var{variable} to @var{value}.
address@hidden must be placed in quotation marks if it contains any
-character other than a letter, underscore, period, or non-initial dash
-or digit. Omitting @code{"@var{value}"} entirely is always equivalent
-to specifying @code{""}.
+The type of the values depend on the syntax. Braces denote value in the
+target language (e.g., a namespace, a type, etc.). Keyword values (no
+delimiters) denote finite choice (e.g., a variation of a feature). String
+values denote remaining cases (e.g., a file name).
-It is an error if a @var{variable} is defined by @code{%define}
-multiple times, but see @ref{Bison Options,,-D
address@hidden@var{value}]}.
+It is an error if a @var{variable} is defined by @code{%define} multiple
+times, but see @ref{Bison Options,,-D @address@hidden
@end deffn
The rest of this section summarizes variables and values that
@@ -5753,7 +5754,7 @@ The parser namespace is @code{foo} and @code{yylex} is
referenced as
@c api.namespace
@c ================================================== api.location.type
address@hidden {Directive} {%define api.location.type} @var{type}
address@hidden {Directive} {%define api.location.type} @address@hidden@}
@itemize @bullet
@item Language(s): C++, Java
@@ -5772,7 +5773,7 @@ Introduced in Bison 2.7 for C, C++ and Java. Introduced
under the name
@end deffn
@c ================================================== api.prefix
address@hidden {Directive} {%define api.prefix} @var{prefix}
address@hidden {Directive} {%define api.prefix} @address@hidden@}
@itemize @bullet
@item Language(s): All
@@ -5789,7 +5790,7 @@ Introduced in Bison 2.7 for C, C++ and Java. Introduced
under the name
@end deffn
@c ================================================== api.pure
address@hidden Directive {%define api.pure}
address@hidden Directive {%define api.pure} @var{purity}
@itemize @bullet
@item Language(s): C
diff --git a/src/parse-gram.y b/src/parse-gram.y
index ebcd31b..355e148 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -82,7 +82,7 @@ static char const *char_name (char);
#define YYTYPE_UINT8 uint_fast8_t
}
-%define api.prefix "gram_"
+%define api.prefix {gram_}
%define api.pure full
%define locations
%define parse.error verbose
diff --git a/tests/calc.at b/tests/calc.at
index 00741f8..3207e69 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -677,7 +677,7 @@ m4_define([AT_CHECK_CALC_LALR1_CC],
AT_CHECK_CALC_LALR1_CC([])
AT_CHECK_CALC_LALR1_CC([%locations])
-AT_CHECK_CALC_LALR1_CC([%locations %define api.location.type Span])
+AT_CHECK_CALC_LALR1_CC([%locations %define api.location.type {Span}])
AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose
%name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %define
api.prefix "calc" %verbose %yacc])
@@ -711,7 +711,7 @@ m4_define([AT_CHECK_CALC_GLR_CC],
AT_CHECK_CALC_GLR_CC([])
AT_CHECK_CALC_GLR_CC([%locations])
-AT_CHECK_CALC_GLR_CC([%locations %define api.location.type Span])
+AT_CHECK_CALC_GLR_CC([%locations %define api.location.type {Span}])
AT_CHECK_CALC_GLR_CC([%defines %define parse.error verbose %name-prefix "calc"
%verbose %yacc])
AT_CHECK_CALC_GLR_CC([%define parse.error verbose %define api.prefix "calc"
%verbose %yacc])
diff --git a/tests/input.at b/tests/input.at
index a1bd03a..7d4f073 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -1442,17 +1442,21 @@ AT_SETUP([["%define" code variables]])
m4_pushdef([AT_TEST],
[AT_DATA([input.yy],
-[[%skeleton "lalr1.cc"
-%define api.namespace ]$1[quux]$2[
-%define api.token.prefix ]$1[quux]$2[
+[[%skeleton "lalr1.cc" %locations
+%define api.location.type ]$1[quux]$2[
+%define api.namespace ]$1[quux]$2[
+%define api.prefix ]$1[quux]$2[
+%define api.token.prefix ]$1[quux]$2[
%token TOK // Otherwise api.token.prefix is unused.
%%
start: TOK;
]])
AT_BISON_CHECK([[input.yy]], [0], [],
-[[input.yy:3.9-24: warning: %define variable 'api.token.prefix' requires
'{...}' values [-Wdeprecated]
-input.yy:2.9-21: warning: %define variable 'api.namespace' requires '{...}'
values [-Wdeprecated]
+[[input.yy:4.9-18: warning: %define variable 'api.prefix' requires '{...}'
values [-Wdeprecated]
+input.yy:5.9-24: warning: %define variable 'api.token.prefix' requires '{...}'
values [-Wdeprecated]
+input.yy:2.9-25: warning: %define variable 'api.location.type' requires
'{...}' values [-Wdeprecated]
+input.yy:3.9-21: warning: %define variable 'api.namespace' requires '{...}'
values [-Wdeprecated]
]])
])
--
1.8.2.1
- [PATCH 0/9] {master} check more (all?) variables requiring code value, Akim Demaille, 2013/04/18
- [PATCH 3/9] style: use %code for local function declarations in our parser, Akim Demaille, 2013/04/18
- [PATCH 7/9] parser: do not convert $ and @ in code values of %define variables, Akim Demaille, 2013/04/18
- [PATCH 4/9] style: avoid %{...%} in our parser, Akim Demaille, 2013/04/18
- [PATCH 1/9] muscle: check the kind of api.prefix, api.location.type,
Akim Demaille <=
- [PATCH 6/9] parser: no longer use the "braceless" non-terminal, Akim Demaille, 2013/04/18
- [PATCH 2/9] regen, Akim Demaille, 2013/04/18
- [PATCH 9/9] muscle: check more cases of %define variables with code values, Akim Demaille, 2013/04/18
- [PATCH 8/9] regen, Akim Demaille, 2013/04/18
- [PATCH 5/9] regen, Akim Demaille, 2013/04/18
- Re: [PATCH 0/9] {master} check more (all?) variables requiring code value, Akim Demaille, 2013/04/22