diff options
Diffstat (limited to 'src/ast/nodes/ExprListNode.java')
-rw-r--r-- | src/ast/nodes/ExprListNode.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/ast/nodes/ExprListNode.java b/src/ast/nodes/ExprListNode.java new file mode 100644 index 0000000..c1a2ebc --- /dev/null +++ b/src/ast/nodes/ExprListNode.java @@ -0,0 +1,61 @@ +package ast.nodes; + +import ast.types.*; +import java.util.ArrayList; +import semanticanalysis.SemanticError; +import semanticanalysis.SymbolTable; + +/** + * Node for the `expr_list` statement of the grammar. + */ +public class ExprListNode implements Node { + + private final ArrayList<Node> exprs; + + public ExprListNode(ArrayList<Node> _exprs) { + this.exprs = _exprs; + } + + @Override + public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting) { + ArrayList<SemanticError> errors = new ArrayList(); + + for (var param : exprs) { + errors.addAll(param.checkSemantics(ST, _nesting)); + } + + return errors; + } + + public int getSize() { + return exprs.size(); + } + + public Node getElem(int i) { + return exprs.get(i); + } + + @Override + public Type typeCheck() { + return new VoidType(); + } + + // TODO: code generation for expr list + @Override + public String codeGeneration() { + return ""; + } + + @Override + public String toPrint(String prefix) { + String str = prefix + "Paramlist\n"; + + prefix += " "; + for (var param : exprs) { + str += param.toPrint(prefix); + } + + return str; + } + +} |