summaryrefslogtreecommitdiff
path: root/src/ast/nodes/ExprListNode.java
diff options
context:
space:
mode:
authorgeno <gabriele.genovese2@studio.unibo.it>2024-06-27 18:20:34 +0200
committergeno <gabriele.genovese2@studio.unibo.it>2024-06-27 18:20:34 +0200
commiteb7fb04d2dfadd004fa86f28da42681e0038df06 (patch)
tree1bba3962300083017673c5d689a5d2bf1652109d /src/ast/nodes/ExprListNode.java
parent095a2cb4e9abb88805aac3271874bc512108ff96 (diff)
left, right = 1, 2 assignment covered
sfaccimm ho fatto refactoring dell exprlist
Diffstat (limited to 'src/ast/nodes/ExprListNode.java')
-rw-r--r--src/ast/nodes/ExprListNode.java61
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;
+ }
+
+}