add: sysy functional test sets.
This commit is contained in:
parent
852dbc824c
commit
58e1e9c62c
1
sysy_sets/00_main.out
Executable file
1
sysy_sets/00_main.out
Executable file
|
@ -0,0 +1 @@
|
|||
3
|
3
sysy_sets/00_main.sy
Executable file
3
sysy_sets/00_main.sy
Executable file
|
@ -0,0 +1,3 @@
|
|||
int main(){
|
||||
return 3;
|
||||
}
|
1
sysy_sets/01_var_defn2.out
Executable file
1
sysy_sets/01_var_defn2.out
Executable file
|
@ -0,0 +1 @@
|
|||
10
|
8
sysy_sets/01_var_defn2.sy
Executable file
8
sysy_sets/01_var_defn2.sy
Executable file
|
@ -0,0 +1,8 @@
|
|||
//test domain of global var define and local define
|
||||
int a = 3;
|
||||
int b = 5;
|
||||
|
||||
int main(){
|
||||
int a = 5;
|
||||
return a + b;
|
||||
}
|
1
sysy_sets/02_var_defn3.out
Executable file
1
sysy_sets/02_var_defn3.out
Executable file
|
@ -0,0 +1 @@
|
|||
5
|
8
sysy_sets/02_var_defn3.sy
Executable file
8
sysy_sets/02_var_defn3.sy
Executable file
|
@ -0,0 +1,8 @@
|
|||
//test local var define
|
||||
int main(){
|
||||
int a, b0, _c;
|
||||
a = 1;
|
||||
b0 = 2;
|
||||
_c = 3;
|
||||
return b0 + _c;
|
||||
}
|
1
sysy_sets/03_arr_defn2.out
Executable file
1
sysy_sets/03_arr_defn2.out
Executable file
|
@ -0,0 +1 @@
|
|||
0
|
4
sysy_sets/03_arr_defn2.sy
Executable file
4
sysy_sets/03_arr_defn2.sy
Executable file
|
@ -0,0 +1,4 @@
|
|||
int a[10][10];
|
||||
int main(){
|
||||
return 0;
|
||||
}
|
1
sysy_sets/04_arr_defn3.out
Executable file
1
sysy_sets/04_arr_defn3.out
Executable file
|
@ -0,0 +1 @@
|
|||
14
|
9
sysy_sets/04_arr_defn3.sy
Executable file
9
sysy_sets/04_arr_defn3.sy
Executable file
|
@ -0,0 +1,9 @@
|
|||
//test array define
|
||||
int main(){
|
||||
int a[4][2] = {};
|
||||
int b[4][2] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
int c[4][2] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}};
|
||||
int d[4][2] = {1, 2, {3}, {5}, 7 , 8};
|
||||
int e[4][2] = {{d[2][1], c[2][1]}, {3, 4}, {5, 6}, {7, 8}};
|
||||
return e[3][1] + e[0][0] + e[0][1] + a[2][0];
|
||||
}
|
1
sysy_sets/05_arr_defn4.out
Executable file
1
sysy_sets/05_arr_defn4.out
Executable file
|
@ -0,0 +1 @@
|
|||
21
|
9
sysy_sets/05_arr_defn4.sy
Executable file
9
sysy_sets/05_arr_defn4.sy
Executable file
|
@ -0,0 +1,9 @@
|
|||
int main(){
|
||||
const int a[4][2] = {{1, 2}, {3, 4}, {}, 7};
|
||||
const int N = 3;
|
||||
int b[4][2] = {};
|
||||
int c[4][2] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
int d[N + 1][2] = {1, 2, {3}, {5}, a[3][0], 8};
|
||||
int e[4][2][1] = {{d[2][1], {c[2][1]}}, {3, 4}, {5, 6}, {7, 8}};
|
||||
return e[3][1][0] + e[0][0][0] + e[0][1][0] + d[3][0];
|
||||
}
|
1
sysy_sets/06_const_var_defn2.out
Executable file
1
sysy_sets/06_const_var_defn2.out
Executable file
|
@ -0,0 +1 @@
|
|||
5
|
6
sysy_sets/06_const_var_defn2.sy
Executable file
6
sysy_sets/06_const_var_defn2.sy
Executable file
|
@ -0,0 +1,6 @@
|
|||
//test const gloal var define
|
||||
const int a = 10, b = 5;
|
||||
|
||||
int main(){
|
||||
return b;
|
||||
}
|
1
sysy_sets/07_const_var_defn3.out
Executable file
1
sysy_sets/07_const_var_defn3.out
Executable file
|
@ -0,0 +1 @@
|
|||
5
|
5
sysy_sets/07_const_var_defn3.sy
Executable file
5
sysy_sets/07_const_var_defn3.sy
Executable file
|
@ -0,0 +1,5 @@
|
|||
//test const local var define
|
||||
int main(){
|
||||
const int a = 10, b = 5;
|
||||
return b;
|
||||
}
|
1
sysy_sets/08_const_array_defn.out
Executable file
1
sysy_sets/08_const_array_defn.out
Executable file
|
@ -0,0 +1 @@
|
|||
4
|
5
sysy_sets/08_const_array_defn.sy
Executable file
5
sysy_sets/08_const_array_defn.sy
Executable file
|
@ -0,0 +1,5 @@
|
|||
const int a[5]={0,1,2,3,4};
|
||||
|
||||
int main(){
|
||||
return a[4];
|
||||
}
|
1
sysy_sets/09_func_defn.out
Executable file
1
sysy_sets/09_func_defn.out
Executable file
|
@ -0,0 +1 @@
|
|||
9
|
11
sysy_sets/09_func_defn.sy
Executable file
11
sysy_sets/09_func_defn.sy
Executable file
|
@ -0,0 +1,11 @@
|
|||
int a;
|
||||
int func(int p){
|
||||
p = p - 1;
|
||||
return p;
|
||||
}
|
||||
int main(){
|
||||
int b;
|
||||
a = 10;
|
||||
b = func(a);
|
||||
return b;
|
||||
}
|
1
sysy_sets/10_var_defn_func.out
Executable file
1
sysy_sets/10_var_defn_func.out
Executable file
|
@ -0,0 +1 @@
|
|||
4
|
8
sysy_sets/10_var_defn_func.sy
Executable file
8
sysy_sets/10_var_defn_func.sy
Executable file
|
@ -0,0 +1,8 @@
|
|||
int defn(){
|
||||
return 4;
|
||||
}
|
||||
|
||||
int main(){
|
||||
int a=defn();
|
||||
return a;
|
||||
}
|
1
sysy_sets/11_add2.out
Executable file
1
sysy_sets/11_add2.out
Executable file
|
@ -0,0 +1 @@
|
|||
9
|
7
sysy_sets/11_add2.sy
Executable file
7
sysy_sets/11_add2.sy
Executable file
|
@ -0,0 +1,7 @@
|
|||
//test add
|
||||
int main(){
|
||||
int a, b;
|
||||
a = 10;
|
||||
b = -1;
|
||||
return a + b;
|
||||
}
|
1
sysy_sets/12_addc.out
Executable file
1
sysy_sets/12_addc.out
Executable file
|
@ -0,0 +1 @@
|
|||
15
|
5
sysy_sets/12_addc.sy
Executable file
5
sysy_sets/12_addc.sy
Executable file
|
@ -0,0 +1,5 @@
|
|||
//test addc
|
||||
const int a = 10;
|
||||
int main(){
|
||||
return a + 5;
|
||||
}
|
1
sysy_sets/13_sub2.out
Executable file
1
sysy_sets/13_sub2.out
Executable file
|
@ -0,0 +1 @@
|
|||
248
|
7
sysy_sets/13_sub2.sy
Executable file
7
sysy_sets/13_sub2.sy
Executable file
|
@ -0,0 +1,7 @@
|
|||
//test sub
|
||||
const int a = 10;
|
||||
int main(){
|
||||
int b;
|
||||
b = 2;
|
||||
return b - a;
|
||||
}
|
1
sysy_sets/14_subc.out
Executable file
1
sysy_sets/14_subc.out
Executable file
|
@ -0,0 +1 @@
|
|||
8
|
6
sysy_sets/14_subc.sy
Executable file
6
sysy_sets/14_subc.sy
Executable file
|
@ -0,0 +1,6 @@
|
|||
//test subc
|
||||
int main(){
|
||||
int a;
|
||||
a = 10;
|
||||
return a - 2;
|
||||
}
|
1
sysy_sets/15_mul.out
Executable file
1
sysy_sets/15_mul.out
Executable file
|
@ -0,0 +1 @@
|
|||
50
|
7
sysy_sets/15_mul.sy
Executable file
7
sysy_sets/15_mul.sy
Executable file
|
@ -0,0 +1,7 @@
|
|||
//test mul
|
||||
int main(){
|
||||
int a, b;
|
||||
a = 10;
|
||||
b = 5;
|
||||
return a * b;
|
||||
}
|
1
sysy_sets/16_mulc.out
Executable file
1
sysy_sets/16_mulc.out
Executable file
|
@ -0,0 +1 @@
|
|||
25
|
5
sysy_sets/16_mulc.sy
Executable file
5
sysy_sets/16_mulc.sy
Executable file
|
@ -0,0 +1,5 @@
|
|||
//test mulc
|
||||
const int a = 5;
|
||||
int main(){
|
||||
return a * 5;
|
||||
}
|
1
sysy_sets/17_div.out
Executable file
1
sysy_sets/17_div.out
Executable file
|
@ -0,0 +1 @@
|
|||
2
|
7
sysy_sets/17_div.sy
Executable file
7
sysy_sets/17_div.sy
Executable file
|
@ -0,0 +1,7 @@
|
|||
//test div
|
||||
int main(){
|
||||
int a, b;
|
||||
a = 10;
|
||||
b = 5;
|
||||
return a / b;
|
||||
}
|
1
sysy_sets/18_divc.out
Executable file
1
sysy_sets/18_divc.out
Executable file
|
@ -0,0 +1 @@
|
|||
2
|
5
sysy_sets/18_divc.sy
Executable file
5
sysy_sets/18_divc.sy
Executable file
|
@ -0,0 +1,5 @@
|
|||
//test divc
|
||||
const int a = 10;
|
||||
int main(){
|
||||
return a / 5;
|
||||
}
|
1
sysy_sets/19_mod.out
Executable file
1
sysy_sets/19_mod.out
Executable file
|
@ -0,0 +1 @@
|
|||
3
|
6
sysy_sets/19_mod.sy
Executable file
6
sysy_sets/19_mod.sy
Executable file
|
@ -0,0 +1,6 @@
|
|||
//test mod
|
||||
int main(){
|
||||
int a;
|
||||
a = 10;
|
||||
return a / 3;
|
||||
}
|
1
sysy_sets/20_rem.out
Executable file
1
sysy_sets/20_rem.out
Executable file
|
@ -0,0 +1 @@
|
|||
1
|
6
sysy_sets/20_rem.sy
Executable file
6
sysy_sets/20_rem.sy
Executable file
|
@ -0,0 +1,6 @@
|
|||
//test rem
|
||||
int main(){
|
||||
int a;
|
||||
a = 10;
|
||||
return a % 3;
|
||||
}
|
2
sysy_sets/21_if_test2.out
Executable file
2
sysy_sets/21_if_test2.out
Executable file
|
@ -0,0 +1,2 @@
|
|||
-5
|
||||
0
|
25
sysy_sets/21_if_test2.sy
Executable file
25
sysy_sets/21_if_test2.sy
Executable file
|
@ -0,0 +1,25 @@
|
|||
// test if-else-if
|
||||
int ifElseIf() {
|
||||
int a;
|
||||
a = 5;
|
||||
int b;
|
||||
b = 10;
|
||||
if(a == 6 || b == 0xb) {
|
||||
return a;
|
||||
}
|
||||
else {
|
||||
if (b == 10 && a == 1)
|
||||
a = 25;
|
||||
else if (b == 10 && a == -5)
|
||||
a = a + 15;
|
||||
else
|
||||
a = -+a;
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
int main(){
|
||||
putint(ifElseIf());
|
||||
return 0;
|
||||
}
|
1
sysy_sets/22_if_test3.out
Executable file
1
sysy_sets/22_if_test3.out
Executable file
|
@ -0,0 +1 @@
|
|||
25
|
18
sysy_sets/22_if_test3.sy
Executable file
18
sysy_sets/22_if_test3.sy
Executable file
|
@ -0,0 +1,18 @@
|
|||
// test if-if-else
|
||||
int ififElse() {
|
||||
int a;
|
||||
a = 5;
|
||||
int b;
|
||||
b = 10;
|
||||
if(a == 5)
|
||||
if (b == 10)
|
||||
a = 25;
|
||||
else
|
||||
a = a + 15;
|
||||
|
||||
return (a);
|
||||
}
|
||||
|
||||
int main(){
|
||||
return (ififElse());
|
||||
}
|
1
sysy_sets/23_if_test4.out
Executable file
1
sysy_sets/23_if_test4.out
Executable file
|
@ -0,0 +1 @@
|
|||
25
|
18
sysy_sets/23_if_test4.sy
Executable file
18
sysy_sets/23_if_test4.sy
Executable file
|
@ -0,0 +1,18 @@
|
|||
// test if-{if-else}
|
||||
int if_ifElse_() {
|
||||
int a;
|
||||
a = 5;
|
||||
int b;
|
||||
b = 10;
|
||||
if(a == 5){
|
||||
if (b == 10)
|
||||
a = 25;
|
||||
else
|
||||
a = a + 15;
|
||||
}
|
||||
return (a);
|
||||
}
|
||||
|
||||
int main(){
|
||||
return (if_ifElse_());
|
||||
}
|
1
sysy_sets/24_if_test5.out
Executable file
1
sysy_sets/24_if_test5.out
Executable file
|
@ -0,0 +1 @@
|
|||
25
|
18
sysy_sets/24_if_test5.sy
Executable file
18
sysy_sets/24_if_test5.sy
Executable file
|
@ -0,0 +1,18 @@
|
|||
// test if-{if}-else
|
||||
int if_if_Else() {
|
||||
int a;
|
||||
a = 5;
|
||||
int b;
|
||||
b = 10;
|
||||
if(a == 5){
|
||||
if (b == 10)
|
||||
a = 25;
|
||||
}
|
||||
else
|
||||
a = a + 15;
|
||||
return (a);
|
||||
}
|
||||
|
||||
int main(){
|
||||
return (if_if_Else());
|
||||
}
|
2
sysy_sets/25_while_if.out
Executable file
2
sysy_sets/25_while_if.out
Executable file
|
@ -0,0 +1,2 @@
|
|||
88
|
||||
0
|
31
sysy_sets/25_while_if.sy
Executable file
31
sysy_sets/25_while_if.sy
Executable file
|
@ -0,0 +1,31 @@
|
|||
int get_one(int a) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int deepWhileBr(int a, int b) {
|
||||
int c;
|
||||
c = a + b;
|
||||
while (c < 75) {
|
||||
int d;
|
||||
d = 42;
|
||||
if (c < 100) {
|
||||
c = c + d;
|
||||
if (c > 99) {
|
||||
int e;
|
||||
e = d * 2;
|
||||
if (get_one(0) == 1) {
|
||||
c = e * 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (c);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int p;
|
||||
p = 2;
|
||||
p = deepWhileBr(p, p);
|
||||
putint(p);
|
||||
return 0;
|
||||
}
|
1
sysy_sets/26_while_test1.out
Executable file
1
sysy_sets/26_while_test1.out
Executable file
|
@ -0,0 +1 @@
|
|||
3
|
18
sysy_sets/26_while_test1.sy
Executable file
18
sysy_sets/26_while_test1.sy
Executable file
|
@ -0,0 +1,18 @@
|
|||
int doubleWhile() {
|
||||
int i;
|
||||
i = 5;
|
||||
int j;
|
||||
j = 7;
|
||||
while (i < 100) {
|
||||
i = i + 30;
|
||||
while(j < 100){
|
||||
j = j + 6;
|
||||
}
|
||||
j = j - 100;
|
||||
}
|
||||
return (j);
|
||||
}
|
||||
|
||||
int main() {
|
||||
return doubleWhile();
|
||||
}
|
1
sysy_sets/27_while_test2.out
Executable file
1
sysy_sets/27_while_test2.out
Executable file
|
@ -0,0 +1 @@
|
|||
54
|
31
sysy_sets/27_while_test2.sy
Executable file
31
sysy_sets/27_while_test2.sy
Executable file
|
@ -0,0 +1,31 @@
|
|||
int FourWhile() {
|
||||
int a;
|
||||
a = 5;
|
||||
int b;
|
||||
int c;
|
||||
b = 6;
|
||||
c = 7;
|
||||
int d;
|
||||
d = 10;
|
||||
while (a < 20) {
|
||||
a = a + 3;
|
||||
while(b < 10){
|
||||
b = b + 1;
|
||||
while(c == 7){
|
||||
c = c - 1;
|
||||
while(d < 20){
|
||||
d = d + 3;
|
||||
}
|
||||
d = d - 1;
|
||||
}
|
||||
c = c + 1;
|
||||
}
|
||||
b = b - 2;
|
||||
}
|
||||
|
||||
return (a + (b + d) + c);
|
||||
}
|
||||
|
||||
int main() {
|
||||
return FourWhile();
|
||||
}
|
1
sysy_sets/28_while_test3.out
Executable file
1
sysy_sets/28_while_test3.out
Executable file
|
@ -0,0 +1 @@
|
|||
23
|
55
sysy_sets/28_while_test3.sy
Executable file
55
sysy_sets/28_while_test3.sy
Executable file
|
@ -0,0 +1,55 @@
|
|||
int g;
|
||||
int h;
|
||||
int f;
|
||||
int e;
|
||||
int EightWhile() {
|
||||
int a;
|
||||
a = 5;
|
||||
int b;
|
||||
int c;
|
||||
b = 6;
|
||||
c = 7;
|
||||
int d;
|
||||
d = 10;
|
||||
while (a < 20) {
|
||||
a = a + 3;
|
||||
while(b < 10){
|
||||
b = b + 1;
|
||||
while(c == 7){
|
||||
c = c - 1;
|
||||
while(d < 20){
|
||||
d = d + 3;
|
||||
while(e > 1){
|
||||
e = e-1;
|
||||
while(f > 2){
|
||||
f = f -2;
|
||||
while(g < 3){
|
||||
g = g +10;
|
||||
while(h < 10){
|
||||
h = h + 8;
|
||||
}
|
||||
h = h-1;
|
||||
}
|
||||
g = g- 8;
|
||||
}
|
||||
f = f + 1;
|
||||
}
|
||||
e = e + 1;
|
||||
}
|
||||
d = d - 1;
|
||||
}
|
||||
c = c + 1;
|
||||
}
|
||||
b = b - 2;
|
||||
}
|
||||
|
||||
return (a + (b + d) + c)-(e + d - g + h);
|
||||
}
|
||||
|
||||
int main() {
|
||||
g = 1;
|
||||
h = 2;
|
||||
e = 4;
|
||||
f = 6;
|
||||
return EightWhile();
|
||||
}
|
1
sysy_sets/29_break.out
Executable file
1
sysy_sets/29_break.out
Executable file
|
@ -0,0 +1 @@
|
|||
201
|
15
sysy_sets/29_break.sy
Executable file
15
sysy_sets/29_break.sy
Executable file
|
@ -0,0 +1,15 @@
|
|||
//test break
|
||||
int main(){
|
||||
int i;
|
||||
i = 0;
|
||||
int sum;
|
||||
sum = 0;
|
||||
while(i < 100){
|
||||
if(i == 50){
|
||||
break;
|
||||
}
|
||||
sum = sum + i;
|
||||
i = i + 1;
|
||||
}
|
||||
return sum;
|
||||
}
|
1
sysy_sets/30_continue.out
Executable file
1
sysy_sets/30_continue.out
Executable file
|
@ -0,0 +1 @@
|
|||
36
|
16
sysy_sets/30_continue.sy
Executable file
16
sysy_sets/30_continue.sy
Executable file
|
@ -0,0 +1,16 @@
|
|||
//test continue
|
||||
int main(){
|
||||
int i;
|
||||
i = 0;
|
||||
int sum;
|
||||
sum = 0;
|
||||
while(i < 100){
|
||||
if(i == 50){
|
||||
i = i + 1;
|
||||
continue;
|
||||
}
|
||||
sum = sum + i;
|
||||
i = i + 1;
|
||||
}
|
||||
return sum;
|
||||
}
|
1
sysy_sets/31_while_if_test1.out
Executable file
1
sysy_sets/31_while_if_test1.out
Executable file
|
@ -0,0 +1 @@
|
|||
198
|
25
sysy_sets/31_while_if_test1.sy
Executable file
25
sysy_sets/31_while_if_test1.sy
Executable file
|
@ -0,0 +1,25 @@
|
|||
// test while-if
|
||||
int whileIf() {
|
||||
int a;
|
||||
a = 0;
|
||||
int b;
|
||||
b = 0;
|
||||
while (a < 100) {
|
||||
if (a == 5) {
|
||||
b = 25;
|
||||
}
|
||||
else if (a == 10) {
|
||||
b = 42;
|
||||
}
|
||||
else {
|
||||
b = a * 2;
|
||||
}
|
||||
a = a + 1;
|
||||
}
|
||||
return (b);
|
||||
}
|
||||
|
||||
|
||||
int main(){
|
||||
return (whileIf());
|
||||
}
|
1
sysy_sets/32_while_if_test2.out
Executable file
1
sysy_sets/32_while_if_test2.out
Executable file
|
@ -0,0 +1 @@
|
|||
96
|
23
sysy_sets/32_while_if_test2.sy
Executable file
23
sysy_sets/32_while_if_test2.sy
Executable file
|
@ -0,0 +1,23 @@
|
|||
int ifWhile() {
|
||||
int a;
|
||||
a = 0;
|
||||
int b;
|
||||
b = 3;
|
||||
if (a == 5) {
|
||||
while(b == 2){
|
||||
b = b + 2;
|
||||
}
|
||||
b = b + 25;
|
||||
}
|
||||
else
|
||||
while (a < 5) {
|
||||
b = b * 2;
|
||||
a = a + 1;
|
||||
}
|
||||
return (b);
|
||||
}
|
||||
|
||||
|
||||
int main(){
|
||||
return (ifWhile());
|
||||
}
|
1
sysy_sets/33_while_if_test3.out
Executable file
1
sysy_sets/33_while_if_test3.out
Executable file
|
@ -0,0 +1 @@
|
|||
88
|
25
sysy_sets/33_while_if_test3.sy
Executable file
25
sysy_sets/33_while_if_test3.sy
Executable file
|
@ -0,0 +1,25 @@
|
|||
int deepWhileBr(int a, int b) {
|
||||
int c;
|
||||
c = a + b;
|
||||
while (c < 75) {
|
||||
int d;
|
||||
d = 42;
|
||||
if (c < 100) {
|
||||
c = c + d;
|
||||
if (c > 99) {
|
||||
int e;
|
||||
e = d * 2;
|
||||
if (1 == 1) {
|
||||
c = e * 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (c);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int p;
|
||||
p = 2;
|
||||
return deepWhileBr(p, p);
|
||||
}
|
1
sysy_sets/34_arr_expr_len.out
Executable file
1
sysy_sets/34_arr_expr_len.out
Executable file
|
@ -0,0 +1 @@
|
|||
51
|
11
sysy_sets/34_arr_expr_len.sy
Executable file
11
sysy_sets/34_arr_expr_len.sy
Executable file
|
@ -0,0 +1,11 @@
|
|||
const int N = -1;
|
||||
int arr[N + 2 * 4 - 99 / 99] = {1, 2, 33, 4, 5, 6};
|
||||
|
||||
int main() {
|
||||
int i = 0, sum = 0;
|
||||
while (i < 6) {
|
||||
sum = sum + arr[i];
|
||||
i = i + 1;
|
||||
}
|
||||
return sum;
|
||||
}
|
1
sysy_sets/35_op_priority1.out
Executable file
1
sysy_sets/35_op_priority1.out
Executable file
|
@ -0,0 +1 @@
|
|||
40
|
9
sysy_sets/35_op_priority1.sy
Executable file
9
sysy_sets/35_op_priority1.sy
Executable file
|
@ -0,0 +1,9 @@
|
|||
//test the priority of add and mul
|
||||
int main(){
|
||||
int a, b, c, d;
|
||||
a = 10;
|
||||
b = 4;
|
||||
c = 2;
|
||||
d = 2;
|
||||
return c + a * b - d;
|
||||
}
|
1
sysy_sets/36_op_priority2.out
Executable file
1
sysy_sets/36_op_priority2.out
Executable file
|
@ -0,0 +1 @@
|
|||
24
|
9
sysy_sets/36_op_priority2.sy
Executable file
9
sysy_sets/36_op_priority2.sy
Executable file
|
@ -0,0 +1,9 @@
|
|||
//test the priority of add and mul
|
||||
int main(){
|
||||
int a, b, c, d;
|
||||
a = 10;
|
||||
b = 4;
|
||||
c = 2;
|
||||
d = 2;
|
||||
return (c + a) * (b - d);
|
||||
}
|
1
sysy_sets/37_op_priority3.out
Executable file
1
sysy_sets/37_op_priority3.out
Executable file
|
@ -0,0 +1 @@
|
|||
40
|
7
sysy_sets/37_op_priority3.sy
Executable file
7
sysy_sets/37_op_priority3.sy
Executable file
|
@ -0,0 +1,7 @@
|
|||
//test the priority of unary operator and binary operator
|
||||
int main(){
|
||||
int a, b;
|
||||
a = 10;
|
||||
b = 30;
|
||||
return a - -5 + b + -5;
|
||||
}
|
1
sysy_sets/38_op_priority4.in
Executable file
1
sysy_sets/38_op_priority4.in
Executable file
|
@ -0,0 +1 @@
|
|||
0 1 1 1 1
|
1
sysy_sets/38_op_priority4.out
Executable file
1
sysy_sets/38_op_priority4.out
Executable file
|
@ -0,0 +1 @@
|
|||
1
|
19
sysy_sets/38_op_priority4.sy
Executable file
19
sysy_sets/38_op_priority4.sy
Executable file
|
@ -0,0 +1,19 @@
|
|||
int a;
|
||||
int b;
|
||||
int c;
|
||||
int d;
|
||||
int e;
|
||||
int main()
|
||||
{
|
||||
a=getint();
|
||||
b=getint();
|
||||
c=getint();
|
||||
d=getint();
|
||||
e=getint();
|
||||
int flag=0;
|
||||
if(a-b*c!=d-a/c||a*b/c==e+d||a+b+c==d+e)
|
||||
{
|
||||
flag=1;
|
||||
}
|
||||
return flag;
|
||||
}
|
2
sysy_sets/39_op_priority5.out
Executable file
2
sysy_sets/39_op_priority5.out
Executable file
|
@ -0,0 +1,2 @@
|
|||
1
|
||||
1
|
15
sysy_sets/39_op_priority5.sy
Executable file
15
sysy_sets/39_op_priority5.sy
Executable file
|
@ -0,0 +1,15 @@
|
|||
int a = 1;
|
||||
int b = 0;
|
||||
int c = 1;
|
||||
int d = 2;
|
||||
int e = 4;
|
||||
int main()
|
||||
{
|
||||
int flag=0;
|
||||
if(a * b / c == e + d && a * (a + b) + c <= d + e || a - (b * c) == d - a / c)
|
||||
{
|
||||
flag=1;
|
||||
}
|
||||
putint(flag);
|
||||
return flag;
|
||||
}
|
1
sysy_sets/40_unary_op.out
Executable file
1
sysy_sets/40_unary_op.out
Executable file
|
@ -0,0 +1 @@
|
|||
0
|
11
sysy_sets/40_unary_op.sy
Executable file
11
sysy_sets/40_unary_op.sy
Executable file
|
@ -0,0 +1,11 @@
|
|||
int main() {
|
||||
int a;
|
||||
a = 10;
|
||||
if (+-!!!a) {
|
||||
a = - - -1;
|
||||
}
|
||||
else {
|
||||
a = 0;
|
||||
}
|
||||
return a;
|
||||
}
|
2
sysy_sets/41_unary_op2.out
Executable file
2
sysy_sets/41_unary_op2.out
Executable file
|
@ -0,0 +1,2 @@
|
|||
4
|
||||
0
|
14
sysy_sets/41_unary_op2.sy
Executable file
14
sysy_sets/41_unary_op2.sy
Executable file
|
@ -0,0 +1,14 @@
|
|||
int main() {
|
||||
int a, b;
|
||||
a = 070;
|
||||
b = 0x4;
|
||||
a = a - - 4 + + b;
|
||||
if (+-!!!a) {
|
||||
a = - - -1;
|
||||
}
|
||||
else {
|
||||
a = 0 + + b;
|
||||
}
|
||||
putint(a);
|
||||
return 0;
|
||||
}
|
1
sysy_sets/42_empty_stmt.out
Executable file
1
sysy_sets/42_empty_stmt.out
Executable file
|
@ -0,0 +1 @@
|
|||
21
|
5
sysy_sets/42_empty_stmt.sy
Executable file
5
sysy_sets/42_empty_stmt.sy
Executable file
|
@ -0,0 +1,5 @@
|
|||
int main() {
|
||||
int a = 10;
|
||||
;
|
||||
return a * 2 + 1;
|
||||
}
|
1
sysy_sets/43_logi_assign.in
Executable file
1
sysy_sets/43_logi_assign.in
Executable file
|
@ -0,0 +1 @@
|
|||
4 4
|
1
sysy_sets/43_logi_assign.out
Executable file
1
sysy_sets/43_logi_assign.out
Executable file
|
@ -0,0 +1 @@
|
|||
1
|
15
sysy_sets/43_logi_assign.sy
Executable file
15
sysy_sets/43_logi_assign.sy
Executable file
|
@ -0,0 +1,15 @@
|
|||
int a;
|
||||
int b;
|
||||
int main()
|
||||
{
|
||||
a=getint();
|
||||
b=getint();
|
||||
int c;
|
||||
if (a==b&&a!=3) {
|
||||
c = 1;
|
||||
}
|
||||
else {
|
||||
c = 0;
|
||||
}
|
||||
return c;
|
||||
}
|
2
sysy_sets/44_stmt_expr.out
Executable file
2
sysy_sets/44_stmt_expr.out
Executable file
|
@ -0,0 +1,2 @@
|
|||
1024
|
||||
0
|
13
sysy_sets/44_stmt_expr.sy
Executable file
13
sysy_sets/44_stmt_expr.sy
Executable file
|
@ -0,0 +1,13 @@
|
|||
int k;
|
||||
const int n = 10;
|
||||
int main () {
|
||||
int i = 0;
|
||||
k = 1;
|
||||
while (i <= n - 1) {
|
||||
i = i + 1;
|
||||
k + 1;
|
||||
k = k + k;
|
||||
}
|
||||
putint(k);
|
||||
return k;
|
||||
}
|
1
sysy_sets/45_comment1.out
Executable file
1
sysy_sets/45_comment1.out
Executable file
|
@ -0,0 +1 @@
|
|||
5
|
12
sysy_sets/45_comment1.sy
Executable file
12
sysy_sets/45_comment1.sy
Executable file
|
@ -0,0 +1,12 @@
|
|||
//test comment
|
||||
int main(){
|
||||
int a;
|
||||
a = 5;
|
||||
//int b = 4;
|
||||
//a = b + a;
|
||||
/*/*
|
||||
b = 1;
|
||||
// b = 2
|
||||
*/
|
||||
return a;
|
||||
}
|
1
sysy_sets/46_hex_defn.out
Executable file
1
sysy_sets/46_hex_defn.out
Executable file
|
@ -0,0 +1 @@
|
|||
15
|
6
sysy_sets/46_hex_defn.sy
Executable file
6
sysy_sets/46_hex_defn.sy
Executable file
|
@ -0,0 +1,6 @@
|
|||
// test hexadecimal define
|
||||
int main(){
|
||||
int a;
|
||||
a = 0xf;
|
||||
return a;
|
||||
}
|
1
sysy_sets/47_hex_oct_add.out
Executable file
1
sysy_sets/47_hex_oct_add.out
Executable file
|
@ -0,0 +1 @@
|
|||
88
|
7
sysy_sets/47_hex_oct_add.sy
Executable file
7
sysy_sets/47_hex_oct_add.sy
Executable file
|
@ -0,0 +1,7 @@
|
|||
//test add of hex and oct
|
||||
int main(){
|
||||
int a, b;
|
||||
a = 0xf;
|
||||
b = 0xc;
|
||||
return a + b + 075;
|
||||
}
|
2
sysy_sets/48_assign_complex_expr.out
Executable file
2
sysy_sets/48_assign_complex_expr.out
Executable file
|
@ -0,0 +1,2 @@
|
|||
-171
|
||||
0
|
18
sysy_sets/48_assign_complex_expr.sy
Executable file
18
sysy_sets/48_assign_complex_expr.sy
Executable file
|
@ -0,0 +1,18 @@
|
|||
// Use complex expression in assign structure
|
||||
int main () {
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
int d;
|
||||
int result;
|
||||
a = 5;
|
||||
b = 5;
|
||||
c = 1;
|
||||
d = -2;
|
||||
result = (d * 1 / 2) + (a - b) - -(c + 3) % 2;
|
||||
putint(result);
|
||||
result = ((d % 2 + 67) + -(a - b) - -((c + 2) % 2));
|
||||
result = result + 3;
|
||||
putint(result);
|
||||
return 0;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user