gitweb on Svarog
projekti pod git sistemom za održavanje verzija -- projects under the git version control system
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 306587b)
raw | patch | inline | side by side (parent: 306587b)
author | Doni Pracner <quinnuendo@gmail.com> | |
Fri, 19 Jul 2019 12:27:14 +0000 (14:27 +0200) | ||
committer | Doni Pracner <quinnuendo@gmail.com> | |
Fri, 19 Jul 2019 12:27:14 +0000 (14:27 +0200) |
33 files changed:
diff --git a/build.xml b/build.xml
index a9dac9f59c05695648e97c25f63a0f8711cdb497..762aef3448059dd8656e15eff8928a9488401f2e 100644 (file)
--- a/build.xml
+++ b/build.xml
<property name="compiler.classname.interpreter" value="MJ.Run" />
<property name="compiler.classname.decoder" value="MJ.Decode" />
- <property name="samples.main.dir" value="samples" />
- <property name="samples.temp.dir" value="temp" />
+ <property name="samples.main.dir" value="samples/alpha-mj" />
+ <property name="samples.temp.dir" value="temp/alpha-mj" />
<property name="transf.wsl.file" value="src-wsl/hill_climbing.wsl" />
<property name="transf.wsl.ini" value="transf.ini" />
diff --git a/samples/ArrayTest.mj b/samples/ArrayTest.mj
--- a/samples/ArrayTest.mj
+++ /dev/null
@@ -1,20 +0,0 @@
-program ArrayTest
- int[] arr;
- int i;
- int max;
-{
- void main(){
- max = 10;
- arr = new int[max];
- i = 0;
- while (i<max){
- arr[i] = max-i;
- i++;
- }
- i = 0;
- while (i<len(arr)){
- print(arr[i],3);
- i++;
- }
- }
-}
\ No newline at end of file
diff --git a/samples/ArraysTest.mj b/samples/ArraysTest.mj
--- a/samples/ArraysTest.mj
+++ /dev/null
@@ -1,29 +0,0 @@
-program ArraysTest
-{
- void rek_arr(int i)
- int[] a; int loc, loc2; {
- if (i>1){
- a = new int[i];
- loc = 0;
- loc2 = 1;
- while (loc<i){
- a[loc] = loc2;
- loc++;
- loc2 = loc2 * i;
- }
- rek_arr(i-1);
- loc = 0;
- while (loc<i){
- print(a[loc],3);
- loc++;
- }
- print(0,5);
- }
- }
-
- void main() int max;
- {
- max = 5;
- rek_arr(max);
- }
-}
\ No newline at end of file
diff --git a/samples/InOut1.mj b/samples/InOut1.mj
--- a/samples/InOut1.mj
+++ /dev/null
@@ -1,9 +0,0 @@
-program InOut1{
- void main()
- int i;
- {
- print('?');
- read(i);
- print(i);
- }
-}
\ No newline at end of file
diff --git a/samples/InOut2.mj b/samples/InOut2.mj
--- a/samples/InOut2.mj
+++ /dev/null
@@ -1,10 +0,0 @@
-program InOut2{
- void main()
- char c;
- {
- print('c');
- print('?');
- read(c);
- print(c);
- }
-}
\ No newline at end of file
diff --git a/samples/InOut3.mj b/samples/InOut3.mj
--- a/samples/InOut3.mj
+++ /dev/null
@@ -1,23 +0,0 @@
-program InOut3{
- void main()
- char c;
- int i;
- {
- i = 5;
- print('c');
- print('?');
- read(c);
- print(c);
- print(chr(10));
- if (c=='y') {
- print('i');
- read(i);
- } else {
- print('c');
- read(c);
- }
- print(chr(10));
- print(i,5);
- print(c,5);
- }
-}
\ No newline at end of file
diff --git a/samples/Rek1.mj b/samples/Rek1.mj
--- a/samples/Rek1.mj
+++ /dev/null
@@ -1,11 +0,0 @@
-program Rek1{
- void func(int i){
- print(i);
- if (i>0)
- func(i-1);
- }
-
- void main() {
- func(5);
- }
-}
\ No newline at end of file
diff --git a/samples/RekFac.mj b/samples/RekFac.mj
--- a/samples/RekFac.mj
+++ /dev/null
@@ -1,17 +0,0 @@
-program RekFac{
-
- int factorial(int f)
- {
- if (f<0)
- return 0;
- if (f<=1)
- return 1;
- return factorial(f-1) * f ;
- }
-
- void main()
- {
- print(factorial(3),3);
- print(factorial(10),10);
- }
-}
\ No newline at end of file
diff --git a/samples/RekFib.mj b/samples/RekFib.mj
--- a/samples/RekFib.mj
+++ /dev/null
@@ -1,18 +0,0 @@
-program RekFib{
-
- int fib(int f)
- {
- if (f==0)
- return 0;
- if (f==1)
- return 1;
- return fib(f-2)+fib(f-1) ;
- }
-
- void main()
- {
- print(fib(0),3);
- print(fib(2),3);
- print(fib(7),3);
- }
-}
\ No newline at end of file
diff --git a/samples/alpha-mj/ArrayTest.mj b/samples/alpha-mj/ArrayTest.mj
--- /dev/null
@@ -0,0 +1,20 @@
+program ArrayTest
+ int[] arr;
+ int i;
+ int max;
+{
+ void main(){
+ max = 10;
+ arr = new int[max];
+ i = 0;
+ while (i<max){
+ arr[i] = max-i;
+ i++;
+ }
+ i = 0;
+ while (i<len(arr)){
+ print(arr[i],3);
+ i++;
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/alpha-mj/ArraysTest.mj b/samples/alpha-mj/ArraysTest.mj
--- /dev/null
@@ -0,0 +1,29 @@
+program ArraysTest
+{
+ void rek_arr(int i)
+ int[] a; int loc, loc2; {
+ if (i>1){
+ a = new int[i];
+ loc = 0;
+ loc2 = 1;
+ while (loc<i){
+ a[loc] = loc2;
+ loc++;
+ loc2 = loc2 * i;
+ }
+ rek_arr(i-1);
+ loc = 0;
+ while (loc<i){
+ print(a[loc],3);
+ loc++;
+ }
+ print(0,5);
+ }
+ }
+
+ void main() int max;
+ {
+ max = 5;
+ rek_arr(max);
+ }
+}
\ No newline at end of file
diff --git a/samples/alpha-mj/InOut1.mj b/samples/alpha-mj/InOut1.mj
--- /dev/null
@@ -0,0 +1,9 @@
+program InOut1{
+ void main()
+ int i;
+ {
+ print('?');
+ read(i);
+ print(i);
+ }
+}
\ No newline at end of file
diff --git a/samples/alpha-mj/InOut2.mj b/samples/alpha-mj/InOut2.mj
--- /dev/null
@@ -0,0 +1,10 @@
+program InOut2{
+ void main()
+ char c;
+ {
+ print('c');
+ print('?');
+ read(c);
+ print(c);
+ }
+}
\ No newline at end of file
diff --git a/samples/alpha-mj/InOut3.mj b/samples/alpha-mj/InOut3.mj
--- /dev/null
@@ -0,0 +1,23 @@
+program InOut3{
+ void main()
+ char c;
+ int i;
+ {
+ i = 5;
+ print('c');
+ print('?');
+ read(c);
+ print(c);
+ print(chr(10));
+ if (c=='y') {
+ print('i');
+ read(i);
+ } else {
+ print('c');
+ read(c);
+ }
+ print(chr(10));
+ print(i,5);
+ print(c,5);
+ }
+}
\ No newline at end of file
diff --git a/samples/alpha-mj/Rek1.mj b/samples/alpha-mj/Rek1.mj
--- /dev/null
+++ b/samples/alpha-mj/Rek1.mj
@@ -0,0 +1,11 @@
+program Rek1{
+ void func(int i){
+ print(i);
+ if (i>0)
+ func(i-1);
+ }
+
+ void main() {
+ func(5);
+ }
+}
\ No newline at end of file
diff --git a/samples/alpha-mj/RekFac.mj b/samples/alpha-mj/RekFac.mj
--- /dev/null
@@ -0,0 +1,17 @@
+program RekFac{
+
+ int factorial(int f)
+ {
+ if (f<0)
+ return 0;
+ if (f<=1)
+ return 1;
+ return factorial(f-1) * f ;
+ }
+
+ void main()
+ {
+ print(factorial(3),3);
+ print(factorial(10),10);
+ }
+}
\ No newline at end of file
diff --git a/samples/alpha-mj/RekFib.mj b/samples/alpha-mj/RekFib.mj
--- /dev/null
@@ -0,0 +1,18 @@
+program RekFib{
+
+ int fib(int f)
+ {
+ if (f==0)
+ return 0;
+ if (f==1)
+ return 1;
+ return fib(f-2)+fib(f-1) ;
+ }
+
+ void main()
+ {
+ print(fib(0),3);
+ print(fib(2),3);
+ print(fib(7),3);
+ }
+}
\ No newline at end of file
diff --git a/samples/alpha-mj/chrtest.mj b/samples/alpha-mj/chrtest.mj
--- /dev/null
@@ -0,0 +1,11 @@
+program P
+{
+ void main()
+ {
+ print(chr(65),5);
+ print('A',5);
+ print(chr(10),2);
+ print(ord('a'),5);
+ print('a',5);
+ }
+}
diff --git a/samples/alpha-mj/div0.mj b/samples/alpha-mj/div0.mj
--- /dev/null
+++ b/samples/alpha-mj/div0.mj
@@ -0,0 +1,11 @@
+program test\r
+{\r
+ void main()\r
+ int i, j;\r
+ {\r
+ i = 100; \r
+ j = 0;\r
+ print(i/j);\r
+ }\r
+\r
+}
\ No newline at end of file
diff --git a/samples/alpha-mj/div2.mj b/samples/alpha-mj/div2.mj
--- /dev/null
+++ b/samples/alpha-mj/div2.mj
@@ -0,0 +1,11 @@
+program test\r
+{\r
+ void main()\r
+ int i, j;\r
+ {\r
+ i = 100; \r
+ j = 2;\r
+ print(i/j);\r
+ }\r
+\r
+}
\ No newline at end of file
diff --git a/samples/alpha-mj/eratos.mj b/samples/alpha-mj/eratos.mj
--- /dev/null
@@ -0,0 +1,47 @@
+program Eratos\r
+\r
+ char[] sieve;\r
+ int max; // maximum prime to be found\r
+ int npp; // numbers per page\r
+\r
+{\r
+ void put(int x)\r
+ {\r
+ if (npp == 10) {\r
+ print(chr(13)); \r
+ print(chr(10)); \r
+ npp = 0;\r
+ }\r
+ print(x, 5);\r
+ npp++;\r
+ }\r
+ \r
+ void found(int x)\r
+ int i;\r
+ {\r
+ put(x);\r
+ i = x;\r
+ while (i <= max) {\r
+ sieve[i] = 'o'; i = i + x;\r
+ }\r
+ }\r
+\r
+ void main()\r
+ int i;\r
+ {\r
+ read(max);\r
+ npp = 0;\r
+ sieve = new char[max+1];\r
+ i = 0;\r
+ while (i <= max) {\r
+ sieve[i] = 'x'; i++;\r
+ }\r
+ i = 2;\r
+ while (i <= max) {\r
+ found(i);\r
+ while(i <= max && sieve[i] == 'o') \r
+ i++;\r
+ }\r
+ }\r
+\r
+}//test
\ No newline at end of file
diff --git a/samples/alpha-mj/fields.mj b/samples/alpha-mj/fields.mj
--- /dev/null
@@ -0,0 +1,44 @@
+program F
+ class HolderClass {
+ int simple;
+ int[] arry;
+ }
+
+ HolderClass holder;
+
+{
+ void main()
+ int i, size;
+ {
+ holder = new HolderClass;
+ holder.simple = 5;
+
+ print(holder.simple,10);
+
+ print(chr(10));
+
+ size = 5;
+ holder.arry = new int[size];
+ holder.arry[0] = size+1;
+ i = 1;
+ while (i < size){
+ holder.arry[i] = holder.arry[i-1]-1;
+ i++;
+ }
+
+ i = 0;
+ while (i < size){
+ print(holder.arry[i],3);
+ i++;
+ }
+ print(chr(10));
+
+ i = 0;
+ while (i < size){
+ holder.arry[i]--;
+ print(holder.arry[i],3);
+ i++;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/samples/alpha-mj/linkedlist.mj b/samples/alpha-mj/linkedlist.mj
--- /dev/null
@@ -0,0 +1,85 @@
+program linkedlist
+ class Element {
+ int info;
+ Element next;
+ }
+ Element first;
+{
+ void add(int i)
+ Element newone;
+ {
+ newone = new Element;
+ newone.info = i;
+ newone.next = first;
+ first = newone;
+ }
+
+ void printlist()
+ Element cur;
+ {
+ cur = first;
+ while (cur != null) {
+ print(cur.info);
+ cur = cur.next;
+ }
+ }
+
+ int exists(int i) Element cur; {
+ cur = first;
+ while (cur != null && cur.info != i)
+ cur = cur.next;
+ if (cur != null)
+ return 1;
+ else
+ return 0;
+ }
+
+ int count(int i) Element cur; int c;{
+ cur = first;
+ c = 0;
+ while (cur != null) {
+ if (cur.info == i)
+ c++;
+ cur = cur.next;
+ }
+ return c;
+ }
+
+ void main()
+ int num; int in; int c; {
+ print('l');
+ print('?');
+ read(num);
+ // demo
+ if (num<0) {
+ add(1);
+ add(2);
+ add(3);
+ add(2);
+ printlist();
+ print(exists(7));
+ print(count(2));
+ } else {
+ c = 0;
+ while (c<num) {
+ print(c);
+ print('?');
+ read(in);
+ add(in);
+ c++;
+ }
+ printlist();
+
+ print('e');
+ print('?');
+
+ read(in);
+ print(exists(in));
+
+ print('c');
+ print('?');
+ read(in);
+ print(count(in));
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/alpha-mj/pos-neg.mj b/samples/alpha-mj/pos-neg.mj
--- /dev/null
@@ -0,0 +1,42 @@
+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/alpha-mj/while-print.mj b/samples/alpha-mj/while-print.mj
--- /dev/null
@@ -0,0 +1,12 @@
+program P\r
+{\r
+ void main()\r
+ int i;\r
+ { \r
+ i = 0;\r
+ while (i < 5) {\r
+ print(i);\r
+ i = i + 1;\r
+ }\r
+ }\r
+}\r
diff --git a/samples/chrtest.mj b/samples/chrtest.mj
--- a/samples/chrtest.mj
+++ /dev/null
@@ -1,11 +0,0 @@
-program P
-{
- void main()
- {
- print(chr(65),5);
- print('A',5);
- print(chr(10),2);
- print(ord('a'),5);
- print('a',5);
- }
-}
diff --git a/samples/div0.mj b/samples/div0.mj
--- a/samples/div0.mj
+++ /dev/null
@@ -1,11 +0,0 @@
-program test\r
-{\r
- void main()\r
- int i, j;\r
- {\r
- i = 100; \r
- j = 0;\r
- print(i/j);\r
- }\r
-\r
-}
\ No newline at end of file
diff --git a/samples/div2.mj b/samples/div2.mj
--- a/samples/div2.mj
+++ /dev/null
@@ -1,11 +0,0 @@
-program test\r
-{\r
- void main()\r
- int i, j;\r
- {\r
- i = 100; \r
- j = 2;\r
- print(i/j);\r
- }\r
-\r
-}
\ No newline at end of file
diff --git a/samples/eratos.mj b/samples/eratos.mj
--- a/samples/eratos.mj
+++ /dev/null
@@ -1,47 +0,0 @@
-program Eratos\r
-\r
- char[] sieve;\r
- int max; // maximum prime to be found\r
- int npp; // numbers per page\r
-\r
-{\r
- void put(int x)\r
- {\r
- if (npp == 10) {\r
- print(chr(13)); \r
- print(chr(10)); \r
- npp = 0;\r
- }\r
- print(x, 5);\r
- npp++;\r
- }\r
- \r
- void found(int x)\r
- int i;\r
- {\r
- put(x);\r
- i = x;\r
- while (i <= max) {\r
- sieve[i] = 'o'; i = i + x;\r
- }\r
- }\r
-\r
- void main()\r
- int i;\r
- {\r
- read(max);\r
- npp = 0;\r
- sieve = new char[max+1];\r
- i = 0;\r
- while (i <= max) {\r
- sieve[i] = 'x'; i++;\r
- }\r
- i = 2;\r
- while (i <= max) {\r
- found(i);\r
- while(i <= max && sieve[i] == 'o') \r
- i++;\r
- }\r
- }\r
-\r
-}//test
\ No newline at end of file
diff --git a/samples/fields.mj b/samples/fields.mj
--- a/samples/fields.mj
+++ /dev/null
@@ -1,44 +0,0 @@
-program F
- class HolderClass {
- int simple;
- int[] arry;
- }
-
- HolderClass holder;
-
-{
- void main()
- int i, size;
- {
- holder = new HolderClass;
- holder.simple = 5;
-
- print(holder.simple,10);
-
- print(chr(10));
-
- size = 5;
- holder.arry = new int[size];
- holder.arry[0] = size+1;
- i = 1;
- while (i < size){
- holder.arry[i] = holder.arry[i-1]-1;
- i++;
- }
-
- i = 0;
- while (i < size){
- print(holder.arry[i],3);
- i++;
- }
- print(chr(10));
-
- i = 0;
- while (i < size){
- holder.arry[i]--;
- print(holder.arry[i],3);
- i++;
- }
-
- }
-}
\ No newline at end of file
diff --git a/samples/linkedlist.mj b/samples/linkedlist.mj
--- a/samples/linkedlist.mj
+++ /dev/null
@@ -1,85 +0,0 @@
-program linkedlist
- class Element {
- int info;
- Element next;
- }
- Element first;
-{
- void add(int i)
- Element newone;
- {
- newone = new Element;
- newone.info = i;
- newone.next = first;
- first = newone;
- }
-
- void printlist()
- Element cur;
- {
- cur = first;
- while (cur != null) {
- print(cur.info);
- cur = cur.next;
- }
- }
-
- int exists(int i) Element cur; {
- cur = first;
- while (cur != null && cur.info != i)
- cur = cur.next;
- if (cur != null)
- return 1;
- else
- return 0;
- }
-
- int count(int i) Element cur; int c;{
- cur = first;
- c = 0;
- while (cur != null) {
- if (cur.info == i)
- c++;
- cur = cur.next;
- }
- return c;
- }
-
- void main()
- int num; int in; int c; {
- print('l');
- print('?');
- read(num);
- // demo
- if (num<0) {
- add(1);
- add(2);
- add(3);
- add(2);
- printlist();
- print(exists(7));
- print(count(2));
- } else {
- c = 0;
- while (c<num) {
- print(c);
- print('?');
- read(in);
- add(in);
- c++;
- }
- printlist();
-
- print('e');
- print('?');
-
- read(in);
- print(exists(in));
-
- print('c');
- print('?');
- read(in);
- print(count(in));
- }
- }
-}
\ No newline at end of file
diff --git a/samples/pos-neg.mj b/samples/pos-neg.mj
--- a/samples/pos-neg.mj
+++ /dev/null
@@ -1,42 +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/while-print.mj b/samples/while-print.mj
--- a/samples/while-print.mj
+++ /dev/null
@@ -1,12 +0,0 @@
-program P\r
-{\r
- void main()\r
- int i;\r
- { \r
- i = 0;\r
- while (i < 5) {\r
- print(i);\r
- i = i + 1;\r
- }\r
- }\r
-}\r