diff options
author | Santo Cariotti <santo@dcariotti.me> | 2024-06-30 13:45:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-30 13:45:57 +0200 |
commit | 8aa8b5834953cab15c0687608f4fafea2e6c61be (patch) | |
tree | 1835ae7c789136b4a6c44c12efd4247a0b96d893 /src/ast/nodes/CompIterNode.java | |
parent | 7125bb27fedaafd5a56b5122e4251b182448ddac (diff) | |
parent | 06d7c8dee25c065b1a569337f34d3cd5e892a31d (diff) |
Merge pull request #10 from boozec/check-semantics
Co-Authored-By: geno <gabriele.genovese2@studio.unibo.it>
Co-Authored-By: L0P0P <grassoemanuele@live.com>
Diffstat (limited to 'src/ast/nodes/CompIterNode.java')
-rw-r--r-- | src/ast/nodes/CompIterNode.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/ast/nodes/CompIterNode.java b/src/ast/nodes/CompIterNode.java new file mode 100644 index 0000000..8de9f2f --- /dev/null +++ b/src/ast/nodes/CompIterNode.java @@ -0,0 +1,50 @@ +package ast.nodes; + +import ast.types.*; +import java.util.ArrayList; +import semanticanalysis.SemanticError; +import semanticanalysis.SymbolTable; + +/** + * Node for the `comp_iter` statement of the grammar. + */ +public class CompIterNode implements Node { + + protected CompForNode comp_for; + // protected CompIfNode compIfNode; + + public CompIterNode(Node comp_for) { + this.comp_for = (CompForNode) comp_for; + } + + @Override + public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting) { + ArrayList<SemanticError> errors = new ArrayList(); + + if (comp_for != null) { + errors.addAll(comp_for.checkSemantics(ST, _nesting)); + } + return errors; + } + + @Override + public Type typeCheck() { + return new VoidType(); + } + + // TODO: add code generation for arglist node + @Override + public String codeGeneration() { + return ""; + } + + @Override + public String toPrint(String prefix) { + String str = prefix + "CompIterNode\n"; + + prefix += " "; + str += comp_for.toPrint(prefix); + return str; + } + +} |