summaryrefslogtreecommitdiff
path: root/src/ast/nodes/BlockNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast/nodes/BlockNode.java')
-rw-r--r--src/ast/nodes/BlockNode.java26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/ast/nodes/BlockNode.java b/src/ast/nodes/BlockNode.java
index 6b07f49..a38b4ea 100644
--- a/src/ast/nodes/BlockNode.java
+++ b/src/ast/nodes/BlockNode.java
@@ -3,17 +3,32 @@ package ast.nodes;
import java.util.ArrayList;
import ast.types.*;
+import semanticanalysis.SemanticError;
+import semanticanalysis.SymbolTable;
/**
* Node for `block` statement of the grammar.
* It extends the `RootNode`.
*/
public class BlockNode extends RootNode {
- public BlockNode(ArrayList<Node> stmts, ArrayList<Node> compoundStmts) {
- super(stmts, compoundStmts);
+ public BlockNode(ArrayList<Node> childs) {
+ super(childs);
}
@Override
+ public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting) {
+ ArrayList<SemanticError> errors = new ArrayList<SemanticError>();
+
+ // Check semantics for each child
+ for (Node child : childs) {
+ errors.addAll(child.checkSemantics(ST, _nesting));
+ }
+
+ return errors;
+ }
+
+
+ @Override
public Type typeCheck() {
return new VoidType();
}
@@ -23,11 +38,8 @@ public class BlockNode extends RootNode {
String str = prefix + "Block\n";
prefix += " ";
- for (Node stmt : stmts) {
- str += stmt.toPrint(prefix);
- }
- for (Node stmt : compoundStmts) {
- str += stmt.toPrint(prefix);
+ for (Node child : childs) {
+ str += child.toPrint(prefix);
}
return str;