From 6d02b582d1a0c20fec234a7eec28a88c7182a9ca Mon Sep 17 00:00:00 2001 From: Robert Muth Date: Wed, 13 Sep 2023 22:06:15 -0400 Subject: [PATCH] support new function call shortcut --- FrontEnd/LangTest/array_test.cw | 16 ++--- FrontEnd/LangTest/assign_test.cw | 8 +-- FrontEnd/LangTest/defer_test.cw | 18 +++--- FrontEnd/LangTest/expr_sint_test.cw | 8 +-- FrontEnd/LangTest/expr_uint_test.cw | 8 +-- FrontEnd/LangTest/sum_tagged_test.cw | 14 ++-- FrontEnd/LangTest/sum_untagged_test.cw | 6 +- FrontEnd/Lib/checksum_test.cw | 24 +++---- FrontEnd/Lib/fmt.cw | 44 ++++++------- FrontEnd/Lib/os.cw | 6 +- FrontEnd/Lib/string.cw | 16 ++--- FrontEnd/Lib/string_test.cw | 90 +++++++++++++------------- FrontEnd/Lib/test.cw | 2 +- FrontEnd/Lib/trig_test.cw | 20 +++--- FrontEnd/TestData/ascii_anim.cw | 8 +-- FrontEnd/TestData/asciiquarium.cw | 54 ++++++++-------- FrontEnd/TestData/binary_tree.cw | 6 +- FrontEnd/TestData/heapsort.cw | 8 +-- FrontEnd/TestData/large_args.cw | 2 +- FrontEnd/TestData/polymorphic.cw | 12 ++-- FrontEnd/TestData/print_argv.cw | 2 +- FrontEnd/TestData/sexpr.cw | 6 +- FrontEnd/TestData/sieve.cw | 2 +- FrontEnd/TestData/wordcount.cw | 6 +- FrontEnd/parse.py | 14 ++-- 25 files changed, 200 insertions(+), 200 deletions(-) diff --git a/FrontEnd/LangTest/array_test.cw b/FrontEnd/LangTest/array_test.cw index 0552da77..573a17bd 100644 --- a/FrontEnd/LangTest/array_test.cw +++ b/FrontEnd/LangTest/array_test.cw @@ -118,9 +118,9 @@ (= a b) (test::AssertEq! (at a 0) 4_u8) - (test::AssertEq! (call update_array [a 0 2]) 4_u8) - (test::AssertEq! (call update_array [a 0 3]) 2_u8) - (test::AssertEq! (call update_array [(^ pa_mut) 0 2]) 3_u8) + (test::AssertEq! (update_array [a 0 2]) 4_u8) + (test::AssertEq! (update_array [a 0 3]) 2_u8) + (test::AssertEq! (update_array [(^ pa_mut) 0 2]) 3_u8) ) @@ -164,14 +164,14 @@ (test::AssertEq! (at f3 0) 111_s32) @doc "basic" (test::AssertEq! (at c3 0) 4_u8) - (test::AssertEq! (call update_array [c3 0 77]) 4_u8) - (test::AssertEq! (call update_array [c3 0 5]) 77_u8) + (test::AssertEq! (update_array [c3 0 77]) 4_u8) + (test::AssertEq! (update_array [c3 0 5]) 77_u8) ) (fun @cdecl main [(param argc s32) (param argv (ptr (ptr u8)))] s32 : - (stmt (call test_global_array [])) - (stmt (call test_local_array [])) - (stmt (call test_mixed_array [])) + (stmt (test_global_array [])) + (stmt (test_local_array [])) + (stmt (test_mixed_array [])) @doc "test end" (test::Success!) (return 0)) diff --git a/FrontEnd/LangTest/assign_test.cw b/FrontEnd/LangTest/assign_test.cw index 12911d16..4468fb4d 100644 --- a/FrontEnd/LangTest/assign_test.cw +++ b/FrontEnd/LangTest/assign_test.cw @@ -67,10 +67,10 @@ (-= (. gr1 i2) 0x1) (test::AssertEq! (. gr1 i2) 0x1234567812345677_u64) @doc "gr1 u64 via pointer" - (= (. (^ (call get_addr [])) i2) 0x1234567812345678) - (test::AssertEq! (. (^ (call get_addr [])) i2) 0x1234567812345678_u64) - (-= (. (^ (call get_addr [])) i2) 0x1) - (test::AssertEq! (. (^ (call get_addr [])) i2) 0x1234567812345677_u64) + (= (. (^ (get_addr [])) i2) 0x1234567812345678) + (test::AssertEq! (. (^ (get_addr [])) i2) 0x1234567812345678_u64) + (-= (. (^ (get_addr [])) i2) 0x1) + (test::AssertEq! (. (^ (get_addr [])) i2) 0x1234567812345677_u64) @doc "gar1 s64" (= (. (at gar1 3) i1) 0x8765432187654321) (test::AssertEq! (. (at gar1 3) i1) 0x8765432187654321_s64) diff --git a/FrontEnd/LangTest/defer_test.cw b/FrontEnd/LangTest/defer_test.cw index b8eae71a..588e49d9 100644 --- a/FrontEnd/LangTest/defer_test.cw +++ b/FrontEnd/LangTest/defer_test.cw @@ -14,23 +14,23 @@ (fun foo [] void : (defer : - (stmt (call store ['h']))) + (stmt (store ['h']))) (defer : - (stmt (call store ['g']))) - (stmt (call store ['a'])) + (stmt (store ['g']))) + (stmt (store ['a'])) (block _ : - (stmt (call store ['b'])) + (stmt (store ['b'])) (defer : - (stmt (call store ['e']))) + (stmt (store ['e']))) (defer : - (stmt (call store ['d']))) - (stmt (call store ['c']))) - (stmt (call store ['f'])) + (stmt (store ['d']))) + (stmt (store ['c']))) + (stmt (store ['f'])) ) (fun @cdecl main [(param argc s32) (param argv (ptr (ptr u8)))] s32 : - (stmt (call foo [])) + (stmt (foo [])) (test::AssertSliceEq! (slice_val (front gSequence) gIndex) "abcdefgh") @doc "test end" (test::Success!) diff --git a/FrontEnd/LangTest/expr_sint_test.cw b/FrontEnd/LangTest/expr_sint_test.cw index 81ed4e05..a7675615 100644 --- a/FrontEnd/LangTest/expr_sint_test.cw +++ b/FrontEnd/LangTest/expr_sint_test.cw @@ -160,10 +160,10 @@ ) (fun @cdecl main [(param argc s32) (param argv (ptr (ptr s8)))] s32 : - (stmt (call test_s64 [0x8765432187654321 0x1234567812345678])) - (stmt (call test_s32 [0x87654321 0x12345678])) - (stmt (call test_s16 [0x8765 0x1234])) - (stmt (call test_s8 [0x87 0x78])) + (stmt (test_s64 [0x8765432187654321 0x1234567812345678])) + (stmt (test_s32 [0x87654321 0x12345678])) + (stmt (test_s16 [0x8765 0x1234])) + (stmt (test_s8 [0x87 0x78])) @doc "test end" (test::Success!) diff --git a/FrontEnd/LangTest/expr_uint_test.cw b/FrontEnd/LangTest/expr_uint_test.cw index 3befefc1..e3b431a2 100644 --- a/FrontEnd/LangTest/expr_uint_test.cw +++ b/FrontEnd/LangTest/expr_uint_test.cw @@ -152,10 +152,10 @@ ) (fun @cdecl main [(param argc s32) (param argv (ptr (ptr u8)))] s32 : - (stmt (call test_u64 [0x8765432187654321 0x1234567812345678])) - (stmt (call test_u32 [0x87654321 0x12345678])) - (stmt (call test_u16 [0x4321 0x1234])) - (stmt (call test_u8 [0x87 0x78])) + (stmt (test_u64 [0x8765432187654321 0x1234567812345678])) + (stmt (test_u32 [0x87654321 0x12345678])) + (stmt (test_u16 [0x4321 0x1234])) + (stmt (test_u8 [0x87 0x78])) @doc "test end" (test::Success!) diff --git a/FrontEnd/LangTest/sum_tagged_test.cw b/FrontEnd/LangTest/sum_tagged_test.cw index a6758c2b..527a8c4b 100644 --- a/FrontEnd/LangTest/sum_tagged_test.cw +++ b/FrontEnd/LangTest/sum_tagged_test.cw @@ -106,9 +106,9 @@ (fun test_tagged_union_parameter [] void : (let @mut x TaggedUnion3 true) - (stmt (call fun_param [true true 0 x])) + (stmt (fun_param [true true 0 x])) (= x 666_s32) - (stmt (call fun_param [false true 666 x])) + (stmt (fun_param [false true 666 x])) ) (fun fun_result [ @@ -124,19 +124,19 @@ (fun test_tagged_union_result [] void : - (let @mut x auto (call fun_result [true false 2])) + (let @mut x auto (fun_result [true false 2])) (test::AssertTrue! (is x bool)) (test::AssertFalse! (is x s32)) - (= x (call fun_result [false false 2])) + (= x (fun_result [false false 2])) (test::AssertFalse! (is x bool)) (test::AssertTrue! (is x s32)) ) (fun @cdecl main [(param argc s32) (param argv (ptr (ptr u8)))] s32 : - (stmt (call test_tagged_union_basic [])) - (stmt (call test_tagged_union_result [])) - (stmt (call test_tagged_union_parameter [])) + (stmt (test_tagged_union_basic [])) + (stmt (test_tagged_union_result [])) + (stmt (test_tagged_union_parameter [])) @doc "test end" (test::Success!) diff --git a/FrontEnd/LangTest/sum_untagged_test.cw b/FrontEnd/LangTest/sum_untagged_test.cw index a1b77cd1..d2fa016d 100644 --- a/FrontEnd/LangTest/sum_untagged_test.cw +++ b/FrontEnd/LangTest/sum_untagged_test.cw @@ -142,9 +142,9 @@ (test::AssertEq! (as (at array1 13) u32) 0x42280000_u32) (test::AssertEq! (as (at array1 13) r32) 42_r32) - (= u1 (call with_union_result [true 10 2.0])) + (= u1 (with_union_result [true 10 2.0])) (test::AssertEq! (as u1 u32) 10_u32) - (= u1 (call with_union_result [false 10 2.0])) + (= u1 (with_union_result [false 10 2.0])) (test::AssertEq! (as u1 u32) 0x40000000_u32) (= (at array1 13) 2.0_r64) @@ -155,7 +155,7 @@ (fun @cdecl main [(param argc s32) (param argv (ptr (ptr u8)))] s32 : - (stmt (call test_untagged_union [])) + (stmt (test_untagged_union [])) @doc "test end" (test::Success!) diff --git a/FrontEnd/Lib/checksum_test.cw b/FrontEnd/Lib/checksum_test.cw index cbc1b04b..5a741d33 100644 --- a/FrontEnd/Lib/checksum_test.cw +++ b/FrontEnd/Lib/checksum_test.cw @@ -83,22 +83,22 @@ (fun @cdecl main [(param argc s32) (param argv (ptr (ptr u8)))] s32 : @doc "init" - (stmt (call checksum::InitCrcTab [checksum::PolyCrc32LE (& @mut Crc32Tab)])) + (stmt (checksum::InitCrcTab [checksum::PolyCrc32LE (& @mut Crc32Tab)])) (fmt::print! ["\n\n"]) - (stmt (call checksum::InitCrcTab [checksum::PolyCrc32cLE (& @mut Crc32cTab)])) + (stmt (checksum::InitCrcTab [checksum::PolyCrc32cLE (& @mut Crc32cTab)])) @doc "crc32" - (test::AssertEq! (call checksum::CalcCrc [Data00 0 (& Crc32Tab)]) 0xefb5af2e_u32) - (test::AssertEq! (call checksum::CalcCrc [Data55 0 (& Crc32Tab)]) 0x6be062a7_u32) - (test::AssertEq! (call checksum::CalcCrc [DataAA 0 (& Crc32Tab)]) 0x3c6f327d_u32) - (test::AssertEq! (call checksum::CalcCrc [DataFF 0 (& Crc32Tab)]) 0xb83afff4_u32) - (test::AssertEq! (call checksum::CalcCrc [DataInc 0 (& Crc32Tab)]) 0x100ece8c_u32) + (test::AssertEq! (checksum::CalcCrc [Data00 0 (& Crc32Tab)]) 0xefb5af2e_u32) + (test::AssertEq! (checksum::CalcCrc [Data55 0 (& Crc32Tab)]) 0x6be062a7_u32) + (test::AssertEq! (checksum::CalcCrc [DataAA 0 (& Crc32Tab)]) 0x3c6f327d_u32) + (test::AssertEq! (checksum::CalcCrc [DataFF 0 (& Crc32Tab)]) 0xb83afff4_u32) + (test::AssertEq! (checksum::CalcCrc [DataInc 0 (& Crc32Tab)]) 0x100ece8c_u32) @doc "crc32c" - (fmt::print! [(as (call checksum::CalcCrc [Data00 0 (& Crc32cTab)]) fmt::u32_hex) "\n"]) - (fmt::print! [(as (call checksum::CalcCrc [Data55 0 (& Crc32cTab)]) fmt::u32_hex) "\n"]) - (fmt::print! [(as (call checksum::CalcCrc [DataAA 0 (& Crc32cTab)]) fmt::u32_hex) "\n"]) - (fmt::print! [(as (call checksum::CalcCrc [DataFF 0 (& Crc32cTab)]) fmt::u32_hex) "\n"]) - (fmt::print! [(as (call checksum::CalcCrc [DataInc 0 (& Crc32cTab)]) fmt::u32_hex) "\n"]) + (fmt::print! [(as (checksum::CalcCrc [Data00 0 (& Crc32cTab)]) fmt::u32_hex) "\n"]) + (fmt::print! [(as (checksum::CalcCrc [Data55 0 (& Crc32cTab)]) fmt::u32_hex) "\n"]) + (fmt::print! [(as (checksum::CalcCrc [DataAA 0 (& Crc32cTab)]) fmt::u32_hex) "\n"]) + (fmt::print! [(as (checksum::CalcCrc [DataFF 0 (& Crc32cTab)]) fmt::u32_hex) "\n"]) + (fmt::print! [(as (checksum::CalcCrc [DataInc 0 (& Crc32cTab)]) fmt::u32_hex) "\n"]) @doc "test end" (test::Success!) diff --git a/FrontEnd/Lib/fmt.cw b/FrontEnd/Lib/fmt.cw index fded3b02..8a1b58e4 100644 --- a/FrontEnd/Lib/fmt.cw +++ b/FrontEnd/Lib/fmt.cw @@ -35,7 +35,7 @@ (param options (ptr @mut SysFormatOptions))] uint : (let s auto (? v (as "true" (slice u8)) (as "false" (slice u8)))) (let n uint (min (len buffer) (len s))) - (return (call mymemcpy [ + (return (mymemcpy [ (front @mut buffer) (front s) n]))) @@ -64,7 +64,7 @@ (continue) :)) (let n uint (min (- $max_width $pos) (len $out_eval))) - (return (call mymemcpy [ + (return (mymemcpy [ (front @mut $out_eval) (incp (front $tmp) $pos) n])))) @@ -98,7 +98,7 @@ (if (< v 0) : (let v_unsigned auto (- 0_s32 v)) (= (at out 0) '-') - (return (+ 1 (unsigned_to_str! v_unsigned 10 32_uint (call slice_incp [out 1])))) + (return (+ 1 (unsigned_to_str! v_unsigned 10 32_uint (slice_incp [out 1])))) : (return (unsigned_to_str! (as v u32) 10 32_uint out)))) @@ -116,35 +116,35 @@ (param v u8) (param out (slice @mut u8)) (param options (ptr @mut SysFormatOptions))] uint : - (return (call u8_to_str [v out]))) + (return (u8_to_str [v out]))) (fun @polymorphic SysRender [ (param v u16) (param out (slice @mut u8)) (param options (ptr @mut SysFormatOptions))] uint : - (return (call u16_to_str [v out]))) + (return (u16_to_str [v out]))) (fun @polymorphic SysRender [ (param v u32) (param out (slice @mut u8)) (param options (ptr @mut SysFormatOptions))] uint : - (return (call u32_to_str [v out]))) + (return (u32_to_str [v out]))) (fun @polymorphic SysRender [ (param v u64) (param out (slice @mut u8)) (param options (ptr @mut SysFormatOptions))] uint : - (return (call u64_to_str [v out]))) + (return (u64_to_str [v out]))) (fun @polymorphic SysRender [ (param v s32) (param out (slice @mut u8)) (param options (ptr @mut SysFormatOptions))] uint : - (return (call s32_to_str [v out]))) + (return (s32_to_str [v out]))) (fun @polymorphic SysRender [ @@ -152,7 +152,7 @@ (param buffer (slice @mut u8)) (param options (ptr @mut SysFormatOptions))] uint : (let n uint (min (len buffer) (len v))) - (return (call mymemcpy [ + (return (mymemcpy [ (front @mut buffer) (front v) n]))) @@ -175,19 +175,19 @@ (param v u32_hex) (param out (slice @mut u8)) (param options (ptr @mut SysFormatOptions))] uint : - (return (call u32_to_hex_str [(as v u32) out]))) + (return (u32_to_hex_str [(as v u32) out]))) (fun @polymorphic SysRender [ (param v u16_hex) (param out (slice @mut u8)) (param options (ptr @mut SysFormatOptions))] uint : - (return (call u16_to_hex_str [(as v u16) out]))) + (return (u16_to_hex_str [(as v u16) out]))) (fun @polymorphic SysRender [ (param v u8_hex) (param out (slice @mut u8)) (param options (ptr @mut SysFormatOptions))] uint : - (return (call u8_to_hex_str [(as v u8) out]))) + (return (u8_to_hex_str [(as v u8) out]))) (type @pub @wrapped rune u8) @@ -218,7 +218,7 @@ (fun slice_copy [(param src (slice u8)) (param dst (slice @mut u8))] uint : (let n uint (min (len src) (len dst))) - (return (call mymemcpy [ + (return (mymemcpy [ (front @mut dst) (front src) n]))) @@ -230,14 +230,14 @@ (param out (slice @mut u8))] uint : (if frac_is_zero : (if is_non_neg : - (return (call slice_copy [INF_POS out])) + (return (slice_copy [INF_POS out])) : - (return (call slice_copy [INF_NEG out]))) + (return (slice_copy [INF_NEG out]))) : (if is_non_neg : - (return (call slice_copy [NAN_POS out])) + (return (slice_copy [NAN_POS out])) : - (return (call slice_copy [NAN_NEG out]))))) + (return (slice_copy [NAN_NEG out]))))) @doc """r64 format (IEEE 754): sign (1 bit) exponent (11 bits) fraction (52 bits) @@ -250,7 +250,7 @@ (let exp_bits auto (and (>> val_bits 52) 0x7ff)) (let sign_bit auto (and (>> val_bits 63) 1)) (if (== exp_bits 0x7ff) : - (return (call nan_to_str [ + (return (nan_to_str [ (== sign_bit 0) (== frac_bits 0) out])) @@ -284,7 +284,7 @@ (= exp (- 0_s64 exp)) :) (let rest auto (slice_val (incp buf i) (- (len out) i))) - (+= i (call u64_to_str [(as exp u64) rest])) + (+= i (u64_to_str [(as exp u64) rest])) (return i)) @@ -295,7 +295,7 @@ (param v r64_hex) (param out (slice @mut u8)) (param options (ptr @mut SysFormatOptions))] uint : - (return (call r64_to_hex_str [(as v r64) out]))) + (return (r64_to_hex_str [(as v r64) out]))) (macro @pub print! STMT_LIST [ @@ -305,11 +305,11 @@ (macro_let @mut $curr uint 0) (macro_let @mut @ref $options auto (rec_val SysFormatOptions [])) (macro_for $i $parts : - (+= $curr (call @polymorphic SysRender [ + (+= $curr (@polymorphic SysRender [ $i (slice_val (incp (front @mut $buffer) $curr) (- (len $buffer) $curr)) (& @mut $options)]))) - (stmt (call os::write [(as os::Stdout s32) (front $buffer) $curr]))) + (stmt (os::write [(as os::Stdout s32) (front $buffer) $curr]))) (fun @pub strz_to_slice [(param s (ptr u8))] (slice u8) : diff --git a/FrontEnd/Lib/os.cw b/FrontEnd/Lib/os.cw index eba279a7..94f2e95f 100644 --- a/FrontEnd/Lib/os.cw +++ b/FrontEnd/Lib/os.cw @@ -28,7 +28,7 @@ (fun @pub FileWrite [ (param fd FD) (param buffer (slice u8))] (union [uint Error]) : - (let res auto (call write [(as fd s32) (front buffer) (len buffer)])) + (let res auto (write [(as fd s32) (front buffer) (len buffer)])) (if (< res 0) : (return (as (as res s32) Error)) : @@ -39,7 +39,7 @@ (fun @pub FileRead [ (param fd FD) (param buffer (slice @mut u8))] (union [uint Error]): - (let res auto (call read [(as fd s32) (front @mut buffer) (len buffer)])) + (let res auto (read [(as fd s32) (front @mut buffer) (len buffer)])) (if (< res 0) : (return (as (as res s32) Error)) : @@ -50,7 +50,7 @@ (fun @pub TimeNanoSleep [(param req (ptr TimeSpec)) (param rem (ptr @mut TimeSpec))] Error : - (let res auto (call nanosleep [req rem])) + (let res auto (nanosleep [req rem])) (return (as res Error)) ) diff --git a/FrontEnd/Lib/string.cw b/FrontEnd/Lib/string.cw index 8cdd59e5..29b83285 100644 --- a/FrontEnd/Lib/string.cw +++ b/FrontEnd/Lib/string.cw @@ -37,7 +37,7 @@ (let n uint (- hlen nlen)) (let @mut i uint 0) (block _ : - (if (call are_two_non_empty_strings_the_same [ + (if (are_two_non_empty_strings_the_same [ (incp hptr i) nptr nlen]) : @@ -64,7 +64,7 @@ (let nptr (ptr u8) (front needle)) (let @mut i uint (- hlen nlen)) (block _ : - (if (call are_two_non_empty_strings_the_same [ + (if (are_two_non_empty_strings_the_same [ (incp hptr i) nptr nlen]) : @@ -87,7 +87,7 @@ (return false) :) @doc "at this point we know that both slices have len > 0" - (return (call are_two_non_empty_strings_the_same [ + (return (are_two_non_empty_strings_the_same [ (front haystack) (front needle) nlen]))) @@ -103,7 +103,7 @@ (return false) :) @doc "at this point we know that both slices have len > 0" - (return (call are_two_non_empty_strings_the_same [ + (return (are_two_non_empty_strings_the_same [ (incp (front haystack) (- hlen nlen)) (front needle) nlen]))) @@ -169,7 +169,7 @@ (let hptr (ptr u8) (front haystack)) (let @mut i uint 0) (block _ : - (if (call contains_char [needle (^ (incp hptr i))]) : + (if (contains_char [needle (^ (incp hptr i))]) : (return i) :) (+= i 1) @@ -192,7 +192,7 @@ (let hptr (ptr u8) (front haystack)) (let @mut i uint 0) (block _ : - (if (call contains_char [needle (^ (incp hptr i))]) : + (if (contains_char [needle (^ (incp hptr i))]) : : (return i)) (+= i 1) @@ -216,7 +216,7 @@ (let @mut i uint hlen) (block _ : (-= i 1) - (if (call contains_char [needle (^ (incp hptr i))]) : + (if (contains_char [needle (^ (incp hptr i))]) : (return i) :) (if (== i 0) : @@ -239,7 +239,7 @@ (let @mut i uint hlen) (block _ : (-= i 1) - (if (call contains_char [needle (^ (incp hptr i))]) : + (if (contains_char [needle (^ (incp hptr i))]) : : (return i)) (if (== i 0) : diff --git a/FrontEnd/Lib/string_test.cw b/FrontEnd/Lib/string_test.cw index 5d9e36f8..26411d11 100644 --- a/FrontEnd/Lib/string_test.cw +++ b/FrontEnd/Lib/string_test.cw @@ -26,59 +26,59 @@ (fun @cdecl main [(param argc s32) (param argv (ptr (ptr u8)))] s32 : @doc "find" - (test::AssertEq! string::NOT_FOUND (call string::find [STR_ABC STR_ABCD])) - (test::AssertEq! 0_uint (call string::find [STR_ABCD STR_ABC])) - (test::AssertEq! 1_uint (call string::find [STR_VXYZ STR_XYZ])) - (test::AssertEq! 2_uint (call string::find [STR_ABCD STR_CD])) - (test::AssertEq! string::NOT_FOUND (call string::find [STR_XYZ STR_VXYZ])) + (test::AssertEq! string::NOT_FOUND (string::find [STR_ABC STR_ABCD])) + (test::AssertEq! 0_uint (string::find [STR_ABCD STR_ABC])) + (test::AssertEq! 1_uint (string::find [STR_VXYZ STR_XYZ])) + (test::AssertEq! 2_uint (string::find [STR_ABCD STR_CD])) + (test::AssertEq! string::NOT_FOUND (string::find [STR_XYZ STR_VXYZ])) @doc "rfind" - (test::AssertEq! string::NOT_FOUND (call string::rfind [STR_ABC STR_ABCD])) - (test::AssertEq! 0_uint (call string::rfind [STR_ABCD STR_ABC])) - (test::AssertEq! 1_uint (call string::rfind [STR_VXYZ STR_XYZ])) - (test::AssertEq! 2_uint (call string::rfind [STR_ABCD STR_CD])) - (test::AssertEq! string::NOT_FOUND (call string::find [STR_ABC STR_ABCD])) + (test::AssertEq! string::NOT_FOUND (string::rfind [STR_ABC STR_ABCD])) + (test::AssertEq! 0_uint (string::rfind [STR_ABCD STR_ABC])) + (test::AssertEq! 1_uint (string::rfind [STR_VXYZ STR_XYZ])) + (test::AssertEq! 2_uint (string::rfind [STR_ABCD STR_CD])) + (test::AssertEq! string::NOT_FOUND (string::find [STR_ABC STR_ABCD])) @doc "cmp" - (test::AssertEq! 0_sint (call string::cmp [STR_ABCD STR_ABCD])) - (test::AssertEq! -1_sint (call string::cmp [STR_ABC STR_ABCD])) - (test::AssertEq! 1_sint (call string::cmp [STR_ABCD STR_ABC])) - (test::AssertEq! -1_sint (call string::cmp [STR_ABC STR_XYZ])) - (test::AssertEq! 1_sint (call string::cmp [STR_XYZ STR_ABC])) + (test::AssertEq! 0_sint (string::cmp [STR_ABCD STR_ABCD])) + (test::AssertEq! -1_sint (string::cmp [STR_ABC STR_ABCD])) + (test::AssertEq! 1_sint (string::cmp [STR_ABCD STR_ABC])) + (test::AssertEq! -1_sint (string::cmp [STR_ABC STR_XYZ])) + (test::AssertEq! 1_sint (string::cmp [STR_XYZ STR_ABC])) @doc "starts_with" - (test::AssertEq! false (call string::starts_with [STR_ABC STR_ABCD])) - (test::AssertEq! true (call string::starts_with [STR_ABCD STR_ABC])) - (test::AssertEq! false (call string::starts_with [STR_VXYZ STR_XYZ])) - (test::AssertEq! false (call string::starts_with [STR_ABCD STR_CD])) - (test::AssertEq! false (call string::starts_with [STR_XYZ STR_VXYZ])) + (test::AssertEq! false (string::starts_with [STR_ABC STR_ABCD])) + (test::AssertEq! true (string::starts_with [STR_ABCD STR_ABC])) + (test::AssertEq! false (string::starts_with [STR_VXYZ STR_XYZ])) + (test::AssertEq! false (string::starts_with [STR_ABCD STR_CD])) + (test::AssertEq! false (string::starts_with [STR_XYZ STR_VXYZ])) @doc "ends_with" - (test::AssertEq! false (call string::ends_with [STR_ABC STR_ABCD])) - (test::AssertEq! false (call string::ends_with [STR_ABCD STR_ABC])) - (test::AssertEq! true (call string::ends_with [STR_VXYZ STR_XYZ])) - (test::AssertEq! true (call string::ends_with [STR_ABCD STR_CD])) - (test::AssertEq! false (call string::ends_with [STR_XYZ STR_VXYZ])) + (test::AssertEq! false (string::ends_with [STR_ABC STR_ABCD])) + (test::AssertEq! false (string::ends_with [STR_ABCD STR_ABC])) + (test::AssertEq! true (string::ends_with [STR_VXYZ STR_XYZ])) + (test::AssertEq! true (string::ends_with [STR_ABCD STR_CD])) + (test::AssertEq! false (string::ends_with [STR_XYZ STR_VXYZ])) @doc "find_first_of" - (test::AssertEq! 0_uint (call string::find_first_of [STR_ABC STR_ABCD])) - (test::AssertEq! 2_uint (call string::find_first_of [STR_ABC STR_CD])) - (test::AssertEq! string::NOT_FOUND (call string::find_first_of [STR_ABC STR_XYZ])) - (test::AssertEq! string::NOT_FOUND (call string::find_first_of [STR_EMPTY STR_XYZ])) - (test::AssertEq! string::NOT_FOUND (call string::find_first_of [STR_ABC STR_EMPTY])) + (test::AssertEq! 0_uint (string::find_first_of [STR_ABC STR_ABCD])) + (test::AssertEq! 2_uint (string::find_first_of [STR_ABC STR_CD])) + (test::AssertEq! string::NOT_FOUND (string::find_first_of [STR_ABC STR_XYZ])) + (test::AssertEq! string::NOT_FOUND (string::find_first_of [STR_EMPTY STR_XYZ])) + (test::AssertEq! string::NOT_FOUND (string::find_first_of [STR_ABC STR_EMPTY])) @doc "find_first_not_of" - (test::AssertEq! 3_uint (call string::find_first_not_of [STR_ABCD STR_ABC])) - (test::AssertEq! 0_uint (call string::find_first_not_of [STR_ABC STR_CD])) - (test::AssertEq! 0_uint (call string::find_first_not_of [STR_ABC STR_XYZ])) - (test::AssertEq! string::NOT_FOUND (call string::find_first_not_of [STR_EMPTY STR_XYZ])) - (test::AssertEq! 0_uint (call string::find_first_not_of [STR_ABC STR_EMPTY])) + (test::AssertEq! 3_uint (string::find_first_not_of [STR_ABCD STR_ABC])) + (test::AssertEq! 0_uint (string::find_first_not_of [STR_ABC STR_CD])) + (test::AssertEq! 0_uint (string::find_first_not_of [STR_ABC STR_XYZ])) + (test::AssertEq! string::NOT_FOUND (string::find_first_not_of [STR_EMPTY STR_XYZ])) + (test::AssertEq! 0_uint (string::find_first_not_of [STR_ABC STR_EMPTY])) @doc "find_last_of" - (test::AssertEq! 2_uint (call string::find_last_of [STR_ABCD STR_ABC])) - (test::AssertEq! 2_uint (call string::find_last_of [STR_ABC STR_CD])) - (test::AssertEq! string::NOT_FOUND (call string::find_last_of [STR_ABC STR_XYZ])) - (test::AssertEq! string::NOT_FOUND (call string::find_last_of [STR_EMPTY STR_XYZ])) - (test::AssertEq! string::NOT_FOUND (call string::find_last_of [STR_ABC STR_EMPTY])) + (test::AssertEq! 2_uint (string::find_last_of [STR_ABCD STR_ABC])) + (test::AssertEq! 2_uint (string::find_last_of [STR_ABC STR_CD])) + (test::AssertEq! string::NOT_FOUND (string::find_last_of [STR_ABC STR_XYZ])) + (test::AssertEq! string::NOT_FOUND (string::find_last_of [STR_EMPTY STR_XYZ])) + (test::AssertEq! string::NOT_FOUND (string::find_last_of [STR_ABC STR_EMPTY])) @doc "find_last_not_of" - (test::AssertEq! 3_uint (call string::find_last_not_of [STR_ABCD STR_ABC])) - (test::AssertEq! 1_uint (call string::find_last_not_of [STR_ABC STR_CD])) - (test::AssertEq! 2_uint (call string::find_last_not_of [STR_ABC STR_XYZ])) - (test::AssertEq! string::NOT_FOUND (call string::find_last_not_of [STR_EMPTY STR_XYZ])) - (test::AssertEq! 2_uint (call string::find_last_not_of [STR_ABC STR_EMPTY])) + (test::AssertEq! 3_uint (string::find_last_not_of [STR_ABCD STR_ABC])) + (test::AssertEq! 1_uint (string::find_last_not_of [STR_ABC STR_CD])) + (test::AssertEq! 2_uint (string::find_last_not_of [STR_ABC STR_XYZ])) + (test::AssertEq! string::NOT_FOUND (string::find_last_not_of [STR_EMPTY STR_XYZ])) + (test::AssertEq! 2_uint (string::find_last_not_of [STR_ABC STR_EMPTY])) @doc "test end" (test::Success!) (return 0)) diff --git a/FrontEnd/Lib/test.cw b/FrontEnd/Lib/test.cw index 76cd9ce0..f7fd27bc 100644 --- a/FrontEnd/Lib/test.cw +++ b/FrontEnd/Lib/test.cw @@ -6,7 +6,7 @@ (macro SysPrint! STMT_LIST [(mparam $msg EXPR)] [$msg_eval] : (macro_let $msg_eval (slice u8) $msg) - (stmt (call os::write [(as os::Stdout s32) (front $msg_eval) (len $msg_eval)]) + (stmt (os::write [(as os::Stdout s32) (front $msg_eval) (len $msg_eval)]) )) (macro @pub Success! STMT [] [] : diff --git a/FrontEnd/Lib/trig_test.cw b/FrontEnd/Lib/trig_test.cw index 37aaaff3..6ad88f25 100644 --- a/FrontEnd/Lib/trig_test.cw +++ b/FrontEnd/Lib/trig_test.cw @@ -14,31 +14,31 @@ cos 1 sqrt(3)/2 sqrt(2)/2 1/2 0 (fun @cdecl main [(param argc s32) (param argv (ptr (ptr u8)))] s32 : - (test::AssertApproxEq! (call trig::sin_restricted [ + (test::AssertApproxEq! (trig::sin_restricted [ 0.0 0.0 true]) 0.0_r64 EPSILON) - (test::AssertApproxEq! (call trig::sin_restricted [ + (test::AssertApproxEq! (trig::sin_restricted [ (/ math::PI 6.0) 0.0 true]) 0.5_r64 EPSILON) - (test::AssertApproxEq! (call trig::sin_restricted [ + (test::AssertApproxEq! (trig::sin_restricted [ (/ math::PI 4.0) 0.0 true]) (/ math::SQRT_2 2) EPSILON) - (test::AssertApproxEq! (call trig::sin_restricted [ + (test::AssertApproxEq! (trig::sin_restricted [ (/ math::PI 3.0) 0.0 true]) (/ math::SQRT_3 2) EPSILON) - (test::AssertApproxEq! (call trig::sin_restricted [ + (test::AssertApproxEq! (trig::sin_restricted [ (/ math::PI 2.0) 0.0 true]) 1.0_r64 EPSILON) - (test::AssertApproxEq! (call trig::cos_restricted [0.0 0.0]) 1.0_r64 EPSILON) - (test::AssertApproxEq! (call trig::cos_restricted [(/ math::PI 6.0) 0.0]) (/ math::SQRT_3 2) EPSILON) - (test::AssertApproxEq! (call trig::cos_restricted [(/ math::PI 4.0) 0.0]) (/ math::SQRT_2 2) EPSILON) - (test::AssertApproxEq! (call trig::cos_restricted [(/ math::PI 3.0) 0.0]) 0.5_r64 EPSILON) - (test::AssertApproxEq! (call trig::cos_restricted [(/ math::PI 2.0) 0.0]) 0.0_r64 EPSILON) + (test::AssertApproxEq! (trig::cos_restricted [0.0 0.0]) 1.0_r64 EPSILON) + (test::AssertApproxEq! (trig::cos_restricted [(/ math::PI 6.0) 0.0]) (/ math::SQRT_3 2) EPSILON) + (test::AssertApproxEq! (trig::cos_restricted [(/ math::PI 4.0) 0.0]) (/ math::SQRT_2 2) EPSILON) + (test::AssertApproxEq! (trig::cos_restricted [(/ math::PI 3.0) 0.0]) 0.5_r64 EPSILON) + (test::AssertApproxEq! (trig::cos_restricted [(/ math::PI 2.0) 0.0]) 0.0_r64 EPSILON) @doc "test end" (test::Success!) (return 0)) diff --git a/FrontEnd/TestData/ascii_anim.cw b/FrontEnd/TestData/ascii_anim.cw index 97fd3cc9..95ab8052 100644 --- a/FrontEnd/TestData/ascii_anim.cw +++ b/FrontEnd/TestData/ascii_anim.cw @@ -77,7 +77,7 @@ (fun get_fg_color [(param attr u8)] (slice u8) : - (let col u8 (call tolower [attr])) + (let col u8 (tolower [attr])) (cond : (case (== col 'k') : (return ansi::FG_COLOR_BLACK)) @@ -100,7 +100,7 @@ (fun get_bg_color [(param attr u8)] (slice u8) : - (let col u8 (call tolower [attr])) + (let col u8 (tolower [attr])) (cond : (case (== col 'k') : (return ansi::BG_COLOR_BLACK)) @@ -181,7 +181,7 @@ (fun @pub window_draw [(param obj (ptr Window)) (param bg_col u8)] void : - (fmt::print! [(call get_bg_color [bg_col]) ansi::CLEAR_ALL]) + (fmt::print! [(get_bg_color [bg_col]) ansi::CLEAR_ALL]) (let w auto (-> obj width)) (let h auto (-> obj height)) @doc "@ is an invalid attrib" @@ -200,7 +200,7 @@ :) (= last_x x) (if (!= last_attr a) : - (fmt::print! [(call get_fg_color [a]) (call get_style [a])]) + (fmt::print! [(get_fg_color [a]) (call get_style [a])]) :) (= last_attr a) (fmt::print! [(as c fmt::rune)])))) diff --git a/FrontEnd/TestData/asciiquarium.cw b/FrontEnd/TestData/asciiquarium.cw index 57dcb65a..763d2863 100644 --- a/FrontEnd/TestData/asciiquarium.cw +++ b/FrontEnd/TestData/asciiquarium.cw @@ -14,18 +14,18 @@ (fmt::print! ["Not enough arguments, need width and height\n"]) (return 0) :) - (let arg_w (slice u8) (call fmt::strz_to_slice [(^ (incp argv 1))])) - (let arg_h (slice u8) (call fmt::strz_to_slice [(^ (incp argv 2))])) - (let width s32 (as (call fmt::str_to_u32 [arg_w]) s32)) - (let height s32 (as (call fmt::str_to_u32 [arg_h]) s32)) + (let arg_w (slice u8) (fmt::strz_to_slice [(^ (incp argv 1))])) + (let arg_h (slice u8) (fmt::strz_to_slice [(^ (incp argv 2))])) + (let width s32 (as (fmt::str_to_u32 [arg_w]) s32)) + (let height s32 (as (fmt::str_to_u32 [arg_h]) s32)) @doc "100ms per frame" (let @ref req os::TimeSpec (rec_val os::TimeSpec [(field_val 0) (field_val 100000000)])) (let @mut @ref rem os::TimeSpec undef) (let @mut @ref window auto (rec_val aanim::Window [(field_val width) (field_val height)])) (let @mut curr auto (front @mut all_objects)) @doc "add obj" - (stmt (call aanim::InitObjectState [curr (& artwork::DuckR)])) - (stmt (call aanim::SetBasics [ + (stmt (aanim::InitObjectState [curr (& artwork::DuckR)])) + (stmt (aanim::SetBasics [ curr 0.0 0 @@ -33,64 +33,64 @@ (= curr (incp curr 1)) @doc "add obj" - (stmt (call aanim::InitObjectState [curr (& artwork::Castle)])) - (stmt (call aanim::SetBasics [ + (stmt (aanim::InitObjectState [curr (& artwork::Castle)])) + (stmt (aanim::SetBasics [ curr 0.0 (- (as width r32) 32) (- (as height r32) 13)])) (= curr (incp curr 1)) @doc "add obj" - (stmt (call aanim::InitObjectState [curr (& artwork::BigFishR)])) - (stmt (call aanim::SetBasics [ + (stmt (aanim::InitObjectState [curr (& artwork::BigFishR)])) + (stmt (aanim::SetBasics [ curr 0.0 10 10])) (= curr (incp curr 1)) @doc "add obj" - (stmt (call aanim::InitObjectState [curr (& artwork::SwanL)])) - (stmt (call aanim::SetBasics [ + (stmt (aanim::InitObjectState [curr (& artwork::SwanL)])) + (stmt (aanim::SetBasics [ curr 0.0 50 1])) (= curr (incp curr 1)) @doc "add obj" - (stmt (call aanim::InitObjectState [curr (& artwork::DolphinL)])) - (stmt (call aanim::SetBasics [ + (stmt (aanim::InitObjectState [curr (& artwork::DolphinL)])) + (stmt (aanim::SetBasics [ curr 0.0 30 8])) (= curr (incp curr 1)) @doc "add obj" - (stmt (call aanim::InitObjectState [curr (& artwork::MonsterR)])) - (stmt (call aanim::SetBasics [ + (stmt (aanim::InitObjectState [curr (& artwork::MonsterR)])) + (stmt (aanim::SetBasics [ curr 0.0 30 2])) (= curr (incp curr 1)) @doc "add obj" - (stmt (call aanim::InitObjectState [curr (& artwork::SharkR)])) - (stmt (call aanim::SetBasics [ + (stmt (aanim::InitObjectState [curr (& artwork::SharkR)])) + (stmt (aanim::SetBasics [ curr 0.0 30 30])) (= curr (incp curr 1)) @doc "add obj" - (stmt (call aanim::InitObjectState [curr (& artwork::ShipR)])) - (stmt (call aanim::SetBasics [ + (stmt (aanim::InitObjectState [curr (& artwork::ShipR)])) + (stmt (aanim::SetBasics [ curr 0.0 50 0])) (= curr (incp curr 1)) @doc "add obj" - (stmt (call aanim::InitObjectState [curr (& artwork::Fish1R)])) - (stmt (call aanim::SetBasics [ + (stmt (aanim::InitObjectState [curr (& artwork::Fish1R)])) + (stmt (aanim::SetBasics [ curr 0.0 40 @@ -100,20 +100,20 @@ (fmt::print! [ansi::CURSOR_HIDE]) (let @mut last_t r32 0.0) (for t 0.0 5.0_r32 0.1 : - (stmt (call aanim::window_fill [ + (stmt (aanim::window_fill [ (& @mut window) ' ' ' '])) (= curr (front @mut all_objects)) (for i 0 9_uint 1 : - (stmt (call aanim::draw [(& @mut window) (incp curr i)]))) - (stmt (call aanim::window_draw [(& window) 'k'])) + (stmt (aanim::draw [(& @mut window) (incp curr i)]))) + (stmt (aanim::window_draw [(& window) 'k'])) (for i 0 9_uint 1 : - (stmt (call artwork::UpdateState [ + (stmt (artwork::UpdateState [ (incp curr i) t (- t last_t)]))) - (stmt (call os::nanosleep [(& req) (& @mut rem)])) + (stmt (os::nanosleep [(& req) (& @mut rem)])) (= last_t t)) (fmt::print! [ansi::CURSOR_SHOW]) (return 0)) diff --git a/FrontEnd/TestData/binary_tree.cw b/FrontEnd/TestData/binary_tree.cw index 62cad9ea..17bbea6a 100644 --- a/FrontEnd/TestData/binary_tree.cw +++ b/FrontEnd/TestData/binary_tree.cw @@ -20,9 +20,9 @@ (fun InorderTraversal [(param root MaybeNode) (param visitor Visitor)] void : (try node (ptr @mut BinaryTreeNode) root _ : (return)) - (stmt (call InorderTraversal [(. (^ node) left) visitor])) - (stmt (call visitor [node])) - (stmt (call InorderTraversal [(. (^ node) right) visitor]))) + (stmt (InorderTraversal [(. (^ node) left) visitor])) + (stmt (visitor [node])) + (stmt (InorderTraversal [(. (^ node) right) visitor]))) ) diff --git a/FrontEnd/TestData/heapsort.cw b/FrontEnd/TestData/heapsort.cw index fdcb0858..1465e53f 100644 --- a/FrontEnd/TestData/heapsort.cw +++ b/FrontEnd/TestData/heapsort.cw @@ -58,14 +58,14 @@ (fun @cdecl main [(param argc s32) (param argv (ptr (ptr u8)))] s32 : (for i 0 SIZE 1 : - (let v auto (call random::get_random [1000])) + (let v auto (random::get_random [1000])) (= (at Data (+ i 1)) v)) - (stmt (call dump_array [SIZE (& (at Data 1))])) + (stmt (dump_array [SIZE (& (at Data 1))])) (fmt::print! [NEWLINE]) (fmt::print! [SIZE NEWLINE]) - (stmt (call heap_sort [SIZE (& @mut (at Data 0))])) + (stmt (heap_sort [SIZE (& @mut (at Data 0))])) (fmt::print! [NEWLINE]) - (stmt (call dump_array [SIZE (& (at Data 1))])) + (stmt (dump_array [SIZE (& (at Data 1))])) (fmt::print! [NEWLINE]) (for i 1 SIZE 1 : (if (> (at Data i) (at Data (+ i 1))) : diff --git a/FrontEnd/TestData/large_args.cw b/FrontEnd/TestData/large_args.cw index 065acede..09c15016 100644 --- a/FrontEnd/TestData/large_args.cw +++ b/FrontEnd/TestData/large_args.cw @@ -17,7 +17,7 @@ (param p1 bool) (param p2 MyRec) (param p3 MyRec)] MyRec : - (return (call foo [ + (return (foo [ 'c' p2 p1 diff --git a/FrontEnd/TestData/polymorphic.cw b/FrontEnd/TestData/polymorphic.cw index 093f6fb7..ecef21cb 100644 --- a/FrontEnd/TestData/polymorphic.cw +++ b/FrontEnd/TestData/polymorphic.cw @@ -7,32 +7,32 @@ (let @mut buffer auto (array_val fmt::FORMATED_STRING_MAX_LEN u8)) (let @mut @ref s (slice @mut u8) buffer) (let @mut n uint 0) - (= n (call @polymorphic SysRender [ + (= n (@polymorphic SysRender [ 666_uint s (& @mut opt)])) (test::AssertSliceEq! (slice_val (front s) n) "666") - (= n (call @polymorphic SysRender [ + (= n (@polymorphic SysRender [ true s (& @mut opt)])) (test::AssertSliceEq! (slice_val (front s) n) "true") - (= n (call @polymorphic SysRender [ + (= n (@polymorphic SysRender [ 69_u16 s (& @mut opt)])) (test::AssertSliceEq! (slice_val (front s) n) "69") - (= n (call @polymorphic SysRender [ + (= n (@polymorphic SysRender [ -69_s32 s (& @mut opt)])) (test::AssertSliceEq! (slice_val (front s) n) "-69") - (= n (call @polymorphic SysRender [ + (= n (@polymorphic SysRender [ (as 120_u8 fmt::rune) s (& @mut opt)])) (test::AssertSliceEq! (slice_val (front s) n) "x") - (= n (call @polymorphic SysRender [ + (= n (@polymorphic SysRender [ (as 2_r64 fmt::r64_hex) s (& @mut opt)])) diff --git a/FrontEnd/TestData/print_argv.cw b/FrontEnd/TestData/print_argv.cw index 523bd4f1..e568be0d 100644 --- a/FrontEnd/TestData/print_argv.cw +++ b/FrontEnd/TestData/print_argv.cw @@ -13,7 +13,7 @@ (fun @cdecl main [(param argc s32) (param argv (ptr (ptr u8)))] s32 : (for i 0 (as argc u32) 1 : (let s (ptr u8) (^ (incp argv i))) - (let t auto (slice_val s (call strlen [s]))) + (let t auto (slice_val s (strlen [s]))) (fmt::print! [t "\n"])) (return 0)) diff --git a/FrontEnd/TestData/sexpr.cw b/FrontEnd/TestData/sexpr.cw index be37c5e6..fed0f38b 100644 --- a/FrontEnd/TestData/sexpr.cw +++ b/FrontEnd/TestData/sexpr.cw @@ -3,11 +3,11 @@ (param a s32) (param b s32) (param c s32)] s32 : - (stmt (call foo1 [ + (stmt (foo1 [ 0 0 0])) - (stmt (call foo2 [ + (stmt (foo2 [ 1 2 3])) @@ -124,5 +124,3 @@ (return (call foo [c]))) ) - - diff --git a/FrontEnd/TestData/sieve.cw b/FrontEnd/TestData/sieve.cw index 269af7bf..3a8ca6ad 100644 --- a/FrontEnd/TestData/sieve.cw +++ b/FrontEnd/TestData/sieve.cw @@ -30,7 +30,7 @@ (fun @cdecl main [(param argc s32) (param argv (ptr (ptr u8)))] s32 : - (test::AssertEq! (call sieve []) EXPECTED) + (test::AssertEq! (sieve []) EXPECTED) (test::Success!) (return 0)) diff --git a/FrontEnd/TestData/wordcount.cw b/FrontEnd/TestData/wordcount.cw index 3cb9d167..fe5d3a8c 100644 --- a/FrontEnd/TestData/wordcount.cw +++ b/FrontEnd/TestData/wordcount.cw @@ -20,7 +20,7 @@ (let @mut in_word auto false) (let @mut buf (array 1024 u8) undef) (while true : - (try n uint (call os::FileRead [fd buf]) err : + (try n uint (os::FileRead [fd buf]) err : (return err)) (if (== n 0) : break : ) (+= (. stats num_chars) n) @@ -29,7 +29,7 @@ (cond : (case (== c '\n') : (+= (. stats num_lines) 1)) - (case (call is_white_space [c]) : + (case (is_white_space [c]) : (= in_word false)) (case (! in_word) : (= in_word true) @@ -40,7 +40,7 @@ (return stats)) (fun @cdecl main [(param argc s32) (param argv (ptr (ptr u8)))] s32 : - (try stats TextStats (call WordCount [os::Stdin]) err : + (try stats TextStats (WordCount [os::Stdin]) err : (return 1) ) (fmt::print! [(. stats num_lines) " " (. stats num_words) " " (. stats num_chars) "\n"]) diff --git a/FrontEnd/parse.py b/FrontEnd/parse.py index 1d9a2088..6da51fa3 100755 --- a/FrontEnd/parse.py +++ b/FrontEnd/parse.py @@ -49,13 +49,14 @@ BUILT_IN_MACROS = set([ - "while", - "for", - "try", - "->", - "swap", + "while", + "for", + "try", + "->", + "swap", ]) + def ReadAttrs(t: str, attr, stream): while t.startswith("@"): tag = t[1:] @@ -390,7 +391,8 @@ def ReadSExpr(stream: ReadTokens, parent_cls, attr) -> Any: # unknown node name - assume it is a macro return ReadMacroInvocation(tag, stream) else: - cwast.CompilerError(stream.srcloc(), f"expected macro got {tag}") + return ReadRestAndMakeNode(cwast.ExprCall, [cwast.Id(tag, x_srcloc=stream.srcloc())], + cwast.ExprCall.FIELDS[1:], attr, stream) assert cls is not None, f"[{stream.line_no}] Non node: {tag}" # This helps catching missing closing braces early