mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
muscle: check more cases of %define variables with code values
* data/bison.m4 (b4_percent_define_check_kind): Fix overquotation. (api.location.type, api.position.type): Check they have code values here. * data/c++.m4 (api.location.type): No longer checked here. (parser_class_name): Check it here. * data/java.m4 (api.value.type, init_throws, lex_throws, parser_class_name) (throws, annotations, extends, implements): Check they have code values. * doc/bison.texi: Fix every incorrect occurrence of %define. Document the additional syntax for %define: code values. Document the additional syntax for -D/-F: string and code values. * tests/calc.at, tests/headers.at, tests/input.at, tests/java.at, * tests/local.at: Fix dependencies.
This commit is contained in:
@@ -607,17 +607,17 @@ AT_CHECK_CALC_LALR([%define api.pure full %locations])
|
||||
AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %locations])
|
||||
AT_CHECK_CALC_LALR([%define parse.error verbose %locations])
|
||||
|
||||
AT_CHECK_CALC_LALR([%define parse.error verbose %locations %defines %define api.prefix "calc" %verbose %yacc])
|
||||
AT_CHECK_CALC_LALR([%define parse.error verbose %locations %defines %define api.prefix {calc} %verbose %yacc])
|
||||
AT_CHECK_CALC_LALR([%define parse.error verbose %locations %defines %name-prefix "calc" %define api.token.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 %define api.prefix "calc" %verbose %yacc])
|
||||
AT_CHECK_CALC_LALR([%define parse.error verbose %debug %locations %defines %define api.prefix {calc} %verbose %yacc])
|
||||
|
||||
AT_CHECK_CALC_LALR([%define api.pure full %define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
||||
AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %define parse.error verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc])
|
||||
AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %define parse.error verbose %debug %locations %defines %define api.prefix {calc} %verbose %yacc])
|
||||
|
||||
AT_CHECK_CALC_LALR([%define api.pure %define parse.error verbose %debug %locations %defines %define api.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 %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||
|
||||
|
||||
# ----------------------- #
|
||||
@@ -639,7 +639,7 @@ AT_CHECK_CALC_GLR()
|
||||
AT_CHECK_CALC_GLR([%defines])
|
||||
AT_CHECK_CALC_GLR([%locations])
|
||||
AT_CHECK_CALC_GLR([%name-prefix "calc"])
|
||||
AT_CHECK_CALC_GLR([%define api.prefix "calc"])
|
||||
AT_CHECK_CALC_GLR([%define api.prefix {calc}])
|
||||
AT_CHECK_CALC_GLR([%verbose])
|
||||
AT_CHECK_CALC_GLR([%yacc])
|
||||
AT_CHECK_CALC_GLR([%define parse.error verbose])
|
||||
@@ -651,12 +651,12 @@ AT_CHECK_CALC_GLR([%define parse.error verbose %locations %defines %name-prefix
|
||||
|
||||
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 %define api.prefix "calc" %define api.token.prefix {TOK_} %verbose %yacc])
|
||||
AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines %define api.prefix {calc} %define api.token.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 %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||
AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %defines %define api.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 %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||
|
||||
|
||||
# ----------------------------- #
|
||||
@@ -680,16 +680,16 @@ AT_CHECK_CALC_LALR1_CC([%locations])
|
||||
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])
|
||||
AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %define api.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 %define api.prefix "calc" %verbose %yacc])
|
||||
AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %define api.prefix "calc" %define api.token.prefix {TOK_} %verbose %yacc])
|
||||
AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %define api.prefix {calc} %verbose %yacc])
|
||||
AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %define api.prefix {calc} %define api.token.prefix {TOK_} %verbose %yacc])
|
||||
|
||||
AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||
|
||||
AT_CHECK_CALC_LALR1_CC([%define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||
AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||
AT_CHECK_CALC_LALR1_CC([%define parse.error verbose %debug %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||
AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %debug %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||
|
||||
|
||||
|
||||
@@ -713,7 +713,7 @@ 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([%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])
|
||||
AT_CHECK_CALC_GLR_CC([%define parse.error verbose %define api.prefix {calc} %verbose %yacc])
|
||||
|
||||
AT_CHECK_CALC_GLR_CC([%debug])
|
||||
|
||||
@@ -721,4 +721,4 @@ AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %ve
|
||||
AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %define api.token.prefix {TOK_} %verbose %yacc])
|
||||
|
||||
AT_CHECK_CALC_GLR_CC([%locations %defines %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||
AT_CHECK_CALC_GLR_CC([%locations %defines %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||
AT_CHECK_CALC_GLR_CC([%locations %defines %define parse.error verbose %debug %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||
|
||||
@@ -117,9 +117,9 @@ AT_SETUP([Several parsers])
|
||||
# nor yy* identifiers in the header. Check that headers are
|
||||
# self-contained, and can be compiled by a C++ compiler.
|
||||
m4_pushdef([AT_TEST],
|
||||
[AT_BISON_OPTION_PUSHDEFS([%define api.prefix "$1_" $2])
|
||||
[AT_BISON_OPTION_PUSHDEFS([%define api.prefix {$1_} $2])
|
||||
AT_DATA_GRAMMAR([$1.y],
|
||||
[[%define api.prefix "$1_"
|
||||
[[%define api.prefix {$1_}
|
||||
$2
|
||||
%error-verbose
|
||||
%union
|
||||
|
||||
@@ -1422,8 +1422,8 @@ AT_SETUP([["%define" Boolean variables]])
|
||||
|
||||
AT_DATA([Input.y],
|
||||
[[%language "Java"
|
||||
%define public "maybe"
|
||||
%define parser_class_name "Input"
|
||||
%define public maybe
|
||||
%define parser_class_name {Input}
|
||||
%%
|
||||
start: %empty;
|
||||
]])
|
||||
@@ -1453,9 +1453,9 @@ start: TOK;
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([[input.yy]], [0], [],
|
||||
[[input.yy:4.9-18: warning: %define variable 'api.prefix' requires '{...}' values [-Wdeprecated]
|
||||
[[input.yy:2.9-25: warning: %define variable 'api.location.type' 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]
|
||||
]])
|
||||
])
|
||||
@@ -1857,10 +1857,10 @@ AT_BISON_CHECK([[$2 input.y]], [[1]], [[]],
|
||||
]])
|
||||
])
|
||||
|
||||
AT_TEST([%define api.prefix foo %name-prefix "bar"], [], [input.y:1.9-18])
|
||||
AT_TEST([], [-Dapi.prefix=foo -p bar], [<command line>:2])
|
||||
AT_TEST([%name-prefix "bar"], [-Dapi.prefix=foo], [<command line>:2])
|
||||
AT_TEST([%define api.prefix foo], [-p bar], [input.y:1.9-18])
|
||||
AT_TEST([%define api.prefix {foo} %name-prefix "bar"], [], [input.y:1.9-18])
|
||||
AT_TEST([], [-Dapi.prefix={foo} -p bar], [<command line>:2])
|
||||
AT_TEST([%name-prefix "bar"], [-Dapi.prefix={foo}], [<command line>:2])
|
||||
AT_TEST([%define api.prefix {foo}], [-p bar], [input.y:1.9-18])
|
||||
|
||||
m4_popdef([AT_TEST])
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ AT_DATA([Calc.y],
|
||||
[[/* Infix notation calculator--calc */
|
||||
%language "Java"
|
||||
%name-prefix "Calc"
|
||||
%define parser_class_name "Calc"
|
||||
%define parser_class_name {Calc}
|
||||
%define public
|
||||
|
||||
]$4[
|
||||
@@ -464,10 +464,10 @@ AT_CHECK_JAVA_GREP([[class PrefixParser]])
|
||||
AT_CHECK_JAVA_MINIMAL([[%define api.token.prefix {TOK_}]])
|
||||
AT_CHECK_JAVA_GREP([[.*TOK_END.*]])
|
||||
|
||||
AT_CHECK_JAVA_MINIMAL([[%define parser_class_name "ParserClassName"]])
|
||||
AT_CHECK_JAVA_MINIMAL([[%define parser_class_name {ParserClassName}]])
|
||||
AT_CHECK_JAVA_GREP([[class ParserClassName]])
|
||||
|
||||
AT_CHECK_JAVA_MINIMAL([[%define package "user_java_package"]])
|
||||
AT_CHECK_JAVA_MINIMAL([[%define package {user_java_package}]])
|
||||
AT_CHECK_JAVA_GREP([[package user_java_package;]])
|
||||
|
||||
AT_CLEANUP
|
||||
@@ -530,7 +530,7 @@ AT_CHECK_JAVA_GREP([[public final strictfp class YYParser]])
|
||||
|
||||
# FIXME: Can't do a Java compile because javacomp.sh is configured for 1.3
|
||||
AT_CHECK_JAVA_MINIMAL([[
|
||||
%define annotations "/*@Deprecated @SupressWarnings(\"unchecked\") @SupressWarnings({\"unchecked\", \"deprecation\"}) @SupressWarnings(value={\"unchecked\", \"deprecation\"})*/"
|
||||
%define annotations {/*@Deprecated @SupressWarnings("unchecked") @SupressWarnings({"unchecked", "deprecation"}) @SupressWarnings(value={"unchecked", "deprecation"})*/}
|
||||
%define public]])
|
||||
AT_CHECK_JAVA_GREP([[/\*@Deprecated @SupressWarnings("unchecked") @SupressWarnings({"unchecked", "deprecation"}) @SupressWarnings(value={"unchecked", "deprecation"})\*/ public class YYParser]])
|
||||
|
||||
@@ -543,15 +543,15 @@ AT_CLEANUP
|
||||
|
||||
AT_SETUP([Java parser class extends and implements])
|
||||
|
||||
AT_CHECK_JAVA_MINIMAL([[%define extends "Thread"]])
|
||||
AT_CHECK_JAVA_MINIMAL([[%define extends {Thread}]])
|
||||
AT_CHECK_JAVA_GREP([[class YYParser extends Thread]])
|
||||
|
||||
AT_CHECK_JAVA_MINIMAL([[%define implements "Cloneable"]])
|
||||
AT_CHECK_JAVA_MINIMAL([[%define implements {Cloneable}]])
|
||||
AT_CHECK_JAVA_GREP([[class YYParser implements Cloneable]])
|
||||
|
||||
AT_CHECK_JAVA_MINIMAL([[
|
||||
%define extends "Thread"
|
||||
%define implements "Cloneable"]])
|
||||
%define extends {Thread}
|
||||
%define implements {Cloneable}]])
|
||||
AT_CHECK_JAVA_GREP([[class YYParser extends Thread implements Cloneable]])
|
||||
|
||||
AT_CLEANUP
|
||||
@@ -643,9 +643,9 @@ AT_SETUP([Java throws specifications])
|
||||
|
||||
m4_define([AT_JT_lex_throws_define], [m4_case(AT_JT_lex_throws,
|
||||
-1, [],
|
||||
0, [[%define lex_throws ""]],
|
||||
1, [[%define lex_throws "InterruptedException"]],
|
||||
2, [[%define lex_throws "InterruptedException, IllegalAccessException"]])])
|
||||
0, [[%define lex_throws {}]],
|
||||
1, [[%define lex_throws {InterruptedException}]],
|
||||
2, [[%define lex_throws {InterruptedException, IllegalAccessException}]])])
|
||||
|
||||
m4_define([AT_JT_yylex_throws], [m4_case(AT_JT_lex_throws,
|
||||
-1, [[ throws java.io.IOException]],
|
||||
@@ -662,9 +662,9 @@ m4_define([AT_JT_yylex_action], [m4_case(AT_JT_lex_throws,
|
||||
|
||||
m4_define([AT_JT_throws_define], [m4_case(AT_JT_throws,
|
||||
-1, [],
|
||||
0, [[%define throws ""]],
|
||||
1, [[%define throws "ClassNotFoundException"]],
|
||||
2, [[%define throws "ClassNotFoundException, InstantiationException"]])])
|
||||
0, [[%define throws {}]],
|
||||
1, [[%define throws {ClassNotFoundException}]],
|
||||
2, [[%define throws {ClassNotFoundException, InstantiationException}]])])
|
||||
|
||||
m4_define([AT_JT_yyaction_throws], [m4_case(AT_JT_throws,
|
||||
-1, [],
|
||||
@@ -727,16 +727,16 @@ AT_CLEANUP
|
||||
AT_SETUP([Java constructor init and init_throws])
|
||||
|
||||
AT_CHECK_JAVA_MINIMAL([[
|
||||
%define extends "Thread"
|
||||
%define extends {Thread}
|
||||
%code init { super("Test Thread"); if (true) throw new InterruptedException(); }
|
||||
%define init_throws "InterruptedException"
|
||||
%define init_throws {InterruptedException}
|
||||
%lex-param {int lex_param}]])
|
||||
AT_CHECK([[grep -q 'super("Test Thread"); if (true) throw new InterruptedException();' YYParser.java]])
|
||||
|
||||
AT_CHECK_JAVA_MINIMAL_W_LEXER([[
|
||||
%define extends "Thread"
|
||||
%define extends {Thread}
|
||||
%code init { super("Test Thread"); if (true) throw new InterruptedException(); }
|
||||
%define init_throws "InterruptedException"]], [], [[return EOF;]])
|
||||
%define init_throws {InterruptedException}]], [], [[return EOF;]])
|
||||
AT_CHECK([[grep -q 'super("Test Thread"); if (true) throw new InterruptedException();' YYParser.java]])
|
||||
|
||||
AT_CLEANUP
|
||||
@@ -749,20 +749,20 @@ AT_CLEANUP
|
||||
AT_SETUP([Java value, position, and location types])
|
||||
|
||||
AT_CHECK_JAVA_MINIMAL([[
|
||||
%define api.value.type "java.awt.Color"
|
||||
%define api.value.type {java.awt.Color}
|
||||
%type<java.awt.Color> start;
|
||||
%define api.location.type "MyLoc"
|
||||
%define api.position.type "MyPos"
|
||||
%define api.location.type {MyLoc}
|
||||
%define api.position.type {MyPos}
|
||||
%code { class MyPos {} }]], [[$$ = $<java.awt.Color>1;]], [[MyPos]])
|
||||
AT_CHECK([[grep 'java.awt.Color' YYParser.java]], [0], [ignore])
|
||||
AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep 'Position']], [1], [ignore])
|
||||
AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep 'Location']], [1], [ignore])
|
||||
|
||||
AT_CHECK_JAVA_MINIMAL_W_LEXER([[
|
||||
%define api.value.type "java.awt.Color"
|
||||
%define api.value.type {java.awt.Color}
|
||||
%type<java.awt.Color> start;
|
||||
%define api.location.type "MyLoc"
|
||||
%define api.position.type "MyPos"
|
||||
%define api.location.type {MyLoc}
|
||||
%define api.position.type {MyPos}
|
||||
%code { class MyPos {} }]], [], [[return EOF;]], [],
|
||||
[[$$ = $<java.awt.Color>1;]],
|
||||
[[java.awt.Color]], [[MyPos]], [[MyLoc]])
|
||||
|
||||
@@ -178,13 +178,13 @@ m4_bpatsubst([$3], [%parse-param { *\([^{}]*[^{} ]\) *}],
|
||||
|
||||
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])])
|
||||
# AT_NAME_PREFIX: also consider api.namespace.
|
||||
m4_pushdef([AT_NAME_PREFIX],
|
||||
[m4_bmatch([$3], [\(%define api\.\(namespace\|prefix\)\|%name-prefix\) .*],
|
||||
[m4_bregexp([$3],
|
||||
[\(%define api\.\(namespace\|prefix\)\|%name-prefix\) [\{\"]\([^""]*\)[\"\}]],
|
||||
[\(%define api\.\(namespace\|prefix\)\|%name-prefix\) [\{\"]\([^\"\}]*\)[\"\}]],
|
||||
[\3])],
|
||||
[yy])])
|
||||
m4_pushdef([AT_TOKEN_CTOR_IF],
|
||||
@@ -193,10 +193,10 @@ m4_pushdef([AT_TOKEN_PREFIX],
|
||||
[m4_bmatch([$3], [%define api\.token\.prefix {.*}],
|
||||
[m4_bregexp([$3], [%define api\.token\.prefix {\(.*\)}], [\1])])])
|
||||
m4_pushdef([AT_VARIANT_IF],
|
||||
[m4_bmatch([$3], [%define api\.value\.type "?variant"?], [$1], [$2])])
|
||||
[m4_bmatch([$3], [%define api\.value\.type variant], [$1], [$2])])
|
||||
m4_pushdef([AT_API_prefix],
|
||||
[m4_bmatch([$3], [%define api\.prefix ".*"],
|
||||
[m4_bregexp([$3], [%define api\.prefix "\([^""]*\)"], [\1])],
|
||||
[m4_bmatch([$3], [%define api\.prefix {.*}],
|
||||
[m4_bregexp([$3], [%define api\.prefix {\([^\}]*\)}], [\1])],
|
||||
[yy])])
|
||||
m4_pushdef([AT_API_PREFIX],
|
||||
[m4_toupper(AT_API_prefix)])
|
||||
@@ -207,7 +207,7 @@ m4_pushdef([AT_API_PREFIX],
|
||||
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
|
||||
[AT_LOCATION_IF([AT_PURE_IF([m4_bmatch([$3],
|
||||
m4_quote(m4_join([\|],
|
||||
[%define api\.pure "?full"?],
|
||||
[%define api\.pure full],
|
||||
[%glr-parser],
|
||||
[%parse-param],
|
||||
[%skeleton "?glr.c"?])),
|
||||
|
||||
Reference in New Issue
Block a user