Compare commits
2 Commits
85e0cf3807
...
c315966219
Author | SHA1 | Date | |
---|---|---|---|
c315966219 | |||
c2c4974c76 |
@ -135,12 +135,12 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(CalculationNode calculationNode) {
|
||||
if (calculationNode.dotExpression != null) {
|
||||
calculationNode.dotExpression.accept(this);
|
||||
}
|
||||
if (calculationNode.calculationExpression != null) {
|
||||
calculationNode.calculationExpression.accept(this);
|
||||
}
|
||||
if (calculationNode.dotExpression != null) {
|
||||
calculationNode.dotExpression.accept(this);
|
||||
}
|
||||
if (calculationNode.operator != null) {
|
||||
switch (calculationNode.operator) {
|
||||
case PLUS:
|
||||
|
@ -39,6 +39,14 @@ public class Main {
|
||||
System.err.println("Error reading the file: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
CharStream codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/input/endabgabeTests/Person.java"));
|
||||
compileFile(codeCharStream, "src/test/resources/input/endabgabeTests");
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error reading the file: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,13 +66,13 @@ public class MiniCompilerLogger {
|
||||
logger.addHandler(consoleHandler);
|
||||
|
||||
// Configure file handler
|
||||
Handler fileHandler = new FileHandler("src/main/resources/logs/miniCompiler.log");
|
||||
//Handler fileHandler = new FileHandler("src/main/resources/logs/miniCompiler.log");
|
||||
// Toggle file logging on/off
|
||||
fileHandler.setLevel(Level.ALL);
|
||||
fileHandler.setFormatter(new CustomFormatter());
|
||||
logger.addHandler(fileHandler);
|
||||
//fileHandler.setLevel(Level.ALL);
|
||||
//fileHandler.setFormatter(new CustomFormatter());
|
||||
//logger.addHandler(fileHandler);
|
||||
|
||||
} catch (SecurityException | IOException e) {
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
25
src/test/resources/input/endabgabeTests/Calculation.java
Normal file
25
src/test/resources/input/endabgabeTests/Calculation.java
Normal file
@ -0,0 +1,25 @@
|
||||
public class Calculation {
|
||||
public int add(int a, int b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
public int sub(int a, int b) {
|
||||
return a - b;
|
||||
}
|
||||
|
||||
public int mul(int a, int b) {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
public int div(int a, int b) {
|
||||
return a / b;
|
||||
}
|
||||
|
||||
public int mod(int a, int b) {
|
||||
return a % b;
|
||||
}
|
||||
|
||||
public int complexCalculation() {
|
||||
return 3 - 2 * 2 + 5;
|
||||
}
|
||||
}
|
@ -4,13 +4,13 @@ public class ControlStructures {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
public cahr checkNumber(int num) {
|
||||
public char checkNumber(int num) {
|
||||
if (num > 0) {
|
||||
return "p";
|
||||
return 'p';
|
||||
} else if (num < 0) {
|
||||
return "n";
|
||||
return 'n';
|
||||
} else {
|
||||
return "z";
|
||||
return 'z';
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ public class ControlStructures {
|
||||
int uneven = 0;
|
||||
int i = 0;
|
||||
while (i < limit) {
|
||||
if (i % 2 == 0) {
|
||||
if ((i % 2) == 0) {
|
||||
even++;
|
||||
} else {
|
||||
uneven = uneven + 1;
|
||||
|
1
src/test/resources/input/endabgabeTests/EmptyClass.java
Normal file
1
src/test/resources/input/endabgabeTests/EmptyClass.java
Normal file
@ -0,0 +1 @@
|
||||
public class EmptyClass {}
|
17
src/test/resources/input/endabgabeTests/Loops.java
Normal file
17
src/test/resources/input/endabgabeTests/Loops.java
Normal file
@ -0,0 +1,17 @@
|
||||
public class Loops {
|
||||
public boolean If(int a, int b) {
|
||||
if(a == b) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int While(int a) {
|
||||
int count = 0;
|
||||
while(count < a) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
5
src/test/resources/input/endabgabeTests/Main.java
Normal file
5
src/test/resources/input/endabgabeTests/Main.java
Normal file
@ -0,0 +1,5 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Person testPerson = new Person(5);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user