From: Brendan Hansen Date: Sat, 20 Jun 2020 23:14:05 +0000 (-0500) Subject: Added initial vim syntax highlighting; bug fixes X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=66d30f860f821e0f0b97b6c1b328ab6f496b7c4d;p=onyx.git Added initial vim syntax highlighting; bug fixes --- diff --git a/misc/onyx.vim b/misc/onyx.vim new file mode 100644 index 00000000..89d22c44 --- /dev/null +++ b/misc/onyx.vim @@ -0,0 +1,43 @@ +" Vim syntax file +" Language: Onyx +" Maintainer: Brendan Hansen +" 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 diff --git a/onyx b/onyx index 1c15f826..7b7f254a 100755 Binary files a/onyx and b/onyx differ diff --git a/progs/minimal.onyx b/progs/minimal.onyx index 03ebfcb2..7114a4cc 100644 --- a/progs/minimal.onyx +++ b/progs/minimal.onyx @@ -11,12 +11,14 @@ add :: proc (a i32, b i32) -> i32 { 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 { @@ -41,12 +43,13 @@ float_test :: proc -> f32 { 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); diff --git a/src/onyx.c b/src/onyx.c index 2a57a80e..816a38a7 100644 --- a/src/onyx.c +++ b/src/onyx.c @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) { onyx_message_print(&msgs); goto main_exit; } else { - onyx_ast_print(program, 0); + // onyx_ast_print(program, 0); bh_printf("\nNo errors.\n"); } diff --git a/src/onyxwasm.c b/src/onyxwasm.c index d5016649..771f913d 100644 --- a/src/onyxwasm.c +++ b/src/onyxwasm.c @@ -244,7 +244,8 @@ static void process_statement(OnyxWasmModule* mod, WasmFunc* func, OnyxAstNode* 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; } }