From f0692ff5f9e39cbd1c203e9d5abebf55a3d0f6fc Mon Sep 17 00:00:00 2001 From: Emanuele Grasso <96300448+L0P0P@users.noreply.github.com> Date: Sat, 6 Jul 2024 09:47:25 +0200 Subject: Fixed the print of the ast and some warnings (#19) Co-authored-by: Santo Cariotti --- src/ast/nodes/ExprNode.java | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/ast/nodes/ExprNode.java') diff --git a/src/ast/nodes/ExprNode.java b/src/ast/nodes/ExprNode.java index 873d537..693176a 100644 --- a/src/ast/nodes/ExprNode.java +++ b/src/ast/nodes/ExprNode.java @@ -52,7 +52,7 @@ public class ExprNode implements Node { @Override public ArrayList checkSemantics(SymbolTable ST, int _nesting) { - ArrayList errors = new ArrayList(); + ArrayList errors = new ArrayList<>(); // check if the atom is a function if (atom != null && !trailers.isEmpty()) { @@ -130,19 +130,22 @@ public class ExprNode implements Node { if (atom != null) { str += atom.toPrint(prefix); } - if (compOp != null) { str += compOp.toPrint(prefix); } - - for (var expr : exprs) { - str = expr.toPrint(prefix); - } - - for (var trailer : trailers) { - str = trailer.toPrint(prefix); + + if (exprs != null) { + for (var expr : exprs) { + str += expr.toPrint(prefix); + } } - + + if (trailers != null) { + for (var trailer : trailers) { + str += trailer.toPrint(prefix); + } + } + if (op != null) { str += prefix + "Op(" + op + ")\n"; } -- cgit v1.2.3-18-g5258