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/TrailerNode.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/TrailerNode.java')
-rw-r--r-- | src/ast/nodes/TrailerNode.java | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/ast/nodes/TrailerNode.java b/src/ast/nodes/TrailerNode.java index b0a0ee7..aaa72f3 100644 --- a/src/ast/nodes/TrailerNode.java +++ b/src/ast/nodes/TrailerNode.java @@ -11,22 +11,25 @@ import org.antlr.v4.runtime.tree.TerminalNode; * Node for the `trailer` statement of the grammar. */ public class TrailerNode implements Node { - private Node arglist; - private ArrayList<Node> exprs; - private TerminalNode methodCall; - private boolean isEmpty; - public TrailerNode(Node arglist, ArrayList<Node> exprs, TerminalNode methodCall) { + private final Node arglist; + private final ArrayList<Node> exprs; + private final TerminalNode methodCall; + private final boolean isParenthesis; + private final boolean isEmpty; + + public TrailerNode(Node arglist, ArrayList<Node> exprs, TerminalNode methodCall, boolean isParenthesis) { this.arglist = arglist; this.exprs = exprs; this.methodCall = methodCall; + this.isParenthesis = isParenthesis; - this.isEmpty = (this.arglist == null && this.exprs.size() == 0 && this.methodCall == null); + this.isEmpty = (this.arglist == null && this.exprs.isEmpty() && this.methodCall == null); } @Override public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting) { - ArrayList<SemanticError> errors = new ArrayList<SemanticError>(); + ArrayList<SemanticError> errors = new ArrayList(); if (arglist != null) { errors.addAll(arglist.checkSemantics(ST, _nesting)); @@ -39,6 +42,18 @@ public class TrailerNode implements Node { return errors; } + public int getArgumentNumber() { + if (arglist == null) { + return 0; + } + + return ((ArglistNode) arglist).getArgumentNumber(); + } + + public boolean isParenthesis() { + return this.isParenthesis; + } + @Override public Type typeCheck() { return new VoidType(); |