delete print statement
This commit is contained in:
@@ -28,8 +28,7 @@ braced_block
|
||||
// Only the first child of a rule alternative will be visited!
|
||||
// i.e. SCOL won't be visited, but thats unneccesary anyway
|
||||
statement
|
||||
: print
|
||||
| if_statement
|
||||
: if_statement
|
||||
| variable_declaration SCOL
|
||||
| variable_assignment SCOL
|
||||
| return_statement
|
||||
@@ -38,10 +37,6 @@ statement
|
||||
| forLoop
|
||||
;
|
||||
|
||||
print
|
||||
: PRINT expression SCOL
|
||||
;
|
||||
|
||||
if_statement
|
||||
: IF OPAR cond = expression CPAR then = braced_block (ELSE (alt = braced_block | elif = if_statement) )?
|
||||
;
|
||||
@@ -123,7 +118,6 @@ forLoop
|
||||
step = variable_assignment CPAR braced_block
|
||||
;
|
||||
|
||||
PRINT: 'print';
|
||||
IF: 'if';
|
||||
ELSE: 'else';
|
||||
FUNC: 'function';
|
||||
|
||||
@@ -102,18 +102,6 @@ public class ContextAnalysis extends KlangBaseVisitor<Node> {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node visitPrint(KlangParser.PrintContext ctx) {
|
||||
ctx.start.getLine();
|
||||
ctx.start.getCharPositionInLine();
|
||||
Node expression = this.visit(ctx.expression());
|
||||
PrintStatement result = new PrintStatement((Expression) expression);
|
||||
result.type = null;
|
||||
result.line = ctx.start.getLine();
|
||||
result.col = ctx.start.getCharPositionInLine();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node visitIf_statement(KlangParser.If_statementContext ctx) {
|
||||
Node condition = this.visit(ctx.cond);
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package de.hsrm.compiler.Klang.nodes.statements;
|
||||
|
||||
import de.hsrm.compiler.Klang.nodes.expressions.Expression;
|
||||
import de.hsrm.compiler.Klang.visitors.Visitor;
|
||||
|
||||
public class PrintStatement extends Statement {
|
||||
public Expression expression;
|
||||
|
||||
public PrintStatement(Expression expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R> R welcome(Visitor<R> v) {
|
||||
return v.visit(this);
|
||||
}
|
||||
}
|
||||
@@ -385,13 +385,6 @@ public class EvalVisitor implements Visitor<Value> {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value visit(PrintStatement e) {
|
||||
Value value = e.expression.welcome(this);
|
||||
System.out.println(value.asObject());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value visit(VariableDeclaration e) {
|
||||
Value initialValue = null;
|
||||
|
||||
@@ -556,11 +556,6 @@ public class GenASM implements Visitor<Void> {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(PrintStatement e) {
|
||||
throw new RuntimeException("Das machen wir mal nicht, ne?!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(VariableDeclaration e) {
|
||||
// If there is an initialization present,
|
||||
|
||||
@@ -179,12 +179,6 @@ class GetVars implements Visitor<Void> {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(PrintStatement e) {
|
||||
e.expression.welcome(this);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(VariableDeclaration e) {
|
||||
vars.add(e.name);
|
||||
|
||||
@@ -276,14 +276,6 @@ public class PrettyPrintVisitor implements Visitor<Void> {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(PrintStatement e) {
|
||||
ex.write("print ");
|
||||
e.expression.welcome(this);
|
||||
ex.write(";");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(VariableDeclaration e) {
|
||||
ex.write("let " + e.name + ": " + e.type.getName());
|
||||
|
||||
@@ -32,7 +32,6 @@ public interface Visitor<R> {
|
||||
R visit(WhileLoop e);
|
||||
R visit(DoWhileLoop e);
|
||||
R visit(ForLoop e);
|
||||
R visit(PrintStatement e);
|
||||
R visit(VariableDeclaration e);
|
||||
R visit(VariableAssignment e);
|
||||
R visit(ReturnStatement e);
|
||||
|
||||
Reference in New Issue
Block a user