From 22dfaf92176c2880a5ef884d944acbd36505a53a Mon Sep 17 00:00:00 2001 From: Tobias Knorr Date: Thu, 4 Nov 2021 11:49:36 +0100 Subject: [PATCH 1/6] added syntax tests for merge-request --- syntax/Add.valid.mj | 5 ++++ syntax/Braces.valid.mj | 8 +++++++ syntax/DerCompilerMain.valid.mj | 30 ++++++++++++++++++++++++ syntax/Foo.invalid.mj | 5 ++++ syntax/Foo.valid.mj | 6 +++++ syntax/MultipleReturnStatements.valid.mj | 20 ++++++++++++++++ syntax/PrivateMethod.invalid.mj | 6 +++++ syntax/ReturnWhile.invalid.mj | 7 ++++++ syntax/UseFor.invalid.mj | 13 ++++++++++ syntax/cSyntax.invalid.mj | 8 +++++++ 10 files changed, 108 insertions(+) create mode 100644 syntax/Add.valid.mj create mode 100644 syntax/Braces.valid.mj create mode 100644 syntax/DerCompilerMain.valid.mj create mode 100644 syntax/Foo.invalid.mj create mode 100644 syntax/Foo.valid.mj create mode 100644 syntax/MultipleReturnStatements.valid.mj create mode 100644 syntax/PrivateMethod.invalid.mj create mode 100644 syntax/ReturnWhile.invalid.mj create mode 100644 syntax/UseFor.invalid.mj create mode 100644 syntax/cSyntax.invalid.mj diff --git a/syntax/Add.valid.mj b/syntax/Add.valid.mj new file mode 100644 index 0000000..c3e6eec --- /dev/null +++ b/syntax/Add.valid.mj @@ -0,0 +1,5 @@ +class Add { + public int add(int a, int b) { + return a + b; + } +} \ No newline at end of file diff --git a/syntax/Braces.valid.mj b/syntax/Braces.valid.mj new file mode 100644 index 0000000..82f9d8c --- /dev/null +++ b/syntax/Braces.valid.mj @@ -0,0 +1,8 @@ +class PrivateMember { + + int[][][] test; + + public int foo() { + {}{}{{}} + } +} \ No newline at end of file diff --git a/syntax/DerCompilerMain.valid.mj b/syntax/DerCompilerMain.valid.mj new file mode 100644 index 0000000..e7d2d5b --- /dev/null +++ b/syntax/DerCompilerMain.valid.mj @@ -0,0 +1,30 @@ +package de.dercompiler; + +import de.dercompiler.actions.Action; +import de.dercompiler.general.CompilerSetup; +import de.dercompiler.io.CommandLineBuilder; +import de.dercompiler.io.CommandLineOptions; + +public class DerCompiler { + + public static void main(String[] args){ + CommandLineBuilder clb = new CommandLineBuilder(); + clb.parseArguments(args); + + CommandLineOptions options = clb.parseArguments(args); + + CompilerSetup.setupGlobalValues(options); + Action action = new CompilerSetup().parseAction(options); + + boolean showHelp = options.help(); + + options.finish(); + + if (showHelp) { + action.help(); + } else { + action.run(); + } + System.exit(0); + } +} \ No newline at end of file diff --git a/syntax/Foo.invalid.mj b/syntax/Foo.invalid.mj new file mode 100644 index 0000000..4f13dc9 --- /dev/null +++ b/syntax/Foo.invalid.mj @@ -0,0 +1,5 @@ +class FooTester2 { + public boolean isFoo(String maybeFoo; String definitelyFoo) { + return maybeFoo _ definitelyFoo; + } +} \ No newline at end of file diff --git a/syntax/Foo.valid.mj b/syntax/Foo.valid.mj new file mode 100644 index 0000000..22b0c66 --- /dev/null +++ b/syntax/Foo.valid.mj @@ -0,0 +1,6 @@ +class FooTester { + public void foo() {} + public boolean isFoo(String maybeFoo, String definitelyFoo) { + return maybeFoo == definitelyFoo; + } +} \ No newline at end of file diff --git a/syntax/MultipleReturnStatements.valid.mj b/syntax/MultipleReturnStatements.valid.mj new file mode 100644 index 0000000..47fe786 --- /dev/null +++ b/syntax/MultipleReturnStatements.valid.mj @@ -0,0 +1,20 @@ +class PrivateMember { + + public int test; + + public static void foo() { + + } + + public String test; +} + +class irgendwas{ + + public static int fib(Integer i){ + return fib(1); + return fib(test); + + return; + } +} \ No newline at end of file diff --git a/syntax/PrivateMethod.invalid.mj b/syntax/PrivateMethod.invalid.mj new file mode 100644 index 0000000..fcf2e08 --- /dev/null +++ b/syntax/PrivateMethod.invalid.mj @@ -0,0 +1,6 @@ +class PrivateMember { + + private int foo() { + return 0; + } +} \ No newline at end of file diff --git a/syntax/ReturnWhile.invalid.mj b/syntax/ReturnWhile.invalid.mj new file mode 100644 index 0000000..6399952 --- /dev/null +++ b/syntax/ReturnWhile.invalid.mj @@ -0,0 +1,7 @@ +class ReturnWhile { + + public void returnWhile() { + return while(true); + } + +} \ No newline at end of file diff --git a/syntax/UseFor.invalid.mj b/syntax/UseFor.invalid.mj new file mode 100644 index 0000000..b856468 --- /dev/null +++ b/syntax/UseFor.invalid.mj @@ -0,0 +1,13 @@ +class UseFor { + + public int[] foo; + + public void useFor() { + + foo = new int[10]; + + for (int i = 0; i < 10; i++) { + foo[i] = 0; + } + } +} \ No newline at end of file diff --git a/syntax/cSyntax.invalid.mj b/syntax/cSyntax.invalid.mj new file mode 100644 index 0000000..05959e0 --- /dev/null +++ b/syntax/cSyntax.invalid.mj @@ -0,0 +1,8 @@ +class PrivateMember { + + int test[]; + + private int foo() { + return 0; + } +} \ No newline at end of file -- GitLab From 44d1055c028e29876f3e1d27fea90ec17dbcd169 Mon Sep 17 00:00:00 2001 From: Tobias Knorr Date: Thu, 4 Nov 2021 12:25:38 +0100 Subject: [PATCH 2/6] fixed wrong tests --- syntax/Braces.valid.mj | 2 +- syntax/DerCompilerMain.valid.mj | 7 ------- syntax/MultipleReturnStatements.valid.mj | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/syntax/Braces.valid.mj b/syntax/Braces.valid.mj index 82f9d8c..f977349 100644 --- a/syntax/Braces.valid.mj +++ b/syntax/Braces.valid.mj @@ -1,6 +1,6 @@ class PrivateMember { - int[][][] test; + public int[][][] test; public int foo() { {}{}{{}} diff --git a/syntax/DerCompilerMain.valid.mj b/syntax/DerCompilerMain.valid.mj index e7d2d5b..1ee0d58 100644 --- a/syntax/DerCompilerMain.valid.mj +++ b/syntax/DerCompilerMain.valid.mj @@ -1,10 +1,3 @@ -package de.dercompiler; - -import de.dercompiler.actions.Action; -import de.dercompiler.general.CompilerSetup; -import de.dercompiler.io.CommandLineBuilder; -import de.dercompiler.io.CommandLineOptions; - public class DerCompiler { public static void main(String[] args){ diff --git a/syntax/MultipleReturnStatements.valid.mj b/syntax/MultipleReturnStatements.valid.mj index 47fe786..3598385 100644 --- a/syntax/MultipleReturnStatements.valid.mj +++ b/syntax/MultipleReturnStatements.valid.mj @@ -2,7 +2,7 @@ class PrivateMember { public int test; - public static void foo() { + public static void foo(int a) { } -- GitLab From 5afce9408f480f7587750e32f528a5ad0272b9f8 Mon Sep 17 00:00:00 2001 From: Tobias Knorr Date: Thu, 4 Nov 2021 11:49:36 +0100 Subject: [PATCH 3/6] added syntax tests for merge-request --- syntax/Add.valid.mj | 5 ++++ syntax/Braces.valid.mj | 8 +++++++ syntax/DerCompilerMain.valid.mj | 30 ++++++++++++++++++++++++ syntax/Foo.invalid.mj | 5 ++++ syntax/Foo.valid.mj | 6 +++++ syntax/MultipleReturnStatements.valid.mj | 20 ++++++++++++++++ syntax/PrivateMethod.invalid.mj | 6 +++++ syntax/ReturnWhile.invalid.mj | 7 ++++++ syntax/UseFor.invalid.mj | 13 ++++++++++ syntax/cSyntax.invalid.mj | 8 +++++++ 10 files changed, 108 insertions(+) create mode 100644 syntax/Add.valid.mj create mode 100644 syntax/Braces.valid.mj create mode 100644 syntax/DerCompilerMain.valid.mj create mode 100644 syntax/Foo.invalid.mj create mode 100644 syntax/Foo.valid.mj create mode 100644 syntax/MultipleReturnStatements.valid.mj create mode 100644 syntax/PrivateMethod.invalid.mj create mode 100644 syntax/ReturnWhile.invalid.mj create mode 100644 syntax/UseFor.invalid.mj create mode 100644 syntax/cSyntax.invalid.mj diff --git a/syntax/Add.valid.mj b/syntax/Add.valid.mj new file mode 100644 index 0000000..c3e6eec --- /dev/null +++ b/syntax/Add.valid.mj @@ -0,0 +1,5 @@ +class Add { + public int add(int a, int b) { + return a + b; + } +} \ No newline at end of file diff --git a/syntax/Braces.valid.mj b/syntax/Braces.valid.mj new file mode 100644 index 0000000..82f9d8c --- /dev/null +++ b/syntax/Braces.valid.mj @@ -0,0 +1,8 @@ +class PrivateMember { + + int[][][] test; + + public int foo() { + {}{}{{}} + } +} \ No newline at end of file diff --git a/syntax/DerCompilerMain.valid.mj b/syntax/DerCompilerMain.valid.mj new file mode 100644 index 0000000..e7d2d5b --- /dev/null +++ b/syntax/DerCompilerMain.valid.mj @@ -0,0 +1,30 @@ +package de.dercompiler; + +import de.dercompiler.actions.Action; +import de.dercompiler.general.CompilerSetup; +import de.dercompiler.io.CommandLineBuilder; +import de.dercompiler.io.CommandLineOptions; + +public class DerCompiler { + + public static void main(String[] args){ + CommandLineBuilder clb = new CommandLineBuilder(); + clb.parseArguments(args); + + CommandLineOptions options = clb.parseArguments(args); + + CompilerSetup.setupGlobalValues(options); + Action action = new CompilerSetup().parseAction(options); + + boolean showHelp = options.help(); + + options.finish(); + + if (showHelp) { + action.help(); + } else { + action.run(); + } + System.exit(0); + } +} \ No newline at end of file diff --git a/syntax/Foo.invalid.mj b/syntax/Foo.invalid.mj new file mode 100644 index 0000000..4f13dc9 --- /dev/null +++ b/syntax/Foo.invalid.mj @@ -0,0 +1,5 @@ +class FooTester2 { + public boolean isFoo(String maybeFoo; String definitelyFoo) { + return maybeFoo _ definitelyFoo; + } +} \ No newline at end of file diff --git a/syntax/Foo.valid.mj b/syntax/Foo.valid.mj new file mode 100644 index 0000000..22b0c66 --- /dev/null +++ b/syntax/Foo.valid.mj @@ -0,0 +1,6 @@ +class FooTester { + public void foo() {} + public boolean isFoo(String maybeFoo, String definitelyFoo) { + return maybeFoo == definitelyFoo; + } +} \ No newline at end of file diff --git a/syntax/MultipleReturnStatements.valid.mj b/syntax/MultipleReturnStatements.valid.mj new file mode 100644 index 0000000..47fe786 --- /dev/null +++ b/syntax/MultipleReturnStatements.valid.mj @@ -0,0 +1,20 @@ +class PrivateMember { + + public int test; + + public static void foo() { + + } + + public String test; +} + +class irgendwas{ + + public static int fib(Integer i){ + return fib(1); + return fib(test); + + return; + } +} \ No newline at end of file diff --git a/syntax/PrivateMethod.invalid.mj b/syntax/PrivateMethod.invalid.mj new file mode 100644 index 0000000..fcf2e08 --- /dev/null +++ b/syntax/PrivateMethod.invalid.mj @@ -0,0 +1,6 @@ +class PrivateMember { + + private int foo() { + return 0; + } +} \ No newline at end of file diff --git a/syntax/ReturnWhile.invalid.mj b/syntax/ReturnWhile.invalid.mj new file mode 100644 index 0000000..6399952 --- /dev/null +++ b/syntax/ReturnWhile.invalid.mj @@ -0,0 +1,7 @@ +class ReturnWhile { + + public void returnWhile() { + return while(true); + } + +} \ No newline at end of file diff --git a/syntax/UseFor.invalid.mj b/syntax/UseFor.invalid.mj new file mode 100644 index 0000000..b856468 --- /dev/null +++ b/syntax/UseFor.invalid.mj @@ -0,0 +1,13 @@ +class UseFor { + + public int[] foo; + + public void useFor() { + + foo = new int[10]; + + for (int i = 0; i < 10; i++) { + foo[i] = 0; + } + } +} \ No newline at end of file diff --git a/syntax/cSyntax.invalid.mj b/syntax/cSyntax.invalid.mj new file mode 100644 index 0000000..05959e0 --- /dev/null +++ b/syntax/cSyntax.invalid.mj @@ -0,0 +1,8 @@ +class PrivateMember { + + int test[]; + + private int foo() { + return 0; + } +} \ No newline at end of file -- GitLab From 9a4432e714a460ebd54f9690cf664acde287c80f Mon Sep 17 00:00:00 2001 From: Tobias Knorr Date: Thu, 4 Nov 2021 12:25:38 +0100 Subject: [PATCH 4/6] fixed wrong tests --- syntax/Braces.valid.mj | 2 +- syntax/DerCompilerMain.valid.mj | 7 ------- syntax/MultipleReturnStatements.valid.mj | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/syntax/Braces.valid.mj b/syntax/Braces.valid.mj index 82f9d8c..f977349 100644 --- a/syntax/Braces.valid.mj +++ b/syntax/Braces.valid.mj @@ -1,6 +1,6 @@ class PrivateMember { - int[][][] test; + public int[][][] test; public int foo() { {}{}{{}} diff --git a/syntax/DerCompilerMain.valid.mj b/syntax/DerCompilerMain.valid.mj index e7d2d5b..1ee0d58 100644 --- a/syntax/DerCompilerMain.valid.mj +++ b/syntax/DerCompilerMain.valid.mj @@ -1,10 +1,3 @@ -package de.dercompiler; - -import de.dercompiler.actions.Action; -import de.dercompiler.general.CompilerSetup; -import de.dercompiler.io.CommandLineBuilder; -import de.dercompiler.io.CommandLineOptions; - public class DerCompiler { public static void main(String[] args){ diff --git a/syntax/MultipleReturnStatements.valid.mj b/syntax/MultipleReturnStatements.valid.mj index 47fe786..3598385 100644 --- a/syntax/MultipleReturnStatements.valid.mj +++ b/syntax/MultipleReturnStatements.valid.mj @@ -2,7 +2,7 @@ class PrivateMember { public int test; - public static void foo() { + public static void foo(int a) { } -- GitLab From 1e163788a47aa5c27475d2e828d23e55707b8ef5 Mon Sep 17 00:00:00 2001 From: Tobias Knorr Date: Fri, 5 Nov 2021 19:31:57 +0100 Subject: [PATCH 5/6] fiex errors of test --- syntax/DerCompilerMain.valid.mj | 2 +- syntax/MultipleReturnStatements.valid.mj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/DerCompilerMain.valid.mj b/syntax/DerCompilerMain.valid.mj index 1ee0d58..88eecfc 100644 --- a/syntax/DerCompilerMain.valid.mj +++ b/syntax/DerCompilerMain.valid.mj @@ -1,4 +1,4 @@ -public class DerCompiler { +class DerCompiler { public static void main(String[] args){ CommandLineBuilder clb = new CommandLineBuilder(); diff --git a/syntax/MultipleReturnStatements.valid.mj b/syntax/MultipleReturnStatements.valid.mj index 3598385..608a097 100644 --- a/syntax/MultipleReturnStatements.valid.mj +++ b/syntax/MultipleReturnStatements.valid.mj @@ -11,7 +11,7 @@ class PrivateMember { class irgendwas{ - public static int fib(Integer i){ + public static void fib(Integer i){ return fib(1); return fib(test); -- GitLab From 949a8450348f6d12a17a275d02609f23a0e17cd5 Mon Sep 17 00:00:00 2001 From: Paul Brinkmeier Date: Fri, 5 Nov 2021 23:27:21 +0100 Subject: [PATCH 6/6] Fix trailing whitespace and CSyntax filename --- syntax/Add.valid.mj | 2 +- syntax/Braces.valid.mj | 2 +- syntax/{cSyntax.invalid.mj => CSyntax.invalid.mj} | 2 +- syntax/DerCompilerMain.valid.mj | 2 +- syntax/Foo.invalid.mj | 2 +- syntax/Foo.valid.mj | 2 +- syntax/MultipleReturnStatements.valid.mj | 2 +- syntax/PrivateMethod.invalid.mj | 2 +- syntax/ReturnWhile.invalid.mj | 2 +- syntax/UseFor.invalid.mj | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) rename syntax/{cSyntax.invalid.mj => CSyntax.invalid.mj} (97%) diff --git a/syntax/Add.valid.mj b/syntax/Add.valid.mj index c3e6eec..19830bb 100644 --- a/syntax/Add.valid.mj +++ b/syntax/Add.valid.mj @@ -2,4 +2,4 @@ class Add { public int add(int a, int b) { return a + b; } -} \ No newline at end of file +} diff --git a/syntax/Braces.valid.mj b/syntax/Braces.valid.mj index f977349..efc2750 100644 --- a/syntax/Braces.valid.mj +++ b/syntax/Braces.valid.mj @@ -5,4 +5,4 @@ class PrivateMember { public int foo() { {}{}{{}} } -} \ No newline at end of file +} diff --git a/syntax/cSyntax.invalid.mj b/syntax/CSyntax.invalid.mj similarity index 97% rename from syntax/cSyntax.invalid.mj rename to syntax/CSyntax.invalid.mj index 05959e0..4e9fbe6 100644 --- a/syntax/cSyntax.invalid.mj +++ b/syntax/CSyntax.invalid.mj @@ -5,4 +5,4 @@ class PrivateMember { private int foo() { return 0; } -} \ No newline at end of file +} diff --git a/syntax/DerCompilerMain.valid.mj b/syntax/DerCompilerMain.valid.mj index 88eecfc..527a9e1 100644 --- a/syntax/DerCompilerMain.valid.mj +++ b/syntax/DerCompilerMain.valid.mj @@ -20,4 +20,4 @@ class DerCompiler { } System.exit(0); } -} \ No newline at end of file +} diff --git a/syntax/Foo.invalid.mj b/syntax/Foo.invalid.mj index 4f13dc9..8b6f8e7 100644 --- a/syntax/Foo.invalid.mj +++ b/syntax/Foo.invalid.mj @@ -2,4 +2,4 @@ class FooTester2 { public boolean isFoo(String maybeFoo; String definitelyFoo) { return maybeFoo _ definitelyFoo; } -} \ No newline at end of file +} diff --git a/syntax/Foo.valid.mj b/syntax/Foo.valid.mj index 22b0c66..31a9765 100644 --- a/syntax/Foo.valid.mj +++ b/syntax/Foo.valid.mj @@ -3,4 +3,4 @@ class FooTester { public boolean isFoo(String maybeFoo, String definitelyFoo) { return maybeFoo == definitelyFoo; } -} \ No newline at end of file +} diff --git a/syntax/MultipleReturnStatements.valid.mj b/syntax/MultipleReturnStatements.valid.mj index 608a097..eb33333 100644 --- a/syntax/MultipleReturnStatements.valid.mj +++ b/syntax/MultipleReturnStatements.valid.mj @@ -17,4 +17,4 @@ class irgendwas{ return; } -} \ No newline at end of file +} diff --git a/syntax/PrivateMethod.invalid.mj b/syntax/PrivateMethod.invalid.mj index fcf2e08..ea7f569 100644 --- a/syntax/PrivateMethod.invalid.mj +++ b/syntax/PrivateMethod.invalid.mj @@ -3,4 +3,4 @@ class PrivateMember { private int foo() { return 0; } -} \ No newline at end of file +} diff --git a/syntax/ReturnWhile.invalid.mj b/syntax/ReturnWhile.invalid.mj index 6399952..af122f9 100644 --- a/syntax/ReturnWhile.invalid.mj +++ b/syntax/ReturnWhile.invalid.mj @@ -4,4 +4,4 @@ class ReturnWhile { return while(true); } -} \ No newline at end of file +} diff --git a/syntax/UseFor.invalid.mj b/syntax/UseFor.invalid.mj index b856468..b4b8869 100644 --- a/syntax/UseFor.invalid.mj +++ b/syntax/UseFor.invalid.mj @@ -10,4 +10,4 @@ class UseFor { foo[i] = 0; } } -} \ No newline at end of file +} -- GitLab