Skip to content

Commit

Permalink
Adds new code test files, adds new interpreter (32bit only right now)
Browse files Browse the repository at this point in the history
  • Loading branch information
psde committed Jan 16, 2013
1 parent 165532e commit 55fb519
Show file tree
Hide file tree
Showing 14 changed files with 300 additions and 0 deletions.
76 changes: 76 additions & 0 deletions code/ParserTests-WS-12-13/p1Test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* div and mod ==> d := a mod b */
int a;
int b;
int c;
int d;

/* int a; 25*/
/* int b; 3*/
/* int c; */
int x;
int y;

int mod;
int div;

/* 25 */
read(a);
/* 3*/
read(b);
if (a < 0) { a = -a; print(a);} else{};
if (b < 0) { b = -b; print(b);} else{};
c = a / b;
d = a - (c * b);

print (d);
print(1);

/* */
/* */
/* Teil II */
/* */
/* */

/* berechnet a^b % c

int a;
int b;
int c;
int x;
int y;

int mod;
int div; */

/* 33 */
read(a);
/* 5 */
read(b);
/*127*/
read(c);

x=1;
y=a;
while(0 < b){
/* b % 2 */
div = b/2;
mod = b - (div * 2);
if (mod = 1){
/* (x*y)%c */
div = (x*y)/c;
mod = (x*y) - (div * c);
x = mod;
} else {};
/* (y*y)%c */
div = (y*y)/c;
mod = (y*y) - (div * c);
y = mod; /* squaring the base*/
b = b / 2;
};
/* x % c */
div = x/c;
mod = x - (div * c);

print(mod);
print(89);

100 changes: 100 additions & 0 deletions code/ParserTests-WS-12-13/p2test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/* ggt (a,b) */
int a;
int b;
int c;
int d;

int x;
int y;
int ggt;

int r0;
int r1;

int p0;
int p1;

int q0;
int q1;

int u;


/* 1045 */
read(a);
/* 335 */
read(b);
if (a < 0) a = -a else{};
if (b < 0) b = -b else{};

while ( 0 < b ){
d = a / b;
c = a - (d * b); /* c = a mod b */
a = b;
b = c;
};
print (a);
print (5);



/* Teil II */
/* x*a + y*b = ggt(a,b) */

/* 1045 */
read(a);
if (a < 0) {
a = -a;
print(a);
}else{};

/* 335 */
read(b);
if (b < 0) {
b = -b;
print(b);
}else{};

r0 = a;
r1 = b;
p0 = 0;
p1 = 1;
q0 = 1;
q1 = 0;

while ( (0 < r0) & (0 < r1) ){
print(r0);
print(r1);
u = r0 / r1;
r0 = r0 - (u * r1); /* r0 = r0 mod r1 */
p0 = (u * p1) + p0;
q0 = (u * q1) + q0;

if ( 0 < r0 ) {
u = r1 / r0;
r1 = r1 - (u * r0); /* r0 = r0 mod r1 */
p1 = (u * p0) + p1;
q1 = (u * q0) + q1;
} else {};
};

if (r0 = 0){
ggt = r1;
x = -q1;
y = p1;
} else {
ggt = r0;
x = q0;
y = -p0;
};


print(ggt);
print(5);
print(x);
print(-25);
print(y);
print(78);
print(((-25) * 1045) + (78 * 335));
print(5);

76 changes: 76 additions & 0 deletions code/failtest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* div and mod ==> d := a mod b */
int a;
int b;
int c; /* test *//* asd */
int d;

/* int a; 25 */
/* int b; 3 */
/* int c; */
int x;
int y;

int mod;
int div;

/* 25 */
read(a);
/* 3*/
read(b);
if (a < 0) { a = -a; print(a);} else{};
if (b < 0) { b = -b; print(b);} else{};
c = a / b;
d = a - (c * b);

print (d);
print(1);

/* */
/* */
/* Teil II */
/* */
/* */

/* berechnet a^b % c

int a;
int b;
int c;
int x;
int y;

int mod;
int div; */

/* 33 */
read(a);
/* 5 */
read(b);
/*127*/
read(c);

x=1;
y=a;
while(0 < b){
/* b % 2 */
div = b/2;
mod = b - (div * 2);
if (mod = 1){
/* (x*y)%c */
div = (x*y)/c;
mod = (x*y) - (div * c);
x = mod;
} else {};
/* (y*y)%c */
div = (y*y)/c;
mod = (y*y) - (div * c);
y = mod; /* squaring the base*/
b = b / 2;
};
/* x % c */
div = x/c;
mod = x - (div * c);

print(mod);
print(89);

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions code/simple.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
int i;
int d;
int r;
int args;

print(r);
42 changes: 42 additions & 0 deletions code/whiletest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
int a;
int b;
int c;
int d;


a = 2;
b = 4;
d = 2;
c = (a * b) - d;
d = b / a;

c = c + (b / a);
print(c);
print(d);

/*
a = 0;
b = 0;
c = 1000;

while( (a < 10) & (b < 10))
{
print(a);
print(b);
a = a + 1;
b = b + 1;
};

print(c);


a = 10;
b = 0;

if( 0 < a)
{
print(a);
};


*/
Binary file added interpreter-new/Interpreter fur Linux 32 bit.jar
Binary file not shown.

0 comments on commit 55fb519

Please sign in to comment.