Skip to content

Commit c2fe742

Browse files
Merge pull request #30 from UniVE-SSV/program-structure
Program structure
2 parents 3e6d764 + acee195 commit c2fe742

File tree

220 files changed

+7772
-2891
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

220 files changed

+7772
-2891
lines changed

lisa/code-style.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ checkstyleTest {
2222

2323
// only included files will be checked
2424
include 'it/unive/lisa/test/imp/**/*.java'
25+
exclude '**/*Test.java'
2526
}
2627

2728
task checkstyleErrorMessage {
@@ -54,6 +55,7 @@ spotless {
5455
include '**/*.java'
5556
exclude '**/build/generated/**'
5657
exclude '**/build/generated-src/**'
58+
exclude '**/target/generated-sources/**'
5759
}
5860
}
5961
antlr4 {

lisa/imp-testcases/example.imp

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
// this is a line comment
2+
3+
/* while this is a block comment */
4+
5+
/*
6+
* Few characteristics of the IMP language:
7+
* - IMP is dynamically typed, all declarations do not specify typing information
8+
* - IMP has no visibility modifiers (public, private, ...)
9+
* - IMP has no concept of static or final members
10+
*/
11+
12+
/*
13+
* similarly to java, an imp file contains zero or more classes
14+
* whose body is enclosed within braces
15+
*/
16+
class first {}
17+
18+
/*
19+
* an imp class can also have one superclass
20+
*/
21+
class second extends first {}
22+
23+
/*
24+
* the body of a class is a list of fields, constructors and methods
25+
*/
26+
class example {
27+
28+
/*
29+
* fields are declared by just specifying their name
30+
* and do not support in-place initialization
31+
*/
32+
field;
33+
34+
/*
35+
* methods are declared by specifying their name and their parameters
36+
*/
37+
foo1() {}
38+
foo2() {
39+
// void methods can also have explicit return statements
40+
return;
41+
}
42+
foo3(i, j) {
43+
// return statements can return something
44+
return i + j;
45+
}
46+
47+
/*
48+
* methods starting with ~ are constructors and cannot be overridden,
49+
* but you can omit the ~ to invoke them
50+
*/
51+
~example() {
52+
// variable definitions are preceeded by the def keyword
53+
def x = 10;
54+
}
55+
56+
types() {
57+
// 6 types are supported in imp:
58+
// - boolean
59+
// - integer
60+
// - float
61+
// - string
62+
// - reference types defined by the classes
63+
// - arrays of the types above
64+
}
65+
66+
expressions(e1, e2) {
67+
// an expression can be:
68+
69+
// 1) a literal
70+
5; "s"; true; null; -5.2;
71+
72+
// 2) an identifier of some sort
73+
this; super; e1;
74+
75+
// 3) a logical operation on other expressions
76+
!e1; e1 && e2; e1 || e2;
77+
78+
// 4) an arithmetic expression
79+
-e1; e1 + e2; e1 - e2; e1 / e2; e1 % e2;
80+
// + can also be used to join strings!
81+
82+
// 5) a comparison
83+
e1 > e2; e1 >= e2; e1 < e2; e1 <= e2; e1 == e2; e1 != e2;
84+
85+
// 6) an array creation
86+
def intArray = new int[5];
87+
new float[5]; new boolean[5]; new example[5];
88+
89+
// 7) an object creation
90+
def obj = new example(); // as method calls, constructor calls can also recieve parameters
91+
92+
// 8) an access to an array element
93+
// only arrays stored in variables or parameters are supported
94+
intArray[2];
95+
96+
// 9) a field access
97+
// the receiver must always be explicit (this, super or a variable/parameter)
98+
this.field;
99+
obj.field;
100+
101+
// 10) a method call
102+
// the receiver must always be explicit (this, super or a variable/parameter)
103+
obj.foo();
104+
obj.foo3(5, 3);
105+
// arguments of calls can be:
106+
// - literals
107+
// - variables
108+
// - this
109+
// - a field access
110+
// - an array access
111+
// - another method call
112+
113+
// all expressions can also be grouped between parenthesis!
114+
}
115+
116+
// methods can be final to avoid overriding by subclasses
117+
final statements(x) {
118+
// each line must end with a semicolon!
119+
120+
// variable definitions are preceeded by the def keyword
121+
// scoping of variables is the same as java
122+
def y = 10;
123+
124+
// assignments can be performed by assigning an expression to:
125+
// - variables
126+
// - fields (through field accesses)
127+
// - array elements (through array accesses)
128+
129+
// conditional execution
130+
if (y != 5) {
131+
return y;
132+
} else {
133+
y = y + 1;
134+
}
135+
136+
if (x != y)
137+
// braces can also be omitted in case of a single instuction
138+
return y;
139+
// the else branch is optional and can be entirely omitted
140+
141+
// loops
142+
// as with conditional executions, braces are not required if the body
143+
// of the loop contains a single instruction
144+
while (y < 100)
145+
y = y * 2;
146+
for (def i = 0; i < 20; i = i + 1)
147+
y = y % 5;
148+
149+
// you can throw any object to raise errors
150+
throw new example();
151+
def ex = new example();
152+
throw ex;
153+
154+
// you can write assertions
155+
assert y == 10;
156+
}
157+
}

lisa/imp-testcases/numeric/int-const/analysis___untyped_div(untyped_i,_untyped_j).dot

Lines changed: 0 additions & 17 deletions
This file was deleted.

lisa/imp-testcases/numeric/int-const/analysis___untyped_constants().dot renamed to lisa/imp-testcases/numeric/int-const/analysis___untyped_tutorial.constants().dot

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
digraph {
22
"node0" [shape="rect",color="black",label=<c = 1<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$c: 1 ]]<BR/>}} -&gt; [vid$c]>];
3-
"node1" [shape="rect",color="gray",label=<&lt;(b, 10)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$b: TOP<BR/>vid$c: 1 ]]<BR/>}} -&gt; [vid$b &lt; 10]>];
4-
"node2" [shape="rect",color="gray",label=<b = +(b, c)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$b: TOP<BR/>vid$c: 1 ]]<BR/>}} -&gt; [vid$b]>];
5-
"node3" [shape="rect",color="black",peripheries="2",label=<return b<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$b: TOP<BR/>vid$c: 1<BR/>vid$ret_value@constants: TOP ]]<BR/>}} -&gt; [vid$ret_value@constants]>];
3+
"node1" [shape="rect",color="gray",label=<b = +(b, c)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$b: TOP<BR/>vid$c: 1 ]]<BR/>}} -&gt; [vid$b]>];
4+
"node2" [shape="rect",color="black",peripheries="2",label=<return b<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$ret_value@constants: TOP ]]<BR/>}} -&gt; [vid$ret_value@constants]>];
5+
"node3" [shape="rect",color="gray",label=<&lt;(b, 10)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$b: TOP<BR/>vid$c: 1 ]]<BR/>}} -&gt; [vid$b &lt; 10]>];
66
"node4" [shape="rect",color="gray",label=<b = 0<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$b: 0<BR/>vid$c: 1 ]]<BR/>}} -&gt; [vid$b]>];
7-
"node1" -> "node2" [color="blue",style="dashed"];
8-
"node1" -> "node3" [color="red",style="dashed"];
9-
"node2" -> "node1" [color="black"];
7+
"node1" -> "node3" [color="black"];
108
"node0" -> "node4" [color="black"];
11-
"node4" -> "node1" [color="black"];
9+
"node3" -> "node1" [color="blue",style="dashed"];
10+
"node3" -> "node2" [color="red",style="dashed"];
11+
"node4" -> "node3" [color="black"];
1212
subgraph cluster_legend {
1313
label="Legend";
1414
style=dotted;

lisa/imp-testcases/numeric/int-const/analysis___untyped_ub_example(untyped_y,_untyped_z).dot renamed to lisa/imp-testcases/numeric/int-const/analysis___untyped_tutorial.div(untyped_i,_untyped_j).dot

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
digraph {
2-
"node0" [shape="rect",color="black",label=<&lt;(y, z)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ TOP ]]<BR/>}} -&gt; [vid$y &lt; vid$z]>];
3-
"node1" [shape="rect",color="black",peripheries="2",label=<return x<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$x: TOP<BR/>vid$ret_value@ub_example: TOP ]]<BR/>}} -&gt; [vid$ret_value@ub_example]>];
4-
"node2" [shape="rect",color="gray",label=<x = -(z, 1)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$x: TOP ]]<BR/>}} -&gt; [vid$x]>];
5-
"node3" [shape="rect",color="gray",label=<x = -(y, 1)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$x: TOP ]]<BR/>}} -&gt; [vid$x]>];
2+
"node0" [shape="rect",color="black",label=<!=(j, 0)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$i: TOP<BR/>vid$j: TOP ]]<BR/>}} -&gt; [vid$j != 0]>];
3+
"node1" [shape="rect",color="black",peripheries="2",label=<return i<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$i: TOP<BR/>vid$j: TOP<BR/>vid$ret_value@div: TOP ]]<BR/>}} -&gt; [vid$ret_value@div]>];
4+
"node2" [shape="rect",color="gray",label=<i = /(i, j)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$i: TOP<BR/>vid$j: TOP ]]<BR/>}} -&gt; [vid$i]>];
5+
"node3" [shape="rect",color="gray",label=<i = /(j, i)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$i: TOP<BR/>vid$j: TOP ]]<BR/>}} -&gt; [vid$i]>];
66
"node2" -> "node1" [color="black"];
77
"node3" -> "node1" [color="black"];
8-
"node0" -> "node2" [color="red",style="dashed"];
9-
"node0" -> "node3" [color="blue",style="dashed"];
8+
"node0" -> "node2" [color="blue",style="dashed"];
9+
"node0" -> "node3" [color="red",style="dashed"];
1010
subgraph cluster_legend {
1111
label="Legend";
1212
style=dotted;

lisa/imp-testcases/numeric/interval/analysis___untyped_gcd(untyped_a,_untyped_b).dot renamed to lisa/imp-testcases/numeric/int-const/analysis___untyped_tutorial.gcd(untyped_a,_untyped_b).dot

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
digraph {
2-
"node0" [shape="rect",color="black",label=<!=(a, b)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ TOP ]]<BR/>}} -&gt; [vid$a != vid$b]>];
3-
"node1" [shape="rect",color="gray",label=<b = -(b, a)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$b: TOP ]]<BR/>}} -&gt; [vid$b]>];
4-
"node2" [shape="rect",color="gray",label=<&gt;(a, b)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ TOP ]]<BR/>}} -&gt; [vid$a &gt; vid$b]>];
5-
"node3" [shape="rect",color="gray",label=<a = -(a, b)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$a: TOP ]]<BR/>}} -&gt; [vid$a]>];
6-
"node4" [shape="rect",color="black",peripheries="2",label=<return a<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$ret_value@gcd: TOP ]]<BR/>}} -&gt; [vid$ret_value@gcd]>];
2+
"node0" [shape="rect",color="black",label=<!=(a, b)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$a: TOP<BR/>vid$b: TOP ]]<BR/>}} -&gt; [vid$a != vid$b]>];
3+
"node1" [shape="rect",color="gray",label=<a = -(a, b)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$a: TOP<BR/>vid$b: TOP ]]<BR/>}} -&gt; [vid$a]>];
4+
"node2" [shape="rect",color="black",peripheries="2",label=<return a<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$a: TOP<BR/>vid$b: TOP<BR/>vid$ret_value@gcd: TOP ]]<BR/>}} -&gt; [vid$ret_value@gcd]>];
5+
"node3" [shape="rect",color="gray",label=<b = -(b, a)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$a: TOP<BR/>vid$b: TOP ]]<BR/>}} -&gt; [vid$b]>];
6+
"node4" [shape="rect",color="gray",label=<&gt;(a, b)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$a: TOP<BR/>vid$b: TOP ]]<BR/>}} -&gt; [vid$a &gt; vid$b]>];
77
"node1" -> "node0" [color="black"];
8-
"node2" -> "node1" [color="red",style="dashed"];
9-
"node2" -> "node3" [color="blue",style="dashed"];
108
"node3" -> "node0" [color="black"];
11-
"node0" -> "node2" [color="blue",style="dashed"];
12-
"node0" -> "node4" [color="red",style="dashed"];
9+
"node0" -> "node2" [color="red",style="dashed"];
10+
"node0" -> "node4" [color="blue",style="dashed"];
11+
"node4" -> "node1" [color="blue",style="dashed"];
12+
"node4" -> "node3" [color="red",style="dashed"];
1313
subgraph cluster_legend {
1414
label="Legend";
1515
style=dotted;

lisa/imp-testcases/numeric/int-const/analysis___untyped_intv_dec().dot renamed to lisa/imp-testcases/numeric/int-const/analysis___untyped_tutorial.intv_dec().dot

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
digraph {
22
"node0" [shape="rect",color="black",label=<i = 1000<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$i: 1000 ]]<BR/>}} -&gt; [vid$i]>];
3-
"node1" [shape="rect",color="black",peripheries="2",label=<return i<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$ret_value@intv_dec: TOP<BR/>vid$i: TOP ]]<BR/>}} -&gt; [vid$ret_value@intv_dec]>];
4-
"node2" [shape="rect",color="gray",label=<&gt;(i, 0)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$i: TOP ]]<BR/>}} -&gt; [vid$i &gt; 0]>];
3+
"node1" [shape="rect",color="gray",label=<&gt;(i, 0)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$i: TOP ]]<BR/>}} -&gt; [vid$i &gt; 0]>];
4+
"node2" [shape="rect",color="black",peripheries="2",label=<return i<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$ret_value@intv_dec: TOP ]]<BR/>}} -&gt; [vid$ret_value@intv_dec]>];
55
"node3" [shape="rect",color="gray",label=<i = -(i, 1)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$i: TOP ]]<BR/>}} -&gt; [vid$i]>];
6-
"node0" -> "node2" [color="black"];
7-
"node2" -> "node1" [color="red",style="dashed"];
8-
"node2" -> "node3" [color="blue",style="dashed"];
9-
"node3" -> "node2" [color="black"];
6+
"node0" -> "node1" [color="black"];
7+
"node1" -> "node2" [color="red",style="dashed"];
8+
"node1" -> "node3" [color="blue",style="dashed"];
9+
"node3" -> "node1" [color="black"];
1010
subgraph cluster_legend {
1111
label="Legend";
1212
style=dotted;

lisa/imp-testcases/numeric/int-const/analysis___untyped_sign_parity_example().dot renamed to lisa/imp-testcases/numeric/int-const/analysis___untyped_tutorial.sign_parity_example().dot

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
digraph {
22
"node0" [shape="rect",color="black",label=<i = 2<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$i: 2 ]]<BR/>}} -&gt; [vid$i]>];
3-
"node1" [shape="rect",color="black",peripheries="2",label=<return i<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$ret_value@sign_parity_example: TOP<BR/>vid$max: 10<BR/>vid$i: TOP ]]<BR/>}} -&gt; [vid$ret_value@sign_parity_example]>];
4-
"node2" [shape="rect",color="gray",label=<max = 10<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$i: 2<BR/>vid$max: 10 ]]<BR/>}} -&gt; [vid$max]>];
3+
"node1" [shape="rect",color="gray",label=<max = 10<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$i: 2<BR/>vid$max: 10 ]]<BR/>}} -&gt; [vid$max]>];
4+
"node2" [shape="rect",color="gray",label=<i = +(i, 1)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$max: 10<BR/>vid$i: TOP ]]<BR/>}} -&gt; [vid$i]>];
55
"node3" [shape="rect",color="gray",label=<&lt;(i, max)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$max: 10<BR/>vid$i: TOP ]]<BR/>}} -&gt; [vid$i &lt; vid$max]>];
6-
"node4" [shape="rect",color="gray",label=<i = +(i, 1)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$max: 10<BR/>vid$i: TOP ]]<BR/>}} -&gt; [vid$i]>];
6+
"node4" [shape="rect",color="black",peripheries="2",label=<return i<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$ret_value@sign_parity_example: TOP ]]<BR/>}} -&gt; [vid$ret_value@sign_parity_example]>];
7+
"node0" -> "node1" [color="black"];
8+
"node1" -> "node3" [color="black"];
79
"node2" -> "node3" [color="black"];
8-
"node3" -> "node1" [color="red",style="dashed"];
9-
"node3" -> "node4" [color="blue",style="dashed"];
10-
"node0" -> "node2" [color="black"];
11-
"node4" -> "node3" [color="black"];
10+
"node3" -> "node2" [color="blue",style="dashed"];
11+
"node3" -> "node4" [color="red",style="dashed"];
1212
subgraph cluster_legend {
1313
label="Legend";
1414
style=dotted;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
digraph {
2+
"node0" [shape="rect",color="black",label=<x = 0<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$y: TOP<BR/>vid$z: TOP<BR/>vid$x: 0 ]]<BR/>}} -&gt; [vid$x]>];
3+
"node1" [shape="rect",color="gray",label=<&lt;(y, z)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$y: TOP<BR/>vid$z: TOP<BR/>vid$x: 0 ]]<BR/>}} -&gt; [vid$y &lt; vid$z]>];
4+
"node2" [shape="rect",color="black",peripheries="2",label=<return x<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$y: TOP<BR/>vid$z: TOP<BR/>vid$ret_value@ub_example: TOP ]]<BR/>}} -&gt; [vid$ret_value@ub_example]>];
5+
"node3" [shape="rect",color="gray",label=<x = -(y, 1)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$y: TOP<BR/>vid$z: TOP<BR/>vid$x: TOP ]]<BR/>}} -&gt; [vid$x]>];
6+
"node4" [shape="rect",color="gray",label=<x = -(z, 1)<BR/>{{<BR/>heap [[ monolith ]]<BR/>value [[ vid$y: TOP<BR/>vid$z: TOP<BR/>vid$x: TOP ]]<BR/>}} -&gt; [vid$x]>];
7+
"node1" -> "node3" [color="blue",style="dashed"];
8+
"node1" -> "node4" [color="red",style="dashed"];
9+
"node0" -> "node1" [color="black"];
10+
"node3" -> "node2" [color="black"];
11+
"node4" -> "node2" [color="black"];
12+
subgraph cluster_legend {
13+
label="Legend";
14+
style=dotted;
15+
node [shape=plaintext];
16+
"legend" [label=<<table border="0" cellpadding="2" cellspacing="0" cellborder="0"><tr><td align="right">node border&nbsp;</td><td align="left"><font color="gray">gray</font>, single</td></tr><tr><td align="right">entrypoint border&nbsp;</td><td align="left"><font color="black">black</font>, single</td></tr><tr><td align="right">exitpoint border&nbsp;</td><td align="left"><font color="black">black</font>, double</td></tr><tr><td align="right">sequential edge&nbsp;</td><td align="left"><font color="black">black</font>, solid</td></tr><tr><td align="right">true edge&nbsp;</td><td align="left"><font color="blue">blue</font>, dashed</td></tr><tr><td align="right">false edge&nbsp;</td><td align="left"><font color="red">red</font>, dashed</td></tr></table>>];
17+
}
18+
19+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"warnings" : [ ],
3-
"files" : [ "analysis___untyped_constants().dot", "analysis___untyped_div(untyped_i,_untyped_j).dot", "analysis___untyped_gcd(untyped_a,_untyped_b).dot", "analysis___untyped_intv_dec().dot", "analysis___untyped_sign_parity_example().dot", "analysis___untyped_ub_example(untyped_y,_untyped_z).dot" ]
3+
"files" : [ "analysis___untyped_tutorial.constants().dot", "analysis___untyped_tutorial.div(untyped_i,_untyped_j).dot", "analysis___untyped_tutorial.gcd(untyped_a,_untyped_b).dot", "analysis___untyped_tutorial.intv_dec().dot", "analysis___untyped_tutorial.sign_parity_example().dot", "analysis___untyped_tutorial.ub_example(untyped_y,_untyped_z).dot" ]
44
}

0 commit comments

Comments
 (0)