Skip to content
Snippets Groups Projects

Dominicsbranch

Merged Dominic Daniel Krämer requested to merge dominicsbranch into main
7 files
+ 150
64
Compare changes
  • Side-by-side
  • Inline
Files
7
+ 6
6
package main;
package main;
import java.util.List;
/**
/**
* <h1>The ASTPrinter</h1>
* <h1>ASTPrinter</h1>
* The ASTPrinter class creates a String out of an AST(represented through an Expression object)
* The ASTPrinter class creates a String out of an AST(represented through an Expression object)
* It prints it in a form the Evaluator class can work with it, it isn't primarily designed for
* It prints it in a form the SwingFunctionPlotter class can work with it, it isn't primarily designed for
* returning a String that is perfect for human readability (e.g. Pow(x,3) would be printed instead of x^3)
* returning a String that is perfect for human readability (e.g. Pow(x,3) would be printed instead of x^3)
*
*
* @version 1.0
* @version 1.0
@@ -19,7 +17,7 @@ public class ASTPrinter implements Visitor<String>{
@@ -19,7 +17,7 @@ public class ASTPrinter implements Visitor<String>{
* recursive call) and combines them into one String together with the operator
* recursive call) and combines them into one String together with the operator
*
*
* @param binaryOP The BinaryOperation that should be printed into a String
* @param binaryOP The BinaryOperation that should be printed into a String
* @return String Returns the String that was build
* @return Returns the String that was build
*/
*/
@Override
@Override
public String visit(final Parser.BinaryOperation binaryOP) {
public String visit(final Parser.BinaryOperation binaryOP) {
@@ -49,7 +47,6 @@ public class ASTPrinter implements Visitor<String>{
@@ -49,7 +47,6 @@ public class ASTPrinter implements Visitor<String>{
return sb.toString();
return sb.toString();
}
}
/**
/**
* Returns the result of ast.accept(this), which will be the core values of a Value(digits),
* Returns the result of ast.accept(this), which will be the core values of a Value(digits),
* Variable(variableName) or BinaryOperation(will lead to a recursive call)
* Variable(variableName) or BinaryOperation(will lead to a recursive call)
@@ -64,6 +61,7 @@ public class ASTPrinter implements Visitor<String>{
@@ -64,6 +61,7 @@ public class ASTPrinter implements Visitor<String>{
}
}
/**
/**
 
* returns a string-representation of the value stored inside a Variable object
* @see #visit(Parser.Expression)
* @see #visit(Parser.Expression)
*/
*/
@Override
@Override
@@ -72,6 +70,7 @@ public class ASTPrinter implements Visitor<String>{
@@ -72,6 +70,7 @@ public class ASTPrinter implements Visitor<String>{
}
}
/**
/**
 
* returns a string-representation of the value stored inside a Number object
* @see #visit(Parser.Expression)
* @see #visit(Parser.Expression)
*/
*/
@Override
@Override
@@ -80,6 +79,7 @@ public class ASTPrinter implements Visitor<String>{
@@ -80,6 +79,7 @@ public class ASTPrinter implements Visitor<String>{
}
}
/**
/**
 
* returns a string-representation of the value stored inside a Decimal object
* @see #visit(Parser.Expression)
* @see #visit(Parser.Expression)
*/
*/
@Override
@Override
Loading