* tests/atlocal.in (CPPFLAGS): We have config.h.

* tests/testsuite.at (AT_DATA_GRAMMAR_PROLOGUE, AT_DATA_GRAMMAR):
New.
* tests/actions.at, tests/calc.at, tests/conflicts.at,
* tests/cxx-type.at, tests/glr-regr1.at, tests/headers.at,
* tests/regression.at, tests/torture.at: Use them for all the
grammars that are to be compiled.
* tests/cxx-type.at (_AT_TEST_GLR_CALC): Rename as...
* tests/cxx-type.at (_AT_TEST_GLR_CXXTYPES): this.
* doc/bison.texinfo (GLR Parsers): Document `inline'.
This commit is contained in:
Akim Demaille
2002-11-14 09:58:01 +00:00
parent 18b519c0d6
commit 9501dc6e69
14 changed files with 155 additions and 85 deletions

View File

@@ -29,7 +29,7 @@ AT_SETUP([Mid-rule actions])
# instead of being attached to the empty rule dedicated to this
# action.
AT_DATA([[input.y]],
AT_DATA_GRAMMAR([[input.y]],
[[%{
# include <stdio.h>
# include <stdlib.h>
@@ -88,7 +88,7 @@ AT_CLEANUP
AT_SETUP([Exotic Dollars])
AT_DATA([[input.y]],
AT_DATA_GRAMMAR([[input.y]],
[[%{
# include <stdio.h>
# include <stdlib.h>
@@ -167,7 +167,7 @@ AT_SETUP([Printers and Destructors: $4])
# Make sure complex $n work.
AT_DATA([[input.y]],
AT_DATA_GRAMMAR([[input.y]],
[[$4
%{
#include <stdio.h>

View File

@@ -9,7 +9,7 @@ CC='@CC@'
CFLAGS='@O0CFLAGS@ @WARNING_CFLAGS@ @WERROR_CFLAGS@'
# We need `config.h'.
CPPFLAGS="-I$abs_top_builddir @CPPFLAGS@"
CPPFLAGS="-DHAVE_CONFIG_H=1 -I$abs_top_builddir @CPPFLAGS@"
# Is the compiler GCC?
GCC='@GCC@'

View File

