blob: 1fdfcc383b2097482a9a3886b1ca8cc54f29fa6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package com.clp.project.ast.nodes;
import java.util.ArrayList;
import com.clp.project.semanticanalysis.SemanticError;
import com.clp.project.semanticanalysis.SymbolTable;
import com.clp.project.ast.types.*;
/**
* Node for `block` statement of the grammar.
* It extends the `RootNode`.
*/
public class BlockNode extends RootNode implements Node {
public BlockNode(ArrayList<Node> stmts, ArrayList<Node> compoundStmts) {
super(stmts, compoundStmts);
}
@Override
public Type typeCheck() {
return new VoidType();
}
@Override
public String toPrint(String prefix) {
String str = prefix + "Block\n";
prefix += " ";
for (Node stmt : stmts) {
str += stmt.toPrint(prefix);
}
for (Node stmt : compoundStmts) {
str += stmt.toPrint(prefix);
}
return str;
}
}
|