Commit 09162b54 authored by Jakub Yaghob's avatar Jakub Yaghob
Browse files

tests for SXA

simplified grammar
parent 58fad2bd
......@@ -358,16 +358,12 @@ typedef-name:
```
statement:
labeled-statement
expression-statement
compound-statement
selection-statement
iteration-statement
jump-statement
labeled-statement:
identifier : statement
compound-statement:
{ block-item-list_opt }
......@@ -392,9 +388,6 @@ iteration-statement:
for ( expression_opt ; expression_opt ; expression_opt ) statement
jump-statement:
goto identifier ;
continue ;
break ;
return expression_opt ;
```
......
// array
int main(int argc, char** argv)
{
int arr[42];
int i, j;
for(i=0;i<42;++i)
arr[i] = i;
int darr[4][2];
for(i=0;i<4;++i)
for(j=0;j<2;++j)
darr[i][j] = i+j;
return 0;
}
========== cecko2 done ==========
// enum
enum days { MON, TUE, WED, THU, WRI, SAT=15, SUN };
int main(int argc, char** argv)
{
enum days day;
day = SAT;
enum rgb { RED, GREEN, BLUE } color;
color = GREEN;
}
========== cecko2 done ==========
// basic expression
int fce(int p, int q)
{
++p;
--q;
p++;
q--;
int rv;
rv = p;
if(p<10 && q>20 || p>=30 && q<=10 || !(p==q))
rv *= q;
else
rv += q;
return rv;
}
int main(int argc, char** argv)
{
int a;
a = 1+2*3-8/sizeof(int);
int b;
b = a+argc;
int r = fce(a, b);
int *p = &r;
*p = fce(a+b, b-a);
return 0;
}
========== cecko2 done ==========
// statements
int main(int argc, char** argv)
{
if(argc<2)
{
printf("No args");
return 4;
}
int mx;
sscanf(argv[1], "%d", &mx);
int i;
for(i=0;i<mx;++i)
{
int q;
q = i;
while(q--)
if(i>q)
do {
// nothing to do
} while(q++!=i);
else if(i<q)
do {
// nothing to do
} while(q--!=i);
else
; // this is empty expr
}
return 0;
}
========== cecko2 done ==========
// struct
struct mighty_str {
char c;
int x,y;
};
int main(int argc, char** argv)
{
struct mighty_str ms;
ms.c = 'x';
struct mighty_str *ps;
ps = &ms;
ps->x = ps->y = 1;
struct god_str {
struct mighty_str ims_;
} gs;
gs.ims_.c = 'G';
return 0;
}
========== cecko2 done ==========
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment