From 3c4229fc9e0ec6da9a7f60b57b9e93c49d1b6b6c Mon Sep 17 00:00:00 2001 From: L0P0P Date: Thu, 27 Jun 2024 12:02:35 +0200 Subject: Fixed a lot of problems from all the progs we need to parse --- src/ast/nodes/ImportNode.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/ast/nodes/ImportNode.java') diff --git a/src/ast/nodes/ImportNode.java b/src/ast/nodes/ImportNode.java index e264c99..900a909 100644 --- a/src/ast/nodes/ImportNode.java +++ b/src/ast/nodes/ImportNode.java @@ -29,12 +29,24 @@ public class ImportNode implements Node { public ArrayList checkSemantics(SymbolTable ST, int _nesting) { ArrayList errors = new ArrayList(); + if (isFrom) { + for (int i = 0; i < names.size(); ++i) { + ST.insert(names.get(i), this.typeCheck(), _nesting, null); + } + } else { + errors.addAll(dottedName.checkSemantics(ST, _nesting)); + } + + if (importAs) { + ST.insert(names.get(names.size() - 1), this.typeCheck(), _nesting, null); + } + return errors; } @Override public Type typeCheck() { - return new VoidType(); + return new ImportType(); } // NOTE: we do not want to provide a code generation for this statement -- cgit v1.2.3-18-g5258