bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: %define: accept unquoted values


From: Joel E. Denny
Subject: Re: %define: accept unquoted values
Date: Fri, 28 Aug 2009 08:28:51 -0400 (EDT)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)

On Fri, 28 Aug 2009, Akim Demaille wrote:

> Le 28 août 09 à 10:27, Joel E. Denny a écrit :

> > There are two changes: (1) lr.type values are renamed so that they're
> > spelled like lowercase IDs (which also look better with -D on the command
> > line), and (2) quotation marks on all %define values are optional when the
> > values are spelled like IDs.  I'm not sure why I didn't do this
> > originally.
> > 
> > The following two patches implement this.  Any objections?
> 
> I think this is a lot better.

Thanks.

> The ratio of actual code change wrt tests/doc/generated changes is most
> impressive.  I think you win, I cannot beat you at that game :)

Victory at last.  :-)

The funny thing is that I just realized I forgot to extend the test suite 
for the second patch, so I folded the diff below into it.  I like for the 
test suite to mostly reflect the best usage, so the change is large.

I pushed those to master and similar patches to branch-2.5.

diff --git a/ChangeLog b/ChangeLog
index 0ce4e81..de9bf48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,14 @@
        (Decl Summary): Update %define documentation.
        (Table of Symbols): Likewise.
        * src/parse-gram.y (content.opt): Add production for ID.
+       * tests/actions.at: Remove quotes in most tests.
+       * tests/calc.at: Likewise.
+       * tests/existing.at: Likewise.
+       * tests/input.at: Likewise.
+       * tests/local.at: Likewise.
+       * tests/push.at: Likewise.
+       * tests/reduce.at: Likewise.
+       * tests/torture.at: Likewise.
 
 2009-08-28  Joel E. Denny  <address@hidden>
 
diff --git a/src/ielr.c b/src/ielr.c
index dfe981a..e47c020 100644
--- a/src/ielr.c
+++ b/src/ielr.c
@@ -35,7 +35,7 @@
 #include "state.h"
 #include "symtab.h"
 
