From 9e6c17cb44bc165e315ec039a0e09183716d2037 Mon Sep 17 00:00:00 2001 From: L0P0P Date: Wed, 26 Jun 2024 11:44:58 +0200 Subject: Semantic check for function declaration and function invocation --- src/ast/nodes/AtomNode.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/ast/nodes/AtomNode.java') diff --git a/src/ast/nodes/AtomNode.java b/src/ast/nodes/AtomNode.java index 0a3c765..0704bc4 100644 --- a/src/ast/nodes/AtomNode.java +++ b/src/ast/nodes/AtomNode.java @@ -25,10 +25,13 @@ public class AtomNode implements Node { @Override public ArrayList checkSemantics(SymbolTable ST, int _nesting) { var errors = new ArrayList(); - // System.out.println("[ATOM] id: " + getId() + " ns: " + _nesting + " top_lookup" + ST.top_lookup(this.getId())); - if ((this.typeCheck() instanceof AtomType) && ST.nslookup(this.getId()) < 0) { + + // Print the symbol table + System.out.println(ST); + + if ((this.typeCheck() instanceof AtomType) && !ST.top_lookup(this.getId())/*ST.nslookup(this.getId()) < 0*/) { // System.out.println(!(this.typeCheck() instanceof IntType) + " " + !ST.top_lookup(this.getId())); - errors.add(new SemanticError("Undefined name `" + this.getId() + "`")); + errors.add(new SemanticError("'" + this.getId() + "' is not defined.")); } return errors; -- cgit v1.2.3-18-g5258