summaryrefslogtreecommitdiff
path: root/nl
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-01-31 18:12:14 +0100
committertomsmeding <tom.smeding@gmail.com>2017-01-31 18:12:14 +0100
commite85b818023fe409468b9802ce2923b5f26974bc4 (patch)
tree7b66139a38b3bdfbad180f8d8fbffb9589192c13 /nl
parent9b71b9206cd6854877262de2aa1c76421aa899be (diff)
Move test files to separate folder
Diffstat (limited to 'nl')
-rw-r--r--nl/block.nl10
-rw-r--r--nl/fibo.nl35
-rw-r--r--nl/puts.nl9
-rw-r--r--nl/simple.nl20
-rw-r--r--nl/test.nl19
-rw-r--r--nl/test_string.nl17
6 files changed, 110 insertions, 0 deletions
diff --git a/nl/block.nl b/nl/block.nl
new file mode 100644
index 0000000..c9052d6
--- /dev/null
+++ b/nl/block.nl
@@ -0,0 +1,10 @@
+i32 main(){
+ i32 kaas = 1;
+ i32 piet = 2;
+ print(kaas + 3);
+ i64 nogwat = 3;
+ if(kaas == 1){
+ print(piet);
+ i32 x = 10;
+ }
+} \ No newline at end of file
diff --git a/nl/fibo.nl b/nl/fibo.nl
new file mode 100644
index 0000000..ac12c2d
--- /dev/null
+++ b/nl/fibo.nl
@@ -0,0 +1,35 @@
+type int = i32;
+type char = i8;
+
+extern func void(int) putchar;
+
+void printnum(int n){
+ if(n==0){
+ putchar('0');
+ putchar('\n');
+ return;
+ }
+ if(n<0){
+ putchar('-');
+ n=-n;
+ }
+ while(n>0){
+ putchar('0'+n%10);
+ n=n/10;
+ }
+ putchar('\n');
+ return;
+}
+
+int main(){
+ int a=0;
+ int b=1;
+ int i=0;
+ while(i<=10){
+ printnum(b);
+ b=a+b;
+ a=b-a;
+ i=i+1;
+ }
+ return 0;
+}
diff --git a/nl/puts.nl b/nl/puts.nl
new file mode 100644
index 0000000..4379916
--- /dev/null
+++ b/nl/puts.nl
@@ -0,0 +1,9 @@
+type int = i32;
+type char = i8;
+
+extern func int(ptr(char)) puts;
+
+int main(){
+ puts("kaas!");
+ return 0;
+} \ No newline at end of file
diff --git a/nl/simple.nl b/nl/simple.nl
new file mode 100644
index 0000000..699fec2
--- /dev/null
+++ b/nl/simple.nl
@@ -0,0 +1,20 @@
+type int = i32;
+type char = i8;
+
+int g_var;
+
+int main(i32 argc, ptr(ptr(i8)) argv) {
+ //int i = g_var;
+ int i = 40;
+ //i = g_var + 2 + 3;
+ int a = i + 2;
+ if (a == 41) {
+ return 10;
+ } else {
+ a = 20;
+ }
+ while (a < 42) {
+ a = a + 1;
+ }
+ return a;
+}
diff --git a/nl/test.nl b/nl/test.nl
new file mode 100644
index 0000000..5e23bf3
--- /dev/null
+++ b/nl/test.nl
@@ -0,0 +1,19 @@
+type int = i32;
+type char = i8;
+
+int glob;
+
+int main(int argc, ptr(char) argv) {
+ glob = 10;
+ int kaas = glob + 2;
+ glob = 2 > 1 || 1 == 1 % 10;
+ while (glob < 20) {
+ if (kaas == 12) glob = glob + 3 / 2;
+ else glob = glob - 1;
+ if (glob < -10) return glob;
+ if (glob < -12) {
+ return glob;
+ } else {}
+ }
+ return kaas;
+}
diff --git a/nl/test_string.nl b/nl/test_string.nl
new file mode 100644
index 0000000..ccba9a1
--- /dev/null
+++ b/nl/test_string.nl
@@ -0,0 +1,17 @@
+type int = i32;
+type char = i8;
+type string = ptr(char);
+
+extern func void(int) putchar;
+
+void f(char c) {
+ putchar(c);
+ return;
+}
+
+int main(int argc, ptr(string) argv) {
+ string s = "kaas";
+ ptr(i8) s2 = "kaas2";
+ f('x');
+ return 0;
+}