-/** Records the value of the \%define variable "lr.type".  */
+/** Records the value of the \%define variable lr.type.  */
 typedef enum { LR_TYPE__LALR, LR_TYPE__IELR, LR_TYPE__CANONICAL_LR } LrType;
 
 /**
diff --git a/tests/actions.at b/tests/actions.at
index be52791..d317920 100644
--- a/tests/actions.at
+++ b/tests/actions.at
@@ -29,7 +29,7 @@ AT_SETUP([Mid-rule actions])
 # action.
 
 AT_DATA_GRAMMAR([[input.y]],
-[[%define parse.error "verbose"
+[[%define parse.error verbose
 %debug
 %{
 # include <stdio.h>
@@ -93,7 +93,7 @@ AT_CLEANUP
 AT_SETUP([Exotic Dollars])
 
 AT_DATA_GRAMMAR([[input.y]],
-[[%define parse.error "verbose"
+[[%define parse.error verbose
 %debug
 %{
 # include <stdio.h>
@@ -557,7 +557,7 @@ m4_define([AT_CHECK_PRINTER_AND_DESTRUCTOR],
 
 $3
 _AT_CHECK_PRINTER_AND_DESTRUCTOR($[1], $[2], $[3], $[4],
-[%define parse.error "verbose"
+[%define parse.error verbose
 %debug
 %verbose
 %locations
@@ -588,7 +588,7 @@ AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-parser], [with union])
 AT_SETUP([Default tagless %printer and %destructor])
 
 AT_DATA_GRAMMAR([[input.y]],
-[[%define parse.error "verbose"
+[[%define parse.error verbose
 %debug
 %locations
 %initial-action {
@@ -706,7 +706,7 @@ AT_CLEANUP
 AT_SETUP([Default tagged and per-type %printer and %destructor])
 
 AT_DATA_GRAMMAR([[input.y]],
-[[%define parse.error "verbose"
+[[%define parse.error verbose
 %debug
 
 %{
@@ -850,7 +850,7 @@ 
m4_define([_AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN],
   [m4_pushdef([kind], [*]) m4_pushdef([not_kind], [])])
 
 AT_DATA_GRAMMAR([[input]]$1[[.y]],
-[[%define parse.error "verbose"
+[[%define parse.error verbose
 %debug
 %locations
 %initial-action {
diff --git a/tests/calc.at b/tests/calc.at
index 9eee68d..52051ef 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -401,7 +401,7 @@ AT_PARSER_CHECK([./calc input], 0, [], [stderr])
 # If BISON-OPTIONS contains `%location', then make sure the ERROR-LOCATION
 # is correctly output on stderr.
 #
-# If BISON-OPTIONS contains `%define parse.error "verbose"', then make sure the
+# If BISON-OPTIONS contains `%define parse.error verbose', then make sure the
 # IF-YYERROR-VERBOSE message is properly output after `syntax error, '
 # on STDERR.
 #
@@ -443,7 +443,7 @@ AT_YYERROR_SEES_LOC_IF([],
 [[sed 's/^[-0-9.]*: //' expout >at-expout
 mv at-expout expout]])
 # 4. If error-verbose is not used, strip the`, unexpected....' part.
-m4_bmatch([$1], [%define parse.error "verbose"], [],
+m4_bmatch([$1], [%define parse.error verbose], [],
 [[sed 's/syntax error, .*$/syntax error/' expout >at-expout
 mv at-expout expout]])
 # 5. Check
@@ -572,22 +572,22 @@ AT_CHECK_CALC_LALR([%locations])
 AT_CHECK_CALC_LALR([%name-prefix="calc"]) dnl test deprecated `='
 AT_CHECK_CALC_LALR([%verbose])
 AT_CHECK_CALC_LALR([%yacc])
-AT_CHECK_CALC_LALR([%define parse.error "verbose"])
+AT_CHECK_CALC_LALR([%define parse.error verbose])
 
 AT_CHECK_CALC_LALR([%define api.pure %locations])
-AT_CHECK_CALC_LALR([%define api.push-pull "both" %define api.pure %locations])
-AT_CHECK_CALC_LALR([%define parse.error "verbose" %locations])
+AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %locations])
+AT_CHECK_CALC_LALR([%define parse.error verbose %locations])
 
-AT_CHECK_CALC_LALR([%define parse.error "verbose" %locations %defines 
%name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR([%define parse.error "verbose" %locations %defines 
%name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define parse.error verbose %locations %defines 
%name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define parse.error verbose %locations %defines 
%name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
 
 AT_CHECK_CALC_LALR([%debug])
-AT_CHECK_CALC_LALR([%define parse.error "verbose" %debug %locations %defines 
%name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define parse.error verbose %debug %locations %defines 
%name-prefix "calc" %verbose %yacc])
 
-AT_CHECK_CALC_LALR([%define api.pure %define parse.error "verbose" %debug 
%locations %defines %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR([%define api.push-pull "both" %define api.pure %define 
parse.error "verbose" %debug %locations %defines %name-prefix "calc" %verbose 
%yacc])
+AT_CHECK_CALC_LALR([%define api.pure %define parse.error verbose %debug 
%locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %define 
parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose 
%yacc])
 
-AT_CHECK_CALC_LALR([%define api.pure %define parse.error "verbose" %debug 
%locations %defines %name-prefix "calc" %verbose %yacc %parse-param 
{semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_LALR([%define api.pure %define parse.error verbose %debug 
%locations %defines %name-prefix "calc" %verbose %yacc %parse-param 
{semantic_value *result} %parse-param {int *count}])
 
 
 # ----------------------- #
@@ -611,20 +611,20 @@ AT_CHECK_CALC_GLR([%locations])
 AT_CHECK_CALC_GLR([%name-prefix "calc"])
 AT_CHECK_CALC_GLR([%verbose])
 AT_CHECK_CALC_GLR([%yacc])
-AT_CHECK_CALC_GLR([%define parse.error "verbose"])
+AT_CHECK_CALC_GLR([%define parse.error verbose])
 
 AT_CHECK_CALC_GLR([%define api.pure %locations])
-AT_CHECK_CALC_GLR([%define parse.error "verbose" %locations])
+AT_CHECK_CALC_GLR([%define parse.error verbose %locations])
 
-AT_CHECK_CALC_GLR([%define parse.error "verbose" %locations %defines 
%name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR([%define parse.error verbose %locations %defines 
%name-prefix "calc" %verbose %yacc])
 
 AT_CHECK_CALC_GLR([%debug])
-AT_CHECK_CALC_GLR([%define parse.error "verbose" %debug %locations %defines 
%name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_GLR([%define parse.error "verbose" %debug %locations %defines 
%name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
+AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines 
%name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines 
%name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
 
-AT_CHECK_CALC_GLR([%define api.pure %define parse.error "verbose" %debug 
%locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug 
%locations %defines %name-prefix "calc" %verbose %yacc])
 
-AT_CHECK_CALC_GLR([%define api.pure %define parse.error "verbose" %debug 
%locations %defines %name-prefix "calc" %verbose %yacc %parse-param 
{semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug 
%locations %defines %name-prefix "calc" %verbose %yacc %parse-param 
{semantic_value *result} %parse-param {int *count}])
 
 
 # ----------------------------- #
@@ -645,14 +645,14 @@ 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 parse.error "verbose" %name-prefix 
"calc" %verbose %yacc])
+AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %name-prefix 
"calc" %verbose %yacc])
 
-AT_CHECK_CALC_LALR1_CC([%locations %define parse.error "verbose" %debug 
%name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug 
%name-prefix "calc" %verbose %yacc])
 
-AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error "verbose" 
%debug %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error "verbose" 
%debug %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
+AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose 
%debug %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose 
%debug %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
 
-AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error "verbose" 
%debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} 
%parse-param {int *count}])
+AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose 
%debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} 
%parse-param {int *count}])
 
 
 
@@ -673,12 +673,12 @@ m4_define([AT_CHECK_CALC_GLR_CC],
 [AT_CHECK_CALC([%language "C++" %glr-parser %defines %locations] $@)])
 
 AT_CHECK_CALC_GLR_CC([])
-AT_CHECK_CALC_GLR_CC([%define parse.error "verbose" %name-prefix "calc" 
%verbose %yacc])
+AT_CHECK_CALC_GLR_CC([%define parse.error verbose %name-prefix "calc" %verbose 
%yacc])
 
 AT_CHECK_CALC_GLR_CC([%debug])
-AT_CHECK_CALC_GLR_CC([%define parse.error "verbose" %debug %name-prefix "calc" 
%verbose %yacc])
+AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" 
%verbose %yacc])
 
-AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error "verbose" %debug 
%name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error "verbose" %debug 
%name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
+AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error verbose %debug 
%name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error verbose %debug 
%name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
 
-AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error "verbose" %debug 
%name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} 
%parse-param {int *count}])
+AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error verbose %debug 
%name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} 
%parse-param {int *count}])
diff --git a/tests/existing.at b/tests/existing.at
index 5a89732..ba06626 100644
--- a/tests/existing.at
+++ b/tests/existing.at
@@ -42,18 +42,18 @@ AT_CHECK([[diff -u input-lalr.output input.output \
          [[0]], [$1])])
 
 AT_TEST_TABLES_AND_PARSE([$2[: LALR(1)]], [[LALR]], [[last-state]],
-                         [[%define lr.type "lalr"
+                         [[%define lr.type lalr
 ]$3],
                          [$4], [$5], [$6], [$7],
                          [AT_LALR1_DIFF_CHECK([$8])$9], [$10], [$11], [$12])
 AT_TEST_TABLES_AND_PARSE([$2[: IELR(1)]], [[IELR]], [[last-state]],
-                         [[%define lr.type "ielr"
+                         [[%define lr.type ielr
 ]$3],
                          [$4], [$5], [$6], [$7],
                          [AT_LALR1_DIFF_CHECK([$8])$9], [$10], [$11], [$12])
 AT_TEST_TABLES_AND_PARSE([$2[: Canonical LR(1)]], [[canonical LR]],
                          [[last-state,no-xml]],
-                         [[%define lr.type "canonical-lr"
+                         [[%define lr.type canonical-lr
 ]$3],
                          [$4], [$5], [$6], [$7],
                          [$9], [$10], [$11], [$12])
diff --git a/tests/input.at b/tests/input.at
index 3d82159..3f08a1b 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -999,7 +999,7 @@ AT_SETUP([[%define enum variables]])
 
 # Front-end.
 AT_DATA([[input.y]],
-[[%define lr.default-reductions "bogus"
+[[%define lr.default-reductions bogus
 %%
 start: ;
 ]])
@@ -1012,7 +1012,7 @@ input.y:1.9-29: accepted value: `accepting'
 
 # Back-end.
 AT_DATA([[input.y]],
-[[%define api.push-pull "neither"
+[[%define api.push-pull neither
 %%
 start: ;
 ]])
@@ -1047,7 +1047,7 @@ input.y:1.9-21: accepted value: `both'
 ]])
 
 AT_DATA([[input.y]],
-[[%define lr.keep_unreachable_states "maybe"
+[[%define lr.keep_unreachable_states maybe
 %%
 start: ;
 ]])
@@ -1102,11 +1102,11 @@ AT_BISON_CHECK([[input.y]], [0], [],
 ])
 
 AT_CHECK_API_PURE([[%language "c++" %defines]], [[]])
-AT_CHECK_API_PURE([[%language "c++" %defines]], [["false"]])
+AT_CHECK_API_PURE([[%language "c++" %defines]], [[false]])
 AT_CHECK_API_PURE([[%language "c++" %defines %glr-parser]], [[""]])
-AT_CHECK_API_PURE([[%language "c++" %defines %glr-parser]], [["false"]])
-AT_CHECK_API_PURE([[%language "java"]], [["true"]])
-AT_CHECK_API_PURE([[%language "java"]], [["false"]])
+AT_CHECK_API_PURE([[%language "c++" %defines %glr-parser]], [[false]])
+AT_CHECK_API_PURE([[%language "java"]], [[true]])
+AT_CHECK_API_PURE([[%language "java"]], [[false]])
 
 AT_CLEANUP
 
diff --git a/tests/local.at b/tests/local.at
index b09c517..dc3897b 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -77,7 +77,7 @@ m4_pushdef([AT_LOCATION_IF],
 [m4_bmatch([$3], [%locations], [$1], [$2])])
 m4_pushdef([AT_PURE_IF],
 [m4_bmatch([$3], [%define  *api\.pure\|%pure-parser],
-           [m4_bmatch([$3], [%define  *api\.pure *"false"], [$2], [$1])],
+           [m4_bmatch([$3], [%define  *api\.pure *"?false"?], [$2], [$1])],
            [$2])])
 m4_pushdef([AT_PURE_AND_LOC_IF],
 [m4_bmatch([$3], [%locations], [AT_PURE_IF($@)], [$2])])
diff --git a/tests/push.at b/tests/push.at
index bf48c68..831be0c 100644
--- a/tests/push.at
+++ b/tests/push.at
@@ -33,7 +33,7 @@ AT_DATA_GRAMMAR([[input.y]],
   void yyerror (char const *msg);
 %}
 
-%define api.pure %define api.push-pull "push"
+%define api.pure %define api.push-pull push
 
 %%
 
@@ -93,7 +93,7 @@ AT_DATA_GRAMMAR([[input.y]],
   int yylex (void);
 %}
 
-%define api.push-pull "]$1["
+%define api.push-pull ]$1[
 
 %%
 
@@ -156,7 +156,7 @@ AT_SETUP([[Push Parsing: Unsupported Skeletons]])
 
 AT_DATA([[input.y]],
 [[%glr-parser
-%define api.push-pull "push"
+%define api.push-pull push
 %%
 start: ;
 ]])
diff --git a/tests/reduce.at b/tests/reduce.at
index 45a856a..e1e3367 100644
--- a/tests/reduce.at
+++ b/tests/reduce.at
@@ -375,19 +375,19 @@ m4_define([AT_TEST_LR_TYPE],
 AT_TEST_TABLES_AND_PARSE([[no %define lr.type: ]$1],
                          [[LALR]], [[]],
                          [$2], m4_shiftn(2, $@))
-AT_TEST_TABLES_AND_PARSE([[%define lr.type "lalr": ]$1],
+AT_TEST_TABLES_AND_PARSE([[%define lr.type lalr: ]$1],
                          [[LALR]], [[]],
-                         [[%define lr.type "lalr"
+                         [[%define lr.type lalr
 ]$2],
                          m4_shiftn(2, $@))
-AT_TEST_TABLES_AND_PARSE([[%define lr.type "ielr": ]$1],
+AT_TEST_TABLES_AND_PARSE([[%define lr.type ielr: ]$1],
                          [[IELR]], [[]],
-                         [[%define lr.type "ielr"
+                         [[%define lr.type ielr
 ]$2],
                          m4_shiftn(2, $@))
-AT_TEST_TABLES_AND_PARSE([[%define lr.type "canonical-lr": ]$1],
+AT_TEST_TABLES_AND_PARSE([[%define lr.type canonical-lr: ]$1],
                          [[canonical LR]], [[]],
-                         [[%define lr.type "canonical-lr"
+                         [[%define lr.type canonical-lr
 ]$2],
                          m4_shiftn(2, $@))
 ])
@@ -1454,17 +1454,17 @@ AT_TEST_TABLES_AND_PARSE([[no %define 
lr.default-reductions]],
                          [[all]], [[]],
                          [[]],
                          [$1], [$2], [[]], [$3])
-AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions "all"]],
+AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions all]],
                          [[all]], [[]],
-                         [[%define lr.default-reductions "all"]],
+                         [[%define lr.default-reductions all]],
                          [$1], [$2], [[]], [$3])
-AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions "consistent"]],
+AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions consistent]],
                          [[consistent]], [[]],
-                         [[%define lr.default-reductions "consistent"]],
+                         [[%define lr.default-reductions consistent]],
                          [$1], [$2], [[]], [$3])
-AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions "accepting"]],
+AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions accepting]],
                          [[accepting]], [[]],
-                         [[%define lr.default-reductions "accepting"]],
+                         [[%define lr.default-reductions accepting]],
                          [$1], [$2], [[]], [$3])
 ])
 
diff --git a/tests/torture.at b/tests/torture.at
index 91b3b1b..47435cb 100644
--- a/tests/torture.at
+++ b/tests/torture.at
@@ -496,7 +496,7 @@ AT_PARSER_CHECK([./input 10000], 2, [], [ignore],
 # just helps guarantee we don't let the YYSTACK_USE_ALLOCA feature affect
 # push parsers.
 AT_DATA_STACK_TORTURE([AT_USE_ALLOCA],
-[[%define api.push-pull "both"
+[[%define api.push-pull both
 ]])
 AT_PARSER_CHECK([./input 20], 0, [], [ignore],
                 [[VALGRIND_OPTS="$VALGRIND_OPTS --log-fd=1"]])
@@ -534,7 +534,7 @@ AT_PARSER_CHECK([./input 10000], 2, [], [ignore],
                 [[VALGRIND_OPTS="$VALGRIND_OPTS --log-fd=1"]])
 
 AT_DATA_STACK_TORTURE([AT_USE_ALLOCA],
-[[%define api.push-pull "both"
+[[%define api.push-pull both
 ]])
 AT_PARSER_CHECK([./input 20], 0, [], [ignore],
                 [[VALGRIND_OPTS="$VALGRIND_OPTS --log-fd=1"]])

reply via email to

[Prev in Thread] Current Thread [Next in Thread]