summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2019-06-15 12:14:33 +0200
committerAkim Demaille <akim.demaille@gmail.com>2019-06-19 19:15:26 +0200
commit66ac4acc6c0ad4be029507f7ab573edab5a356c4 (patch)
treeb2701c7a831826b2667c502ed38390975a16c368 /tests
parentcd0f25df5f9f162639b622d10dff43c1be905214 (diff)
downloadbison-66ac4acc6c0ad4be029507f7ab573edab5a356c4.tar.gz
java: style changes
* data/skeletons/lalr1.java: Use more conventional function names for Java. Prefer < and <= to => and >. Use the same approach for m4 quotation as in the other skeletons. Fix indentation issues. * tests/calc.at, tests/java.at, tests/javapush.at: Fix quotation style. (main): Use 'args', not 'argv', the former seems more conventional and is used elsewhere in Bison. Prefer character literals to integers to denote characters. * examples/java/Calc.y: Likewise.
Diffstat (limited to 'tests')
-rw-r--r--tests/calc.at2
-rw-r--r--tests/java.at21
-rw-r--r--tests/javapush.at65
3 files changed, 44 insertions, 44 deletions
diff --git a/tests/calc.at b/tests/calc.at
index ba33592a..0036c10e 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -598,7 +598,7 @@ AT_DATA_CALC_Y([$1])
AT_FULL_COMPILE([calc], AT_DEFINES_IF([[lex], [main]], [[], []]), [$2], [-Wno-deprecated])
AT_CHECK_SPACES([calc.AT_LANG_EXT AT_DEFINES_IF([calc.AT_LANG_HDR])])
-# Test the priorities.
+# Test the precedences.
_AT_CHECK_CALC([$1],
[1 + 2 * 3 = 7
1 + 2 * -3 = -5
diff --git a/tests/java.at b/tests/java.at
index 29797154..0c66c817 100644
--- a/tests/java.at
+++ b/tests/java.at
@@ -127,17 +127,17 @@ class CalcLexer implements Calc.Lexer {
]])[
StreamTokenizer st;
- public ]AT_LEXPARAM_IF([[YYLexer]], [[CalcLexer]]) (InputStream is)
+ public ]AT_LEXPARAM_IF([[YYLexer]], [[CalcLexer]])[ (InputStream is)
{
st = new StreamTokenizer (new InputStreamReader (is));
st.resetSyntax ();
st.eolIsSignificant (true);
- st.whitespaceChars (9, 9);
- st.whitespaceChars (32, 32);
- st.wordChars (48, 57);
+ st.whitespaceChars ('\t', '\t');
+ st.whitespaceChars (' ', ' ');
+ st.wordChars ('0', '9');
}
-AT_LOCATION_IF([[
+]AT_LOCATION_IF([[
Position yypos = new Position (1, 0);
public Position getStartPos() {
@@ -157,15 +157,14 @@ AT_LOCATION_IF([[
}
public int yylex () throws IOException {
- int ttype = st.nextToken ();
- ]AT_LOCATION_IF([[yypos = new Position (yypos.lineno (),
- yypos.token () + 1);]])[
+ int ttype = st.nextToken ();]AT_LOCATION_IF([[
+ yypos = new Position (yypos.lineno (), yypos.token () + 1);]])[
if (ttype == st.TT_EOF)
return EOF;
else if (ttype == st.TT_EOL)
- {
- ]AT_LOCATION_IF([[yypos = new Position (yypos.lineno () + 1, 0);]])[
+ {]AT_LOCATION_IF([[
+ yypos = new Position (yypos.lineno () + 1, 0);]])[
return (int) '\n';
}
@@ -251,7 +250,7 @@ $2
AT_BISON_CHECK([-Wno-deprecated -o Calc.java Calc.y])
AT_JAVA_COMPILE([Calc.java])
-# Test the priorities.
+# Test the precedences.
AT_DATA([[input]],
[[1 + 2 * 3 = 7
1 + 2 * -3 = -5
diff --git a/tests/javapush.at b/tests/javapush.at
index 572b8666..8214a6d0 100644
--- a/tests/javapush.at
+++ b/tests/javapush.at
@@ -43,7 +43,7 @@ AT_BANNER([[Java Push Parsing Tests]])
# Define a single copy of the trivial parser grammar.
# This is missing main(), so two versions
# are instantiated with different main() procedures.
-m4_define([AT_TRIVIAL_GRAMMAR],[
+m4_define([AT_TRIVIAL_GRAMMAR],[[
%define api.parser.class {YYParser}
%define parse.error verbose
@@ -57,11 +57,11 @@ import java.util.*;
start: 'a' 'b' 'c' ;
%%
-])
+]])
# Define comon code across to be included in
# class Main for the trivial parser tests.
-m4_define([AT_TRIVIAL_COMMON],[
+m4_define([AT_TRIVIAL_COMMON],[[
static class YYerror implements YYParser.Lexer
{
public Object getLVal() {return null;}
@@ -82,29 +82,30 @@ m4_define([AT_TRIVIAL_COMMON],[
teststate = -1;
}
- static String[[]] teststatename
- = new String[[]]{"YYACCEPT","YYABORT","YYERROR","UNKNOWN","YYPUSH_MORE"};
+ static String[] teststatename
+ = new String[]{"YYACCEPT","YYABORT","YYERROR","UNKNOWN","YYPUSH_MORE"};
static void check(int teststate, int expected, String msg)
{
- System.err.println("teststate="+teststatename[[teststate]]
- +"; expected="+teststatename[[expected]]);
- if (teststate == expected)
- return;
- System.err.println("unexpected state: "+msg);
- System.exit(1);
+ System.err.println("teststate="+teststatename[teststate]
+ +"; expected="+teststatename[expected]);
+ if (teststate != expected)
+ {
+ System.err.println("unexpected state: "+msg);
+ System.exit(1);
+ }
}
-])
+]])
-m4_define([AT_TRIVIAL_PARSER],[
- AT_TRIVIAL_GRAMMAR
+m4_define([AT_TRIVIAL_PARSER],[[
+ ]AT_TRIVIAL_GRAMMAR[
public class Main
{
- AT_TRIVIAL_COMMON
+ ]AT_TRIVIAL_COMMON[
- static public void main (String[[]] argv)
+ static public void main (String[] args)
throws IOException
{
setup();
@@ -131,17 +132,17 @@ m4_define([AT_TRIVIAL_PARSER],[
}
}
-])
+]])
-m4_define([AT_TRIVIAL_PARSER_INITIAL_ACTION],[
- AT_TRIVIAL_GRAMMAR
+m4_define([AT_TRIVIAL_PARSER_INITIAL_ACTION],[[
+ ]AT_TRIVIAL_GRAMMAR[
public class Main
{
- AT_TRIVIAL_COMMON
+ ]AT_TRIVIAL_COMMON[
- static public void main (String[[]] argv)
+ static public void main (String[] args)
throws IOException
{
setup();
@@ -159,7 +160,7 @@ m4_define([AT_TRIVIAL_PARSER_INITIAL_ACTION],[
}
}
-])
+]])
## ----------------------------------------------------- ##
## Trivial Push Parser with api.push-pull verification. ##
@@ -359,9 +360,9 @@ AT_DATA([Calc.y],[[/* Infix notation calculator--calc */
st = new StreamTokenizer(rdr);
st.resetSyntax();
st.eolIsSignificant(true);
- st.whitespaceChars(9, 9);
- st.whitespaceChars(32, 32);
- st.wordChars(48, 57);
+ st.whitespaceChars('\t', '\t');
+ st.whitespaceChars(' ', ' ');
+ st.wordChars('0', '9');
}
Integer yylval;
@@ -385,10 +386,10 @@ AT_DATA([Calc.y],[[/* Infix notation calculator--calc */
}
%code {
- public static void main (String[] argv)
+ public static void main (String[] args)
throws IOException
{
- StringReader reader = getinput(argv[0]);
+ StringReader reader = getinput(args[0]);
UserLexer lexer = new UserLexer(reader);
Calc calc = new Calc(lexer);
calc.setDebugLevel(1);
@@ -634,9 +635,9 @@ AT_DATA([Calc.y],[[/* Infix notation calculator--calc. */
st = new StreamTokenizer(rdr);
st.resetSyntax();
st.eolIsSignificant(true);
- st.whitespaceChars(9, 9);
- st.whitespaceChars(32, 32);
- st.wordChars(48, 57);
+ st.whitespaceChars('\t', '\t');
+ st.whitespaceChars(' ', ' ');
+ st.wordChars('0', '9');
}
Position yypos = new Position (1, 0);
@@ -673,10 +674,10 @@ AT_DATA([Calc.y],[[/* Infix notation calculator--calc. */
%code { ]AT_JAVA_POSITION_DEFINE[ }
%code {
- public static void main (String[] argv)
+ public static void main (String[] args)
throws IOException
{
- StringReader reader = getinput(argv[0]);
+ StringReader reader = getinput(args[0]);
Calc calc = new Calc(reader);
calc.setDebugLevel(1);
calc.parse();