diff options
author | L0P0P <grassoemanuele@live.com> | 2024-06-26 11:44:58 +0200 |
---|---|---|
committer | L0P0P <grassoemanuele@live.com> | 2024-06-26 11:44:58 +0200 |
commit | 9e6c17cb44bc165e315ec039a0e09183716d2037 (patch) | |
tree | 4a64fd37fa9b2483b88a5f33a37c6b9b51812d81 /src/ast/nodes/ExprNode.java | |
parent | fc712f94a7ed8554d8d44f4965be367354a7e670 (diff) |
Semantic check for function declaration and function invocation
Diffstat (limited to 'src/ast/nodes/ExprNode.java')
-rw-r--r-- | src/ast/nodes/ExprNode.java | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/src/ast/nodes/ExprNode.java b/src/ast/nodes/ExprNode.java index 344f3c0..4bb67f7 100644 --- a/src/ast/nodes/ExprNode.java +++ b/src/ast/nodes/ExprNode.java @@ -106,30 +106,23 @@ public class ExprNode implements Node { @Override public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting) { ArrayList<SemanticError> errors = new ArrayList<SemanticError>(); - if (atom != null && !trailers.isEmpty()) { - // function call - if (!Arrays.asList(bif).contains(atom.getId())) { - errors.addAll(atom.checkSemantics(ST, _nesting)); - } - } else { - // butto tutto quello che c'era prima nell'else così non rischio di perdere niente di utile - if (atom != null) { - errors.addAll(atom.checkSemantics(ST, _nesting)); - } - - if (compOp != null) { - errors.addAll(compOp.checkSemantics(ST, _nesting)); - } - - for (var expr : exprs) { - errors.addAll(expr.checkSemantics(ST, _nesting)); - } - + + if (atom != null && !Arrays.asList(bif).contains(atom.getId())) { + errors.addAll(atom.checkSemantics(ST, _nesting)); + for (var trailer : trailers) { errors.addAll(trailer.checkSemantics(ST, _nesting)); } } + + if (compOp != null) { + errors.addAll(compOp.checkSemantics(ST, _nesting)); + } + for (var expr : exprs) { + errors.addAll(expr.checkSemantics(ST, _nesting)); + } + return errors; } |