├── tests ├── 404 │ ├── function.jou │ ├── type.jou │ ├── file_missing_extension.jou │ ├── generic_class_1.jou │ ├── number_underscore_prefix.jou │ ├── char.jou │ ├── generic_class_2.jou │ ├── var.jou │ ├── decorator.jou │ ├── file.jou │ ├── var_addressof.jou │ ├── enum.jou │ ├── python_print_function.jou │ ├── embed_file.jou │ ├── enum_member.jou │ ├── class_field.jou │ ├── python_input_function.jou │ ├── match_function.jou │ ├── method_on_class.jou │ ├── stderr.jou │ ├── stdout.jou │ ├── compile_time_constant.jou │ ├── stdin.jou │ ├── char_array_corner_case.jou │ ├── type_array.jou │ └── indirect_import_symbol.jou ├── data │ ├── empty_file │ ├── hellohellohello.txt │ ├── hellohellohello.xz │ └── zeros.bin ├── other_errors │ ├── imported │ │ ├── func1.jou │ │ ├── func2.jou │ │ ├── typedef.jou │ │ └── class_named_func.jou │ ├── source_file_contain_zero_byte.jou │ ├── assert_fail_compile_time.jou │ ├── const_missing_value.jou │ ├── empty_array.jou │ ├── cyclic_typedef.jou │ ├── dumb_assignment.jou │ ├── array0.jou │ ├── cyclic_const.jou │ ├── self_assign_in_function.jou │ ├── self_use_in_function.jou │ ├── assign_to_WINDOWS.jou │ ├── assert_cannot_compile_time_evaluate.jou │ ├── duplicate_arg_name.jou │ ├── duplicate_enum_member.jou │ ├── address_off_1.jou │ ├── assign_to_NULL.jou │ ├── assign_to_string.jou │ ├── embed_file_empty.jou │ ├── self_declare_local_var_in_function.jou │ ├── assign_to_ternary.jou │ ├── double_import.jou │ ├── none_ptr.jou │ ├── self_assign_in_method.jou │ ├── shadow_WINDOWS.jou │ ├── varargs_def.jou │ ├── void_as_type.jou │ ├── dumb_assignment_with_plusequals.jou │ ├── shadow_var.jou │ ├── double_plusplus.jou │ ├── dynamic_array_length.jou │ ├── noreturn_as_type.jou │ ├── self_declare_local_var_in_method.jou │ ├── shadow_const.jou │ ├── assert_missing_import.jou │ ├── import_it_self.jou │ ├── assign_to_array_count.jou │ ├── assign_to_const_int.jou │ ├── assign_to_enum.jou │ ├── const_cannot_evaluate.jou │ ├── instantiation_dupe.jou │ ├── missing_value_in_return_function.jou │ ├── return_void_function.jou │ ├── unexpected_return_value_function.jou │ ├── assign_to_const_string.jou │ ├── assign_to_enum_count.jou │ ├── noreturn_but_return_without_value.jou │ ├── address_of_minusminus.jou │ ├── missing_generic.jou │ ├── noreturn_but_return_with_value_function.jou │ ├── using_function_with_none_return.jou │ ├── string_doesnt_fit_to_array.jou │ ├── address_of_function_call.jou │ ├── increment_indirect_addressof_fails.jou │ ├── missing_value_in_return_method.jou │ ├── return_void_method.jou │ ├── unexpected_generic_2.jou │ ├── unexpected_return_value_method.jou │ ├── immediate_member_assign.jou │ ├── redefine_imported_func.jou │ ├── embed_file_cannot_evaluate.jou │ ├── noreturn_but_return_with_value_method.jou │ ├── wrong_num_args.jou │ ├── generic_doing_stuff_with_T.jou │ ├── main_public.jou │ ├── public_method.jou │ ├── unexpected_generic_1.jou │ ├── wrong_num_args_funcptr.jou │ ├── generic_wrong_num_params.jou │ ├── using_method_with_none_return.jou │ ├── import_conflict.jou │ ├── assign_to_method.jou │ ├── funcptr_method.jou │ ├── self_take_arg.jou │ ├── address_of_method_call.jou │ ├── import_private_class.jou │ ├── import_private_global_var.jou │ ├── missing_main_function.jou │ ├── import_conflict_function_and_class.jou │ ├── import_private_enum.jou │ ├── import_private_global_var_declare.jou │ ├── import_private_const.jou │ ├── field_of_a_field_of_a_field_error.jou │ ├── import_private_function.jou │ ├── funcptr_method_ptr.jou │ ├── imported_error.jou │ ├── match_missing_1.jou │ ├── python_init_method.jou │ ├── assert_fail.jou │ ├── match_missing_1_or.jou │ ├── generic_zero_params.jou │ ├── runtime_return_1.jou │ ├── assert_fail_multiline.jou │ ├── match_missing_2.jou │ ├── func_then_method.jou │ ├── match_twice.jou │ ├── instantiation_address_of_field.jou │ ├── array_literal_as_a_pointer.jou │ ├── function_call_indexing.jou │ ├── match_enum_too_dynamic.jou │ └── multiple_union_members_given.jou ├── should_succeed │ ├── eof_newline_and_space.jou │ ├── imported │ │ ├── public_global.jou │ │ ├── generic.jou │ │ ├── magic_constant.jou │ │ ├── point_factory.jou │ │ ├── typedef.jou │ │ ├── cycle.jou │ │ ├── level1 │ │ │ └── level2 │ │ │ │ └── deep.jou │ │ ├── samename1.jou │ │ └── samename2.jou │ ├── noreturn_function.jou │ ├── eof_no_newline.jou │ ├── deep_import.jou │ ├── assign.jou │ ├── cast_between_ptr_and_long.jou │ ├── unused_const.jou │ ├── const_enum_count.jou │ ├── public_hello_printer.jou │ ├── noreturn_method.jou │ ├── assert_success.jou │ ├── unicode_varname.jou │ ├── enum_and_local_var.jou │ ├── main_funny_arg_names.jou │ ├── unused_class.jou │ ├── crlf.jou │ ├── unused_typedef.jou │ ├── expfloat.jou │ ├── function_and_var_same_name.jou │ ├── link_with_liblzma_dynamic.jou │ ├── unused_enum.jou │ ├── unused_global.jou │ ├── sscanf.jou │ ├── link_with_liblzma_relative_path.jou │ ├── indirect_method_import.jou │ ├── return_string.jou │ ├── stderr.jou │ ├── double_dotdot_import │ │ └── more_nesting │ │ │ └── double_dotdot_import.jou │ ├── typedef_bug.jou │ ├── not_warning.jou │ ├── string_initialize_byte_array.jou │ ├── loop_variable_reused_warning.jou │ ├── empty_class.jou │ ├── array_size_const.jou │ ├── funcptr.jou │ ├── pass.jou │ ├── return_none.jou │ ├── shadow_function.jou │ ├── bool_eq_bool.jou │ ├── unused_function.jou │ ├── argument.jou │ ├── link_with_liblzma_system_path.jou │ ├── global.jou │ └── import_cycle.jou ├── syntax_error │ ├── bad_toplevel_statement.jou │ ├── float.jou │ ├── bad_statement.jou │ ├── typedef_bad_type.jou │ ├── arrow_method.jou │ ├── bad_byte.jou │ ├── bad_class_field_name.jou │ ├── const_missing_name.jou │ ├── local_var_comma.jou │ ├── mismatched_close_brace.jou │ ├── arrow_field.jou │ ├── bad_type.jou │ ├── import1.jou │ ├── c_not.jou │ ├── double_point5.jou │ ├── ee.jou │ ├── indexing.jou │ ├── typedef_bad_name.jou │ ├── unknown_escape_ascii.jou │ ├── array_size.jou │ ├── bad_class_name.jou │ ├── bad_expression.jou │ ├── c_and.jou │ ├── c_or.jou │ ├── class_default.jou │ ├── double_5point.jou │ ├── double_point5_exp.jou │ ├── let_without_type.jou │ ├── ternary.jou │ ├── too_many_closing_parens.jou │ ├── typedef_c_syntax.jou │ ├── var_without_type.jou │ ├── bad_enum_member.jou │ ├── bad_field.jou │ ├── class_missing_type.jou │ ├── dot_after_e.jou │ ├── let_with_type.jou │ ├── var_with_type.jou │ ├── arg_default.jou │ ├── bad_argument_name.jou │ ├── bad_array.jou │ ├── double_5point_exp.jou │ ├── indentation_not4.jou │ ├── no_break_space.jou │ ├── string_bad_hex.jou │ ├── typedef_missing_eq.jou │ ├── union_1only.jou │ ├── 2bad.jou │ ├── bad_function_name_after_def.jou │ ├── call_missing_comma.jou │ ├── dotdotdot_dotdotdot.jou │ ├── double_assignment.jou │ ├── generic_missing_comma_define.jou │ ├── match_bad_with.jou │ ├── missing_number_after_e.jou │ ├── bad_union_member_name.jou │ ├── import_with_extra_crap_at_end.jou │ ├── missing_arg_type.jou │ ├── missing_args_function.jou │ ├── missing_global_keyword_type.jou │ ├── missing_global_keyword_value.jou │ ├── missing_number_after_eminus.jou │ ├── number_underscore_suffix.jou │ ├── python_style_unpack.jou │ ├── 0b2.jou │ ├── double_not.jou │ ├── keyword_int.jou │ ├── multidot_float.jou │ ├── number_underscore_prefix_oct.jou │ ├── number_underscore_suffix_oct.jou │ ├── double_assignment_comma_typed.jou │ ├── double_with_letters_after.jou │ ├── import_missing_quotes.jou │ ├── keyword_bool.jou │ ├── keyword_byte.jou │ ├── keyword_float.jou │ ├── keyword_int16.jou │ ├── keyword_int32.jou │ ├── keyword_int64.jou │ ├── keyword_int8.jou │ ├── keyword_uint8.jou │ ├── missing_global_keyword_type_and_value.jou │ ├── missing_indentation.jou │ ├── number_underscore_prefix_hex.jou │ ├── number_underscore_suffix_hex.jou │ ├── string_zero_byte.jou │ ├── arg_after_dotdotdot.jou │ ├── funcptr.jou │ ├── generic_bad_typevar.jou │ ├── generic_zero_params_define.jou │ ├── keyword_double.jou │ ├── keyword_uint16.jou │ ├── keyword_uint32.jou │ ├── keyword_uint64.jou │ ├── mark_print_as_public.jou │ ├── self_not_first.jou │ ├── string_zero_byte_hex.jou │ ├── unnecessary_quote_escape_byte.jou │ ├── None_as_value.jou │ ├── bad_method_name_after_def.jou │ ├── funcptr_junk_after_arg.jou │ ├── local_vars_comma.jou │ ├── local_vars_comma_assign.jou │ ├── missing_args_method.jou │ ├── missing_colon.jou │ ├── missing_return_type_funcptr.jou │ ├── unnecessary_quote_escape_string.jou │ ├── chained_eq.jou │ ├── dotdotdot_dotdotdot_funcptr.jou │ ├── import_missing_dot.jou │ ├── missing_array_size_byte.jou │ ├── zig_pointer_type.jou │ ├── L_suffix.jou │ ├── else_if.jou │ ├── union_default.jou │ ├── zig_array_type.jou │ ├── arg_after_dotdotdot_funcptr.jou │ ├── empty_byte_literal.jou │ ├── chained_le.jou │ ├── hex.jou │ ├── overlong_char.jou │ ├── bin.jou │ ├── triple_equals.jou │ ├── utf8_multibyte_char.jou │ ├── first_line_indent.jou │ ├── missing_field_names.jou │ ├── missing_return_type_function.jou │ ├── triple_not_equals.jou │ ├── global_missing_type_and_value.jou │ ├── type_bad_parentheses.jou │ ├── missing_array_size_class.jou │ ├── funcptr_named_arg.jou │ ├── missing_return_type_method.jou │ ├── python_cast_int.jou │ ├── python_cast_byte.jou │ ├── tab.jou │ ├── missing_self.jou │ ├── python_cast_int64.jou │ ├── python_style_for.jou │ ├── python_cast_uint64.jou │ ├── missing_second_equal_sign.jou │ ├── class_init_js_syntax.jou │ ├── missing_end_quote_in_byte.jou │ ├── missing_end_quote_in_string.jou │ ├── match_bad_case_parens.jou │ ├── match_no_case_keyword.jou │ ├── generic_missing_comma_use.jou │ ├── double_with_E.jou │ ├── string_continue_on_next_line.jou │ ├── assign_to_None.jou │ ├── double_assignment_comma_untyped.jou │ ├── match_bad_case.jou │ ├── double_plus.jou │ ├── too_many_opening_parens.jou │ ├── unknown_escape_multibyte.jou │ ├── and_or_chaining.jou │ ├── match_underscore_not_last.jou │ ├── declare_global_with_value.jou │ └── array_length_from_type.jou ├── too_long │ ├── byte_const.jou │ ├── int.jou │ ├── int_const.jou │ ├── too_big_for_64bit_const.jou │ ├── too_big_for_64bit.jou │ ├── uint64_vs_int64_const.jou │ ├── byte.jou │ ├── uint64_vs_int64.jou │ ├── huge_int_const.jou │ ├── name.jou │ └── huge_int.jou ├── wrong_place │ ├── break_outside_function.jou │ ├── continue_outside_function.jou │ ├── return_outside_function.jou │ ├── increment2_outside_function.jou │ ├── increment1_outside_function.jou │ ├── return_in_class.jou │ ├── self_outside_class.jou │ ├── break_outside_loop.jou │ ├── continue_outside_loop.jou │ ├── import_in_class.jou │ ├── union_outside_class.jou │ ├── while_loop_outside_function.jou │ ├── for_loop_outside_function.jou │ ├── link_in_class.jou │ ├── import_in_function.jou │ ├── nested_function.jou │ ├── call_outside_function.jou │ ├── link_in_function.jou │ ├── match_outside_function.jou │ ├── nested_class.jou │ ├── typedef_in_class.jou │ ├── assert_in_class_body.jou │ ├── define_global_var_in_class.jou │ ├── import_after_def.jou │ ├── call_in_class.jou │ ├── class_in_function.jou │ ├── declare_global_var_in_class.jou │ ├── typedef_in_function.jou │ ├── declare_function_in_class.jou │ ├── declare_global_var_in_function.jou │ ├── define_global_var_in_function.jou │ ├── import_in_method.jou │ ├── const_in_function.jou │ ├── declare_function_in_function.jou │ ├── link_in_method.jou │ ├── enum_inside_class.jou │ ├── global_in_function_python_style.jou │ ├── typedef_in_method.jou │ ├── class_in_method.jou │ ├── define_global_var_in_method.jou │ ├── declare_global_var_in_method.jou │ ├── enum_inside_function.jou │ ├── declare_function_in_method.jou │ ├── global_in_method_python_style.jou │ ├── enum_inside_method.jou │ └── class_union_after_method.jou ├── wrong_type │ ├── assert_compile_time.jou │ ├── and_const.jou │ ├── not_const.jou │ ├── embed_file_1.jou │ ├── or_const.jou │ ├── const.jou │ ├── bitwise_not.jou │ ├── bitwise_not_bool.jou │ ├── bool_main.jou │ ├── main_returns_none.jou │ ├── and.jou │ ├── bitwise_not_double.jou │ ├── bitwise_xor.jou │ ├── cannot_be_indexed.jou │ ├── link_int.jou │ ├── bitwise_xor_double.jou │ ├── bitwise_xor_doubles.jou │ ├── index.jou │ ├── mod.jou │ ├── plusplus.jou │ ├── ternary_condition.jou │ ├── array_with_hint.jou │ ├── bitwise_and_double.jou │ ├── bitwise_or_double.jou │ ├── bool_plus_bool.jou │ ├── global_initial.jou │ ├── if.jou │ ├── neg.jou │ ├── not_a_function.jou │ ├── array_mixed_types.jou │ ├── assert.jou │ ├── bitwise_and_doubles.jou │ ├── bitwise_or_doubles.jou │ ├── bitwise_shift_left.jou │ ├── array_count.jou │ ├── assign_with_type.jou │ ├── bitwise_shift_right.jou │ ├── deref_non_pointer.jou │ ├── inplace_bitwise_xor_double_value.jou │ ├── inplace_bitwise_xor_doubles.jou │ ├── not.jou │ ├── while.jou │ ├── array_mixed_types_ptr.jou │ ├── bitwise_shift_left_double_lhs.jou │ ├── bitwise_shift_left_double_rhs.jou │ ├── bitwise_shift_left_doubles.jou │ ├── bitwise_shift_right_double_lhs.jou │ ├── bitwise_shift_right_double_rhs.jou │ ├── inplace_bitwise_xor_double_variable.jou │ ├── inplace_mul_str_str.jou │ ├── ternary_values.jou │ ├── var_assignment.jou │ ├── arg_funcptr.jou │ ├── assign_none_return_funcptr.jou │ ├── bitwise_shift_right_doubles.jou │ ├── explicit_array_to_pointer_cast.jou │ ├── for.jou │ ├── assign_none_return.jou │ ├── deref_array.jou │ ├── inplace_bitwise_and_double_value.jou │ ├── inplace_bitwise_and_doubles.jou │ ├── inplace_bitwise_or_double_value.jou │ ├── inplace_bitwise_or_double_variable.jou │ ├── inplace_bitwise_or_doubles.jou │ ├── inplace_bitwise_shift_left.jou │ ├── inplace_bitwise_shift_right.jou │ ├── pointer_eq.jou │ ├── inplace_bitwise_and_double_variable.jou │ ├── or.jou │ ├── enum_count.jou │ ├── inplace_add_str_int.jou │ ├── inplace_bitwise_shift_left_double_value.jou │ ├── inplace_bitwise_shift_left_doubles.jou │ ├── inplace_bitwise_shift_right_double_value.jou │ ├── inplace_bitwise_shift_right_doubles.jou │ ├── pointer_assignment.jou │ ├── self_annotation.jou │ ├── inplace_bitwise_shift_left_double_variable.jou │ ├── inplace_bitwise_shift_right_double_variable.jou │ ├── inplace_bitwise_xor.jou │ ├── arg.jou │ ├── elif.jou │ ├── inplace_bitwise_and.jou │ ├── inplace_bitwise_or.jou │ ├── brace_init_arg.jou │ ├── class_member_init.jou │ ├── enum_to_int.jou │ ├── instantiate_enum.jou │ ├── instantiate_int_typedef.jou │ ├── return_value_function.jou │ ├── arg_varargs.jou │ ├── dot_operator_int.jou │ ├── int_to_enum.jou │ ├── dot_operator_int_call.jou │ ├── voidptr_increment.jou │ ├── bitwise_or.jou │ ├── class_member_assign.jou │ ├── pointer_to_int.jou │ ├── voidptr_index.jou │ ├── bitwise_and.jou │ ├── funcptr_ptr1.jou │ ├── main_1_arg.jou │ ├── ternary_values_with_type_hint.jou │ ├── dot_operator_intptr.jou │ ├── float_and_double.jou │ ├── funcptr_array1.jou │ ├── return_value_method.jou │ ├── dot_operator_intptr_call.jou │ ├── using_class_like_enum.jou │ ├── funcptr_ptr2.jou │ ├── main_argc.jou │ ├── main_argv.jou │ ├── arg_varargs_funcptr.jou │ ├── funcptr_array2.jou │ ├── assign_to_deref_non_pointer.jou │ ├── main_3_args.jou │ ├── match_bool.jou │ ├── match_with_arg1.jou │ ├── funcptr_different_return_type.jou │ ├── match_function_num_args.jou │ ├── funcptr_different_return_type_none.jou │ ├── funcptr_different_varargs.jou │ ├── match_string_without_strcmp.jou │ ├── match_with_arg2.jou │ ├── enum_as_vararg.jou │ ├── funcptr_different_arg_type.jou │ ├── match_function_return_none.jou │ ├── enums_mix_eq.jou │ ├── funcptr_different_num_args.jou │ ├── match_class.jou │ ├── match_function_return_type.jou │ ├── method_arg.jou │ ├── match_float.jou │ ├── match_wrong_enum.jou │ ├── funcptr_different_noreturn.jou │ ├── inplace_add_doesnt_go_back.jou │ ├── uint16_instead_of_byte.jou │ ├── match_function_varargs.jou │ ├── sort_comparator.jou │ └── complex_funcptr_error.jou ├── already_exists_error │ ├── class_field.jou │ ├── class_windows.jou │ ├── const_windows.jou │ ├── const.jou │ ├── local_var.jou │ ├── global_var.jou │ ├── class.jou │ ├── const_and_global_var.jou │ ├── global_var_and_const.jou │ ├── union_member_duplicate.jou │ ├── class_and_enum.jou │ ├── class_and_typedef.jou │ ├── enum_and_class.jou │ ├── local_variable_windows.jou │ ├── typedef_and_class.jou │ ├── class_field_and_method.jou │ ├── enum.jou │ ├── func.jou │ ├── method_and_class_field.jou │ ├── class_import.jou │ ├── class_field_and_union_member.jou │ ├── union_member_and_class_field.jou │ ├── func_import.jou │ ├── method.jou │ ├── class_import_redefine_as_generic.jou │ ├── method_and_union_member.jou │ ├── union_member.jou │ ├── union_member_and_method.jou │ ├── class_and_function.jou │ ├── const_import.jou │ ├── global_var_import.jou │ ├── global_var_import_and_const.jou │ └── class_import_redefine_generic_as_normal.jou └── crash │ └── null_deref.jou ├── examples ├── aoc2025 │ ├── day11 │ │ ├── .gitignore │ │ ├── sampleinput.txt │ │ ├── sampleinput2.txt │ │ └── to_graphviz.sh │ ├── day09 │ │ └── sampleinput.txt │ ├── day03 │ │ └── sampleinput.txt │ ├── day06 │ │ └── sampleinput.txt │ ├── day01 │ │ └── sampleinput.txt │ ├── day05 │ │ └── sampleinput.txt │ ├── day04 │ │ └── sampleinput.txt │ ├── day02 │ │ └── sampleinput.txt │ ├── day10 │ │ └── sampleinput.txt │ ├── day08 │ │ └── sampleinput.txt │ └── day07 │ │ └── sampleinput.txt ├── aoc2024 │ ├── day11 │ │ └── sampleinput.txt │ ├── day24 │ │ └── .gitignore │ ├── day09 │ │ └── sampleinput.txt │ ├── day22 │ │ ├── sampleinput2.txt │ │ └── sampleinput1.txt │ ├── day21 │ │ └── sampleinput.txt │ ├── day01 │ │ └── sampleinput.txt │ ├── day12 │ │ ├── sampleinput2.txt │ │ └── sampleinput1.txt │ ├── day03 │ │ ├── sampleinput1.txt │ │ └── sampleinput2.txt │ ├── day02 │ │ └── sampleinput.txt │ ├── day17 │ │ ├── sampleinput1.txt │ │ └── sampleinput2.txt │ ├── day10 │ │ └── sampleinput.txt │ ├── day15 │ │ ├── sampleinput2-simple.txt │ │ └── sampleinput1.txt │ ├── day19 │ │ └── sampleinput.txt │ ├── day04 │ │ ├── part2_templates.txt │ │ └── sampleinput.txt │ ├── day06 │ │ └── sampleinput.txt │ ├── day07 │ │ └── sampleinput.txt │ ├── day08 │ │ └── sampleinput.txt │ ├── day14 │ │ └── sampleinput.txt │ ├── day18 │ │ └── sampleinput.txt │ ├── day16 │ │ └── sampleinput.txt │ ├── day20 │ │ └── sampleinput.txt │ ├── day13 │ │ └── sampleinput.txt │ ├── day05 │ │ └── sampleinput.txt │ ├── day23 │ │ └── sampleinput.txt │ └── day25 │ │ └── sampleinput.txt ├── aoc2022 │ ├── day02 │ │ └── sampleinput.txt │ ├── day04 │ │ └── sampleinput.txt │ ├── day01 │ │ └── sampleinput.txt │ ├── day05 │ │ └── sampleinput.txt │ ├── day03 │ │ └── sampleinput.txt │ ├── day06 │ │ └── sampleinput.txt │ └── day07 │ │ └── sampleinput.txt ├── aoc2023 │ ├── day10 │ │ ├── sampleinput.txt │ │ └── sampleinput2.txt │ ├── day06 │ │ └── sampleinput.txt │ ├── day01 │ │ ├── sampleinput.txt │ │ └── sampleinput2.txt │ ├── day09 │ │ └── sampleinput.txt │ ├── day15 │ │ └── sampleinput.txt │ ├── day07 │ │ └── sampleinput.txt │ ├── day08 │ │ ├── sampleinput2.txt │ │ ├── sampleinput.txt │ │ └── sampleinput3.txt │ ├── day20 │ │ ├── sampleinput.txt │ │ └── visualize.sh │ ├── day22 │ │ └── sampleinput.txt │ ├── day24 │ │ └── sampleinput.txt │ ├── day12 │ │ └── sampleinput.txt │ ├── day03 │ │ └── sampleinput.txt │ ├── day11 │ │ └── sampleinput.txt │ ├── day14 │ │ └── sampleinput.txt │ ├── day16 │ │ └── sampleinput.txt │ ├── day21 │ │ └── sampleinput.txt │ ├── day13 │ │ └── sampleinput.txt │ ├── day17 │ │ └── sampleinput.txt │ ├── day25 │ │ └── sampleinput.txt │ ├── day18 │ │ └── sampleinput.txt │ ├── day04 │ │ └── sampleinput.txt │ ├── day02 │ │ └── sampleinput.txt │ └── day19 │ │ └── sampleinput.txt ├── hello.jou ├── memory_leak.jou ├── hello_minimal.jou ├── fib.jou └── sort.jou ├── vm └── .gitignore ├── .gitattributes ├── Makefile ├── doc └── compiler_internals │ └── images │ ├── design.odg │ ├── design.png │ └── libreoffice-to-png ├── stdlib └── intnative.jou ├── activate └── .github └── workflows └── linux-i686.yml /tests/data/empty_file: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/aoc2025/day11/.gitignore: -------------------------------------------------------------------------------- 1 | graph.png 2 | -------------------------------------------------------------------------------- /tests/data/hellohellohello.txt: -------------------------------------------------------------------------------- 1 | hellohellohello -------------------------------------------------------------------------------- /vm/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore all subfolders 2 | */ 3 | -------------------------------------------------------------------------------- /examples/aoc2024/day11/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 125 17 2 | -------------------------------------------------------------------------------- /examples/aoc2024/day24/.gitignore: -------------------------------------------------------------------------------- 1 | asd.txt 2 | asd.png 3 | -------------------------------------------------------------------------------- /examples/aoc2022/day02/sampleinput.txt: -------------------------------------------------------------------------------- 1 | A Y 2 | B X 3 | C Z 4 | -------------------------------------------------------------------------------- /examples/aoc2024/day09/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 2333133121414131402 2 | -------------------------------------------------------------------------------- /examples/aoc2024/day22/sampleinput2.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 2024 5 | -------------------------------------------------------------------------------- /examples/aoc2024/day22/sampleinput1.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 10 3 | 100 4 | 2024 5 | -------------------------------------------------------------------------------- /examples/aoc2024/day21/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 029A 2 | 980A 3 | 179A 4 | 456A 5 | 379A 6 | -------------------------------------------------------------------------------- /examples/aoc2023/day10/sampleinput.txt: -------------------------------------------------------------------------------- 1 | ..... 2 | .S-7. 3 | .|.|. 4 | .L-J. 5 | ..... 6 | -------------------------------------------------------------------------------- /tests/other_errors/imported/func1.jou: -------------------------------------------------------------------------------- 1 | @public 2 | def func() -> None: 3 | pass 4 | -------------------------------------------------------------------------------- /tests/other_errors/imported/func2.jou: -------------------------------------------------------------------------------- 1 | @public 2 | def func() -> None: 3 | pass 4 | -------------------------------------------------------------------------------- /tests/other_errors/imported/typedef.jou: -------------------------------------------------------------------------------- 1 | @public 2 | typedef StringyString = byte* 3 | -------------------------------------------------------------------------------- /tests/should_succeed/eof_newline_and_space.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | return 0 3 | -------------------------------------------------------------------------------- /tests/syntax_error/bad_toplevel_statement.jou: -------------------------------------------------------------------------------- 1 | 92 # Error: not a valid statement 2 | -------------------------------------------------------------------------------- /examples/aoc2023/day06/sampleinput.txt: -------------------------------------------------------------------------------- 1 | Time: 7 15 30 2 | Distance: 9 40 200 3 | -------------------------------------------------------------------------------- /tests/other_errors/imported/class_named_func.jou: -------------------------------------------------------------------------------- 1 | @public 2 | class func: 3 | pass 4 | -------------------------------------------------------------------------------- /tests/should_succeed/imported/public_global.jou: -------------------------------------------------------------------------------- 1 | @public 2 | global public_global: int 3 | -------------------------------------------------------------------------------- /tests/too_long/byte_const.jou: -------------------------------------------------------------------------------- 1 | const b: byte = 300 # Error: value does not fit into byte 2 | -------------------------------------------------------------------------------- /examples/aoc2023/day01/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 1abc2 2 | pqr3stu8vwx 3 | a1b2c3d4e5f 4 | treb7uchet 5 | -------------------------------------------------------------------------------- /examples/aoc2023/day09/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 0 3 6 9 12 15 2 | 1 3 6 10 15 21 3 | 10 13 16 21 30 45 4 | -------------------------------------------------------------------------------- /examples/aoc2023/day15/sampleinput.txt: -------------------------------------------------------------------------------- 1 | rn=1,cm-,qp=3,cm=2,qp-,pc=4,ot=9,ab=5,pc-,pc=6,ot=7 2 | -------------------------------------------------------------------------------- /examples/aoc2024/day01/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 3 4 2 | 4 3 3 | 2 5 4 | 1 3 5 | 3 9 6 | 3 3 7 | -------------------------------------------------------------------------------- /tests/404/function.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | lol('x') # Error: function 'lol' not found 3 | -------------------------------------------------------------------------------- /tests/404/type.jou: -------------------------------------------------------------------------------- 1 | def foo() -> asd: # Error: there is no type named 'asd' 2 | return 1 3 | -------------------------------------------------------------------------------- /tests/syntax_error/float.jou: -------------------------------------------------------------------------------- 1 | 123abc45f # Error: invalid number or variable name "123abc45f" 2 | -------------------------------------------------------------------------------- /tests/data/hellohellohello.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akuli/jou/HEAD/tests/data/hellohellohello.xz -------------------------------------------------------------------------------- /tests/other_errors/source_file_contain_zero_byte.jou: -------------------------------------------------------------------------------- 1 | # Error: source file contains a zero byte 2 | -------------------------------------------------------------------------------- /tests/should_succeed/imported/generic.jou: -------------------------------------------------------------------------------- 1 | @public 2 | class Point2D[T]: 3 | x: T 4 | y: T 5 | -------------------------------------------------------------------------------- /tests/should_succeed/imported/magic_constant.jou: -------------------------------------------------------------------------------- 1 | @public 2 | const MAGIC_CONSTANT: int = 0x6a6f75 3 | -------------------------------------------------------------------------------- /tests/syntax_error/bad_statement.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | 5 # Error: not a valid statement 3 | -------------------------------------------------------------------------------- /tests/syntax_error/typedef_bad_type.jou: -------------------------------------------------------------------------------- 1 | typedef lol = 123 # Error: expected a type, got an integer 2 | -------------------------------------------------------------------------------- /tests/wrong_place/break_outside_function.jou: -------------------------------------------------------------------------------- 1 | break # Error: 'break' can only be used inside a loop 2 | -------------------------------------------------------------------------------- /tests/wrong_type/assert_compile_time.jou: -------------------------------------------------------------------------------- 1 | assert 123 # Error: assertion must be a bool, not int 2 | -------------------------------------------------------------------------------- /examples/aoc2023/day07/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 32T3K 765 2 | T55J5 684 3 | KK677 28 4 | KTJJT 220 5 | QQQJA 483 6 | -------------------------------------------------------------------------------- /examples/aoc2024/day12/sampleinput2.txt: -------------------------------------------------------------------------------- 1 | AAAAAA 2 | AAABBA 3 | AAABBA 4 | ABBAAA 5 | ABBAAA 6 | AAAAAA 7 | -------------------------------------------------------------------------------- /examples/aoc2025/day09/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 7,1 2 | 11,1 3 | 11,7 4 | 9,7 5 | 9,5 6 | 2,5 7 | 2,3 8 | 7,3 9 | -------------------------------------------------------------------------------- /tests/other_errors/assert_fail_compile_time.jou: -------------------------------------------------------------------------------- 1 | assert WINDOWS and MACOS # Error: assertion is False 2 | -------------------------------------------------------------------------------- /tests/other_errors/const_missing_value.jou: -------------------------------------------------------------------------------- 1 | const x: int # Error: constants must have an initial value 2 | -------------------------------------------------------------------------------- /tests/other_errors/empty_array.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = [] # Error: arrays cannot be empty 3 | -------------------------------------------------------------------------------- /tests/syntax_error/arrow_method.jou: -------------------------------------------------------------------------------- 1 | def main() -> None: 2 | foo->bar() # Error: use . instead of -> 3 | -------------------------------------------------------------------------------- /tests/syntax_error/bad_byte.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | return ` # Error: unexpected byte '`' (0x60) 3 | -------------------------------------------------------------------------------- /tests/syntax_error/bad_class_field_name.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | 1: int # Error: not a valid statement 3 | -------------------------------------------------------------------------------- /tests/syntax_error/const_missing_name.jou: -------------------------------------------------------------------------------- 1 | const : int = 42 # Error: expected a constant name, got ':' 2 | -------------------------------------------------------------------------------- /tests/syntax_error/local_var_comma.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | x, = 0 # Error: not a valid statement 3 | -------------------------------------------------------------------------------- /tests/syntax_error/mismatched_close_brace.jou: -------------------------------------------------------------------------------- 1 | def foo(} -> None: # Error: '}' without a matching '{' 2 | -------------------------------------------------------------------------------- /tests/wrong_type/and_const.jou: -------------------------------------------------------------------------------- 1 | const foo: int = 1 and 2 # Error: 'and' only works with bools, not int 2 | -------------------------------------------------------------------------------- /tests/wrong_type/not_const.jou: -------------------------------------------------------------------------------- 1 | const x: int = not 1 # Error: value after 'not' must be a bool, not int 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Trick github to highlighting Jou files as Python files. 2 | *.jou linguist-language=python 3 | -------------------------------------------------------------------------------- /examples/aoc2022/day04/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 2-4,6-8 2 | 2-3,4-5 3 | 5-7,7-9 4 | 2-8,3-7 5 | 6-6,4-6 6 | 2-6,4-8 7 | -------------------------------------------------------------------------------- /tests/404/file_missing_extension.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io" # Error: use "stdlib/io.jou" instead of "stdlib/io" 2 | -------------------------------------------------------------------------------- /tests/404/generic_class_1.jou: -------------------------------------------------------------------------------- 1 | def foo() -> asd[int]: # Error: there is no type named 'asd' 2 | return 1 3 | -------------------------------------------------------------------------------- /tests/other_errors/cyclic_typedef.jou: -------------------------------------------------------------------------------- 1 | typedef x = y # Error: type 'x' depends on itself 2 | typedef y = x 3 | -------------------------------------------------------------------------------- /tests/other_errors/dumb_assignment.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | 1 = 1 # Error: cannot assign to a constant 3 | -------------------------------------------------------------------------------- /tests/syntax_error/arrow_field.jou: -------------------------------------------------------------------------------- 1 | def main() -> None: 2 | x = foo->bar # Error: use . instead of -> 3 | -------------------------------------------------------------------------------- /tests/syntax_error/bad_type.jou: -------------------------------------------------------------------------------- 1 | def main() -> 7: # Error: expected a type, got an integer 2 | return 3 | -------------------------------------------------------------------------------- /tests/syntax_error/import1.jou: -------------------------------------------------------------------------------- 1 | import 1 # Error: expected a string to specify the file name, got an integer 2 | -------------------------------------------------------------------------------- /tests/wrong_place/continue_outside_function.jou: -------------------------------------------------------------------------------- 1 | continue # Error: 'continue' can only be used inside a loop 2 | -------------------------------------------------------------------------------- /tests/wrong_place/return_outside_function.jou: -------------------------------------------------------------------------------- 1 | return # Error: 'return' must be inside a function or method 2 | -------------------------------------------------------------------------------- /tests/wrong_type/embed_file_1.jou: -------------------------------------------------------------------------------- 1 | global foo = embed_file(1) # Error: file name must be a string, not int 2 | -------------------------------------------------------------------------------- /tests/wrong_type/or_const.jou: -------------------------------------------------------------------------------- 1 | const foo: bool = False or 123 # Error: 'or' only works with bools, not int 2 | -------------------------------------------------------------------------------- /examples/aoc2023/day08/sampleinput2.txt: -------------------------------------------------------------------------------- 1 | LLR 2 | 3 | AAA = (BBB, BBB) 4 | BBB = (AAA, ZZZ) 5 | ZZZ = (ZZZ, ZZZ) 6 | -------------------------------------------------------------------------------- /examples/aoc2024/day03/sampleinput1.txt: -------------------------------------------------------------------------------- 1 | xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5)) 2 | -------------------------------------------------------------------------------- /examples/aoc2024/day03/sampleinput2.txt: -------------------------------------------------------------------------------- 1 | xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5)) 2 | -------------------------------------------------------------------------------- /examples/aoc2025/day03/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 987654321111111 2 | 811111111111119 3 | 234234234234278 4 | 818181911112111 5 | -------------------------------------------------------------------------------- /examples/aoc2025/day06/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 123 328 51 64 2 | 45 64 387 23 3 | 6 98 215 314 4 | * + * + 5 | -------------------------------------------------------------------------------- /tests/404/number_underscore_prefix.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | return _123 # Error: no variable named '_123' 3 | -------------------------------------------------------------------------------- /tests/other_errors/array0.jou: -------------------------------------------------------------------------------- 1 | def foo(x: int[0]) -> None: # Error: array length must be positive 2 | return 3 | -------------------------------------------------------------------------------- /tests/other_errors/cyclic_const.jou: -------------------------------------------------------------------------------- 1 | const a: int = b # Error: constant 'a' depends on itself 2 | const b: int = a 3 | -------------------------------------------------------------------------------- /tests/should_succeed/noreturn_function.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/process.jou" 2 | 3 | def main() -> int: 4 | exit(0) 5 | -------------------------------------------------------------------------------- /tests/syntax_error/c_not.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | if !x: # Error: use 'not' instead of '!' 3 | pass 4 | -------------------------------------------------------------------------------- /tests/syntax_error/double_point5.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = .5 # Error: expected an expression, got '.' 3 | -------------------------------------------------------------------------------- /tests/syntax_error/ee.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1ee2.3 # Error: invalid number or variable name "1ee2.3" 3 | -------------------------------------------------------------------------------- /tests/syntax_error/indexing.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | asd[lol 123] # Error: expected a ']', got an integer 3 | -------------------------------------------------------------------------------- /tests/syntax_error/typedef_bad_name.jou: -------------------------------------------------------------------------------- 1 | typedef 1 = lol # Error: expected the name for a type, got an integer 2 | -------------------------------------------------------------------------------- /tests/syntax_error/unknown_escape_ascii.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | return '\p' # Error: unknown escape: '\p' 3 | -------------------------------------------------------------------------------- /tests/wrong_place/increment2_outside_function.jou: -------------------------------------------------------------------------------- 1 | x += 2 # Error: assignments must be inside a function or method 2 | -------------------------------------------------------------------------------- /tests/wrong_type/const.jou: -------------------------------------------------------------------------------- 1 | const foo: int = True # Error: constant of type int cannot have a value of type bool 2 | -------------------------------------------------------------------------------- /examples/aoc2024/day02/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 7 6 4 2 1 2 | 1 2 7 8 9 3 | 9 7 6 2 1 4 | 1 3 2 4 5 5 | 8 6 4 4 1 6 | 1 3 6 7 9 7 | -------------------------------------------------------------------------------- /tests/404/char.jou: -------------------------------------------------------------------------------- 1 | def foo(x: char) -> None: # Error: there is no type named 'char', use 'byte' instead 2 | pass 3 | -------------------------------------------------------------------------------- /tests/data/zeros.bin: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/other_errors/self_assign_in_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | self = 0 # Error: 'self' cannot be used here 3 | -------------------------------------------------------------------------------- /tests/other_errors/self_use_in_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = self # Error: 'self' cannot be used here 3 | -------------------------------------------------------------------------------- /tests/syntax_error/array_size.jou: -------------------------------------------------------------------------------- 1 | def foo(x: int[1 2]) # Error: expected a ']' to end the array size, got an integer 2 | -------------------------------------------------------------------------------- /tests/syntax_error/bad_class_name.jou: -------------------------------------------------------------------------------- 1 | class 1: # Error: expected a name for the class, got an integer 2 | bla bla 3 | -------------------------------------------------------------------------------- /tests/syntax_error/bad_expression.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | return -> # Error: expected an expression, got '->' 3 | -------------------------------------------------------------------------------- /tests/syntax_error/c_and.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | if x && y: # Error: use 'and' instead of '&&' 3 | pass 4 | -------------------------------------------------------------------------------- /tests/syntax_error/c_or.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | if x || y: # Error: use 'or' instead of '||' 3 | pass 4 | -------------------------------------------------------------------------------- /tests/syntax_error/class_default.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | num: int = 1 # Error: class fields cannot have default values 3 | -------------------------------------------------------------------------------- /tests/syntax_error/double_5point.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 5. # Error: invalid number or variable name "5." 3 | -------------------------------------------------------------------------------- /tests/syntax_error/double_point5_exp.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = .5e3 # Error: expected an expression, got '.' 3 | -------------------------------------------------------------------------------- /tests/syntax_error/let_without_type.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | let x = 1 # Error: there is no 'let' keyword in Jou 3 | -------------------------------------------------------------------------------- /tests/syntax_error/ternary.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | printf("hello" if True) # Error: expected 'else', got ')' 3 | -------------------------------------------------------------------------------- /tests/syntax_error/too_many_closing_parens.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | bar(1)) # Error: ')' without a matching '(' 3 | -------------------------------------------------------------------------------- /tests/syntax_error/typedef_c_syntax.jou: -------------------------------------------------------------------------------- 1 | typedef int MyInt # Error: expected the name for a type, got the 'int' keyword 2 | -------------------------------------------------------------------------------- /tests/syntax_error/var_without_type.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | var x = 1 # Error: there is no 'var' keyword in Jou 3 | -------------------------------------------------------------------------------- /tests/wrong_place/increment1_outside_function.jou: -------------------------------------------------------------------------------- 1 | x++ # Error: this line of code must be inside a function or method 2 | -------------------------------------------------------------------------------- /tests/wrong_place/return_in_class.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | return # Error: 'return' must be inside a function or method 3 | -------------------------------------------------------------------------------- /tests/wrong_place/self_outside_class.jou: -------------------------------------------------------------------------------- 1 | def foo(self) -> None: # Error: 'self' cannot be used here 2 | return 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_not.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = ~"hello" # Error: cannot take bitwise NOT of byte* 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_not_bool.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = ~True # Error: cannot take bitwise NOT of bool 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bool_main.jou: -------------------------------------------------------------------------------- 1 | def main() -> bool: # Error: the main() function must return int 2 | return true 3 | -------------------------------------------------------------------------------- /tests/wrong_type/main_returns_none.jou: -------------------------------------------------------------------------------- 1 | def main() -> None: # Error: the main() function must return int 2 | return 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ifneq (,$(findstring Windows,$(OS))) 2 | include Makefile.windows 3 | else 4 | include Makefile.posix 5 | endif 6 | -------------------------------------------------------------------------------- /doc/compiler_internals/images/design.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akuli/jou/HEAD/doc/compiler_internals/images/design.odg -------------------------------------------------------------------------------- /doc/compiler_internals/images/design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akuli/jou/HEAD/doc/compiler_internals/images/design.png -------------------------------------------------------------------------------- /examples/aoc2023/day20/sampleinput.txt: -------------------------------------------------------------------------------- 1 | broadcaster -> a 2 | %a -> inv, con 3 | &inv -> b 4 | %b -> con 5 | &con -> output 6 | -------------------------------------------------------------------------------- /examples/aoc2024/day17/sampleinput1.txt: -------------------------------------------------------------------------------- 1 | Register A: 729 2 | Register B: 0 3 | Register C: 0 4 | 5 | Program: 0,1,5,4,3,0 6 | -------------------------------------------------------------------------------- /examples/aoc2024/day17/sampleinput2.txt: -------------------------------------------------------------------------------- 1 | Register A: 2024 2 | Register B: 0 3 | Register C: 0 4 | 5 | Program: 0,3,5,4,3,0 6 | -------------------------------------------------------------------------------- /examples/aoc2025/day01/sampleinput.txt: -------------------------------------------------------------------------------- 1 | L68 2 | L30 3 | R48 4 | L5 5 | R60 6 | L55 7 | L1 8 | L99 9 | R14 10 | L82 11 | -------------------------------------------------------------------------------- /tests/404/generic_class_2.jou: -------------------------------------------------------------------------------- 1 | def foo() -> asd[int, byte]: # Error: there is no generic class named 'asd' 2 | return 1 3 | -------------------------------------------------------------------------------- /tests/404/var.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | putchar(asd) # Error: no variable named 'asd' 5 | -------------------------------------------------------------------------------- /tests/other_errors/assign_to_WINDOWS.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | WINDOWS = False # Error: cannot assign to a constant 3 | -------------------------------------------------------------------------------- /tests/syntax_error/bad_enum_member.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | 123 # Error: expected a name for an enum member, got an integer 3 | -------------------------------------------------------------------------------- /tests/syntax_error/bad_field.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | bar.(1+2) # Error: expected a field or method name, got '(' 3 | -------------------------------------------------------------------------------- /tests/syntax_error/class_missing_type.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | # should be "x: int" 3 | x # Error: not a valid statement 4 | -------------------------------------------------------------------------------- /tests/syntax_error/dot_after_e.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1e2.3 # Error: invalid number or variable name "1e2.3" 3 | -------------------------------------------------------------------------------- /tests/syntax_error/let_with_type.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | let x: int = 1 # Error: there is no 'let' keyword in Jou 3 | -------------------------------------------------------------------------------- /tests/syntax_error/var_with_type.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | var x: int = 1 # Error: there is no 'var' keyword in Jou 3 | -------------------------------------------------------------------------------- /tests/wrong_place/break_outside_loop.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | break # Error: 'break' can only be used inside a loop 3 | -------------------------------------------------------------------------------- /tests/wrong_type/and.jou: -------------------------------------------------------------------------------- 1 | def one_and_two() -> None: 2 | foo = 1 and 2 # Error: 'and' only works with bools, not int 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_not_double.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = ~12.34 # Error: cannot take bitwise NOT of double 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_xor.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1 ^ "hello" # Error: wrong types: cannot xor int and byte* 3 | -------------------------------------------------------------------------------- /tests/wrong_type/cannot_be_indexed.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1["hey"] # Error: value of type int cannot be indexed 3 | -------------------------------------------------------------------------------- /tests/wrong_type/link_int.jou: -------------------------------------------------------------------------------- 1 | link 123 # Error: expected a string of linker flags after the 'link' keyword, got an integer 2 | -------------------------------------------------------------------------------- /examples/aoc2025/day05/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 3-5 2 | 10-14 3 | 16-20 4 | 12-18 5 | 6 | 1 7 | 5 8 | 8 9 | 11 10 | 17 11 | 32 12 | -------------------------------------------------------------------------------- /tests/other_errors/assert_cannot_compile_time_evaluate.jou: -------------------------------------------------------------------------------- 1 | assert lol == wat # Error: cannot evaluate assertion at compile time 2 | -------------------------------------------------------------------------------- /tests/other_errors/duplicate_arg_name.jou: -------------------------------------------------------------------------------- 1 | declare foo(x: int, x: byte) -> None # Error: there are multiple arguments named 'x' 2 | -------------------------------------------------------------------------------- /tests/other_errors/duplicate_enum_member.jou: -------------------------------------------------------------------------------- 1 | enum Blah: 2 | Foo 3 | Foo # Error: the enum has two members named 'Foo' 4 | -------------------------------------------------------------------------------- /tests/syntax_error/arg_default.jou: -------------------------------------------------------------------------------- 1 | def foo(num: int = 1) -> None: # Error: arguments cannot have default values 2 | return 3 | -------------------------------------------------------------------------------- /tests/syntax_error/bad_argument_name.jou: -------------------------------------------------------------------------------- 1 | def f(5) -> None: # Error: expected an argument name, got an integer 2 | return 3 | -------------------------------------------------------------------------------- /tests/syntax_error/bad_array.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = [1 2] # Error: expected a ']' to end the array, got an integer 3 | -------------------------------------------------------------------------------- /tests/syntax_error/double_5point_exp.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 5.e3 # Error: invalid number or variable name "5.e3" 3 | -------------------------------------------------------------------------------- /tests/syntax_error/indentation_not4.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | return 0 # Error: indentation must be a multiple of 4 spaces 3 | -------------------------------------------------------------------------------- /tests/syntax_error/no_break_space.jou: -------------------------------------------------------------------------------- 1 |   # Error: source file contains Unicode whitespace character U+000000A0 NO-BREAK SPACE 2 | -------------------------------------------------------------------------------- /tests/syntax_error/string_bad_hex.jou: -------------------------------------------------------------------------------- 1 | "\xx" # Error: \x must be followed by two hexadecimal digits (0-9, A-F) to specify a byte 2 | -------------------------------------------------------------------------------- /tests/syntax_error/typedef_missing_eq.jou: -------------------------------------------------------------------------------- 1 | typedef lol int # Error: expected '=' between name and type, got the 'int' keyword 2 | -------------------------------------------------------------------------------- /tests/syntax_error/union_1only.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | union: # Error: unions must have at least 2 members 3 | x: int 4 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_xor_double.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1 ^ 2.3 # Error: wrong types: cannot xor int and double 3 | -------------------------------------------------------------------------------- /tests/404/decorator.jou: -------------------------------------------------------------------------------- 1 | @asdf_lolwat_69 # Error: there is no decorator named '@asdf_lolwat_69' 2 | def foo() -> None: 3 | pass 4 | -------------------------------------------------------------------------------- /tests/404/file.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/foobar.jou" # Error: cannot import from "/stdlib/foobar.jou": No such file or directory 2 | -------------------------------------------------------------------------------- /tests/404/var_addressof.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | putchar(&asd) # Error: no variable named 'asd' 5 | -------------------------------------------------------------------------------- /tests/already_exists_error/class_field.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | x: int 3 | x: byte # Error: class Foo already has a field named 'x' 4 | -------------------------------------------------------------------------------- /tests/already_exists_error/class_windows.jou: -------------------------------------------------------------------------------- 1 | class WINDOWS: # Error: a special constant named 'WINDOWS' already exists 2 | pass 3 | -------------------------------------------------------------------------------- /tests/already_exists_error/const_windows.jou: -------------------------------------------------------------------------------- 1 | const WINDOWS: bool = False # Error: a special constant named 'WINDOWS' already exists 2 | -------------------------------------------------------------------------------- /tests/other_errors/address_off_1.jou: -------------------------------------------------------------------------------- 1 | def foo() -> int*: 2 | return &1 # Error: the '&' operator cannot be applied to a constant 3 | -------------------------------------------------------------------------------- /tests/other_errors/assign_to_NULL.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | NULL = "hi" # Error: cannot assign to a constant 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/other_errors/assign_to_string.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | "hi" = "lol" # Error: cannot assign to a constant 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/other_errors/embed_file_empty.jou: -------------------------------------------------------------------------------- 1 | global lol = embed_file("../data/empty_file") # Error: file "tests/data/empty_file" is empty 2 | -------------------------------------------------------------------------------- /tests/other_errors/self_declare_local_var_in_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | self: int # Error: 'self' cannot be used here 3 | -------------------------------------------------------------------------------- /tests/syntax_error/2bad.jou: -------------------------------------------------------------------------------- 1 | def x() -> None: 2 | 2bad = "oh no" # Error: invalid number or variable name "2bad" 3 | return 4 | -------------------------------------------------------------------------------- /tests/syntax_error/bad_function_name_after_def.jou: -------------------------------------------------------------------------------- 1 | def 69() -> None: # Error: expected a function name, got an integer 2 | return 3 | -------------------------------------------------------------------------------- /tests/syntax_error/call_missing_comma.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | printf("hello %d\n" 1) # Error: expected a ')', got an integer 3 | -------------------------------------------------------------------------------- /tests/syntax_error/dotdotdot_dotdotdot.jou: -------------------------------------------------------------------------------- 1 | declare foo(..., ...) -> None # Error: if '...' is used, it must be the last parameter 2 | -------------------------------------------------------------------------------- /tests/syntax_error/double_assignment.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = y = 7 # Error: only one variable can be assigned at a time 3 | -------------------------------------------------------------------------------- /tests/syntax_error/generic_missing_comma_define.jou: -------------------------------------------------------------------------------- 1 | class Foo[T U]: # Error: expected a ']', got a variable name 'U' 2 | pass 3 | -------------------------------------------------------------------------------- /tests/syntax_error/match_bad_with.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | match foo with 1: # Error: expected function name, got an integer 3 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_number_after_e.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 123e # Error: invalid number or variable name "123e" 3 | -------------------------------------------------------------------------------- /tests/wrong_place/continue_outside_loop.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | continue # Error: 'continue' can only be used inside a loop 3 | -------------------------------------------------------------------------------- /tests/wrong_place/import_in_class.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | import "stdlib/io.jou" # Error: imports must be in the beginning of the file 3 | -------------------------------------------------------------------------------- /tests/wrong_place/union_outside_class.jou: -------------------------------------------------------------------------------- 1 | union: # Error: 'union' can only be used inside a class 2 | x: int 3 | y: byte* 4 | -------------------------------------------------------------------------------- /tests/wrong_place/while_loop_outside_function.jou: -------------------------------------------------------------------------------- 1 | while True: # Error: while loop must be inside a function or method 2 | pass 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_xor_doubles.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1.2 ^ 3.4 # Error: wrong types: cannot xor double and double 3 | -------------------------------------------------------------------------------- /tests/wrong_type/index.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = "hey"["hey"] # Error: the index inside [...] must be an integer, not byte* 3 | -------------------------------------------------------------------------------- /tests/wrong_type/mod.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | x = "hey %s" % 1 # Error: wrong types: cannot take remainder with byte* and int 3 | -------------------------------------------------------------------------------- /tests/wrong_type/plusplus.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | yep = True 3 | ++yep # Error: cannot increment a value of type bool 4 | -------------------------------------------------------------------------------- /examples/aoc2024/day10/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 89010123 2 | 78121874 3 | 87430965 4 | 96549874 5 | 45678903 6 | 32019012 7 | 01329801 8 | 10456732 9 | -------------------------------------------------------------------------------- /tests/already_exists_error/const.jou: -------------------------------------------------------------------------------- 1 | const x: int = 1 2 | global x: int # Error: a constant named 'x' already exists (defined on line 1) 3 | -------------------------------------------------------------------------------- /tests/already_exists_error/local_var.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x: int 3 | x: int # Error: a variable named 'x' already exists 4 | -------------------------------------------------------------------------------- /tests/other_errors/assign_to_ternary.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | 1 if True else 2 = 3 # Error: cannot assign to a ternary expression 3 | -------------------------------------------------------------------------------- /tests/other_errors/double_import.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | import "stdlib/io.jou" # Error: file "stdlib/io.jou" is imported twice 3 | -------------------------------------------------------------------------------- /tests/other_errors/none_ptr.jou: -------------------------------------------------------------------------------- 1 | def foo(x: None*) -> int: # Error: 'None' cannot be used here because it is not a type 2 | return 1 3 | -------------------------------------------------------------------------------- /tests/other_errors/self_assign_in_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def foo(self) -> None: 3 | self = 0 # Error: cannot assign to self 4 | -------------------------------------------------------------------------------- /tests/other_errors/shadow_WINDOWS.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | WINDOWS: int = 666 # Error: a constant named 'WINDOWS' already exists 3 | -------------------------------------------------------------------------------- /tests/other_errors/varargs_def.jou: -------------------------------------------------------------------------------- 1 | def foo(...) -> int: # Error: functions with variadic arguments cannot be defined yet 2 | return 0 3 | -------------------------------------------------------------------------------- /tests/other_errors/void_as_type.jou: -------------------------------------------------------------------------------- 1 | def foo(x: void) -> int: # Error: 'void' cannot be used here because it is not a type 2 | return 1 3 | -------------------------------------------------------------------------------- /tests/should_succeed/eof_no_newline.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | printf("Hi\n") # Output: Hi 5 | return 0 -------------------------------------------------------------------------------- /tests/syntax_error/bad_union_member_name.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | union: 3 | 1: int # Error: expected a union member, got an integer 4 | -------------------------------------------------------------------------------- /tests/syntax_error/import_with_extra_crap_at_end.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" lol # Error: expected end of line, got a variable name 'lol' 2 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_arg_type.jou: -------------------------------------------------------------------------------- 1 | def f(x): # Error: expected ':' and a type after it (example: "foo: int"), got ')' 2 | return 3 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_args_function.jou: -------------------------------------------------------------------------------- 1 | def foo: # Error: expected a '(' to denote the start of arguments, got ':' 2 | return 3 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_global_keyword_type.jou: -------------------------------------------------------------------------------- 1 | foo: int # Error: missing 'global' or 'const' keyword when defining global variable 2 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_global_keyword_value.jou: -------------------------------------------------------------------------------- 1 | foo = 1 # Error: missing 'global' or 'const' keyword when defining global variable 2 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_number_after_eminus.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 123e- # Error: invalid number or variable name "123e-" 3 | -------------------------------------------------------------------------------- /tests/syntax_error/number_underscore_suffix.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | return 123_ # Error: invalid number or variable name "123_" 3 | -------------------------------------------------------------------------------- /tests/syntax_error/python_style_unpack.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | x, y = "hi" # Error: only one variable can be assigned at a time 3 | -------------------------------------------------------------------------------- /tests/wrong_place/for_loop_outside_function.jou: -------------------------------------------------------------------------------- 1 | for i = 0; i < 10; i++: # Error: for loop must be inside a function or method 2 | pass 3 | -------------------------------------------------------------------------------- /tests/wrong_type/ternary_condition.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1 if 2 else 3 # Error: ternary condition must be a bool, not int 3 | -------------------------------------------------------------------------------- /examples/hello.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | # Output: Hello World 5 | puts("Hello World") 6 | return 0 7 | -------------------------------------------------------------------------------- /stdlib/intnative.jou: -------------------------------------------------------------------------------- 1 | if IS_32BIT: 2 | @public 3 | typedef intnative = int 4 | else: 5 | @public 6 | typedef intnative = int64 7 | -------------------------------------------------------------------------------- /tests/404/enum.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | Bar 3 | Baz 4 | 5 | def foo() -> None: 6 | x = Foooooo.Bar # Error: no variable named 'Foooooo' 7 | -------------------------------------------------------------------------------- /tests/other_errors/dumb_assignment_with_plusequals.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | 1 += 1 # Error: cannot assign to a constant 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/syntax_error/0b2.jou: -------------------------------------------------------------------------------- 1 | def foo() -> int: 2 | a = 0b0 3 | a = 0b1 4 | a = 0b2 # Error: invalid number or variable name "0b2" 5 | -------------------------------------------------------------------------------- /tests/syntax_error/double_not.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | x = False 3 | y = not not x # Error: 'not' cannot be repeated 4 | return 0 5 | -------------------------------------------------------------------------------- /tests/syntax_error/keyword_int.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | int = 1 # Error: expected an expression, got the 'int' keyword 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/syntax_error/multidot_float.jou: -------------------------------------------------------------------------------- 1 | def get_ip() -> double: 2 | return 127.0.0.1 # Error: invalid number or variable name "127.0.0.1" 3 | -------------------------------------------------------------------------------- /tests/syntax_error/number_underscore_prefix_oct.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | return 0o_777 # Error: invalid number or variable name "0o_777" 3 | -------------------------------------------------------------------------------- /tests/syntax_error/number_underscore_suffix_oct.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | return 0o777_ # Error: invalid number or variable name "0o777_" 3 | -------------------------------------------------------------------------------- /tests/too_long/int.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1000000000 # no error 3 | y = 1000000000000000 # Error: value does not fit into int 4 | -------------------------------------------------------------------------------- /tests/too_long/int_const.jou: -------------------------------------------------------------------------------- 1 | const x: int = 1000000000 # no error 2 | const y: int = 1000000000000000 # Error: value does not fit into int 3 | -------------------------------------------------------------------------------- /tests/too_long/too_big_for_64bit_const.jou: -------------------------------------------------------------------------------- 1 | const x: uint64 = 100000000000000000000 # Error: value does not fit into any supported integer type 2 | -------------------------------------------------------------------------------- /tests/wrong_place/link_in_class.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | link "-lfoo" # Error: 'link' statement must be on top level, not e.g. inside a function 3 | -------------------------------------------------------------------------------- /tests/wrong_type/array_with_hint.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x: int[3] = [1, 2.3, 4] # Error: array items should be of type int, not double 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_and_double.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1 & 2.3 # Error: wrong types: cannot take bitwise AND of int and double 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_or_double.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1 | 2.3 # Error: wrong types: cannot take bitwise OR of int and double 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bool_plus_bool.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | x = True + False # Error: wrong types: cannot add bool and bool 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/wrong_type/global_initial.jou: -------------------------------------------------------------------------------- 1 | global foo: int = "hello" # Error: global variable of type int cannot have an initial value of type byte* 2 | -------------------------------------------------------------------------------- /tests/wrong_type/if.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | if 7: # Error: 'if' condition must be a bool, not int 3 | return 1 4 | return 0 5 | -------------------------------------------------------------------------------- /tests/wrong_type/neg.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | x = -'a' # Error: value after '-' must be a float or double or a signed integer, not byte 3 | -------------------------------------------------------------------------------- /tests/wrong_type/not_a_function.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | "printf"("hello\n") # Error: expected a function, got byte* 3 | return 0 4 | -------------------------------------------------------------------------------- /examples/aoc2023/day22/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 1,0,1~1,2,1 2 | 0,0,2~2,0,2 3 | 0,2,3~2,2,3 4 | 0,0,4~0,2,4 5 | 2,0,5~2,2,5 6 | 0,1,6~2,1,6 7 | 1,1,8~1,1,9 8 | -------------------------------------------------------------------------------- /tests/404/python_print_function.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | print("Hello") # Error: function 'print' not found, try 'printf' from "stdlib/io.jou" 3 | -------------------------------------------------------------------------------- /tests/already_exists_error/global_var.jou: -------------------------------------------------------------------------------- 1 | global x: int 2 | global x: int # Error: a global variable named 'x' already exists (defined on line 1) 3 | -------------------------------------------------------------------------------- /tests/other_errors/shadow_var.jou: -------------------------------------------------------------------------------- 1 | global foo: byte* 2 | 3 | def bar() -> None: 4 | foo: int = 1 # Error: a variable named 'foo' already exists 5 | -------------------------------------------------------------------------------- /tests/should_succeed/imported/point_factory.jou: -------------------------------------------------------------------------------- 1 | import "./bar.jou" 2 | 3 | @public 4 | def make_point() -> Point: 5 | return Point{x=1, y=2} 6 | -------------------------------------------------------------------------------- /tests/syntax_error/double_assignment_comma_typed.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x, y: int = 7 # Error: only one variable can be assigned at a time 3 | -------------------------------------------------------------------------------- /tests/syntax_error/double_with_letters_after.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 123.456hello # Error: invalid number or variable name "123.456hello" 3 | -------------------------------------------------------------------------------- /tests/syntax_error/import_missing_quotes.jou: -------------------------------------------------------------------------------- 1 | import stdlib/io.jou # Error: expected a string to specify the file name, got a variable name 'stdlib' 2 | -------------------------------------------------------------------------------- /tests/syntax_error/keyword_bool.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | bool = 1 # Error: expected an expression, got the 'bool' keyword 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/syntax_error/keyword_byte.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | byte = 1 # Error: expected an expression, got the 'byte' keyword 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/syntax_error/keyword_float.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | float = 1 # Error: expected an expression, got the 'float' keyword 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/syntax_error/keyword_int16.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | int16 = 1 # Error: expected an expression, got the 'int16' keyword 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/syntax_error/keyword_int32.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | int32 = 1 # Error: expected an expression, got the 'int32' keyword 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/syntax_error/keyword_int64.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | int64 = 1 # Error: expected an expression, got the 'int64' keyword 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/syntax_error/keyword_int8.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | int8 = 1 # Error: expected an expression, got the 'int8' keyword 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/syntax_error/keyword_uint8.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | uint8 = 1 # Error: expected an expression, got the 'uint8' keyword 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_global_keyword_type_and_value.jou: -------------------------------------------------------------------------------- 1 | foo: int = 1 # Error: missing 'global' or 'const' keyword when defining global variable 2 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_indentation.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | return 0 # Error: expected more indentation after ':', got the 'return' keyword 3 | -------------------------------------------------------------------------------- /tests/syntax_error/number_underscore_prefix_hex.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | return 0x_cafe # Error: invalid number or variable name "0x_cafe" 3 | -------------------------------------------------------------------------------- /tests/syntax_error/number_underscore_suffix_hex.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | return 0xcafe_ # Error: invalid number or variable name "0xcafe_" 3 | -------------------------------------------------------------------------------- /tests/syntax_error/string_zero_byte.jou: -------------------------------------------------------------------------------- 1 | "foo\0bar" # Error: strings cannot contain zero bytes (\0), because that is the special end marker byte 2 | -------------------------------------------------------------------------------- /tests/wrong_place/import_in_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | import "stdlib/io.jou" # Error: imports must be in the beginning of the file 3 | -------------------------------------------------------------------------------- /tests/wrong_place/nested_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | def bar() -> None: # Error: nested functions are not supported 3 | pass 4 | -------------------------------------------------------------------------------- /tests/wrong_type/array_mixed_types.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = [1, "hey", "ho", 123] # Error: array items have different types (int, byte*) 3 | -------------------------------------------------------------------------------- /tests/wrong_type/assert.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/assert.jou" 2 | 3 | def main() -> int: 4 | assert 123 # Error: assertion must be a bool, not int 5 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_and_doubles.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1.2 & 3.4 # Error: wrong types: cannot take bitwise AND of double and double 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_or_doubles.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1.2 | 3.4 # Error: wrong types: cannot take bitwise OR of double and double 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_shift_left.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1 << "hello" # Error: wrong types: cannot do bitwise shift with int and byte* 3 | -------------------------------------------------------------------------------- /tests/other_errors/double_plusplus.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | foo = 1 3 | ++foo++ # Error: cannot increment the result of incrementing a value 4 | -------------------------------------------------------------------------------- /tests/other_errors/dynamic_array_length.jou: -------------------------------------------------------------------------------- 1 | def foo(a: int, b: int[a]) -> int: # Error: cannot evaluate array length at compile time 2 | return 0 3 | -------------------------------------------------------------------------------- /tests/other_errors/noreturn_as_type.jou: -------------------------------------------------------------------------------- 1 | def foo(x: noreturn) -> int: # Error: 'noreturn' cannot be used here because it is not a type 2 | return 1 3 | -------------------------------------------------------------------------------- /tests/other_errors/self_declare_local_var_in_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> None: 3 | self: int # Error: not a valid statement 4 | -------------------------------------------------------------------------------- /tests/other_errors/shadow_const.jou: -------------------------------------------------------------------------------- 1 | const foo: int = 7 2 | 3 | def bar() -> None: 4 | foo: int = 1 # Error: a constant named 'foo' already exists 5 | -------------------------------------------------------------------------------- /tests/syntax_error/arg_after_dotdotdot.jou: -------------------------------------------------------------------------------- 1 | declare printf(format: byte*, ..., foo: int) -> int # Error: if '...' is used, it must be the last parameter 2 | -------------------------------------------------------------------------------- /tests/syntax_error/funcptr.jou: -------------------------------------------------------------------------------- 1 | def foo(x: funcptr) -> None: # Error: expected a '(' to denote the start of funcptr argument types, got ')' 2 | pass 3 | -------------------------------------------------------------------------------- /tests/syntax_error/generic_bad_typevar.jou: -------------------------------------------------------------------------------- 1 | class Foo[2]: # Error: expected name of a generic type variable (typically 'T'), got an integer 2 | pass 3 | -------------------------------------------------------------------------------- /tests/syntax_error/generic_zero_params_define.jou: -------------------------------------------------------------------------------- 1 | class Foo[]: # Error: at least one generic type parameter is needed, e.g. 'class Foo[T]:' 2 | pass 3 | -------------------------------------------------------------------------------- /tests/syntax_error/keyword_double.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | double = 1 # Error: expected an expression, got the 'double' keyword 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/syntax_error/keyword_uint16.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | uint16 = 1 # Error: expected an expression, got the 'uint16' keyword 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/syntax_error/keyword_uint32.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | uint32 = 1 # Error: expected an expression, got the 'uint32' keyword 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/syntax_error/keyword_uint64.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | uint64 = 1 # Error: expected an expression, got the 'uint64' keyword 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/syntax_error/mark_print_as_public.jou: -------------------------------------------------------------------------------- 1 | def main() -> None: 2 | @public # Error: the @public decorator cannot be used here 3 | printf("Hi\n") 4 | -------------------------------------------------------------------------------- /tests/syntax_error/self_not_first.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(x: int, self) -> None: # Error: 'self' must be the first argument 3 | return 4 | -------------------------------------------------------------------------------- /tests/syntax_error/string_zero_byte_hex.jou: -------------------------------------------------------------------------------- 1 | "foo\x00bar" # Error: strings cannot contain zero bytes (\x00), because that is the special end marker byte 2 | -------------------------------------------------------------------------------- /tests/syntax_error/unnecessary_quote_escape_byte.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = '\"' # Error: double quotes shouldn't be escaped in byte literals 3 | -------------------------------------------------------------------------------- /tests/too_long/too_big_for_64bit.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 100000000000000000000 # Error: value does not fit into any supported integer type 3 | -------------------------------------------------------------------------------- /tests/wrong_place/call_outside_function.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | printf("hello\n") # Error: this line of code must be inside a function or method 3 | -------------------------------------------------------------------------------- /tests/wrong_place/link_in_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | link "-lfoo" # Error: 'link' statement must be on top level, not e.g. inside a function 3 | -------------------------------------------------------------------------------- /tests/wrong_place/match_outside_function.jou: -------------------------------------------------------------------------------- 1 | match foo: # Error: match statement must be inside a function or method 2 | case bar: 3 | pass 4 | -------------------------------------------------------------------------------- /tests/wrong_place/nested_class.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | class Bar: # Error: classes must be on top level, not e.g. inside a function 3 | x: int 4 | -------------------------------------------------------------------------------- /tests/wrong_place/typedef_in_class.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | typedef Foo = int # Error: typedef statement must be on top level, not e.g. inside a function 3 | -------------------------------------------------------------------------------- /tests/wrong_type/array_count.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | x: int 3 | n = array_count(&x) # Error: array_count must be called on an array, not int* 4 | -------------------------------------------------------------------------------- /tests/wrong_type/assign_with_type.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x: int = "hey" # Error: initial value for variable of type int cannot be of type byte* 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_shift_right.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1 >> "hello" # Error: wrong types: cannot do bitwise shift with int and byte* 3 | -------------------------------------------------------------------------------- /tests/wrong_type/deref_non_pointer.jou: -------------------------------------------------------------------------------- 1 | def foo(x: int) -> int: 2 | return *x # Error: the dereference operator '*' is only for pointers, not for int 3 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_xor_double_value.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1 3 | a ^= 2.3 # Error: wrong types: cannot xor int and double 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_xor_doubles.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1.2 3 | a ^= 3.4 # Error: wrong types: cannot xor double and double 4 | -------------------------------------------------------------------------------- /tests/wrong_type/not.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | if not 1: # Error: value after 'not' must be a bool, not int 3 | return 1 4 | return 0 5 | -------------------------------------------------------------------------------- /tests/wrong_type/while.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | while 7: # Error: 'while' condition must be a bool, not int 3 | return 1 4 | return 0 5 | -------------------------------------------------------------------------------- /examples/aoc2023/day01/sampleinput2.txt: -------------------------------------------------------------------------------- 1 | two1nine 2 | eightwothree 3 | abcone2threexyz 4 | xtwone3four 5 | 4nineeightseven2 6 | zoneight234 7 | 7pqrstsixteen 8 | -------------------------------------------------------------------------------- /examples/aoc2024/day15/sampleinput2-simple.txt: -------------------------------------------------------------------------------- 1 | ####### 2 | #...#.# 3 | #.....# 4 | #..OO@# 5 | #..O..# 6 | #.....# 7 | ####### 8 | 9 | None: 2 | assert True # Error: you must import "stdlib/assert.jou" to use the assert keyword 3 | -------------------------------------------------------------------------------- /tests/other_errors/import_it_self.jou: -------------------------------------------------------------------------------- 1 | import "./import_it_self.jou" # Error: the file itself cannot be imported 2 | 3 | def main() -> int: 4 | return 0 5 | -------------------------------------------------------------------------------- /tests/syntax_error/None_as_value.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = None # Error: None is not a value in Jou, use e.g. -1 for numbers or NULL for pointers 3 | -------------------------------------------------------------------------------- /tests/syntax_error/bad_method_name_after_def.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def 69(self) -> None: # Error: expected a method name, got an integer 3 | return 4 | -------------------------------------------------------------------------------- /tests/syntax_error/funcptr_junk_after_arg.jou: -------------------------------------------------------------------------------- 1 | def foo(x: funcptr(int junk) -> int) -> None: # Error: expected a ')', got a variable name 'junk' 2 | pass 3 | -------------------------------------------------------------------------------- /tests/syntax_error/local_vars_comma.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | x, y, = 0 # Error: expected ':' and a type after it (example: "foo, bar: int"), got ',' 3 | -------------------------------------------------------------------------------- /tests/syntax_error/local_vars_comma_assign.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | x, y, # Error: expected ':' and a type after it (example: "foo, bar: int"), got ',' 3 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_args_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar: # Error: expected a '(' to denote the start of arguments, got ':' 3 | return 4 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_colon.jou: -------------------------------------------------------------------------------- 1 | def main() -> int # Error: expected ':' followed by a new line with more indentation, got end of line 2 | return 0 3 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_return_type_funcptr.jou: -------------------------------------------------------------------------------- 1 | def foo(x: funcptr()) -> None: # Error: return type of funcptr must be specified with '->' 2 | pass 3 | -------------------------------------------------------------------------------- /tests/syntax_error/unnecessary_quote_escape_string.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = "hello \'world" # Error: single quotes shouldn't be escaped in strings 3 | -------------------------------------------------------------------------------- /tests/wrong_place/assert_in_class_body.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | assert 1 + 2 == 3 # Error: 'assert' cannot be placed inside a class unless it is inside a method 3 | -------------------------------------------------------------------------------- /tests/wrong_place/define_global_var_in_class.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | global foo: int # Error: global variables must be on top level, not e.g. inside a function 3 | -------------------------------------------------------------------------------- /tests/wrong_place/import_after_def.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | return 3 | 4 | import "stdlib/io.jou" # Error: imports must be in the beginning of the file 5 | -------------------------------------------------------------------------------- /tests/wrong_type/array_mixed_types_ptr.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1 3 | x = [&a, "hello"] # Error: array items have different types (int*, byte*) 4 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_shift_left_double_lhs.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1.2 << 3 # Error: wrong types: cannot do bitwise shift with double and int 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_shift_left_double_rhs.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1 << 2.3 # Error: wrong types: cannot do bitwise shift with int and double 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_shift_left_doubles.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1.2 << 3.4 # Error: wrong types: cannot do bitwise shift with double and double 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_shift_right_double_lhs.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1.2 >> 3 # Error: wrong types: cannot do bitwise shift with double and int 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_shift_right_double_rhs.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1 >> 2.3 # Error: wrong types: cannot do bitwise shift with int and double 3 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_xor_double_variable.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1.2 3 | a ^= 3 # Error: wrong types: cannot xor double and int 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_mul_str_str.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = "hello" 3 | x *= "world" # Error: wrong types: cannot multiply byte* and byte* 4 | -------------------------------------------------------------------------------- /tests/wrong_type/ternary_values.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1 if True else "lol" # Error: ternary values must be of the same type (got int and byte*) 3 | -------------------------------------------------------------------------------- /tests/wrong_type/var_assignment.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1 3 | x = "hey" # Error: cannot assign a value of type byte* to a variable of type int 4 | -------------------------------------------------------------------------------- /examples/aoc2022/day01/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 1000 2 | 2000 3 | 3000 4 | 5 | 4000 6 | 7 | 5000 8 | 6000 9 | 10 | 7000 11 | 8000 12 | 9000 13 | 14 | 10000 15 | -------------------------------------------------------------------------------- /examples/aoc2024/day19/sampleinput.txt: -------------------------------------------------------------------------------- 1 | r, wr, b, g, bwu, rb, gb, br 2 | 3 | brwrr 4 | bggr 5 | gbbr 6 | rrbgbr 7 | ubwu 8 | bwurrg 9 | brgr 10 | bbrgwb 11 | -------------------------------------------------------------------------------- /tests/404/enum_member.jou: -------------------------------------------------------------------------------- 1 | enum FooBar: 2 | Foo 3 | Bar 4 | 5 | def foo() -> None: 6 | x = FooBar.Asdf # Error: enum FooBar has no member named 'Asdf' 7 | -------------------------------------------------------------------------------- /tests/other_errors/assign_to_array_count.jou: -------------------------------------------------------------------------------- 1 | def blah() -> None: 2 | x: int[10] 3 | array_count(x) = 20 # Error: cannot assign to an array_count expression 4 | -------------------------------------------------------------------------------- /tests/other_errors/assign_to_const_int.jou: -------------------------------------------------------------------------------- 1 | const foo: int = 7 2 | 3 | def main() -> int: 4 | foo = 123 # Error: cannot assign to a constant 5 | return 0 6 | -------------------------------------------------------------------------------- /tests/syntax_error/chained_eq.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | printf("%d\n", 1 == 2 == 3) # Error: comparisons cannot be chained 5 | -------------------------------------------------------------------------------- /tests/syntax_error/dotdotdot_dotdotdot_funcptr.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | f: funcptr(..., ...) -> None # Error: if '...' is used, it must be the last parameter 3 | -------------------------------------------------------------------------------- /tests/syntax_error/import_missing_dot.jou: -------------------------------------------------------------------------------- 1 | import "blahblah.jou" # Error: import path must start with 'stdlib/' (standard-library import) or a dot (relative import) 2 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_array_size_byte.jou: -------------------------------------------------------------------------------- 1 | def foo(data: byte[]) -> int: # Error: array length must be specified, e.g. int[10] instead of int[] 2 | pass 3 | -------------------------------------------------------------------------------- /tests/syntax_error/zig_pointer_type.jou: -------------------------------------------------------------------------------- 1 | def blah() -> None: 2 | foo: *byte # Error: a type cannot start with '*', use e.g. int* instead of *int for pointers 3 | -------------------------------------------------------------------------------- /tests/wrong_place/call_in_class.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | class Foo: 3 | printf("hello\n") # Error: this line of code must be inside a function or method 4 | -------------------------------------------------------------------------------- /tests/wrong_place/class_in_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | class Bar: # Error: classes must be on top level, not e.g. inside a function 3 | x: int 4 | -------------------------------------------------------------------------------- /tests/wrong_place/declare_global_var_in_class.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | declare global foo: int # Error: 'declare' must be on top level, not e.g. inside a function 3 | -------------------------------------------------------------------------------- /tests/wrong_place/typedef_in_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | typedef Foo = int # Error: typedef statement must be on top level, not e.g. inside a function 3 | -------------------------------------------------------------------------------- /tests/wrong_type/arg_funcptr.jou: -------------------------------------------------------------------------------- 1 | def bar(f: funcptr(int*) -> None) -> None: 2 | f(1) # Error: first argument of funcptr(int*) should have type int*, not int 3 | -------------------------------------------------------------------------------- /tests/wrong_type/assign_none_return_funcptr.jou: -------------------------------------------------------------------------------- 1 | def foo(funcs: (funcptr() -> None)[5]) -> None: 2 | x = funcs[0]() # Error: function does not return a value 3 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_shift_right_doubles.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1.2 >> 3.4 # Error: wrong types: cannot do bitwise shift with double and double 3 | -------------------------------------------------------------------------------- /tests/wrong_type/explicit_array_to_pointer_cast.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = [1, 2, 3] 3 | y = x as byte* # Error: cannot cast from type int[3] to byte* 4 | -------------------------------------------------------------------------------- /tests/wrong_type/for.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | for i = 0; i; i = i+1: # Error: 'for' condition must be a bool, not int 3 | return 1 4 | return 0 5 | -------------------------------------------------------------------------------- /examples/aoc2024/day04/part2_templates.txt: -------------------------------------------------------------------------------- 1 | M.S 2 | .A. 3 | M.S 4 | 5 | S.S 6 | .A. 7 | M.M 8 | 9 | S.M 10 | .A. 11 | S.M 12 | 13 | M.M 14 | .A. 15 | S.S 16 | -------------------------------------------------------------------------------- /tests/404/class_field.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | x: int 3 | 4 | def asdasd() -> None: 5 | foo = Foo{x=1} 6 | bar = foo.y # Error: class Foo has no field named 'y' 7 | -------------------------------------------------------------------------------- /tests/404/python_input_function.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | name = input("What's your name? ") # Error: function 'input' not found, try 'fgets' from "stdlib/io.jou" 3 | -------------------------------------------------------------------------------- /tests/already_exists_error/class_and_enum.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | x: int 3 | 4 | enum Foo: # Error: a type named 'Foo' already exists (defined on line 1) 5 | Blah 6 | -------------------------------------------------------------------------------- /tests/already_exists_error/class_and_typedef.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | x: int 3 | 4 | typedef Foo = int # Error: a type named 'Foo' already exists (defined on line 1) 5 | -------------------------------------------------------------------------------- /tests/already_exists_error/enum_and_class.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | Blah 3 | 4 | class Foo: # Error: a type named 'Foo' already exists (defined on line 1) 5 | x: int 6 | -------------------------------------------------------------------------------- /tests/already_exists_error/local_variable_windows.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | WINDOWS: int = 123 # Error: a constant named 'WINDOWS' already exists 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/already_exists_error/typedef_and_class.jou: -------------------------------------------------------------------------------- 1 | typedef Foo = int64 2 | 3 | class Foo: # Error: a type named 'Foo' already exists (defined on line 1) 4 | x: int 5 | -------------------------------------------------------------------------------- /tests/crash/null_deref.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | x: byte* = NULL 5 | putchar(*x) # Output: Segmentation fault 6 | return 0 7 | -------------------------------------------------------------------------------- /tests/other_errors/assign_to_enum.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | Bar 3 | Baz 4 | 5 | def foo() -> None: 6 | Foo.Bar = Foo.Baz # Error: cannot assign to an enum member 7 | -------------------------------------------------------------------------------- /tests/should_succeed/imported/typedef.jou: -------------------------------------------------------------------------------- 1 | @public 2 | typedef StringyString = byte* 3 | 4 | typedef PrivateInt = int 5 | 6 | @public 7 | typedef PublicInt = PrivateInt 8 | -------------------------------------------------------------------------------- /tests/syntax_error/L_suffix.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | # This is how "long" numbers are created in C 3 | x = 0L # Error: invalid number or variable name "0L" 4 | -------------------------------------------------------------------------------- /tests/syntax_error/else_if.jou: -------------------------------------------------------------------------------- 1 | def blah() -> None: 2 | if foo: 3 | x = 1 4 | else if bar: # Error: use 'elif' instead of 'else if' 5 | x = 2 6 | -------------------------------------------------------------------------------- /tests/syntax_error/union_default.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | union: 3 | message: byte* 4 | num: int = 1 # Error: union members cannot have default values 5 | -------------------------------------------------------------------------------- /tests/syntax_error/zig_array_type.jou: -------------------------------------------------------------------------------- 1 | def blah() -> None: 2 | foo: [100]byte # Error: a type cannot start with '[', use e.g. int[10] instead of [10]int for arrays 3 | -------------------------------------------------------------------------------- /tests/wrong_place/declare_function_in_class.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | declare puts(s: byte*) -> int # Error: 'declare' must be on top level, not e.g. inside a function 3 | -------------------------------------------------------------------------------- /tests/wrong_type/assign_none_return.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | return 3 | 4 | def bar() -> None: 5 | x = foo() # Error: function 'foo' does not return a value 6 | -------------------------------------------------------------------------------- /tests/wrong_type/deref_array.jou: -------------------------------------------------------------------------------- 1 | def foo() -> int: 2 | x = [1, 2, 3] 3 | return *x # Error: the dereference operator '*' is only for pointers, not for int[3] 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_and_double_value.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1 3 | a &= 2.3 # Error: wrong types: cannot take bitwise AND of int and double 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_and_doubles.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1.2 3 | a &= 3.4 # Error: wrong types: cannot take bitwise AND of double and double 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_or_double_value.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1 3 | a |= 2.3 # Error: wrong types: cannot take bitwise OR of int and double 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_or_double_variable.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1.2 3 | a |= 3 # Error: wrong types: cannot take bitwise OR of double and int 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_or_doubles.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1.2 3 | a |= 3.4 # Error: wrong types: cannot take bitwise OR of double and double 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_shift_left.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1 3 | a <<= "hi" # Error: wrong types: cannot do bitwise shift with int and byte* 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_shift_right.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1 3 | a >>= "hi" # Error: wrong types: cannot do bitwise shift with int and byte* 4 | -------------------------------------------------------------------------------- /tests/wrong_type/pointer_eq.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x: int* = NULL 3 | y: byte* = NULL 4 | z = (x==y) # Error: wrong types: cannot compare int* and byte* 5 | -------------------------------------------------------------------------------- /examples/aoc2023/day24/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 19, 13, 30 @ -2, 1, -2 2 | 18, 19, 22 @ -1, -1, -2 3 | 20, 25, 34 @ -2, -2, -4 4 | 12, 31, 28 @ -1, -2, -1 5 | 20, 19, 15 @ 1, -5, -3 6 | -------------------------------------------------------------------------------- /tests/404/match_function.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | match "hello" with lolwatwut: # Error: function 'lolwatwut' not found 3 | case "hi": 4 | pass 5 | -------------------------------------------------------------------------------- /tests/other_errors/const_cannot_evaluate.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | const foo: int = printf("hello\n") # Error: cannot evaluate value of constant at compile time 4 | -------------------------------------------------------------------------------- /tests/other_errors/instantiation_dupe.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | x: int 3 | 4 | def foo() -> None: 5 | wat = Foo{x=1, x=2} # Error: multiple values were given for field 'x' 6 | -------------------------------------------------------------------------------- /tests/other_errors/missing_value_in_return_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> int: 2 | return # Error: a return value is needed, because the return type of function 'foo' is int 3 | -------------------------------------------------------------------------------- /tests/other_errors/return_void_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> void: # Error: void is not a valid return type, use '-> None' if the function does not return a value 2 | pass 3 | -------------------------------------------------------------------------------- /tests/other_errors/unexpected_return_value_function.jou: -------------------------------------------------------------------------------- 1 | def f() -> None: 2 | return 123 # Error: function 'f' cannot return a value because it was defined with '-> None' 3 | -------------------------------------------------------------------------------- /tests/syntax_error/arg_after_dotdotdot_funcptr.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | f: funcptr(byte*, ..., int) -> int # Error: if '...' is used, it must be the last parameter 3 | -------------------------------------------------------------------------------- /tests/syntax_error/empty_byte_literal.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | return '' # Error: a byte literal cannot be empty, maybe use double quotes to instead make a string? 3 | -------------------------------------------------------------------------------- /tests/wrong_place/declare_global_var_in_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | declare global foo: int # Error: 'declare' must be on top level, not e.g. inside a function 3 | -------------------------------------------------------------------------------- /tests/wrong_place/define_global_var_in_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | global foo: int # Error: global variables must be on top level, not e.g. inside a function 3 | -------------------------------------------------------------------------------- /tests/wrong_place/import_in_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> None: 3 | import "stdlib/io.jou" # Error: imports must be in the beginning of the file 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_and_double_variable.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1.2 3 | a &= 3 # Error: wrong types: cannot take bitwise AND of double and int 4 | -------------------------------------------------------------------------------- /tests/wrong_type/or.jou: -------------------------------------------------------------------------------- 1 | def one_or_two(x: int) -> bool: 2 | if x == 1 or 2: # Error: 'or' only works with bools, not int 3 | return True 4 | return False 5 | -------------------------------------------------------------------------------- /examples/aoc2024/day15/sampleinput1.txt: -------------------------------------------------------------------------------- 1 | ######## 2 | #..O.O.# 3 | ##@.O..# 4 | #...O..# 5 | #.#.O..# 6 | #...O..# 7 | #......# 8 | ######## 9 | 10 | <^^>>>vv>v<< 11 | -------------------------------------------------------------------------------- /tests/404/method_on_class.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | x: int 3 | 4 | def main() -> int: 5 | f = Foo{x=1} 6 | f.bar() # Error: class Foo does not have a method named 'bar' 7 | -------------------------------------------------------------------------------- /tests/already_exists_error/class_field_and_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | x: int 3 | def x(self) -> None: # Error: class Foo already has a field named 'x' 4 | return 5 | -------------------------------------------------------------------------------- /tests/already_exists_error/enum.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | Bar 3 | Baz 4 | 5 | enum Foo: # Error: a type named 'Foo' already exists (defined on line 1) 6 | Lol 7 | Wat 8 | -------------------------------------------------------------------------------- /tests/other_errors/assign_to_const_string.jou: -------------------------------------------------------------------------------- 1 | const foo: byte* = "hello" 2 | 3 | def main() -> int: 4 | foo = "lol" # Error: cannot assign to a constant 5 | return 0 6 | -------------------------------------------------------------------------------- /tests/other_errors/assign_to_enum_count.jou: -------------------------------------------------------------------------------- 1 | enum FooBar: 2 | Foo 3 | Bar 4 | 5 | def blah() -> None: 6 | enum_count(FooBar) = 20 # Error: cannot assign to a constant 7 | -------------------------------------------------------------------------------- /tests/other_errors/noreturn_but_return_without_value.jou: -------------------------------------------------------------------------------- 1 | def foo() -> noreturn: 2 | return # Error: function 'foo' cannot return because it was defined with '-> noreturn' 3 | -------------------------------------------------------------------------------- /tests/syntax_error/chained_le.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | x = 5 5 | printf("%d\n", 1 <= x <= 10) # Error: comparisons cannot be chained 6 | -------------------------------------------------------------------------------- /tests/syntax_error/hex.jou: -------------------------------------------------------------------------------- 1 | def foo() -> int: 2 | a = 0xabc123 3 | b = 0xabc 4 | c = 0xa 5 | d = 0x00a 6 | e = 0x # Error: invalid number or variable name "0x" 7 | -------------------------------------------------------------------------------- /tests/syntax_error/overlong_char.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | return 'hi' # Error: single quotes are for specifying a byte, maybe use double quotes to instead make a string? 3 | -------------------------------------------------------------------------------- /tests/wrong_place/const_in_function.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | const x: int = 42 # Error: const definitions must be on top level, not e.g. inside a function 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/wrong_place/declare_function_in_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | declare puts(s: byte*) -> int # Error: 'declare' must be on top level, not e.g. inside a function 3 | -------------------------------------------------------------------------------- /tests/wrong_place/link_in_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> None: 3 | link "-lfoo" # Error: 'link' statement must be on top level, not e.g. inside a function 4 | -------------------------------------------------------------------------------- /tests/wrong_type/enum_count.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | n = enum_count(FILE) # Error: enum_count must be called on an enum type, not a class 5 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_add_str_int.jou: -------------------------------------------------------------------------------- 1 | def foo(s: byte*) -> None: 2 | # The "Jou way" would be: s = &s[5] 3 | s += 5 # Error: wrong types: cannot add byte* and int 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_shift_left_double_value.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1 3 | a <<= 2.3 # Error: wrong types: cannot do bitwise shift with int and double 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_shift_left_doubles.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1.2 3 | a <<= 3.4 # Error: wrong types: cannot do bitwise shift with double and double 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_shift_right_double_value.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1 3 | a >>= 2.3 # Error: wrong types: cannot do bitwise shift with int and double 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_shift_right_doubles.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1.2 3 | a >>= 3.4 # Error: wrong types: cannot do bitwise shift with double and double 4 | -------------------------------------------------------------------------------- /tests/wrong_type/pointer_assignment.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1 3 | y = &x 4 | *y = "hey" # Error: cannot place a value of type byte* into a pointer of type int* 5 | -------------------------------------------------------------------------------- /tests/wrong_type/self_annotation.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar( 3 | self: int, # Error: type of self must be Foo* (default) or Foo 4 | ) -> None: 5 | return 6 | -------------------------------------------------------------------------------- /examples/aoc2023/day12/sampleinput.txt: -------------------------------------------------------------------------------- 1 | ???.### 1,1,3 2 | .??..??...?##. 1,1,3 3 | ?#?#?#?#?#?#?#? 1,3,1,6 4 | ????.#...#... 4,1,1 5 | ????.######..#####. 1,6,5 6 | ?###???????? 3,2,1 7 | -------------------------------------------------------------------------------- /tests/404/stderr.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | fprintf(stderr, "hi\n") # Error: no variable named 'stderr', try 'get_stderr()' from "stdlib/io.jou" 5 | -------------------------------------------------------------------------------- /tests/404/stdout.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | fprintf(stdout, "hi\n") # Error: no variable named 'stdout', try 'get_stdout()' from "stdlib/io.jou" 5 | -------------------------------------------------------------------------------- /tests/already_exists_error/func.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | return 3 | 4 | def foo() -> None: # Error: a function named 'foo' already exists (defined on line 1) 5 | return 6 | -------------------------------------------------------------------------------- /tests/already_exists_error/method_and_class_field.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def x(self) -> None: 3 | return 4 | x: int # Error: class fields must be defined before methods 5 | -------------------------------------------------------------------------------- /tests/other_errors/address_of_minusminus.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | foo = 1 3 | x = &foo-- # Error: the '&' operator cannot be applied to the result of decrementing a value 4 | -------------------------------------------------------------------------------- /tests/other_errors/missing_generic.jou: -------------------------------------------------------------------------------- 1 | class Foo[T]: 2 | x: T 3 | 4 | def blah() -> None: 5 | f: Foo # Error: Foo[T] is a generic class, use e.g. Foo[int] instead of just Foo 6 | -------------------------------------------------------------------------------- /tests/other_errors/noreturn_but_return_with_value_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> noreturn: 2 | return 1 # Error: function 'foo' cannot return because it was defined with '-> noreturn' 3 | -------------------------------------------------------------------------------- /tests/other_errors/using_function_with_none_return.jou: -------------------------------------------------------------------------------- 1 | def f() -> None: 2 | return 3 | 4 | def g() -> None: 5 | x = f() + 123 # Error: function 'f' does not return a value 6 | -------------------------------------------------------------------------------- /tests/syntax_error/bin.jou: -------------------------------------------------------------------------------- 1 | def foo() -> int: 2 | a = 0b110010 3 | b = 0b001101 4 | c = 0b0 5 | d = 0b1 6 | e = 0b # Error: invalid number or variable name "0b" 7 | -------------------------------------------------------------------------------- /tests/syntax_error/triple_equals.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | if 1 === 2: # Error: use '==' instead of '===' 5 | puts("hey") 6 | return 0 7 | -------------------------------------------------------------------------------- /tests/syntax_error/utf8_multibyte_char.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | return 'ö' # Error: single quotes are for specifying a byte, maybe use double quotes to instead make a string? 3 | -------------------------------------------------------------------------------- /tests/wrong_place/enum_inside_class.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | enum Bar: # Error: enums must be on top level, not e.g. inside a function 3 | Asd 4 | Blah 5 | Cacca 6 | -------------------------------------------------------------------------------- /tests/wrong_place/global_in_function_python_style.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | global thing # Error: you don't need 'global' inside a function or method to use a global variable 3 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_shift_left_double_variable.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1.2 3 | a <<= 3 # Error: wrong types: cannot do bitwise shift with double and int 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_shift_right_double_variable.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1.2 3 | a >>= 3 # Error: wrong types: cannot do bitwise shift with double and int 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_xor.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1 3 | a ^= 2 as uint32 # Error: xor produced a value of type uint32 which cannot be assigned back to int 4 | -------------------------------------------------------------------------------- /examples/aoc2023/day10/sampleinput2.txt: -------------------------------------------------------------------------------- 1 | ........... 2 | .S-------7. 3 | .|F-----7|. 4 | .||.....||. 5 | .||.....||. 6 | .|L-7.F-J|. 7 | .|..|.|..|. 8 | .L--J.L--J. 9 | ........... 10 | -------------------------------------------------------------------------------- /tests/404/compile_time_constant.jou: -------------------------------------------------------------------------------- 1 | if foo: # Error: cannot evaluate condition at compile time 2 | def blah() -> None: 3 | pass 4 | 5 | def main() -> int: 6 | return 0 7 | -------------------------------------------------------------------------------- /tests/already_exists_error/class_import.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | class FILE: # Error: a type named 'FILE' already exists (imported from "stdlib/io.jou" on line 1) 4 | x: int 5 | -------------------------------------------------------------------------------- /tests/other_errors/string_doesnt_fit_to_array.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x: byte[20] = "this is a long string" # Error: a string of 22 bytes (including '\0') does not fit into byte[20] 3 | -------------------------------------------------------------------------------- /tests/should_succeed/deep_import.jou: -------------------------------------------------------------------------------- 1 | import "./imported/level1/level2/deep.jou" 2 | 3 | def main() -> int: 4 | do_deep_stuff() # Output: Deep stuff... Bar Bar 123 456 5 | return 0 6 | -------------------------------------------------------------------------------- /tests/syntax_error/first_line_indent.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: # Error: expected an expression, got more indentation 2 | return 3 | 4 | # TODO: this error message is not very good... 5 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_field_names.jou: -------------------------------------------------------------------------------- 1 | class Point: 2 | x: int 3 | y: int 4 | 5 | def foo() -> None: 6 | p = Point{1, 2} # Error: expected a field name, got an integer 7 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_return_type_function.jou: -------------------------------------------------------------------------------- 1 | def foo(): # Error: return type must be specified with '->', or with '-> None' if the function doesn't return anything 2 | return 3 | -------------------------------------------------------------------------------- /tests/syntax_error/triple_not_equals.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | if 1 !== 2: # Error: use '!=' instead of '!==' 5 | puts("hey") 6 | return 0 7 | -------------------------------------------------------------------------------- /tests/too_long/uint64_vs_int64_const.jou: -------------------------------------------------------------------------------- 1 | const x: uint64 = 10_000_000_000_000_000_000 # no error 2 | const y: int64 = 10_000_000_000_000_000_000 # Error: value does not fit into int64 3 | -------------------------------------------------------------------------------- /tests/wrong_place/typedef_in_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> None: 3 | typedef Foo = int # Error: typedef statement must be on top level, not e.g. inside a function 4 | -------------------------------------------------------------------------------- /tests/wrong_type/arg.jou: -------------------------------------------------------------------------------- 1 | def foo(x: int*) -> None: 2 | return 3 | 4 | def bar() -> None: 5 | foo(1) # Error: first argument of function foo(x: int*) should have type int*, not int 6 | -------------------------------------------------------------------------------- /tests/wrong_type/elif.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | if 1 == 2: 3 | return 1 4 | elif 7: # Error: 'elif' condition must be a bool, not int 5 | return 2 6 | return 0 7 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_and.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1 3 | a &= 2 as uint32 # Error: bitwise AND produced a value of type uint32 which cannot be assigned back to int 4 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_bitwise_or.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | a = 1 3 | a |= 2 as uint32 # Error: bitwise OR produced a value of type uint32 which cannot be assigned back to int 4 | -------------------------------------------------------------------------------- /tests/already_exists_error/class_field_and_union_member.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | x: int 3 | union: 4 | x: int64 # Error: class Foo already has a field named 'x' 5 | y: byte 6 | -------------------------------------------------------------------------------- /tests/other_errors/address_of_function_call.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def foo() -> None: 4 | x = &printf("hello\n") # Error: the '&' operator cannot be applied to a function call 5 | -------------------------------------------------------------------------------- /tests/wrong_place/class_in_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> None: 3 | class Baz: # Error: classes must be on top level, not e.g. inside a function 4 | x: int 5 | -------------------------------------------------------------------------------- /tests/wrong_place/define_global_var_in_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> None: 3 | global x: int # Error: global variables must be on top level, not e.g. inside a function 4 | -------------------------------------------------------------------------------- /tests/wrong_type/brace_init_arg.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | x: int 3 | 4 | def foo() -> None: 5 | wat = Foo{x="hey"} # Error: value for field 'x' of class Foo must be of type int, not byte* 6 | -------------------------------------------------------------------------------- /tests/wrong_type/class_member_init.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | x: int 3 | 4 | def blah() -> None: 5 | f = Foo{x = "hey"} # Error: value for field 'x' of class Foo must be of type int, not byte* 6 | -------------------------------------------------------------------------------- /tests/wrong_type/enum_to_int.jou: -------------------------------------------------------------------------------- 1 | enum FooBar: 2 | Foo 3 | Bar 4 | 5 | def main() -> int: 6 | x: FooBar = 0 # Error: initial value for variable of type FooBar cannot be of type int 7 | -------------------------------------------------------------------------------- /tests/wrong_type/instantiate_enum.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | Bar 3 | Baz 4 | 5 | def asdf() -> None: 6 | f = Foo{x=1} # Error: the Foo{...} syntax is only for classes, but Foo is an enum 7 | -------------------------------------------------------------------------------- /tests/wrong_type/instantiate_int_typedef.jou: -------------------------------------------------------------------------------- 1 | typedef MyInt = int 2 | 3 | def asdf() -> None: 4 | f = MyInt{x=1} # Error: the int{...} syntax is only for classes, but int is a number type 5 | -------------------------------------------------------------------------------- /tests/wrong_type/return_value_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> byte: 2 | x: int = 1 3 | return x # Error: attempting to return a value of type int from function 'foo' defined with '-> byte' 4 | -------------------------------------------------------------------------------- /examples/aoc2023/day03/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 467..114.. 2 | ...*...... 3 | ..35..633. 4 | ......#... 5 | 617*...... 6 | .....+.58. 7 | ..592..... 8 | ......755. 9 | ...$.*.... 10 | .664.598.. 11 | -------------------------------------------------------------------------------- /examples/aoc2023/day11/sampleinput.txt: -------------------------------------------------------------------------------- 1 | ...#...... 2 | .......#.. 3 | #......... 4 | .......... 5 | ......#... 6 | .#........ 7 | .........# 8 | .......... 9 | .......#.. 10 | #...#..... 11 | -------------------------------------------------------------------------------- /examples/aoc2023/day14/sampleinput.txt: -------------------------------------------------------------------------------- 1 | O....#.... 2 | O.OO#....# 3 | .....##... 4 | OO.#O....O 5 | .O.....O#. 6 | O.#..O.#.# 7 | ..O..#O..O 8 | .......O.. 9 | #....###.. 10 | #OO..#.... 11 | -------------------------------------------------------------------------------- /examples/aoc2023/day16/sampleinput.txt: -------------------------------------------------------------------------------- 1 | .|...\.... 2 | |.-.\..... 3 | .....|-... 4 | ........|. 5 | .......... 6 | .........\ 7 | ..../.\\.. 8 | .-.-/..|.. 9 | .|....-|.\ 10 | ..//.|.... 11 | -------------------------------------------------------------------------------- /examples/aoc2024/day04/sampleinput.txt: -------------------------------------------------------------------------------- 1 | MMMSXXMASM 2 | MSAMXMSMSA 3 | AMXSXMAAMM 4 | MSAMASMSMX 5 | XMASAMXAMM 6 | XXAMMXXAMA 7 | SMSMSASXSS 8 | SAXAMASAAA 9 | MAMMMXMMMM 10 | MXMXAXMASX 11 | -------------------------------------------------------------------------------- /examples/aoc2024/day06/sampleinput.txt: -------------------------------------------------------------------------------- 1 | ....#..... 2 | .........# 3 | .......... 4 | ..#....... 5 | .......#.. 6 | .......... 7 | .#..^..... 8 | ........#. 9 | #......... 10 | ......#... 11 | -------------------------------------------------------------------------------- /examples/aoc2024/day12/sampleinput1.txt: -------------------------------------------------------------------------------- 1 | RRRRIICCFF 2 | RRRRIICCCF 3 | VVRRRCCFFF 4 | VVRCCCJFFF 5 | VVVVCJJCFE 6 | VVIVCCJJEE 7 | VVIIICJJEE 8 | MIIIIIJJEE 9 | MIIISIJEEE 10 | MMMISSJEEE 11 | -------------------------------------------------------------------------------- /examples/aoc2025/day04/sampleinput.txt: -------------------------------------------------------------------------------- 1 | ..@@.@@@@. 2 | @@@.@.@.@@ 3 | @@@@@.@.@@ 4 | @.@@@@..@. 5 | @@.@@@@.@@ 6 | .@@@@@@@.@ 7 | .@.@.@.@@@ 8 | @.@@@.@@@@ 9 | .@@@@@@@@. 10 | @.@.@@@.@. 11 | -------------------------------------------------------------------------------- /tests/already_exists_error/union_member_and_class_field.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | union: 3 | x: int64 4 | y: byte 5 | x: int # Error: class Foo already has a union member named 'x' 6 | -------------------------------------------------------------------------------- /tests/other_errors/increment_indirect_addressof_fails.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | x: int 3 | 4 | def bar() -> None: 5 | Foo{x=1}.x++ # Error: cannot increment a field of a newly created instance 6 | -------------------------------------------------------------------------------- /tests/other_errors/missing_value_in_return_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> int: 3 | return # Error: a return value is needed, because the return type of method 'bar' is int 4 | -------------------------------------------------------------------------------- /tests/other_errors/return_void_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def foo(self) -> void: # Error: void is not a valid return type, use '-> None' if the method does not return a value 3 | pass 4 | -------------------------------------------------------------------------------- /tests/other_errors/unexpected_generic_2.jou: -------------------------------------------------------------------------------- 1 | class Blah: 2 | pass 3 | 4 | def foo() -> None: 5 | x: Blah[int, byte] # Error: Blah is not generic, use just Blah instead of Blah[something] 6 | -------------------------------------------------------------------------------- /tests/other_errors/unexpected_return_value_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def f(self) -> None: 3 | return 123 # Error: method 'f' cannot return a value because it was defined with '-> None' 4 | -------------------------------------------------------------------------------- /tests/syntax_error/global_missing_type_and_value.jou: -------------------------------------------------------------------------------- 1 | global thingy # Error: expected ':' and a type after it (global thingy: int) or '=' and a value after it (global thingy = 123), got end of line 2 | -------------------------------------------------------------------------------- /tests/syntax_error/type_bad_parentheses.jou: -------------------------------------------------------------------------------- 1 | def foo( 2 | x: (int), 3 | y: ((((int)))), 4 | z: (int bruh), # Error: expected a ')', got a variable name 'bruh' 5 | ) -> None: 6 | pass 7 | -------------------------------------------------------------------------------- /tests/too_long/byte.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | b: byte = 250 3 | b = 251 4 | b = 252 5 | b = 253 6 | b = 254 7 | b = 255 8 | b = 256 # Error: value does not fit into byte 9 | -------------------------------------------------------------------------------- /tests/too_long/uint64_vs_int64.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x: uint64 = 10_000_000_000_000_000_000 # no error 3 | y: int64 = 10_000_000_000_000_000_000 # Error: value does not fit into int64 4 | -------------------------------------------------------------------------------- /tests/wrong_place/declare_global_var_in_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> None: 3 | declare global x: int # Error: 'declare' must be on top level, not e.g. inside a function 4 | -------------------------------------------------------------------------------- /tests/wrong_place/enum_inside_function.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | enum Bar: # Error: enums must be on top level, not e.g. inside a function 3 | Asd 4 | Blah 5 | Cacca 6 | -------------------------------------------------------------------------------- /tests/wrong_type/arg_varargs.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def foo() -> None: 4 | printf(1) # Error: first argument of function printf(pattern: byte*, ...) should have type byte*, not int 5 | -------------------------------------------------------------------------------- /tests/wrong_type/dot_operator_int.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 123 3 | y = x.lolwat # Error: left side of '.' operator must be an instance of a class or a pointer to an instance, not int 4 | -------------------------------------------------------------------------------- /tests/wrong_type/int_to_enum.jou: -------------------------------------------------------------------------------- 1 | enum FooBar: 2 | Foo 3 | Bar 4 | 5 | def main() -> int: 6 | x: int = FooBar.Foo # Error: initial value for variable of type int cannot be of type FooBar 7 | -------------------------------------------------------------------------------- /examples/aoc2022/day05/sampleinput.txt: -------------------------------------------------------------------------------- 1 | [D] 2 | [N] [C] 3 | [Z] [M] [P] 4 | 1 2 3 5 | 6 | move 1 from 2 to 1 7 | move 3 from 1 to 3 8 | move 2 from 2 to 1 9 | move 1 from 1 to 2 10 | -------------------------------------------------------------------------------- /examples/aoc2023/day08/sampleinput.txt: -------------------------------------------------------------------------------- 1 | RL 2 | 3 | AAA = (BBB, CCC) 4 | BBB = (DDD, EEE) 5 | CCC = (ZZZ, GGG) 6 | DDD = (DDD, DDD) 7 | EEE = (EEE, EEE) 8 | GGG = (GGG, GGG) 9 | ZZZ = (ZZZ, ZZZ) 10 | -------------------------------------------------------------------------------- /examples/aoc2024/day07/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 190: 10 19 2 | 3267: 81 40 27 3 | 83: 17 5 4 | 156: 15 6 5 | 7290: 6 8 6 15 6 | 161011: 16 10 13 7 | 192: 17 8 14 8 | 21037: 9 7 18 13 9 | 292: 11 6 16 20 10 | -------------------------------------------------------------------------------- /examples/aoc2025/day02/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862,565653-565659,824824821-824824827,2121212118-2121212124 2 | -------------------------------------------------------------------------------- /examples/aoc2025/day11/sampleinput.txt: -------------------------------------------------------------------------------- 1 | aaa: you hhh 2 | you: bbb ccc 3 | bbb: ddd eee 4 | ccc: ddd eee fff 5 | ddd: ggg 6 | eee: out 7 | fff: out 8 | ggg: out 9 | hhh: ccc fff iii 10 | iii: out 11 | -------------------------------------------------------------------------------- /tests/already_exists_error/func_import.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def puts() -> None: # Error: a function named 'puts' already exists (imported from "stdlib/io.jou" on line 1) 4 | return 5 | -------------------------------------------------------------------------------- /tests/already_exists_error/method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> None: 3 | return 4 | def bar(self) -> None: # Error: class Foo already has a method named 'bar' 5 | return 6 | -------------------------------------------------------------------------------- /tests/other_errors/immediate_member_assign.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | x: int 3 | 4 | def main() -> int: 5 | Foo{x=1}.x = 2 # Error: cannot assign to a field of a newly created instance 6 | return 0 7 | -------------------------------------------------------------------------------- /tests/other_errors/redefine_imported_func.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def puts() -> None: # Error: a function named 'puts' already exists (imported from "stdlib/io.jou" on line 1) 4 | return 5 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_array_size_class.jou: -------------------------------------------------------------------------------- 1 | class Thing: 2 | pass 3 | 4 | def foo(things: Thing[]) -> int: # Error: array length must be specified, e.g. int[10] instead of int[] 5 | pass 6 | -------------------------------------------------------------------------------- /tests/wrong_place/declare_function_in_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> None: 3 | declare puts(s: byte*) -> int # Error: 'declare' must be on top level, not e.g. inside a function 4 | -------------------------------------------------------------------------------- /tests/wrong_type/dot_operator_int_call.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 123 3 | y = x.lolwat() # Error: left side of '.' operator must be an instance of a class or a pointer to an instance, not int 4 | -------------------------------------------------------------------------------- /tests/wrong_type/voidptr_increment.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/mem.jou" 2 | 3 | def main() -> int: 4 | foo: void* = malloc(123) 5 | foo++ # Error: cannot increment a value of type void* 6 | return 0 7 | -------------------------------------------------------------------------------- /examples/aoc2022/day03/sampleinput.txt: -------------------------------------------------------------------------------- 1 | vJrwpWtwJgWrhcsFMMfFFhFp 2 | jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL 3 | PmmdzqPrVvPwwTWBwg 4 | wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn 5 | ttgJtRGJQctTZtZT 6 | CrZsJsPPZsGzwwsLwLmpwMDw 7 | -------------------------------------------------------------------------------- /tests/other_errors/embed_file_cannot_evaluate.jou: -------------------------------------------------------------------------------- 1 | def runtime_thing() -> byte*: 2 | return "lol" 3 | 4 | global lol = embed_file(runtime_thing()) # Error: failed to evaluate file name at compile time 5 | -------------------------------------------------------------------------------- /tests/other_errors/noreturn_but_return_with_value_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> noreturn: 3 | return 1 # Error: method 'bar' cannot return because it was defined with '-> noreturn' 4 | -------------------------------------------------------------------------------- /tests/other_errors/wrong_num_args.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | getchar('m') # Error: function getchar() takes 0 arguments, but it was called with 1 argument 5 | return 0 6 | -------------------------------------------------------------------------------- /tests/syntax_error/funcptr_named_arg.jou: -------------------------------------------------------------------------------- 1 | def good(x: funcptr(int) -> int) -> None: 2 | pass 3 | 4 | def bad(x: funcptr(y: int) -> int) -> None: # Error: funcptr parameters cannot be named 5 | pass 6 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_return_type_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self): # Error: return type must be specified with '->', or with '-> None' if the method doesn't return anything 3 | return 4 | -------------------------------------------------------------------------------- /tests/too_long/huge_int_const.jou: -------------------------------------------------------------------------------- 1 | const x: int = 123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123 # Error: number is too long: 12312312312312312312... 2 | -------------------------------------------------------------------------------- /tests/too_long/name.jou: -------------------------------------------------------------------------------- 1 | def asdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasd() -> None: # Error: name is too long: asdasdasdasdasdasdas... 2 | return 3 | -------------------------------------------------------------------------------- /tests/wrong_place/global_in_method_python_style.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> None: 3 | global thing # Error: you don't need 'global' inside a function or method to use a global variable 4 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_or.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | # Uppercase OR seems to make this error message more readable 3 | x = 1 | "hello" # Error: wrong types: cannot take bitwise OR of int and byte* 4 | -------------------------------------------------------------------------------- /tests/wrong_type/class_member_assign.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | x: int 3 | 4 | def blah() -> None: 5 | f = Foo{x = 1} 6 | f.x = "hey" # Error: cannot assign a value of type byte* to field 'x' of type int 7 | -------------------------------------------------------------------------------- /tests/wrong_type/pointer_to_int.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | # Pointers (64-bit) do not fit in int (32-bit), so compiler errors 3 | x = 1 4 | y = &x as int # Error: cannot cast from type int* to int 5 | -------------------------------------------------------------------------------- /tests/wrong_type/voidptr_index.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/mem.jou" 2 | 3 | def main() -> int: 4 | foo: void* = malloc(123) 5 | foo[2] = 'x' # Error: value of type void* cannot be indexed 6 | return 0 7 | -------------------------------------------------------------------------------- /examples/aoc2022/day06/sampleinput.txt: -------------------------------------------------------------------------------- 1 | mjqjpqmgbljsphdztnvjfqwrcgsmlb 2 | bvwbjplbgvbhsrlpgdmjqwftvncz 3 | nppdvjthqldpwncqszvftbrmjlhg 4 | nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg 5 | zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw 6 | -------------------------------------------------------------------------------- /tests/404/stdin.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | line: byte[100] 5 | fgets(line, sizeof(line), stdin) # Error: no variable named 'stdin', try 'get_stdin()' from "stdlib/io.jou" 6 | -------------------------------------------------------------------------------- /tests/already_exists_error/class_import_redefine_as_generic.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | class FILE[T]: # Error: a type named 'FILE' already exists (imported from "stdlib/io.jou" on line 1) 4 | x: int 5 | -------------------------------------------------------------------------------- /tests/other_errors/generic_doing_stuff_with_T.jou: -------------------------------------------------------------------------------- 1 | class Foo[T]: 2 | x: T 3 | 4 | def blah(self) -> None: 5 | thing = T{} # Error: the T{...} syntax is only for classes, but T is an unknown type 6 | -------------------------------------------------------------------------------- /tests/other_errors/main_public.jou: -------------------------------------------------------------------------------- 1 | # The main() function is special and does not need to be marked public. 2 | 3 | @public # Error: the main() function cannot be @public 4 | def main() -> int: 5 | return 0 6 | -------------------------------------------------------------------------------- /tests/other_errors/public_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | @public # Error: methods cannot be decorated with @public, a class is either fully public or fully private 3 | def bar(self) -> None: 4 | pass 5 | -------------------------------------------------------------------------------- /tests/other_errors/unexpected_generic_1.jou: -------------------------------------------------------------------------------- 1 | class Blah: 2 | pass 3 | 4 | def foo() -> None: 5 | # Compiler thinks you're trying to do e.g. "x: Blah[5]" 6 | x: Blah[int] # Error: invalid array length 7 | -------------------------------------------------------------------------------- /tests/other_errors/wrong_num_args_funcptr.jou: -------------------------------------------------------------------------------- 1 | def foo(f: funcptr(int, byte*) -> int) -> None: 2 | f(1,2,3) # Error: funcptr(int, byte*) takes 2 arguments, but it was called with 3 arguments 3 | return 0 4 | -------------------------------------------------------------------------------- /tests/wrong_type/bitwise_and.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | # Uppercase AND seems to make this error message more readable 3 | x = 1 & "hello" # Error: wrong types: cannot take bitwise AND of int and byte* 4 | -------------------------------------------------------------------------------- /tests/wrong_type/funcptr_ptr1.jou: -------------------------------------------------------------------------------- 1 | def foo() -> int: 2 | # Pointer to function pointer 3 | x: (funcptr() -> int)* = 123 # Error: initial value for variable of type (funcptr() -> int)* cannot be of type int 4 | -------------------------------------------------------------------------------- /tests/wrong_type/main_1_arg.jou: -------------------------------------------------------------------------------- 1 | def main( 2 | argc: int # Error: if the main() function takes parameters, it should be defined like this: def main(argc: int, argv: byte**) -> int 3 | ) -> int: 4 | return 0 5 | -------------------------------------------------------------------------------- /tests/wrong_type/ternary_values_with_type_hint.jou: -------------------------------------------------------------------------------- 1 | def foo() -> int: 2 | return ( 3 | 1 4 | if True 5 | else "lol" # Error: ternary values should be of type int, not byte* 6 | ) 7 | -------------------------------------------------------------------------------- /tests/syntax_error/python_cast_int.jou: -------------------------------------------------------------------------------- 1 | def blah() -> None: 2 | x = int("123") # Error: int is not a function, use 'as int' to convert between numbers or e.g. atoi() from "stdlib/str.jou" to convert a string to int 3 | -------------------------------------------------------------------------------- /tests/too_long/huge_int.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123 # Error: number is too long: 12312312312312312312... 3 | -------------------------------------------------------------------------------- /tests/wrong_type/dot_operator_intptr.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 123 3 | y = &x 4 | z = y.lolwat # Error: left side of '.' operator must be an instance of a class or a pointer to an instance, not int* 5 | -------------------------------------------------------------------------------- /tests/wrong_type/float_and_double.jou: -------------------------------------------------------------------------------- 1 | def foo(x: float) -> None: 2 | return 3 | 4 | def bar() -> None: 5 | foo(12.34 + 56F) # Error: first argument of function foo(x: float) should have type float, not double 6 | -------------------------------------------------------------------------------- /tests/wrong_type/funcptr_array1.jou: -------------------------------------------------------------------------------- 1 | def foo() -> int: 2 | # Array of function pointers 3 | x: (funcptr() -> int)[5] = 123 # Error: initial value for variable of type (funcptr() -> int)[5] cannot be of type int 4 | -------------------------------------------------------------------------------- /tests/wrong_type/return_value_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> byte: 3 | x: int = 1 4 | return x # Error: attempting to return a value of type int from method 'bar' defined with '-> byte' 5 | -------------------------------------------------------------------------------- /examples/aoc2023/day21/sampleinput.txt: -------------------------------------------------------------------------------- 1 | ........... 2 | .....###.#. 3 | .###.##..#. 4 | ..#.#...#.. 5 | ....#.#.... 6 | .##..S####. 7 | .##..#...#. 8 | .......##.. 9 | .##.#.####. 10 | .##..##.##. 11 | ........... 12 | -------------------------------------------------------------------------------- /examples/aoc2025/day10/sampleinput.txt: -------------------------------------------------------------------------------- 1 | [.##.] (3) (1,3) (2) (2,3) (0,2) (0,1) {3,5,4,7} 2 | [...#.] (0,2,3,4) (2,3) (0,4) (0,1,2) (1,2,3,4) {7,5,12,7,2} 3 | [.###.#] (0,1,2,3,4) (0,3,4) (0,1,2,4,5) (1,2) {10,11,11,5,10,5} 4 | -------------------------------------------------------------------------------- /tests/already_exists_error/method_and_union_member.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def x(self) -> int: 3 | pass 4 | union: # Error: class fields must be defined before methods 5 | x: int64 6 | y: byte 7 | -------------------------------------------------------------------------------- /tests/already_exists_error/union_member.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | union: 3 | x: int 4 | y: byte* 5 | union: 6 | x: int64 # Error: class Foo already has a union member named 'x' 7 | z: byte 8 | -------------------------------------------------------------------------------- /tests/already_exists_error/union_member_and_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | union: 3 | x: int64 4 | y: byte 5 | def x(self) -> int: # Error: class Foo already has a union member named 'x' 6 | pass 7 | -------------------------------------------------------------------------------- /tests/other_errors/generic_wrong_num_params.jou: -------------------------------------------------------------------------------- 1 | class Foo[T]: 2 | x: T 3 | 4 | def foo() -> None: 5 | f = Foo[int, byte]{} # Error: generic class Foo[T] takes 1 type parameter, but it is used with 2 type parameters 6 | -------------------------------------------------------------------------------- /tests/should_succeed/assign.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | message = "Hello" 5 | puts(message) # Output: Hello 6 | message = "Hi" 7 | puts(message) # Output: Hi 8 | return 0 9 | -------------------------------------------------------------------------------- /tests/syntax_error/python_cast_byte.jou: -------------------------------------------------------------------------------- 1 | def blah() -> None: 2 | x = byte("123") # Error: byte is not a function, use 'as byte' to convert between numbers or e.g. atoi() from "stdlib/str.jou" to convert a string to int 3 | -------------------------------------------------------------------------------- /tests/syntax_error/tab.jou: -------------------------------------------------------------------------------- 1 | # This file contains a tab character. Make sure your editor doesn't ruin it. 2 | def main() -> int: 3 | return 0 # Error: Jou files cannot contain tab characters (use 4 spaces for indentation) 4 | -------------------------------------------------------------------------------- /tests/wrong_type/dot_operator_intptr_call.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 123 3 | y = &x 4 | z = y.lolwat() # Error: left side of '.' operator must be an instance of a class or a pointer to an instance, not int* 5 | -------------------------------------------------------------------------------- /tests/wrong_type/using_class_like_enum.jou: -------------------------------------------------------------------------------- 1 | class BlahBlah: 2 | x: int 3 | 4 | def foo() -> int: 5 | wat = BlahBlah.x # Error: class members cannot be accessed directly on the class, they only exist on instances 6 | -------------------------------------------------------------------------------- /examples/aoc2023/day08/sampleinput3.txt: -------------------------------------------------------------------------------- 1 | LR 2 | 3 | 11A = (11B, XXX) 4 | 11B = (XXX, 11Z) 5 | 11Z = (11B, XXX) 6 | 22A = (22B, XXX) 7 | 22B = (22C, 22C) 8 | 22C = (22Z, 22Z) 9 | 22Z = (22B, 22B) 10 | XXX = (XXX, XXX) 11 | -------------------------------------------------------------------------------- /tests/already_exists_error/class_and_function.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | class foo: 4 | x: int 5 | 6 | def foo() -> foo: # Error: a type named 'foo' already exists (defined on line 3) 7 | return foo{x = 123} 8 | -------------------------------------------------------------------------------- /tests/other_errors/using_method_with_none_return.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def f(self) -> None: 3 | return 4 | 5 | def g() -> None: 6 | foo = Foo{} 7 | x = foo.f() + 123 # Error: method 'f' does not return a value 8 | -------------------------------------------------------------------------------- /tests/should_succeed/cast_between_ptr_and_long.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | nums = [1, 2, 3] 5 | p = ((&nums[0] as int64) + 8) as int* 6 | printf("%d\n", *p) # Output: 3 7 | return 0 8 | -------------------------------------------------------------------------------- /tests/should_succeed/unused_const.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | const foo: int = 7 # Warning: constant 'foo' defined but not used 4 | 5 | def main() -> int: 6 | printf("it runs\n") # Output: it runs 7 | return 0 8 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_self.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar() -> None: # Error: missing self, should be 'def bar(self, ...)' 3 | return 4 | 5 | def main() -> int: 6 | f = Foo{} 7 | f.bar() 8 | return 0 9 | -------------------------------------------------------------------------------- /tests/syntax_error/python_cast_int64.jou: -------------------------------------------------------------------------------- 1 | def blah() -> None: 2 | x = int64("123") # Error: int64 is not a function, use 'as int64' to convert between numbers or e.g. atoll() from "stdlib/str.jou" to convert a string to int64 3 | -------------------------------------------------------------------------------- /tests/syntax_error/python_style_for.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | n = 123 3 | for item in range(n): # Error: Python-style for loops aren't supported. Use e.g. 'for i = 0; i < 10; i++' 4 | return 1 5 | return 0 6 | -------------------------------------------------------------------------------- /tests/wrong_type/funcptr_ptr2.jou: -------------------------------------------------------------------------------- 1 | def foo() -> int: 2 | # One function pointer that returns a pointer 3 | x: funcptr() -> int* = 123 # Error: initial value for variable of type funcptr() -> int* cannot be of type int 4 | -------------------------------------------------------------------------------- /tests/wrong_type/main_argc.jou: -------------------------------------------------------------------------------- 1 | def main( 2 | argc: int64, argv: byte** # Error: if the main() function takes parameters, it should be defined like this: def main(argc: int, argv: byte**) -> int 3 | ) -> int: 4 | return 0 5 | -------------------------------------------------------------------------------- /tests/wrong_type/main_argv.jou: -------------------------------------------------------------------------------- 1 | def main( 2 | argc: int, argv: byte* # Error: if the main() function takes parameters, it should be defined like this: def main(argc: int, argv: byte**) -> int 3 | ) -> int: 4 | return 0 5 | -------------------------------------------------------------------------------- /examples/aoc2025/day11/sampleinput2.txt: -------------------------------------------------------------------------------- 1 | svr: aaa bbb 2 | aaa: fft 3 | fft: ccc 4 | bbb: tty 5 | tty: ccc 6 | ccc: ddd eee 7 | ddd: hub 8 | hub: fff 9 | eee: dac 10 | dac: fff 11 | fff: ggg hhh 12 | ggg: out 13 | hhh: out 14 | -------------------------------------------------------------------------------- /tests/syntax_error/python_cast_uint64.jou: -------------------------------------------------------------------------------- 1 | def blah() -> None: 2 | x = uint64("123") # Error: uint64 is not a function, use 'as uint64' to convert between numbers or e.g. atoll() from "stdlib/str.jou" to convert a string to int64 3 | -------------------------------------------------------------------------------- /tests/wrong_place/enum_inside_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> None: 3 | enum Baz: # Error: enums must be on top level, not e.g. inside a function 4 | Asd 5 | Blah 6 | Cacca 7 | -------------------------------------------------------------------------------- /tests/wrong_type/arg_varargs_funcptr.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def foo() -> None: 4 | f: funcptr(byte*, ...) -> int = printf 5 | f(1) # Error: first argument of funcptr(byte*, ...) should have type byte*, not int 6 | -------------------------------------------------------------------------------- /tests/wrong_type/funcptr_array2.jou: -------------------------------------------------------------------------------- 1 | def foo() -> int: 2 | # One function pointer that returns an array 3 | x: funcptr() -> int[5] = 123 # Error: initial value for variable of type funcptr() -> int[5] cannot be of type int 4 | -------------------------------------------------------------------------------- /tests/other_errors/import_conflict.jou: -------------------------------------------------------------------------------- 1 | import "./imported/func1.jou" 2 | import "./imported/func2.jou" # Error: files "./imported/func1.jou" and "./imported/func2.jou" cannot be imported into the same file, because they both define 'func' 3 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_second_equal_sign.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x = 1 3 | # TODO: improve the error message? 4 | if x = 1: # Error: expected ':' followed by a new line with more indentation, got '=' 5 | return 6 | -------------------------------------------------------------------------------- /tests/wrong_type/assign_to_deref_non_pointer.jou: -------------------------------------------------------------------------------- 1 | # https://github.com/Akuli/jou/issues/24 2 | def main() -> int: 3 | foo = 1 4 | *foo = 2 # Error: the dereference operator '*' is only for pointers, not for int 5 | return 0 6 | -------------------------------------------------------------------------------- /tests/wrong_type/main_3_args.jou: -------------------------------------------------------------------------------- 1 | def main( 2 | argc: int, argv: byte**, lol: int # Error: if the main() function takes parameters, it should be defined like this: def main(argc: int, argv: byte**) -> int 3 | ) -> int: 4 | return 0 5 | -------------------------------------------------------------------------------- /tests/wrong_type/match_bool.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | match True: # Error: cannot match a value of type bool (use if/else instead) 5 | case True: 6 | printf("ya\n") 7 | return 0 8 | -------------------------------------------------------------------------------- /tests/wrong_place/class_union_after_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def do_thing(self) -> None: 3 | printf("%d\n", self.x) 4 | 5 | union: # Error: class fields must be defined before methods 6 | x: int 7 | y: byte 8 | -------------------------------------------------------------------------------- /tests/wrong_type/match_with_arg1.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/str.jou" 2 | 3 | def main() -> int: 4 | match 1 with strcmp: # Error: cannot match int with strcmp(s1: byte*, s2: byte*) 5 | case "hey": 6 | pass 7 | return 0 8 | -------------------------------------------------------------------------------- /tests/should_succeed/const_enum_count.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | enum FooBar: 4 | Foo 5 | Bar 6 | 7 | const N: int = enum_count(FooBar) 8 | 9 | def main() -> int: 10 | printf("%d\n", N) # Output: 2 11 | return 0 12 | -------------------------------------------------------------------------------- /tests/syntax_error/class_init_js_syntax.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | x: int 3 | 4 | # attempting to use javascript-style for initing class 5 | def foo() -> None: 6 | foo = Foo{x: 1} # Error: expected '=' followed by a value for field 'x', got ':' 7 | -------------------------------------------------------------------------------- /examples/aoc2023/day13/sampleinput.txt: -------------------------------------------------------------------------------- 1 | #.##..##. 2 | ..#.##.#. 3 | ##......# 4 | ##......# 5 | ..#.##.#. 6 | ..##..##. 7 | #.#.##.#. 8 | 9 | #...##..# 10 | #....#..# 11 | ..##..### 12 | #####.##. 13 | #####.##. 14 | ..##..### 15 | #....#..# 16 | -------------------------------------------------------------------------------- /examples/aoc2024/day08/sampleinput.txt: -------------------------------------------------------------------------------- 1 | ............ 2 | ........0... 3 | .....0...... 4 | .......0.... 5 | ....0....... 6 | ......A..... 7 | ............ 8 | ............ 9 | ........A... 10 | .........A.. 11 | ............ 12 | ............ 13 | -------------------------------------------------------------------------------- /tests/other_errors/assign_to_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> None: 3 | pass 4 | 5 | def foo() -> None: 6 | f = Foo{} 7 | f.bar = 123 # Error: Foo.bar() is a method, it can be called but it cannot be used in any other way 8 | -------------------------------------------------------------------------------- /tests/should_succeed/public_hello_printer.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | @public 4 | def print_hello() -> None: 5 | printf("Hello World!\n") 6 | 7 | def main() -> int: 8 | print_hello() # Output: Hello World! 9 | return 0 10 | -------------------------------------------------------------------------------- /examples/aoc2024/day14/sampleinput.txt: -------------------------------------------------------------------------------- 1 | p=0,4 v=3,-3 2 | p=6,3 v=-1,-3 3 | p=10,3 v=-1,2 4 | p=2,0 v=2,-1 5 | p=0,0 v=1,3 6 | p=3,0 v=-2,-2 7 | p=7,6 v=-1,-3 8 | p=3,0 v=-1,-2 9 | p=9,3 v=2,3 10 | p=7,3 v=-1,2 11 | p=2,4 v=2,-3 12 | p=9,5 v=-3,-3 13 | -------------------------------------------------------------------------------- /tests/other_errors/funcptr_method.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> None: 3 | pass 4 | 5 | 6 | def foo() -> None: 7 | f = Foo{} 8 | thing = f.bar # Error: Foo.bar() is a method, it can be called but it cannot be used in any other way 9 | -------------------------------------------------------------------------------- /tests/should_succeed/noreturn_method.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/process.jou" 2 | 3 | class Foo: 4 | def stop_the_process_silently(self) -> noreturn: 5 | exit(0) 6 | 7 | def main() -> int: 8 | f = Foo{} 9 | f.stop_the_process_silently() 10 | -------------------------------------------------------------------------------- /tests/wrong_type/funcptr_different_return_type.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def foo() -> None: 4 | f: funcptr(byte*) -> byte 5 | f = puts # Error: cannot assign a value of type funcptr(byte*) -> int to a variable of type funcptr(byte*) -> byte 6 | -------------------------------------------------------------------------------- /tests/wrong_type/match_function_num_args.jou: -------------------------------------------------------------------------------- 1 | def foo(a: byte*) -> int: 2 | return 0 3 | 4 | def main() -> int: 5 | match "hello" with foo: # Error: cannot match with function foo(a: byte*) 6 | case "hi": 7 | pass 8 | return 0 9 | -------------------------------------------------------------------------------- /examples/aoc2024/day18/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 5,4 2 | 4,2 3 | 4,5 4 | 3,0 5 | 2,1 6 | 6,3 7 | 2,4 8 | 1,5 9 | 0,6 10 | 3,3 11 | 2,6 12 | 5,1 13 | 1,2 14 | 5,5 15 | 2,5 16 | 6,5 17 | 1,4 18 | 0,4 19 | 6,4 20 | 1,1 21 | 6,1 22 | 1,0 23 | 0,5 24 | 1,6 25 | 2,0 26 | -------------------------------------------------------------------------------- /tests/wrong_type/funcptr_different_return_type_none.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def foo() -> None: 4 | f: funcptr(byte*) -> None 5 | f = puts # Error: cannot assign a value of type funcptr(byte*) -> int to a variable of type funcptr(byte*) -> None 6 | -------------------------------------------------------------------------------- /tests/wrong_type/funcptr_different_varargs.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def foo() -> None: 4 | f: funcptr(byte*) -> int 5 | f = printf # Error: cannot assign a value of type funcptr(byte*, ...) -> int to a variable of type funcptr(byte*) -> int 6 | -------------------------------------------------------------------------------- /tests/wrong_type/match_string_without_strcmp.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | match "hi": # Error: cannot match a value of type byte* (try adding 'with strcmp') 5 | case "ho": 6 | printf("ya\n") 7 | return 0 8 | -------------------------------------------------------------------------------- /tests/wrong_type/match_with_arg2.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/str.jou" 2 | 3 | def main() -> int: 4 | match "hey" with strcmp: 5 | case 1: # Error: case value cannot be int when matching with strcmp(s1: byte*, s2: byte*) 6 | pass 7 | return 0 8 | -------------------------------------------------------------------------------- /tests/404/char_array_corner_case.jou: -------------------------------------------------------------------------------- 1 | const SIZE: int = 10 2 | 3 | # This is in a separate test because the error comes from a different place in the compiler. 4 | def foo(x: char[SIZE]) -> None: # Error: there is no type named 'char', use 'byte' instead 5 | pass 6 | -------------------------------------------------------------------------------- /tests/already_exists_error/const_import.jou: -------------------------------------------------------------------------------- 1 | import "../should_succeed/imported/magic_constant.jou" 2 | const MAGIC_CONSTANT: int = 42 # Error: a constant named 'MAGIC_CONSTANT' already exists (imported from "../should_succeed/imported/magic_constant.jou" on line 1) 3 | -------------------------------------------------------------------------------- /tests/other_errors/self_take_arg.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self, x: int) -> None: 3 | return 4 | 5 | def main() -> int: 6 | f = Foo{} 7 | f.bar(1, 2) # Error: method bar(x: int) takes 1 argument, but it was called with 2 arguments 8 | return 0 9 | -------------------------------------------------------------------------------- /tests/should_succeed/assert_success.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/assert.jou" 2 | import "stdlib/io.jou" 3 | 4 | assert WINDOWS or not WINDOWS 5 | 6 | def main() -> int: 7 | assert True 8 | assert 1 == 1 9 | printf("ok\n") # Output: ok 10 | return 0 11 | -------------------------------------------------------------------------------- /tests/should_succeed/unicode_varname.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def füncŧiøn() -> None: 4 | yrjö = 1 5 | örkkiläinen = 2 6 | printf("%d\n", yrjö + örkkiläinen) # Output: 3 7 | 8 | def main() -> int: 9 | füncŧiøn() 10 | return 0 11 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_end_quote_in_byte.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | # Output: compiler error in file "tests/syntax_error/missing_end_quote_in_byte.jou", line 5: missing ' to end the byte literal 4 | def main() -> int: 5 | printf('?) 6 | return 0 7 | -------------------------------------------------------------------------------- /tests/syntax_error/missing_end_quote_in_string.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | # Output: compiler error in file "tests/syntax_error/missing_end_quote_in_string.jou", line 5: missing " to end the string 4 | def main() -> int: 5 | printf("Hello) 6 | return 0 7 | -------------------------------------------------------------------------------- /tests/should_succeed/enum_and_local_var.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | enum Foo: # Warning: enum 'Foo' defined but not used 4 | Bar 5 | Baz 6 | 7 | def main() -> int: 8 | Foo = 123 9 | printf("%d\n", Foo) # Output: 123 10 | return 0 11 | -------------------------------------------------------------------------------- /tests/syntax_error/match_bad_case_parens.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | One 3 | Two 4 | Three 5 | 6 | def blah(f: Foo) -> None: 7 | match f: 8 | case (Foo.One Foo.Two): # Error: expected a ')', got a variable name 'Foo' 9 | printf("hi\n") 10 | -------------------------------------------------------------------------------- /tests/syntax_error/match_no_case_keyword.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | One 3 | Two 4 | Three 5 | 6 | def blah(f: Foo) -> None: 7 | match f: 8 | Foo.One: # Error: expected the 'case' keyword, got a variable name 'Foo' 9 | printf("hi\n") 10 | -------------------------------------------------------------------------------- /tests/wrong_type/enum_as_vararg.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | enum Foo: 4 | Bar 5 | Baz 6 | 7 | def main() -> int: 8 | printf("%d\n", Foo.Bar) # Error: variadic arguments of function printf(pattern: byte*, ...) cannot be enums 9 | return 0 10 | -------------------------------------------------------------------------------- /tests/404/type_array.jou: -------------------------------------------------------------------------------- 1 | # This is tested separately from other type not found errors, because the 2 | # compiler creates this error in a different place than other type not 3 | # found errors. 4 | def foo() -> asd[10]: # Error: there is no type named 'asd' 5 | return 1 6 | -------------------------------------------------------------------------------- /tests/already_exists_error/global_var_import.jou: -------------------------------------------------------------------------------- 1 | import "../should_succeed/imported/public_global.jou" 2 | 3 | global public_global: int # Error: a global variable named 'public_global' already exists (imported from "../should_succeed/imported/public_global.jou" on line 1) 4 | -------------------------------------------------------------------------------- /tests/other_errors/address_of_method_call.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | class Foo: 4 | def bar(self) -> int: 5 | return 123 6 | 7 | def blah() -> None: 8 | f: Foo 9 | x = &f.bar() # Error: the '&' operator cannot be applied to a method call 10 | -------------------------------------------------------------------------------- /tests/other_errors/import_private_class.jou: -------------------------------------------------------------------------------- 1 | import "./imported/privates.jou" 2 | 3 | # TODO: error message could be better, should say that it exists but is not @public 4 | def foo() -> PrivateClass: # Error: there is no type named 'PrivateClass' 5 | return PrivateClass{} 6 | -------------------------------------------------------------------------------- /tests/other_errors/import_private_global_var.jou: -------------------------------------------------------------------------------- 1 | import "./imported/privates.jou" 2 | 3 | def main() -> int: 4 | # TODO: error message could be better, should say that it exists but is not @public 5 | x = globaah # Error: no variable named 'globaah' 6 | return 0 7 | -------------------------------------------------------------------------------- /tests/other_errors/missing_main_function.jou: -------------------------------------------------------------------------------- 1 | # Output: compiler error in file "tests/other_errors/missing_main_function.jou": missing `main` function to execute the program 2 | def test() -> None: # Warning: function 'test' defined but not used 3 | _ = "lol no main func" 4 | -------------------------------------------------------------------------------- /tests/should_succeed/imported/cycle.jou: -------------------------------------------------------------------------------- 1 | # This file is meant to be imported, not ran directly. 2 | 3 | import "stdlib/io.jou" 4 | import "../import_cycle.jou" 5 | 6 | @public 7 | def b(x: int) -> None: 8 | printf("b %d\n", x) 9 | if x > 0: 10 | a(x-1) 11 | -------------------------------------------------------------------------------- /tests/syntax_error/generic_missing_comma_use.jou: -------------------------------------------------------------------------------- 1 | class Foo[T1, T2]: 2 | pass 3 | 4 | def foo() -> None: 5 | # TODO: error message is not great, it is trying to interpret this as an array 6 | f: Foo[int int] # Error: expected an expression, got the 'int' keyword 7 | -------------------------------------------------------------------------------- /tests/wrong_type/funcptr_different_arg_type.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/str.jou" 2 | 3 | def foo() -> None: 4 | f: funcptr(byte*, int*) -> int 5 | f = strcmp # Error: cannot assign a value of type funcptr(byte*, byte*) -> int to a variable of type funcptr(byte*, int*) -> int 6 | -------------------------------------------------------------------------------- /doc/compiler_internals/images/libreoffice-to-png: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script creates design.png from the libreoffice file. 4 | 5 | set -ex 6 | libreoffice --headless --convert-to png design.odg 7 | convert design.png -trim +repage -bordercolor white -border 50 design.png 8 | -------------------------------------------------------------------------------- /examples/aoc2023/day17/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 2413432311323 2 | 3215453535623 3 | 3255245654254 4 | 3446585845452 5 | 4546657867536 6 | 1438598798454 7 | 4457876987766 8 | 3637877979653 9 | 4654967986887 10 | 4564679986453 11 | 1224686865563 12 | 2546548887735 13 | 4322674655533 14 | -------------------------------------------------------------------------------- /tests/other_errors/import_conflict_function_and_class.jou: -------------------------------------------------------------------------------- 1 | import "./imported/func1.jou" 2 | import "./imported/class_named_func.jou" # Error: files "./imported/func1.jou" and "./imported/class_named_func.jou" cannot be imported into the same file, because they both define 'func' 3 | -------------------------------------------------------------------------------- /tests/other_errors/import_private_enum.jou: -------------------------------------------------------------------------------- 1 | import "./imported/privates.jou" 2 | 3 | def main() -> int: 4 | # TODO: error message could be better, should say that it exists but is not @public 5 | x: PrivateEnum # Error: there is no type named 'PrivateEnum' 6 | return 0 7 | -------------------------------------------------------------------------------- /tests/other_errors/import_private_global_var_declare.jou: -------------------------------------------------------------------------------- 1 | import "./imported/privates.jou" 2 | 3 | def main() -> int: 4 | # TODO: error message could be better, should say that it exists but is not @public 5 | x = decl_g # Error: no variable named 'decl_g' 6 | return 0 7 | -------------------------------------------------------------------------------- /tests/should_succeed/main_funny_arg_names.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | # Usually the args are named "argc" and "argv", but you can name them whatever you want. 4 | def main(lol: int, wat: byte**) -> int: 5 | printf("lol = %d\n", lol) # Output: lol = 1 6 | return 0 7 | -------------------------------------------------------------------------------- /tests/syntax_error/double_with_E.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | # Uppercase E is banned because it looks visually similar to surrounding digits. 3 | # It looks like 2E3 is a thing, but it isn't. 4 | x = 1.2e3 5 | y = 1.2E3 # Error: invalid number or variable name "1.2E3" 6 | -------------------------------------------------------------------------------- /tests/already_exists_error/global_var_import_and_const.jou: -------------------------------------------------------------------------------- 1 | import "../should_succeed/imported/public_global.jou" 2 | 3 | const public_global: int = 7 # Error: a global variable named 'public_global' already exists (imported from "../should_succeed/imported/public_global.jou" on line 1) 4 | -------------------------------------------------------------------------------- /tests/other_errors/import_private_const.jou: -------------------------------------------------------------------------------- 1 | import "./imported/privates.jou" 2 | 3 | def main() -> int: 4 | # TODO: error message could be better, should say that it exists but is not @public 5 | x = PRIVATE_CONSTANT # Error: no variable named 'PRIVATE_CONSTANT' 6 | return 0 7 | -------------------------------------------------------------------------------- /tests/wrong_type/match_function_return_none.jou: -------------------------------------------------------------------------------- 1 | def foo(a: byte*, b: byte*) -> None: 2 | pass 3 | 4 | def main() -> int: 5 | match "hello" with foo: # Error: cannot match with function foo(a: byte*, b: byte*) -> None 6 | case "hi": 7 | pass 8 | return 0 9 | -------------------------------------------------------------------------------- /tests/other_errors/field_of_a_field_of_a_field_error.jou: -------------------------------------------------------------------------------- 1 | class FooX: 2 | x: int 3 | class FooY: 4 | y: FooX 5 | class FooZ: 6 | z: FooY 7 | 8 | def bar() -> None: 9 | FooZ{}.z.y.x++ # Error: cannot increment a field of a field of a field of a newly created instance 10 | -------------------------------------------------------------------------------- /tests/other_errors/import_private_function.jou: -------------------------------------------------------------------------------- 1 | import "./imported/privates.jou" 2 | 3 | def main() -> int: 4 | # TODO: error message could be better, should say that it exists but is not @public 5 | private_function() # Error: function 'private_function' not found 6 | return 0 7 | -------------------------------------------------------------------------------- /tests/should_succeed/unused_class.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | @public 4 | class Foo: 5 | x: int 6 | 7 | class Bar: # Warning: class 'Bar' defined but not used 8 | x: int 9 | 10 | def main() -> int: 11 | printf("it runs\n") # Output: it runs 12 | return 0 13 | -------------------------------------------------------------------------------- /tests/syntax_error/string_continue_on_next_line.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | # Output: compiler error in file "tests/syntax_error/string_continue_on_next_line.jou", line 6: missing " to end the string 4 | def main() -> int: 5 | a = "\ 6 | asdf 7 | printf(a) 8 | return 0 9 | -------------------------------------------------------------------------------- /tests/wrong_type/enums_mix_eq.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | Bar 3 | Baz 4 | 5 | enum Color: 6 | Red 7 | Green 8 | Bool 9 | 10 | def main() -> int: 11 | if Foo.Baz == Color.Green: # Error: wrong types: cannot compare Foo and Color 12 | pass 13 | return 0 14 | -------------------------------------------------------------------------------- /tests/wrong_type/funcptr_different_num_args.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/str.jou" 2 | 3 | def foo() -> None: 4 | f: funcptr(byte*, byte*, byte*) -> int 5 | f = strcmp # Error: cannot assign a value of type funcptr(byte*, byte*) -> int to a variable of type funcptr(byte*, byte*, byte*) -> int 6 | -------------------------------------------------------------------------------- /activate: -------------------------------------------------------------------------------- 1 | if ! [[ "$OS" =~ Windows ]]; then 2 | echo "The activate script is needed only on Windows." 3 | elif echo "$PATH" | tr : '\n' | grep -qFx "$PWD/mingw64/bin"; then 4 | echo "Already activated." 5 | else 6 | PS1="(jou dev) $PS1" 7 | export PATH="$PWD/mingw64/bin:$PATH" 8 | fi 9 | -------------------------------------------------------------------------------- /examples/aoc2023/day25/sampleinput.txt: -------------------------------------------------------------------------------- 1 | jqt: rhn xhk nvd 2 | rsh: frs pzl lsr 3 | xhk: hfx 4 | cmg: qnr nvd lhk bvb 5 | rhn: xhk bvb hfx 6 | bvb: xhk hfx 7 | pzl: lsr hfx nvd 8 | qnr: nvd 9 | ntq: jqt hfx bvb xhk 10 | nvd: lhk 11 | lsr: lhk 12 | rzs: qnr cmg lsr rsh 13 | frs: qnr lhk lsr 14 | -------------------------------------------------------------------------------- /tests/already_exists_error/class_import_redefine_generic_as_normal.jou: -------------------------------------------------------------------------------- 1 | import "../should_succeed/imported/generic.jou" 2 | 3 | class Point2D: # Error: a generic class named 'Point2D' already exists (imported from "../should_succeed/imported/generic.jou" on line 1) 4 | x: int 5 | y: int 6 | -------------------------------------------------------------------------------- /tests/other_errors/funcptr_method_ptr.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self) -> None: 3 | pass 4 | 5 | 6 | def foo() -> None: 7 | f = Foo{} 8 | f_ptr = &f 9 | thing = f_ptr.bar # Error: Foo.bar() is a method, it can be called but it cannot be used in any other way 10 | -------------------------------------------------------------------------------- /tests/other_errors/imported_error.jou: -------------------------------------------------------------------------------- 1 | # See what paths to other files in error messages look like. 2 | # https://github.com/Akuli/jou/issues/98 3 | 4 | import "./dumb_assignment.jou" 5 | # Output: compiler error in file "tests/other_errors/dumb_assignment.jou", line 2: cannot assign to a constant 6 | -------------------------------------------------------------------------------- /tests/wrong_type/match_class.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | class Foo: 4 | x: int 5 | y: int 6 | 7 | def main() -> int: 8 | match Foo{x=1, y=2}: # Error: cannot match a value of type Foo 9 | case Foo{x=1, y=2}: 10 | printf("ya\n") 11 | return 0 12 | -------------------------------------------------------------------------------- /tests/wrong_type/match_function_return_type.jou: -------------------------------------------------------------------------------- 1 | def foo(a: byte*, b: byte*) -> byte*: 2 | return NULL 3 | 4 | def main() -> int: 5 | match "hello" with foo: # Error: cannot match with function foo(a: byte*, b: byte*) -> byte* 6 | case "hi": 7 | pass 8 | return 0 9 | -------------------------------------------------------------------------------- /tests/wrong_type/method_arg.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | def bar(self, x: int, y: int, z: byte*) -> None: 3 | pass 4 | 5 | def main() -> int: 6 | f = Foo{} 7 | f.bar(1, 2, 3) # Error: third argument of method bar(x: int, y: int, z: byte*) should have type byte*, not int 8 | return 0 9 | -------------------------------------------------------------------------------- /examples/aoc2023/day18/sampleinput.txt: -------------------------------------------------------------------------------- 1 | R 6 (#70c710) 2 | D 5 (#0dc571) 3 | L 2 (#5713f0) 4 | D 2 (#d2c081) 5 | R 2 (#59c680) 6 | D 2 (#411b91) 7 | L 5 (#8ceee2) 8 | U 2 (#caa173) 9 | L 1 (#1b58a2) 10 | U 2 (#caa171) 11 | R 2 (#7807d2) 12 | U 3 (#a77fa3) 13 | L 2 (#015232) 14 | U 2 (#7a21e3) 15 | -------------------------------------------------------------------------------- /examples/memory_leak.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | import "stdlib/mem.jou" 3 | import "stdlib/str.jou" 4 | 5 | def main() -> int: 6 | foo: byte* = malloc(100) 7 | strcpy(foo, "Hello") 8 | strcpy(&foo[5], "World") 9 | puts(foo) # Output: HelloWorld 10 | 11 | return 0 12 | -------------------------------------------------------------------------------- /tests/syntax_error/assign_to_None.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | # error message is kinda weird, but IMO it's ok. 3 | # Not many people will run into this. It's not tempting for a Python programmer. 4 | None = 123 # Error: None is not a value in Jou, use e.g. -1 for numbers or NULL for pointers 5 | -------------------------------------------------------------------------------- /tests/other_errors/match_missing_1.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | One 3 | Two 4 | Three 5 | 6 | def blah() -> None: 7 | match Foo.One: # Error: enum member Foo.Three not handled in match statement 8 | case Foo.One: 9 | pass 10 | case Foo.Two: 11 | pass 12 | -------------------------------------------------------------------------------- /tests/other_errors/python_init_method.jou: -------------------------------------------------------------------------------- 1 | # This isn't special-cased, because it's not as tempting to try as __init__ in class. 2 | def __init__() -> None: 3 | pass 4 | 5 | class Foo: 6 | def __init__(self) -> None: # Error: Jou does not have a special __init__ method like Python 7 | pass 8 | -------------------------------------------------------------------------------- /tests/should_succeed/crlf.jou: -------------------------------------------------------------------------------- 1 | # This file has CRLF line endings. Make sure your editor doesn't ruin them. 2 | import "stdlib/io.jou" 3 | 4 | def main() -> int: 5 | # Output: hi 6 | putchar('h') 7 | putchar('i') 8 | putchar('\r') 9 | putchar('\n') 10 | return 0 11 | -------------------------------------------------------------------------------- /tests/should_succeed/imported/level1/level2/deep.jou: -------------------------------------------------------------------------------- 1 | # This file tests "../../" imports, which were previously broken. 2 | 3 | import "stdlib/io.jou" 4 | import "../../bar.jou" 5 | 6 | @public 7 | def do_deep_stuff() -> None: 8 | printf("Deep stuff... ") 9 | bar(Point{x = 123, y = 456}) 10 | -------------------------------------------------------------------------------- /tests/should_succeed/unused_typedef.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | typedef Foo = int 4 | typedef Bar = int64* # Warning: type 'Bar' defined but not used 5 | 6 | @public 7 | typedef PublicFoo = int* 8 | 9 | def main() -> Foo: 10 | printf("it runs\n") # Output: it runs 11 | return 0 12 | -------------------------------------------------------------------------------- /tests/syntax_error/double_assignment_comma_untyped.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | # Python's unpack syntax is not supported in Jou. 3 | # If you think it should be supported, note that it conflicts with "x, y: int" syntax (see #536). 4 | x, y = 0 # Error: only one variable can be assigned at a time 5 | -------------------------------------------------------------------------------- /tests/syntax_error/match_bad_case.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | One 3 | Two 4 | Three 5 | 6 | def blah(f: Foo) -> None: 7 | match f: 8 | case Foo.One Foo.Two: # Error: expected ':' followed by a new line with more indentation, got a variable name 'Foo' 9 | printf("hi\n") 10 | -------------------------------------------------------------------------------- /tests/wrong_type/match_float.jou: -------------------------------------------------------------------------------- 1 | def bruh() -> None: 2 | # Floats and doubles usually shouldn't be == compared, so matching them 3 | # is a bad idea (unless you use "match ... with ..." syntax) 4 | match 1.0: # Error: cannot match a value of type double 5 | case 2.0: 6 | pass 7 | -------------------------------------------------------------------------------- /tests/syntax_error/double_plus.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | # The + character is not allowed because it doesn't do anything useful. 3 | # As error message shows, the compiler doesn't see it as belonging to the double. 4 | x = 1.2e3 5 | y = 1.2e+3 # Error: invalid number or variable name "1.2e" 6 | -------------------------------------------------------------------------------- /tests/other_errors/assert_fail.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/assert.jou" 2 | 3 | def main() -> int: 4 | lol = True 5 | wat = True 6 | assert lol and wat 7 | assert lol and not wat # Output: Assertion 'lol and not wat' failed in file "tests/other_errors/assert_fail.jou", line 7. 8 | 9 | return 0 10 | -------------------------------------------------------------------------------- /tests/should_succeed/expfloat.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | printf("%.5f\n", 3e5) # Output: 300000.00000 5 | printf("%.5f\n", 3e-2) # Output: 0.03000 6 | printf("%.5f\n", 12.34e2) # Output: 1234.00000 7 | printf("%.5f\n", 12.34e-2) # Output: 0.12340 8 | return 0 9 | -------------------------------------------------------------------------------- /tests/should_succeed/function_and_var_same_name.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def foo() -> None: 4 | printf("Foo!\n") 5 | 6 | def bar() -> None: 7 | foo() 8 | 9 | def main() -> int: 10 | foo = 123 11 | printf("%d\n", foo) # Output: 123 12 | bar() # Output: Foo! 13 | return 0 14 | -------------------------------------------------------------------------------- /tests/should_succeed/link_with_liblzma_dynamic.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | import "./imported/simple_lzma_decode.jou" 3 | 4 | link "-llzma" 5 | 6 | def main() -> int: 7 | result = simple_lzma_decode("tests/data/hellohellohello.xz") 8 | puts(result) # Output: hellohellohello 9 | return 0 10 | -------------------------------------------------------------------------------- /tests/should_succeed/unused_enum.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | enum Foo: # Warning: enum 'Foo' defined but not used 4 | Asdf 5 | Bbb 6 | 7 | @public 8 | enum PublicFoo: 9 | Asdf 10 | Bbb 11 | 12 | def main() -> int: 13 | printf("it runs\n") # Output: it runs 14 | return 0 15 | -------------------------------------------------------------------------------- /tests/should_succeed/unused_global.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | global foo: int # Warning: global variable 'foo' defined but not used 4 | declare global bar: int64 # Warning: global variable 'bar' declared but not used 5 | 6 | def main() -> int: 7 | printf("it runs\n") # Output: it runs 8 | return 0 9 | -------------------------------------------------------------------------------- /tests/wrong_type/match_wrong_enum.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | One 3 | Two 4 | 5 | enum Bar: 6 | Three 7 | Four 8 | Five 9 | 10 | def bruh() -> None: 11 | match Foo.One: 12 | case Bar.Three: # Error: case value of type Bar cannot be matched against Foo 13 | printf("hi\n") 14 | -------------------------------------------------------------------------------- /tests/syntax_error/too_many_opening_parens.jou: -------------------------------------------------------------------------------- 1 | # As usual, I try to point the error at the first line where 2 | # things go wrong. In this case that means the first unbalanced 3 | # paren token. 4 | 5 | bar( # Error: '(' without a matching ')' 6 | (blah) 7 | (blah) 8 | ( 9 | blaah blah 10 | -------------------------------------------------------------------------------- /tests/syntax_error/unknown_escape_multibyte.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | # This error message doesn't mention the character being escaped, because 3 | # it is not ASCII and it actually consists of two bytes. The tokenizer 4 | # only sees the first byte when it errors. 5 | return '\ö' # Error: unknown '\' escape 6 | -------------------------------------------------------------------------------- /tests/should_succeed/sscanf.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | import "stdlib/str.jou" 3 | 4 | def calculate_sum(string: byte*) -> int: 5 | x, y: int 6 | sscanf(string, "%d + %d", &x, &y) 7 | return x + y 8 | 9 | def main() -> int: 10 | printf("%d\n", calculate_sum("12 + 3")) # Output: 15 11 | return 0 12 | -------------------------------------------------------------------------------- /tests/wrong_type/funcptr_different_noreturn.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/process.jou" 2 | 3 | def foo() -> None: 4 | f: funcptr(int) -> None 5 | 6 | # TODO: Maybe this should be allowed with any return type? 7 | f = exit # Error: cannot assign a value of type funcptr(int) -> noreturn to a variable of type funcptr(int) -> None 8 | -------------------------------------------------------------------------------- /tests/wrong_type/inplace_add_doesnt_go_back.jou: -------------------------------------------------------------------------------- 1 | def foo() -> None: 2 | x: byte = 'a' 3 | num: int = 123 4 | 5 | x += 123 as byte # no error 6 | x += 123 # no error, type of 123 inferred as int 7 | x += num # Error: addition produced a value of type int which cannot be assigned back to byte 8 | -------------------------------------------------------------------------------- /tests/other_errors/match_missing_1_or.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | One 3 | Two 4 | Three 5 | Four 6 | 7 | def blah() -> None: 8 | match Foo.One: # Error: enum member Foo.Four not handled in match statement 9 | case Foo.One | Foo.Two: 10 | pass 11 | case Foo.Three: 12 | pass 13 | -------------------------------------------------------------------------------- /examples/aoc2022/day07/sampleinput.txt: -------------------------------------------------------------------------------- 1 | $ cd / 2 | $ ls 3 | dir a 4 | 14848514 b.txt 5 | 8504156 c.dat 6 | dir d 7 | $ cd a 8 | $ ls 9 | dir e 10 | 29116 f 11 | 2557 g 12 | 62596 h.lst 13 | $ cd e 14 | $ ls 15 | 584 i 16 | $ cd .. 17 | $ cd .. 18 | $ cd d 19 | $ ls 20 | 4060174 j 21 | 8033020 d.log 22 | 5626152 d.ext 23 | 7214296 k 24 | -------------------------------------------------------------------------------- /tests/other_errors/generic_zero_params.jou: -------------------------------------------------------------------------------- 1 | class Foo[T]: 2 | pass 3 | 4 | def foo() -> None: 5 | # Error message talks about arrays rather than generics. IMO that's fine 6 | # because the same syntax is much more commonly used for arrays. 7 | x: Foo[] # Error: array length must be specified, e.g. int[10] instead of int[] 8 | -------------------------------------------------------------------------------- /tests/should_succeed/link_with_liblzma_relative_path.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | import "./imported/simple_lzma_decode.jou" 3 | 4 | link "../../tmp/tests/liblzma.a" 5 | 6 | def main() -> int: 7 | result = simple_lzma_decode("tests/data/hellohellohello.xz") 8 | puts(result) # Output: hellohellohello 9 | return 0 10 | -------------------------------------------------------------------------------- /tests/other_errors/runtime_return_1.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | # Make sure this code actually runs, so it isn't a compile error 5 | putchar('x') # Output: x 6 | putchar('\n') 7 | 8 | # Returning 1 from main makes the process exit with code 1, so it counts as a failure. 9 | return 1 10 | -------------------------------------------------------------------------------- /tests/syntax_error/and_or_chaining.jou: -------------------------------------------------------------------------------- 1 | def main() -> int: 2 | # Jou's behaviour is different from Python and C, but consistent with Python's 3 | # philosophy: explicit is good, as long as it is readable. 4 | x = (a and b) or c # no error 5 | y = a and b or c # Error: 'and' cannot be chained with 'or', you need more parentheses 6 | -------------------------------------------------------------------------------- /examples/aoc2023/day04/sampleinput.txt: -------------------------------------------------------------------------------- 1 | Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53 2 | Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19 3 | Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1 4 | Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83 5 | Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36 6 | Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11 7 | -------------------------------------------------------------------------------- /examples/aoc2024/day16/sampleinput.txt: -------------------------------------------------------------------------------- 1 | ############### 2 | #.......#....E# 3 | #.#.###.#.###.# 4 | #.....#.#...#.# 5 | #.###.#####.#.# 6 | #.#.#.......#.# 7 | #.#.#####.###.# 8 | #...........#.# 9 | ###.#.#####.#.# 10 | #...#.....#.#.# 11 | #.#.#.###.#.#.# 12 | #.....#...#.#.# 13 | #.###.#.#.#.#.# 14 | #S..#.....#...# 15 | ############### 16 | -------------------------------------------------------------------------------- /examples/aoc2024/day20/sampleinput.txt: -------------------------------------------------------------------------------- 1 | ############### 2 | #...#...#.....# 3 | #.#.#.#.#.###.# 4 | #S#...#.#.#...# 5 | #######.#.#.### 6 | #######.#.#...# 7 | #######.#.###.# 8 | ###..E#...#...# 9 | ###.#######.### 10 | #...###...#...# 11 | #.#####.#.###.# 12 | #.#...#.#.#...# 13 | #.#.#.#.#.#.### 14 | #...#...#...### 15 | ############### 16 | -------------------------------------------------------------------------------- /tests/other_errors/assert_fail_multiline.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/assert.jou" 2 | 3 | def main() -> int: 4 | lol = True 5 | wat = True 6 | assert ( # Output: Assertion '(lol and not wat)' failed in file "tests/other_errors/assert_fail_multiline.jou", line 6. 7 | lol 8 | and not wat 9 | ) 10 | 11 | return 0 12 | -------------------------------------------------------------------------------- /tests/other_errors/match_missing_2.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | One 3 | Two 4 | Three 5 | Four 6 | 7 | def blah() -> None: 8 | match Foo.One: # Error: the following 2 members of enum Foo are not handled in match statement: Three, Four 9 | case Foo.One: 10 | pass 11 | case Foo.Two: 12 | pass 13 | -------------------------------------------------------------------------------- /tests/wrong_type/uint16_instead_of_byte.jou: -------------------------------------------------------------------------------- 1 | def want_int(n: int) -> None: 2 | pass 3 | 4 | def want_byte(b: byte) -> None: 5 | pass 6 | 7 | def main() -> int: 8 | n = 123 as uint16 9 | want_int(n) 10 | want_byte(n) # Error: first argument of function want_byte(b: byte) should have type byte, not uint16 11 | return 0 12 | -------------------------------------------------------------------------------- /tests/should_succeed/indirect_method_import.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | import "./imported/point_factory.jou" 3 | 4 | def main() -> int: 5 | p = make_point() 6 | # This should work even though this file doesn't import the file 7 | # that defines the get_sum() method. 8 | printf("%d\n", p.get_sum()) # Output: 3 9 | return 0 10 | -------------------------------------------------------------------------------- /tests/should_succeed/return_string.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def return_string_1() -> byte*: 4 | return "Foo" 5 | 6 | def return_string_2() -> byte*: 7 | return "Bar" 8 | 9 | def main() -> int: 10 | s1 = return_string_1() 11 | s2 = return_string_2() 12 | printf("%s %s\n", s1, s2) # Output: Foo Bar 13 | return 0 14 | -------------------------------------------------------------------------------- /tests/wrong_type/match_function_varargs.jou: -------------------------------------------------------------------------------- 1 | # Otherwise the correct signature, but has "..." (varargs) which is not supported 2 | declare func(a: byte*, b: byte*, ...) -> int 3 | 4 | def main() -> int: 5 | match "hello" with func: # Error: cannot match with function func(a: byte*, b: byte*, ...) 6 | case "hi": 7 | pass 8 | return 0 9 | -------------------------------------------------------------------------------- /examples/aoc2025/day08/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 162,817,812 2 | 57,618,57 3 | 906,360,560 4 | 592,479,940 5 | 352,342,300 6 | 466,668,158 7 | 542,29,236 8 | 431,825,988 9 | 739,650,466 10 | 52,470,668 11 | 216,146,977 12 | 819,987,18 13 | 117,168,530 14 | 805,96,715 15 | 346,949,466 16 | 970,615,88 17 | 941,993,340 18 | 862,61,35 19 | 984,92,344 20 | 425,690,689 21 | -------------------------------------------------------------------------------- /tests/other_errors/func_then_method.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | class Foo: 4 | def do_stuff(self) -> None: 5 | printf("Doing stuff!\n") 6 | 7 | def make_foo() -> Foo: 8 | return Foo{} 9 | 10 | def bar() -> None: 11 | make_foo().do_stuff() # Error: cannot take address of a function call, needed for calling the do_stuff() method 12 | -------------------------------------------------------------------------------- /tests/should_succeed/stderr.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | # Must be in a separate file, because mixed stdout and stderr prints 4 | # tend to appear in inconsistent order when the output is piped. 5 | def main() -> int: 6 | fputs("hello\n", get_stderr()) # Output: hello 7 | fprintf(get_stderr(), "hello %d\n", 123) # Output: hello 123 8 | return 0 9 | -------------------------------------------------------------------------------- /examples/aoc2024/day13/sampleinput.txt: -------------------------------------------------------------------------------- 1 | Button A: X+94, Y+34 2 | Button B: X+22, Y+67 3 | Prize: X=8400, Y=5400 4 | 5 | Button A: X+26, Y+66 6 | Button B: X+67, Y+21 7 | Prize: X=12748, Y=12176 8 | 9 | Button A: X+17, Y+86 10 | Button B: X+84, Y+37 11 | Prize: X=7870, Y=6450 12 | 13 | Button A: X+69, Y+23 14 | Button B: X+27, Y+71 15 | Prize: X=18641, Y=10279 16 | -------------------------------------------------------------------------------- /examples/aoc2025/day07/sampleinput.txt: -------------------------------------------------------------------------------- 1 | .......S....... 2 | ............... 3 | .......^....... 4 | ............... 5 | ......^.^...... 6 | ............... 7 | .....^.^.^..... 8 | ............... 9 | ....^.^...^.... 10 | ............... 11 | ...^.^...^.^... 12 | ............... 13 | ..^...^.....^.. 14 | ............... 15 | .^.^.^.^.^...^. 16 | ............... 17 | -------------------------------------------------------------------------------- /tests/syntax_error/match_underscore_not_last.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | One 3 | Two 4 | Three 5 | 6 | def blah() -> None: 7 | match Foo.One: 8 | case Foo.One: 9 | pass 10 | case _: 11 | pass 12 | case Foo.Two: # Error: this case will never run, because 'case _:' above matches anything 13 | pass 14 | -------------------------------------------------------------------------------- /examples/aoc2023/day02/sampleinput.txt: -------------------------------------------------------------------------------- 1 | Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green 2 | Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue 3 | Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red 4 | Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red 5 | Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green 6 | -------------------------------------------------------------------------------- /tests/should_succeed/double_dotdot_import/more_nesting/double_dotdot_import.jou: -------------------------------------------------------------------------------- 1 | # This file tests "../../" imports, which were previously broken. 2 | 3 | import "stdlib/io.jou" 4 | import "../../imported/bar.jou" 5 | 6 | def main() -> int: 7 | printf("It runs\n") # Output: It runs 8 | bar(Point{x = 123, y = 456}) # Output: Bar Bar 123 456 9 | return 0 10 | -------------------------------------------------------------------------------- /examples/aoc2024/day05/sampleinput.txt: -------------------------------------------------------------------------------- 1 | 47|53 2 | 97|13 3 | 97|61 4 | 97|47 5 | 75|29 6 | 61|13 7 | 75|53 8 | 29|13 9 | 97|29 10 | 53|29 11 | 61|53 12 | 97|53 13 | 61|29 14 | 47|13 15 | 75|47 16 | 97|75 17 | 47|61 18 | 75|61 19 | 47|29 20 | 75|13 21 | 53|13 22 | 23 | 75,47,61,53,29 24 | 97,61,53,29,13 25 | 75,29,13 26 | 75,97,47,61,53 27 | 61,13,29 28 | 97,13,75,29,47 29 | -------------------------------------------------------------------------------- /tests/other_errors/match_twice.jou: -------------------------------------------------------------------------------- 1 | enum Foo: 2 | One 3 | Two 4 | Three 5 | 6 | def blah() -> None: 7 | match Foo.One: 8 | case Foo.One: 9 | pass 10 | case Foo.Two: 11 | pass 12 | case Foo.Three: 13 | pass 14 | case Foo.Two: # Error: enum member Two is handled twice 15 | pass 16 | -------------------------------------------------------------------------------- /tests/should_succeed/typedef_bug.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | import "./imported/typedef.jou" 3 | 4 | # This causes the compiler to figure out what PrivateInt is. It must do that 5 | # based on what's available in the imported file, not this file. 6 | const foo: PublicInt = 123 7 | 8 | def main() -> int: 9 | printf("%d\n", foo) # Output: 123 10 | return 0 11 | -------------------------------------------------------------------------------- /examples/aoc2024/day23/sampleinput.txt: -------------------------------------------------------------------------------- 1 | kh-tc 2 | qp-kh 3 | de-cg 4 | ka-co 5 | yn-aq 6 | qp-ub 7 | cg-tb 8 | vc-aq 9 | tb-ka 10 | wh-tc 11 | yn-cg 12 | kh-ub 13 | ta-co 14 | de-co 15 | tc-td 16 | tb-wq 17 | wh-td 18 | ta-ka 19 | td-qp 20 | aq-cg 21 | wq-ub 22 | ub-vc 23 | de-ta 24 | wq-aq 25 | wq-vc 26 | wh-yn 27 | ka-de 28 | kh-ta 29 | co-tc 30 | wh-qp 31 | tb-vc 32 | td-yn 33 | -------------------------------------------------------------------------------- /tests/should_succeed/not_warning.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | a = 1 5 | b = 2 6 | if not a != b: # Warning: use 'foo == bar' instead of 'not foo != bar' 7 | printf("Same\n") 8 | if not a == b: # Warning: use 'foo != bar' instead of 'not foo == bar' 9 | printf("Different\n") # Output: Different 10 | return 0 11 | -------------------------------------------------------------------------------- /tests/syntax_error/declare_global_with_value.jou: -------------------------------------------------------------------------------- 1 | # This code doesn't make any sense, because declare means "this 2 | # thing is defined somewhere else and I only reference it here". 3 | # So whatever other place actually has the variable is responsible 4 | # for giving it a default value. 5 | declare global x: int = 1 # Error: a value cannot be given when declaring a global variable 6 | -------------------------------------------------------------------------------- /.github/workflows/linux-i686.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | pull_request: 6 | 7 | jobs: 8 | test: 9 | runs-on: ubuntu-latest 10 | timeout-minutes: 10 11 | steps: 12 | - uses: actions/checkout@v4 13 | with: 14 | fetch-depth: 0 # Fetch the whole Git history for bootstrapping 15 | - run: cd vm && ./alpine.sh 16 | -------------------------------------------------------------------------------- /examples/hello_minimal.jou: -------------------------------------------------------------------------------- 1 | # This hello world program will work even if there is a problem with importing 2 | # stdlib/io.jou. It is sometimes useful when debugging the Jou compiler. It 3 | # might also help someone understand how `declare` works. 4 | 5 | declare puts(s: byte*) -> int 6 | 7 | def main() -> int: 8 | puts("Hello World") # Output: Hello World 9 | return 0 10 | -------------------------------------------------------------------------------- /tests/syntax_error/array_length_from_type.jou: -------------------------------------------------------------------------------- 1 | # This is a funny corner case. The compiler first interprets Foo[x*] as a 2 | # generic class, but then realizes that Foo is not generic and attempts to 3 | # interpret x* as an expression instead of a type. 4 | 5 | class Foo: 6 | pass 7 | 8 | def blah() -> None: 9 | x = 123 10 | y: Foo[x*] # Error: invalid array length 11 | -------------------------------------------------------------------------------- /tests/wrong_type/sort_comparator.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/sort.jou" 2 | import "stdlib/str.jou" 3 | 4 | def main() -> int: 5 | arr = ["hello", "world"] 6 | Sorter[byte*]{}.sort(arr, 2, strcmp) # Error: third argument of method sort(ptr: byte**, len: , comparator: funcptr(byte**, byte**) -> int) should have type funcptr(byte**, byte**) -> int, not funcptr(byte*, byte*) -> int 7 | -------------------------------------------------------------------------------- /tests/should_succeed/string_initialize_byte_array.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | foo: byte[50] = "hi" 5 | # Output: hi000000000000000000000000000000000000000000000000 6 | for i = 0; i < 50; i++: 7 | if foo[i] == '\0': 8 | putchar('0') 9 | else: 10 | putchar(foo[i]) 11 | putchar('\n') 12 | return 0 13 | -------------------------------------------------------------------------------- /tests/other_errors/instantiation_address_of_field.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/mem.jou" 2 | 3 | class Foo: 4 | x: int 5 | 6 | def make_foo_pointer() -> Foo*: 7 | return malloc(123) 8 | 9 | def asdf() -> None: 10 | magic_pointer = &make_foo_pointer().x # This succeeds 11 | magic_pointer = &Foo{}.x # Error: the '&' operator cannot be applied to a field of a newly created instance 12 | -------------------------------------------------------------------------------- /examples/fib.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def fib(n: int) -> int: 4 | if n <= 1: 5 | return n 6 | return fib(n-1) + fib(n-2) 7 | 8 | def main() -> int: 9 | printf("fib(10) = %d\n", fib(10)) # Output: fib(10) = 55 10 | printf("fib(20) = %d\n", fib(20)) # Output: fib(20) = 6765 11 | printf("fib(30) = %d\n", fib(30)) # Output: fib(30) = 832040 12 | return 0 13 | -------------------------------------------------------------------------------- /tests/should_succeed/imported/samename1.jou: -------------------------------------------------------------------------------- 1 | # Tests two files with non-public things that have same name. 2 | global value: int 3 | declare global the_counter: int 4 | const internal_num: int = 1 5 | 6 | def internal() -> None: 7 | value *= 9 + internal_num 8 | the_counter++ 9 | 10 | @public 11 | def public_func_1() -> int: 12 | value = 1 13 | internal() 14 | return value 15 | -------------------------------------------------------------------------------- /tests/should_succeed/imported/samename2.jou: -------------------------------------------------------------------------------- 1 | # Tests two files with non-public things that have same name. 2 | global value: int 3 | declare global the_counter: int 4 | const internal_num: int = 2 5 | 6 | def internal() -> None: 7 | value *= 18 + internal_num 8 | the_counter++ 9 | 10 | @public 11 | def public_func_2() -> int: 12 | value = 2 13 | internal() 14 | return value 15 | -------------------------------------------------------------------------------- /tests/other_errors/array_literal_as_a_pointer.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def foo() -> None: 4 | # This works 5 | message = ['h','i','\0'] 6 | puts(message) 7 | 8 | # This doesn't work, because you can't do &['h','i','\0'] 9 | puts(['h','i','\0']) # Error: cannot create a pointer into an array that comes from an array literal (try storing it to a local variable first) 10 | -------------------------------------------------------------------------------- /tests/should_succeed/loop_variable_reused_warning.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def main() -> int: 4 | # Output: inner loop says 0 1 2 5 | for i = 0; i < 3; i++: 6 | printf("inner loop says") 7 | for i = 0; i < 3; i++: # Warning: this loop is inside another loop that also uses variable 'i' 8 | printf(" %d", i) 9 | printf("\n") 10 | 11 | return 0 12 | -------------------------------------------------------------------------------- /examples/sort.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | import "stdlib/sort.jou" 3 | 4 | 5 | def main() -> int: 6 | numbers = [4, 5, 2, 1, 3] 7 | sort_int32(numbers, array_count(numbers)) 8 | 9 | # Output: 1 2 3 4 5 10 | for i = 0; i < array_count(numbers); i++: 11 | if i != 0: 12 | printf(" ") 13 | printf("%d", numbers[i]) 14 | printf("\n") 15 | 16 | return 0 17 | -------------------------------------------------------------------------------- /tests/should_succeed/empty_class.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | class Emptie: 4 | pass 5 | 6 | def main() -> int: 7 | e1: Emptie 8 | e2 = Emptie{} 9 | 10 | printf("%d\n", sizeof(e1)) # Output: 0 11 | printf("%d\n", sizeof(e2)) # Output: 0 12 | 13 | if &e1 == NULL: 14 | printf("wat?\n") 15 | if &e2 == NULL: 16 | printf("wat?\n") 17 | 18 | return 0 19 | -------------------------------------------------------------------------------- /tests/wrong_type/complex_funcptr_error.jou: -------------------------------------------------------------------------------- 1 | def one(a: int, b: int) -> funcptr() -> funcptr() -> None: 2 | return two # Error: attempting to return a value of type funcptr(int, int) -> funcptr() -> None from function 'one' defined with '-> funcptr() -> funcptr() -> None' 3 | 4 | 5 | def two(a: int, b: int) -> funcptr() -> None: 6 | return three 7 | 8 | 9 | def three() -> None: 10 | pass 11 | -------------------------------------------------------------------------------- /tests/should_succeed/array_size_const.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | import "stdlib/mem.jou" 3 | 4 | const N: int = 3 5 | 6 | 7 | def main() -> int: 8 | numbers: int[N] 9 | printf("%d\n", array_count(numbers)) # Output: 3 10 | 11 | memset(numbers, 0, sizeof(numbers)) 12 | numbers[2]++ 13 | printf("%d %d %d\n", numbers[0], numbers[1], numbers[2]) # Output: 0 0 1 14 | 15 | return 0 16 | -------------------------------------------------------------------------------- /tests/should_succeed/funcptr.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | 4 | def blah() -> int: 5 | printf("Blah!!\n") 6 | return 123 7 | 8 | 9 | def main() -> int: 10 | f = blah 11 | ret = f() # Output: Blah!! 12 | printf("Got %d\n", ret) # Output: Got 123 13 | 14 | g: funcptr(byte*, ...) -> int = printf 15 | g("Hello %s\n", "World") # Output: Hello World 16 | 17 | return 0 18 | -------------------------------------------------------------------------------- /tests/should_succeed/pass.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | pass # not useful, but also not wrong 4 | 5 | if WINDOWS: 6 | pass 7 | else: 8 | pass 9 | 10 | def main() -> int: 11 | pass 12 | 13 | if WINDOWS: 14 | pass 15 | else: 16 | pass 17 | 18 | a = 114514 19 | if a == 114514: 20 | pass 21 | else: 22 | puts("wat?") 23 | 24 | return 0 25 | -------------------------------------------------------------------------------- /tests/should_succeed/return_none.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def foo() -> None: 4 | putchar('h') 5 | putchar('i') 6 | putchar('\n') 7 | 8 | def skipper(skip: bool, c: byte) -> None: 9 | if skip: 10 | return 11 | putchar(c) 12 | putchar('\n') 13 | 14 | def main() -> int: 15 | skipper(False, 'a') # Output: a 16 | skipper(True, 'b') 17 | foo() # Output: hi 18 | return 0 19 | -------------------------------------------------------------------------------- /examples/aoc2024/day25/sampleinput.txt: -------------------------------------------------------------------------------- 1 | ##### 2 | .#### 3 | .#### 4 | .#### 5 | .#.#. 6 | .#... 7 | ..... 8 | 9 | ##### 10 | ##.## 11 | .#.## 12 | ...## 13 | ...#. 14 | ...#. 15 | ..... 16 | 17 | ..... 18 | #.... 19 | #.... 20 | #...# 21 | #.#.# 22 | #.### 23 | ##### 24 | 25 | ..... 26 | ..... 27 | #.#.. 28 | ###.. 29 | ###.# 30 | ###.# 31 | ##### 32 | 33 | ..... 34 | ..... 35 | ..... 36 | #.... 37 | #.#.. 38 | #.#.# 39 | ##### 40 | -------------------------------------------------------------------------------- /tests/should_succeed/shadow_function.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def foo() -> None: 4 | printf("Foo\n") 5 | 6 | def bar() -> None: 7 | printf("Bar\n") 8 | 9 | def foo_bar() -> None: 10 | foo = bar # Creates a new local variable named 'foo' 11 | foo() 12 | 13 | def main() -> int: 14 | foo() # Output: Foo 15 | foo_bar() # Output: Bar 16 | foo() # Output: Foo 17 | return 0 18 | -------------------------------------------------------------------------------- /tests/other_errors/function_call_indexing.jou: -------------------------------------------------------------------------------- 1 | def foo() -> int[3]: 2 | return [1, 2, 3] 3 | 4 | def bar() -> None: 5 | # This works 6 | my_var = foo() 7 | x = my_var[1] 8 | 9 | # This doesn't work, because foo()[1] is implemented as *((pointer to foo()) + some offset) 10 | x = foo()[1] # Error: cannot create a pointer into an array that comes from a function call (try storing it to a local variable first) 11 | -------------------------------------------------------------------------------- /tests/other_errors/match_enum_too_dynamic.jou: -------------------------------------------------------------------------------- 1 | enum Thing: 2 | Foo 3 | Bar 4 | Baz 5 | 6 | def do_stuff(t1: Thing, t2: Thing) -> None: 7 | match t1: 8 | # This is forbidden because it would be hard for the compiler to know 9 | # which values have been handled and which haven't 10 | case t2: # Error: 'case' value must be Thing.something when matching a value of enum Thing 11 | pass 12 | -------------------------------------------------------------------------------- /tests/should_succeed/bool_eq_bool.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | def do_stuff(a: bool, b: bool) -> None: 4 | if a == b: 5 | puts("Hi") 6 | 7 | def main() -> int: 8 | do_stuff(False, False) # Output: Hi 9 | 10 | # Output: 1001 11 | printf( 12 | "%d%d%d%d\n", 13 | True == True, 14 | True == False, 15 | False == True, 16 | False == False, 17 | ) 18 | 19 | return 0 20 | -------------------------------------------------------------------------------- /tests/should_succeed/unused_function.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | declare usleep(us: int) -> int # Warning: function 'usleep' declared but not used 4 | 5 | def foo(stuff: byte*) -> None: # Warning: function 'foo' defined but not used 6 | bar(stuff) 7 | 8 | def bar(stuff: byte*) -> None: 9 | printf("it doesn't run %s\n", stuff) 10 | 11 | def main() -> int: 12 | printf("it runs\n") # Output: it runs 13 | return 0 14 | -------------------------------------------------------------------------------- /tests/should_succeed/argument.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | # TODO: should there be a warning for this? Not sure. 4 | def unused_arg(asd: bool) -> None: 5 | return 6 | 7 | def putchar3(ch: int) -> None: 8 | putchar(ch) 9 | putchar(ch) 10 | putchar(ch) 11 | 12 | def main() -> int: 13 | # Output: yyyooo 14 | putchar3('y') 15 | putchar3('o') 16 | putchar('\n') 17 | 18 | unused_arg(True) 19 | 20 | return 0 21 | -------------------------------------------------------------------------------- /tests/should_succeed/link_with_liblzma_system_path.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | import "./imported/simple_lzma_decode.jou" 3 | 4 | # "pkg-config --variable=libdir liblzma" prints /usr/lib/x86_64-linux-gnu on a typical linux system 5 | link "`pkg-config --variable=libdir liblzma`/liblzma.a" 6 | 7 | def main() -> int: 8 | result = simple_lzma_decode("tests/data/hellohellohello.xz") 9 | puts(result) # Output: hellohellohello 10 | return 0 11 | -------------------------------------------------------------------------------- /examples/aoc2023/day19/sampleinput.txt: -------------------------------------------------------------------------------- 1 | px{a<2006:qkq,m>2090:A,rfg} 2 | pv{a>1716:R,A} 3 | lnx{m>1548:A,A} 4 | rfg{s<537:gd,x>2440:R,A} 5 | qs{s>3448:A,lnx} 6 | qkq{x<1416:A,crn} 7 | crn{x>2662:A,R} 8 | in{s<1351:px,qqz} 9 | qqz{s>2770:qs,m<1801:hdj,R} 10 | gd{a>3333:R,R} 11 | hdj{m>838:A,pv} 12 | 13 | {x=787,m=2655,a=1222,s=2876} 14 | {x=1679,m=44,a=2067,s=496} 15 | {x=2036,m=264,a=79,s=2244} 16 | {x=2461,m=1339,a=466,s=291} 17 | {x=2127,m=1623,a=2188,s=1013} 18 | -------------------------------------------------------------------------------- /tests/404/indirect_import_symbol.jou: -------------------------------------------------------------------------------- 1 | # If point_factory.jou imports Point, it doesn't mean that importing 2 | # point_factory.jou also gives you Point. 3 | # 4 | # To access Point, you would need to import the file that defines Point. 5 | # This is one of the ways how Jou's import is "better" than C's #include. 6 | 7 | import "../should_succeed/imported/point_factory.jou" 8 | 9 | def foo() -> None: 10 | p = Point{x=1, y=2} # Error: there is no type named 'Point' 11 | -------------------------------------------------------------------------------- /tests/other_errors/multiple_union_members_given.jou: -------------------------------------------------------------------------------- 1 | class Foo: 2 | union: 3 | blah: byte* 4 | lolwat: bool 5 | unrelated_value: int64 6 | union: 7 | x: int 8 | y: int 9 | 10 | def foo() -> None: 11 | f = Foo{ 12 | x = 1, 13 | blah = "hey!", 14 | unrelated_value = 12345, 15 | y = 2, # Error: fields 'x' and 'y' cannot be set simultaneously because they belong to the same union 16 | } 17 | -------------------------------------------------------------------------------- /tests/should_succeed/global.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | 3 | global x: int 4 | global y: int = 100 5 | global z = 200 6 | 7 | def increment_all() -> None: 8 | x++ 9 | y++ 10 | z++ 11 | 12 | def main() -> int: 13 | printf("%d %d %d\n", x, y, z) # Output: 0 100 200 14 | increment_all() 15 | printf("%d %d %d\n", x, y, z) # Output: 1 101 201 16 | increment_all() 17 | printf("%d %d %d\n", x, y, z) # Output: 2 102 202 18 | 19 | return 0 20 | -------------------------------------------------------------------------------- /tests/should_succeed/import_cycle.jou: -------------------------------------------------------------------------------- 1 | import "stdlib/io.jou" 2 | import "./imported/cycle.jou" 3 | 4 | @public 5 | def a(x: int) -> None: 6 | printf("a %d\n", x) 7 | if x > 0: 8 | b(x-1) 9 | 10 | # Output: a 10 11 | # Output: b 9 12 | # Output: a 8 13 | # Output: b 7 14 | # Output: a 6 15 | # Output: b 5 16 | # Output: a 4 17 | # Output: b 3 18 | # Output: a 2 19 | # Output: b 1 20 | # Output: a 0 21 | def main() -> int: 22 | a(10) 23 | return 0 24 | -------------------------------------------------------------------------------- /examples/aoc2023/day20/visualize.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | if [ $# != 1 ] || [[ "$1" =~ ^- ]]; then 6 | echo "Usage: $0 input.txt" 7 | exit 2 8 | fi 9 | 10 | dot -T png -o /tmp/aoc20-graph.png <( 11 | echo "digraph G {" 12 | cat "$1" | sed s/'#.*'// | sed '/^$/d' | sed -E s/'^%([A-Za-z0-9]*)'/'\1[label="flip-flop \1"]\n\1'/g | sed -E s/'^&([A-Za-z]*)'/'\1[label="conjunction \1"]\n\1'/g 13 | echo "}" 14 | ) 15 | open /tmp/aoc20-graph.png 16 | -------------------------------------------------------------------------------- /examples/aoc2025/day11/to_graphviz.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | ( 5 | echo 'digraph G {' 6 | echo '"you" [style=filled, fillcolor=red, fontcolor=white];' # thanks AI 7 | cat sampleinput.txt | while read line; do 8 | start=$(echo $line | cut -d: -f1) 9 | for part in $(echo $line | cut -d: -f2); do 10 | echo "$start -> $part;" 11 | done 12 | done 13 | echo '}' 14 | ) | dot -Tpng -o graph.png 15 | echo "Wrote graph.png" 16 | --------------------------------------------------------------------------------