diff options
| author | 2022-08-25 06:13:58 +0200 | |
|---|---|---|
| committer | 2022-08-25 06:13:58 +0200 | |
| commit | 033e0fc64415dcaebf15ec26f743e8916fc0aa03 (patch) | |
| tree | a851cfa66289e9a3f8f8b3d01a0731606763298b /test | |
| parent | 4f479ac68028a89c8e545f72335642c42a5c4efe (diff) | |
iswitch
Diffstat (limited to 'test')
| -rw-r--r-- | test/1.cff | 17 | ||||
| -rw-r--r-- | test/libc.hff | 32 |
2 files changed, 49 insertions, 0 deletions
diff --git a/test/1.cff b/test/1.cff new file mode 100644 index 0000000..cdda6b9 --- /dev/null +++ b/test/1.cff @@ -0,0 +1,17 @@ +import "libc.hff"; + +extern fn main(argc int) int { + switch argc - 1 { + case 0, 1; + printf("zero or one\n"); + case -1; + printf("???\n"); + case 2; + printf("two"); + printf("\n"); + case 7; + //empty + case else + printf("its %d\n", argc); + } +} diff --git a/test/libc.hff b/test/libc.hff new file mode 100644 index 0000000..488a495 --- /dev/null +++ b/test/libc.hff @@ -0,0 +1,32 @@ +// stdio.h +struct FILE; +extern static stdin *FILE, + stdout *FILE, + stderr *FILE; +extern fn printf(fmt *const u8, ...) int; +extern fn fprintf(fp *FILE, fmt *const u8, ...) int; +extern fn sprintf(*u8, fmt *const u8, ...) int; +extern fn snprintf(*u8, usize, fmt *const u8, ...) int; +extern fn fopen(path *const u8, mode *const u8) *FILE; +extern fn fclose(*FILE) int; +extern fn fgetc(*FILE) int; +extern fn fputc(int, *FILE) int; +def EOF = -1; + +// stdlib.h +extern fn abort() void; +extern fn exit(c int) void; +extern fn perror(s *const u8) void; +extern fn malloc(n usize) *void; +extern fn calloc(n usize, m usize) *void; +extern fn realloc(p *void, n usize) *void; +extern fn free(p *void) void; + +// string.h +extern fn strlen(s *const u8) usize; +extern fn strcmp(a *const u8, b *const u8) int; +extern fn memcpy(*void, *const void, usize) *void; +extern fn strcpy(*u8, *const u8) *u8; + +//ctype.h +extern fn tolower(int) int; |