@@ -35,15 +35,10 @@
m4_define([_AT_DATA_CALC_Y],
[m4_if([$1$2$3], $[1]$[2]$[3], [],
[m4_fatal([$0: Invalid arguments: $@])])dnl
AT_DATA([calc.y],
AT_DATA_GRAMMAR([calc.y],
[[/* Infix notation calculator--calc */
]$4[
%{
#include <config.h>
/* We don't need perfect functions for these tests. */
#undef malloc
#undef memcmp
#undef realloc
#include <stdio.h>
#if STDC_HEADERS

View File

@@ -50,14 +50,9 @@ AT_CLEANUP
AT_SETUP([%nonassoc and eof])
AT_DATA([input.y],
AT_DATA_GRAMMAR([input.y],
[[
%{
#include <config.h>
/* We don't need perfect functions for these tests. */
#undef malloc
#undef memcmp
#undef realloc
#include <stdio.h>
#if STDC_HEADERS

View File

@@ -18,13 +18,13 @@
AT_BANNER([[C++ Type Syntax (GLR).]])
# _AT_TEST_GLR_CALC(DECL, RESOLVE1, RESOLVE2)
# -------------------------------------------
# _AT_TEST_GLR_CXXTYPES(DECL, RESOLVE1, RESOLVE2)
# -----------------------------------------------
# Store into types.y the calc program, with DECL inserted as a declaration,
# and with RESOLVE1 and RESOLVE2 as annotations on the conflicted rule for
# stmt. Then compile the result.
m4_define([_AT_TEST_GLR_CALC],
[AT_DATA([types.y],
m4_define([_AT_TEST_GLR_CXXTYPES],
[AT_DATA_GRAMMAR([types.y],
[[/* Simplified C++ Type and Expression Grammar. */
$1
@@ -253,57 +253,62 @@ m4_define([_AT_VERBOSE_GLR_STDERR],
## ---------------------------------------------------- ##
AT_SETUP([GLR: Resolve ambiguity, impure, no locations])
_AT_TEST_GLR_CALC([],[%dprec 1],[%dprec 2])
_AT_TEST_GLR_CXXTYPES([],
[%dprec 1], [%dprec 2])
AT_PARSER_CHECK([[./types test-input | sed 's/ *$//']], 0,
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Resolve ambiguity, impure, locations])
_AT_TEST_GLR_CALC([%locations],[%dprec 1],[%dprec 2])
_AT_TEST_GLR_CXXTYPES([%locations],[%dprec 1],[%dprec 2])
AT_PARSER_CHECK([[./types test-input | sed 's/ *$//']], 0,
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Resolve ambiguity, pure, no locations])
_AT_TEST_GLR_CALC([%pure-parser],[%dprec 1],[%dprec 2])
_AT_TEST_GLR_CXXTYPES([%pure-parser],
[%dprec 1], [%dprec 2])
AT_PARSER_CHECK([[./types test-input | sed 's/ *$//']], 0,
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Resolve ambiguity, pure, locations])
_AT_TEST_GLR_CALC([%pure-parser
%locations],[%dprec 1],[%dprec 2])
_AT_TEST_GLR_CXXTYPES([%pure-parser %locations],
[%dprec 1], [%dprec 2])
AT_PARSER_CHECK([[./types test-input | sed 's/ *$//']], 0,
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Merge conflicting parses, impure, no locations])
_AT_TEST_GLR_CALC([],[%merge <stmtMerge>],[%merge <stmtMerge>])
_AT_TEST_GLR_CXXTYPES([],
[%merge <stmtMerge>], [%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input | sed 's/ *$//']], 0,
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Merge conflicting parses, impure, locations])
_AT_TEST_GLR_CALC([%locations],[%merge <stmtMerge>],[%merge <stmtMerge>])
_AT_TEST_GLR_CXXTYPES([%locations],
[%merge <stmtMerge>], [%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input | sed 's/ *$//']], 0,
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Merge conflicting parses, pure, no locations])
_AT_TEST_GLR_CALC([%pure-parser],[%merge <stmtMerge>],[%merge <stmtMerge>])
_AT_TEST_GLR_CXXTYPES([%pure-parser],
[%merge <stmtMerge>], [%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input | sed 's/ *$//']], 0,
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Merge conflicting parses, pure, locations])
_AT_TEST_GLR_CALC([%pure-parser
%locations],[%merge <stmtMerge>],[%merge <stmtMerge>])
_AT_TEST_GLR_CXXTYPES([%pure-parser %locations],
[%merge <stmtMerge>],[%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input | sed 's/ *$//']], 0,
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Verbose messages, resolve ambiguity, impure, no locations])
_AT_TEST_GLR_CALC([%error-verbose],
[%merge <stmtMerge>],[%merge <stmtMerge>])
_AT_TEST_GLR_CXXTYPES([%error-verbose],
[%merge <stmtMerge>], [%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input | sed 's/ *$//']], 0,
_AT_AMBIG_GLR_OUTPUT, _AT_VERBOSE_GLR_STDERR)
AT_CLEANUP

View File

@@ -20,7 +20,7 @@ AT_BANNER([[GLR Regression Test #1.]])
AT_SETUP([Badly Collapsed GLR States])
AT_DATA([glr-regr1.y],
AT_DATA_GRAMMAR([glr-regr1.y],
[[/* Regression Test: Improper state compression */
/* Reported by Scott McPeak */

View File

@@ -55,7 +55,7 @@ m4_define([AT_TEST_CPP_GUARD_H],
dirname=`AS_DIRNAME([$1])`
AS_MKDIR_P([$dirname])
AT_DATA([$1.y],
AT_DATA_GRAMMAR([$1.y],
[%%
dummy:;
])
@@ -80,7 +80,7 @@ AT_TEST_CPP_GUARD_H([9foo])
AT_SETUP([export YYLTYPE])
AT_DATA([input.y],
AT_DATA_GRAMMAR([input.y],
[%locations
%name-prefix="my_"

View File

@@ -92,7 +92,7 @@ AT_CLEANUP
AT_SETUP([Torturing the Scanner])
AT_DATA([input.y],
AT_DATA_GRAMMAR([input.y],
[[%{
/* This is seen in GCC: a %{ and %} in middle of a comment. */
const char *foo = "So %{ and %} can be here too.";
@@ -188,6 +188,8 @@ yyerror (const char *msg)
}
]])
# Pacify Emacs'font-lock-mode: "
AT_DATA([main.c],
[[typedef int value_t;
#include "input.h"

View File

@@ -29,7 +29,7 @@ AT_SETUP([Early token definitions])
# Found in GCJ: they expect the tokens to be defined before the user
# prologue, so that they can use the token definitions in it.
AT_DATA([input.y],
AT_DATA_GRAMMAR([input.y],
[[%{
void yyerror (const char *s);
int yylex (void);
@@ -313,7 +313,7 @@ AT_CLEANUP
AT_SETUP([Token definitions])
# Bison managed, when fed with `%token 'f' "f"' to #define 'f'!
AT_DATA([input.y],
AT_DATA_GRAMMAR([input.y],
[%{
void yyerror (const char *s);
int yylex (void);
@@ -340,7 +340,7 @@ AT_CLEANUP
AT_SETUP([Characters Escapes])
AT_DATA([input.y],
AT_DATA_GRAMMAR([input.y],
[%{
void yyerror (const char *s);
int yylex (void);
@@ -352,6 +352,7 @@ exp:
| '"' "'"
;
]])
# Pacify font-lock-mode: "
AT_CHECK([bison -o input.c input.y])
AT_COMPILE([input.o], [-c input.c])

View File

@@ -22,6 +22,34 @@
m4_version_prereq([2.52g])
# AT_DATA_GRAMMAR_PROLOGUE
# ------------------------
# The prologue that should be included in any grammar which parser is
# meant to be compiled.
m4_define([AT_DATA_GRAMMAR_PROLOGUE],
[[%{
#if HAVE_CONFIG_H
# include <config.h>
/* We don't need perfect functions for these tests. */
# undef malloc
# undef memcmp
# undef realloc
#endif
%}]
])
# AT_DATA_GRAMMAR(NAME, CONTENT)
# ------------------------------
# Generate the file NAME, which CONTENT is preceded by
# AT_DATA_GRAMMAR_PROLOGUE.
m4_define([AT_DATA_GRAMMAR],
[AT_DATA([$1],
[AT_DATA_GRAMMAR_PROLOGUE
$2])
])
# AT_COMPILE(OUTPUT, [SOURCES = OUTPUT.c])
# ----------------------------------------
#
@@ -77,7 +105,7 @@ m4_include([existing.at])
# Some old bugs.
m4_include([regression.at])
# GLR tests:
# GLR tests:
# C++ types, simplified
m4_include([cxx-type.at])
# Regression test for state-folding optimization

View File

@@ -48,6 +48,7 @@ use strict;
my $max = $ARGV[0] || 10;
print <<EOF;
]AT_DATA_GRAMMAR_PROLOGUE[
%{
#include <stdio.h>
#include <stdlib.h>
@@ -163,6 +164,7 @@ use strict;
my $max = $ARGV[0] || 10;
print <<EOF;
]AT_DATA_GRAMMAR_PROLOGUE[
%{
#include <stdio.h>
#include <stdlib.h>