Files
compilers/5LAB/ErrorTest.decaf
T

49 lines
1.1 KiB
Plaintext

// This test should have errors.
// comment them out until you have no errors
extern func print_int(int) void;
extern func print_string(string) void;
package foo {
var x int;
var A[100] bool;
func foo(x int) void { { var x int; }
while ( x <= y )
{
x = 1 + 2 - 3 * 4 / 6 % 7 && 8 || ! f(); // operators
return(3);
return(b); // where b was declared as "var b bool;"
return();
return;
break;
continue;
if (a < b)
{ a = a << b >> c;}
if (a < b)
{ a = a << b >> c;
c = "hello "; } // string
else
{ print_string("hello"); }
}
}
func main() int { foo(1);
for ( i=1,j=2; i <= k; i=i+1, j=j+2) // for loop
{
var x,y,z int;
var x,y,z bool;
i = print_int(i);
x = 0xBad0FF; // HEX
}
}
} // end of package foo