summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgeno <gabriele.genovese2@studio.unibo.it>2024-06-26 18:23:05 +0200
committergeno <gabriele.genovese2@studio.unibo.it>2024-06-26 18:23:05 +0200
commitfb89b8c0885ee4e289cfb577bbabf0ee66b05024 (patch)
tree6c7bdc2349a22ee5b8c8cbb1c077832d4582ff3b
parent06671f5aed68753435a762bc3be43e83094156d1 (diff)
test dir added, fix bug in ExprNode (added by myself obv)
-rw-r--r--progs/test.py2
-rw-r--r--progs/test2.py6
-rw-r--r--src/Main.java2
-rw-r--r--src/ast/nodes/ExprNode.java2
-rw-r--r--test/1a.py8
-rw-r--r--test/1b.py6
-rw-r--r--test/1c.py5
7 files changed, 22 insertions, 9 deletions
diff --git a/progs/test.py b/progs/test.py
deleted file mode 100644
index f9140c6..0000000
--- a/progs/test.py
+++ /dev/null
@@ -1,2 +0,0 @@
-def unibo(a):
- unibo(a)
diff --git a/progs/test2.py b/progs/test2.py
deleted file mode 100644
index 9c1318d..0000000
--- a/progs/test2.py
+++ /dev/null
@@ -1,6 +0,0 @@
-x = 2 ; y = 3
-
-def f(x, y):
- return x+y
-
-print(f(5,3,1)+ x + y)
diff --git a/src/Main.java b/src/Main.java
index 121d3d1..21645db 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -20,7 +20,7 @@ public class Main {
try {
// String fileStr = file.getPath();
// FIXME: use the fileStr above
- String fileStr = "./progs/test2.py";
+ String fileStr = "./test/1a.py";
System.out.println(fileStr);
System.out.println(readFile(fileStr));
CharStream cs = CharStreams.fromFileName(fileStr);
diff --git a/src/ast/nodes/ExprNode.java b/src/ast/nodes/ExprNode.java
index eea69f8..4fbe166 100644
--- a/src/ast/nodes/ExprNode.java
+++ b/src/ast/nodes/ExprNode.java
@@ -132,6 +132,8 @@ public class ExprNode implements Node {
errors.addAll(trailer.checkSemantics(ST, _nesting));
}
}
+ } else if (atom != null) {
+ errors.addAll(atom.checkSemantics(ST, _nesting));
}
if (compOp != null) {
diff --git a/test/1a.py b/test/1a.py
new file mode 100644
index 0000000..69b3dc5
--- /dev/null
+++ b/test/1a.py
@@ -0,0 +1,8 @@
+
+x = 2
+y = z
+
+def f(x, y):
+ return x + y
+
+print(f(5, 3) + x + y)
diff --git a/test/1b.py b/test/1b.py
new file mode 100644
index 0000000..a8324a0
--- /dev/null
+++ b/test/1b.py
@@ -0,0 +1,6 @@
+x = 2 ; y = 3
+
+def f(x, x):
+ return x+y
+
+print(f(5,3)+ x + y)
diff --git a/test/1c.py b/test/1c.py
new file mode 100644
index 0000000..59e51e5
--- /dev/null
+++ b/test/1c.py
@@ -0,0 +1,5 @@
+
+def mult(a, b):
+ return a * b
+
+print(mult(3, 2, 4))