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:
Akim Demaille
2020-11-01 17:36:21 +01:00
parent c223baee63
commit 1995d9e2f2
2 changed files with 26 additions and 17 deletions

View File

@@ -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])