summaryrefslogtreecommitdiff
path: root/src/ast/nodes/ArglistNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast/nodes/ArglistNode.java')
-rw-r--r--src/ast/nodes/ArglistNode.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ast/nodes/ArglistNode.java b/src/ast/nodes/ArglistNode.java
index 71bcdce..cd1a403 100644
--- a/src/ast/nodes/ArglistNode.java
+++ b/src/ast/nodes/ArglistNode.java
@@ -1,15 +1,15 @@
package ast.nodes;
+import ast.types.*;
import java.util.ArrayList;
-
import semanticanalysis.SemanticError;
import semanticanalysis.SymbolTable;
-import ast.types.*;
/**
* Node for the `arglist` statement of the grammar.
*/
public class ArglistNode implements Node {
+
protected ArrayList<Node> arguments;
public ArglistNode(ArrayList<Node> arguments) {
@@ -19,14 +19,14 @@ public class ArglistNode implements Node {
@Override
public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting) {
ArrayList<SemanticError> errors = new ArrayList<SemanticError>();
-
+
for (var arg : arguments) {
ExprNode argExpr = (ExprNode) arg;
String argName = argExpr.getId();
// TODO: check fucking IntType for params
// TODO: remove fucking comments
- if (!ST.top_lookup(argName) && argExpr.typeCheck() instanceof AtomType){
+ if (argName != null && !ST.top_lookup(argName) && argExpr.typeCheck() instanceof AtomType) {
// System.out.println(!(this.typeCheck() instanceof IntType) + " " + !ST.top_lookup(this.getId()));
errors.add(new SemanticError("'" + argName + "' is not defined."));
} else {
@@ -37,6 +37,10 @@ public class ArglistNode implements Node {
return errors;
}
+ public int getArgumentNumber() {
+ return arguments.size();
+ }
+
@Override
public Type typeCheck() {
return new VoidType();