From: Doni Pracner Date: Fri, 24 Jan 2014 12:23:21 +0000 (+0100) Subject: samples renamed to more logical names X-Git-Tag: v0.1.4~3 X-Git-Url: https://svarog.pmf.uns.ac.rs/gitweb/?a=commitdiff_plain;h=6b96ddc43ce994ef402a19b106c283e571d45219;p=mjc2wsl.git samples renamed to more logical names --- diff --git a/samples/eratos.mj b/samples/eratos.mj new file mode 100644 index 0000000..620bd2d --- /dev/null +++ b/samples/eratos.mj @@ -0,0 +1,38 @@ +program Eratos + + char[] sieve; + int max; // maximum prime to be found + int npp; // numbers per page + +{ + void put(int x) + { + if (npp == 10) {print(chr(13)); print(chr(10)); npp = 0;} + print(x, 5); + npp++; + } + + void found(int x) + int i; + { + put(x); + i = x; + while (i <= max) {sieve[i] = 'o'; i = i + x;} + } + + void main() + int i; + { + read(max); + npp = 0; + sieve = new char[max+1]; + i = 0; + while (i <= max) {sieve[i] = 'x'; i++;} + i = 2; + while (i <= max) { + found(i); + while(i <= max && sieve[i] == 'o') i++; + } + } + +}//test \ No newline at end of file diff --git a/samples/pos-neg.mj b/samples/pos-neg.mj new file mode 100644 index 0000000..5bf3771 --- /dev/null +++ b/samples/pos-neg.mj @@ -0,0 +1,40 @@ +program P + final int size = 10; + class Table { + int[] pos; + int[] neg; + } + Table val; +{ + void main() + int x, i; + { //---------- Initialize val + val = new Table; + val.pos = new int[size]; val.neg = new int[size]; + i = 0; + while (i < size) { + val.pos[i] = 0; val.neg[i] = 0; + i++; + } + //---------- Read values + read(x); + while (x != 0) { + if (0 <= x && x < size) { + val.pos[x]++; + } else if (-size < x && x < 0) { + val.neg[-x]++; + } + read(x); + } + + // output everything + i = 0; + while (i < size) { + print(i,3); + print(val.pos[i],5); + print(val.neg[i],5); + print(chr(10)); + i++; + } + } +} diff --git a/samples/sample-ext.mj b/samples/sample-ext.mj deleted file mode 100644 index 5bf3771..0000000 --- a/samples/sample-ext.mj +++ /dev/null @@ -1,40 +0,0 @@ -program P - final int size = 10; - class Table { - int[] pos; - int[] neg; - } - Table val; -{ - void main() - int x, i; - { //---------- Initialize val - val = new Table; - val.pos = new int[size]; val.neg = new int[size]; - i = 0; - while (i < size) { - val.pos[i] = 0; val.neg[i] = 0; - i++; - } - //---------- Read values - read(x); - while (x != 0) { - if (0 <= x && x < size) { - val.pos[x]++; - } else if (-size < x && x < 0) { - val.neg[-x]++; - } - read(x); - } - - // output everything - i = 0; - while (i < size) { - print(i,3); - print(val.pos[i],5); - print(val.neg[i],5); - print(chr(10)); - i++; - } - } -} diff --git a/samples/sample.mj b/samples/sample.mj deleted file mode 100644 index 8442ca8..0000000 --- a/samples/sample.mj +++ /dev/null @@ -1,30 +0,0 @@ -program P - final int size = 10; - class Table { - int[] pos; - int[] neg; - } - Table val; -{ - void main() - int x, i; - { //---------- Initialize val - val = new Table; - val.pos = new int[size]; val.neg = new int[size]; - i = 0; - while (i < size) { - val.pos[i] = 0; val.neg[i] = 0; - i++; - } - //---------- Read values - read(x); - while (x != 0) { - if (0 <= x && x < size) { - val.pos[x]++; - } else if (-size < x && x < 0) { - val.neg[-x]++; - } - read(x); - } - } -} diff --git a/samples/sample0-h1.wsl b/samples/sample0-h1.wsl deleted file mode 100644 index 905cb16..0000000 --- a/samples/sample0-h1.wsl +++ /dev/null @@ -1,41 +0,0 @@ -C:" This file automatically converted from microjava bytecode"; -C:" with mjc2wsl v 0.1"; -VAR < tempa := 0, tempb := 0, tempres :=0, -loc0 := 0, loc1 := 0, loc2 := 0, loc3 := 0, - estack := < >, t_e_m_p := 0 > : - ACTIONS A_S_start: - A_S_start == - -C:" enter not fully procesed yet"; -estack := <0 > ++ estack; -loc0 := HEAD(estack); estack := TAIL(estack); -CALL a19 END -a19 == -estack := ++ estack; -estack := <5 > ++ estack; -tempa := HEAD(estack); estack := TAIL(estack); -tempb := HEAD(estack); estack := TAIL(estack); -C:" IF CALL 13"; -IF tempb >= tempa THEN CALL a34 FI; -estack := ++ estack; -estack := <0 > ++ estack; -tempa := HEAD(estack); estack := TAIL(estack); -tempa := HEAD(estack); estack := TAIL(estack); -PRINT(tempa); -estack := ++ estack; -estack := <1 > ++ estack; -tempa := HEAD(estack); estack := TAIL(estack); -tempb := HEAD(estack); estack := TAIL(estack); -tempres := tempb + tempa; -estack := ++ estack; -loc0 := HEAD(estack); estack := TAIL(estack); -C:" CALL -12"; -CALL a19 END -a34 == -C:" exit not fully procesed yet"; -C:" return not fully procesed yet"; -CALL Z -END -ENDACTIONS; -SKIP -ENDVAR diff --git a/samples/sample0.mj b/samples/sample0.mj deleted file mode 100644 index cdc0851..0000000 --- a/samples/sample0.mj +++ /dev/null @@ -1,12 +0,0 @@ -program P -{ - void main() - int i; - { - i = 0; - while (i < 5) { - print(i); - i = i + 1; - } - } -} diff --git a/samples/sample0.wsl b/samples/sample0.wsl deleted file mode 100644 index 7fcb024..0000000 --- a/samples/sample0.wsl +++ /dev/null @@ -1,68 +0,0 @@ -C:" This file automatically converted from microjava bytecode"; -C:" with mjc2wsl v 0.1.2"; -VAR < tempa := 0, tempb := 0, tempres :=0, -loc0 := 0, loc1 := 0, loc2 := 0, loc3 := 0, - estack := < >, t_e_m_p := 0 > : -SKIP; - ACTIONS A_S_start: - A_S_start == CALL a14 END -a14 == -C:" enter not fully procesed yet"; -CALL a17 END -a17 == -estack := <0 > ++ estack; -CALL a18 END -a18 == -loc0 := HEAD(estack); estack := TAIL(estack); -CALL a19 END -a19 == -estack := ++ estack; -CALL a20 END -a20 == -estack := <5 > ++ estack; -CALL a21 END -a21 == -tempa := HEAD(estack); estack := TAIL(estack); -tempb := HEAD(estack); estack := TAIL(estack); -IF tempb >= tempa THEN CALL a34 FI; -CALL a24 END -a24 == -estack := ++ estack; -CALL a25 END -a25 == -estack := <0 > ++ estack; -CALL a26 END -a26 == -tempa := HEAD(estack); estack := TAIL(estack); -tempb := HEAD(estack); estack := TAIL(estack); -PRINT(tempb); -CALL a27 END -a27 == -estack := ++ estack; -CALL a28 END -a28 == -estack := <1 > ++ estack; -CALL a29 END -a29 == -tempa := HEAD(estack); estack := TAIL(estack); -tempb := HEAD(estack); estack := TAIL(estack); -tempres := tempb + tempa; -estack := ++ estack; -CALL a30 END -a30 == -loc0 := HEAD(estack); estack := TAIL(estack); -CALL a31 END -a31 == -CALL a19; -CALL a34 END -a34 == -C:" exit not fully procesed yet"; -CALL a35 END -a35 == -C:" return not fully procesed yet"; -CALL Z; -SKIP END -ENDACTIONS; - -SKIP -ENDVAR diff --git a/samples/sample1.mj b/samples/sample1.mj deleted file mode 100644 index 620bd2d..0000000 --- a/samples/sample1.mj +++ /dev/null @@ -1,38 +0,0 @@ -program Eratos - - char[] sieve; - int max; // maximum prime to be found - int npp; // numbers per page - -{ - void put(int x) - { - if (npp == 10) {print(chr(13)); print(chr(10)); npp = 0;} - print(x, 5); - npp++; - } - - void found(int x) - int i; - { - put(x); - i = x; - while (i <= max) {sieve[i] = 'o'; i = i + x;} - } - - void main() - int i; - { - read(max); - npp = 0; - sieve = new char[max+1]; - i = 0; - while (i <= max) {sieve[i] = 'x'; i++;} - i = 2; - while (i <= max) { - found(i); - while(i <= max && sieve[i] == 'o') i++; - } - } - -}//test \ No newline at end of file diff --git a/samples/while-print.mj b/samples/while-print.mj new file mode 100644 index 0000000..cdc0851 --- /dev/null +++ b/samples/while-print.mj @@ -0,0 +1,12 @@ +program P +{ + void main() + int i; + { + i = 0; + while (i < 5) { + print(i); + i = i + 1; + } + } +}