diff options
Diffstat (limited to 'test.toc')
-rw-r--r-- | test.toc | 41 |
1 files changed, 1 insertions, 40 deletions
@@ -1,41 +1,2 @@ -voidptr ::= &u8; - -getstdout ::= fn() voidptr { - #builtin("stdout") +addmul ::= fn (x:=0, y:=0) add := x+y, mul := x*y { }; - -getstdin ::= fn() voidptr { - #builtin("stdin") -}; - -fwrite :: fn(voidptr, u64, u64, voidptr) u64 = #foreign "fwrite", "libc.so.6"; -fputc :: fn(i32, voidptr) i32 = #foreign "fputc", "libc.so.6"; -fgets :: fn(&char, i32, voidptr) &char = #foreign "fgets", "libc.so.6"; - -writes ::= fn(x : []char) { - fwrite(&x[0] as voidptr, 1, x.len as u64, getstdout()); -}; - -puts ::= fn(x : []char) { - writes(x); - fputc('\n' as i32, getstdout()); -}; - -hw ::= fn() int { - name : [1024]char; - writes("Name? "); - fgets(&name[0], name.len as i32, getstdin()); - - writes("Hello, "); - if #builtin("compiling") { - writes("compiling "); - } - - writes(name[:]); // fgets already has a newline - 2 -}; - -main ::= fn() { - hw(); - x ::= hw(); -};
\ No newline at end of file |