summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2019-04-01 18:23:20 +0200
committerAkim Demaille <akim.demaille@gmail.com>2019-04-03 19:20:39 +0200
commit0f193d2d210e9b8581b487aada3d6c1a1c074931 (patch)
tree9910cadff396c797272852fb1ff72bdc0ea0a2d3 /tests
parent9832fdd6efe566441690306f184daaf3e856d8ff (diff)
downloadbison-0f193d2d210e9b8581b487aada3d6c1a1c074931.tar.gz
no-lines: avoid leaving an empty line instead of the syncline
Currently, with --no-lines, instead of "#line file line\n", we emit "\n". Let's emit nothing. * data/skeletons/bison.m4 (b4_syncline): Emit at end-of-line when enabled. * data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/glr.cc, * data/skeletons/lalr1.cc, src/output.c: Use dnl after b4_syncline to avoid spurious empty lines. * tests/synclines.at (Sync Lines): Make sure that --no-lines is like grep -v #line. * tests/calc.at: Make sure that a rich grammar file behaves properly with %no-lines.
Diffstat (limited to 'tests')
-rw-r--r--tests/calc.at6
-rw-r--r--tests/synclines.at31
2 files changed, 34 insertions, 3 deletions
diff --git a/tests/calc.at b/tests/calc.at
index b2584576..99f1160c 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -714,6 +714,7 @@ AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %define par
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([%no-lines %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}])
# ----------------------- #
# Simple GLR Calculator. #
@@ -753,6 +754,8 @@ AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %location
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([%no-lines %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}])
+
# ----------------------------- #
# Simple LALR1 C++ Calculator. #
@@ -790,6 +793,8 @@ AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %debug %
AT_CHECK_CALC_LALR1_CC([%defines %locations %define api.location.file none])
AT_CHECK_CALC_LALR1_CC([%defines %locations %define api.location.file "my-location.hh"])
+AT_CHECK_CALC_LALR1_CC([%no-lines %defines %locations %define api.location.file "my-location.hh"])
+
# --------------------------- #
# Simple GLR C++ Calculator. #
@@ -821,6 +826,7 @@ AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %de
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([%no-lines %locations %defines %define parse.error verbose %debug %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
# --------------------------- #
diff --git a/tests/synclines.at b/tests/synclines.at
index 857a6ca5..2a8a5fd8 100644
--- a/tests/synclines.at
+++ b/tests/synclines.at
@@ -28,7 +28,7 @@ AT_BANNER([[Sync Lines.]])
m4_define([_AT_SYNCLINES_COMPILE],
[AT_CHECK([$CC $CFLAGS $CPPFLAGS -c $1], [ignore], [], [stderr])
-# Transform stderr into something like this:
+# Transform the file 'stderr' into something like this:
#
# input.y:4: #error "4"
#
@@ -121,7 +121,7 @@ EOF
# AT_SYNCLINES_COMPILE(FILE)
# --------------------------
-# Compile FILE expecting an error, and save in the file stdout the
+# Compile FILE expecting an error, and save in the file 'stdout' the
# normalized output. If we can't get a trustable location
# from the compiler, just skip the test.
#
@@ -449,11 +449,36 @@ AT_DATA_GRAMMAR([input.y],
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
%}
+%union {
+ int ival;
+}
%%
exp: '0'
]])
+
+# Generate without.* without the #line. Don't use -o without.c which
+# would change the content (e.g., CPP guard depend on the output file
+# name).
AT_BISON_CHECK([--no-lines -o input.AT_LANG_EXT -d input.y])
-AT_CHECK([[grep '#line'] *.AT_LANG_EXT *.AT_LANG_HDR], 1)
+AT_CHECK([mv input.]AT_LANG_EXT[ without.]AT_LANG_EXT[])
+AT_CHECK([mv input.]AT_LANG_HDR[ without.]AT_LANG_HDR[])
+# There is no #line at all.
+AT_CHECK([grep '#line' *.]AT_LANG_EXT[ *.]AT_LANG_HDR[], 1)
+
+# Generate with.* without the #line.
+AT_BISON_CHECK([-o input.AT_LANG_EXT -d input.y])
+AT_CHECK([mv input.]AT_LANG_EXT[ with.]AT_LANG_EXT[])
+AT_CHECK([mv input.]AT_LANG_HDR[ with.]AT_LANG_HDR[])
+
+# The implementation file with --no-line is exactly the
+# original one with #lines removed.
+AT_CHECK([grep -v '#line' with.]AT_LANG_EXT[ >expout])
+AT_CHECK([cat without.AT_LANG_EXT], 0, [expout])
+
+# Likewise for the header.
+AT_CHECK([grep -v '#line' with.]AT_LANG_HDR[ >expout])
+AT_CHECK([cat without.AT_LANG_HDR], 0, [expout])
+
AT_BISON_OPTION_POPDEFS
AT_CLEANUP