├── 6 ├── Makefile ├── asm.h ├── blob.c ├── gen.c ├── gengas.c ├── genp9.c ├── insns.def ├── isel.c ├── locs.c ├── main.c ├── mkfile ├── peep.c ├── ra.c ├── regs.def ├── simp.c └── typeinfo.c ├── .builds └── archlinux.yml ├── .gitattributes ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── bench ├── bigint.myr ├── bld.sub ├── copious-allocs.myr ├── hashit.myr ├── intsort.myr ├── mandelbrot.myr ├── many-memcpy.myr ├── regex-match.myr ├── runner.myr └── sha1-compute.myr ├── bld.proj ├── bld.tags ├── configure ├── doc ├── 6m.1 ├── bld.sub ├── buildsys.txt ├── lang.txt ├── mbld.txt ├── mkfile └── muse.1 ├── examples ├── bld.sub ├── h.myr └── srvdot.myr ├── genbootstrap.sh ├── lib ├── bio │ ├── bio.myr │ ├── bld.sub │ ├── fd.myr │ ├── geti.myr │ ├── iter.myr │ ├── mem.myr │ ├── puti.myr │ ├── test │ │ ├── bio-create.myr │ │ ├── bio-delim.myr │ │ ├── bio-endianrd.myr │ │ ├── bio-endianwr.myr │ │ ├── bio-peek.myr │ │ ├── bio-read.myr │ │ ├── bio-readterm.myr │ │ ├── bio-skipto.myr │ │ ├── bio-unitwr.myr │ │ ├── bio-write.myr │ │ ├── bld.sub │ │ ├── data │ │ │ ├── bio-create-expected │ │ │ ├── bio-delim-expected │ │ │ ├── bio-endianrd-expected │ │ │ ├── bio-endianwr-expected │ │ │ ├── bio-peek-expected │ │ │ ├── bio-read-expected │ │ │ ├── bio-readterm │ │ │ ├── bio-readtoinc-expected │ │ │ ├── bio-skipto │ │ │ ├── bio-skipto-16kbound │ │ │ ├── bio-skipto-16kspan │ │ │ ├── bio-unitwr-expected │ │ │ ├── bio-write-expected │ │ │ ├── datafile │ │ │ └── lines │ │ ├── mem.myr │ │ ├── runtest.sh │ │ └── tests │ └── types.myr ├── bld.sub ├── crypto │ ├── aes.myr │ ├── aesgcm.myr │ ├── bld.sub │ ├── chacha20.myr │ ├── clear.myr │ ├── ct.myr │ ├── ctbig.myr │ ├── curve25519.myr │ ├── entropy.myr │ ├── hash.myr │ ├── hmac.myr │ ├── md5.myr │ ├── rand.myr │ ├── rsa.myr │ ├── sha1.myr │ ├── sha256.myr │ ├── sha3.myr │ ├── sha512.myr │ ├── test │ │ ├── aes.myr │ │ ├── aesgcm.myr │ │ ├── chacha20.myr │ │ ├── ct.myr │ │ ├── ctbig.myr │ │ ├── curve25519.myr │ │ ├── md5.myr │ │ ├── rsa.myr │ │ ├── sha1.myr │ │ ├── sha256.myr │ │ ├── sha3.myr │ │ └── sha512.myr │ └── util.myr ├── date │ ├── bld.sub │ ├── date.myr │ ├── fmt.myr │ ├── names.myr │ ├── parse.myr │ ├── test │ │ ├── fmt.myr │ │ └── parse.myr │ ├── types.myr │ ├── zoneinfo+plan9.myr │ └── zoneinfo+posixy.myr ├── escfmt │ ├── bld.sub │ ├── eschtml.myr │ ├── escre.myr │ ├── escsh.myr │ ├── escurl.myr │ └── test │ │ ├── eschtml.myr │ │ ├── escre.myr │ │ ├── escsh.myr │ │ └── escurl.myr ├── fileutil │ ├── bld.sub │ ├── del.myr │ ├── homedir.myr │ ├── loopcheck+plan9.myr │ ├── loopcheck+posixy.myr │ ├── tmpdir.myr │ └── walk.myr ├── flate │ ├── bld.sub │ ├── flate.myr │ ├── test │ │ └── flate.myr │ └── types.myr ├── http │ ├── bld.sub │ ├── client.myr │ ├── parse.myr │ ├── server.myr │ ├── session.myr │ ├── status.myr │ ├── types.myr │ └── url.myr ├── inifile │ ├── access.myr │ ├── bld.sub │ ├── parse.myr │ ├── test │ │ ├── inifile.myr │ │ └── test.ini │ ├── types.myr │ └── write.myr ├── iter │ ├── bld.sub │ ├── chunk.myr │ ├── enum.myr │ ├── perm.myr │ ├── ref.myr │ ├── reverse.myr │ ├── test │ │ ├── chunk.myr │ │ ├── enum.myr │ │ ├── perm.myr │ │ ├── reverse.myr │ │ └── zip.myr │ └── zip.myr ├── json │ ├── bld.sub │ ├── fmt.myr │ ├── parse.myr │ ├── test │ │ ├── inputs │ │ │ ├── LICENSE │ │ │ ├── _n_string_UTF8_surrogate_U+D800.json │ │ │ ├── _y_string_utf16.json │ │ │ ├── i_number_neg_int_huge_exp.json │ │ │ ├── i_number_pos_double_huge_exp.json │ │ │ ├── i_object_key_lone_2nd_surrogate.json │ │ │ ├── i_string_1st_surrogate_but_2nd_missing.json │ │ │ ├── i_string_1st_valid_surrogate_2nd_invalid.json │ │ │ ├── i_string_UTF-16_invalid_lonely_surrogate.json │ │ │ ├── i_string_UTF-16_invalid_surrogate.json │ │ │ ├── i_string_UTF-8_invalid_sequence.json │ │ │ ├── i_string_incomplete_surrogate_and_escape_valid.json │ │ │ ├── i_string_incomplete_surrogate_pair.json │ │ │ ├── i_string_incomplete_surrogates_escape_valid.json │ │ │ ├── i_string_inverted_surrogates_U+1D11E.json │ │ │ ├── i_string_lone_second_surrogate.json │ │ │ ├── i_string_not_in_unicode_range.json │ │ │ ├── i_string_truncated-utf-8.json │ │ │ ├── i_string_unicode_U+10FFFE_nonchar.json │ │ │ ├── i_string_unicode_U+1FFFE_nonchar.json │ │ │ ├── i_string_unicode_U+FDD0_nonchar.json │ │ │ ├── i_string_unicode_U+FFFE_nonchar.json │ │ │ ├── i_structure_500_nested_arrays.json │ │ │ ├── i_structure_UTF-8_BOM_empty_object.json │ │ │ ├── n_array_1_true_without_comma.json │ │ │ ├── n_array_a_invalid_utf8.json │ │ │ ├── n_array_colon_instead_of_comma.json │ │ │ ├── n_array_comma_after_close.json │ │ │ ├── n_array_comma_and_number.json │ │ │ ├── n_array_double_comma.json │ │ │ ├── n_array_double_extra_comma.json │ │ │ ├── n_array_extra_close.json │ │ │ ├── n_array_extra_comma.json │ │ │ ├── n_array_incomplete.json │ │ │ ├── n_array_incomplete_invalid_value.json │ │ │ ├── n_array_inner_array_no_comma.json │ │ │ ├── n_array_invalid_utf8.json │ │ │ ├── n_array_items_separated_by_semicolon.json │ │ │ ├── n_array_just_comma.json │ │ │ ├── n_array_just_minus.json │ │ │ ├── n_array_missing_value.json │ │ │ ├── n_array_newlines_unclosed.json │ │ │ ├── n_array_number_and_comma.json │ │ │ ├── n_array_number_and_several_commas.json │ │ │ ├── n_array_spaces_vertical_tab_formfeed.json │ │ │ ├── n_array_star_inside.json │ │ │ ├── n_array_unclosed.json │ │ │ ├── n_array_unclosed_trailing_comma.json │ │ │ ├── n_array_unclosed_with_new_lines.json │ │ │ ├── n_array_unclosed_with_object_inside.json │ │ │ ├── n_incomplete_false.json │ │ │ ├── n_incomplete_null.json │ │ │ ├── n_incomplete_true.json │ │ │ ├── n_number_++.json │ │ │ ├── n_number_+1.json │ │ │ ├── n_number_+Inf.json │ │ │ ├── n_number_-01.json │ │ │ ├── n_number_-1.0..json │ │ │ ├── n_number_-2..json │ │ │ ├── n_number_-NaN.json │ │ │ ├── n_number_.-1.json │ │ │ ├── n_number_.2e-3.json │ │ │ ├── n_number_0.1.2.json │ │ │ ├── n_number_0.3e+.json │ │ │ ├── n_number_0.3e.json │ │ │ ├── n_number_0.e1.json │ │ │ ├── n_number_0_capital_E+.json │ │ │ ├── n_number_0_capital_E.json │ │ │ ├── n_number_0e+.json │ │ │ ├── n_number_0e.json │ │ │ ├── n_number_1.0e+.json │ │ │ ├── n_number_1.0e-.json │ │ │ ├── n_number_1.0e.json │ │ │ ├── n_number_1_000.json │ │ │ ├── n_number_1eE2.json │ │ │ ├── n_number_2.e+3.json │ │ │ ├── n_number_2.e-3.json │ │ │ ├── n_number_2.e3.json │ │ │ ├── n_number_9.e+.json │ │ │ ├── n_number_Inf.json │ │ │ ├── n_number_NaN.json │ │ │ ├── n_number_U+FF11_fullwidth_digit_one.json │ │ │ ├── n_number_expression.json │ │ │ ├── n_number_hex_1_digit.json │ │ │ ├── n_number_hex_2_digits.json │ │ │ ├── n_number_infinity.json │ │ │ ├── n_number_invalid+-.json │ │ │ ├── n_number_invalid-negative-real.json │ │ │ ├── n_number_invalid-utf-8-in-bigger-int.json │ │ │ ├── n_number_invalid-utf-8-in-exponent.json │ │ │ ├── n_number_invalid-utf-8-in-int.json │ │ │ ├── n_number_minus_infinity.json │ │ │ ├── n_number_minus_sign_with_trailing_garbage.json │ │ │ ├── n_number_minus_space_1.json │ │ │ ├── n_number_neg_int_starting_with_zero.json │ │ │ ├── n_number_neg_real_without_int_part.json │ │ │ ├── n_number_neg_with_garbage_at_end.json │ │ │ ├── n_number_real_garbage_after_e.json │ │ │ ├── n_number_real_with_invalid_utf8_after_e.json │ │ │ ├── n_number_real_without_fractional_part.json │ │ │ ├── n_number_starting_with_dot.json │ │ │ ├── n_number_then_00.json │ │ │ ├── n_number_with_alpha.json │ │ │ ├── n_number_with_alpha_char.json │ │ │ ├── n_number_with_leading_zero.json │ │ │ ├── n_object_bad_value.json │ │ │ ├── n_object_bracket_key.json │ │ │ ├── n_object_comma_instead_of_colon.json │ │ │ ├── n_object_double_colon.json │ │ │ ├── n_object_emoji.json │ │ │ ├── n_object_garbage_at_end.json │ │ │ ├── n_object_key_with_single_quotes.json │ │ │ ├── n_object_missing_colon.json │ │ │ ├── n_object_missing_key.json │ │ │ ├── n_object_missing_semicolon.json │ │ │ ├── n_object_missing_value.json │ │ │ ├── n_object_no-colon.json │ │ │ ├── n_object_non_string_key.json │ │ │ ├── n_object_non_string_key_but_huge_number_instead.json │ │ │ ├── n_object_pi_in_key_and_trailing_comma.json │ │ │ ├── n_object_repeated_null_null.json │ │ │ ├── n_object_several_trailing_commas.json │ │ │ ├── n_object_single_quote.json │ │ │ ├── n_object_trailing_comma.json │ │ │ ├── n_object_trailing_comment.json │ │ │ ├── n_object_trailing_comment_open.json │ │ │ ├── n_object_trailing_comment_slash_open.json │ │ │ ├── n_object_trailing_comment_slash_open_incomplete.json │ │ │ ├── n_object_two_commas_in_a_row.json │ │ │ ├── n_object_unquoted_key.json │ │ │ ├── n_object_unterminated-value.json │ │ │ ├── n_object_with_single_string.json │ │ │ ├── n_object_with_trailing_garbage.json │ │ │ ├── n_single_space.json │ │ │ ├── n_string_1_surrogate_then_escape │ │ │ ├── n_string_1_surrogate_then_escape u.json │ │ │ ├── n_string_1_surrogate_then_escape u1.json │ │ │ ├── n_string_1_surrogate_then_escape u1x.json │ │ │ ├── n_string_1_surrogate_then_escape.json │ │ │ ├── n_string_UTF-16_incomplete_surrogate.json │ │ │ ├── n_string_accentuated_char_no_quotes.json │ │ │ ├── n_string_backslash_00.json │ │ │ ├── n_string_escape_x.json │ │ │ ├── n_string_escaped_backslash_bad.json │ │ │ ├── n_string_escaped_ctrl_char_tab.json │ │ │ ├── n_string_escaped_emoji.json │ │ │ ├── n_string_incomplete_escape.json │ │ │ ├── n_string_incomplete_escaped_character.json │ │ │ ├── n_string_incomplete_surrogate_escape_invalid.json │ │ │ ├── n_string_invalid-utf-8-in-escape.json │ │ │ ├── n_string_invalid_backslash_esc.json │ │ │ ├── n_string_invalid_unicode_escape.json │ │ │ ├── n_string_invalid_utf-8.json │ │ │ ├── n_string_invalid_utf8_after_escape.json │ │ │ ├── n_string_iso_latin_1.json │ │ │ ├── n_string_leading_uescaped_thinspace.json │ │ │ ├── n_string_lone_utf8_continuation_byte.json │ │ │ ├── n_string_no_quotes_with_bad_escape.json │ │ │ ├── n_string_overlong_sequence_2_bytes.json │ │ │ ├── n_string_overlong_sequence_6_bytes.json │ │ │ ├── n_string_overlong_sequence_6_bytes_null.json │ │ │ ├── n_string_single_doublequote.json │ │ │ ├── n_string_single_quote.json │ │ │ ├── n_string_single_string_no_double_quotes.json │ │ │ ├── n_string_start_escape_unclosed.json │ │ │ ├── n_string_unescaped_crtl_char.json │ │ │ ├── n_string_unescaped_newline.json │ │ │ ├── n_string_unescaped_tab.json │ │ │ ├── n_string_unicode_CapitalU.json │ │ │ ├── n_string_with_trailing_garbage.json │ │ │ ├── n_structure_100000_opening_arrays.json │ │ │ ├── n_structure_<.>.json │ │ │ ├── n_structure_.json │ │ │ ├── n_structure_U+2060_word_joined.json │ │ │ ├── n_structure_UTF8_BOM_no_data.json │ │ │ ├── n_structure_array_trailing_garbage.json │ │ │ ├── n_structure_array_with_extra_array_close.json │ │ │ ├── n_structure_array_with_unclosed_string.json │ │ │ ├── n_structure_ascii-unicode-identifier.json │ │ │ ├── n_structure_capitalized_True.json │ │ │ ├── n_structure_close_unopened_array.json │ │ │ ├── n_structure_comma_instead_of_closing_brace.json │ │ │ ├── n_structure_double_array.json │ │ │ ├── n_structure_end_array.json │ │ │ ├── n_structure_incomplete_UTF8_BOM.json │ │ │ ├── n_structure_lone-invalid-utf-8.json │ │ │ ├── n_structure_lone-open-bracket.json │ │ │ ├── n_structure_no_data.json │ │ │ ├── n_structure_null-byte-outside-string.json │ │ │ ├── n_structure_number_with_trailing_garbage.json │ │ │ ├── n_structure_object_followed_by_closing_object.json │ │ │ ├── n_structure_object_unclosed_no_value.json │ │ │ ├── n_structure_object_with_comment.json │ │ │ ├── n_structure_object_with_trailing_garbage.json │ │ │ ├── n_structure_open_array_apostrophe.json │ │ │ ├── n_structure_open_array_comma.json │ │ │ ├── n_structure_open_array_object.json │ │ │ ├── n_structure_open_array_open_object.json │ │ │ ├── n_structure_open_array_open_string.json │ │ │ ├── n_structure_open_array_string.json │ │ │ ├── n_structure_open_object.json │ │ │ ├── n_structure_open_object_close_array.json │ │ │ ├── n_structure_open_object_comma.json │ │ │ ├── n_structure_open_object_open_array.json │ │ │ ├── n_structure_open_object_open_string.json │ │ │ ├── n_structure_open_object_string_with_apostrophes.json │ │ │ ├── n_structure_open_open.json │ │ │ ├── n_structure_single_point.json │ │ │ ├── n_structure_single_star.json │ │ │ ├── n_structure_trailing_#.json │ │ │ ├── n_structure_uescaped_LF_before_string.json │ │ │ ├── n_structure_unclosed_array.json │ │ │ ├── n_structure_unclosed_array_partial_null.json │ │ │ ├── n_structure_unclosed_array_unfinished_false.json │ │ │ ├── n_structure_unclosed_array_unfinished_true.json │ │ │ ├── n_structure_unclosed_object.json │ │ │ ├── n_structure_unicode-identifier.json │ │ │ ├── n_structure_whitespace_U+2060_word_joiner.json │ │ │ ├── n_structure_whitespace_formfeed.json │ │ │ ├── y_array_arraysWithSpaces.json │ │ │ ├── y_array_empty-string.json │ │ │ ├── y_array_empty.json │ │ │ ├── y_array_ending_with_newline.json │ │ │ ├── y_array_false.json │ │ │ ├── y_array_heterogeneous.json │ │ │ ├── y_array_null.json │ │ │ ├── y_array_with_1_and_newline.json │ │ │ ├── y_array_with_leading_space.json │ │ │ ├── y_array_with_several_null.json │ │ │ ├── y_array_with_trailing_space.json │ │ │ ├── y_number.json │ │ │ ├── y_number_0e+1.json │ │ │ ├── y_number_0e1.json │ │ │ ├── y_number_after_space.json │ │ │ ├── y_number_double_close_to_zero.json │ │ │ ├── y_number_double_huge_neg_exp.json │ │ │ ├── y_number_huge_exp.json │ │ │ ├── y_number_int_with_exp.json │ │ │ ├── y_number_minus_zero.json │ │ │ ├── y_number_negative_int.json │ │ │ ├── y_number_negative_one.json │ │ │ ├── y_number_negative_zero.json │ │ │ ├── y_number_real_capital_e.json │ │ │ ├── y_number_real_capital_e_neg_exp.json │ │ │ ├── y_number_real_capital_e_pos_exp.json │ │ │ ├── y_number_real_exponent.json │ │ │ ├── y_number_real_fraction_exponent.json │ │ │ ├── y_number_real_neg_exp.json │ │ │ ├── y_number_real_neg_overflow.json │ │ │ ├── y_number_real_pos_exponent.json │ │ │ ├── y_number_real_pos_overflow.json │ │ │ ├── y_number_real_underflow.json │ │ │ ├── y_number_simple_int.json │ │ │ ├── y_number_simple_real.json │ │ │ ├── y_number_too_big_neg_int.json │ │ │ ├── y_number_too_big_pos_int.json │ │ │ ├── y_number_very_big_negative_int.json │ │ │ ├── y_object.json │ │ │ ├── y_object_basic.json │ │ │ ├── y_object_duplicated_key.json │ │ │ ├── y_object_duplicated_key_and_value.json │ │ │ ├── y_object_empty.json │ │ │ ├── y_object_empty_key.json │ │ │ ├── y_object_escaped_null_in_key.json │ │ │ ├── y_object_extreme_numbers.json │ │ │ ├── y_object_long_strings.json │ │ │ ├── y_object_simple.json │ │ │ ├── y_object_string_unicode.json │ │ │ ├── y_object_with_newlines.json │ │ │ ├── y_string_1_2_3_bytes_UTF-8_sequences.json │ │ │ ├── y_string_UTF-16_Surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json │ │ │ ├── y_string_accepted_surrogate_pair.json │ │ │ ├── y_string_accepted_surrogate_pairs.json │ │ │ ├── y_string_allowed_escapes.json │ │ │ ├── y_string_backslash_and_u_escaped_zero.json │ │ │ ├── y_string_backslash_doublequotes.json │ │ │ ├── y_string_comments.json │ │ │ ├── y_string_double_escape_a.json │ │ │ ├── y_string_double_escape_n.json │ │ │ ├── y_string_escaped_control_character.json │ │ │ ├── y_string_escaped_noncharacter.json │ │ │ ├── y_string_in_array.json │ │ │ ├── y_string_in_array_with_leading_space.json │ │ │ ├── y_string_last_surrogates_1_and_2.json │ │ │ ├── y_string_newline_uescaped.json │ │ │ ├── y_string_nonCharacterInUTF-8_U+10FFFF.json │ │ │ ├── y_string_nonCharacterInUTF-8_U+1FFFF.json │ │ │ ├── y_string_nonCharacterInUTF-8_U+FFFF.json │ │ │ ├── y_string_null_escape.json │ │ │ ├── y_string_one-byte-utf-8.json │ │ │ ├── y_string_pi.json │ │ │ ├── y_string_simple_ascii.json │ │ │ ├── y_string_space.json │ │ │ ├── y_string_three-byte-utf-8.json │ │ │ ├── y_string_two-byte-utf-8.json │ │ │ ├── y_string_u+2028_line_sep.json │ │ │ ├── y_string_u+2029_par_sep.json │ │ │ ├── y_string_uEscape.json │ │ │ ├── y_string_unescaped_char_delete.json │ │ │ ├── y_string_unicode.json │ │ │ ├── y_string_unicodeEscapedBackslash.json │ │ │ ├── y_string_unicode_2.json │ │ │ ├── y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json │ │ │ ├── y_string_unicode_U+2064_invisible_plus.json │ │ │ ├── y_string_unicode_escaped_double_quote.json │ │ │ ├── y_string_utf8.json │ │ │ ├── y_string_with_del_character.json │ │ │ ├── y_structure_lonely_false.json │ │ │ ├── y_structure_lonely_int.json │ │ │ ├── y_structure_lonely_negative_real.json │ │ │ ├── y_structure_lonely_null.json │ │ │ ├── y_structure_lonely_string.json │ │ │ ├── y_structure_lonely_true.json │ │ │ ├── y_structure_string_empty.json │ │ │ ├── y_structure_trailing_newline.json │ │ │ ├── y_structure_true_in_array.json │ │ │ └── y_structure_whitespace_array.json │ │ └── parse.myr │ └── types.myr ├── math │ ├── ancillary │ │ ├── KM06-calc.gp │ │ ├── README │ │ ├── generate-arctan-tuples-for-GB91.c │ │ ├── generate-minimax-by-Remez.gp │ │ ├── generate-triples-for-GB91.c │ │ ├── log-overkill-constants.c │ │ ├── log-overkill-tests.c │ │ ├── pi-constants.c │ │ └── ulp.gp │ ├── atan-impl.myr │ ├── bld.sub │ ├── exp-impl.myr │ ├── fma-impl+posixy-x64-fma.s │ ├── fma-impl.myr │ ├── fma.myr │ ├── fpmath.myr │ ├── ftrap-impl+plan9-x64.s │ ├── ftrap-impl+posixy-x64.s │ ├── ftrap.myr │ ├── impls.myr │ ├── log-impl.myr │ ├── log-overkill.myr │ ├── poly-impl.myr │ ├── pown-impl.myr │ ├── powr-impl.myr │ ├── references │ ├── round-impl+posixy-x64-sse4.s │ ├── round-impl.myr │ ├── scale2-impl.myr │ ├── sin-impl.myr │ ├── sqrt-impl+posixy-x64-sse2.s │ ├── sqrt-impl.myr │ ├── sum-impl.myr │ ├── tan-impl.myr │ ├── test │ │ ├── atan-impl.myr │ │ ├── exp-impl.myr │ │ ├── fma-impl.myr │ │ ├── log-impl.myr │ │ ├── log-overkill.myr │ │ ├── poly-impl.myr │ │ ├── pown-impl.myr │ │ ├── powr-impl.myr │ │ ├── round-impl.myr │ │ ├── scale2-impl.myr │ │ ├── sin-impl.myr │ │ ├── sqrt-impl.myr │ │ ├── sum-impl.myr │ │ ├── tan-impl.myr │ │ ├── trunc-impl.myr │ │ └── util.myr │ ├── trunc-impl+posixy-x64-sse4.s │ ├── trunc-impl.myr │ └── util.myr ├── regex │ ├── bld.sub │ ├── compile.myr │ ├── interp.myr │ ├── myr-regex.3 │ ├── ranges.myr │ ├── redump.myr │ ├── test │ │ ├── basic.myr │ │ ├── bld.sub │ │ ├── boundaries.myr │ │ ├── capture.myr │ │ ├── class.myr │ │ ├── failmatch.myr │ │ ├── idxmatch.myr │ │ ├── negclass.myr │ │ ├── runtest.sh │ │ ├── search.myr │ │ ├── subst.myr │ │ ├── testmatch.myr │ │ ├── tests │ │ └── unicode.myr │ └── types.myr ├── std │ ├── alloc.myr │ ├── assert.myr │ ├── backtrace+x64.myr │ ├── bigint.myr │ ├── bitset.myr │ ├── blat.myr │ ├── bld.sub │ ├── bytealloc.myr │ ├── chartype.myr │ ├── chomp.myr │ ├── clear.myr │ ├── cmp.myr │ ├── consts.myr │ ├── cstrconv.myr │ ├── dial+plan9.myr │ ├── dial+posixy.myr │ ├── dialparse+posixy.myr │ ├── die.myr │ ├── dir+freebsd.myr │ ├── dir+linux.myr │ ├── dir+netbsd.myr │ ├── dir+openbsd.myr │ ├── dir+osx.myr │ ├── dir+plan9.myr │ ├── diriter.myr │ ├── dirname.myr │ ├── endian.myr │ ├── env+plan9.myr │ ├── env+posixy.myr │ ├── errno+plan9.myr │ ├── errno.myr │ ├── execvp.myr │ ├── extremum.myr │ ├── fltbits.myr │ ├── fltfmt.myr │ ├── fltparse.myr │ ├── fmt.myr │ ├── fmtfuncs.myr │ ├── fndup.myr │ ├── getbp+plan9-x64.s │ ├── getbp+posixy-x64.s │ ├── getcwd.myr │ ├── getint.myr │ ├── hashfuncs.myr │ ├── hasprefix.myr │ ├── hassuffix.myr │ ├── htab.myr │ ├── intfmt.myr │ ├── intparse.myr │ ├── introspect.myr │ ├── ipparse.myr │ ├── listen+plan9.myr │ ├── listen+posixy.myr │ ├── memops-impl+plan9-x64.s │ ├── memops-impl+posixy-x64.s │ ├── memops-impl.myr │ ├── memops.myr │ ├── mk.myr │ ├── mkpath.myr │ ├── mktemp.myr │ ├── netaddr.myr │ ├── now.myr │ ├── option.myr │ ├── optparse.myr │ ├── pathjoin.myr │ ├── pledge+openbsd.myr │ ├── pledge.myr │ ├── putint.myr │ ├── rand.myr │ ├── readall.myr │ ├── resolve+plan9.myr │ ├── resolve+posixy.myr │ ├── result.myr │ ├── search.myr │ ├── sjlj+x64.myr │ ├── sjlj-impl+plan9-x64.s │ ├── sjlj-impl+posixy-x64.s │ ├── slcp.myr │ ├── sldup.myr │ ├── sleep.myr │ ├── sleq.myr │ ├── slfill.myr │ ├── sljoin.myr │ ├── slpop.myr │ ├── slpush.myr │ ├── slput.myr │ ├── slurp.myr │ ├── sort.myr │ ├── spork.myr │ ├── strbuf.myr │ ├── strfind.myr │ ├── striter.myr │ ├── strjoin.myr │ ├── strreplace.myr │ ├── strsplit.myr │ ├── strstrip.myr │ ├── swap.myr │ ├── syserrno+plan9.myr │ ├── syswrap+plan9.myr │ ├── syswrap+posixy.myr │ ├── syswrap-ss+freebsd.myr │ ├── syswrap-ss+linux.myr │ ├── syswrap-ss+netbsd.myr │ ├── syswrap-ss+openbsd.myr │ ├── syswrap-ss+osx.myr │ ├── syswrap-ss+plan9.myr │ ├── test │ │ ├── alloc.myr │ │ ├── bigint.myr │ │ ├── bitset.myr │ │ ├── bytealloc.myr │ │ ├── bytebuf.myr │ │ ├── chartype.myr │ │ ├── chomp.myr │ │ ├── cmp.myr │ │ ├── dirname.myr │ │ ├── env.myr │ │ ├── fltbits.myr │ │ ├── fltfmt.myr │ │ ├── fltparse.myr │ │ ├── fmt.myr │ │ ├── hashfuncs.myr │ │ ├── htab.myr │ │ ├── ipparse.myr │ │ ├── netaddr.myr │ │ ├── option.myr │ │ ├── pathjoin.myr │ │ ├── rand.myr │ │ ├── search.myr │ │ ├── sjlj.myr │ │ ├── slcp.myr │ │ ├── sleq.myr │ │ ├── sort.myr │ │ ├── strbuf.myr │ │ ├── strfind.myr │ │ ├── striter.myr │ │ ├── strreplace.myr │ │ ├── strsplit.myr │ │ ├── try.myr │ │ └── utf.myr │ ├── threadhooks.myr │ ├── traits.myr │ ├── try.myr │ ├── types.myr │ ├── units.myr │ ├── utf.myr │ ├── varargs.myr │ ├── wait+plan9.myr │ ├── wait+posixy.myr │ └── writeall.myr ├── sys │ ├── bld.sub │ ├── ifreq+freebsd.myr │ ├── ifreq+linux.myr │ ├── ifreq+netbsd.myr │ ├── ifreq+openbsd.myr │ ├── ifreq+osx.myr │ ├── ifreq+plan9.myr │ ├── sys+freebsd-x64.myr │ ├── sys+linux-x64.myr │ ├── sys+netbsd-x64.myr │ ├── sys+openbsd-x64.myr │ ├── sys+openbsd:6.2-x64.myr │ ├── sys+openbsd:6.3-x64.myr │ ├── sys+openbsd:6.4-x64.myr │ ├── sys+openbsd:7.0-x64.myr │ ├── sys+osx-x64.myr │ ├── sys+plan9-x64.myr │ ├── syscall+freebsd-x64.s │ ├── syscall+linux-x64.s │ ├── syscall+netbsd-x64.s │ ├── syscall+openbsd-x64.s │ ├── syscall+osx-x64.s │ ├── syscall+plan9-x64.s │ ├── syserrno+freebsd.myr │ ├── syserrno+linux.myr │ ├── syserrno+netbsd.myr │ ├── syserrno+openbsd.myr │ ├── syserrno+osx.myr │ ├── systypes.myr │ ├── util+plan9-x64.s │ └── util+posixy-x64.s ├── testr │ ├── bld.sub │ └── testr.myr └── thread │ ├── atomic-impl+plan9-x64.s │ ├── atomic-impl+x64.s │ ├── atomic.myr │ ├── bld.sub │ ├── common.myr │ ├── condvar+freebsd.myr │ ├── condvar+linux.myr │ ├── condvar+openbsd:6.2.myr │ ├── condvar+osx.myr │ ├── condvar.myr │ ├── do.myr │ ├── exit+freebsd-x64.s │ ├── exit+linux-x64.s │ ├── exit+openbsd-x64.s │ ├── fsbase+freebsd.myr │ ├── fsbase+linux.myr │ ├── fsbase+netbsd.myr │ ├── fsbase+openbsd.myr │ ├── futex+freebsd.myr │ ├── futex+linux.myr │ ├── futex+openbsd:6.2.myr │ ├── futex+osx.myr │ ├── future.myr │ ├── hookstd.myr │ ├── mutex+futex.myr │ ├── mutex+plan9.myr │ ├── mutex.myr │ ├── ncpu+freebsd.myr │ ├── ncpu+linux.myr │ ├── ncpu+openbsd.myr │ ├── ncpu+plan9.myr │ ├── ncpu.myr │ ├── queue.myr │ ├── rwlock+futex.myr │ ├── rwlock.myr │ ├── sem+futex.myr │ ├── sem+plan9.myr │ ├── sem.myr │ ├── spawn+freebsd.myr │ ├── spawn+linux.myr │ ├── spawn+netbsd.myr │ ├── spawn+openbsd.myr │ ├── spawn+osx.myr │ ├── spawn+plan9.myr │ ├── start+osx-x64.s │ ├── test │ ├── atomic.myr │ ├── condvar.myr │ ├── die.myr │ ├── do.myr │ ├── future.myr │ ├── mutex.myr │ ├── queue.myr │ ├── rwlock.myr │ ├── sem.myr │ ├── spawn.myr │ ├── tls.myr │ └── waitgrp.myr │ ├── tls+fsbase.myr │ ├── tls+osx.myr │ ├── tls+plan9.myr │ ├── tls-impl+fsbase-x64.s │ ├── tls-impl+osx-x64.s │ ├── types+fsbase.myr │ ├── types+osx.myr │ ├── types+plan9.myr │ ├── util.myr │ ├── waitgrp+futex.myr │ └── waitgrp.myr ├── mbld ├── bld.sub ├── build.myr ├── config+plan9-x64.myr ├── cpufeatures+plan9-x64.s ├── cpufeatures+posixy-x64.s ├── deps.myr ├── install.myr ├── libs.myr ├── main.myr ├── mbld.1 ├── opts.myr ├── parse.myr ├── subtest.myr ├── syssel.myr ├── test.myr ├── types.myr └── util.myr ├── mbldwrap.sh ├── mi ├── Makefile ├── cfg.c ├── dfcheck.c ├── flatten.c ├── match.c ├── match_test.c ├── mi.h ├── mkfile └── reaching.c ├── mk ├── bootstrap │ ├── bootstrap+Darwin-x86_64.sh │ ├── bootstrap+FreeBSD-amd64.sh │ ├── bootstrap+Linux-x86_64.sh │ ├── bootstrap+NetBSD-amd64.sh │ ├── bootstrap+OpenBSD-amd64.sh │ └── bootstrap+Plan9-amd64.sh ├── c.mk └── lexyacc.mk ├── mkfile ├── muse ├── Makefile ├── mkfile └── muse.c ├── parse ├── Makefile ├── dump.c ├── err.c ├── export.c ├── fold.c ├── gram.y ├── infer.c ├── lits.def ├── mkfile ├── names.c ├── node.c ├── nodes.def ├── ops.def ├── parse.h ├── specialize.c ├── stab.c ├── tok.c ├── trait.def ├── type.c ├── types.def └── use.c ├── rebootstrap.sh ├── rt ├── Makefile ├── _myrrt-plan9.s ├── abort-freebsd.s ├── abort-linux.s ├── abort-netbsd.s ├── abort-openbsd.s ├── abort-osx.s ├── common.s ├── mkfile ├── start-freebsd.s ├── start-linux.s ├── start-netbsd.s ├── start-openbsd.s └── start-osx.s ├── support ├── acid │ └── myr ├── bld.sub ├── dumpleak.myr ├── matchstats.myr ├── pkg │ ├── default.nix │ └── freebsd │ │ └── pkg-descr ├── release.sh ├── syscall-gen │ ├── c2myr.py │ ├── gencalls.awk │ ├── gensys.sh │ ├── gentypes+openbsd:6.2-x64.frag │ ├── gentypes+openbsd:6.3-x64.frag │ ├── specials+freebsd-x64.frag │ ├── specials+linux-x64.frag │ ├── specials+openbsd:6.1-x64.frag │ ├── specials+openbsd:6.2-x64.frag │ ├── specials+openbsd:6.3-x64.frag │ ├── specials+openbsd:7.0-x64.frag │ ├── syscalls+freebsd.master │ ├── syscalls+openbsd.master │ ├── syscalls+openbsd:6.2.master │ ├── syscalls+openbsd:7.0.master │ ├── types+freebsd-x64.frag │ ├── types+linux-x64.frag │ ├── types+openbsd:6.1-x64.frag │ ├── types+openbsd:6.2-x64.frag │ ├── types+openbsd:6.3-x64.frag │ └── types+openbsd:7.0-x64.frag └── vim │ ├── ftdetect │ ├── mbld.vim │ └── myr.vim │ ├── indent │ ├── mbld.vim │ └── myr.vim │ └── syntax │ ├── mbld.vim │ └── myr.vim ├── test ├── Makefile ├── abi │ ├── 001_in-c.glue.c │ ├── 001_in-c.myr │ ├── 001_in-myr.myr │ ├── 001_main.myr │ ├── 001_types.h │ ├── 001_types.myr │ ├── 002_main.myr │ ├── 003_main.myr │ ├── 004_in-c.glue.c │ ├── 004_in-c.myr │ ├── 004_in-myr.myr │ ├── 004_main.myr │ ├── 004_types.h │ ├── 004_types.myr │ ├── 005_in-c.glue.c │ ├── 005_in-c.myr │ ├── 005_in-myr.myr │ ├── 005_main.myr │ ├── 005_types.h │ ├── 005_types.myr │ ├── 006_in-c.glue.c │ ├── 006_in-c.myr │ ├── 006_in-myr.myr │ ├── 006_main.myr │ ├── 006_types.h │ ├── 006_types.myr │ └── bld.proj ├── add.myr ├── align.myr ├── arityhigh.myr ├── aritylow.myr ├── array.myr ├── arrayaddr.myr ├── arraylen.myr ├── arraylit-ni.myr ├── arraylit.myr ├── arraypack.myr ├── arraypass.myr ├── badop.myr ├── basicfloat.myr ├── bigcondarg.myr ├── bigliteral.myr ├── bigtyblob.myr ├── bld.sub ├── bounds.myr ├── bsr.myr ├── call.myr ├── callbig.myr ├── catfile.myr ├── chartest.myr ├── closure.myr ├── closurerec.myr ├── compoundimpl.myr ├── condiffalse.myr ├── condifrel.myr ├── condiftrue.myr ├── constslice.myr ├── constunion.myr ├── custiter.myr ├── data │ ├── align-expected │ ├── catfile-expected │ ├── catfile-in │ ├── mandelbrot-expected │ ├── matchargstr-expected │ ├── stdbigint-expected │ ├── stdfmtpad-expected │ ├── stdpathnorm-expected │ ├── stdslcp-expected │ ├── stdsort-expected │ ├── stdtry-expected │ ├── strfind-expected │ ├── strjoin-expected │ ├── strsplit-expected │ ├── strstrip-expected │ └── strtab-expected ├── declmismatch.myr ├── derefassign.myr ├── destructuretup.myr ├── div.myr ├── doublecall.myr ├── empty-struct.myr ├── emptytrait.myr ├── encodechar.myr ├── exportcycle.myr ├── exportmain.myr ├── exporttrait.myr ├── fib.myr ├── fltabs.myr ├── fmtalign.myr ├── fmtnest.myr ├── fncast.myr ├── foldidx.myr ├── foroptexpr.myr ├── generic-in-const.myr ├── generic.myr ├── genericcall.myr ├── genericchain.myr ├── genericimpl.myr ├── genericmake.myr ├── genericmatch.myr ├── genericrec.myr ├── genericret.myr ├── generictype.myr ├── genericuret.myr ├── genericval.myr ├── global-arrayvar.myr ├── gsizeof.myr ├── gtrait.myr ├── helloworld.myr ├── implexpr-concrete.myr ├── implexpr.myr ├── import-type.myr ├── incret.myr ├── infer-named.myr ├── infermismatch.myr ├── initializer.myr ├── livearraylit.myr ├── livestructlit.myr ├── local-labels.myr ├── log-and.myr ├── log-or.myr ├── loop.myr ├── main.myr ├── mandelbrot.myr ├── match-badtypes.myr ├── matchargstr.myr ├── matchargunion.myr ├── matcharray.myr ├── matchbind.myr ├── matchconst.myr ├── matchctup.myr ├── matchexhaust.myr ├── matchint.myr ├── matchmixed.myr ├── matchnest.myr ├── matchnsconst.myr ├── matchor.myr ├── matchptr.myr ├── matchstruct.myr ├── matchtup.myr ├── matchunion.myr ├── matchunion_sl.myr ├── matchvoid.myr ├── mkfile ├── mkunion.myr ├── mod.myr ├── mul.myr ├── mul8.myr ├── multistr.myr ├── nestclosure.myr ├── nestedgoto.myr ├── nestfn.myr ├── neststruct.myr ├── nestucon.myr ├── occur.myr ├── outparam-sl.myr ├── outparam.myr ├── overlappingif.myr ├── patiter.myr ├── pkgtrait.myr ├── postinc-ret.myr ├── ptrcmp.myr ├── ptrpreinc.myr ├── recgeneric.myr ├── runtest.rc ├── runtest.sh ├── rvaldotlen.myr ├── sizeof.myr ├── slalloc.myr ├── slgrow.myr ├── slice.myr ├── slicelen.myr ├── slprint.myr ├── splitline.myr ├── sqrt.myr ├── str.myr ├── strfind.myr ├── strjoin.myr ├── strsplit.myr ├── strstrip.myr ├── strtab.myr ├── struct.myr ├── struct1.myr ├── structarray.myr ├── structasn.myr ├── structlit.myr ├── structptr.myr ├── structret.myr ├── subrangefor.myr ├── swidencast.myr ├── tests ├── trait-builtin.myr ├── traitimpl.myr ├── trunccast.myr ├── tuple.myr ├── tupleaccess.myr ├── tyoccur.myr ├── tyrec.myr ├── uconinit.myr ├── union-extraarg.myr ├── union-missingarg.myr ├── union.myr ├── usedef.myr ├── voidarg.myr ├── voidassign.myr ├── voidcall.myr ├── voideffect.myr ├── voidmatch.myr └── zwidencast.myr ├── u.json ├── u1.json ├── u1x.json └── util ├── Makefile ├── alloc.c ├── bitset.c ├── htab.c ├── mkfile ├── pack.c ├── util.c └── util.h /.builds/archlinux.yml: -------------------------------------------------------------------------------- 1 | image: archlinux 2 | packages: 3 | - bison 4 | - gcc 5 | - git 6 | - make 7 | sources: 8 | - https://git.sr.ht/~fsx/mc 9 | tasks: 10 | - build: | 11 | cd mc 12 | ./configure 13 | make bootstrap 14 | make 15 | - test: | 16 | cd mc 17 | make check 18 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | lib/bio/test/data/bio-delim-expected binary 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # file patterns 2 | *.o 3 | *.use 4 | *.a 5 | */.deps 6 | *.core 7 | 8 | # common tool generated scratch files 9 | tags 10 | *~ 11 | 12 | # generated files 13 | config.h 14 | config.mk 15 | mbld/config.myr 16 | parse/gram.c 17 | parse/gram.h 18 | configvar_cache 19 | rt/_*.s 20 | !rt/*-*.s 21 | 22 | # outputs 23 | obj/** 24 | test/obj/** 25 | 6/6m 26 | muse/muse 27 | mbld/mbld 28 | support/mdumpleak 29 | myrbuild/myrbuild 30 | lib/regex/redump 31 | xmbld 32 | -------------------------------------------------------------------------------- /6/Makefile: -------------------------------------------------------------------------------- 1 | INSTBIN=6m 2 | OBJ= \ 3 | blob.o \ 4 | gen.o \ 5 | gengas.o \ 6 | genp9.o \ 7 | isel.o \ 8 | locs.o \ 9 | main.o \ 10 | ra.o \ 11 | peep.o \ 12 | simp.o \ 13 | typeinfo.o \ 14 | 15 | DEPS=../parse/libparse.a ../mi/libmi.a ../util/libutil.a 16 | 17 | include ../config.mk 18 | include ../mk/c.mk 19 | -------------------------------------------------------------------------------- /6/mkfile: -------------------------------------------------------------------------------- 1 | void) 6 | generic slclear : (sl : @a[:] -> void) 7 | generic free : (p : @a# -> void) 8 | generic slfree : (sl : @a[:] -> void) 9 | ;; 10 | 11 | generic clear = {p : @a# 12 | std.memfill((p : byte#), 0, sizeof(@a)) 13 | } 14 | 15 | generic slclear = {sl : @a[:] 16 | std.memfill((sl : byte#), 0, sizeof(@a)*sl.len) 17 | } 18 | 19 | generic free = {p : @a# 20 | clear(p) 21 | std.free(p) 22 | } 23 | 24 | generic slfree = {sl : @a[:] 25 | slclear(sl) 26 | std.slfree(sl) 27 | } 28 | -------------------------------------------------------------------------------- /lib/crypto/entropy.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg crypto = 4 | const getentropy : (buf : byte[:] -> void) 5 | ;; 6 | 7 | var randfd 8 | 9 | const __init__ = { 10 | match std.open("/dev/urandom", std.Oread) 11 | | `std.Ok fd: randfd = fd 12 | | `std.Err e: randfd = std.try(std.open("/dev/random", std.Oread)) 13 | ;; 14 | } 15 | 16 | const getentropy = {buf 17 | var nread 18 | 19 | nread = 0 20 | while nread < buf.len 21 | match std.read(randfd, buf) 22 | | `std.Err e: std.die(std.fmt("unable to read from randfd: {}\n", e)) 23 | | `std.Ok 0: std.die("could not get entropy from randfd: EOF\n") 24 | | `std.Ok n: nread += n 25 | ;; 26 | ;; 27 | } 28 | -------------------------------------------------------------------------------- /lib/crypto/hash.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg crypto = 4 | trait hash @a = 5 | Blocksz : std.size 6 | Hashsz : std.size 7 | 8 | hinit : (h : @a# -> void) 9 | hadd : (h : @a#, msg : byte[:] -> void) 10 | hfin : (h : @a#, dst : byte[:] -> void) 11 | ;; 12 | ;; 13 | -------------------------------------------------------------------------------- /lib/crypto/util.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg testutil = 4 | const hasheq : (got : byte[:], expected : byte[:] -> void) 5 | ;; 6 | 7 | const hasheq = {got, expected 8 | var sb, str 9 | 10 | sb = std.mksb() 11 | for x : got 12 | std.sbfmt(sb, "{p=0,w=2,x}", x) 13 | ;; 14 | str = std.sbfin(sb) 15 | if (!std.eq(str, expected)) 16 | std.fatal("mismatched hashes:\n\tgot:\t{}\n\texpected:\t{}\n", str, expected) 17 | ;; 18 | std.slfree(str) 19 | } 20 | -------------------------------------------------------------------------------- /lib/date/bld.sub: -------------------------------------------------------------------------------- 1 | lib date = 2 | date.myr 3 | fmt.myr 4 | names.myr 5 | parse.myr 6 | types.myr 7 | zoneinfo+posixy.myr 8 | zoneinfo+plan9.myr 9 | 10 | lib ../sys:sys 11 | lib ../std:std 12 | ;; 13 | 14 | -------------------------------------------------------------------------------- /lib/date/zoneinfo+plan9.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use sys 3 | 4 | use "types" 5 | 6 | pkg _zoneinfo = 7 | type zifile 8 | const findtzoff : (tz : byte[:], tm : std.time -> std.option(date.duration)) 9 | const load : (file : byte[:] -> zifile#) 10 | const free : (f : zifile# -> void) 11 | ;; 12 | 13 | type zifile = byte 14 | 15 | const findtzoff = {tz, tm 16 | -> `std.Some 0 17 | } 18 | 19 | const load = {f 20 | -> std.alloc() 21 | } 22 | 23 | const free = {p 24 | -> std.free(p) 25 | } 26 | -------------------------------------------------------------------------------- /lib/escfmt/bld.sub: -------------------------------------------------------------------------------- 1 | testdeps = ../testr:testr ;; 2 | 3 | lib escfmt = 4 | escsh.myr 5 | eschtml.myr 6 | escurl.myr 7 | escre.myr 8 | 9 | lib ../std:std 10 | lib ../sys:sys 11 | ;; 12 | -------------------------------------------------------------------------------- /lib/escfmt/eschtml.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg escfmt = 4 | type eschtml = byte[:] 5 | 6 | const html : (s : byte[:] -> eschtml) 7 | ;; 8 | 9 | const __init__ = { 10 | var s = ("" : eschtml) 11 | std.fmtinstall(std.typeof(s), htmlfmt) 12 | } 13 | 14 | const html = {s 15 | -> (s : eschtml) 16 | } 17 | 18 | const htmlfmt = {sb, ap, args 19 | var s : byte[:] 20 | 21 | s = std.vanext(ap) 22 | for c : std.bychar(s) 23 | match c 24 | | '&': std.sbputs(sb, "&") 25 | | '<': std.sbputs(sb, "<") 26 | | '>': std.sbputs(sb, ">") 27 | | '/': std.sbputs(sb, "/") 28 | | _: std.sbputc(sb, c) 29 | ;; 30 | ;; 31 | } 32 | -------------------------------------------------------------------------------- /lib/escfmt/escsh.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg escfmt = 4 | type escsh = byte[:] 5 | 6 | const sh : (s : byte[:] -> escsh) 7 | ;; 8 | 9 | const __init__ = { 10 | var s = ("" : escsh) 11 | std.fmtinstall(std.typeof(s), shfmt) 12 | } 13 | 14 | const sh = {s 15 | -> (s : escsh) 16 | } 17 | 18 | const shfmt = {sb, ap, args 19 | var s : byte[:] 20 | 21 | s = std.vanext(ap) 22 | std.sbputb(sb, ('\'' : byte)) 23 | for b : s 24 | if b == ('\'' : byte) 25 | std.sbputs(sb, "'\\''") 26 | else 27 | std.sbputb(sb, b) 28 | ;; 29 | ;; 30 | std.sbputb(sb, ('\'' : byte)) 31 | } 32 | -------------------------------------------------------------------------------- /lib/escfmt/test/escre.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use escfmt 3 | use testr 4 | 5 | const main = { 6 | testr.run([\ 7 | [.name="unchanged", .fn={ctx 8 | var s = std.fmt("{}", escfmt.url("word")) 9 | testr.check(ctx, std.eq("word", s), std.fmt("mismatched escape {}", s)) 10 | std.slfree(s) 11 | }], 12 | [.name="randomcrud", .fn={ctx 13 | var s = std.fmt("{}", escfmt.re("^:/?#[]@!$&'()*+,;=%")) 14 | testr.check(ctx, \ 15 | std.eq("\\^:/\\?#\\[\\]@!\\$&'\\(\\)\\*\\+,;=%", s), \ 16 | std.fmt("mismatched escape {}", s)) 17 | std.slfree(s) 18 | }], 19 | ][:]) 20 | } 21 | 22 | -------------------------------------------------------------------------------- /lib/fileutil/bld.sub: -------------------------------------------------------------------------------- 1 | lib fileutil = 2 | walk.myr 3 | homedir.myr 4 | tmpdir.myr 5 | del.myr 6 | 7 | loopcheck+posixy.myr 8 | loopcheck+plan9.myr 9 | 10 | lib ../sys:sys 11 | lib ../std:std 12 | ;; 13 | 14 | -------------------------------------------------------------------------------- /lib/fileutil/homedir.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg fileutil = 4 | const homedir : (-> byte[:]) 5 | ;; 6 | 7 | const homedir = { 8 | match std.getenv("HOME") 9 | | `std.Some h: -> h 10 | | `std.None: /* nothing */ 11 | ;; 12 | 13 | /* 9front uses $home */ 14 | match std.getenv("home") 15 | | `std.Some h: -> h 16 | | `std.None: /* nothing */ 17 | ;; 18 | 19 | /* really, we should read from /etc/passwd or ldap/nss */ 20 | -> "" 21 | } 22 | -------------------------------------------------------------------------------- /lib/fileutil/loopcheck+plan9.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | /* plan 9 can't have directory loops, by construction, so this is nops */ 4 | pkg fileutil = 5 | type loopcheck = void 6 | 7 | const mkloopcheck : (cwd : byte[:] -> loopcheck) 8 | const freeloopcheck : (l : loopcheck -> void) 9 | const looped : (l : loopcheck, p : byte[:] -> bool) 10 | ;; 11 | 12 | const mkloopcheck = {cwd 13 | -> (void : loopcheck) 14 | } 15 | 16 | const freeloopcheck = {l 17 | } 18 | 19 | const looped = {l, p 20 | -> false 21 | } 22 | -------------------------------------------------------------------------------- /lib/fileutil/tmpdir.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg fileutil = 4 | const tmpdir : (-> byte[:]) 5 | ;; 6 | 7 | const tmpdir = { 8 | match std.getenv("TMPDIR") 9 | | `std.Some d: -> d 10 | | `std.None: -> "/tmp" 11 | ;; 12 | } 13 | -------------------------------------------------------------------------------- /lib/flate/bld.sub: -------------------------------------------------------------------------------- 1 | lib flate = 2 | flate.myr 3 | types.myr 4 | 5 | lib ../bio:bio 6 | lib ../std:std 7 | ;; 8 | 9 | testdeps = 10 | ../testr:testr 11 | ../bio:bio 12 | ../std:std 13 | ;; 14 | -------------------------------------------------------------------------------- /lib/flate/types.myr: -------------------------------------------------------------------------------- 1 | use bio 2 | 3 | pkg flate = 4 | type err = union 5 | `Io bio.err 6 | `Format byte[:] 7 | ;; 8 | ;; 9 | -------------------------------------------------------------------------------- /lib/http/bld.sub: -------------------------------------------------------------------------------- 1 | lib http = 2 | parse.myr 3 | types.myr 4 | url.myr 5 | client.myr 6 | server.myr 7 | session.myr 8 | status.myr 9 | 10 | lib ../sys:sys 11 | lib ../std:std 12 | lib ../bio:bio 13 | lib ../thread:thread 14 | ;; 15 | -------------------------------------------------------------------------------- /lib/inifile/bld.sub: -------------------------------------------------------------------------------- 1 | lib inifile = 2 | access.myr 3 | parse.myr 4 | types.myr 5 | write.myr 6 | 7 | lib ../std:std 8 | lib ../sys:sys 9 | lib ../bio:bio 10 | ;; 11 | 12 | test test/inifile = 13 | test/inifile.myr 14 | 15 | lib ../std:std 16 | lib ../sys:sys 17 | lib ../bio:bio 18 | lib inifile 19 | ;; 20 | -------------------------------------------------------------------------------- /lib/inifile/test/test.ini: -------------------------------------------------------------------------------- 1 | toplev = stuff 2 | [somesect] 3 | key= foo 4 | otherkey =meh 5 | whatever = "stuff here" 6 | 7 | [another section] 8 | key = foo1 9 | otherkey = meh1 10 | whatever = "more stuff here" 11 | 12 | -------------------------------------------------------------------------------- /lib/iter/bld.sub: -------------------------------------------------------------------------------- 1 | lib iter = 2 | chunk.myr 3 | enum.myr 4 | perm.myr 5 | ref.myr 6 | reverse.myr 7 | zip.myr 8 | 9 | lib ../sys:sys 10 | lib ../std:std 11 | ;; 12 | 13 | testdeps = 14 | ../testr:testr 15 | ../sys:sys 16 | ../std:std 17 | ;; 18 | -------------------------------------------------------------------------------- /lib/iter/enum.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg iter = 4 | type enumiter(@a) = struct 5 | idx : std.size 6 | sl : @a[:] 7 | ;; 8 | 9 | impl iterable enumiter(@a) -> (std.size, @a) 10 | generic byenum : (a : @a[:] -> enumiter(@a)) 11 | ;; 12 | 13 | generic byenum = {a 14 | -> [.sl = a, .idx = 0] 15 | } 16 | 17 | impl iterable enumiter(@a) -> (std.size, @a) = 18 | __iternext__ = {itp, valp 19 | if itp.idx == itp.sl.len 20 | -> false 21 | ;; 22 | valp# = (itp.idx, itp.sl[itp.idx]) 23 | itp.idx++ 24 | -> true 25 | } 26 | 27 | __iterfin__ = {itp, valp 28 | } 29 | ;; 30 | 31 | -------------------------------------------------------------------------------- /lib/iter/ref.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg iter = 4 | type refiter(@a) = struct 5 | idx : std.size 6 | sl : @a[:] 7 | ;; 8 | impl iterable refiter(@a) -> @a# 9 | generic byref : (sl : @a[:] -> refiter(@a)) 10 | ;; 11 | 12 | generic byref = {a 13 | -> [.sl = a, .idx = 0] 14 | } 15 | 16 | impl iterable refiter(@a) -> @a# = 17 | __iternext__ = {itp, valp 18 | if itp.idx == itp.sl.len 19 | -> false 20 | ;; 21 | valp# = &itp.sl[itp.idx] 22 | itp.idx++ 23 | -> true 24 | } 25 | 26 | __iterfin__ = {itp, valp 27 | } 28 | ;; 29 | 30 | -------------------------------------------------------------------------------- /lib/iter/reverse.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg iter = 4 | type reverseiter(@a) = struct 5 | sl : @a[:] 6 | idx : std.size 7 | ;; 8 | impl iterable reverseiter(@a) -> @a 9 | generic byreverse : (sl : @a[:] -> reverseiter(@a)) 10 | ;; 11 | 12 | generic byreverse = {sl 13 | -> [.sl = sl, .idx = sl.len] 14 | } 15 | 16 | impl iterable reverseiter(@a) -> @a = 17 | __iternext__ = {itp, valp 18 | if itp.idx > 0 19 | valp# = itp.sl[itp.idx - 1] 20 | itp.idx-- 21 | -> true 22 | else 23 | -> false 24 | ;; 25 | } 26 | 27 | __iterfin__ = {itp, valp 28 | } 29 | ;; 30 | 31 | -------------------------------------------------------------------------------- /lib/iter/test/enum.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use iter 3 | 4 | const main = { 5 | var n 6 | 7 | n = 0 8 | for (x, i) : iter.byenum([1,3,5,7,9][:]) 9 | std.assert(x == n, "invalid enum idx {}", x) 10 | std.assert(i == n*2 + 1, "invalid enum val {}", i) 11 | n++ 12 | ;; 13 | } 14 | -------------------------------------------------------------------------------- /lib/iter/test/reverse.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use iter 3 | 4 | const main = { 5 | var n 6 | 7 | n = 0 8 | for x : iter.byreverse([3, 2, 1, 0][:]) 9 | std.assert(x == n, "invalid reversed value {}, expected {}", x, n) 10 | n++ 11 | ;; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /lib/iter/test/zip.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use iter 3 | 4 | const main = { 5 | var n 6 | 7 | n = 0 8 | for (a, b) : iter.byzip([0,2,4,6,8][:], [2,4][:]) 9 | std.assert(a == n*2, "invalid val from a: {}", a) 10 | std.assert(b == n*2 + 2, "invalid val from b: {}", b) 11 | n++ 12 | ;; 13 | } 14 | -------------------------------------------------------------------------------- /lib/iter/zip.myr: -------------------------------------------------------------------------------- 1 | pkg iter = 2 | type zipiter(@a, @b) = struct 3 | s1 : @a[:] 4 | s2 : @b[:] 5 | ;; 6 | 7 | impl iterable zipiter(@a, @b) -> (@a, @b) 8 | generic byzip : (a : @a[:], b : @b[:] -> zipiter(@a, @b)) 9 | ;; 10 | 11 | generic byzip = {a, b 12 | -> [.s1 = a, .s2 = b] 13 | } 14 | 15 | impl iterable zipiter(@a, @b) -> (@a, @b) = 16 | __iternext__ = {itp, valp 17 | if itp.s1.len > 0 && itp.s2.len > 0 18 | valp# = (itp.s1[0], itp.s2[0]) 19 | itp.s1 = itp.s1[1:] 20 | itp.s2 = itp.s2[1:] 21 | -> true 22 | else 23 | -> false 24 | ;; 25 | } 26 | 27 | __iterfin__ = {itp, valp 28 | } 29 | ;; 30 | 31 | -------------------------------------------------------------------------------- /lib/json/bld.sub: -------------------------------------------------------------------------------- 1 | lib json = 2 | types.myr 3 | parse.myr 4 | fmt.myr 5 | 6 | lib ../sys:sys 7 | lib ../std:std 8 | ;; 9 | 10 | testdeps = ../testr:testr ;; 11 | -------------------------------------------------------------------------------- /lib/json/test/inputs/_n_string_UTF8_surrogate_U+D800.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/_n_string_UTF8_surrogate_U+D800.json -------------------------------------------------------------------------------- /lib/json/test/inputs/_y_string_utf16.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/_y_string_utf16.json -------------------------------------------------------------------------------- /lib/json/test/inputs/i_number_neg_int_huge_exp.json: -------------------------------------------------------------------------------- 1 | [-1e+9999] -------------------------------------------------------------------------------- /lib/json/test/inputs/i_number_pos_double_huge_exp.json: -------------------------------------------------------------------------------- 1 | [1.5e+9999] -------------------------------------------------------------------------------- /lib/json/test/inputs/i_object_key_lone_2nd_surrogate.json: -------------------------------------------------------------------------------- 1 | {"\uDFAA":0} -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_1st_surrogate_but_2nd_missing.json: -------------------------------------------------------------------------------- 1 | ["\uDADA"] -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_1st_valid_surrogate_2nd_invalid.json: -------------------------------------------------------------------------------- 1 | ["\uD888\u1234"] -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_UTF-16_invalid_lonely_surrogate.json: -------------------------------------------------------------------------------- 1 | ["\ud800"] -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_UTF-16_invalid_surrogate.json: -------------------------------------------------------------------------------- 1 | ["\ud800abc"] -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_UTF-8_invalid_sequence.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/i_string_UTF-8_invalid_sequence.json -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_incomplete_surrogate_and_escape_valid.json: -------------------------------------------------------------------------------- 1 | ["\uD800\n"] -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_incomplete_surrogate_pair.json: -------------------------------------------------------------------------------- 1 | ["\uDd1ea"] -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_incomplete_surrogates_escape_valid.json: -------------------------------------------------------------------------------- 1 | ["\uD800\uD800\n"] -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_inverted_surrogates_U+1D11E.json: -------------------------------------------------------------------------------- 1 | ["\uDd1e\uD834"] -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_lone_second_surrogate.json: -------------------------------------------------------------------------------- 1 | ["\uDFAA"] -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_not_in_unicode_range.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/i_string_not_in_unicode_range.json -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_truncated-utf-8.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/i_string_truncated-utf-8.json -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_unicode_U+10FFFE_nonchar.json: -------------------------------------------------------------------------------- 1 | ["\uDBFF\uDFFE"] -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_unicode_U+1FFFE_nonchar.json: -------------------------------------------------------------------------------- 1 | ["\uD83F\uDFFE"] -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_unicode_U+FDD0_nonchar.json: -------------------------------------------------------------------------------- 1 | ["\uFDD0"] -------------------------------------------------------------------------------- /lib/json/test/inputs/i_string_unicode_U+FFFE_nonchar.json: -------------------------------------------------------------------------------- 1 | ["\uFFFE"] -------------------------------------------------------------------------------- /lib/json/test/inputs/i_structure_UTF-8_BOM_empty_object.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_1_true_without_comma.json: -------------------------------------------------------------------------------- 1 | [1 true] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_a_invalid_utf8.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_array_a_invalid_utf8.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_colon_instead_of_comma.json: -------------------------------------------------------------------------------- 1 | ["": 1] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_comma_after_close.json: -------------------------------------------------------------------------------- 1 | [""], -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_comma_and_number.json: -------------------------------------------------------------------------------- 1 | [,1] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_double_comma.json: -------------------------------------------------------------------------------- 1 | [1,,2] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_double_extra_comma.json: -------------------------------------------------------------------------------- 1 | ["x",,] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_extra_close.json: -------------------------------------------------------------------------------- 1 | ["x"]] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_extra_comma.json: -------------------------------------------------------------------------------- 1 | ["",] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_incomplete.json: -------------------------------------------------------------------------------- 1 | ["x" -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_incomplete_invalid_value.json: -------------------------------------------------------------------------------- 1 | [x -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_inner_array_no_comma.json: -------------------------------------------------------------------------------- 1 | [3[4]] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_invalid_utf8.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_array_invalid_utf8.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_items_separated_by_semicolon.json: -------------------------------------------------------------------------------- 1 | [1:2] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_just_comma.json: -------------------------------------------------------------------------------- 1 | [,] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_just_minus.json: -------------------------------------------------------------------------------- 1 | [-] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_missing_value.json: -------------------------------------------------------------------------------- 1 | [ , ""] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_newlines_unclosed.json: -------------------------------------------------------------------------------- 1 | ["a", 2 | 4 3 | ,1, -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_number_and_comma.json: -------------------------------------------------------------------------------- 1 | [1,] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_number_and_several_commas.json: -------------------------------------------------------------------------------- 1 | [1,,] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_spaces_vertical_tab_formfeed.json: -------------------------------------------------------------------------------- 1 | [" a"\f] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_star_inside.json: -------------------------------------------------------------------------------- 1 | [*] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_unclosed.json: -------------------------------------------------------------------------------- 1 | ["" -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_unclosed_trailing_comma.json: -------------------------------------------------------------------------------- 1 | [1, -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_unclosed_with_new_lines.json: -------------------------------------------------------------------------------- 1 | [1, 2 | 1 3 | ,1 -------------------------------------------------------------------------------- /lib/json/test/inputs/n_array_unclosed_with_object_inside.json: -------------------------------------------------------------------------------- 1 | [{} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_incomplete_false.json: -------------------------------------------------------------------------------- 1 | [fals] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_incomplete_null.json: -------------------------------------------------------------------------------- 1 | [nul] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_incomplete_true.json: -------------------------------------------------------------------------------- 1 | [tru] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_++.json: -------------------------------------------------------------------------------- 1 | [++1234] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_+1.json: -------------------------------------------------------------------------------- 1 | [+1] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_+Inf.json: -------------------------------------------------------------------------------- 1 | [+Inf] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_-01.json: -------------------------------------------------------------------------------- 1 | [-01] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_-1.0..json: -------------------------------------------------------------------------------- 1 | [-1.0.] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_-2..json: -------------------------------------------------------------------------------- 1 | [-2.] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_-NaN.json: -------------------------------------------------------------------------------- 1 | [-NaN] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_.-1.json: -------------------------------------------------------------------------------- 1 | [.-1] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_.2e-3.json: -------------------------------------------------------------------------------- 1 | [.2e-3] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_0.1.2.json: -------------------------------------------------------------------------------- 1 | [0.1.2] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_0.3e+.json: -------------------------------------------------------------------------------- 1 | [0.3e+] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_0.3e.json: -------------------------------------------------------------------------------- 1 | [0.3e] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_0.e1.json: -------------------------------------------------------------------------------- 1 | [0.e1] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_0_capital_E+.json: -------------------------------------------------------------------------------- 1 | [0E+] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_0_capital_E.json: -------------------------------------------------------------------------------- 1 | [0E] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_0e+.json: -------------------------------------------------------------------------------- 1 | [0e+] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_0e.json: -------------------------------------------------------------------------------- 1 | [0e] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_1.0e+.json: -------------------------------------------------------------------------------- 1 | [1.0e+] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_1.0e-.json: -------------------------------------------------------------------------------- 1 | [1.0e-] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_1.0e.json: -------------------------------------------------------------------------------- 1 | [1.0e] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_1_000.json: -------------------------------------------------------------------------------- 1 | [1 000.0] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_1eE2.json: -------------------------------------------------------------------------------- 1 | [1eE2] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_2.e+3.json: -------------------------------------------------------------------------------- 1 | [2.e+3] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_2.e-3.json: -------------------------------------------------------------------------------- 1 | [2.e-3] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_2.e3.json: -------------------------------------------------------------------------------- 1 | [2.e3] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_9.e+.json: -------------------------------------------------------------------------------- 1 | [9.e+] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_Inf.json: -------------------------------------------------------------------------------- 1 | [Inf] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_NaN.json: -------------------------------------------------------------------------------- 1 | [NaN] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_U+FF11_fullwidth_digit_one.json: -------------------------------------------------------------------------------- 1 | [1] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_expression.json: -------------------------------------------------------------------------------- 1 | [1+2] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_hex_1_digit.json: -------------------------------------------------------------------------------- 1 | [0x1] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_hex_2_digits.json: -------------------------------------------------------------------------------- 1 | [0x42] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_infinity.json: -------------------------------------------------------------------------------- 1 | [Infinity] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_invalid+-.json: -------------------------------------------------------------------------------- 1 | [0e+-1] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_invalid-negative-real.json: -------------------------------------------------------------------------------- 1 | [-123.123foo] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_invalid-utf-8-in-bigger-int.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_number_invalid-utf-8-in-bigger-int.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_invalid-utf-8-in-exponent.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_number_invalid-utf-8-in-exponent.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_invalid-utf-8-in-int.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_number_invalid-utf-8-in-int.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_minus_infinity.json: -------------------------------------------------------------------------------- 1 | [-Infinity] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_minus_sign_with_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | [-foo] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_minus_space_1.json: -------------------------------------------------------------------------------- 1 | [- 1] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_neg_int_starting_with_zero.json: -------------------------------------------------------------------------------- 1 | [-012] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_neg_real_without_int_part.json: -------------------------------------------------------------------------------- 1 | [-.123] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_neg_with_garbage_at_end.json: -------------------------------------------------------------------------------- 1 | [-1x] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_real_garbage_after_e.json: -------------------------------------------------------------------------------- 1 | [1ea] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_real_with_invalid_utf8_after_e.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_number_real_with_invalid_utf8_after_e.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_real_without_fractional_part.json: -------------------------------------------------------------------------------- 1 | [1.] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_starting_with_dot.json: -------------------------------------------------------------------------------- 1 | [.123] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_then_00.json: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_with_alpha.json: -------------------------------------------------------------------------------- 1 | [1.2a-3] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_with_alpha_char.json: -------------------------------------------------------------------------------- 1 | [1.8011670033376514H-308] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_number_with_leading_zero.json: -------------------------------------------------------------------------------- 1 | [012] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_bad_value.json: -------------------------------------------------------------------------------- 1 | ["x", truth] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_bracket_key.json: -------------------------------------------------------------------------------- 1 | {[: "x"} 2 | -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_comma_instead_of_colon.json: -------------------------------------------------------------------------------- 1 | {"x", null} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_double_colon.json: -------------------------------------------------------------------------------- 1 | {"x"::"b"} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_emoji.json: -------------------------------------------------------------------------------- 1 | {🇨🇭} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_garbage_at_end.json: -------------------------------------------------------------------------------- 1 | {"a":"a" 123} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_key_with_single_quotes.json: -------------------------------------------------------------------------------- 1 | {key: 'value'} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_missing_colon.json: -------------------------------------------------------------------------------- 1 | {"a" b} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_missing_key.json: -------------------------------------------------------------------------------- 1 | {:"b"} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_missing_semicolon.json: -------------------------------------------------------------------------------- 1 | {"a" "b"} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_missing_value.json: -------------------------------------------------------------------------------- 1 | {"a": -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_no-colon.json: -------------------------------------------------------------------------------- 1 | {"a" -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_non_string_key.json: -------------------------------------------------------------------------------- 1 | {1:1} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_non_string_key_but_huge_number_instead.json: -------------------------------------------------------------------------------- 1 | {9999E9999:1} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_pi_in_key_and_trailing_comma.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_object_pi_in_key_and_trailing_comma.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_repeated_null_null.json: -------------------------------------------------------------------------------- 1 | {null:null,null:null} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_several_trailing_commas.json: -------------------------------------------------------------------------------- 1 | {"id":0,,,,,} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_single_quote.json: -------------------------------------------------------------------------------- 1 | {'a':0} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_trailing_comma.json: -------------------------------------------------------------------------------- 1 | {"id":0,} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_trailing_comment.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}/**/ -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_trailing_comment_open.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}/**// -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_trailing_comment_slash_open.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}// -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_trailing_comment_slash_open_incomplete.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}/ -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_two_commas_in_a_row.json: -------------------------------------------------------------------------------- 1 | {"a":"b",,"c":"d"} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_unquoted_key.json: -------------------------------------------------------------------------------- 1 | {a: "b"} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_unterminated-value.json: -------------------------------------------------------------------------------- 1 | {"a":"a -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_with_single_string.json: -------------------------------------------------------------------------------- 1 | { "foo" : "bar", "a" } -------------------------------------------------------------------------------- /lib/json/test/inputs/n_object_with_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}# -------------------------------------------------------------------------------- /lib/json/test/inputs/n_single_space.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_1_surrogate_then_escape: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_string_1_surrogate_then_escape -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_1_surrogate_then_escape u.json: -------------------------------------------------------------------------------- 1 | ["\uD800\u"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_1_surrogate_then_escape u1.json: -------------------------------------------------------------------------------- 1 | ["\uD800\u1"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_1_surrogate_then_escape u1x.json: -------------------------------------------------------------------------------- 1 | ["\uD800\u1x"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_1_surrogate_then_escape.json: -------------------------------------------------------------------------------- 1 | ["\uD800\"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_UTF-16_incomplete_surrogate.json: -------------------------------------------------------------------------------- 1 | ["\uD834\uDd"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_accentuated_char_no_quotes.json: -------------------------------------------------------------------------------- 1 | [é] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_backslash_00.json: -------------------------------------------------------------------------------- 1 | ["\"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_escape_x.json: -------------------------------------------------------------------------------- 1 | ["\x00"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_escaped_backslash_bad.json: -------------------------------------------------------------------------------- 1 | ["\\\"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_escaped_ctrl_char_tab.json: -------------------------------------------------------------------------------- 1 | ["\ "] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_escaped_emoji.json: -------------------------------------------------------------------------------- 1 | ["\🌀"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_incomplete_escape.json: -------------------------------------------------------------------------------- 1 | ["\"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_incomplete_escaped_character.json: -------------------------------------------------------------------------------- 1 | ["\u00A"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_incomplete_surrogate_escape_invalid.json: -------------------------------------------------------------------------------- 1 | ["\uD800\uD800\x"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_invalid-utf-8-in-escape.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_string_invalid-utf-8-in-escape.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_invalid_backslash_esc.json: -------------------------------------------------------------------------------- 1 | ["\a"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_invalid_unicode_escape.json: -------------------------------------------------------------------------------- 1 | ["\uqqqq"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_invalid_utf-8.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_string_invalid_utf-8.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_invalid_utf8_after_escape.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_string_invalid_utf8_after_escape.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_iso_latin_1.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_string_iso_latin_1.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_leading_uescaped_thinspace.json: -------------------------------------------------------------------------------- 1 | [\u0020"asd"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_lone_utf8_continuation_byte.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_string_lone_utf8_continuation_byte.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_no_quotes_with_bad_escape.json: -------------------------------------------------------------------------------- 1 | [\n] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_overlong_sequence_2_bytes.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_string_overlong_sequence_2_bytes.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_overlong_sequence_6_bytes.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_string_overlong_sequence_6_bytes.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_overlong_sequence_6_bytes_null.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_string_overlong_sequence_6_bytes_null.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_single_doublequote.json: -------------------------------------------------------------------------------- 1 | " -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_single_quote.json: -------------------------------------------------------------------------------- 1 | ['single quote'] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_single_string_no_double_quotes.json: -------------------------------------------------------------------------------- 1 | abc -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_start_escape_unclosed.json: -------------------------------------------------------------------------------- 1 | ["\ -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_unescaped_crtl_char.json: -------------------------------------------------------------------------------- 1 | ["aa"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_unescaped_newline.json: -------------------------------------------------------------------------------- 1 | ["new 2 | line"] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_unescaped_tab.json: -------------------------------------------------------------------------------- 1 | [" "] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_unicode_CapitalU.json: -------------------------------------------------------------------------------- 1 | "\UA66D" -------------------------------------------------------------------------------- /lib/json/test/inputs/n_string_with_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | ""x -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_<.>.json: -------------------------------------------------------------------------------- 1 | <.> -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_U+2060_word_joined.json: -------------------------------------------------------------------------------- 1 | [⁠] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_UTF8_BOM_no_data.json: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_array_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | [1]x -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_array_with_extra_array_close.json: -------------------------------------------------------------------------------- 1 | [1]] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_array_with_unclosed_string.json: -------------------------------------------------------------------------------- 1 | ["asd] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_ascii-unicode-identifier.json: -------------------------------------------------------------------------------- 1 | aå -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_capitalized_True.json: -------------------------------------------------------------------------------- 1 | [True] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_close_unopened_array.json: -------------------------------------------------------------------------------- 1 | 1] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_comma_instead_of_closing_brace.json: -------------------------------------------------------------------------------- 1 | {"x": true, -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_double_array.json: -------------------------------------------------------------------------------- 1 | [][] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_end_array.json: -------------------------------------------------------------------------------- 1 | ] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_incomplete_UTF8_BOM.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_structure_incomplete_UTF8_BOM.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_lone-invalid-utf-8.json: -------------------------------------------------------------------------------- 1 | � -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_lone-open-bracket.json: -------------------------------------------------------------------------------- 1 | [ -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_no_data.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/lib/json/test/inputs/n_structure_no_data.json -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_null-byte-outside-string.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_number_with_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | 2@ -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_object_followed_by_closing_object.json: -------------------------------------------------------------------------------- 1 | {}} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_object_unclosed_no_value.json: -------------------------------------------------------------------------------- 1 | {"": -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_object_with_comment.json: -------------------------------------------------------------------------------- 1 | {"a":/*comment*/"b"} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_object_with_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | {"a": true} "x" -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_open_array_apostrophe.json: -------------------------------------------------------------------------------- 1 | [' -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_open_array_comma.json: -------------------------------------------------------------------------------- 1 | [, -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_open_array_open_object.json: -------------------------------------------------------------------------------- 1 | [{ -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_open_array_open_string.json: -------------------------------------------------------------------------------- 1 | ["a -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_open_array_string.json: -------------------------------------------------------------------------------- 1 | ["a" -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_open_object.json: -------------------------------------------------------------------------------- 1 | { -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_open_object_close_array.json: -------------------------------------------------------------------------------- 1 | {] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_open_object_comma.json: -------------------------------------------------------------------------------- 1 | {, -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_open_object_open_array.json: -------------------------------------------------------------------------------- 1 | {[ -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_open_object_open_string.json: -------------------------------------------------------------------------------- 1 | {"a -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_open_object_string_with_apostrophes.json: -------------------------------------------------------------------------------- 1 | {'a' -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_open_open.json: -------------------------------------------------------------------------------- 1 | ["\{["\{["\{["\{ -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_single_point.json: -------------------------------------------------------------------------------- 1 | � -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_single_star.json: -------------------------------------------------------------------------------- 1 | * -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_trailing_#.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}#{} -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_uescaped_LF_before_string.json: -------------------------------------------------------------------------------- 1 | [\u000A""] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_unclosed_array.json: -------------------------------------------------------------------------------- 1 | [1 -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_unclosed_array_partial_null.json: -------------------------------------------------------------------------------- 1 | [ false, nul -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_unclosed_array_unfinished_false.json: -------------------------------------------------------------------------------- 1 | [ true, fals -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_unclosed_array_unfinished_true.json: -------------------------------------------------------------------------------- 1 | [ false, tru -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_unclosed_object.json: -------------------------------------------------------------------------------- 1 | {"asd":"asd" -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_unicode-identifier.json: -------------------------------------------------------------------------------- 1 | å -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_whitespace_U+2060_word_joiner.json: -------------------------------------------------------------------------------- 1 | [⁠] -------------------------------------------------------------------------------- /lib/json/test/inputs/n_structure_whitespace_formfeed.json: -------------------------------------------------------------------------------- 1 | [ ] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_array_arraysWithSpaces.json: -------------------------------------------------------------------------------- 1 | [[] ] 2 | -------------------------------------------------------------------------------- /lib/json/test/inputs/y_array_empty-string.json: -------------------------------------------------------------------------------- 1 | [""] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_array_empty.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_array_ending_with_newline.json: -------------------------------------------------------------------------------- 1 | ["a"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_array_false.json: -------------------------------------------------------------------------------- 1 | [false] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_array_heterogeneous.json: -------------------------------------------------------------------------------- 1 | [null, 1, "1", {}] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_array_null.json: -------------------------------------------------------------------------------- 1 | [null] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_array_with_1_and_newline.json: -------------------------------------------------------------------------------- 1 | [1 2 | ] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_array_with_leading_space.json: -------------------------------------------------------------------------------- 1 | [1] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_array_with_several_null.json: -------------------------------------------------------------------------------- 1 | [1,null,null,null,2] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_array_with_trailing_space.json: -------------------------------------------------------------------------------- 1 | [2] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number.json: -------------------------------------------------------------------------------- 1 | [123e65] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_0e+1.json: -------------------------------------------------------------------------------- 1 | [0e+1] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_0e1.json: -------------------------------------------------------------------------------- 1 | [0e1] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_after_space.json: -------------------------------------------------------------------------------- 1 | [ 4] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_double_close_to_zero.json: -------------------------------------------------------------------------------- 1 | [-0.000000000000000000000000000000000000000000000000000000000000000000000000000001] 2 | -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_double_huge_neg_exp.json: -------------------------------------------------------------------------------- 1 | [123.456e-789] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_huge_exp.json: -------------------------------------------------------------------------------- 1 | [0.4e00669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_int_with_exp.json: -------------------------------------------------------------------------------- 1 | [20e1] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_minus_zero.json: -------------------------------------------------------------------------------- 1 | [-0] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_negative_int.json: -------------------------------------------------------------------------------- 1 | [-123] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_negative_one.json: -------------------------------------------------------------------------------- 1 | [-1] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_negative_zero.json: -------------------------------------------------------------------------------- 1 | [-0] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_real_capital_e.json: -------------------------------------------------------------------------------- 1 | [1E22] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_real_capital_e_neg_exp.json: -------------------------------------------------------------------------------- 1 | [1E-2] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_real_capital_e_pos_exp.json: -------------------------------------------------------------------------------- 1 | [1E+2] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_real_exponent.json: -------------------------------------------------------------------------------- 1 | [123e45] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_real_fraction_exponent.json: -------------------------------------------------------------------------------- 1 | [123.456e78] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_real_neg_exp.json: -------------------------------------------------------------------------------- 1 | [1e-2] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_real_neg_overflow.json: -------------------------------------------------------------------------------- 1 | [-123123e100000] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_real_pos_exponent.json: -------------------------------------------------------------------------------- 1 | [1e+2] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_real_pos_overflow.json: -------------------------------------------------------------------------------- 1 | [123123e100000] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_real_underflow.json: -------------------------------------------------------------------------------- 1 | [123e-10000000] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_simple_int.json: -------------------------------------------------------------------------------- 1 | [123] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_simple_real.json: -------------------------------------------------------------------------------- 1 | [123.456789] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_too_big_neg_int.json: -------------------------------------------------------------------------------- 1 | [-123123123123123123123123123123] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_too_big_pos_int.json: -------------------------------------------------------------------------------- 1 | [100000000000000000000] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_number_very_big_negative_int.json: -------------------------------------------------------------------------------- 1 | [-237462374673276894279832749832423479823246327846] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_object.json: -------------------------------------------------------------------------------- 1 | {"asd":"sdf", "dfg":"fgh"} -------------------------------------------------------------------------------- /lib/json/test/inputs/y_object_basic.json: -------------------------------------------------------------------------------- 1 | {"asd":"sdf"} -------------------------------------------------------------------------------- /lib/json/test/inputs/y_object_duplicated_key.json: -------------------------------------------------------------------------------- 1 | {"a":"b","a":"c"} -------------------------------------------------------------------------------- /lib/json/test/inputs/y_object_duplicated_key_and_value.json: -------------------------------------------------------------------------------- 1 | {"a":"b","a":"b"} -------------------------------------------------------------------------------- /lib/json/test/inputs/y_object_empty.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /lib/json/test/inputs/y_object_empty_key.json: -------------------------------------------------------------------------------- 1 | {"":0} -------------------------------------------------------------------------------- /lib/json/test/inputs/y_object_escaped_null_in_key.json: -------------------------------------------------------------------------------- 1 | {"foo\u0000bar": 42} -------------------------------------------------------------------------------- /lib/json/test/inputs/y_object_extreme_numbers.json: -------------------------------------------------------------------------------- 1 | { "min": -1.0e+28, "max": 1.0e+28 } 2 | -------------------------------------------------------------------------------- /lib/json/test/inputs/y_object_long_strings.json: -------------------------------------------------------------------------------- 1 | {"x":[{"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}], "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} -------------------------------------------------------------------------------- /lib/json/test/inputs/y_object_simple.json: -------------------------------------------------------------------------------- 1 | {"a":[]} -------------------------------------------------------------------------------- /lib/json/test/inputs/y_object_string_unicode.json: -------------------------------------------------------------------------------- 1 | {"title":"\u041f\u043e\u043b\u0442\u043e\u0440\u0430 \u0417\u0435\u043c\u043b\u0435\u043a\u043e\u043f\u0430" } -------------------------------------------------------------------------------- /lib/json/test/inputs/y_object_with_newlines.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b" 3 | } -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_1_2_3_bytes_UTF-8_sequences.json: -------------------------------------------------------------------------------- 1 | ["\u0060\u012a\u12AB"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_UTF-16_Surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json: -------------------------------------------------------------------------------- 1 | ["\uD834\uDd1e"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_accepted_surrogate_pair.json: -------------------------------------------------------------------------------- 1 | ["\uD801\udc37"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_accepted_surrogate_pairs.json: -------------------------------------------------------------------------------- 1 | ["\ud83d\ude39\ud83d\udc8d"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_allowed_escapes.json: -------------------------------------------------------------------------------- 1 | ["\"\\\/\b\f\n\r\t"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_backslash_and_u_escaped_zero.json: -------------------------------------------------------------------------------- 1 | ["\\u0000"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_backslash_doublequotes.json: -------------------------------------------------------------------------------- 1 | ["\""] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_comments.json: -------------------------------------------------------------------------------- 1 | ["a/*b*/c/*d//e"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_double_escape_a.json: -------------------------------------------------------------------------------- 1 | ["\\a"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_double_escape_n.json: -------------------------------------------------------------------------------- 1 | ["\\n"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_escaped_control_character.json: -------------------------------------------------------------------------------- 1 | ["\u0012"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_escaped_noncharacter.json: -------------------------------------------------------------------------------- 1 | ["\uFFFF"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_in_array.json: -------------------------------------------------------------------------------- 1 | ["asd"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_in_array_with_leading_space.json: -------------------------------------------------------------------------------- 1 | [ "asd"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_last_surrogates_1_and_2.json: -------------------------------------------------------------------------------- 1 | ["\uDBFF\uDFFF"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_newline_uescaped.json: -------------------------------------------------------------------------------- 1 | ["new\u00A0line"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_nonCharacterInUTF-8_U+10FFFF.json: -------------------------------------------------------------------------------- 1 | ["􏿿"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_nonCharacterInUTF-8_U+1FFFF.json: -------------------------------------------------------------------------------- 1 | ["𛿿"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_nonCharacterInUTF-8_U+FFFF.json: -------------------------------------------------------------------------------- 1 | ["￿"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_null_escape.json: -------------------------------------------------------------------------------- 1 | ["\u0000"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_one-byte-utf-8.json: -------------------------------------------------------------------------------- 1 | ["\u002c"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_pi.json: -------------------------------------------------------------------------------- 1 | ["π"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_simple_ascii.json: -------------------------------------------------------------------------------- 1 | ["asd "] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_space.json: -------------------------------------------------------------------------------- 1 | " " -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_three-byte-utf-8.json: -------------------------------------------------------------------------------- 1 | ["\u0821"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_two-byte-utf-8.json: -------------------------------------------------------------------------------- 1 | ["\u0123"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_u+2028_line_sep.json: -------------------------------------------------------------------------------- 1 | ["
"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_u+2029_par_sep.json: -------------------------------------------------------------------------------- 1 | ["
"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_uEscape.json: -------------------------------------------------------------------------------- 1 | ["\u0061\u30af\u30EA\u30b9"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_unescaped_char_delete.json: -------------------------------------------------------------------------------- 1 | [""] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_unicode.json: -------------------------------------------------------------------------------- 1 | ["\uA66D"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_unicodeEscapedBackslash.json: -------------------------------------------------------------------------------- 1 | ["\u005C"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_unicode_2.json: -------------------------------------------------------------------------------- 1 | ["⍂㈴⍂"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json: -------------------------------------------------------------------------------- 1 | ["\u200B"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_unicode_U+2064_invisible_plus.json: -------------------------------------------------------------------------------- 1 | ["\u2064"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_unicode_escaped_double_quote.json: -------------------------------------------------------------------------------- 1 | ["\u0022"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_utf8.json: -------------------------------------------------------------------------------- 1 | ["€𝄞"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_string_with_del_character.json: -------------------------------------------------------------------------------- 1 | ["aa"] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_structure_lonely_false.json: -------------------------------------------------------------------------------- 1 | false -------------------------------------------------------------------------------- /lib/json/test/inputs/y_structure_lonely_int.json: -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /lib/json/test/inputs/y_structure_lonely_negative_real.json: -------------------------------------------------------------------------------- 1 | -0.1 -------------------------------------------------------------------------------- /lib/json/test/inputs/y_structure_lonely_null.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /lib/json/test/inputs/y_structure_lonely_string.json: -------------------------------------------------------------------------------- 1 | "asd" -------------------------------------------------------------------------------- /lib/json/test/inputs/y_structure_lonely_true.json: -------------------------------------------------------------------------------- 1 | true -------------------------------------------------------------------------------- /lib/json/test/inputs/y_structure_string_empty.json: -------------------------------------------------------------------------------- 1 | "" -------------------------------------------------------------------------------- /lib/json/test/inputs/y_structure_trailing_newline.json: -------------------------------------------------------------------------------- 1 | ["a"] 2 | -------------------------------------------------------------------------------- /lib/json/test/inputs/y_structure_true_in_array.json: -------------------------------------------------------------------------------- 1 | [true] -------------------------------------------------------------------------------- /lib/json/test/inputs/y_structure_whitespace_array.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /lib/json/types.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg json = 4 | type elt = union 5 | `Null 6 | `Bool bool 7 | `Num flt64 8 | `Str byte[:] 9 | `Arr elt#[:] 10 | `Obj (byte[:], elt#)[:] 11 | ;; 12 | 13 | type err = struct 14 | e : errtype 15 | line : std.size 16 | off : std.size 17 | ;; 18 | 19 | type errtype = union 20 | `Badesc char 21 | `Junk char 22 | `Depth 23 | `End 24 | ;; 25 | ;; 26 | 27 | -------------------------------------------------------------------------------- /lib/math/ancillary/README: -------------------------------------------------------------------------------- 1 | The files in this directory are only useful for understanding 2 | derivation of constants. If you wish to improve a file like 3 | sqrt-impl.myr, and are curious as to how certain constants were 4 | derived, this might hold some answers. 5 | -------------------------------------------------------------------------------- /lib/math/fma-impl+posixy-x64-fma.s: -------------------------------------------------------------------------------- 1 | .globl math$fma32 2 | .globl _math$fma32 3 | math$fma32: 4 | _math$fma32: 5 | vfmadd132ss %xmm1, %xmm2, %xmm0 6 | ret 7 | 8 | .globl math$fma64 9 | .globl _math$fma64 10 | math$fma64: 11 | _math$fma64: 12 | vfmadd132sd %xmm1, %xmm2, %xmm0 13 | ret 14 | -------------------------------------------------------------------------------- /lib/math/fma.myr: -------------------------------------------------------------------------------- 1 | pkg math = 2 | pkglocal extern const fma32 : (x : flt32, y : flt32, z : flt32 -> flt32) 3 | pkglocal extern const fma64 : (x : flt64, y : flt64, z : flt64 -> flt64) 4 | ;; 5 | -------------------------------------------------------------------------------- /lib/math/ftrap-impl+plan9-x64.s: -------------------------------------------------------------------------------- 1 | TEXT math$fptrap(SB),$0 2 | SUBQ $4,SP 3 | WAIT 4 | STMXCSR (SP) 5 | MOVL (SP),AX 6 | ANDL $~0x1f80,AX 7 | TESTB DI,DI 8 | JNZ .apply 9 | ORL $0x1f80,AX 10 | .apply: 11 | MOVL AX,(SP) 12 | LDMXCSR (SP) 13 | ADDQ $4,SP 14 | RET 15 | -------------------------------------------------------------------------------- /lib/math/ftrap-impl+posixy-x64.s: -------------------------------------------------------------------------------- 1 | .globl _math$fptrap 2 | .globl math$fptrap 3 | _math$fptrap: 4 | math$fptrap: 5 | subq $4,%rsp 6 | wait 7 | stmxcsr (%rsp) 8 | movl (%rsp),%eax 9 | andl $~0x1f80,%eax 10 | testb %dil,%dil 11 | jnz .apply 12 | orl $0x1f80,%eax 13 | .apply: 14 | movl %eax,(%rsp) 15 | ldmxcsr (%rsp) 16 | addq $4,%rsp 17 | ret 18 | -------------------------------------------------------------------------------- /lib/math/ftrap.myr: -------------------------------------------------------------------------------- 1 | pkg math = 2 | extern const fptrap : (f : bool -> void) 3 | ;; 4 | -------------------------------------------------------------------------------- /lib/math/round-impl+posixy-x64-sse4.s: -------------------------------------------------------------------------------- 1 | .globl math$rn32 2 | .globl _math$rn32 3 | math$rn32: 4 | _math$rn32: 5 | pushq %rbp 6 | movq %rsp, %rbp 7 | subq $16, %rsp 8 | fnstcw (%rsp) 9 | fnstcw 8(%rsp) 10 | andl $0xf3ff, 8(%rsp) 11 | fldcw 8(%rsp) 12 | cvtss2si %xmm0, %eax 13 | fldcw (%rsp) 14 | leave 15 | ret 16 | 17 | .globl math$rn64 18 | .globl _math$rn64 19 | math$rn64: 20 | _math$rn64: 21 | pushq %rbp 22 | movq %rsp, %rbp 23 | subq $16, %rsp 24 | fnstcw (%rsp) 25 | fnstcw 8(%rsp) 26 | andl $0xf3ff, 8(%rsp) 27 | fldcw 8(%rsp) 28 | cvtsd2si %xmm0, %rax 29 | fldcw (%rsp) 30 | leave 31 | ret 32 | 33 | -------------------------------------------------------------------------------- /lib/math/sqrt-impl+posixy-x64-sse2.s: -------------------------------------------------------------------------------- 1 | .globl math$sqrt32 2 | .globl _math$sqrt32 3 | math$sqrt32: 4 | _math$sqrt32: 5 | sqrtss %xmm0, %xmm0 6 | ret 7 | 8 | .globl math$sqrt64 9 | .globl _math$sqrt64 10 | math$sqrt64: 11 | _math$sqrt64: 12 | sqrtsd %xmm0, %xmm0 13 | ret 14 | -------------------------------------------------------------------------------- /lib/regex/bld.sub: -------------------------------------------------------------------------------- 1 | lib regex = 2 | compile.myr 3 | interp.myr 4 | ranges.myr 5 | types.myr 6 | 7 | lib ../sys:sys 8 | lib ../std:std 9 | ;; 10 | 11 | bin redump = 12 | redump.myr 13 | lib ../std:std 14 | lib ../bio:bio 15 | lib ../sys:sys 16 | lib regex 17 | ;; 18 | 19 | gen ranges.myr {durable} = 20 | mkchartab -a -p_ranges UnicodeData.txt -o ranges.myr 21 | ;; 22 | 23 | sub = test ;; 24 | 25 | man = myr-regex.3 ;; 26 | -------------------------------------------------------------------------------- /lib/regex/test/capture.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use "testmatch" 3 | 4 | const main = { 5 | testmatch("A(.*)", "Abc", `std.Some ["bc"][:]) 6 | testmatch("A(.*)e", "Abcde", `std.Some ["bcd"][:]) 7 | testmatch("(a|b)+", "abab", `std.Some ["b"][:]) 8 | testmatch("A(b(.*)d)e", "Abcde", `std.Some [ 9 | "bcd", 10 | "c" 11 | ][:]) 12 | testmatch("(a?)(a*)(a?)", "aaaa", `std.Some [ 13 | "a", 14 | "aaa", 15 | "" 16 | ][:]) 17 | } 18 | -------------------------------------------------------------------------------- /lib/regex/test/failmatch.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | use "testmatch" 4 | 5 | const main = { 6 | testmatch(".*bcd", "Abc", `std.None) 7 | } 8 | -------------------------------------------------------------------------------- /lib/regex/test/unicode.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use regex 3 | 4 | use "testmatch" 5 | 6 | const main = { 7 | testmatch(".*bæc", "Abæc", `std.Some [][:]) 8 | testmatch("(\\p{L}*)bæc\\P{L}*", \ 9 | "Aabæc%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", \ 10 | `std.Some ["Aa"][:]) 11 | /* test various syntaxen */ 12 | testmatch("(\\pL*)bæc\\PL*", \ 13 | "Aabæc%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", \ 14 | `std.Some ["Aa"][:]) 15 | testmatch("(\\p{Letter}*)bæc\\P{Uppercase_Letter}*", \ 16 | "Aabæc%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", \ 17 | `std.Some ["Aa"][:]) 18 | testmatch(".", "æ", `std.Some [][:]) 19 | } 20 | -------------------------------------------------------------------------------- /lib/std/assert.myr: -------------------------------------------------------------------------------- 1 | use "fmt" 2 | use "syswrap" 3 | use "varargs" 4 | 5 | pkg std = 6 | const assert : (cond : bool, fmt : byte[:], args : ... -> void) 7 | ;; 8 | 9 | const assert = {cond, msg, args 10 | var ap 11 | 12 | if !cond 13 | ap = vastart(&args) 14 | std.fputv(2, msg, &ap) 15 | suicide() 16 | ;; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /lib/std/backtrace+x64.myr: -------------------------------------------------------------------------------- 1 | use "types" 2 | 3 | pkg std = 4 | const backtrace : (pc : void#[:] -> std.size) 5 | ;; 6 | 7 | type stackrec = struct 8 | next : stackrec# 9 | pc : void# 10 | ;; 11 | 12 | extern const getbp : (-> stackrec#) 13 | const backtrace = {pc 14 | var bp, i, len 15 | 16 | i = 0 17 | len = pc.len 18 | bp = getbp() 19 | while bp != (0 : stackrec#) && i < len 20 | pc[i++] = bp.pc 21 | bp = bp.next 22 | ;; 23 | -> i 24 | } 25 | 26 | -------------------------------------------------------------------------------- /lib/std/blat.myr: -------------------------------------------------------------------------------- 1 | use "syswrap" 2 | use "result" 3 | 4 | pkg std = 5 | const blat : (path : byte[:], buf : byte[:], perm : int64 -> bool) 6 | const fblat : (f : fd, buf : byte[:] -> bool) 7 | ;; 8 | 9 | const blat = {path, buf, perm 10 | match openmode(path, Ocreat|Owrite, perm) 11 | | `Ok fd: 12 | var r = fblat(fd, buf) 13 | close(fd) 14 | -> r 15 | | `Err e: 16 | -> false 17 | ;; 18 | } 19 | 20 | 21 | const fblat = {fd, buf 22 | var count 23 | 24 | count = 0 25 | while true 26 | match write(fd, buf[count:]) 27 | | `Err e: -> false 28 | | `Ok n: 29 | if n == 0 30 | break 31 | ;; 32 | count += n 33 | ;; 34 | ;; 35 | -> count == buf.len 36 | } 37 | -------------------------------------------------------------------------------- /lib/std/chomp.myr: -------------------------------------------------------------------------------- 1 | use "hasprefix" 2 | 3 | pkg std = 4 | const chomp : (str : byte[:]#, pfx : byte[:] -> bool) 5 | ;; 6 | 7 | const chomp = {str, pfx 8 | if std.hasprefix(str#, pfx) 9 | str# = str#[pfx.len:] 10 | -> true 11 | else 12 | -> false 13 | ;; 14 | } 15 | -------------------------------------------------------------------------------- /lib/std/clear.myr: -------------------------------------------------------------------------------- 1 | use "memops" 2 | 3 | pkg std = 4 | generic clear : (p : @a# -> void) 5 | ;; 6 | 7 | generic clear = {p : @a# 8 | memfill((p : byte#), 0, sizeof(@a)) 9 | } 10 | 11 | -------------------------------------------------------------------------------- /lib/std/consts.myr: -------------------------------------------------------------------------------- 1 | use "syswrap" 2 | 3 | pkg std = 4 | const In : fd = 0 5 | const Out : fd = 1 6 | const Err : fd = 2 7 | ;; 8 | -------------------------------------------------------------------------------- /lib/std/cstrconv.myr: -------------------------------------------------------------------------------- 1 | use "types" 2 | 3 | pkg std = 4 | const cstrlen : (buf : byte[:] -> size) 5 | const cstrconv : (buf : byte[:] -> byte[:]) 6 | const cstrconvp : (p : byte# -> byte[:]) 7 | ;; 8 | 9 | const cstrconv = {buf 10 | for var i = 0; i < buf.len; i++ 11 | if buf[i] == 0 12 | -> buf[:i] 13 | ;; 14 | ;; 15 | -> buf 16 | } 17 | 18 | const cstrconvp = {p 19 | var len 20 | 21 | len = 1 22 | while p[:len][len -1] != 0 23 | len++ 24 | ;; 25 | -> p[:len-1] 26 | } 27 | 28 | const cstrlen = {buf 29 | for var i = 0; i < buf.len; i++ 30 | if buf[i] == 0 31 | -> i 32 | ;; 33 | ;; 34 | -> 0 35 | } 36 | -------------------------------------------------------------------------------- /lib/std/die.myr: -------------------------------------------------------------------------------- 1 | use "syswrap" 2 | use "types" 3 | 4 | pkg std = 5 | $noret const die : (msg : byte[:] -> void) 6 | pkglocal const iassert : (cond : bool, msg : byte[:] -> void) 7 | ;; 8 | 9 | const die = {msg 10 | write(2, msg) 11 | suicide() 12 | } 13 | 14 | const iassert = {cond, msg 15 | if !cond 16 | die(msg) 17 | ;; 18 | } 19 | -------------------------------------------------------------------------------- /lib/std/diriter.myr: -------------------------------------------------------------------------------- 1 | use "alloc" 2 | use "dir" 3 | use "option" 4 | 5 | pkg std = 6 | type diriter = dir# 7 | impl iterable diriter -> byte[:] 8 | 9 | const byentry : (d : dir# -> diriter) 10 | ;; 11 | 12 | const byentry = {d 13 | -> (d : diriter) 14 | } 15 | 16 | impl iterable diriter -> byte[:] = 17 | __iternext__ = {itp, valp 18 | :nextfile 19 | match dirread((itp# : dir#)) 20 | | `Some ".": goto nextfile 21 | | `Some "..": goto nextfile 22 | | `Some ent: 23 | valp# = ent 24 | -> true 25 | | `None: 26 | -> false 27 | ;; 28 | } 29 | 30 | __iterfin__ = {itp, valp 31 | std.slfree(valp#) 32 | } 33 | ;; 34 | 35 | 36 | -------------------------------------------------------------------------------- /lib/std/errno+plan9.myr: -------------------------------------------------------------------------------- 1 | pkg std = 2 | type errno = int 3 | const Enone : errno = 0 4 | const Erange : errno = 1 5 | const Ebadf : errno = 2 6 | const Eexist : errno = 3 7 | const Einval : errno = 4 8 | const Efault : errno = 5 9 | const Eio : errno = 6 10 | const Emisc : errno = 40 11 | ;; 12 | -------------------------------------------------------------------------------- /lib/std/extremum.myr: -------------------------------------------------------------------------------- 1 | pkg std = 2 | generic min : (a : @a, b : @a -> @a) :: numeric @a 3 | generic max : (a : @a, b : @a -> @a) :: numeric @a 4 | generic clamp : (a : @a, min : @a, max : @a -> @a) :: numeric @a 5 | generic abs : (a : @a -> @a) :: numeric @a 6 | ;; 7 | 8 | generic min = {a, b 9 | if a < b 10 | -> a 11 | else 12 | -> b 13 | ;; 14 | } 15 | 16 | generic max = {a, b 17 | if a > b 18 | -> a 19 | else 20 | -> b 21 | ;; 22 | } 23 | 24 | generic clamp = {a, min, max 25 | if a < min 26 | -> min 27 | elif a > max 28 | -> max 29 | else 30 | -> a 31 | ;; 32 | } 33 | 34 | generic abs = {a 35 | if a < (0 : @a) 36 | -> -a 37 | else 38 | -> a 39 | ;; 40 | } 41 | -------------------------------------------------------------------------------- /lib/std/getbp+plan9-x64.s: -------------------------------------------------------------------------------- 1 | TEXT std$getbp+0(SB),$0 2 | MOVQ BP,AX 3 | RET 4 | -------------------------------------------------------------------------------- /lib/std/getbp+posixy-x64.s: -------------------------------------------------------------------------------- 1 | .globl std$getbp 2 | .globl _std$getbp 3 | std$getbp: 4 | _std$getbp: 5 | movq %rbp,%rax 6 | ret 7 | -------------------------------------------------------------------------------- /lib/std/getcwd.myr: -------------------------------------------------------------------------------- 1 | use "alloc" 2 | use "errno" 3 | use "extremum" 4 | use "syswrap" 5 | use "syswrap-ss" 6 | 7 | pkg std = 8 | const getcwd : (-> byte[:]) 9 | ;; 10 | 11 | const getcwd = { 12 | var len, n, buf 13 | 14 | len = 128 15 | while true 16 | buf = std.slalloc(len) 17 | n = bgetcwd(buf) 18 | if n >= 0 19 | /* n is the length of the nul terminated c string */ 20 | -> buf[:n] 21 | elif n != Erange 22 | std.slfree(buf) 23 | -> "" 24 | else 25 | len *= 2 26 | ;; 27 | ;; 28 | /* unreachable; shut up return without value analysis */ 29 | -> "" 30 | } 31 | 32 | -------------------------------------------------------------------------------- /lib/std/hasprefix.myr: -------------------------------------------------------------------------------- 1 | use "cmp" 2 | 3 | pkg std = 4 | const hasprefix : (s : byte[:], pre : byte[:] -> bool) 5 | ;; 6 | 7 | const hasprefix = {s, pre 8 | match strncmp(s, pre, pre.len) 9 | | `Equal: -> true 10 | | _: -> false 11 | ;; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /lib/std/hassuffix.myr: -------------------------------------------------------------------------------- 1 | use "traits" 2 | use "sleq" 3 | 4 | pkg std = 5 | const hassuffix : (s : byte[:], suff : byte[:] -> bool) 6 | ;; 7 | 8 | const hassuffix = {s, suff 9 | var tail 10 | 11 | if suff.len <= s.len 12 | tail = s[s.len - suff.len:] 13 | -> eq(tail, suff) 14 | ;; 15 | -> false 16 | } 17 | 18 | -------------------------------------------------------------------------------- /lib/std/memops.myr: -------------------------------------------------------------------------------- 1 | use "types" 2 | 3 | pkg std = 4 | extern const memblit : (dst : byte#, src : byte#, len : std.size -> void) 5 | extern const memfill : (dst : byte#, val : byte, len : std.size -> void) 6 | extern const memeq : (a : byte#, b : byte#, len : std.size -> bool) 7 | ;; 8 | 9 | -------------------------------------------------------------------------------- /lib/std/mk.myr: -------------------------------------------------------------------------------- 1 | use "alloc" 2 | 3 | pkg std = 4 | generic mk : (val : @a -> @a#) 5 | ;; 6 | 7 | /* Takes a value, and heapifies it. 8 | 9 | FIXME: This depends on inlining and copy propagation 10 | in order to be efficient. Neither of those are 11 | currently implemented. That means that this function 12 | is not efficient. 13 | 14 | It's still damn convenient, though, so it's in. 15 | */ 16 | generic mk = {val 17 | var p 18 | 19 | p = alloc() 20 | p# = val 21 | -> p 22 | } 23 | -------------------------------------------------------------------------------- /lib/std/mkpath.myr: -------------------------------------------------------------------------------- 1 | use "syswrap" 2 | use "errno" 3 | 4 | pkg std = 5 | const mkpath : (p : byte[:] -> errno) 6 | ;; 7 | 8 | const mkpath = {p 9 | var st 10 | 11 | for var i = 0; i < p.len; i++ 12 | if p[i] == ('/' : byte) && i != 0 13 | if !fexists(p[:i]) 14 | st = mkdir(p[:i], 0o755) 15 | if st != 0 16 | -> st 17 | ;; 18 | ;; 19 | ;; 20 | ;; 21 | st = mkdir(p, 0o755) 22 | 23 | -> Enone 24 | } 25 | -------------------------------------------------------------------------------- /lib/std/now.myr: -------------------------------------------------------------------------------- 1 | use "types" 2 | use "syswrap" 3 | 4 | pkg std = 5 | const now : (-> time) 6 | ;; 7 | 8 | /* microseconds since epoch */ 9 | const now = { 10 | -> curtime() 11 | } 12 | -------------------------------------------------------------------------------- /lib/std/option.myr: -------------------------------------------------------------------------------- 1 | pkg std = 2 | type option(@a) = union 3 | `None 4 | `Some @a 5 | ;; 6 | ;; 7 | 8 | -------------------------------------------------------------------------------- /lib/std/pledge+openbsd.myr: -------------------------------------------------------------------------------- 1 | use sys 2 | use "errno" 3 | use "result" 4 | 5 | pkg std = 6 | const pledge : (promise : byte[:], epromise : byte[:] -> result(void, errno)) 7 | ;; 8 | 9 | const pledge = {promise, epromise 10 | var r 11 | 12 | r = sys.pledge(sys.cstring(promise), sys.cstring(epromise)) 13 | if r < 0 14 | -> `std.Err (r : errno) 15 | else 16 | -> `std.Ok void 17 | ;; 18 | } 19 | -------------------------------------------------------------------------------- /lib/std/pledge.myr: -------------------------------------------------------------------------------- 1 | use sys 2 | use "errno" 3 | use "result" 4 | 5 | pkg std = 6 | const pledge : (promise : byte[:], epromise : byte[:] -> result(void, errno)) 7 | ;; 8 | 9 | const pledge = {promise, epromise 10 | -> `std.Ok void 11 | } 12 | -------------------------------------------------------------------------------- /lib/std/readall.myr: -------------------------------------------------------------------------------- 1 | use "errno" 2 | use "result" 3 | use "option" 4 | use "syswrap" 5 | use "types" 6 | 7 | pkg std = 8 | const readall : (fd : fd, dst : byte[:] -> result(size, errno)) 9 | ;; 10 | 11 | const readall = {fd, dst 12 | var sz 13 | 14 | sz = dst.len 15 | while dst.len != 0 16 | match std.read(fd, dst) 17 | | `Ok 0: 18 | break 19 | | `Ok n: 20 | dst = dst[n:] 21 | | `Err e: 22 | -> `Err e 23 | ;; 24 | ;; 25 | -> `Ok (sz - dst.len) 26 | } 27 | -------------------------------------------------------------------------------- /lib/std/resolve+plan9.myr: -------------------------------------------------------------------------------- 1 | pkg std = 2 | ;; 3 | -------------------------------------------------------------------------------- /lib/std/result.myr: -------------------------------------------------------------------------------- 1 | pkg std = 2 | type result(@a, @b) = union 3 | `Ok @a 4 | `Err @b 5 | ;; 6 | ;; 7 | 8 | -------------------------------------------------------------------------------- /lib/std/sjlj+x64.myr: -------------------------------------------------------------------------------- 1 | pkg std = 2 | type jmpbuf = struct 3 | regs : uint64[9] 4 | ;; 5 | 6 | extern const setjmp : (jb : jmpbuf# -> bool) 7 | extern const longjmp : (jb : jmpbuf# -> void) 8 | ;; 9 | -------------------------------------------------------------------------------- /lib/std/slcp.myr: -------------------------------------------------------------------------------- 1 | use "die" 2 | use "types" 3 | use "memops" 4 | 5 | pkg std = 6 | generic slcp : (a : @a[:], b : @a[:] -> void) 7 | ;; 8 | 9 | generic slcp = {a : @a[:], b : @a[:] 10 | iassert(a.len == b.len, "arguments to slcp() must be of equal length\n") 11 | memblit((a : byte#), (b : byte#), a.len * sizeof(@a)) 12 | } 13 | -------------------------------------------------------------------------------- /lib/std/sldup.myr: -------------------------------------------------------------------------------- 1 | use "alloc" 2 | use "die" 3 | use "slcp" 4 | 5 | pkg std = 6 | generic sldup : (sl : @a[:] -> @a[:]) 7 | ;; 8 | 9 | generic sldup = {sl 10 | var ret 11 | 12 | ret = slalloc(sl.len) 13 | slcp(ret, sl) 14 | -> ret 15 | } 16 | -------------------------------------------------------------------------------- /lib/std/sleep.myr: -------------------------------------------------------------------------------- 1 | use "syswrap-ss" 2 | use "types" 3 | 4 | pkg std = 5 | const usleep : (tm : time -> void) 6 | ;; 7 | 8 | const usleep = {tm 9 | nanosleep((tm * 1000 : uint64)) 10 | } 11 | 12 | -------------------------------------------------------------------------------- /lib/std/slfill.myr: -------------------------------------------------------------------------------- 1 | pkg std = 2 | generic slfill : (sl : @a[:], v : @a -> @a[:]) 3 | ;; 4 | 5 | generic slfill = {sl, v 6 | for var i = 0; i < sl.len; i++ 7 | sl[i] = v 8 | ;; 9 | -> sl 10 | } 11 | -------------------------------------------------------------------------------- /lib/std/sljoin.myr: -------------------------------------------------------------------------------- 1 | use "alloc" 2 | use "slcp" 3 | 4 | pkg std = 5 | generic sljoin : (dst : @a[:]#, src : @a[:] -> @a[:]) 6 | ;; 7 | 8 | generic sljoin = {dst, src 9 | var len 10 | 11 | len = dst#.len 12 | slgrow(dst, len + src.len) 13 | slcp(dst#[len:], src) 14 | -> dst# 15 | } 16 | -------------------------------------------------------------------------------- /lib/std/slpop.myr: -------------------------------------------------------------------------------- 1 | use "types" 2 | use "alloc" 3 | 4 | pkg std = 5 | generic slpop : (sl : @a[:]# -> @a) 6 | ;; 7 | 8 | generic slpop = {sl 9 | var elt 10 | 11 | elt = sl#[sl#.len - 1] 12 | slgrow(sl, sl#.len - 1) 13 | -> elt 14 | } 15 | -------------------------------------------------------------------------------- /lib/std/slpush.myr: -------------------------------------------------------------------------------- 1 | use "types" 2 | use "alloc" 3 | 4 | pkg std = 5 | generic slpush : (sl : @a[:]#, elt : @a -> @a[:]) 6 | ;; 7 | 8 | generic slpush = {sl, elt 9 | /* 10 | slpush relies on implementation details 11 | of slgrow for efficiency. Because bucket 12 | sizes come in powers of two for all buckets 13 | <= 32k, and by powers of 1.5 for larger 14 | slices, this is effectively growing the 15 | slice by powers of two. 16 | */ 17 | slgrow(sl, sl#.len + 1) 18 | sl#[sl#.len - 1] = elt 19 | -> sl# 20 | } 21 | -------------------------------------------------------------------------------- /lib/std/slput.myr: -------------------------------------------------------------------------------- 1 | use "types" 2 | use "alloc" 3 | use "die" 4 | 5 | pkg std = 6 | generic slput : (sl : @a[:]#, idx : size, elt : @a -> @a[:]) 7 | generic sldel : (sl : @a[:]#, idx : size -> @a[:]) 8 | ;; 9 | 10 | generic slput = {sl, idx, elt 11 | var i 12 | var len 13 | 14 | len = sl#.len 15 | slgrow(sl, sl#.len + 1) 16 | for i = len - 1; i >= idx; i-- 17 | sl#[i + 1] = sl#[i] 18 | ;; 19 | sl#[idx] = elt 20 | -> sl# 21 | } 22 | 23 | generic sldel = {sl, idx 24 | for var i = idx; i < sl#.len - 1; i++ 25 | sl#[i] = sl#[i + 1] 26 | ;; 27 | sl# = sl#[:sl#.len - 1] 28 | -> sl# 29 | } 30 | -------------------------------------------------------------------------------- /lib/std/strreplace.myr: -------------------------------------------------------------------------------- 1 | use "alloc" 2 | use "die" 3 | use "slcp" 4 | use "strfind" 5 | use "sljoin" 6 | use "types" 7 | use "option" 8 | 9 | pkg std = 10 | const strreplace : (haystack : byte[:], needle : byte[:], repl : byte[:] -> byte[:]) 11 | ;; 12 | 13 | const strreplace = {haystack, needle, repl 14 | var ret 15 | 16 | iassert(needle.len > 0, "missing needle") 17 | ret = "" 18 | while true 19 | match std.strfind(haystack, needle) 20 | | `None: break 21 | | `Some idx: 22 | std.sljoin(&ret, haystack[:idx]) 23 | std.sljoin(&ret, repl) 24 | haystack = haystack[idx + needle.len:] 25 | ;; 26 | ;; 27 | std.sljoin(&ret, haystack) 28 | -> ret 29 | } 30 | 31 | -------------------------------------------------------------------------------- /lib/std/swap.myr: -------------------------------------------------------------------------------- 1 | pkg std = 2 | generic swap : (a : @a#, b : @a# -> void) 3 | ;; 4 | 5 | generic swap = {a : @a#, b : @a# 6 | var t 7 | 8 | t = a# 9 | a# = b# 10 | b# = t 11 | } 12 | -------------------------------------------------------------------------------- /lib/std/syswrap-ss+netbsd.myr: -------------------------------------------------------------------------------- 1 | use sys 2 | use "types" 3 | use "errno" 4 | use "cstrconv" 5 | use "slcp" 6 | use "die" 7 | 8 | pkg std = 9 | const nanosleep : (nsecs : uint64 -> errno) 10 | $noret const exit : (status:int -> void) 11 | 12 | pkglocal const bgetcwd : (buf : byte[:] -> errno) 13 | ;; 14 | 15 | const exit = {status; sys.exit(status)} 16 | 17 | const bgetcwd = {buf 18 | -> (sys.__getcwd(buf) - 1 : errno) 19 | } 20 | 21 | const nanosleep = {nsecs 22 | var req, rem 23 | var s, ns 24 | 25 | s = (nsecs / 1_000_000_000 : int64) 26 | ns = (nsecs % 1_000_000_000 : int64) 27 | req = [.sec = s, .nsec = ns] 28 | 29 | -> (sys.nanosleep(&req, &rem) : errno) 30 | } 31 | 32 | -------------------------------------------------------------------------------- /lib/std/test/chomp.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | check("aaab", "aaa", "b") 5 | check("aaa", "aaa", "") 6 | check("aa", "aaa", "aa") 7 | } 8 | 9 | const check = {sl, pfx, expected 10 | var r 11 | 12 | r = sl 13 | std.chomp(&r, pfx) 14 | std.assert(std.eq(r, expected), \ 15 | "expected chomp({}, {}) => {}, got {}\n", sl, pfx, expected, r) 16 | } 17 | -------------------------------------------------------------------------------- /lib/std/test/dirname.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | eq(std.dirname("foo/bar"), "foo") 5 | eq(std.dirname("/foo/bar"), "/foo") 6 | eq(std.dirname("/foo/bar/"), "/foo") 7 | eq(std.dirname("/bar/"), "/") 8 | eq(std.dirname("/"), "/") 9 | eq(std.dirname("///"), "/") 10 | 11 | eq(std.basename("foo/bar"), "bar") 12 | eq(std.basename("/foo/bar"), "bar") 13 | eq(std.basename("/foo/bar/"), "bar") 14 | eq(std.basename("/bar/"), "bar") 15 | eq(std.basename("/"), "") 16 | eq(std.basename("///"), "") 17 | } 18 | 19 | const eq = {a, e 20 | if !std.eq(e, a) 21 | std.fatal("expected '{}', got '{}'\n", e, a) 22 | ;; 23 | } 24 | -------------------------------------------------------------------------------- /lib/std/test/sjlj.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | var st 4 | 5 | const main = { 6 | var jb 7 | 8 | st = 1 9 | if std.setjmp(&jb) 10 | std.put("nonlocal return\n") 11 | std.exit(st) 12 | ;; 13 | st = 0 14 | std.put("doing jmp\n") 15 | dolongjmp(&jb) 16 | std.fatal("unreachable\n") 17 | } 18 | 19 | const dolongjmp = {jb 20 | std.longjmp(jb) 21 | } 22 | -------------------------------------------------------------------------------- /lib/std/test/try.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | var x = `std.Some 123 5 | var r : std.result(int, byte[:]) = `std.Ok 666 6 | std.assert(std.get(x) == 123, "expected 123 from try") 7 | std.assert(std.try(r) == 666, "expected 123 from try") 8 | } 9 | -------------------------------------------------------------------------------- /lib/std/traits.myr: -------------------------------------------------------------------------------- 1 | pkg std = 2 | trait equatable @a = 3 | eq : (a : @a, b : @a -> bool) 4 | ;; 5 | 6 | trait hashable @a = 7 | hash : (a : @a -> uint64) 8 | ;; 9 | ;; 10 | -------------------------------------------------------------------------------- /lib/std/types.myr: -------------------------------------------------------------------------------- 1 | use sys 2 | 3 | pkg std = 4 | type size = sys.size /* spans entire address space */ 5 | type usize = sys.usize /* unsigned size */ 6 | type off = sys.off /* file offsets */ 7 | type intptr = sys.intptr /* can hold any pointer losslessly */ 8 | type time = sys.time /* milliseconds since epoch */ 9 | ;; 10 | -------------------------------------------------------------------------------- /lib/std/units.myr: -------------------------------------------------------------------------------- 1 | use "types" 2 | 3 | pkg std = 4 | /* JEDEC 100B.1 memory sizes */ 5 | generic KiB : @a = 1024 :: integral,numeric @a 6 | generic MiB : @a = KiB*1024 :: integral,numeric @a 7 | generic GiB : @a = MiB*1024 :: integral,numeric @a 8 | generic TiB : @a = GiB*1024 :: integral,numeric @a 9 | generic PiB : @a = TiB*1024 :: integral,numeric @a 10 | generic EiB : @a = PiB*1024 :: integral,numeric @a 11 | generic ZiB : @a = EiB*1024 :: integral,numeric @a 12 | generic YiB : @a = ZiB*1024 :: integral,numeric @a 13 | 14 | generic Sec : time = 1_000_000 15 | generic Msec : time = 1_000 16 | generic Usec : time = 1 17 | ;; 18 | -------------------------------------------------------------------------------- /lib/std/writeall.myr: -------------------------------------------------------------------------------- 1 | use "errno" 2 | use "result" 3 | use "option" 4 | use "syswrap" 5 | use "types" 6 | 7 | pkg std = 8 | const writeall : (fd : fd, src : byte[:] -> std.result(size, (size, errno))) 9 | ;; 10 | 11 | const writeall = {fd, src 12 | var sz 13 | 14 | sz = src.len 15 | while src.len != 0 16 | match std.write(fd, src) 17 | | `Err e: -> `std.Err (sz, e) 18 | | `Ok 0: -> `std.Err (sz, 0) 19 | | `Ok n: src = src[n:] 20 | ;; 21 | ;; 22 | -> `std.Ok sz 23 | } 24 | -------------------------------------------------------------------------------- /lib/sys/ifreq+freebsd.myr: -------------------------------------------------------------------------------- 1 | pkg sys = 2 | ;; 3 | -------------------------------------------------------------------------------- /lib/sys/ifreq+netbsd.myr: -------------------------------------------------------------------------------- 1 | pkg sys = 2 | ;; 3 | -------------------------------------------------------------------------------- /lib/sys/ifreq+openbsd.myr: -------------------------------------------------------------------------------- 1 | pkg sys = 2 | ;; 3 | -------------------------------------------------------------------------------- /lib/sys/ifreq+plan9.myr: -------------------------------------------------------------------------------- 1 | pkg sys = 2 | ;; 3 | -------------------------------------------------------------------------------- /lib/sys/systypes.myr: -------------------------------------------------------------------------------- 1 | pkg sys = 2 | type size = int64 /* spans entire address space */ 3 | type usize = uint64 /* unsigned size */ 4 | type off = int64 /* file offsets */ 5 | type intptr = uint64/* can hold any pointer losslessly */ 6 | type time = int64 /* milliseconds since epoch */ 7 | ;; 8 | -------------------------------------------------------------------------------- /lib/testr/bld.sub: -------------------------------------------------------------------------------- 1 | lib testr = 2 | testr.myr 3 | 4 | lib ../sys:sys 5 | lib ../std:std 6 | ;; 7 | -------------------------------------------------------------------------------- /lib/thread/common.myr: -------------------------------------------------------------------------------- 1 | pkg thread = 2 | pkglocal generic Zptr : @a# = (0 : @a#) 3 | ;; 4 | -------------------------------------------------------------------------------- /lib/thread/do.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | use "future" 4 | use "spawn" 5 | 6 | pkg thread = 7 | generic do : (fn : (-> @a) -> future(@a)#) 8 | ;; 9 | 10 | generic do = {fn 11 | var r 12 | 13 | r = mkfut() 14 | spawn({; futput(r, fn()) }) 15 | -> r 16 | } 17 | 18 | -------------------------------------------------------------------------------- /lib/thread/exit+freebsd-x64.s: -------------------------------------------------------------------------------- 1 | /* 2 | const thread.exit : (stacksz : std.size -> void) 3 | */ 4 | .globl thread$exit 5 | thread$exit: 6 | /* munmap(base, size) */ 7 | movq $73,%rax /* munmap */ 8 | movq %fs:0x08,%rdi /* base */ 9 | movq %fs:0x10,%rsi /* stksz */ 10 | syscall 11 | 12 | /* thr_exit(null) */ 13 | movq $431,%rax /* exit */ 14 | xorq %rdi,%rdi /* 0 */ 15 | syscall 16 | 17 | -------------------------------------------------------------------------------- /lib/thread/exit+linux-x64.s: -------------------------------------------------------------------------------- 1 | /* 2 | const thread.exit : (-> void) 3 | */ 4 | .globl thread$exit 5 | thread$exit: 6 | /* munmap(base, size) */ 7 | movq $11,%rax /* munmap */ 8 | movq %fs:0x08,%rdi /* base */ 9 | movq %fs:0x10,%rsi /* stksz */ 10 | syscall 11 | 12 | /* thread_exit(0) */ 13 | movq $60,%rax /* exit */ 14 | xorq %rdi,%rdi /* 0 */ 15 | syscall 16 | 17 | -------------------------------------------------------------------------------- /lib/thread/exit+openbsd-x64.s: -------------------------------------------------------------------------------- 1 | /* 2 | const thread.exit : (stacksz : std.size -> void) 3 | */ 4 | .globl thread$exit 5 | thread$exit: 6 | /* 7 | Because OpenBSD wants a valid stack whenever 8 | we enter the kernel, we need to toss a preallocated 9 | stack pointer into %rsp. 10 | */ 11 | movq thread$exitstk,%rsp 12 | 13 | /* munmap(base, size) */ 14 | movq $73,%rax /* munmap */ 15 | movq %fs:0x08,%rdi /* base */ 16 | movq %fs:0x10,%rsi /* stksz */ 17 | syscall 18 | 19 | /* __threxit(0) */ 20 | movq $302,%rax /* exit */ 21 | xorq %rdi,%rdi /* 0 */ 22 | syscall 23 | 24 | -------------------------------------------------------------------------------- /lib/thread/fsbase+freebsd.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use sys 3 | 4 | use "types" 5 | 6 | pkg thread = 7 | pkglocal const setfsbase : (h : tlshdr# -> void) 8 | pkglocal const getfsbase : (-> tlshdr#) 9 | ;; 10 | 11 | const setfsbase = {h 12 | match sys.sysarch(sys.Archamd64setfs, &(h : void#)) 13 | | 0: 14 | | err: 15 | std.fput(std.Err, "error: sysarch returned {}\n", err) 16 | std.suicide() 17 | ;; 18 | } 19 | 20 | const getfsbase = { 21 | var h 22 | match sys.sysarch(sys.Archamd64getfs, &h) 23 | | 0: -> (h : tlshdr#) 24 | | err: 25 | std.fput(std.Err, "error: sysarch returned {}\n", err) 26 | std.suicide() 27 | ;; 28 | } 29 | -------------------------------------------------------------------------------- /lib/thread/fsbase+linux.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use sys 3 | 4 | use "types" 5 | 6 | pkg thread = 7 | pkglocal const setfsbase : (h : tlshdr# -> void) 8 | pkglocal const getfsbase : (-> tlshdr#) 9 | ;; 10 | 11 | const setfsbase = {h 12 | match sys.arch_prctl(sys.Archsetfs, (h : void#)) 13 | | 0: 14 | | err: 15 | std.fput(std.Err, "error: arch_prctl returned {}\n", err) 16 | std.suicide() 17 | ;; 18 | } 19 | 20 | const getfsbase = { 21 | var h : tlshdr# 22 | match sys.arch_prctl(sys.Archgetfs, (&h : void#)) 23 | | 0: -> h 24 | | err: 25 | std.fput(std.Err, "error: arch_prctl returned {}\n", err) 26 | std.suicide() 27 | ;; 28 | } 29 | -------------------------------------------------------------------------------- /lib/thread/fsbase+netbsd.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use sys 3 | 4 | use "types" 5 | 6 | pkg thread = 7 | pkglocal const setfsbase : (h : tlshdr# -> void) 8 | pkglocal const getfsbase : (-> tlshdr#) 9 | ;; 10 | 11 | const setfsbase = {h 12 | match sys.sysarch(sys.X8664setfsbase, &(h : void#)) 13 | | 0: 14 | | err: 15 | std.fput(std.Err, "error: sysarch returned: {}\n", err) 16 | std.suicide() 17 | ;; 18 | } 19 | 20 | const getfsbase = { 21 | var h 22 | match sys.sysarch(sys.X8664getfsbase, &h) 23 | | 0: -> (h : tlshdr#) 24 | | err: 25 | std.fput(std.Err, "error: sysarch returned: {}\n", err) 26 | std.suicide() 27 | ;; 28 | } 29 | -------------------------------------------------------------------------------- /lib/thread/fsbase+openbsd.myr: -------------------------------------------------------------------------------- 1 | use sys 2 | 3 | use "types" 4 | 5 | pkg thread = 6 | pkglocal const setfsbase : (h : tlshdr# -> void) 7 | pkglocal const getfsbase : (-> tlshdr#) 8 | ;; 9 | 10 | const setfsbase = {h 11 | sys.__set_tcb((h : void#)) 12 | } 13 | 14 | const getfsbase = { 15 | -> (sys.__get_tcb() : tlshdr#) 16 | } 17 | -------------------------------------------------------------------------------- /lib/thread/future.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | use "sem" 4 | 5 | pkg thread = 6 | type future(@a) = struct 7 | sem : sem 8 | val : @a 9 | ;; 10 | 11 | generic mkfut : (-> future(@a)#) 12 | generic futput : (fut : future(@a)#, val : @a -> void) 13 | generic futget : (fut : future(@a)# -> @a) 14 | ;; 15 | 16 | generic mkfut = { 17 | -> std.mk([.sem = mksem(0)]) 18 | } 19 | 20 | generic futput = {fut, val 21 | fut.val = val 22 | sempost(&fut.sem) 23 | } 24 | 25 | generic futget = {fut 26 | var val 27 | 28 | semwait(&fut.sem) 29 | val = fut.val 30 | std.free(fut) 31 | -> val 32 | } 33 | 34 | -------------------------------------------------------------------------------- /lib/thread/hookstd.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use sys 3 | use "mutex" 4 | use "tls" 5 | 6 | pkg thread = 7 | ;; 8 | 9 | var memlck 10 | var netlck 11 | var envlck 12 | var stdtls 13 | 14 | const __init__ = { 15 | memlck = mkmtx() 16 | netlck = mkmtx() 17 | envlck = mkmtx() 18 | stdtls = tlsalloc() 19 | std.__lockinit( \ 20 | (&memlck : void#), \ 21 | (&netlck : void#), \ 22 | (&envlck : void#), \ 23 | {mtx; mtxlock((mtx : mutex#))}, \ 24 | {mtx; mtxunlock((mtx : mutex#))}, \ 25 | {; -> tlsget(stdtls)}, \ 26 | {val; tlsset(stdtls, val)} \ 27 | ) 28 | } 29 | 30 | -------------------------------------------------------------------------------- /lib/thread/ncpu+freebsd.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use sys 3 | 4 | pkg thread = 5 | const ncpu : (-> int) 6 | ;; 7 | 8 | const ncpu = { 9 | var mib : int[2] 10 | var ncpu : int 11 | var ncpusz 12 | var res 13 | 14 | mib[0] = 6 /* CTL_HW */ 15 | mib[1] = 3 /* HW_NCPU */ 16 | ncpusz = sizeof(int) 17 | 18 | res = sys.sysctl(mib[:], (&ncpu : void#), &ncpusz, (0 : void#), (0 : sys.size#)) 19 | if res < 0 || ncpu <= 0 20 | -> 1 21 | ;; 22 | -> ncpu 23 | } 24 | -------------------------------------------------------------------------------- /lib/thread/ncpu+linux.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use sys 3 | 4 | pkg thread = 5 | const ncpu : (-> int) 6 | ;; 7 | 8 | const ncpu = { 9 | var cpubuf : uint64[4] 10 | var n 11 | 12 | sys.sched_getaffinity(sys.getpid(), sizeof(uint64[4]), (&cpubuf : uint64#)) 13 | n = 0 14 | for b : cpubuf[:] 15 | if b != 0 16 | n += count(b) 17 | ;; 18 | ;; 19 | -> n 20 | } 21 | 22 | const count = {b 23 | var n = 0 24 | for var i = 0; i < 8*sizeof(uint64); i++ 25 | if b & (1< n 30 | } 31 | -------------------------------------------------------------------------------- /lib/thread/ncpu+openbsd.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use sys 3 | 4 | pkg thread = 5 | const ncpu : (-> int) 6 | ;; 7 | 8 | const ncpu = { 9 | var mib : int[2] 10 | var ncpu : int 11 | var ncpusz 12 | var res 13 | 14 | mib[0] = 6 /* CTL_HW */ 15 | mib[1] = 3 /* HW_NCPU */ 16 | ncpusz = sizeof(int) 17 | 18 | res = sys.sysctl(mib[:], (&ncpu : void#), &ncpusz, (0 : void#), (0 : sys.size#)) 19 | if res < 0 || ncpu <= 0 20 | -> 1 21 | ;; 22 | -> ncpu 23 | } 24 | -------------------------------------------------------------------------------- /lib/thread/ncpu+plan9.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg thread = 4 | const ncpu : (-> int) 5 | ;; 6 | 7 | const ncpu = { 8 | match std.intparse(std.getenvv("NPROC", "1")) 9 | | `std.Some n: -> n 10 | | `std.None: -> 1 11 | ;; 12 | } 13 | -------------------------------------------------------------------------------- /lib/thread/ncpu.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use sys 3 | 4 | pkg thread = 5 | const ncpu : (-> int) 6 | ;; 7 | 8 | const ncpu = { 9 | -> 1 10 | } 11 | -------------------------------------------------------------------------------- /lib/thread/spawn+netbsd.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg thread = 4 | type tid = uint64 5 | 6 | const spawn : (fn : (-> void) -> std.result(tid, byte[:])) 7 | ;; 8 | 9 | const spawn = {fn 10 | std.die("unimplemented\n") 11 | -> `std.Err "fuck" 12 | } 13 | 14 | -------------------------------------------------------------------------------- /lib/thread/test/die.myr: -------------------------------------------------------------------------------- 1 | use thread 2 | 3 | const main = { 4 | var m = thread.mkmtx() 5 | thread.mtxlock(&m) 6 | thread.mtxunlock(&m) 7 | thread.mtxunlock(&m) 8 | } 9 | -------------------------------------------------------------------------------- /lib/thread/test/future.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use sys 3 | use thread 4 | 5 | const main = { 6 | var f 7 | 8 | f = thread.mkfut() 9 | thread.futput(f, 123) 10 | std.assert(thread.futget(f) == 123, "the future is broken\n") 11 | 12 | f = thread.mkfut() 13 | thread.spawn({ 14 | std.usleep(10_000) 15 | thread.futput(f, 321) 16 | }) 17 | std.assert(thread.futget(f) == 321, "the future is broken\n") 18 | } 19 | 20 | -------------------------------------------------------------------------------- /lib/thread/test/mutex.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use thread 3 | 4 | use thrtestutil 5 | 6 | const Nherd = 20 7 | 8 | var val : uint64 = 0 9 | var mtx : thread.mutex 10 | var done 11 | 12 | const main = { 13 | mtx = thread.mkmtx() 14 | done = thread.mkwg(Nherd) 15 | 16 | thrtestutil.mkherd(Nherd, incvar) 17 | thread.wgwait(&done) 18 | if val != 1000 * (Nherd : uint64) 19 | std.fatal("mutexes are broken, got {}\n", val) 20 | ;; 21 | } 22 | 23 | const incvar = { 24 | for var i = 0; i < 1000; i++ 25 | thread.mtxlock(&mtx) 26 | val++ 27 | thread.mtxunlock(&mtx) 28 | ;; 29 | thread.wgpost(&done) 30 | } 31 | -------------------------------------------------------------------------------- /lib/thread/test/spawn.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use thread 3 | 4 | var done : int32 5 | var capture 6 | 7 | const main = { 8 | var ptr 9 | 10 | capture = 666 11 | ptr = &capture 12 | thread.spawn({ 13 | std.assert(capture==666, "wrong captured value\n") 14 | std.assert(ptr#==666, "wrong captured ptr value\n") 15 | ptr# = 333 16 | thread.xadd(&done, 1) 17 | }) 18 | 19 | while done == 0 20 | /* nothing */ 21 | ;; 22 | 23 | std.assert(capture == 333, "capture wasn't written to correctly\n") 24 | std.usleep(100_000) 25 | } 26 | 27 | -------------------------------------------------------------------------------- /lib/thread/test/waitgrp.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use thread 3 | 4 | const Threadc = 8 5 | 6 | var wg 7 | 8 | const main = { 9 | wg = thread.mkwg(Threadc) 10 | 11 | for var i = 0; i < Threadc; i++ 12 | thread.spawn({ 13 | std.usleep(3_000_000) 14 | thread.wgpost(&wg) 15 | thread.wgwait(&wg) 16 | }) 17 | ;; 18 | thread.wgwait(&wg) 19 | } 20 | -------------------------------------------------------------------------------- /lib/thread/types+fsbase.myr: -------------------------------------------------------------------------------- 1 | use sys 2 | 3 | pkg thread = 4 | type tid = sys.pid /* 32 bits on all of the fsbase platforms */ 5 | type tlskey(@a) = uint32 6 | 7 | /* 8 | XXX: Be sure to update tls-impl+fsbase.s and 9 | rt/start-{freebsd,linux,netbsd,openbsd}.s if any changes are made to 10 | the size of this struct and/or the offsets of any of its members. 11 | */ 12 | pkglocal type tlshdr = struct 13 | tid : tid 14 | len : tlskey(void) 15 | base : byte# 16 | stksz : sys.size 17 | slots : void#[...] 18 | ;; 19 | ;; 20 | -------------------------------------------------------------------------------- /lib/thread/types+osx.myr: -------------------------------------------------------------------------------- 1 | use sys 2 | 3 | pkg thread = 4 | type tid = sys.pid /* 64 bits */ 5 | type tlskey(@a) = uint64 6 | 7 | /* 8 | XXX: Be sure to update tls-impl+osx.s and rt/start-osx.s if any changes 9 | are made to the size of this struct and/or the offsets of any of its 10 | members. 11 | */ 12 | pkglocal type tlshdr = struct 13 | tid : tid 14 | len : tlskey(void) 15 | base : byte# 16 | stksz : sys.size 17 | self : tlshdr# 18 | slots : void#[...] 19 | ;; 20 | ;; 21 | -------------------------------------------------------------------------------- /lib/thread/types+plan9.myr: -------------------------------------------------------------------------------- 1 | use sys 2 | 3 | pkg thread = 4 | type tid = uint64 5 | type tlskey(@a) = uint32 6 | ;; 7 | -------------------------------------------------------------------------------- /lib/thread/util.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use thread 3 | 4 | pkg thrtestutil = 5 | const mkherd : (n : uint32, fn : (-> void) ->void) 6 | ;; 7 | 8 | const mkherd = {n, fn 9 | for var i = 0; i < n; i++ 10 | std.try(thread.spawn(fn)) 11 | ;; 12 | } 13 | -------------------------------------------------------------------------------- /lib/thread/waitgrp+futex.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | use "atomic" 4 | use "futex" 5 | 6 | pkg thread = 7 | type waitgrp = struct 8 | _val : ftxtag 9 | ;; 10 | 11 | const mkwg : (v : uint32 -> waitgrp) 12 | const wgwait : (w : waitgrp# -> void) 13 | const wgpost : (w : waitgrp# -> void) 14 | ;; 15 | 16 | const mkwg = {v 17 | -> [._val = (v : ftxtag)] 18 | } 19 | 20 | const wgwait = {w 21 | var v = 0 22 | 23 | while (v = xget(&w._val)) != 0 24 | ftxwait(&w._val, v, -1) 25 | ;; 26 | } 27 | 28 | const wgpost = {w 29 | var v = xadd(&w._val, -1) 30 | 31 | if v == 1 32 | ftxwakeall(&w._val) 33 | -> void 34 | ;; 35 | std.assert(v > 0, "error: waitgroup underflowed\n") 36 | } 37 | -------------------------------------------------------------------------------- /mbld/bld.sub: -------------------------------------------------------------------------------- 1 | bin mbld = 2 | build.myr 3 | cpufeatures+posixy-x64.s 4 | cpufeatures+plan9-x64.s 5 | deps.myr 6 | libs.myr 7 | install.myr 8 | main.myr 9 | opts.myr 10 | parse.myr 11 | subtest.myr 12 | syssel.myr 13 | test.myr 14 | types.myr 15 | util.myr 16 | 17 | # probed (or hard coded) system config 18 | config.myr 19 | config+plan9-x64.myr 20 | 21 | # Currently, mbld doesn't add all deps transitively. 22 | # Until this gets fixed, we need to list all dependent 23 | # libraries here explicitly. 24 | lib ../lib/sys:sys 25 | lib ../lib/std:std 26 | lib ../lib/bio:bio 27 | lib ../lib/regex:regex 28 | lib ../lib/thread:thread 29 | ;; 30 | 31 | man = mbld.1;; 32 | -------------------------------------------------------------------------------- /mbld/config+plan9-x64.myr: -------------------------------------------------------------------------------- 1 | pkg config = 2 | const Env : (byte[:], byte[:])[:] = [][:] 3 | const Instroot = "/" 4 | const Sys = "Plan9" 5 | const Objsuffix = ".6" 6 | const Linkcmd = ["6l", "-l"] 7 | const Dlflags : byte[:][:] = [][:] 8 | const Arcmd = ["ar", "u"] 9 | const Ascmd = ["6a"] 10 | const Directlib = true 11 | const Runtime = "_myrrt.6" 12 | 13 | const Manpath = "sys/man/" 14 | const Binpath = "amd64/bin" 15 | const Libpath = "amd64/lib/myr" 16 | const Sharepath = "lib" 17 | const Stripman = true 18 | ;; 19 | -------------------------------------------------------------------------------- /mbld/cpufeatures+plan9-x64.s: -------------------------------------------------------------------------------- 1 | TEXT bld$cpufeatures+0(SB),$0 2 | MOVL $0x1,AX 3 | CPUID 4 | MOVL CX, AX 5 | MOVL DX, DX 6 | ROLQ $32, DX 7 | ORQ DX, AX 8 | RET 9 | -------------------------------------------------------------------------------- /mbld/cpufeatures+posixy-x64.s: -------------------------------------------------------------------------------- 1 | .globl bld$cpufeatures 2 | .globl _bld$cpufeatures 3 | bld$cpufeatures: 4 | _bld$cpufeatures: 5 | mov $0x1, %eax 6 | cpuid 7 | mov %ecx, %eax 8 | rol $32, %rax 9 | shrd $32, %rdx, %rax 10 | ret 11 | -------------------------------------------------------------------------------- /mbldwrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # this should be a bourne compatible shell script. 4 | export PATH=`pwd`:`pwd`/6:`pwd`/muse:$PATH 5 | if test `uname` = Plan9; then 6 | O=6 7 | export MYR_MUSE=`pwd`/muse/$O.out 8 | export MYR_MC=`pwd`/6/$O.out 9 | export MYR_RT=`pwd`/rt/_myrrt.$O 10 | else 11 | export MYR_MUSE=muse 12 | export MYR_MC=6m 13 | export MYR_RT=`pwd`/rt/_myrrt.o 14 | fi 15 | 16 | if [ -z "$MBLD" ]; then 17 | if [ -f obj/mbld/mbld ]; then 18 | MBLD=obj/mbld/mbld 19 | else 20 | MBLD=$(command -v mbld) 21 | fi 22 | fi 23 | 24 | if [ -z "$MBLD" ]; then 25 | echo 'could not find mbld: did you run "make bootstrap"?' 26 | else 27 | $MBLD $@ 28 | fi 29 | -------------------------------------------------------------------------------- /mi/Makefile: -------------------------------------------------------------------------------- 1 | LIB=libmi.a 2 | OBJ=\ 3 | cfg.o \ 4 | flatten.o \ 5 | dfcheck.o \ 6 | match.o \ 7 | reaching.o \ 8 | 9 | 10 | DEPS=../parse/libparse.a ../util/libutil.a 11 | 12 | include ../mk/c.mk 13 | -------------------------------------------------------------------------------- /mi/mkfile: -------------------------------------------------------------------------------- 1 | $@ 13 | 14 | %.s: %-$(SYS).s 15 | cp $< $@ 16 | 17 | install: all 18 | mkdir -p $(abspath $(DESTDIR)/$(INST_ROOT)/lib/myr) 19 | install _myrrt.o $(abspath $(DESTDIR)/$(INST_ROOT)/lib/myr) 20 | 21 | uninstall: 22 | rm -f $(abspath $(DESTDIR)/$(INST_ROOT)/lib/myr/_myrrt.o) 23 | 24 | clean: 25 | rm -f _myrrt.o _myrrt.s start.s abort.s 26 | -------------------------------------------------------------------------------- /rt/mkfile: -------------------------------------------------------------------------------- 1 | 6 | #include "001_types.h" 7 | 8 | extern t1 fn_1_myr(void); 9 | 10 | t1 11 | fn_1_c(void) 12 | { 13 | return (t1) {.field_1=(t2) {.field_1=249229305184256,.field_2=3.36328125}}; 14 | } 15 | 16 | int 17 | const check_c_to_myr_fns(void) 18 | { 19 | t1 ret_1 = fn_1_myr(); 20 | if (!(((ret_1.field_1.field_1==249229305184256) && (ret_1.field_1.field_2==3.36328125)))) { 21 | return -1; 22 | } 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /test/abi/001_in-c.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use "001_types" 3 | 4 | pkg = 5 | extern const fn_1_c : ( -> t1) 6 | extern const check_c_to_myr_fns : (-> int) 7 | ;; 8 | -------------------------------------------------------------------------------- /test/abi/001_in-myr.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use "001_types" 3 | 4 | pkg = 5 | const fn_1_myr : ( -> t1) 6 | ;; 7 | 8 | const fn_1_myr = { 9 | -> [.field_1=(249229305184256,3.36328125)] 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test/abi/001_types.h: -------------------------------------------------------------------------------- 1 | typedef struct {uint64_t field_1;double field_2;} t2; 2 | typedef struct {t2 field_1;} t1; 3 | -------------------------------------------------------------------------------- /test/abi/001_types.myr: -------------------------------------------------------------------------------- 1 | pkg = 2 | type t1 = struct 3 | field_1 : (uint64,flt64) 4 | ;; 5 | ;; 6 | -------------------------------------------------------------------------------- /test/abi/002_main.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg = 4 | type foo = struct 5 | bar : uint32 6 | ;; 7 | ;; 8 | 9 | const main = { 10 | var a : foo = [.bar = 158747960] 11 | call_me(a) 12 | 13 | /* 14 | * If argument alignment is not respected, the above will stuff 15 | * all eight bytes of %rdi into four bytes of stack, and the 16 | * overflow will clobber enough to cause a segfault. Explicitly 17 | * exiting via std.exit(0) will mask this failure, however. 18 | */ 19 | } 20 | 21 | 22 | const call_me = { a : foo 23 | -> void 24 | } 25 | -------------------------------------------------------------------------------- /test/add.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* should exit with status 53 */ 3 | const main = { 4 | var a 5 | var b 6 | var c 7 | 8 | a = 42 9 | b = 11 10 | c = 0_0 11 | std.exit(a + b + c) 12 | } 13 | -------------------------------------------------------------------------------- /test/arityhigh.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* should fail because we call f with too many args */ 3 | const f = {a:int 4 | -> a 5 | } 6 | 7 | const main = { 8 | std.exit(f(1, 2, 3)) 9 | } 10 | -------------------------------------------------------------------------------- /test/aritylow.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* should fail because we call f with too few args */ 3 | const f = {a:int, b:int, c:int 4 | -> a + b + c 5 | } 6 | 7 | const main = { 8 | std.exit(f(1, 2)) 9 | } 10 | -------------------------------------------------------------------------------- /test/array.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* tests reading and writing to arrays. should exit with 7 */ 3 | const main = { 4 | var a : int[3] 5 | a[0] = 3 6 | a[1] = 4 7 | a[2] = a[0] + a[1] 8 | std.exit(a[2]) 9 | } 10 | -------------------------------------------------------------------------------- /test/arrayaddr.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* tests taking the address of array elements. should exit with 42. */ 3 | const main = { 4 | var v : int[3] 5 | var p 6 | 7 | v[1] = 42 8 | p = &v[1] 9 | std.exit(p#) 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test/arraylen.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that array lengths work. should exit with 12. */ 3 | const main = { 4 | var a : int[12] 5 | 6 | std.exit(a.len) 7 | } 8 | -------------------------------------------------------------------------------- /test/arraylit-ni.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that we can create arrays without indexed initializers. exits with 2. */ 3 | const main = { 4 | var a = [1, 3, 2] 5 | std.exit(a[2]) 6 | } 7 | -------------------------------------------------------------------------------- /test/arraylit.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | /* checks we can make indexed array literals. exits with 3. */ 4 | const main = { 5 | var a = [ 6 | .[0] = 1, 7 | .[2] = 3, 8 | .[1] = 2, 9 | ] 10 | std.exit(a[2]) 11 | } 12 | -------------------------------------------------------------------------------- /test/arraypack.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | /* test for accidentally packed values */ 4 | const a = [ 5 | (1, "foo"), 6 | (2, "bar"), 7 | (3, "baz"), 8 | ] 9 | 10 | const main = { 11 | for x : a[:] 12 | std.put("{}", x) 13 | ;; 14 | std.put("\n") 15 | } 16 | -------------------------------------------------------------------------------- /test/arraypass.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const keq = {a, b 4 | std.put("{}\n", b[0]) 5 | } 6 | 7 | const main = {args : byte[:][:] 8 | var k : byte[5] 9 | 10 | k = [1,2,3,4,5] 11 | keq(k, k) 12 | } 13 | -------------------------------------------------------------------------------- /test/badop.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | var x 5 | x = "a" + "b" 6 | } 7 | -------------------------------------------------------------------------------- /test/basicfloat.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const get42 = { 4 | -> 42.0 5 | } 6 | 7 | /* basic sanity check on floating point operations. should return 84. */ 8 | const main = { 9 | std.exit((42.0 + get42() : int)) 10 | } 11 | -------------------------------------------------------------------------------- /test/bigliteral.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | std.put("{}\n", (34359738368 : int64)) 5 | } 6 | -------------------------------------------------------------------------------- /test/bld.sub: -------------------------------------------------------------------------------- 1 | cmd runtest {test,tag=posixy} = ./runtest.sh ;; 2 | cmd runtest {test,tag=plan9} = ./runtest.rc ;; 3 | -------------------------------------------------------------------------------- /test/bounds.myr: -------------------------------------------------------------------------------- 1 | const main = { 2 | var a : byte[:] = [1, 2, 3][:] 3 | var b = a[:4] 4 | } 5 | -------------------------------------------------------------------------------- /test/bsr.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* should exit with status 5 */ 3 | const main = { 4 | var a = 42 5 | std.exit(a >> 3) 6 | } 7 | -------------------------------------------------------------------------------- /test/call.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that simple function calls work. should exit with 42. */ 3 | const f = { 4 | -> 21 5 | } 6 | 7 | const main = { 8 | std.exit(f() + f()) 9 | } 10 | -------------------------------------------------------------------------------- /test/callbig.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that calls with large return values (ie, ones that don't fit in a 3 | * register) works correctly. Should exit with 42. */ 4 | type pair = struct 5 | a : int 6 | b : int 7 | ;; 8 | 9 | const f = {s 10 | -> s.a + s.b 11 | } 12 | 13 | const main = { 14 | var s : pair 15 | s.a = 12 16 | s.b = 30 17 | std.exit(f(s)) 18 | } 19 | -------------------------------------------------------------------------------- /test/catfile.myr: -------------------------------------------------------------------------------- 1 | /* checks that we can read a data file. */ 2 | use std 3 | 4 | const main = {args : byte[:][:] 5 | var r 6 | 7 | r = std.slurp("data/catfile-in") 8 | match r 9 | | `std.Ok dat: std.write(1, dat) 10 | | `std.Err msg: std.put("Failed to read file: {}\n", msg) 11 | ;; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /test/chartest.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | std.assert('a' == '\u{61}', "unicode char values invalid") 5 | std.assert('Σ' == '\u{03a3}', "unicode char values invalid") 6 | } 7 | -------------------------------------------------------------------------------- /test/closure.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | var a, b, c, fn 5 | 6 | a = 111 7 | b = 555 8 | c = 333 9 | fn = { 10 | var x 11 | 12 | x = 666 13 | std.put("{}{}{}{}\n", a, b, c, x) 14 | } 15 | fn() 16 | } 17 | -------------------------------------------------------------------------------- /test/closurerec.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | const fib = {n 5 | if n <= 0 6 | -> 0 7 | elif n == 1 8 | -> 1 9 | else 10 | -> fib(n - 1) + fib(n - 2) 11 | ;; 12 | } 13 | std.exit(fib(8)) 14 | } 15 | 16 | -------------------------------------------------------------------------------- /test/compoundimpl.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | trait frobable @a = 4 | frob : (val : @a -> void) 5 | ;; 6 | 7 | impl frobable int# = 8 | frob = {val 9 | std.put("intptr,") 10 | } 11 | ;; 12 | 13 | impl frobable char# = 14 | frob = {val 15 | std.put("charptr\n") 16 | } 17 | ;; 18 | 19 | generic foo = {x : @a :: frobable @a 20 | frob(x) 21 | } 22 | 23 | const main = { 24 | var a = (123 : int) 25 | var b = 'c' 26 | foo(&a) 27 | foo(&b) 28 | } 29 | 30 | -------------------------------------------------------------------------------- /test/condiffalse.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that false conditions lead to the false branch of an if statement. 3 | * should exit with 9. */ 4 | const main = { 5 | var x = 5, y = 7 6 | 7 | if x == 7 && y == 5 8 | std.exit(7) 9 | else 10 | std.exit(9) 11 | ;; 12 | } 13 | -------------------------------------------------------------------------------- /test/condifrel.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks if relatonal operators work. should exit with 9. */ 3 | const main = { 4 | var x = 3, y = 9 5 | 6 | if x < 5 && y > 7 7 | std.exit(7) 8 | else 9 | std.exit(9) 10 | ;; 11 | } 12 | -------------------------------------------------------------------------------- /test/condiftrue.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that true complex boolean conditions work. exits with 7. */ 3 | const main = { 4 | var x = 5, y = 7 5 | 6 | if x == 5 && y == 7 7 | std.exit(7) 8 | else 9 | std.exit(9) 10 | ;; 11 | } 12 | -------------------------------------------------------------------------------- /test/constslice.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const slpart = array[1:3] 4 | const slfull = array[:] 5 | const slinline = [6,7,8][:] 6 | const array = [1,2,3,4,5] 7 | 8 | const main = { 9 | /* expected output 23 */ 10 | for x : slpart 11 | std.put("{}", x) 12 | ;; 13 | /* expected output 12345 */ 14 | for x : slfull 15 | std.put("{}", x) 16 | ;; 17 | /* expected output 678 */ 18 | for x : slinline 19 | std.put("{}", x) 20 | ;; 21 | std.put("\n") 22 | } 23 | -------------------------------------------------------------------------------- /test/constunion.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const x = `std.Some "thing" 4 | 5 | const main = { 6 | std.put("{}\n", x) 7 | } 8 | -------------------------------------------------------------------------------- /test/custiter.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | type range = struct 4 | lo : int 5 | hi : int 6 | ;; 7 | 8 | /* iterate up to 100 */ 9 | impl iterable range -> int = 10 | __iternext__ = {rng, output 11 | if rng.lo > rng.hi 12 | -> false 13 | else 14 | output# = rng.lo++ 15 | -> true 16 | ;; 17 | } 18 | 19 | __iterfin__ = {it, val 20 | } 21 | ;; 22 | 23 | const main = { 24 | var r : range 25 | var x : int 26 | 27 | r = [.lo=6, .hi=11] 28 | for v : r 29 | x = v 30 | std.put("{}", x) 31 | ;; 32 | std.put("\n") 33 | } 34 | -------------------------------------------------------------------------------- /test/data/align-expected: -------------------------------------------------------------------------------- 1 | size = 1 2 | size = 16 3 | size = 20 4 | size = 20 5 | size = 8 6 | size = 24 7 | size = 8 8 | size = 24 9 | size = 8 10 | size = 16 11 | size = 12 12 | -------------------------------------------------------------------------------- /test/data/catfile-expected: -------------------------------------------------------------------------------- 1 | Hello-世界 2 | -------------------------------------------------------------------------------- /test/data/catfile-in: -------------------------------------------------------------------------------- 1 | Hello-世界 2 | -------------------------------------------------------------------------------- /test/data/matchargstr-expected: -------------------------------------------------------------------------------- 1 | Correct `Str "asdf"! 2 | -------------------------------------------------------------------------------- /test/data/stdbigint-expected: -------------------------------------------------------------------------------- 1 | 517347321949036993306 2 | 0 == 0 3 | 1234567812346789666677778888 / 123456781234678966667777 == 10000 4 | 1208908684563961789813300 / 263951815549716 == 4580035496 5 | 5192296858534810493479828944327220 / 75557863709417659441940 == 68719476751 6 | 75557863709417659441940 / 5192296858534810493479828944327220 == 0 7 | 5192296858534810493479828944327220 % 75557863709417659441940 == 257025710597479990280 8 | (1 ^ 3) % 2 == 1 9 | (5192296858534810493479828944327220 ^ 75557863709417659441940) % 755578 == 49054 10 | (7220 ^ 755578) % 75557863709417659441940 == 27076504425474791131220 11 | -------------------------------------------------------------------------------- /test/data/stdfmtpad-expected: -------------------------------------------------------------------------------- 1 | abcd 2 | 00000bdcae 3 | abcdefghijkl 4 | a 5 | 10 6 | 0000000010 7 | 4294967295 8 | -000000001 9 | -1 10 | 100000 11 | -------------------------------------------------------------------------------- /test/data/stdpathnorm-expected: -------------------------------------------------------------------------------- 1 | . 2 | foo 3 | foo/bar 4 | /foo/bar 5 | . 6 | . 7 | foo 8 | foo/bar/baz 9 | /foo/bar 10 | foo/bar 11 | /foo/bar 12 | foo/bar 13 | /foo/bar 14 | ../../foo/bar 15 | foo 16 | . 17 | .. 18 | / 19 | /foo/bar 20 | ../../foo/bar 21 | foo 22 | . 23 | / 24 | .. 25 | a/b 26 | a/b/c 27 | foo 28 | foo/bar 29 | -------------------------------------------------------------------------------- /test/data/stdslcp-expected: -------------------------------------------------------------------------------- 1 | 3 4 5 4 5 2 | 6 7 6 7 8 3 | -------------------------------------------------------------------------------- /test/data/stdsort-expected: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 2 4 | 3 5 | 4 6 | 5 7 | 6 8 | 7 9 | 8 10 | 9 11 | --- 12 | 1 13 | 2 14 | 3 15 | 4 16 | 5 17 | 6 18 | 7 19 | 8 20 | 9 21 | 10 22 | --- 23 | C 24 | Cc 25 | a 26 | aa 27 | b 28 | cC 29 | d 30 | f 31 | fuckit 32 | go 33 | -------------------------------------------------------------------------------- /test/data/stdtry-expected: -------------------------------------------------------------------------------- 1 | expected `Some @a, got `None 2 | -------------------------------------------------------------------------------- /test/data/strfind-expected: -------------------------------------------------------------------------------- 1 | Found 0 2 | No match 3 | No match 4 | Found 0 5 | Found 0 6 | No match 7 | Found 1 8 | Found 2 9 | No match 10 | No match 11 | -------------------------------------------------------------------------------- /test/data/strjoin-expected: -------------------------------------------------------------------------------- 1 | foo;bar 2 | xyzw 3 | x:y:z:w 4 | -------------------------------------------------------------------------------- /test/data/strsplit-expected: -------------------------------------------------------------------------------- 1 | "a" 2 | "b" 3 | "c" 4 | "d" 5 | "a" 6 | "" 7 | "b" 8 | "c" 9 | "" 10 | "d" 11 | "a--b" 12 | "b--c" 13 | "c-d--d" 14 | -------------------------------------------------------------------------------- /test/data/strstrip-expected: -------------------------------------------------------------------------------- 1 | "cccc" 2 | "cccc" 3 | "cccc" 4 | -- 5 | "abc" 6 | "abc " 7 | " abc" 8 | -- 9 | "世界" 10 | "世界 " 11 | " 世界" 12 | -- 13 | "" 14 | "" 15 | "" 16 | -- 17 | "" 18 | "" 19 | "" 20 | -------------------------------------------------------------------------------- /test/data/strtab-expected: -------------------------------------------------------------------------------- 1 | 0: foo 2 | 1: bar 3 | 2: baz 4 | 3: quux 5 | -------------------------------------------------------------------------------- /test/declmismatch.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* 3 | should fail to compile with a type error. 4 | char is incompatible with int. 5 | */ 6 | const main = { 7 | var a : int 8 | var b : char 9 | 10 | a = b 11 | } 12 | -------------------------------------------------------------------------------- /test/derefassign.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* should assign to v through pointer p, exiting with 123 */ 3 | const main = { 4 | var p 5 | var v 6 | 7 | v = 0 8 | p = &v 9 | p# = 123 10 | std.exit(v) 11 | } 12 | -------------------------------------------------------------------------------- /test/destructuretup.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | var a,b 5 | ((a, b), _) = ((1, 2), 3) 6 | std.assert(a+b == 3, "fail\n") 7 | } 8 | -------------------------------------------------------------------------------- /test/div.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* should exit with status 42 */ 3 | const main = { 4 | var a 5 | var b 6 | 7 | a = 127 8 | b = 3 9 | std.exit(a / b) 10 | } 11 | -------------------------------------------------------------------------------- /test/doublecall.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | std.put("{},{}\n", a(), b()) 5 | } 6 | 7 | const a = { 8 | -> 42 9 | } 10 | 11 | const b = { 12 | -> (33 : int16) 13 | } 14 | -------------------------------------------------------------------------------- /test/empty-struct.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | type foo = struct 4 | ;; 5 | 6 | type bar = struct 7 | baz : foo[:] 8 | quux : foo[0][:] 9 | ;; 10 | 11 | 12 | const main = { 13 | var a : foo 14 | var z : foo[0] 15 | var b : bar = [.baz = [a, a][:], .quux = [z, z, z][:]] 16 | var c : int = 0 17 | for f : b.baz 18 | c += 3 19 | ;; 20 | 21 | for f : b.quux 22 | c += 5 23 | ;; 24 | 25 | std.exit(c) 26 | } 27 | -------------------------------------------------------------------------------- /test/emptytrait.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | trait fooable @a = 4 | ;; 5 | 6 | impl fooable int = 7 | ;; 8 | 9 | generic foo = {x : @a::fooable @a 10 | -> x 11 | } 12 | 13 | const main = { 14 | std.exit(foo(123)) 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test/encodechar.myr: -------------------------------------------------------------------------------- 1 | /* checks that we can decode and encode characters from a utf8 string. */ 2 | use std 3 | 4 | const main = {args : byte[:][:] 5 | chartypes() 6 | } 7 | 8 | const chartypes = { 9 | var s 10 | var foo 11 | var buf : byte[32] 12 | 13 | s = "1世界äa\n" 14 | for c : std.bychar(s) 15 | foo = c 16 | if std.encode(buf[:std.charlen(c)], c) == 0 17 | std.write(1, "couldn't encode\n") 18 | ;; 19 | std.write(1, buf[:std.charlen(c)]) 20 | ;; 21 | } 22 | -------------------------------------------------------------------------------- /test/exportcycle.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* This test checks that cyclic types will be output 3 | * by muse. */ 4 | pkg = 5 | type list = struct 6 | next : list# 7 | val : int 8 | ;; 9 | ;; 10 | 11 | const main = { 12 | } 13 | -------------------------------------------------------------------------------- /test/exportmain.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg = 4 | const foo : (val:int -> int) 5 | ;; 6 | 7 | 8 | const foo = {val 9 | -> val 10 | } 11 | 12 | const main = { 13 | std.exit(foo(42)) 14 | } 15 | -------------------------------------------------------------------------------- /test/exporttrait.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg = 4 | trait t @a 5 | 6 | impl t int 7 | ;; 8 | 9 | trait t @a = 10 | frob : (v : @a -> @a) 11 | ;; 12 | 13 | impl t int = 14 | frob = {v 15 | -> v*2 16 | } 17 | ;; 18 | 19 | /* shut up the linker: we just want to compile this. */ 20 | const main = { 21 | } 22 | -------------------------------------------------------------------------------- /test/fib.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks if recursive functions work. should return 21. */ 3 | const fib = {n 4 | if n <= 0 5 | -> 0 6 | elif n == 1 7 | -> 1 8 | else 9 | -> fib(n - 1) + fib(n - 2) 10 | ;; 11 | } 12 | 13 | const main = { 14 | std.exit(fib(8)) 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test/fltabs.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | std.put("{}\n", std.abs(-42.0)) 5 | } 6 | -------------------------------------------------------------------------------- /test/fmtalign.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg = 4 | type msg = union 5 | `Tversion tversion 6 | ;; 7 | type tversion = struct 8 | tag : uint16 9 | version : byte[:] 10 | ;; 11 | ;; 12 | 13 | const main = { 14 | var msg=`Tversion [.tag=45, .version="9P2000"] 15 | std.put("{}\n", msg) 16 | } 17 | 18 | -------------------------------------------------------------------------------- /test/fmtnest.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | type foo = struct 4 | f2 : uint8 5 | f3 : (uint8, flt64) 6 | ;; 7 | 8 | const main = { 9 | var f : foo = [ .f2 = 2, .f3 = (3, 4.4) ] 10 | var str = std.fmt("{}", f) 11 | for var j = 0; j < str.len; ++j 12 | /* Try not to accidentally create any shell characters */ 13 | if str[j] == ('(' : byte) || str[j] == (')' : byte) || str[j] == ('[' : byte) || str[j] == (']' : byte) || str[j] == (' ' : byte) || str[j] == ('=' : byte) 14 | str[j] = ('_' : byte) 15 | ;; 16 | ;; 17 | std.put("{}\n", str) 18 | } 19 | -------------------------------------------------------------------------------- /test/fncast.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | var fn, envfn 5 | var ptr 6 | 7 | fn = { 8 | } 9 | ptr = (fn : byte#) 10 | ptr = (envfn : byte#) 11 | envfn = { 12 | ptr = ptr 13 | } 14 | std.put("ok\n") 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test/foldidx.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | type xy = struct 4 | x : int 5 | y : int 6 | ;; 7 | const X = 123 8 | const Y = 456 9 | const z : xy[1] = [ 10 | [.x = X, .y = Y] 11 | ] 12 | 13 | const main = { 14 | std.put("{},{}\n", z[0].x, z[0].y) 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test/generic-in-const.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* 3 | should fail to compile because generic types 4 | are only allowed in generic declarations. 5 | */ 6 | const foo = {v : @a 7 | -> v 8 | } 9 | -------------------------------------------------------------------------------- /test/generic.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that simple generics are specialized correctly. exits with 42. */ 3 | generic id = {a:@a 4 | -> a 5 | } 6 | 7 | const main = { 8 | id("adsf") 9 | std.exit(id(42)) 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test/genericcall.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that generics can call non-generics. exits with 42. */ 3 | const f = { 4 | -> 42 5 | } 6 | 7 | const main = { 8 | id("adsf") 9 | std.exit(id(42)) 10 | } 11 | 12 | generic id = {a:@a 13 | -> f() 14 | } 15 | 16 | -------------------------------------------------------------------------------- /test/genericchain.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | generic fail = {val : @a 4 | -> `std.Some val 5 | } 6 | 7 | generic try = {opt : std.option(@b) 8 | match opt 9 | | `std.Some v: -> v 10 | | `std.None: std.die("Badness\n") 11 | ;; 12 | } 13 | 14 | const main = { 15 | std.put("val = {}\n", try(fail(123))) 16 | } 17 | -------------------------------------------------------------------------------- /test/genericimpl.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | trait gimpl @a = 4 | desc : (x : @a -> byte[:]) 5 | ;; 6 | 7 | impl gimpl int = 8 | desc = {x 9 | -> "int" 10 | } 11 | ;; 12 | 13 | impl gimpl byte[:] = 14 | desc = {x 15 | -> "string" 16 | } 17 | ;; 18 | 19 | impl gimpl @a = 20 | desc = {x 21 | -> "@a" 22 | } 23 | ;; 24 | 25 | impl gimpl @b[:] = 26 | desc = {x 27 | -> "@a[:]" 28 | } 29 | ;; 30 | 31 | const main = { 32 | std.put("{} {} {} {}\n", desc(123), desc("foo"), desc('x'), desc([true][:])) 33 | } 34 | -------------------------------------------------------------------------------- /test/genericmake.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | type t(@ty) = union 4 | `Some @ty 5 | `None 6 | ;; 7 | 8 | const make = {v 9 | -> `Some v 10 | } 11 | 12 | const main = { 13 | var x 14 | 15 | x = make(123) 16 | match x 17 | | `Some v: std.put("val = {}\n", v) 18 | | `None: std.die("Unreachable\n") 19 | ;; 20 | } 21 | -------------------------------------------------------------------------------- /test/genericmatch.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | type t(@a) = union 4 | `Foo @a 5 | `Bar 6 | ;; 7 | 8 | const main = { 9 | match `Foo 123 10 | | `Foo a: std.exit(0xf) 11 | | `Bar: std.exit(0x0) 12 | ;; 13 | } 14 | -------------------------------------------------------------------------------- /test/genericrec.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* test that generic types can be recursive, as long as they're not self 3 | * including. This just needs to compile and exit with 0. */ 4 | type list(@t) = struct 5 | val : @t 6 | next : list(@t)# 7 | ;; 8 | 9 | const main = { 10 | var v : list(int) 11 | 12 | v.val = 123 13 | v.next = std.alloc() 14 | v.next.val = 234 15 | var n = std.alloc() 16 | v.next.next = n 17 | n.val = 345 18 | } 19 | -------------------------------------------------------------------------------- /test/genericret.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | type t(@a) = union 4 | `Val @a 5 | `None 6 | ;; 7 | 8 | const f = {-> t(int) 9 | -> `None 10 | } 11 | 12 | const main = { 13 | match f() 14 | | `None: std.exit(42) 15 | | _: std.die("Impossible match failure\n"); 16 | ;; 17 | std.exit(0) 18 | } 19 | -------------------------------------------------------------------------------- /test/generictype.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | /* checks that parameterized types work. exits with 0. */ 4 | type option(@a) :: integral,numeric @a = union 5 | `Some @a 6 | `None 7 | ;; 8 | 9 | const main = { 10 | var v 11 | 12 | v = `Some 123 13 | match v 14 | | `None: std.exit(1) 15 | | `Some 123: std.exit(0) 16 | | `Some _: std.die("Impossible match failure\n") 17 | ;; 18 | std.exit(60) 19 | } 20 | -------------------------------------------------------------------------------- /test/genericuret.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | generic work = {val : @a 4 | -> `std.Some val 5 | } 6 | 7 | const main = { 8 | work(123) 9 | std.exit(42) 10 | } 11 | -------------------------------------------------------------------------------- /test/genericval.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | generic Foo : @a = 42 :: integral,numeric @a 4 | 5 | const main = { 6 | std.exit(Foo) 7 | } 8 | 9 | -------------------------------------------------------------------------------- /test/global-arrayvar.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* tests that global arrays work as expected, and are zero-initialized by 3 | * default. should exit with 7 */ 4 | var a : int[10] 5 | 6 | const main = { 7 | a[0] = 3 8 | a[1] = 4 9 | std.exit(a[0] + a[1] + a[2] + a[3]) 10 | } 11 | -------------------------------------------------------------------------------- /test/gsizeof.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that sizeof works on generics. exits with 5. */ 3 | generic sz = {a:@a 4 | -> sizeof(@a) 5 | } 6 | 7 | const main = { 8 | std.exit(sz(123) + sz("asdf"[0])) 9 | } 10 | -------------------------------------------------------------------------------- /test/gtrait.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | trait comparable @a = 4 | cmp : (a : @a, b : @a -> std.order) 5 | ;; 6 | 7 | impl comparable @a :: numeric @a = 8 | cmp = {a, b 9 | -> std.numcmp(a, b) 10 | } 11 | ;; 12 | 13 | const main = { 14 | std.put("{}", cmp(1, 2)) 15 | } 16 | -------------------------------------------------------------------------------- /test/helloworld.myr: -------------------------------------------------------------------------------- 1 | /* checks that this program prints Hello-世界\n */ 2 | use std 3 | 4 | const main = {args : byte[:][:] 5 | std.write(1, "Hello-世界\n") 6 | } 7 | 8 | -------------------------------------------------------------------------------- /test/implexpr-concrete.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | trait name @a = 4 | Name: byte[:] 5 | ;; 6 | impl name void = 7 | Name = "zig" 8 | ;; 9 | impl name int = 10 | Name = "zag" 11 | ;; 12 | 13 | const main = { 14 | std.put("{}{}\n", impl(Name, void), impl(Name, int)) 15 | } 16 | -------------------------------------------------------------------------------- /test/implexpr.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | trait favorite @a = 4 | Fav : @a 5 | ;; 6 | impl favorite int = 7 | Fav = 12 8 | ;; 9 | impl favorite char = 10 | Fav = 'z' 11 | ;; 12 | impl favorite byte[:] = 13 | Fav = "hello" 14 | ;; 15 | 16 | const main = { 17 | std.put("{},{},{}\n", impl(Fav, int), impl(Fav, char), impl(Fav, byte[:])) 18 | } 19 | -------------------------------------------------------------------------------- /test/import-type.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use sys 3 | 4 | const main = { 5 | var x : std.size 6 | var y : std.off 7 | var z : sys.fd 8 | } 9 | -------------------------------------------------------------------------------- /test/incret.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | var i = 0 4 | const f = { 5 | -> i++ 6 | } 7 | 8 | const main = { 9 | f() 10 | std.exit(i) 11 | } 12 | -------------------------------------------------------------------------------- /test/infer-named.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | type u = union 4 | `Foo 5 | `Bar int 6 | ;; 7 | 8 | const f = {v : int -> u 9 | -> `Bar v 10 | } 11 | 12 | const main = { 13 | var v 14 | 15 | v = f(99) 16 | match v 17 | | `Foo: std.exit(1) 18 | | `Bar x: std.exit(x) 19 | ;; 20 | std.exit(2) 21 | } 22 | -------------------------------------------------------------------------------- /test/infermismatch.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* 3 | should fail to compile after infering that a is a float, b is a char, and 4 | the types are incompatible. 5 | */ 6 | const main = { 7 | var a 8 | var b 9 | 10 | a = 1.0 11 | b = 'a' 12 | a = b 13 | } 14 | -------------------------------------------------------------------------------- /test/initializer.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | pkg = 4 | type qid = struct 5 | ty : uint8 6 | path : uint64 7 | ;; 8 | 9 | type stat = struct 10 | dev : uint32 11 | qid : qid 12 | ;; 13 | ;; 14 | 15 | const main = { 16 | var stat : stat = [.dev=0, .qid=[.ty=0, .path=0]] 17 | std.assert(stat.qid.path == 0, "fail\n") 18 | } 19 | -------------------------------------------------------------------------------- /test/livearraylit.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | var v 5 | 6 | v = [foo(), 42, 123] 7 | std.exit(v[0]) 8 | } 9 | 10 | const foo = { 11 | -> 21 12 | } 13 | -------------------------------------------------------------------------------- /test/livestructlit.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | /* checks that we can create struct literals with named initializers. 4 | exits with 42. */ 5 | type t = struct 6 | a : int 7 | b : byte 8 | c : byte[:] 9 | ;; 10 | 11 | const main = { 12 | var v : t 13 | 14 | v = [.a=foo(), .b=42, .c="foo"] 15 | std.exit(v.a) 16 | } 17 | 18 | const foo = { 19 | -> 21 20 | } 21 | -------------------------------------------------------------------------------- /test/local-labels.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | goto foo 5 | std.exit(123) 6 | :foo 7 | std.exit(bar()) 8 | } 9 | 10 | const bar = { 11 | goto foo 12 | -> 42 13 | :foo 14 | -> 10 15 | } 16 | -------------------------------------------------------------------------------- /test/log-and.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that evaluating a logical and to a bool works. should return 0. */ 3 | const main = { 4 | std.exit((0 && 1 : int)) 5 | } 6 | -------------------------------------------------------------------------------- /test/log-or.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that evaluating a logical or works. exits with 1. */ 3 | const main = { 4 | std.exit((0 || 1 : int)) 5 | } 6 | -------------------------------------------------------------------------------- /test/loop.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that loops work. */ 3 | const main = { 4 | var i 5 | var n 6 | 7 | n = 0 8 | for i = 0; i < 5; ++i 9 | std.put("{}", i) 10 | ;; 11 | for i = 0; i < 5; ++i 12 | if i > 3 13 | break 14 | ;; 15 | std.put("{}", i) 16 | ;; 17 | for i = 0; i < 10; ++i 18 | if i < 6 19 | continue 20 | ;; 21 | std.put("{}", i) 22 | ;; 23 | std.put("\n") 24 | } 25 | -------------------------------------------------------------------------------- /test/main.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* should exit with status 0 */ 3 | const main = {;} 4 | -------------------------------------------------------------------------------- /test/match-badtypes.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* 3 | should fail to compile because 4 | all types matched over should be 5 | compatible. Strings are not compatible 6 | with integers. 7 | */ 8 | const foo = { 9 | match 123 10 | |"asdf": 123 11 | |234567: 888 12 | ;; 13 | std.exit(42) 14 | } 15 | -------------------------------------------------------------------------------- /test/matchargstr.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks pattern matching on unions with arguments. 3 | exits with 42. */ 4 | type u = union 5 | `Int int 6 | `Str byte[:] 7 | `Nil 8 | ;; 9 | 10 | const main = { 11 | var v 12 | 13 | v = `Str "asdf" 14 | match v 15 | | `Int 127: std.fatal("wrong match `Int 127\n") 16 | | `Str "foo": std.fatal("Wrong match `Str \"foo\"\n") 17 | /* make sure we backtrack for the test */ 18 | | `Str "asfd": std.fatal("Wrong match `Str \"fsda\"\n") 19 | | `Str "asdf": std.put("Correct `Str \"asdf\"!\n") 20 | | `Nil: std.fatal("Wrong match `Str \"fsda\"\n") 21 | | _: std.fatal("Impossible failed match\n") 22 | ;; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /test/matchargunion.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks pattern matching on unions with arguments. 3 | exits with 42. */ 4 | type u = union 5 | `Int int 6 | `Chr char 7 | `Nil 8 | ;; 9 | 10 | const main = { 11 | var v 12 | 13 | v = `Int 123 14 | match v 15 | | `Int 127: std.exit(42) 16 | | `Int 123: std.exit(69) 17 | | `Chr 'a': std.exit(4) 18 | | `Nil: std.exit(6) 19 | | _: std.die("Impossible failed match\n") 20 | ;; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /test/matcharray.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | var v = [2, 40, 10] 5 | 6 | match v 7 | | [x, y, 10]: 8 | std.exit(x + y) 9 | | _: std.die("Wat") 10 | ;; 11 | std.exit(0) 12 | } 13 | -------------------------------------------------------------------------------- /test/matchbind.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that we can bind values in pattern matches. 3 | exits with 11. */ 4 | type u = union 5 | `Int int 6 | `Chr char 7 | `Nil 8 | ;; 9 | 10 | const main = { 11 | var v 12 | 13 | v = `Int 8 14 | match v 15 | | `Int 127: std.exit(42) 16 | | `Int x: std.exit(x) 17 | | `Chr 'a': std.exit(4) 18 | | `Nil: std.exit(6) 19 | | x: std.die("Impossible match failure\n") 20 | ;; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /test/matchconst.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that matching works when comparing against constants, 3 | instead of just literals. exits with 88. */ 4 | /* some misc constants */ 5 | const Ca = 123 6 | const Cb = 8 7 | const Cc = 42 8 | 9 | const main = { 10 | var v 11 | 12 | v = 8 13 | match v 14 | | Ca: std.exit(123) 15 | | Cb: std.exit(88) 16 | | Cc: std.exit(42) 17 | | _: std.die("Impossible match failure in pattern\n") 18 | ;; 19 | } 20 | -------------------------------------------------------------------------------- /test/matchctup.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | match (gen_a(), gen_b()) 5 | | (`std.Err _, _): std.put("error case 1") 6 | | (_, `std.Err _): std.put("error case 2") 7 | | (`std.Ok L, `std.Ok N): 8 | std.put("l = {} n = {}\n", L, N) 9 | ;; 10 | } 11 | 12 | var gen_a : (-> std.result(byte[:][:], void)) = { 13 | var ret = [][:] 14 | 15 | for var j = 0; j < 4; ++j 16 | std.slpush(&ret, std.fmt("{}", j)) 17 | ;; 18 | 19 | if 1 + 1 > 3 20 | -> `std.Err void 21 | ;; 22 | 23 | -> `std.Ok ret 24 | } 25 | 26 | var gen_b : (-> std.result(int, void)) = { 27 | if 1 + 1 > 3 28 | -> `std.Err void 29 | ;; 30 | 31 | -> `std.Ok 5 32 | } 33 | -------------------------------------------------------------------------------- /test/matchexhaust.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | type u = union 4 | `Foo (bool, v, bool) 5 | `Bar (bool, bool) 6 | `Baz bool 7 | `Quux 8 | ;; 9 | 10 | type v = union 11 | `A 12 | `B 13 | ;; 14 | 15 | const main = { 16 | match `Quux 17 | | `Foo (true, `A, true): 18 | | `Foo (true, `A, false): 19 | | `Foo (true, `B, true): 20 | | `Foo (true, `B, false): 21 | | `Foo (false, `A, true): 22 | | `Foo (false, `A, false): 23 | | `Foo (false, `B, true): 24 | | `Foo (false, `B, false): 25 | 26 | | `Bar (false, false): 27 | | `Bar (false, true): 28 | | `Bar (true, false): 29 | | `Bar (true, true): 30 | 31 | | `Baz false: 32 | | `Baz true: 33 | 34 | | `Quux: 35 | ;; 36 | std.put("worked\n") 37 | } 38 | -------------------------------------------------------------------------------- /test/matchint.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that matching integers works. exits with 84. */ 3 | const main = { 4 | var v 5 | 6 | v = 12 7 | match 12 8 | | 1: std.exit(42) 9 | | 2: std.exit(81) 10 | | 3: std.exit(123) 11 | | 4: std.exit(99) 12 | | 12: std.exit(84) 13 | | 6: std.exit(18) 14 | | x: std.die("Got an unexpected int!\n") 15 | ;; 16 | } 17 | -------------------------------------------------------------------------------- /test/matchmixed.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | type u = union 4 | `A 5 | `B 6 | ;; 7 | 8 | const main = { 9 | match "asdf" 10 | | `A: std.put("Got a\n") 11 | | `B: std.put("Got b\n") 12 | ;; 13 | std.exit(42) 14 | } 15 | -------------------------------------------------------------------------------- /test/matchnsconst.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | var v 5 | 6 | v = std.Badchar 7 | match v 8 | | std.Maxcharval: std.put("matched maxcharval\n") 9 | | std.Badchar: std.put("matched badchar\n") 10 | | 'c': std.put("matched 'c'\n") 11 | | _: std.die("Impossible match failure in pattern\n") 12 | ;; 13 | } 14 | -------------------------------------------------------------------------------- /test/matchptr.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | type loop = struct 4 | l : loop# 5 | val : int 6 | ;; 7 | 8 | const main = { 9 | var x : std.option(std.option(int)#) 10 | var y : loop 11 | var ok 12 | 13 | ok = false 14 | x = `std.Some &(`std.Some 123) 15 | match x 16 | | `std.Some &(`std.None): std.put("failed\n") 17 | | `std.Some &(`std.Some 666): std.put("failed\n") 18 | | `std.Some &(`std.Some 123): ok = true 19 | | _: std.put("failed\n") 20 | ;; 21 | 22 | y.val=666 23 | match &y 24 | | &[.val=777]: std.put("failed\n") 25 | | &[.val=123]: ok = ok && true 26 | | &[.val=999]: std.put("failed\n") 27 | | _: 28 | ;; 29 | 30 | if ok 31 | std.put("worked\n") 32 | else 33 | std.put("failed\n") 34 | ;; 35 | } 36 | -------------------------------------------------------------------------------- /test/matchstruct.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | type t = struct 4 | v1 : int 5 | v2 : int 6 | v3 : int 7 | ;; 8 | 9 | const main = { 10 | var v : t 11 | 12 | v.v1 = 2 13 | v.v2 = 40 14 | v.v3 = 10 15 | match v 16 | | [.v2 = x, .v1 = y, .v3 = 10]: 17 | std.exit(x + y) 18 | | _: 19 | std.die("Wat") 20 | ;; 21 | std.exit(0) 22 | } 23 | -------------------------------------------------------------------------------- /test/matchtup.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | var v = (1, 2) 5 | 6 | match v 7 | | (1, x): std.exit(40 + x) 8 | | _: std.die("Wat") 9 | ;; 10 | std.exit(0) 11 | } 12 | -------------------------------------------------------------------------------- /test/matchunion.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that union matching works, at least on the key. 3 | exits with 84. */ 4 | type u = union 5 | `Foo 6 | `Bar 7 | `Baz 8 | `Quux 9 | ;; 10 | 11 | const main = { 12 | var v 13 | 14 | v = `Foo 15 | match v 16 | | `Bar: std.exit(42) 17 | | `Baz: std.exit(81) 18 | | `Foo: std.exit(84) 19 | | `Quux: std.exit(123) 20 | ;; 21 | } 22 | -------------------------------------------------------------------------------- /test/matchunion_sl.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks pattern matching on unions with arguments. 3 | exits with 42. */ 4 | type u = union 5 | `Int int 6 | `Str byte[:] 7 | `Nil 8 | ;; 9 | 10 | const main = { 11 | var v 12 | 13 | v = `Str "foo" 14 | match v 15 | | `Int 127: std.exit(42) 16 | | `Str s: std.put("{}\n", s) 17 | | `Nil: 18 | | _: std.die("Impossible match failure\n") 19 | ;; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /test/matchvoid.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | match `std.Some void 5 | | `std.Some void: std.put("ok\n") 6 | | `std.None: std.put("nope\n") 7 | ;; 8 | } 9 | -------------------------------------------------------------------------------- /test/mkfile: -------------------------------------------------------------------------------- 1 | all:V: runtest.rc 2 | 3 | check:V: 4 | ./runtest.rc 5 | 6 | -------------------------------------------------------------------------------- /test/mkunion.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that union creation works. exits with 0. */ 3 | type u = union 4 | `Some int 5 | `None 6 | ;; 7 | 8 | const main = { 9 | var v 10 | 11 | v = `Some 123 12 | std.exit(0) 13 | } 14 | -------------------------------------------------------------------------------- /test/mod.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* should exit with status 6 */ 3 | const main = { 4 | var a = 42 5 | var b = 9 6 | std.exit(a % b) 7 | } 8 | -------------------------------------------------------------------------------- /test/mul.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* should exit with status 42 */ 3 | const main = { 4 | var a = 7 5 | var b = 2 6 | var c = 3 7 | std.exit(a * b * c) 8 | } 9 | -------------------------------------------------------------------------------- /test/mul8.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | var a : int8 = 6 4 | const f = { -> int8 5 | -> 3 6 | } 7 | const main = { 8 | std.exit(((a*f() : int))) 9 | } 10 | -------------------------------------------------------------------------------- /test/multistr.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | var multi 5 | 6 | multi = "abc" "def" \ 7 | "ghi" 8 | 9 | match multi 10 | | "abcdefghi": 11 | | fail: std.fatal("failed: {}\n", fail) 12 | ;; 13 | } 14 | -------------------------------------------------------------------------------- /test/nestclosure.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | var a = 1 5 | var f = std.fndup({ 6 | { 7 | std.put("{}\n", a) 8 | }() 9 | }) 10 | f() 11 | } 12 | -------------------------------------------------------------------------------- /test/nestedgoto.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | match 0 5 | | 0: 6 | goto ok 7 | | 1: 8 | :ok 9 | -> void 10 | | _: 11 | ;; 12 | std.exit(1) 13 | } 14 | -------------------------------------------------------------------------------- /test/nestfn.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that nested functions without environment capture work. should 3 | * exit with 42. */ 4 | const main = { 5 | const ret42 = { 6 | -> 42 7 | } 8 | std.exit(ret42()) 9 | } 10 | -------------------------------------------------------------------------------- /test/neststruct.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* tests that nested structs work. should exit with 3 */ 3 | type s1 = struct 4 | x : s2 5 | ;; 6 | 7 | type s2 = struct 8 | a : int 9 | b : int 10 | ;; 11 | 12 | const main = { 13 | var s1 : s1 14 | var s2 : s2 15 | 16 | s1.x.a = 1 17 | s1.x.b = 2 18 | s2 = s1.x 19 | 20 | std.exit(s2.a + s2.b) 21 | } 22 | -------------------------------------------------------------------------------- /test/nestucon.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | type t = struct 4 | x : union 5 | `Int int 6 | `Str byte[:] 7 | ;; 8 | ;; 9 | 10 | const main = { 11 | var a : t 12 | 13 | a = [.x = `Str "asdf"] 14 | match a 15 | | [.x=`Str s]: std.put("{}\n", s) 16 | | _: std.die("Impossible match failure\n") 17 | ;; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /test/occur.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that f is not an infinite type (ie, the type 3 | doesn't exist within itself). If 'f' typechecked, 4 | it's type would be: 5 | 6 | f : (std.exit((-> (-> ... ad infinitum ...)))) 7 | */ 8 | const f = { 9 | std.exit(f) 10 | } 11 | -------------------------------------------------------------------------------- /test/outparam-sl.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* should assign a slice through an out param, returning exiting with 2 */ 3 | const arr = [1,2,3,4] 4 | const f = {out 5 | out# = arr[1:3] 6 | } 7 | 8 | const main = { 9 | var v 10 | 11 | f(&v) 12 | std.exit(v[0]) 13 | } 14 | -------------------------------------------------------------------------------- /test/outparam.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* should assign through an out pointer parameter, exiting with status 42 */ 3 | const f = {out 4 | out# = 42 5 | } 6 | 7 | const main = { 8 | var v 9 | 10 | v = 16 11 | f(&v) 12 | std.exit(v) 13 | } 14 | -------------------------------------------------------------------------------- /test/overlappingif.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that if multiple if conditions are valid, only the first is 3 | * selected. should exit with 2. */ 4 | const main = { 5 | var v 6 | var x 7 | 8 | v = 0xff 9 | 10 | x = 42 11 | if v & 0xff00 != 0 12 | x = 1 13 | elif v & 0xfff0 != 0 14 | x = 2 15 | elif v & 0xffff != 0 16 | x = 3 17 | ;; 18 | std.exit(x) 19 | } 20 | -------------------------------------------------------------------------------- /test/patiter.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | /* should print 1,3,5, skipping 4 */ 5 | for (1,x) : [(1,2),(1,3),(2,4),(1,5)] 6 | std.put("{}", x) 7 | ;; 8 | /* should print 1, 2 skipping `None */ 9 | for `std.Some v : [`std.None, `std.Some 1, `std.Some 2] 10 | std.put("{}", v) 11 | ;; 12 | std.put("\n") 13 | } 14 | -------------------------------------------------------------------------------- /test/pkgtrait.myr: -------------------------------------------------------------------------------- 1 | use std 2 | use regex 3 | 4 | impl disposable regex.regex# = 5 | __dispose__ = {r 6 | regex.free(r) 7 | } 8 | ;; 9 | 10 | const main = { 11 | auto std.try(regex.compile(".*")) 12 | std.exit(42) 13 | } 14 | -------------------------------------------------------------------------------- /test/postinc-ret.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | std.put("{}\n", f()) 5 | } 6 | 7 | const a = [1,2,3][:] 8 | const f = { 9 | var i = 0 10 | -> a[i++] 11 | } 12 | 13 | -------------------------------------------------------------------------------- /test/ptrcmp.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | var a, b, v1, v2 5 | 6 | v1 = 42 7 | v2 = 42 8 | a = &v1 9 | b = &v1 10 | std.assert(a == b, "pointers should be equal, but weren't\n") 11 | a = &v1 12 | b = &v2 13 | std.assert(a != b, "pointers weren't equal, but should be\n") 14 | std.exit(0) 15 | } 16 | -------------------------------------------------------------------------------- /test/ptrpreinc.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* should preincrement through a pointer, exiting with status 9 */ 3 | const ppreinc = {p 4 | -> ++p# 5 | } 6 | 7 | const main = { 8 | var x = 8 9 | 10 | std.exit(ppreinc(&x)) 11 | } 12 | 13 | -------------------------------------------------------------------------------- /test/recgeneric.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | type o(@a) :: integral @a = union 4 | `S @a 5 | ;; 6 | 7 | type x(@k) = struct 8 | n : o(x(@k)#) 9 | ;; 10 | 11 | const main = { 12 | var test : x(int) 13 | std.put("built\n") 14 | } 15 | -------------------------------------------------------------------------------- /test/rvaldotlen.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const f1 = { -> byte[:] 4 | -> [1, 2, 3][:] 5 | } 6 | 7 | const f2 = { -> byte[3] 8 | -> [1, 2, 3] 9 | } 10 | 11 | 12 | const main = { 13 | if f1().len != 3 14 | -> void 15 | ;; 16 | if f2().len != 3 17 | -> void 18 | ;; 19 | std.put("pass\n") 20 | } 21 | 22 | -------------------------------------------------------------------------------- /test/sizeof.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that sizeof() works. exits with 4. */ 3 | const main = { 4 | std.exit(sizeof(int)) 5 | } 6 | -------------------------------------------------------------------------------- /test/slalloc.myr: -------------------------------------------------------------------------------- 1 | /* test the allocation of slices. should return 123 */ 2 | use std 3 | 4 | const main = { 5 | var sl : int[:] 6 | 7 | sl = std.slalloc(123) 8 | sl[0] = 42 9 | sl[122] = 1 10 | std.exit(sl.len) 11 | } 12 | -------------------------------------------------------------------------------- /test/slgrow.myr: -------------------------------------------------------------------------------- 1 | /* checks that our slice grow function works. exits with 42. */ 2 | use std 3 | 4 | const main = { 5 | var sl 6 | 7 | sl = std.slalloc(42) 8 | sl[0] = 12 9 | std.slgrow(&sl, 123) 10 | sl[122] = 30 11 | std.exit(sl[0] + sl[122]) 12 | } 13 | -------------------------------------------------------------------------------- /test/slice.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that taking slices of arrays works. should exit with 7 */ 3 | const main = { 4 | var a : int[3] 5 | var s 6 | 7 | s = a[:] 8 | s[0] = 3 9 | s[1] = 4 10 | s[2] = s[0] + s[1] + s.len 11 | std.exit(s[2]) 12 | } 13 | -------------------------------------------------------------------------------- /test/slicelen.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that taking incomplete slices calculates the length correctly. 3 | * should exit with 5. */ 4 | const main = { 5 | var a : int[8] 6 | var s 7 | 8 | s = a[1:6] 9 | std.exit(s.len) 10 | } 11 | -------------------------------------------------------------------------------- /test/slprint.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | std.put("{} {}\n", (1 : uint32), [2][:]) /* !!! */ 5 | } 6 | -------------------------------------------------------------------------------- /test/splitline.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | std.exit(1 + \ /* ignored crap */ 5 | 2) 6 | } 7 | -------------------------------------------------------------------------------- /test/sqrt.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const abs = {d 4 | if d < 0.0 5 | -> -d 6 | else 7 | -> d 8 | ;; 9 | } 10 | 11 | const Eps = 0.00001 12 | const Maxiter = 20 13 | 14 | const sqrt = {x : flt64 15 | var val 16 | var iter 17 | var i; 18 | 19 | val = 1.0; 20 | for i = 0; i < Maxiter; i++ 21 | iter = 0.5*(val + x/val) 22 | if abs(val - iter) < Eps 23 | -> val; 24 | ;; 25 | val = iter; 26 | ;; 27 | -> val 28 | } 29 | 30 | const main = { 31 | var r 32 | 33 | r = (sqrt(20.0) : int) 34 | std.exit(r) 35 | } 36 | 37 | -------------------------------------------------------------------------------- /test/str.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that string literals are compiled correctly. 3 | exits with ascii 'f', ie, 102. */ 4 | const main = { 5 | var str 6 | 7 | str = "asdf" 8 | std.exit((str[3] : int)) 9 | } 10 | -------------------------------------------------------------------------------- /test/strfind.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | printloc(std.strfind("", "")) 5 | printloc(std.strfind("", "a")) 6 | printloc(std.strfind("ab", "abc")) 7 | printloc(std.strfind("abc", "abc")) 8 | printloc(std.strfind("abcde", "abc")) 9 | printloc(std.strfind("abcde", "xyz")) 10 | printloc(std.strfind("abcde", "bcd")) 11 | printloc(std.strfind("abcde", "cde")) 12 | printloc(std.strfind("abcde", "def")) 13 | printloc(std.strfind("abcde", "abx")) 14 | } 15 | 16 | const printloc = {l 17 | match l 18 | | `std.Some loc: std.put("Found {}\n", loc) 19 | | `std.None: std.put("No match\n") 20 | ;; 21 | } 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /test/strjoin.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | const strings = [ 5 | "x", 6 | "y", 7 | "z", 8 | "w" 9 | ] 10 | std.put("{}\n", std.strcat("foo;", "bar")) 11 | std.put("{}\n", std.strjoin(strings[:], "")) 12 | std.put("{}\n", std.strjoin(strings[:], ":")) 13 | } 14 | -------------------------------------------------------------------------------- /test/strsplit.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | var i 5 | var sp 6 | 7 | sp = std.strsplit("a,b,c,d", ",") 8 | for i = 0; i < sp.len; i++ 9 | std.put("\"{}\"\n", sp[i]) 10 | ;; 11 | std.slfree(sp) 12 | 13 | sp = std.strsplit("a,,b,c,,d", ",") 14 | for i = 0; i < sp.len; i++ 15 | std.put("\"{}\"\n", sp[i]) 16 | ;; 17 | std.slfree(sp) 18 | 19 | sp = std.strsplit("a--b---b--c---c-d--d", "---") 20 | for i = 0; i < sp.len; i++ 21 | std.put("\"{}\"\n", sp[i]) 22 | ;; 23 | std.slfree(sp) 24 | } 25 | -------------------------------------------------------------------------------- /test/strtab.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const strtab = [ 4 | "foo", 5 | "bar", 6 | "baz", 7 | "quux" 8 | ] 9 | 10 | const main = { 11 | var i 12 | for i = 0; i < strtab.len; i++ 13 | std.put("{}: {}\n", i, strtab[i]) 14 | ;; 15 | std.exit(0) 16 | } 17 | -------------------------------------------------------------------------------- /test/struct.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* test reading and writing to struct members. exits with 42. */ 3 | type pair = struct 4 | a : int 5 | b : int 6 | ;; 7 | 8 | const main = { 9 | var s : pair 10 | s.a = 12 11 | s.b = 30 12 | std.exit(s.a + s.b) 13 | } 14 | -------------------------------------------------------------------------------- /test/struct1.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* 3 | make sure assigning to a 1-element struct works; exit status should be 12 4 | */ 5 | type val = struct 6 | a : int 7 | ;; 8 | 9 | const main = { 10 | var s : val 11 | s.a = 12 12 | std.exit(s.a) 13 | } 14 | -------------------------------------------------------------------------------- /test/structarray.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* tests a struct containing an array. exit status should be 42. */ 3 | type t = struct 4 | a : int[42] 5 | ;; 6 | 7 | const main = { 8 | var v : t 9 | 10 | v.a[0] = 11 11 | v.a[1] = 20 12 | 13 | std.exit(2*v.a[0] + v.a[1]) 14 | } 15 | -------------------------------------------------------------------------------- /test/structasn.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* tests block assignment of structs. exits with 42.*/ 3 | type pair = struct 4 | a : int 5 | b : int 6 | ;; 7 | 8 | const main = { 9 | var x : pair 10 | var y : pair 11 | x.a = 12 12 | x.b = 30 13 | y = x 14 | std.exit(y.a + y.b) 15 | } 16 | -------------------------------------------------------------------------------- /test/structlit.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | /* checks that we can create struct literals with named initializers. 4 | exits with 42. */ 5 | type t = struct 6 | a : int 7 | b : char 8 | c : byte[:] 9 | ;; 10 | 11 | const main = { 12 | var v : t 13 | 14 | v = [.a=42, .b='x', .c="foo"] 15 | std.exit(v.a) 16 | } 17 | 18 | -------------------------------------------------------------------------------- /test/structptr.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* tests reading and writing through a struct pointer. exits with 42. */ 3 | type pair = struct 4 | a : int 5 | b : int 6 | ;; 7 | 8 | const frob = {s 9 | s.a = 12 10 | s.b = 30 11 | } 12 | 13 | const main = { 14 | var s : pair 15 | frob(&s) 16 | std.exit(s.a + s.b) 17 | } 18 | -------------------------------------------------------------------------------- /test/structret.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* tests returning large structs. should exit with 42. */ 3 | type pair = struct 4 | a : int 5 | b : int 6 | ;; 7 | 8 | const f = { 9 | var s 10 | 11 | s.a = 12 12 | s.b = 30 13 | -> s 14 | } 15 | 16 | const main = { 17 | var s : pair 18 | 19 | s = f() 20 | std.exit(s.a + s.b) 21 | } 22 | -------------------------------------------------------------------------------- /test/subrangefor.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | for i : [1,2,3,4][:2] 5 | std.put("{}", i) 6 | ;; 7 | std.put("\n") 8 | } 9 | -------------------------------------------------------------------------------- /test/swidencast.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* sign extending cast. should exit with status 99 */ 3 | const main = { 4 | var u : int8 5 | var v : int32 6 | 7 | u = 99 8 | v = (u : int32) 9 | std.exit((v : int)) 10 | } 11 | -------------------------------------------------------------------------------- /test/trait-builtin.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that generic types with traits are compiled correctly. 3 | without the 'numeric' trait on '@a', the '>' operator would not work 4 | within max. without the 'tctest' trait on '@a' in intlike_is42, 5 | comparing to 42 wouldn't work. 6 | 7 | exits with 42. 8 | */ 9 | 10 | generic max = {a : @a, b : @a :: numeric @a 11 | if a > b 12 | -> a 13 | else 14 | -> b 15 | ;; 16 | } 17 | 18 | generic intlike_is42 = {a : @a :: numeric,integral @a 19 | -> a == 42 20 | } 21 | 22 | const main = { 23 | if intlike_is42(123) 24 | std.exit(16) 25 | else 26 | std.exit(max(12, 42)) 27 | ;; 28 | } 29 | -------------------------------------------------------------------------------- /test/traitimpl.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | trait frobable @a = 4 | frob : (val : @a -> @a) 5 | ;; 6 | 7 | impl frobable int = 8 | frob = {val 9 | -> val * 2 10 | } 11 | ;; 12 | 13 | impl frobable int16 = 14 | frob = {val 15 | -> val * 4 16 | } 17 | ;; 18 | 19 | impl frobable byte[:] = 20 | frob = {val 21 | -> val[:4] 22 | } 23 | ;; 24 | 25 | generic foo = {x : @a :: frobable @a 26 | -> frob(x) 27 | } 28 | 29 | const main = { 30 | var a, b, c 31 | a = foo(123) 32 | b = foo((11 : int16)) 33 | c = frob("meeeeeeh") 34 | std.put("{},{},{}\n", a, b, c) 35 | } 36 | 37 | -------------------------------------------------------------------------------- /test/trunccast.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* should truncate y when casting to x, exiting with status 15 */ 3 | const main = { 4 | var x : uint8 5 | var y : int32 6 | 7 | y = 9999 8 | x = (y : uint8) 9 | std.exit((x % 73 : int)) 10 | } 11 | -------------------------------------------------------------------------------- /test/tuple.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that we can create tuples and destructure them. exits with 42. */ 3 | const main = { 4 | var a, b, c 5 | var v, x 6 | 7 | x = 10 8 | v = ((x, x + 12), x) 9 | ((a, b), c) = v 10 | std.exit(a + b + c) 11 | } 12 | -------------------------------------------------------------------------------- /test/tupleaccess.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const foo = { 4 | -> (1, 2, (3, 4)) 5 | } 6 | 7 | const main = { 8 | match foo() 9 | | x: 10 | x.0 = 0 11 | (x.2).1 = 5 12 | std.put("a: {}, b: {}, c: {}\n", x.0, x.2.1, foo().1) 13 | ;; 14 | } 15 | -------------------------------------------------------------------------------- /test/tyoccur.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that types do not contain themselves 3 | inline, because that would lead to an infinite 4 | sized type. 5 | */ 6 | 7 | type t = struct 8 | memb : t 9 | ;; 10 | 11 | var v : t 12 | -------------------------------------------------------------------------------- /test/tyrec.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* we just want to see if this file compiles */ 3 | type foo = struct 4 | v : foo# 5 | ;; 6 | 7 | const main = { 8 | var v : foo 9 | std.exit(42) 10 | } 11 | -------------------------------------------------------------------------------- /test/uconinit.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | type u = union 4 | `A 5 | `B 6 | `C int 7 | ;; 8 | 9 | const a = [`A, `B, `C 123] 10 | 11 | const main = { 12 | for v : a 13 | match v 14 | | `A: std.put("A ") 15 | | `B: std.put("B ") 16 | | `C x: std.put("C {}\n", x) 17 | ;; 18 | ;; 19 | std.put("\n") 20 | } 21 | 22 | -------------------------------------------------------------------------------- /test/union-extraarg.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* 3 | should fail to compile becuse 4 | we're constructing a union that 5 | with too many arguments. 6 | */ 7 | type u = union 8 | `Foo 9 | ;; 10 | 11 | const main = { 12 | `Foo 123 13 | } 14 | -------------------------------------------------------------------------------- /test/union-missingarg.myr: -------------------------------------------------------------------------------- 1 | use std 2 | type u = union 3 | `Foo int 4 | ;; 5 | 6 | const main = { 7 | `Foo 8 | } 9 | -------------------------------------------------------------------------------- /test/union.myr: -------------------------------------------------------------------------------- 1 | type u = union 2 | `Some int 3 | `None 4 | ;; 5 | 6 | const main = { 7 | var v : u 8 | 9 | v = `None 10 | } 11 | -------------------------------------------------------------------------------- /test/usedef.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | /* 4 | should fail to compile because 'a' is used 5 | before it is defined. 6 | */ 7 | const main = { 8 | var a : int 9 | std.exit(a) 10 | } 11 | -------------------------------------------------------------------------------- /test/voidarg.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | var x : void 5 | 6 | 7 | std.put("{}\n", f(x, 1, void, 2)) 8 | } 9 | 10 | const f = {v1, n1, v2, n2 11 | -> n1 + n2 12 | } 13 | -------------------------------------------------------------------------------- /test/voidassign.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | var x : void 5 | 6 | x = f() 7 | } 8 | 9 | const f = { 10 | std.put("ok\n") 11 | } 12 | 13 | -------------------------------------------------------------------------------- /test/voidcall.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* checks that calling void functions works. should compile, and not die 3 | when running. the exit value is 12, but it's really a dummy. */ 4 | const f = { 5 | var a 6 | 7 | a = a + 1 8 | } 9 | 10 | const main = { 11 | f() 12 | std.exit(12) 13 | } 14 | -------------------------------------------------------------------------------- /test/voideffect.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const bar = { 4 | std.put("pass") 5 | } 6 | 7 | const foo = { 8 | -> bar() 9 | } 10 | 11 | const main = { 12 | foo() 13 | } 14 | -------------------------------------------------------------------------------- /test/voidmatch.myr: -------------------------------------------------------------------------------- 1 | use std 2 | 3 | const main = { 4 | match `std.Some void 5 | | `std.Some x: std.put("ok\n") 6 | | `std.None: std.put("fail\n") 7 | ;; 8 | } 9 | -------------------------------------------------------------------------------- /test/zwidencast.myr: -------------------------------------------------------------------------------- 1 | use std 2 | /* should zero-extend u when casting to v, returning 99 */ 3 | const main = { 4 | var u : uint8 5 | var v : uint32 6 | 7 | u = 99 8 | v = (u : uint32) 9 | std.exit((v : int)) 10 | } 11 | -------------------------------------------------------------------------------- /u.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/u.json -------------------------------------------------------------------------------- /u1.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/u1.json -------------------------------------------------------------------------------- /u1x.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oridb/mc/74d91a0021de012908cfdb35fb61a1473a376130/u1x.json -------------------------------------------------------------------------------- /util/Makefile: -------------------------------------------------------------------------------- 1 | LIB=libutil.a 2 | OBJ= \ 3 | alloc.o \ 4 | bitset.o \ 5 | htab.o \ 6 | pack.o \ 7 | util.o \ 8 | 9 | include ../mk/lexyacc.mk 10 | include ../mk/c.mk 11 | -------------------------------------------------------------------------------- /util/mkfile: -------------------------------------------------------------------------------- 1 |