From c3c19f3220485af12c3a5561ad1754bf546e7429 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 2 Sep 2017 15:48:01 +0200 Subject: Move *.lang files to a directory --- arrays.lang | 7 -- bf.lang | 104 ----------------------------- chaincond.lang | 14 ---- chartest.lang | 19 ------ compare.lang | 10 --- dupifs.lang | 8 --- fibo.lang | 31 --------- l/arrays.lang | 7 ++ l/bf.lang | 104 +++++++++++++++++++++++++++++ l/chaincond.lang | 14 ++++ l/chartest.lang | 19 ++++++ l/compare.lang | 10 +++ l/dupifs.lang | 8 +++ l/fibo.lang | 31 +++++++++ l/opttest.lang | 8 +++ l/primes.bf | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ l/putint.lang | 4 ++ l/putstr.lang | 19 ++++++ l/strlen.lang | 11 ++++ l/struct.lang | 34 ++++++++++ l/test.lang | 20 ++++++ opttest.lang | 8 --- primes.bf | 194 ------------------------------------------------------- putint.lang | 4 -- putstr.lang | 19 ------ strlen.lang | 11 ---- struct.lang | 34 ---------- test.lang | 20 ------ todo.txt | 2 + 29 files changed, 485 insertions(+), 483 deletions(-) delete mode 100644 arrays.lang delete mode 100644 bf.lang delete mode 100644 chaincond.lang delete mode 100644 chartest.lang delete mode 100644 compare.lang delete mode 100644 dupifs.lang delete mode 100644 fibo.lang create mode 100644 l/arrays.lang create mode 100644 l/bf.lang create mode 100644 l/chaincond.lang create mode 100644 l/chartest.lang create mode 100644 l/compare.lang create mode 100644 l/dupifs.lang create mode 100644 l/fibo.lang create mode 100644 l/opttest.lang create mode 100644 l/primes.bf create mode 100644 l/putint.lang create mode 100644 l/putstr.lang create mode 100644 l/strlen.lang create mode 100644 l/struct.lang create mode 100644 l/test.lang delete mode 100644 opttest.lang delete mode 100644 primes.bf delete mode 100644 putint.lang delete mode 100644 putstr.lang delete mode 100644 strlen.lang delete mode 100644 struct.lang delete mode 100644 test.lang create mode 100644 todo.txt diff --git a/arrays.lang b/arrays.lang deleted file mode 100644 index 8cab05f..0000000 --- a/arrays.lang +++ /dev/null @@ -1,7 +0,0 @@ -func int main() { - int[] arr := new int[5]; - arr[0] = 97; - arr[1] = 98; - putc(char(arr[0])); - return 0; -} diff --git a/bf.lang b/bf.lang deleted file mode 100644 index 0ce6389..0000000 --- a/bf.lang +++ /dev/null @@ -1,104 +0,0 @@ -type byte := char; - -func putstr(char[] str) { - int i := 0; - while (str[i] != '\0') { - putc(str[i]); - i = i + 1; - } -} - -func int[] makejumpmap(char[] src, int srclen) { - int[] jm := new int[srclen]; - int[] stack := new int[srclen]; - int stkp := 0; - int i := 0; - while (i < srclen) { - // putint(i); putc(' '); putint(stkp); putc(' '); putc(src[i]); putc('\n'); - if (src[i] == '[') { - stack[stkp] = i; - stkp = stkp + 1; - } - if (src[i] == ']') { - stkp = stkp - 1; - int j := stack[stkp]; - jm[i] = j; - jm[j] = i; - } - i = i + 1; - } - if (stkp != 0) { - putstr("Unmatched opening brackets in BF source\n"); - exit(1); - } - /*i = 0; - while (i < srclen) { - putint(jm[i]); - putc(' '); - i = i + 1; - } - putc('\n');*/ - return jm; -} - -func interpret(char[] src, int srclen) { - int[] jm := makejumpmap(src, srclen); - byte[] mem := new char[4088]; - int ip := 0; - int memp := 0; - while (src[ip] != '\0') { - // putint(ip); putc('\n'); - char c := src[ip]; - if (c == '+') {mem[memp] = mem[memp] + byte(1);} - if (c == '-') {mem[memp] = mem[memp] - byte(1);} - if (c == '>') {memp = memp + 1;} - if (c == '<') {memp = memp - 1;} - if (c == '.') {putc(mem[memp]);} - if (c == ',') {mem[memp] = byte(getc());} - if (c == '[') { - if (mem[memp] == '\0') { - ip = jm[ip]; - } - } - if (c == ']') { - if (mem[memp] != '\0') { - ip = jm[ip]; - } - } - ip = ip + 1; - } - - // debugger; - - putc('\n'); - memp = 0; - while (memp < 10) { - putint(int(mem[memp]) & 0xff); putc(' '); - memp = memp + 1; - } - putc('\n'); -} - -func int main() { - int bufsize := 12280; - char[] source := new char[12280]; - - int sourcelen := 0; - while (1) { - int c := getc(); - // putc(char(c)); - if (c < 0) { - break; - } else { - source[sourcelen] = char(c); - sourcelen = sourcelen + 1; - if (sourcelen >= bufsize - 1) { - break; - } - } - } - source[sourcelen] = '\0'; - - interpret(source, sourcelen); - return 0; -} diff --git a/chaincond.lang b/chaincond.lang deleted file mode 100644 index 542cae9..0000000 --- a/chaincond.lang +++ /dev/null @@ -1,14 +0,0 @@ -func int main() { - int a := 0; - if (a == 0) { - a = 1; - } else { - a = 2; - } - if (a > 0) { - a = 10; - } else { - a = 20; - } - return a; -} \ No newline at end of file diff --git a/chartest.lang b/chartest.lang deleted file mode 100644 index 208bcab..0000000 --- a/chartest.lang +++ /dev/null @@ -1,19 +0,0 @@ -int glob := 42; - -func f(char x) { - putc(x); -} - -func char g() { - return '\n'; -} - -func int main() { - char c := 'a'; - f(c); - putc('\n'); - char d := g(); - c = d + d + d + d + d + d + d + d + 'a'; - putc(c); - return 0; -} diff --git a/compare.lang b/compare.lang deleted file mode 100644 index 1de9a70..0000000 --- a/compare.lang +++ /dev/null @@ -1,10 +0,0 @@ -func int main() { - int i := 0; - while (i != 10) { - if (i == 5) { - i = i + 2; - } - i = i + 1; - } - return 0; -} diff --git a/dupifs.lang b/dupifs.lang deleted file mode 100644 index 91e7ca4..0000000 --- a/dupifs.lang +++ /dev/null @@ -1,8 +0,0 @@ -func int main() { - int c := getc(); - int i := 0; - if (c == 97) {i = 1;} - if (c == 98) {i = 2;} - putint(i); - return 0; -} diff --git a/fibo.lang b/fibo.lang deleted file mode 100644 index e1a7a4a..0000000 --- a/fibo.lang +++ /dev/null @@ -1,31 +0,0 @@ -func printnum(int n) { - if (n == 0) {putc('0'); return;} - if (n < 0) {putc('-'); n = -n;} - while (n > 0) { - putc('0' + char(n % 10)); - n = n / 10; - } -} - -func int fibo(int n) { - int a := 0; - int b := 1; - int i := 0; - while (i < n) { - int c := a + b; - a = b; - b = c; - i = i + 1; - } - return b; -} - -func int main() { - int i := 0; - while (i <= 20) { - printnum(fibo(i)); - putc('\n'); - i = i + 1; - } - return 0; -} diff --git a/l/arrays.lang b/l/arrays.lang new file mode 100644 index 0000000..8cab05f --- /dev/null +++ b/l/arrays.lang @@ -0,0 +1,7 @@ +func int main() { + int[] arr := new int[5]; + arr[0] = 97; + arr[1] = 98; + putc(char(arr[0])); + return 0; +} diff --git a/l/bf.lang b/l/bf.lang new file mode 100644 index 0000000..0ce6389 --- /dev/null +++ b/l/bf.lang @@ -0,0 +1,104 @@ +type byte := char; + +func putstr(char[] str) { + int i := 0; + while (str[i] != '\0') { + putc(str[i]); + i = i + 1; + } +} + +func int[] makejumpmap(char[] src, int srclen) { + int[] jm := new int[srclen]; + int[] stack := new int[srclen]; + int stkp := 0; + int i := 0; + while (i < srclen) { + // putint(i); putc(' '); putint(stkp); putc(' '); putc(src[i]); putc('\n'); + if (src[i] == '[') { + stack[stkp] = i; + stkp = stkp + 1; + } + if (src[i] == ']') { + stkp = stkp - 1; + int j := stack[stkp]; + jm[i] = j; + jm[j] = i; + } + i = i + 1; + } + if (stkp != 0) { + putstr("Unmatched opening brackets in BF source\n"); + exit(1); + } + /*i = 0; + while (i < srclen) { + putint(jm[i]); + putc(' '); + i = i + 1; + } + putc('\n');*/ + return jm; +} + +func interpret(char[] src, int srclen) { + int[] jm := makejumpmap(src, srclen); + byte[] mem := new char[4088]; + int ip := 0; + int memp := 0; + while (src[ip] != '\0') { + // putint(ip); putc('\n'); + char c := src[ip]; + if (c == '+') {mem[memp] = mem[memp] + byte(1);} + if (c == '-') {mem[memp] = mem[memp] - byte(1);} + if (c == '>') {memp = memp + 1;} + if (c == '<') {memp = memp - 1;} + if (c == '.') {putc(mem[memp]);} + if (c == ',') {mem[memp] = byte(getc());} + if (c == '[') { + if (mem[memp] == '\0') { + ip = jm[ip]; + } + } + if (c == ']') { + if (mem[memp] != '\0') { + ip = jm[ip]; + } + } + ip = ip + 1; + } + + // debugger; + + putc('\n'); + memp = 0; + while (memp < 10) { + putint(int(mem[memp]) & 0xff); putc(' '); + memp = memp + 1; + } + putc('\n'); +} + +func int main() { + int bufsize := 12280; + char[] source := new char[12280]; + + int sourcelen := 0; + while (1) { + int c := getc(); + // putc(char(c)); + if (c < 0) { + break; + } else { + source[sourcelen] = char(c); + sourcelen = sourcelen + 1; + if (sourcelen >= bufsize - 1) { + break; + } + } + } + source[sourcelen] = '\0'; + + interpret(source, sourcelen); + return 0; +} diff --git a/l/chaincond.lang b/l/chaincond.lang new file mode 100644 index 0000000..542cae9 --- /dev/null +++ b/l/chaincond.lang @@ -0,0 +1,14 @@ +func int main() { + int a := 0; + if (a == 0) { + a = 1; + } else { + a = 2; + } + if (a > 0) { + a = 10; + } else { + a = 20; + } + return a; +} \ No newline at end of file diff --git a/l/chartest.lang b/l/chartest.lang new file mode 100644 index 0000000..208bcab --- /dev/null +++ b/l/chartest.lang @@ -0,0 +1,19 @@ +int glob := 42; + +func f(char x) { + putc(x); +} + +func char g() { + return '\n'; +} + +func int main() { + char c := 'a'; + f(c); + putc('\n'); + char d := g(); + c = d + d + d + d + d + d + d + d + 'a'; + putc(c); + return 0; +} diff --git a/l/compare.lang b/l/compare.lang new file mode 100644 index 0000000..1de9a70 --- /dev/null +++ b/l/compare.lang @@ -0,0 +1,10 @@ +func int main() { + int i := 0; + while (i != 10) { + if (i == 5) { + i = i + 2; + } + i = i + 1; + } + return 0; +} diff --git a/l/dupifs.lang b/l/dupifs.lang new file mode 100644 index 0000000..91e7ca4 --- /dev/null +++ b/l/dupifs.lang @@ -0,0 +1,8 @@ +func int main() { + int c := getc(); + int i := 0; + if (c == 97) {i = 1;} + if (c == 98) {i = 2;} + putint(i); + return 0; +} diff --git a/l/fibo.lang b/l/fibo.lang new file mode 100644 index 0000000..e1a7a4a --- /dev/null +++ b/l/fibo.lang @@ -0,0 +1,31 @@ +func printnum(int n) { + if (n == 0) {putc('0'); return;} + if (n < 0) {putc('-'); n = -n;} + while (n > 0) { + putc('0' + char(n % 10)); + n = n / 10; + } +} + +func int fibo(int n) { + int a := 0; + int b := 1; + int i := 0; + while (i < n) { + int c := a + b; + a = b; + b = c; + i = i + 1; + } + return b; +} + +func int main() { + int i := 0; + while (i <= 20) { + printnum(fibo(i)); + putc('\n'); + i = i + 1; + } + return 0; +} diff --git a/l/opttest.lang b/l/opttest.lang new file mode 100644 index 0000000..9f87e78 --- /dev/null +++ b/l/opttest.lang @@ -0,0 +1,8 @@ +func int main() { + int a := 1; + int b := 2; + int x := a + b; + b = 100; + putint(x); putc('\n'); + return 0; +} diff --git a/l/primes.bf b/l/primes.bf new file mode 100644 index 0000000..f492705 --- /dev/null +++ b/l/primes.bf @@ -0,0 +1,194 @@ +compute prime numbers +to use type the max number then push Alt 1 0 +=================================================================== +======================== OUTPUT STRING ============================ +=================================================================== +>++++++++[<++++++++>-]<++++++++++++++++.[-] +>++++++++++[<++++++++++>-]<++++++++++++++.[-] +>++++++++++[<++++++++++>-]<+++++.[-] +>++++++++++[<++++++++++>-]<+++++++++.[-] +>++++++++++[<++++++++++>-]<+.[-] +>++++++++++[<++++++++++>-]<+++++++++++++++.[-] +>+++++[<+++++>-]<+++++++.[-] +>++++++++++[<++++++++++>-]<+++++++++++++++++.[-] +>++++++++++[<++++++++++>-]<++++++++++++.[-] +>+++++[<+++++>-]<+++++++.[-] +>++++++++++[<++++++++++>-]<++++++++++++++++.[-] +>++++++++++[<++++++++++>-]<+++++++++++.[-] +>+++++++[<+++++++>-]<+++++++++.[-] +>+++++[<+++++>-]<+++++++.[-] +=================================================================== +======================== INPUT NUMBER ============================ +=================================================================== +[[[ COMMENT + + cont=1 + [ + - cont=0 + >, + ======SUB10====== + ---------- + + [ not 10 + <+> cont=1 + =====SUB38====== + ---------- + ---------- + ---------- + -------- + > + =====MUL10======= + [>+>+<<-]>>[<<+>>-]< dup + >>>+++++++++ + [ + <<< + [>+>+<<-]>>[<<+>>-]< dup + [<<+>>-] + >>- + ] + <<<[-]< + ======RMOVE1====== + < + [>+<-] + ] + < + ] + >>[<<+>>-]<< +]]] +++++++++++.[-] OUTPUT A NEWLINE +- THE INPUT NUMBER (WE DONT HAVE STDIN YET) +=================================================================== +======================= PROCESS NUMBER =========================== +=================================================================== +==== ==== ==== ==== +numd numu teid teiu +==== ==== ==== ==== +>+<- +[ + >+ + ======DUP====== + [>+>+<<-]>>[<<+>>-]< + >+<-- + >>>>>>>>+<<<<<<<< isprime=1 + [ + >+ + <- + =====DUP3===== + <[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<<< + =====DUP2===== + >[>>+>+<<<-]>>>[<<<+>>>-]<<< < + >>> + ====DIVIDES======= + [>+>+<<-]>>[<<+>>-]< DUP i=div + + << + [ + >>>>>+ bool=1 + <<< + [>+>+<<-]>>[<<+>>-]< DUP + [>>[-]<<-] IF i THEN bool=0 + >> + [ IF i=0 + <<<< + [>+>+<<-]>>[<<+>>-]< i=div + >>> + - bool=0 + ] + <<< + - DEC i + << + - + ] + + +>>[<<[-]>>-]<< + >[-]< CLR div + =====END DIVIDES==== + [>>>>>>[-]<<<<<<-] if divides then isprime=0 + << + >>[-]>[-]<<< + ] + >>>>>>>> + [ + - + <<<<<<<[-]<< + [>>+>+<<<-]>>>[<<<+>>>-]<<< + >> + =================================================================== + ======================== OUTPUT NUMBER =========================== + =================================================================== + [>+<-]> + + [ + ======DUP====== + [>+>+<<-]>>[<<+>>-]< + + + ======MOD10==== + >+++++++++< + [ + >>>+<< bool= 1 + [>+>[-]<<-] bool= ten==0 + >[<+>-] ten = tmp + >[<<++++++++++>>-] if ten=0 ten=10 + <<- dec ten + <- dec num + ] + +++++++++ num=9 + >[<->-]< dec num by ten + + =======RROT====== + [>+<-] + < [>+<-] + < [>+<-] + >>>[<<<+>>>-] + < + + =======DIV10======== + >+++++++++< + [ + >>>+<< bool= 1 + [>+>[-]<<-] bool= ten==0 + >[<+>-] ten = tmp + >[<<++++++++++>>>+<-] if ten=0 ten=10 inc div + <<- dec ten + <- dec num + ] + >>>>[<<<<+>>>>-]<<<< copy div to num + >[-]< clear ten + + =======INC1========= + <+> + ] + + < + [ + =======MOVER========= + [>+<-] + + =======ADD48======== + +++++++[<+++++++>-]<-> + + =======PUTC======= + <.[-]> + + ======MOVEL2======== + >[<<+>>-]< + + <- + ] + + >++++[<++++++++>-]<.[-] + + =================================================================== + =========================== END FOR =============================== + =================================================================== + >>>>>>> + ] + <<<<<<<< + >[-]< + [-] + <<- +] + +======LF======== + +++++++++++.[-] diff --git a/l/putint.lang b/l/putint.lang new file mode 100644 index 0000000..198b4ee --- /dev/null +++ b/l/putint.lang @@ -0,0 +1,4 @@ +func int main() { + putint(-12345678); putc('\n'); + return 0; +} diff --git a/l/putstr.lang b/l/putstr.lang new file mode 100644 index 0000000..f132bda --- /dev/null +++ b/l/putstr.lang @@ -0,0 +1,19 @@ +func putstr(char[] str) { + int i := 0; + while (str[i] != '\0') { + putc(str[i]); + i = i + 1; + } +} + +func int main() { + char[] str := new char[100]; + str[0] = 'k'; + str[1] = 'a'; + str[2] = str[1]; + str[3] = 's'; + str[4] = '\n'; + str[5] = '\0'; + putstr(str); + return 0; +} diff --git a/l/strlen.lang b/l/strlen.lang new file mode 100644 index 0000000..27c23a3 --- /dev/null +++ b/l/strlen.lang @@ -0,0 +1,11 @@ +func int strlen(char[] str) { + int i := 0; + char c := str[i]; + while (c != '\0') { + i = i + 1; + c = str[i]; + } + return i; +} + +func int main() {return 0;} diff --git a/l/struct.lang b/l/struct.lang new file mode 100644 index 0000000..00b3442 --- /dev/null +++ b/l/struct.lang @@ -0,0 +1,34 @@ +type S := struct { + int x; + char y; +}; + +S global := {x = 1, y = '!'}; + +func f(int iets1, S s, int iets2) { + putint(s.x); putc(s.y); putc('\n'); + putint(iets1); putc(' '); putint(iets2); putc('\n'); +} + +func int main() { + /*global.x = 3 * global.x + int(global.y); + putint(global.x + 1); putc(global.y); putc('\n'); + int a := getc(); + int b := getc(); + getc(); // newline + S ding := {x = 2*a, y = 'a'}; + // return ding.x; + f(123, ding, 456); + S ding2 := ding; + ding2.x = ding2.x; + // ding2.y = ding2.y; + f(234, ding2, 567); + return int(ding.y) + a + b;*/ + + int a := getc(); + getc(); // newline + S ding := {x = 2*a, y = 'a'}; + S ding2 := ding; + f(123, ding2, 456); + return 0; +} diff --git a/l/test.lang b/l/test.lang new file mode 100644 index 0000000..f03b3e3 --- /dev/null +++ b/l/test.lang @@ -0,0 +1,20 @@ +int glob := 100; + +func f() { + glob = glob + 10; +} + +func g(int x , int y) { + glob = glob + x + 2 * y; +} + +func int main() { + int i := 0; /* block /* comments */ nest! */ + // int[4] arr := 2; + i = i + 1; + f(); + if (i > 0 && i < 10) { + int i := 20; + g(i , 2 * i); + } +} diff --git a/opttest.lang b/opttest.lang deleted file mode 100644 index 9f87e78..0000000 --- a/opttest.lang +++ /dev/null @@ -1,8 +0,0 @@ -func int main() { - int a := 1; - int b := 2; - int x := a + b; - b = 100; - putint(x); putc('\n'); - return 0; -} diff --git a/primes.bf b/primes.bf deleted file mode 100644 index f492705..0000000 --- a/primes.bf +++ /dev/null @@ -1,194 +0,0 @@ -compute prime numbers -to use type the max number then push Alt 1 0 -=================================================================== -======================== OUTPUT STRING ============================ -=================================================================== ->++++++++[<++++++++>-]<++++++++++++++++.[-] ->++++++++++[<++++++++++>-]<++++++++++++++.[-] ->++++++++++[<++++++++++>-]<+++++.[-] ->++++++++++[<++++++++++>-]<+++++++++.[-] ->++++++++++[<++++++++++>-]<+.[-] ->++++++++++[<++++++++++>-]<+++++++++++++++.[-] ->+++++[<+++++>-]<+++++++.[-] ->++++++++++[<++++++++++>-]<+++++++++++++++++.[-] ->++++++++++[<++++++++++>-]<++++++++++++.[-] ->+++++[<+++++>-]<+++++++.[-] ->++++++++++[<++++++++++>-]<++++++++++++++++.[-] ->++++++++++[<++++++++++>-]<+++++++++++.[-] ->+++++++[<+++++++>-]<+++++++++.[-] ->+++++[<+++++>-]<+++++++.[-] -=================================================================== -======================== INPUT NUMBER ============================ -=================================================================== -[[[ COMMENT - + cont=1 - [ - - cont=0 - >, - ======SUB10====== - ---------- - - [ not 10 - <+> cont=1 - =====SUB38====== - ---------- - ---------- - ---------- - -------- - > - =====MUL10======= - [>+>+<<-]>>[<<+>>-]< dup - >>>+++++++++ - [ - <<< - [>+>+<<-]>>[<<+>>-]< dup - [<<+>>-] - >>- - ] - <<<[-]< - ======RMOVE1====== - < - [>+<-] - ] - < - ] - >>[<<+>>-]<< -]]] -++++++++++.[-] OUTPUT A NEWLINE -- THE INPUT NUMBER (WE DONT HAVE STDIN YET) -=================================================================== -======================= PROCESS NUMBER =========================== -=================================================================== -==== ==== ==== ==== -numd numu teid teiu -==== ==== ==== ==== ->+<- -[ - >+ - ======DUP====== - [>+>+<<-]>>[<<+>>-]< - >+<-- - >>>>>>>>+<<<<<<<< isprime=1 - [ - >+ - <- - =====DUP3===== - <[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<<< - =====DUP2===== - >[>>+>+<<<-]>>>[<<<+>>>-]<<< < - >>> - ====DIVIDES======= - [>+>+<<-]>>[<<+>>-]< DUP i=div - - << - [ - >>>>>+ bool=1 - <<< - [>+>+<<-]>>[<<+>>-]< DUP - [>>[-]<<-] IF i THEN bool=0 - >> - [ IF i=0 - <<<< - [>+>+<<-]>>[<<+>>-]< i=div - >>> - - bool=0 - ] - <<< - - DEC i - << - - - ] - - +>>[<<[-]>>-]<< - >[-]< CLR div - =====END DIVIDES==== - [>>>>>>[-]<<<<<<-] if divides then isprime=0 - << - >>[-]>[-]<<< - ] - >>>>>>>> - [ - - - <<<<<<<[-]<< - [>>+>+<<<-]>>>[<<<+>>>-]<<< - >> - =================================================================== - ======================== OUTPUT NUMBER =========================== - =================================================================== - [>+<-]> - - [ - ======DUP====== - [>+>+<<-]>>[<<+>>-]< - - - ======MOD10==== - >+++++++++< - [ - >>>+<< bool= 1 - [>+>[-]<<-] bool= ten==0 - >[<+>-] ten = tmp - >[<<++++++++++>>-] if ten=0 ten=10 - <<- dec ten - <- dec num - ] - +++++++++ num=9 - >[<->-]< dec num by ten - - =======RROT====== - [>+<-] - < [>+<-] - < [>+<-] - >>>[<<<+>>>-] - < - - =======DIV10======== - >+++++++++< - [ - >>>+<< bool= 1 - [>+>[-]<<-] bool= ten==0 - >[<+>-] ten = tmp - >[<<++++++++++>>>+<-] if ten=0 ten=10 inc div - <<- dec ten - <- dec num - ] - >>>>[<<<<+>>>>-]<<<< copy div to num - >[-]< clear ten - - =======INC1========= - <+> - ] - - < - [ - =======MOVER========= - [>+<-] - - =======ADD48======== - +++++++[<+++++++>-]<-> - - =======PUTC======= - <.[-]> - - ======MOVEL2======== - >[<<+>>-]< - - <- - ] - - >++++[<++++++++>-]<.[-] - - =================================================================== - =========================== END FOR =============================== - =================================================================== - >>>>>>> - ] - <<<<<<<< - >[-]< - [-] - <<- -] - -======LF======== - -++++++++++.[-] diff --git a/putint.lang b/putint.lang deleted file mode 100644 index 198b4ee..0000000 --- a/putint.lang +++ /dev/null @@ -1,4 +0,0 @@ -func int main() { - putint(-12345678); putc('\n'); - return 0; -} diff --git a/putstr.lang b/putstr.lang deleted file mode 100644 index f132bda..0000000 --- a/putstr.lang +++ /dev/null @@ -1,19 +0,0 @@ -func putstr(char[] str) { - int i := 0; - while (str[i] != '\0') { - putc(str[i]); - i = i + 1; - } -} - -func int main() { - char[] str := new char[100]; - str[0] = 'k'; - str[1] = 'a'; - str[2] = str[1]; - str[3] = 's'; - str[4] = '\n'; - str[5] = '\0'; - putstr(str); - return 0; -} diff --git a/strlen.lang b/strlen.lang deleted file mode 100644 index 27c23a3..0000000 --- a/strlen.lang +++ /dev/null @@ -1,11 +0,0 @@ -func int strlen(char[] str) { - int i := 0; - char c := str[i]; - while (c != '\0') { - i = i + 1; - c = str[i]; - } - return i; -} - -func int main() {return 0;} diff --git a/struct.lang b/struct.lang deleted file mode 100644 index 00b3442..0000000 --- a/struct.lang +++ /dev/null @@ -1,34 +0,0 @@ -type S := struct { - int x; - char y; -}; - -S global := {x = 1, y = '!'}; - -func f(int iets1, S s, int iets2) { - putint(s.x); putc(s.y); putc('\n'); - putint(iets1); putc(' '); putint(iets2); putc('\n'); -} - -func int main() { - /*global.x = 3 * global.x + int(global.y); - putint(global.x + 1); putc(global.y); putc('\n'); - int a := getc(); - int b := getc(); - getc(); // newline - S ding := {x = 2*a, y = 'a'}; - // return ding.x; - f(123, ding, 456); - S ding2 := ding; - ding2.x = ding2.x; - // ding2.y = ding2.y; - f(234, ding2, 567); - return int(ding.y) + a + b;*/ - - int a := getc(); - getc(); // newline - S ding := {x = 2*a, y = 'a'}; - S ding2 := ding; - f(123, ding2, 456); - return 0; -} diff --git a/test.lang b/test.lang deleted file mode 100644 index f03b3e3..0000000 --- a/test.lang +++ /dev/null @@ -1,20 +0,0 @@ -int glob := 100; - -func f() { - glob = glob + 10; -} - -func g(int x , int y) { - glob = glob + x + 2 * y; -} - -func int main() { - int i := 0; /* block /* comments */ nest! */ - // int[4] arr := 2; - i = i + 1; - f(); - if (i > 0 && i < 10) { - int i := 20; - g(i , 2 * i); - } -} diff --git a/todo.txt b/todo.txt new file mode 100644 index 0000000..63916b2 --- /dev/null +++ b/todo.txt @@ -0,0 +1,2 @@ +- Move arguments to a temporary at the beginning of the function. If it's only read, it's constant propagated everywhere and the situation is exactly the same as before (arguably not perfect, but still). Otherwise, you have it in a register and you're happy. + Only situation where this is *worse* is if that temp is then spilled. This is only one memory move at the function entry then, which is not that bad. -- cgit v1.2.3-70-g09d2