From d2e488edb1ca47c0c2fa064744680a4f7bdf2dd1 Mon Sep 17 00:00:00 2001 From: David Gonzalez Martin Date: Thu, 17 Apr 2025 12:13:08 -0600 Subject: [PATCH] Update switch --- src/compiler.bbb | 50 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/src/compiler.bbb b/src/compiler.bbb index 5b5cdd1..728502b 100644 --- a/src/compiler.bbb +++ b/src/compiler.bbb @@ -242,30 +242,46 @@ CompilerCommand = enum >command_string = c_string_to_slice(argv[1]); - > a = #string_to_enum(CompilerCommand, command_string); - - >relative_file_path_pointer = argv[2]; - if (!relative_file_path_pointer) + > command_string_to_enum = #string_to_enum(CompilerCommand, command_string); + if (!command_string_to_enum.is_valid) { return 1; } - >relative_file_path = c_string_to_slice(relative_file_path_pointer); - - if (relative_file_path.length < 5) + >command = command_string_to_enum.enum_value; + switch (command) { - return 1; - } + .compile => + { + >relative_file_path_pointer = argv[2]; + if (!relative_file_path_pointer) + { + return 1; + } - >extension_start = string_last_character(relative_file_path, '.'); - if (extension_start == string_no_match) - { - return 1; - } + >relative_file_path = c_string_to_slice(relative_file_path_pointer); - if (!string_equal(relative_file_path[extension_start..], ".bbb")) - { - return 1; + if (relative_file_path.length < 5) + { + return 1; + } + + >extension_start = string_last_character(relative_file_path, '.'); + if (extension_start == string_no_match) + { + return 1; + } + + if (!string_equal(relative_file_path[extension_start..], ".bbb")) + { + return 1; + } + }, + .test => + { + // TODO + #trap(); + }, } return 0;