summaryrefslogtreecommitdiff
path: root/src/ast/nodes/AssignmentNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast/nodes/AssignmentNode.java')
-rw-r--r--src/ast/nodes/AssignmentNode.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/ast/nodes/AssignmentNode.java b/src/ast/nodes/AssignmentNode.java
index 3d597ef..07966c3 100644
--- a/src/ast/nodes/AssignmentNode.java
+++ b/src/ast/nodes/AssignmentNode.java
@@ -10,14 +10,14 @@ import semanticanalysis.SymbolTable;
*/
public class AssignmentNode implements Node {
- private ExprNode lhr;
+ private ExprListNode lhr;
private Node assign;
- private ExprNode rhr;
+ private ExprListNode rhr;
public AssignmentNode(Node lhr, Node assign, Node rhr) {
- this.lhr = (ExprNode) lhr;
+ this.lhr = (ExprListNode) lhr;
this.assign = assign;
- this.rhr = (ExprNode) rhr;
+ this.rhr = (ExprListNode) rhr;
}
@Override
@@ -28,7 +28,18 @@ public class AssignmentNode implements Node {
errors.addAll(assign.checkSemantics(ST, _nesting));
errors.addAll(rhr.checkSemantics(ST, _nesting));
- ST.insert(lhr.getId(), rhr.typeCheck(), _nesting, "");
+ int lsize = lhr.getSize();
+ int rsize = rhr.getSize();
+
+ if (lsize == rsize) {
+ for (int i = 0; i < lsize; i++) {
+ ExprNode latom = (ExprNode) lhr.getElem(i);
+ ExprNode ratom = (ExprNode) rhr.getElem(i);
+ ST.insert(latom.getId(), ratom.typeCheck(), _nesting, "");
+ }
+ } else {
+ errors.add(new SemanticError("ValueError: different size of left or right side assignment"));
+ }
return errors;
}