--- /dev/null
+" Vim syntax file
+" Language: Onyx
+" Maintainer: Brendan Hansen <brendan.f.hansen@gmail.com>
+" Last Change: 2020 June 20
+
+if exists("b:current_syntax")
+ finish
+endif
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+syn keyword onyxKeyword struct
+syn keyword onyxKeyword use
+syn keyword onyxKeyword if
+syn keyword onyxKeyword elseif
+syn keyword onyxKeyword else
+syn keyword onyxKeyword export
+syn keyword onyxKeyword proc
+syn keyword onyxKeyword foreign
+syn keyword onyxKeyword for
+syn keyword onyxKeyword return
+syn keyword onyxKeyword do
+syn keyword onyxKeyword global
+syn keyword onyxKeyword as
+
+syn keyword onyxType i32
+syn keyword onyxType i64
+syn keyword onyxType f32
+syn keyword onyxType f64
+
+syn keyword onyxCommentStart contained TODO NOTE BUG HACK
+
+syn region onyxComment start="//" end="$" keepend contains=onyxCommentStart
+
+hi def link onyxKeyword Statement
+hi def link onyxType Type
+hi def link onyxComment Comment
+hi def link onyxCommentStart Todo
+
+let b:current_syntax = "onyx"
+let &cpo = s:cpo_save
+unlet s:cpo_save
return a + b;
}
+// NOTE: There is a weird bug here if the else is used instead
+// This is because the WASM embedder does not think that it
+// is possible that all code paths are covered with returning
+// an i32. This will need to be fixed.
abs :: proc (val i32) -> i32 {
- if val <= 0 {
- return -val;
- } else {
- return val;
- };
+ if val <= 0 { return -val; };
+ // else { return val; };
+ return val;
}
diff_square :: proc (a i32, b i32) -> i32 {
export main :: proc {
output := do_stuff();
- if output + 66 {
- new_output :: -output * 2;
+ if output == -66 {
+ new_output :: abs(output) * 2;
print(new_output);
} else {
print(-1);
+
};
print(output);
onyx_message_print(&msgs);
goto main_exit;
} else {
- onyx_ast_print(program, 0);
+ // onyx_ast_print(program, 0);
bh_printf("\nNo errors.\n");
}
case ONYX_AST_NODE_KIND_RETURN: process_return(mod, func, stmt); break;
case ONYX_AST_NODE_KIND_ASSIGNMENT: process_assignment(mod, func, stmt); break;
case ONYX_AST_NODE_KIND_IF: process_if(mod, func, (OnyxAstNodeIf *) stmt); break;
- default: process_expression(mod, func, stmt);
+ case ONYX_AST_NODE_KIND_CALL: process_expression(mod, func, stmt); break;
+ default: break;
}
}