summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2019-09-30 22:52:51 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2019-09-30 22:52:51 -0400
commit3f91bb6f0fb9805ff846327a0d6cf3aa9dd1501e (patch)
tree16b41a32be9926d1666861121f02aee69a960934
parent6cebb40221d0fce80fedb4c644ca9278054a4f49 (diff)
fixed fn() bug
-rw-r--r--#test.toc#17
-rw-r--r--main.c1
-rw-r--r--parse.c11
-rw-r--r--test.toc2
4 files changed, 23 insertions, 8 deletions
diff --git a/#test.toc# b/#test.toc#
new file mode 100644
index 0000000..112e4e3
--- /dev/null
+++ b/#test.toc#
@@ -0,0 +1,17 @@
+main @= fn() {
+ arr1 : ['a' as u8]int;
+ arr2 : [main as u64]int;
+1 arr3 : [main as i64]int;
+ N @= (-10 + (97 as char as f32)) as u32;
+ arr4 : [N]int;
+ arr5 : [main as u64]int;
+ // arr6 : [main as u64 as fn() as u64]int;FIXME
+ arr7 : [main as u64 as fn() int as u64]int;
+
+ str @= "foo";
+ arr8 : [(str[0] as u32) + (str[1] as u32) + (str[2] as u32)]int;
+ asdf @= new int;
+ arr9 : [asdf as u64]int;
+ arr10 : [main as &i32 as u64]int;
+ arr11 : [((main as &u64) as [4]u64)[3]]int;
+};
diff --git a/main.c b/main.c
index 4e69993..29476e0 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,5 @@
/*
TODO:
-casting errors
call fns at compile time
finish evaluator
fix void fn type
diff --git a/parse.c b/parse.c
index 0391a27..6c28b7e 100644
--- a/parse.c
+++ b/parse.c
@@ -443,8 +443,6 @@ static inline Expression *parser_new_expr(Parser *p) {
return parser_malloc(p, sizeof(Expression));
}
-/* TODO: check that we check which thing ends it everywhere */
-
#define EXPR_CAN_END_WITH_COMMA 0x01 /* a comma could end the expression */
#define EXPR_CAN_END_WITH_LBRACE 0x02
@@ -568,10 +566,11 @@ static bool parse_type(Parser *p, Type *type) {
t->token++; /* move past ) */
Type *ret_type = type->fn.types.data;
/* if there's a symbol that isn't [ or (, that can't be the start of a type */
- if (t->token->kind == TOKEN_KW
- && t->token->kw <= KW_LAST_SYMBOL
- && t->token->kw != KW_LSQUARE
- && t->token->kw != KW_LPAREN) {
+ if ((t->token->kind == TOKEN_KW
+ && t->token->kw <= KW_LAST_SYMBOL
+ && t->token->kw != KW_LSQUARE
+ && t->token->kw != KW_LPAREN)
+ || t->token->kw == KW_AS) {
ret_type->kind = TYPE_VOID;
ret_type->flags = 0;
} else {
diff --git a/test.toc b/test.toc
index 7d77550..e22bcbd 100644
--- a/test.toc
+++ b/test.toc
@@ -5,7 +5,7 @@ main @= fn() {
N @= (-10 + (97 as char as u8 as f32)) as u32;
arr4 : [N]int;
arr5 : [main as u64]int;
- // arr6 : [main as u64 as fn() as u64]int;FIXME
+ arr6 : [main as u64 as fn() as u64]int;
arr7 : [main as u64 as fn() int as u64]int;
str @= "foo";