Skip to content

Commit afd01af

Browse files
committed
complete grammar [test]
1 parent a41922c commit afd01af

1 file changed

Lines changed: 26 additions & 59 deletions

File tree

MJCompiler/test/program.mj

Lines changed: 26 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,37 @@
1-
//Test 302
2-
3-
program test302
4-
5-
const int jedan = 1;
6-
7-
int i;
8-
bool ibool;
9-
10-
int niz2;
11-
12-
record Test {
13-
int niz[];
14-
int a;
15-
}
1+
program Program
2+
class A{int x[],y[];}
3+
const int pi = 3, e = 2;
4+
5+
class B extends A {
6+
int i;
7+
{
8+
int getValue(int a) int b; bool c;{ return this.i + this.x[0] + a; }
9+
void m(){}
10+
}
11+
}
1612

17-
Test t1, t2;
13+
class C extends B{A theA;int a;}
1814

1915
{
20-
21-
int sum(int z, int d)
22-
{
23-
return z + d;
24-
}
25-
26-
int inkrement(int a, int inc)
27-
int pom;
28-
{
29-
if(inc == jedan) pom = 1;
30-
else if(inc == 2) pom = a;
16+
void main() A a; C c; int i; int x[]; char ch; {
17+
a = new A;
18+
a.x = new int[5]; a.y = new int[5];
3119

32-
return sum(a,pom);
33-
}
34-
35-
bool verify() {
36-
print('v');
37-
return false;
38-
}
39-
40-
void main() int x;
41-
{
20+
c = new C;
21+
c.theA = a; c.x = new int[5];
4222

43-
if(1!=1) print(-6);
44-
else print(0);
45-
46-
ibool = false;
23+
x = new int[3];
24+
read(c.i);
4725
i = 0;
4826
do{
49-
if(i == 2) ibool = true;
27+
28+
read(c.x[i]); read(c.theA.x[i]);
5029
i++;
51-
}while(i < 5);
52-
53-
if(ibool)
54-
if(i == 5) print(1);
55-
else print(-1);
56-
t1 = new Test;
57-
t1.a = 2;
58-
t1.niz = new int[3];
59-
t1.niz[0] = 1 * t1.a;
60-
t1.niz[1] = 2 * t1.a;
61-
t1.niz[2] = sum(t1.niz[1], t1.niz[0]) * t1.a + 1;
62-
if(verify() || t1.niz[2] == 4) print(ord('A'));
63-
else print(ord('a'));
30+
31+
}while(i<5);
6432

65-
print(eol);
66-
i = 0;
33+
print(c.getValue(c.theA.x[0]));
6734

35+
c.m();
6836
}
69-
}
70-
37+
}

0 commit comments

Comments
 (0)