[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/6] java: prefer errors to fatal errors
From: |
Akim Demaille |
Subject: |
[PATCH 2/6] java: prefer errors to fatal errors |
Date: |
Wed, 3 Apr 2019 19:17:04 +0200 |
Fatal errors are inconvenient, and should be reserved to cases where
we cannot continue. Here, it could even be warnings actually: these
directives will simply be ignored.
* data/skeletons/lalr1.java: Prefer error (b4_complain) to fatal
errors (b4_fatal).
* tests/java.at (Java invalid directives): New.
---
data/skeletons/lalr1.java | 4 ++--
tests/java.at | 22 ++++++++++++++++++++++
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/data/skeletons/lalr1.java b/data/skeletons/lalr1.java
index 1b9e11d8..0356d46d 100644
--- a/data/skeletons/lalr1.java
+++ b/data/skeletons/lalr1.java
@@ -17,7 +17,7 @@
m4_include(b4_skeletonsdir/[java.m4])
-b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java],
+b4_defines_if([b4_complain([%s: %%defines does not make sense in Java],
[b4_skeleton])])
# We do not depend on %debug in Java, but pacify warnings about
@@ -26,7 +26,7 @@ b4_parse_trace_if([0], [0])
m4_define([b4_symbol_no_destructor_assert],
[b4_symbol_if([$1], [has_destructor],
- [b4_fatal([%s: %s: %%destructor does not make sense in Java],
+ [b4_complain([%s: %s: %%destructor does not make sense in Java],
[b4_skeleton],
[b4_symbol_action_location([$1], [destructor])])])])
b4_symbol_foreach([b4_symbol_no_destructor_assert])
diff --git a/tests/java.at b/tests/java.at
index 50b72968..e732f1d3 100644
--- a/tests/java.at
+++ b/tests/java.at
@@ -18,6 +18,28 @@
AT_BANNER([[Java Calculator.]])
+# ------------------------- #
+# Java invalid directives. #
+# ------------------------- #
+
+AT_SETUP([Java invalid directives])
+
+AT_DATA([[YYParser.y]], [
+%language "Java"
+%defines
+%destructor { /* Nothing. */ } exp
+%%
+exp:
+])
+
+AT_BISON_CHECK([[-fcaret YYParser.y]], [1], [],
+[[YYParser.y: error: "lalr1.java": %defines does not make sense in Java
+YYParser.y: error: "lalr1.java": "YYParser.y":/* :4 */: %destructor does not
make sense in Java
+]])
+
+AT_CLEANUP
+
+
# ------------------------- #
# Helping Autotest macros. #
# ------------------------- #
--
2.21.0