diff options
Diffstat (limited to 'src/ast/nodes/BlockNode.java')
-rw-r--r-- | src/ast/nodes/BlockNode.java | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/ast/nodes/BlockNode.java b/src/ast/nodes/BlockNode.java index 6b07f49..d9a151d 100644 --- a/src/ast/nodes/BlockNode.java +++ b/src/ast/nodes/BlockNode.java @@ -1,16 +1,29 @@ package ast.nodes; -import java.util.ArrayList; - import ast.types.*; +import java.util.ArrayList; +import semanticanalysis.SemanticError; +import semanticanalysis.SymbolTable; /** - * Node for `block` statement of the grammar. - * It extends the `RootNode`. + * 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(); + + // Check semantics for each child + for (Node child : childs) { + errors.addAll(child.checkSemantics(ST, _nesting)); + } + + return errors; } @Override @@ -23,11 +36,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; |