mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 10:13:03 +00:00
java: lac: check it
* 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.
This commit is contained in:
@@ -953,7 +953,7 @@ AT_JAVA_IF(
|
|||||||
[AT_PARSER_CHECK([calc $1 input], 0, [m4_ifvaln(m4_quote($3), [$3])], [stderr])])
|
[AT_PARSER_CHECK([calc $1 input], 0, [m4_ifvaln(m4_quote($3), [$3])], [stderr])])
|
||||||
AT_LANG_MATCH([c\|c++\|java],
|
AT_LANG_MATCH([c\|c++\|java],
|
||||||
[AT_GLR_IF([],
|
[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],
|
[ignore],
|
||||||
[m4_n([AT_DEBUG_IF([$4], [0])])])])])
|
[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
|
# Normalize the observed and expected error messages, depending upon the
|
||||||
# options.
|
# options.
|
||||||
# 1. Remove the traces from observed.
|
# 1. Remove the traces from observed.
|
||||||
sed '/^Starting/d
|
sed '
|
||||||
|
/ \$[[0-9$]]* = /d
|
||||||
|
/^Cleanup:/d
|
||||||
|
/^Discarding/d
|
||||||
/^Entering/d
|
/^Entering/d
|
||||||
/^Stack/d
|
/^Error:/d
|
||||||
|
/^LAC:/d
|
||||||
|
/^Next/d
|
||||||
|
/^Now/d
|
||||||
/^Reading/d
|
/^Reading/d
|
||||||
/^Reducing/d
|
/^Reducing/d
|
||||||
/^Return/d
|
/^Return/d
|
||||||
/^Shifting/d
|
/^Shifting/d
|
||||||
|
/^Stack/d
|
||||||
|
/^Starting/d
|
||||||
/^state/d
|
/^state/d
|
||||||
/^Cleanup:/d
|
/^yydestructor:/d
|
||||||
/^Error:/d
|
' stderr >at-stderr
|
||||||
/^Next/d
|
|
||||||
/^Now/d
|
|
||||||
/^Discarding/d
|
|
||||||
/ \$[[0-9$]]* = /d
|
|
||||||
/^yydestructor:/d' stderr >at-stderr
|
|
||||||
mv at-stderr stderr
|
mv at-stderr stderr
|
||||||
|
|
||||||
# 2. Create the reference error message.
|
# 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 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])
|
||||||
|
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])
|
||||||
AT_CHECK_CALC_LALR1_CC([%define parse.error custom %locations %define api.prefix {calc} %parse-param {semantic_value *result}{int *count}{int *nerrs}])
|
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 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])
|
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_MAIN])
|
||||||
m4_popdef([AT_CALC_YYLEX])
|
m4_popdef([AT_CALC_YYLEX])
|
||||||
|
|||||||
@@ -1007,24 +1007,25 @@ m4_define([AT_YYERROR_DEFINE(java)],
|
|||||||
|
|
||||||
]AT_ERROR_CUSTOM_IF([[
|
]AT_ERROR_CUSTOM_IF([[
|
||||||
public void reportSyntaxError(Calc.Context ctx) {
|
public void reportSyntaxError(Calc.Context ctx) {
|
||||||
System.err.print(]AT_LOCATION_IF([[ctx.getLocation() + ": "
|
// Buffer and print the message at the end, to avoid being intertwined
|
||||||
+ ]])["syntax error");
|
// with debug traces from getExpectedTokens.
|
||||||
|
String msg = ]AT_LOCATION_IF([[ctx.getLocation() + ": " + ]])["syntax error";
|
||||||
{
|
{
|
||||||
Calc.SymbolKind token = ctx.getToken();
|
Calc.SymbolKind token = ctx.getToken();
|
||||||
if (token != null)
|
if (token != null)
|
||||||
System.err.print(" on token @<:@" + token.getName() + "@:>@");
|
msg += " on token @<:@" + token.getName() + "@:>@";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Calc.SymbolKind[] arg = new Calc.SymbolKind[ctx.NTOKENS];
|
Calc.SymbolKind[] arg = new Calc.SymbolKind[ctx.NTOKENS];
|
||||||
int n = ctx.getExpectedTokens(arg, ctx.NTOKENS);
|
int n = ctx.getExpectedTokens(arg, ctx.NTOKENS);
|
||||||
if (0 < n) {
|
if (0 < n) {
|
||||||
System.err.print(" (expected:");
|
msg += " (expected:";
|
||||||
for (int i = 0; i < n; ++i)
|
for (int i = 0; i < n; ++i)
|
||||||
System.err.print(" @<:@" + arg[i].getName() + "@:>@");
|
msg += " @<:@" + arg[i].getName() + "@:>@";
|
||||||
System.err.print(")");
|
msg += ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.err.println("");
|
System.err.println(msg);
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
])
|
])
|
||||||
|
|||||||
Reference in New Issue
Block a user