-
Notifications
You must be signed in to change notification settings - Fork 3
/
BuggyParserInput.mj
41 lines (40 loc) · 967 Bytes
/
BuggyParserInput.mj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Test input for the MicroJava parser
//***************************************************
// invoke as: java MJ.TestParser BuggyParserInput.mj
//***************************************************
program P
final int size = 10;
class Table
//------------| "{" expected
int[] pos;
int[] neg
//-----------| ";" expected
}
Table val;
{
void main()
int x, i;
{ val := new Table;
//------| invalid assignment or call
val.pos = new int[size); val.neg = new int[size];
//------------------------| "]" expected
i = 0;
while i < size {
//--------| "(" expected
//----------------| ")" expected
val.pos[i] = 0; val.neg[i] = 0;
i = i + 1;
}
x = read();
//------| invalid expression
while (x != 0) {
if (x >= 0) {
val.pos[x] = val pos[x] + 1;
//----------------------| incompatible type in assigment
} else if (x < 0) {
val.neg[-x] = val.neg[-x] + 1;
}
read(x);
}
}
}