java: lac: a stronger test for the exploratory stack

* tests/local.at (AT_YYLEX_DEFINE(java)): Fix overquoting issue.
Style changes.
* tests/regression.at (LAC: Exploratory stack): Run for lalr1.java too.
This commit is contained in:
Akim Demaille
2020-11-06 07:19:47 +01:00
parent fa8aca1ed4
commit d49da0101a
4 changed files with 35 additions and 18 deletions

View File

@@ -440,7 +440,7 @@ AT_DATA_GRAMMAR([input.y],
]$2[
]AT_JAVA_IF([[%code lexer {
]AT_YYLEX_DEFINE([$3], [[return new Integer(1)]])[
]AT_YYLEX_DEFINE(["$3"], [[return new Integer(1)]])[
]AT_YYERROR_DEFINE[
};
%%

View File

@@ -1036,30 +1036,27 @@ m4_define([AT_YYLEX_DEFINE(java)],
| yylex. |
`--------*/
public String input = "]$1[";
public String input = ]$1[;
public int index = 0;
public int yylex ()
{
if (index < input.length ())
return input.charAt (index++);
public int yylex() {
if (index < input.length())
return input.charAt(index++);
else
return 0;
}
public Object getLVal ()
{
]$2[;
public Object getLVal() {
]m4_ifval([$2], [$2], [return null])[;
}
]])
m4_define([AT_MAIN_DEFINE(java)],
[[class input
{
public static void main (String[] args) throws IOException
{
]AT_API_prefix[Parser p = new ]AT_API_prefix[Parser ();
boolean success = p.parse ();
public static void main(String[] args) throws IOException {
]AT_API_prefix[Parser p = new ]AT_API_prefix[Parser();
boolean success = p.parse();
if (!success)
System.exit (1);
System.exit(1);
}
}]])

View File

@@ -1341,11 +1341,21 @@ m4_pushdef([AT_LAC_CHECK], [
AT_BISON_OPTION_PUSHDEFS([%debug $1])
AT_DATA_GRAMMAR([input.y],
[AT_JAVA_IF([[%code imports {
import java.io.IOException;
}
%code lexer {
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["bbbbc"])[
};
]],
[[%code {
#include <stdio.h> /* printf */
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
}
]])[
%debug
]$1[
%define parse.error verbose
@@ -1359,13 +1369,15 @@ S: A B A A B A A A A B A A A A A A A B C C A A A A A A A A A A A A B ;
// ^ ^ ^
// LAC reallocs
A: 'a' | %empty { printf ("inconsistent default reduction\n"); } ;
A: 'a' | %empty { ]AT_JAVA_IF([System.out.print], [printf])[ ("inconsistent default reduction\n"); } ;
B: 'b' ;
C: %empty { printf ("consistent default reduction\n"); } ;
C: %empty { ]AT_JAVA_IF([System.out.print], [printf])[ ("consistent default reduction\n"); } ;
%%
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["bbbbc"])[
]AT_JAVA_IF([], [[
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["bbbbc"])[
]])[
]AT_MAIN_DEFINE[
]])
@@ -1402,13 +1414,18 @@ AT_PERL_CHECK([[-0777 -ne 'print s/\bconsistent default reduction//g;' stdout.tx
AT_BISON_OPTION_POPDEFS
])
# C.
AT_LAC_CHECK([[%define api.push-pull pull]])
AT_LAC_CHECK([[%define api.push-pull pull %define api.pure]])
AT_LAC_CHECK([[%define api.push-pull both]])
AT_LAC_CHECK([[%define api.push-pull both %define api.pure]])
# C++.
AT_LAC_CHECK([[%skeleton "lalr1.cc"]])
# Java.
AT_LAC_CHECK([[%skeleton "lalr1.java"]])
m4_popdef([AT_LAC_CHECK])
AT_CLEANUP