[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/4] java: lac: check it
From: |
Akim Demaille |
Subject: |
[PATCH 4/4] java: lac: check it |
Date: |
Sun, 1 Nov 2020 19:33:24 +0100 |
* tests/calc.at: Add tests for LAC in pull and push parsers.
Skip LAC: line from the logs.
* tests/local.at (reportSyntaxError): Output the error message in a
single call, to avoid having the error message on stderr be
interrupted by the debug traces of LAC in getExpectedTokens.
---
tests/calc.at | 28 ++++++++++++++++++----------
tests/local.at | 15 ++++++++-------
2 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/tests/calc.at b/tests/calc.at
index a96fc98a..a8b9ed67 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -953,7 +953,7 @@ AT_JAVA_IF(
[AT_PARSER_CHECK([calc $1 input], 0, [m4_ifvaln(m4_quote($3), [$3])],
[stderr])])
AT_LANG_MATCH([c\|c++\|java],
[AT_GLR_IF([],
- [AT_CHECK([grep -c -v 'Return for a new token:' stderr],
+ [AT_CHECK([grep -c -v -E 'Return for a new token:|LAC:' stderr],
[ignore],
[m4_n([AT_DEBUG_IF([$4], [0])])])])])
])
@@ -993,21 +993,24 @@ m4_define([_AT_CHECK_CALC_ERROR],
# Normalize the observed and expected error messages, depending upon the
# options.
# 1. Remove the traces from observed.
-sed '/^Starting/d
+sed '
+/ \$[[0-9$]]* = /d
+/^Cleanup:/d
+/^Discarding/d
/^Entering/d
-/^Stack/d
+/^Error:/d
+/^LAC:/d
+/^Next/d
+/^Now/d
/^Reading/d
/^Reducing/d
/^Return/d
/^Shifting/d
+/^Stack/d
+/^Starting/d
/^state/d
-/^Cleanup:/d
-/^Error:/d
-/^Next/d
-/^Now/d
-/^Discarding/d
-/ \$[[0-9$]]* = /d
-/^yydestructor:/d' stderr >at-stderr
+/^yydestructor:/d
+' stderr >at-stderr
mv at-stderr stderr
# 2. Create the reference error message.
@@ -1392,6 +1395,7 @@ AT_CHECK_CALC_LALR1_CC([%no-lines %header %locations
%define api.location.file "
AT_CHECK_CALC_LALR1_CC([%locations %define parse.lac full %define parse.error
verbose])
AT_CHECK_CALC_LALR1_CC([%locations %define parse.lac full %define parse.error
detailed])
+AT_CHECK_CALC_LALR1_CC([%locations %define parse.lac full %define parse.error
detailed %define parse.trace])
AT_CHECK_CALC_LALR1_CC([%define parse.error custom])
AT_CHECK_CALC_LALR1_CC([%define parse.error custom %locations %define
api.prefix {calc} %parse-param {semantic_value *result}{int *count}{int
*nerrs}])
@@ -1481,6 +1485,10 @@ AT_CHECK_CALC_LALR1_JAVA([%define api.push-pull both
%define parse.error detaile
AT_CHECK_CALC_LALR1_JAVA([%define parse.trace %define parse.error custom
%locations %lex-param {InputStream is} %define api.push-pull both])
AT_CHECK_CALC_LALR1_JAVA([%define parse.trace %define parse.error verbose
%locations %lex-param {InputStream is} %define api.push-pull both])
+# parse.lac.
+AT_CHECK_CALC_LALR1_JAVA([%define parse.trace %define parse.error custom
%locations %define parse.lac full])
+AT_CHECK_CALC_LALR1_JAVA([%define parse.trace %define parse.error custom
%locations %define api.push-pull both %define parse.lac full])
+
m4_popdef([AT_CALC_MAIN])
m4_popdef([AT_CALC_YYLEX])
diff --git a/tests/local.at b/tests/local.at
index b18bdf3b..d9b11f9a 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -1007,24 +1007,25 @@ m4_define([AT_YYERROR_DEFINE(java)],
]AT_ERROR_CUSTOM_IF([[
public void reportSyntaxError(Calc.Context ctx) {
- System.err.print(]AT_LOCATION_IF([[ctx.getLocation() + ": "
- + ]])["syntax error");
+ // Buffer and print the message at the end, to avoid being intertwined
+ // with debug traces from getExpectedTokens.
+ String msg = ]AT_LOCATION_IF([[ctx.getLocation() + ": " + ]])["syntax
error";
{
Calc.SymbolKind token = ctx.getToken();
if (token != null)
- System.err.print(" on token @<:@" + token.getName() + "@:>@");
+ msg += " on token @<:@" + token.getName() + "@:>@";
}
{
Calc.SymbolKind[] arg = new Calc.SymbolKind[ctx.NTOKENS];
int n = ctx.getExpectedTokens(arg, ctx.NTOKENS);
if (0 < n) {
- System.err.print(" (expected:");
+ msg += " (expected:";
for (int i = 0; i < n; ++i)
- System.err.print(" @<:@" + arg[i].getName() + "@:>@");
- System.err.print(")");
+ msg += " @<:@" + arg[i].getName() + "@:>@";
+ msg += ")";
}
}
- System.err.println("");
+ System.err.println(msg);
}
]])
])
--
2.28.0
[PATCH 4/4] java: lac: check it,
Akim Demaille <=