From f8894ea4c04977995487495ec92e7e8ec11b4a2a Mon Sep 17 00:00:00 2001 From: Kyler Date: Mon, 17 Nov 2025 22:53:15 -0700 Subject: [PATCH] Characters --- SLS_C/src/lexer.c | 49 +- SLS_C/tests/lexer_test_helpers.c | 2 +- SLS_C/tests/lexer_tests.c | 2278 +----------------------- SLS_Tests/cases.yaml | 2269 +---------------------- SLS_Tests/generate_tests/char_tests.py | 94 +- 5 files changed, 130 insertions(+), 4562 deletions(-) diff --git a/SLS_C/src/lexer.c b/SLS_C/src/lexer.c index 9af92f1..4e4232d 100644 --- a/SLS_C/src/lexer.c +++ b/SLS_C/src/lexer.c @@ -593,8 +593,48 @@ static LexerResult parse_numeric_literal(LexerInfo *lexer_info, char c, size_t s } static LexerResult parse_character_literal(LexerInfo *lexer_info, char c, size_t start, size_t start_line) { - (void)lexer_info; (void)c; (void)start; (void)start_line; - return (LexerResult){SLS_ERROR, .error = (SlsError){SLS_STR("Lexer: Character Literals Not Implemented Error."), 1}}; + if (c == '\'') + return lexer_error(lexer_info, SLS_STR("Invalid character literal: empty character literal."), start, start_line); + char value = '\0'; + if (c == '\\') { + c = advance(lexer_info); + switch (c) { + case 'n': + value = '\n'; + break; + case 'r': + value = '\r'; + break; + case 't': + value = '\t'; + break; + case '\\': + value = '\\'; + break; + case '\'': + value = '\''; + break; + case '0': + value = '\0'; + break; + default: + SlsStr error_msg = sls_format(SLS_STR("Invalid character literal: unknown escape sequence '\\%c'."), c); + if (error_msg.str == NULL) return (LexerResult){SLS_ERROR, .error = (SlsError){SLS_STR("Out Of Memory Error."), 1}}; + return lexer_error(lexer_info, error_msg, start, start_line); + } + } else if (c == '\n' || c == '\r') + return lexer_error(lexer_info, SLS_STR("Invalid character literal: unclosed character literal."), start, start_line); + else value = c; + c = advance(lexer_info); + if (isspace(c) || c == '/' || c == '\0') + return lexer_error(lexer_info, SLS_STR("Invalid character literal: unclosed character literal."), start, start_line); + else if (c != '\'') { + SlsStr error_msg = sls_format(SLS_STR("Invalid character literal: unexpected '%c' in character."), c); + if (error_msg.str == NULL) return (LexerResult){SLS_ERROR, .error = (SlsError){SLS_STR("Out Of Memory Error."), 1}}; + return lexer_error(lexer_info, error_msg, start, start_line); + } + advance(lexer_info); + return lexer_result(lexer_info, (Token){TOKEN_CHARACTER, .character_literal = (uint8_t){value}}, start, start_line); } static LexerResult parse_string_literal(LexerInfo *lexer_info, char c, size_t start, size_t start_line) { @@ -644,7 +684,10 @@ static LexerResult lexer_next(LexerInfo *lexer_info) { if (isdigit(c) || (c == '.' && isdigit(far_peek(lexer_info, 1))) || (c == '-' && isdigit(far_peek(lexer_info, 1)))) return parse_numeric_literal(lexer_info, c, start, start_line); // Character Literals - if (c == '\'') return parse_character_literal(lexer_info, c, start, start_line); + if (c == '\'') { + c = advance(lexer_info); + return parse_character_literal(lexer_info, c, start, start_line); + } // String Literals if (c == '\"') return parse_string_literal(lexer_info, c, start, start_line); // Token Strings diff --git a/SLS_C/tests/lexer_test_helpers.c b/SLS_C/tests/lexer_test_helpers.c index c2a7bf8..1c43161 100644 --- a/SLS_C/tests/lexer_test_helpers.c +++ b/SLS_C/tests/lexer_test_helpers.c @@ -291,7 +291,7 @@ Boolean test_integer_value(LexerTest *test, LexerResult result, size_t i, TestIn } Boolean test_character_value(LexerTest *test, LexerResult result, size_t i, uint8_t *value) { - static const TokenType token_type = TOKEN_INTEGER; + static const TokenType token_type = TOKEN_CHARACTER; LexerTokenResult *head = get_token(result.result, i); if (test_token_type(test, result, i, token_type)) { return TRUE; diff --git a/SLS_C/tests/lexer_tests.c b/SLS_C/tests/lexer_tests.c index d10bd07..912380b 100644 --- a/SLS_C/tests/lexer_tests.c +++ b/SLS_C/tests/lexer_tests.c @@ -16,7 +16,7 @@ #include "tests/tests.h" -static const size_t NUM_OF_TESTS = 448; +static const size_t NUM_OF_TESTS = 243; static TestResult test_Empty_Statement() { LexerTest test = start_up_test(SLS_STR("Empty_Statement"), SLS_STR("")); @@ -2073,18 +2073,18 @@ static TestResult test_Char_Right_Brace() { return pass_test(&test, result); } -static TestResult test_Char_Escape_Null_character() { - LexerTest test = start_up_test(SLS_STR("Char Escape Null character"), SLS_STR("'\0'")); +static TestResult test_Char_Escape_Single_quote() { + LexerTest test = start_up_test(SLS_STR("Char Escape Single quote"), SLS_STR("'\\''")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){0})) return test.result; + if (test_character_value(&test, result, i++, &(uint8_t){39})) return test.result; if (test_eof_value(&test, result, i++, 0)) return test.result; return pass_test(&test, result); } static TestResult test_Char_Escape_Tab() { - LexerTest test = start_up_test(SLS_STR("Char Escape Tab"), SLS_STR("'\t'")); + LexerTest test = start_up_test(SLS_STR("Char Escape Tab"), SLS_STR("'\\t'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2093,18 +2093,8 @@ static TestResult test_Char_Escape_Tab() { return pass_test(&test, result); } -static TestResult test_Char_Escape_Double_quote() { - LexerTest test = start_up_test(SLS_STR("Char Escape Double quote"), SLS_STR("'\\\"'")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){34})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - static TestResult test_Char_Escape_Carriage_return() { - LexerTest test = start_up_test(SLS_STR("Char Escape Carriage return"), SLS_STR("'\r'")); + LexerTest test = start_up_test(SLS_STR("Char Escape Carriage return"), SLS_STR("'\\r'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2114,7 +2104,7 @@ static TestResult test_Char_Escape_Carriage_return() { } static TestResult test_Char_Escape_Backslash() { - LexerTest test = start_up_test(SLS_STR("Char Escape Backslash"), SLS_STR("'\\'")); + LexerTest test = start_up_test(SLS_STR("Char Escape Backslash"), SLS_STR("'\\\\'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2123,18 +2113,8 @@ static TestResult test_Char_Escape_Backslash() { return pass_test(&test, result); } -static TestResult test_Char_Escape_Single_quote() { - LexerTest test = start_up_test(SLS_STR("Char Escape Single quote"), SLS_STR("'\''")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){39})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - static TestResult test_Char_Escape_Newline() { - LexerTest test = start_up_test(SLS_STR("Char Escape Newline"), SLS_STR("'\n'")); + LexerTest test = start_up_test(SLS_STR("Char Escape Newline"), SLS_STR("'\\n'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2143,68 +2123,8 @@ static TestResult test_Char_Escape_Newline() { return pass_test(&test, result); } -static TestResult test_Char_Newline() { - LexerTest test = start_up_test(SLS_STR("Char Newline"), SLS_STR("'\n'")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){10})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Char_Carriage_Return() { - LexerTest test = start_up_test(SLS_STR("Char Carriage Return"), SLS_STR("'\r'")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){13})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Char_Tab() { - LexerTest test = start_up_test(SLS_STR("Char Tab"), SLS_STR("'\t'")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){9})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Char_Backslash() { - LexerTest test = start_up_test(SLS_STR("Char Backslash"), SLS_STR("'\\'")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){92})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Char_Double_Quote() { - LexerTest test = start_up_test(SLS_STR("Char Double Quote"), SLS_STR("'\\\"'")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){34})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Char_Single_Quote() { - LexerTest test = start_up_test(SLS_STR("Char Single Quote"), SLS_STR("'\''")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){39})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Char_Null() { - LexerTest test = start_up_test(SLS_STR("Char Null"), SLS_STR("'\0'")); +static TestResult test_Char_Escape_Null_character() { + LexerTest test = start_up_test(SLS_STR("Char Escape Null character"), SLS_STR("'\\0'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2213,58 +2133,8 @@ static TestResult test_Char_Null() { return pass_test(&test, result); } -static TestResult test_Char_Hex_Escape_x41() { - LexerTest test = start_up_test(SLS_STR("Char Hex Escape \x41"), SLS_STR("'\x41'")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){65})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Char_Hex_Escape_x61() { - LexerTest test = start_up_test(SLS_STR("Char Hex Escape \x61"), SLS_STR("'\x61'")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){97})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Char_Hex_Escape_x20() { - LexerTest test = start_up_test(SLS_STR("Char Hex Escape \x20"), SLS_STR("'\x20'")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){32})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Char_Hex_Escape_x00() { - LexerTest test = start_up_test(SLS_STR("Char Hex Escape \x00"), SLS_STR("'\x00'")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){0})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Char_Hex_Escape_xFF() { - LexerTest test = start_up_test(SLS_STR("Char Hex Escape \xFF"), SLS_STR("'\xFF'")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){255})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - static TestResult test_Char_Hex_Lowercase_A() { - LexerTest test = start_up_test(SLS_STR("Char Hex Lowercase A"), SLS_STR("'\x61'")); + LexerTest test = start_up_test(SLS_STR("Char Hex Lowercase A"), SLS_STR("'\\x61'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2274,7 +2144,7 @@ static TestResult test_Char_Hex_Lowercase_A() { } static TestResult test_Char_Hex_Uppercase_A() { - LexerTest test = start_up_test(SLS_STR("Char Hex Uppercase A"), SLS_STR("'\x41'")); + LexerTest test = start_up_test(SLS_STR("Char Hex Uppercase A"), SLS_STR("'\\x41'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2284,7 +2154,7 @@ static TestResult test_Char_Hex_Uppercase_A() { } static TestResult test_Char_Hex_Space() { - LexerTest test = start_up_test(SLS_STR("Char Hex Space"), SLS_STR("'\x20'")); + LexerTest test = start_up_test(SLS_STR("Char Hex Space"), SLS_STR("'\\x20'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2294,7 +2164,7 @@ static TestResult test_Char_Hex_Space() { } static TestResult test_Char_Hex_Tab() { - LexerTest test = start_up_test(SLS_STR("Char Hex Tab"), SLS_STR("'\x09'")); + LexerTest test = start_up_test(SLS_STR("Char Hex Tab"), SLS_STR("'\\x09'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2304,7 +2174,7 @@ static TestResult test_Char_Hex_Tab() { } static TestResult test_Char_Hex_Newline() { - LexerTest test = start_up_test(SLS_STR("Char Hex Newline"), SLS_STR("'\x0A'")); + LexerTest test = start_up_test(SLS_STR("Char Hex Newline"), SLS_STR("'\\x0A'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2314,7 +2184,7 @@ static TestResult test_Char_Hex_Newline() { } static TestResult test_Char_Hex_Max_ASCII() { - LexerTest test = start_up_test(SLS_STR("Char Hex Max ASCII"), SLS_STR("'\x7F'")); + LexerTest test = start_up_test(SLS_STR("Char Hex Max ASCII"), SLS_STR("'\\x7F'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2387,7 +2257,7 @@ static TestResult test_Char_Multiple_Characters() { LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid character literal: multiple characters without escape sequence."))) return test.result; + if (test_for_error(&test, result, i++, SLS_STR("Invalid character literal: unexpected 'B' in character."))) return test.result; return pass_test(&test, result); } @@ -2405,7 +2275,7 @@ static TestResult test_Char_Unescaped_Newline() { LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid character literal: unescaped newline in character literal."))) return test.result; + if (test_for_error(&test, result, i++, SLS_STR("Invalid character literal: unclosed character literal."))) return test.result; return pass_test(&test, result); } @@ -2445,26 +2315,8 @@ static TestResult test_Char_Hex_Invalid_Digit() { return pass_test(&test, result); } -static TestResult test_Char_Double_Quotes() { - LexerTest test = start_up_test(SLS_STR("Char Double Quotes"), SLS_STR("\"A\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid character literal: character literals must use single quotes."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Char_No_Quotes() { - LexerTest test = start_up_test(SLS_STR("Char No Quotes"), SLS_STR("A")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Not a character literal: missing quotes."))) return test.result; - return pass_test(&test, result); -} - static TestResult test_Char_ASCII_Control_SOH() { - LexerTest test = start_up_test(SLS_STR("Char ASCII Control SOH"), SLS_STR("'\x01'")); + LexerTest test = start_up_test(SLS_STR("Char ASCII Control SOH"), SLS_STR("'\\x01'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2474,7 +2326,7 @@ static TestResult test_Char_ASCII_Control_SOH() { } static TestResult test_Char_ASCII_Control_BEL() { - LexerTest test = start_up_test(SLS_STR("Char ASCII Control BEL"), SLS_STR("'\x07'")); + LexerTest test = start_up_test(SLS_STR("Char ASCII Control BEL"), SLS_STR("'\\x07'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2484,7 +2336,7 @@ static TestResult test_Char_ASCII_Control_BEL() { } static TestResult test_Char_ASCII_Control_ESC() { - LexerTest test = start_up_test(SLS_STR("Char ASCII Control ESC"), SLS_STR("'\x1B'")); + LexerTest test = start_up_test(SLS_STR("Char ASCII Control ESC"), SLS_STR("'\\x1B'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2494,7 +2346,7 @@ static TestResult test_Char_ASCII_Control_ESC() { } static TestResult test_Char_ASCII_Control_DEL() { - LexerTest test = start_up_test(SLS_STR("Char ASCII Control DEL"), SLS_STR("'\x7F'")); + LexerTest test = start_up_test(SLS_STR("Char ASCII Control DEL"), SLS_STR("'\\x7F'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2504,7 +2356,7 @@ static TestResult test_Char_ASCII_Control_DEL() { } static TestResult test_Char_Extended_ASCII_Lower() { - LexerTest test = start_up_test(SLS_STR("Char Extended ASCII Lower"), SLS_STR("'\x80'")); + LexerTest test = start_up_test(SLS_STR("Char Extended ASCII Lower"), SLS_STR("'\\x80'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2514,7 +2366,7 @@ static TestResult test_Char_Extended_ASCII_Lower() { } static TestResult test_Char_Extended_ASCII_Upper() { - LexerTest test = start_up_test(SLS_STR("Char Extended ASCII Upper"), SLS_STR("'\xFF'")); + LexerTest test = start_up_test(SLS_STR("Char Extended ASCII Upper"), SLS_STR("'\\xFF'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2523,28 +2375,8 @@ static TestResult test_Char_Extended_ASCII_Upper() { return pass_test(&test, result); } -static TestResult test_Char_Backslash_Literal() { - LexerTest test = start_up_test(SLS_STR("Char Backslash Literal"), SLS_STR("'\\'")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){92})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Char_Single_Quote_Escaped() { - LexerTest test = start_up_test(SLS_STR("Char Single Quote Escaped"), SLS_STR("'\''")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_character_value(&test, result, i++, &(uint8_t){39})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - static TestResult test_Char_Hex_Lowercase_x() { - LexerTest test = start_up_test(SLS_STR("Char Hex Lowercase x"), SLS_STR("'\x41'")); + LexerTest test = start_up_test(SLS_STR("Char Hex Lowercase x"), SLS_STR("'\\x41'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2554,7 +2386,7 @@ static TestResult test_Char_Hex_Lowercase_x() { } static TestResult test_Char_Hex_Digits_Uppercase() { - LexerTest test = start_up_test(SLS_STR("Char Hex Digits Uppercase"), SLS_STR("'\xFF'")); + LexerTest test = start_up_test(SLS_STR("Char Hex Digits Uppercase"), SLS_STR("'\\xFF'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2564,7 +2396,7 @@ static TestResult test_Char_Hex_Digits_Uppercase() { } static TestResult test_Char_Hex_Digits_Lowercase() { - LexerTest test = start_up_test(SLS_STR("Char Hex Digits Lowercase"), SLS_STR("'\xff'")); + LexerTest test = start_up_test(SLS_STR("Char Hex Digits Lowercase"), SLS_STR("'\\xff'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2574,7 +2406,7 @@ static TestResult test_Char_Hex_Digits_Lowercase() { } static TestResult test_Char_Hex_Digits_Mixed() { - LexerTest test = start_up_test(SLS_STR("Char Hex Digits Mixed"), SLS_STR("'\xAb'")); + LexerTest test = start_up_test(SLS_STR("Char Hex Digits Mixed"), SLS_STR("'\\xAb'")); LexerResult result = lexical_analysis(&test.lexer_info); if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); size_t i = 0; @@ -2583,1851 +2415,6 @@ static TestResult test_Char_Hex_Digits_Mixed() { return pass_test(&test, result); } -static TestResult test_String_Empty() { - LexerTest test = start_up_test(SLS_STR("String Empty"), SLS_STR("\"\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR(""))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Simple() { - LexerTest test = start_up_test(SLS_STR("String Simple"), SLS_STR("\"hello\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("hello"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_With_Space() { - LexerTest test = start_up_test(SLS_STR("String With Space"), SLS_STR("\"hello world\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("hello world"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Single_Char() { - LexerTest test = start_up_test(SLS_STR("String Single Char"), SLS_STR("\"A\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("A"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Multiple_Words() { - LexerTest test = start_up_test(SLS_STR("String Multiple Words"), SLS_STR("\"The quick brown fox\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("The quick brown fox"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_With_Numbers() { - LexerTest test = start_up_test(SLS_STR("String With Numbers"), SLS_STR("\"abc123\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("abc123"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Only_Numbers() { - LexerTest test = start_up_test(SLS_STR("String Only Numbers"), SLS_STR("\"12345\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("12345"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Mixed_Case() { - LexerTest test = start_up_test(SLS_STR("String Mixed Case"), SLS_STR("\"HeLLo WoRLd\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("HeLLo WoRLd"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_With_Punctuation() { - LexerTest test = start_up_test(SLS_STR("String With Punctuation"), SLS_STR("\"Hello, World!\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("Hello, World!"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_With_Symbols() { - LexerTest test = start_up_test(SLS_STR("String With Symbols"), SLS_STR("\"@#$%^&*()\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("@#$%^&*()"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Multiple_Spaces() { - LexerTest test = start_up_test(SLS_STR("String Multiple Spaces"), SLS_STR("\"hello world\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("hello world"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Leading_Space() { - LexerTest test = start_up_test(SLS_STR("String Leading Space"), SLS_STR("\" hello\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR(" hello"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Trailing_Space() { - LexerTest test = start_up_test(SLS_STR("String Trailing Space"), SLS_STR("\"hello \"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("hello "))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Only_Spaces() { - LexerTest test = start_up_test(SLS_STR("String Only Spaces"), SLS_STR("\" \"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR(" "))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Newline() { - LexerTest test = start_up_test(SLS_STR("String Newline"), SLS_STR("\"hello\nworld\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("hello\nworld"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Tab() { - LexerTest test = start_up_test(SLS_STR("String Tab"), SLS_STR("\"hello\tworld\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("hello\tworld"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Carriage_Return() { - LexerTest test = start_up_test(SLS_STR("String Carriage Return"), SLS_STR("\"hello\rworld\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("hello\rworld"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Backslash() { - LexerTest test = start_up_test(SLS_STR("String Backslash"), SLS_STR("\"hello\\world\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("hello\\world"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Double_Quote() { - LexerTest test = start_up_test(SLS_STR("String Double Quote"), SLS_STR("\"say \\\"hello\\\"\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("say \"hello\""))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Single_Quote() { - LexerTest test = start_up_test(SLS_STR("String Single Quote"), SLS_STR("\"it\'s\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("it's"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Null_Char() { - LexerTest test = start_up_test(SLS_STR("String Null Char"), SLS_STR("\"hello\0world\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("hello\0world"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Multiple_Escapes() { - LexerTest test = start_up_test(SLS_STR("String Multiple Escapes"), SLS_STR("\"line1\nline2\nline3\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("line1\nline2\nline3"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Mixed_Escapes() { - LexerTest test = start_up_test(SLS_STR("String Mixed Escapes"), SLS_STR("\"tab\there\nnewline\\backslash\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("tab\there\nnewline\\backslash"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Escape_At_Start() { - LexerTest test = start_up_test(SLS_STR("String Escape At Start"), SLS_STR("\"\nhello\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("\nhello"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Escape_At_End() { - LexerTest test = start_up_test(SLS_STR("String Escape At End"), SLS_STR("\"hello\n\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("hello\n"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Consecutive_Escapes() { - LexerTest test = start_up_test(SLS_STR("String Consecutive Escapes"), SLS_STR("\"\n\n\n\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("\n\n\n"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_All_Escapes() { - LexerTest test = start_up_test(SLS_STR("String All Escapes"), SLS_STR("\"\n\r\t\\\"\'\0\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("\n\r\t\\\"\'\0"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Hex_Letter_A() { - LexerTest test = start_up_test(SLS_STR("String Hex Letter A"), SLS_STR("\"\x41\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("A"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Hex_Letter_a() { - LexerTest test = start_up_test(SLS_STR("String Hex Letter a"), SLS_STR("\"\x61\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("a"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Hex_Space() { - LexerTest test = start_up_test(SLS_STR("String Hex Space"), SLS_STR("\"\x20\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR(" "))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Hex_Tab() { - LexerTest test = start_up_test(SLS_STR("String Hex Tab"), SLS_STR("\"\x09\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("\t"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Hex_Newline() { - LexerTest test = start_up_test(SLS_STR("String Hex Newline"), SLS_STR("\"\x0A\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("\n"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Multiple_Hex() { - LexerTest test = start_up_test(SLS_STR("String Multiple Hex"), SLS_STR("\"\x48\x65\x6C\x6C\x6F\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("Hello"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Hex_Mixed() { - LexerTest test = start_up_test(SLS_STR("String Hex Mixed"), SLS_STR("\"Hello\x20World\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("Hello World"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Hex_Extended_ASCII() { - LexerTest test = start_up_test(SLS_STR("String Hex Extended ASCII"), SLS_STR("\"\xA9\xAE\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("©®"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Hex_Uppercase() { - LexerTest test = start_up_test(SLS_STR("String Hex Uppercase"), SLS_STR("\"\xFF\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("\xFF"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Hex_Lowercase() { - LexerTest test = start_up_test(SLS_STR("String Hex Lowercase"), SLS_STR("\"\xff\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("\xff"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Hex_Mixed_Case() { - LexerTest test = start_up_test(SLS_STR("String Hex Mixed Case"), SLS_STR("\"\xAb\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("\xAb"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Hex_Zero() { - LexerTest test = start_up_test(SLS_STR("String Hex Zero"), SLS_STR("\"\x00\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("\0"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Hex_Max() { - LexerTest test = start_up_test(SLS_STR("String Hex Max"), SLS_STR("\"\xFF\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("\xFF"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_With_Escaped_Newlines() { - LexerTest test = start_up_test(SLS_STR("String With Escaped Newlines"), SLS_STR("\"line1\nline2\nline3\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("line1\nline2\nline3"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Paragraph() { - LexerTest test = start_up_test(SLS_STR("String Paragraph"), SLS_STR("\"First line.\nSecond line.\nThird line.\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("First line.\nSecond line.\nThird line."))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Mixed_Line_Endings() { - LexerTest test = start_up_test(SLS_STR("String Mixed Line Endings"), SLS_STR("\"Windows\r\nUnix\nMac\r\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("Windows\r\nUnix\nMac\r"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Leading_Whitespace_Outside() { - LexerTest test = start_up_test(SLS_STR("String Leading Whitespace Outside"), SLS_STR(" \"hello\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("hello"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Trailing_Whitespace_Outside() { - LexerTest test = start_up_test(SLS_STR("String Trailing Whitespace Outside"), SLS_STR("\"hello\" ")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("hello"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Both_Whitespace_Outside() { - LexerTest test = start_up_test(SLS_STR("String Both Whitespace Outside"), SLS_STR(" \"hello\" ")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("hello"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Tab_Before() { - LexerTest test = start_up_test(SLS_STR("String Tab Before"), SLS_STR(" \"hello\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("hello"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Tabs_And_Newlines_Inside() { - LexerTest test = start_up_test(SLS_STR("String Tabs And Newlines Inside"), SLS_STR("\"hello\t\tworld\n\ntest\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("hello\t\tworld\n\ntest"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Only_Tabs() { - LexerTest test = start_up_test(SLS_STR("String Only Tabs"), SLS_STR("\"\t\t\t\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("\t\t\t"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Only_Newlines() { - LexerTest test = start_up_test(SLS_STR("String Only Newlines"), SLS_STR("\"\n\n\n\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("\n\n\n"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Mixed_Whitespace() { - LexerTest test = start_up_test(SLS_STR("String Mixed Whitespace"), SLS_STR("\" \t\n\r \"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR(" \t\n\r "))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Sentence() { - LexerTest test = start_up_test(SLS_STR("String Sentence"), SLS_STR("\"The quick brown fox jumps over the lazy dog.\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("The quick brown fox jumps over the lazy dog."))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Multiple_Sentences() { - LexerTest test = start_up_test(SLS_STR("String Multiple Sentences"), SLS_STR("\"First sentence. Second sentence. Third sentence.\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("First sentence. Second sentence. Third sentence."))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Long_With_Escapes() { - LexerTest test = start_up_test(SLS_STR("String Long With Escapes"), SLS_STR("\"This is a long string.\nIt has multiple lines.\nAnd some tabs\there.\nPlus quotes \"like this\".\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("This is a long string.\nIt has multiple lines.\nAnd some tabs\there.\nPlus quotes \"like this\"."))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Repetitive() { - LexerTest test = start_up_test(SLS_STR("String Repetitive"), SLS_STR("\"aaaaaaaaaa\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("aaaaaaaaaa"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_ASCII_Printable() { - LexerTest test = start_up_test(SLS_STR("String ASCII Printable"), SLS_STR("\" !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR(" !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Code_Like() { - LexerTest test = start_up_test(SLS_STR("String Code Like"), SLS_STR("\"int main() { return 0; }\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("int main() { return 0; }"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_JSON_Like() { - LexerTest test = start_up_test(SLS_STR("String JSON Like"), SLS_STR("\"{{\\\"key\\\": \\\"value\\\"}}\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("{\"key\": \"value\"}"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_URL() { - LexerTest test = start_up_test(SLS_STR("String URL"), SLS_STR("\"https://example.com/path?query=value\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("https://example.com/path?query=value"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Email() { - LexerTest test = start_up_test(SLS_STR("String Email"), SLS_STR("\"user@example.com\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("user@example.com"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Unix_Path() { - LexerTest test = start_up_test(SLS_STR("String Unix Path"), SLS_STR("\"/home/user/file.txt\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("/home/user/file.txt"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Windows_Path() { - LexerTest test = start_up_test(SLS_STR("String Windows Path"), SLS_STR("\"C:\\Users\\file.txt\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("C:\\Users\\file.txt"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_SQL_Like() { - LexerTest test = start_up_test(SLS_STR("String SQL Like"), SLS_STR("\"SELECT * FROM users WHERE id = 1\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("SELECT * FROM users WHERE id = 1"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Regex_Like() { - LexerTest test = start_up_test(SLS_STR("String Regex Like"), SLS_STR("\"[a-zA-Z0-9]+\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("[a-zA-Z0-9]+"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Unclosed() { - LexerTest test = start_up_test(SLS_STR("String Unclosed"), SLS_STR("\"hello")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid string literal: unclosed string literal."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Unescaped_Newline() { - LexerTest test = start_up_test(SLS_STR("String Unescaped Newline"), SLS_STR("\"hello\nworld\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid string literal: unescaped newline in string literal."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Invalid_Escape() { - LexerTest test = start_up_test(SLS_STR("String Invalid Escape"), SLS_STR("\"hello\\qworld\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid string literal: unknown escape sequence '\\q'."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Hex_Too_Short() { - LexerTest test = start_up_test(SLS_STR("String Hex Too Short"), SLS_STR("\"\x4\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid string literal: hexadecimal escape must have exactly 2 digits."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Hex_Too_Long() { - LexerTest test = start_up_test(SLS_STR("String Hex Too Long"), SLS_STR("\"\\x414\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid string literal: hexadecimal escape must have exactly 2 digits."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Hex_Invalid_Digit() { - LexerTest test = start_up_test(SLS_STR("String Hex Invalid Digit"), SLS_STR("\"\\xGG\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid string literal: invalid hexadecimal digit 'G'."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Single_Quotes() { - LexerTest test = start_up_test(SLS_STR("String Single Quotes"), SLS_STR("'hello'")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid string literal: string literals must use double quotes."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Backslash_At_End() { - LexerTest test = start_up_test(SLS_STR("String Backslash At End"), SLS_STR("\"hello\\\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid string literal: incomplete escape sequence at end."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Only_Escapes() { - LexerTest test = start_up_test(SLS_STR("String Only Escapes"), SLS_STR("\"\n\t\r\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("\n\t\r"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_With_Nulls() { - LexerTest test = start_up_test(SLS_STR("String With Nulls"), SLS_STR("\"a\0b\0c\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("a\0b\0c"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_String_Many_Escapes() { - LexerTest test = start_up_test(SLS_STR("String Many Escapes"), SLS_STR("\"\n\n\n\n\n\n\n\n\n\n\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_string_value(&test, result, i++, &SLS_STR("\n\n\n\n\n\n\n\n\n\n"))) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Simple_Lowercase() { - LexerTest test = start_up_test(SLS_STR("Identifier Simple Lowercase"), SLS_STR("hello")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("hello")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Simple_Uppercase() { - LexerTest test = start_up_test(SLS_STR("Identifier Simple Uppercase"), SLS_STR("HELLO")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("HELLO")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Mixed_Case() { - LexerTest test = start_up_test(SLS_STR("Identifier Mixed Case"), SLS_STR("HelloWorld")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("HelloWorld")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Single_Letter() { - LexerTest test = start_up_test(SLS_STR("Identifier Single Letter"), SLS_STR("x")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("x")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Single_Letter_Upper() { - LexerTest test = start_up_test(SLS_STR("Identifier Single Letter Upper"), SLS_STR("X")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("X")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_With_Numbers() { - LexerTest test = start_up_test(SLS_STR("Identifier With Numbers"), SLS_STR("var123")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("var123")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Numbers_End() { - LexerTest test = start_up_test(SLS_STR("Identifier Numbers End"), SLS_STR("myVar2")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("myVar2")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Mixed_Numbers() { - LexerTest test = start_up_test(SLS_STR("Identifier Mixed Numbers"), SLS_STR("a1b2c3")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("a1b2c3")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_With_Underscore() { - LexerTest test = start_up_test(SLS_STR("Identifier With Underscore"), SLS_STR("hello_world")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("hello_world")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Leading_Underscore() { - LexerTest test = start_up_test(SLS_STR("Identifier Leading Underscore"), SLS_STR("_private")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("_private")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Multiple_Underscores() { - LexerTest test = start_up_test(SLS_STR("Identifier Multiple Underscores"), SLS_STR("my_long_var_name")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("my_long_var_name")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Double_Underscore() { - LexerTest test = start_up_test(SLS_STR("Identifier Double Underscore"), SLS_STR("my__var")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("my__var")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Trailing_Underscore() { - LexerTest test = start_up_test(SLS_STR("Identifier Trailing Underscore"), SLS_STR("var_")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("var_")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Only_Underscores() { - LexerTest test = start_up_test(SLS_STR("Identifier Only Underscores"), SLS_STR("___")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("___")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Snake_Case() { - LexerTest test = start_up_test(SLS_STR("Identifier Snake Case"), SLS_STR("my_variable_name")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("my_variable_name")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Camel_Case() { - LexerTest test = start_up_test(SLS_STR("Identifier Camel Case"), SLS_STR("myVariableName")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("myVariableName")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Pascal_Case() { - LexerTest test = start_up_test(SLS_STR("Identifier Pascal Case"), SLS_STR("MyClassName")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("MyClassName")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_All_Caps() { - LexerTest test = start_up_test(SLS_STR("Identifier All Caps"), SLS_STR("MY_CONSTANT")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("MY_CONSTANT")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_Simple() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal Simple"), SLS_STR("::hello")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("hello")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_Uppercase() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal Uppercase"), SLS_STR("::Point")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("Point")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_Snake_Case() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal Snake Case"), SLS_STR("::my_var")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("my_var")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_Type_i64() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal Type i64"), SLS_STR("::i64")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("i64")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_Type_String() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal Type String"), SLS_STR("::String")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("String")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_Type_Point() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal Type Point"), SLS_STR("::Point")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("Point")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_Trait_Addable() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal Trait Addable"), SLS_STR("::Addable")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("Addable")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_Trait_Drawable() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal Trait Drawable"), SLS_STR("::Drawable")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("Drawable")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_Field_x() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal Field x"), SLS_STR("::x")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("x")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_Field_width() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal Field width"), SLS_STR("::width")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("width")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_With_Underscore() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal With Underscore"), SLS_STR("::_private")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("_private")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_Multiple_Underscores() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal Multiple Underscores"), SLS_STR("::my_long_name")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("my_long_name")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_With_Numbers() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal With Numbers"), SLS_STR("::var123")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("var123")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Leading_Whitespace() { - LexerTest test = start_up_test(SLS_STR("Identifier Leading Whitespace"), SLS_STR(" hello")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("hello")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Trailing_Whitespace() { - LexerTest test = start_up_test(SLS_STR("Identifier Trailing Whitespace"), SLS_STR("hello ")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("hello")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Both_Whitespace() { - LexerTest test = start_up_test(SLS_STR("Identifier Both Whitespace"), SLS_STR(" hello ")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("hello")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Tab_Before() { - LexerTest test = start_up_test(SLS_STR("Identifier Tab Before"), SLS_STR(" hello")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("hello")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_Leading_Whitespace() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal Leading Whitespace"), SLS_STR(" ::hello")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("hello")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_Trailing_Whitespace() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal Trailing Whitespace"), SLS_STR("::hello ")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("hello")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_Both_Whitespace() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal Both Whitespace"), SLS_STR(" ::hello ")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){TRUE, SLS_STR("hello")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Moderate_Length() { - LexerTest test = start_up_test(SLS_STR("Identifier Moderate Length"), SLS_STR("thisIsAReasonablyLongVariableName")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("thisIsAReasonablyLongVariableName")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Very_Long() { - LexerTest test = start_up_test(SLS_STR("Identifier Very Long"), SLS_STR("this_is_a_very_long_identifier_name_that_someone_might_use_for_some_reason")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("this_is_a_very_long_identifier_name_that_someone_might_use_for_some_reason")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Long_With_Numbers() { - LexerTest test = start_up_test(SLS_STR("Identifier Long With Numbers"), SLS_STR("variable_with_many_numbers_123_456_789_000")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("variable_with_many_numbers_123_456_789_000")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Starting_With_Number() { - LexerTest test = start_up_test(SLS_STR("Identifier Starting With Number"), SLS_STR("123abc")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier: cannot start with digit."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_With_Hash() { - LexerTest test = start_up_test(SLS_STR("Identifier With Hash"), SLS_STR("my#var")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier: '#' is not allowed in identifiers."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_With_Dash() { - LexerTest test = start_up_test(SLS_STR("Identifier With Dash"), SLS_STR("my-var")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier: '-' is not allowed in identifiers."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_With_Dot() { - LexerTest test = start_up_test(SLS_STR("Identifier With Dot"), SLS_STR("my.var")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier: '.' is not allowed in identifiers."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_With_Space() { - LexerTest test = start_up_test(SLS_STR("Identifier With Space"), SLS_STR("my var")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier: whitespace not allowed in identifiers."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_With_Colon() { - LexerTest test = start_up_test(SLS_STR("Identifier With Colon"), SLS_STR("my:var")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier: ':' is not allowed in identifiers."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Double_Colon_Inside() { - LexerTest test = start_up_test(SLS_STR("Identifier Double Colon Inside"), SLS_STR("my::var")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier: '::' only allowed as prefix for identifier literals."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_With_At() { - LexerTest test = start_up_test(SLS_STR("Identifier With At"), SLS_STR("@variable")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier: '@' is not allowed in identifiers."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_With_Dollar() { - LexerTest test = start_up_test(SLS_STR("Identifier With Dollar"), SLS_STR("$variable")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier: '$' is not allowed in identifiers."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_With_Percent() { - LexerTest test = start_up_test(SLS_STR("Identifier With Percent"), SLS_STR("%variable")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier: '%' is not allowed in identifiers."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_With_Brackets() { - LexerTest test = start_up_test(SLS_STR("Identifier With Brackets"), SLS_STR("my[var]")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier: brackets not allowed in identifiers."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_With_Braces() { - LexerTest test = start_up_test(SLS_STR("Identifier With Braces"), SLS_STR("my{var}")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier: braces not allowed in identifiers."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_With_Parens() { - LexerTest test = start_up_test(SLS_STR("Identifier With Parens"), SLS_STR("my(var)")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier: parentheses not allowed in identifiers."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_With_Single_Quote() { - LexerTest test = start_up_test(SLS_STR("Identifier With Single Quote"), SLS_STR("my'var")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier: quotes not allowed in identifiers."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_With_Double_Quote() { - LexerTest test = start_up_test(SLS_STR("Identifier With Double Quote"), SLS_STR("my\"var")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier: quotes not allowed in identifiers."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Only_Numbers() { - LexerTest test = start_up_test(SLS_STR("Identifier Only Numbers"), SLS_STR("123")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Not an identifier: numeric literal."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Literal_Empty() { - LexerTest test = start_up_test(SLS_STR("Identifier Literal Empty"), SLS_STR("::")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid identifier literal: empty identifier after '::'."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Case_Lower() { - LexerTest test = start_up_test(SLS_STR("Identifier Case Lower"), SLS_STR("variable")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("variable")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Case_Upper() { - LexerTest test = start_up_test(SLS_STR("Identifier Case Upper"), SLS_STR("VARIABLE")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("VARIABLE")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Case_Mixed() { - LexerTest test = start_up_test(SLS_STR("Identifier Case Mixed"), SLS_STR("Variable")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("Variable")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Case_Camel() { - LexerTest test = start_up_test(SLS_STR("Identifier Case Camel"), SLS_STR("variableName")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("variableName")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Case_Pascal() { - LexerTest test = start_up_test(SLS_STR("Identifier Case Pascal"), SLS_STR("VariableName")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("VariableName")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_true() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word true"), SLS_STR("true")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("true")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_false() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word false"), SLS_STR("false")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("false")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_if() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word if"), SLS_STR("if")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("if")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_while() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word while"), SLS_STR("while")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("while")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_for() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word for"), SLS_STR("for")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("for")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_match() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word match"), SLS_STR("match")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("match")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_break() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word break"), SLS_STR("break")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("break")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_continue() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word continue"), SLS_STR("continue")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("continue")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_fn() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word fn"), SLS_STR("fn")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("fn")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_struct() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word struct"), SLS_STR("struct")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("struct")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_union() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word union"), SLS_STR("union")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("union")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_enum() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word enum"), SLS_STR("enum")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("enum")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_trait() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word trait"), SLS_STR("trait")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("trait")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_impl() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word impl"), SLS_STR("impl")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("impl")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_inher() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word inher"), SLS_STR("inher")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("inher")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_dup() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word dup"), SLS_STR("dup")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("dup")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_drop() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word drop"), SLS_STR("drop")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("drop")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_swap() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word swap"), SLS_STR("swap")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("swap")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_over() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word over"), SLS_STR("over")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("over")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_rot() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word rot"), SLS_STR("rot")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("rot")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_pick() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word pick"), SLS_STR("pick")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("pick")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_roll() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word roll"), SLS_STR("roll")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("roll")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Identifier_Reserved_Word_depth() { - LexerTest test = start_up_test(SLS_STR("Identifier Reserved Word depth"), SLS_STR("depth")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_identifier_value(&test, result, i++, &(TestIdentifierValue){FALSE, SLS_STR("depth")})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_True() { - LexerTest test = start_up_test(SLS_STR("Bool True"), SLS_STR("true")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_boolean_value(&test, result, i++, &(Boolean){TRUE})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_False() { - LexerTest test = start_up_test(SLS_STR("Bool False"), SLS_STR("false")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_boolean_value(&test, result, i++, &(Boolean){FALSE})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_True_Leading_Whitespace() { - LexerTest test = start_up_test(SLS_STR("Bool True Leading Whitespace"), SLS_STR(" true")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_boolean_value(&test, result, i++, &(Boolean){TRUE})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_True_Trailing_Whitespace() { - LexerTest test = start_up_test(SLS_STR("Bool True Trailing Whitespace"), SLS_STR("true ")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_boolean_value(&test, result, i++, &(Boolean){TRUE})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_True_Both_Whitespace() { - LexerTest test = start_up_test(SLS_STR("Bool True Both Whitespace"), SLS_STR(" true ")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_boolean_value(&test, result, i++, &(Boolean){TRUE})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_True_Tab_Before() { - LexerTest test = start_up_test(SLS_STR("Bool True Tab Before"), SLS_STR(" true")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_boolean_value(&test, result, i++, &(Boolean){TRUE})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_False_Leading_Whitespace() { - LexerTest test = start_up_test(SLS_STR("Bool False Leading Whitespace"), SLS_STR(" false")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_boolean_value(&test, result, i++, &(Boolean){FALSE})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_False_Trailing_Whitespace() { - LexerTest test = start_up_test(SLS_STR("Bool False Trailing Whitespace"), SLS_STR("false ")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_boolean_value(&test, result, i++, &(Boolean){FALSE})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_False_Both_Whitespace() { - LexerTest test = start_up_test(SLS_STR("Bool False Both Whitespace"), SLS_STR(" false ")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_boolean_value(&test, result, i++, &(Boolean){FALSE})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_False_Tab_Before() { - LexerTest test = start_up_test(SLS_STR("Bool False Tab Before"), SLS_STR(" false")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_boolean_value(&test, result, i++, &(Boolean){FALSE})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_True_Capitalized() { - LexerTest test = start_up_test(SLS_STR("Bool True Capitalized"), SLS_STR("True")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid boolean: 'True' is not a boolean literal (use lowercase 'true')."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_False_Capitalized() { - LexerTest test = start_up_test(SLS_STR("Bool False Capitalized"), SLS_STR("False")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid boolean: 'False' is not a boolean literal (use lowercase 'false')."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_True_All_Caps() { - LexerTest test = start_up_test(SLS_STR("Bool True All Caps"), SLS_STR("TRUE")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid boolean: 'TRUE' is not a boolean literal (use lowercase 'true')."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_False_All_Caps() { - LexerTest test = start_up_test(SLS_STR("Bool False All Caps"), SLS_STR("FALSE")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid boolean: 'FALSE' is not a boolean literal (use lowercase 'false')."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_True_Mixed_Case() { - LexerTest test = start_up_test(SLS_STR("Bool True Mixed Case"), SLS_STR("tRuE")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid boolean: 'tRuE' is not a boolean literal (use lowercase 'true')."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_False_Mixed_Case() { - LexerTest test = start_up_test(SLS_STR("Bool False Mixed Case"), SLS_STR("fAlSe")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid boolean: 'fAlSe' is not a boolean literal (use lowercase 'false')."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_Numeric_1() { - LexerTest test = start_up_test(SLS_STR("Bool Numeric 1"), SLS_STR("1")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Not a boolean: numeric literal."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_Numeric_0() { - LexerTest test = start_up_test(SLS_STR("Bool Numeric 0"), SLS_STR("0")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Not a boolean: numeric literal."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_String_True() { - LexerTest test = start_up_test(SLS_STR("Bool String True"), SLS_STR("\"true\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Not a boolean: string literal."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_String_False() { - LexerTest test = start_up_test(SLS_STR("Bool String False"), SLS_STR("\"false\"")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Not a boolean: string literal."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_Yes() { - LexerTest test = start_up_test(SLS_STR("Bool Yes"), SLS_STR("yes")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid boolean: 'yes' is not a boolean literal."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_No() { - LexerTest test = start_up_test(SLS_STR("Bool No"), SLS_STR("no")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid boolean: 'no' is not a boolean literal."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_Typo_Ture() { - LexerTest test = start_up_test(SLS_STR("Bool Typo Ture"), SLS_STR("ture")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid boolean: 'ture' is not a boolean literal."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_Typo_Flase() { - LexerTest test = start_up_test(SLS_STR("Bool Typo Flase"), SLS_STR("flase")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_for_error(&test, result, i++, SLS_STR("Invalid boolean: 'flase' is not a boolean literal."))) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_Multiple_True_False() { - LexerTest test = start_up_test(SLS_STR("Bool Multiple True False"), SLS_STR("true false")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_boolean_value(&test, result, i++, &(Boolean){TRUE})) return test.result; - if (test_boolean_value(&test, result, i++, &(Boolean){FALSE})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_Multiple_Same() { - LexerTest test = start_up_test(SLS_STR("Bool Multiple Same"), SLS_STR("true true")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_boolean_value(&test, result, i++, &(Boolean){TRUE})) return test.result; - if (test_boolean_value(&test, result, i++, &(Boolean){TRUE})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - -static TestResult test_Bool_Three_Values() { - LexerTest test = start_up_test(SLS_STR("Bool Three Values"), SLS_STR("true false true")); - LexerResult result = lexical_analysis(&test.lexer_info); - if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error); - size_t i = 0; - if (test_boolean_value(&test, result, i++, &(Boolean){TRUE})) return test.result; - if (test_boolean_value(&test, result, i++, &(Boolean){FALSE})) return test.result; - if (test_boolean_value(&test, result, i++, &(Boolean){TRUE})) return test.result; - if (test_eof_value(&test, result, i++, 0)) return test.result; - return pass_test(&test, result); -} - TestsReport run_lexer_tests() { TestsReport test_report = (TestsReport) { .section = SLS_STR("lexer_tests"), @@ -4645,25 +2632,12 @@ TestsReport run_lexer_tests() { test_report.tests[i++] = test_Char_Right_Bracket(); test_report.tests[i++] = test_Char_Left_Brace(); test_report.tests[i++] = test_Char_Right_Brace(); - test_report.tests[i++] = test_Char_Escape_Null_character(); + test_report.tests[i++] = test_Char_Escape_Single_quote(); test_report.tests[i++] = test_Char_Escape_Tab(); - test_report.tests[i++] = test_Char_Escape_Double_quote(); test_report.tests[i++] = test_Char_Escape_Carriage_return(); test_report.tests[i++] = test_Char_Escape_Backslash(); - test_report.tests[i++] = test_Char_Escape_Single_quote(); test_report.tests[i++] = test_Char_Escape_Newline(); - test_report.tests[i++] = test_Char_Newline(); - test_report.tests[i++] = test_Char_Carriage_Return(); - test_report.tests[i++] = test_Char_Tab(); - test_report.tests[i++] = test_Char_Backslash(); - test_report.tests[i++] = test_Char_Double_Quote(); - test_report.tests[i++] = test_Char_Single_Quote(); - test_report.tests[i++] = test_Char_Null(); - test_report.tests[i++] = test_Char_Hex_Escape_x41(); - test_report.tests[i++] = test_Char_Hex_Escape_x61(); - test_report.tests[i++] = test_Char_Hex_Escape_x20(); - test_report.tests[i++] = test_Char_Hex_Escape_x00(); - test_report.tests[i++] = test_Char_Hex_Escape_xFF(); + test_report.tests[i++] = test_Char_Escape_Null_character(); test_report.tests[i++] = test_Char_Hex_Lowercase_A(); test_report.tests[i++] = test_Char_Hex_Uppercase_A(); test_report.tests[i++] = test_Char_Hex_Space(); @@ -4683,208 +2657,16 @@ TestsReport run_lexer_tests() { test_report.tests[i++] = test_Char_Hex_Escape_Too_Short(); test_report.tests[i++] = test_Char_Hex_Escape_Too_Long(); test_report.tests[i++] = test_Char_Hex_Invalid_Digit(); - test_report.tests[i++] = test_Char_Double_Quotes(); - test_report.tests[i++] = test_Char_No_Quotes(); test_report.tests[i++] = test_Char_ASCII_Control_SOH(); test_report.tests[i++] = test_Char_ASCII_Control_BEL(); test_report.tests[i++] = test_Char_ASCII_Control_ESC(); test_report.tests[i++] = test_Char_ASCII_Control_DEL(); test_report.tests[i++] = test_Char_Extended_ASCII_Lower(); test_report.tests[i++] = test_Char_Extended_ASCII_Upper(); - test_report.tests[i++] = test_Char_Backslash_Literal(); - test_report.tests[i++] = test_Char_Single_Quote_Escaped(); test_report.tests[i++] = test_Char_Hex_Lowercase_x(); test_report.tests[i++] = test_Char_Hex_Digits_Uppercase(); test_report.tests[i++] = test_Char_Hex_Digits_Lowercase(); test_report.tests[i++] = test_Char_Hex_Digits_Mixed(); - test_report.tests[i++] = test_String_Empty(); - test_report.tests[i++] = test_String_Simple(); - test_report.tests[i++] = test_String_With_Space(); - test_report.tests[i++] = test_String_Single_Char(); - test_report.tests[i++] = test_String_Multiple_Words(); - test_report.tests[i++] = test_String_With_Numbers(); - test_report.tests[i++] = test_String_Only_Numbers(); - test_report.tests[i++] = test_String_Mixed_Case(); - test_report.tests[i++] = test_String_With_Punctuation(); - test_report.tests[i++] = test_String_With_Symbols(); - test_report.tests[i++] = test_String_Multiple_Spaces(); - test_report.tests[i++] = test_String_Leading_Space(); - test_report.tests[i++] = test_String_Trailing_Space(); - test_report.tests[i++] = test_String_Only_Spaces(); - test_report.tests[i++] = test_String_Newline(); - test_report.tests[i++] = test_String_Tab(); - test_report.tests[i++] = test_String_Carriage_Return(); - test_report.tests[i++] = test_String_Backslash(); - test_report.tests[i++] = test_String_Double_Quote(); - test_report.tests[i++] = test_String_Single_Quote(); - test_report.tests[i++] = test_String_Null_Char(); - test_report.tests[i++] = test_String_Multiple_Escapes(); - test_report.tests[i++] = test_String_Mixed_Escapes(); - test_report.tests[i++] = test_String_Escape_At_Start(); - test_report.tests[i++] = test_String_Escape_At_End(); - test_report.tests[i++] = test_String_Consecutive_Escapes(); - test_report.tests[i++] = test_String_All_Escapes(); - test_report.tests[i++] = test_String_Hex_Letter_A(); - test_report.tests[i++] = test_String_Hex_Letter_a(); - test_report.tests[i++] = test_String_Hex_Space(); - test_report.tests[i++] = test_String_Hex_Tab(); - test_report.tests[i++] = test_String_Hex_Newline(); - test_report.tests[i++] = test_String_Multiple_Hex(); - test_report.tests[i++] = test_String_Hex_Mixed(); - test_report.tests[i++] = test_String_Hex_Extended_ASCII(); - test_report.tests[i++] = test_String_Hex_Uppercase(); - test_report.tests[i++] = test_String_Hex_Lowercase(); - test_report.tests[i++] = test_String_Hex_Mixed_Case(); - test_report.tests[i++] = test_String_Hex_Zero(); - test_report.tests[i++] = test_String_Hex_Max(); - test_report.tests[i++] = test_String_With_Escaped_Newlines(); - test_report.tests[i++] = test_String_Paragraph(); - test_report.tests[i++] = test_String_Mixed_Line_Endings(); - test_report.tests[i++] = test_String_Leading_Whitespace_Outside(); - test_report.tests[i++] = test_String_Trailing_Whitespace_Outside(); - test_report.tests[i++] = test_String_Both_Whitespace_Outside(); - test_report.tests[i++] = test_String_Tab_Before(); - test_report.tests[i++] = test_String_Tabs_And_Newlines_Inside(); - test_report.tests[i++] = test_String_Only_Tabs(); - test_report.tests[i++] = test_String_Only_Newlines(); - test_report.tests[i++] = test_String_Mixed_Whitespace(); - test_report.tests[i++] = test_String_Sentence(); - test_report.tests[i++] = test_String_Multiple_Sentences(); - test_report.tests[i++] = test_String_Long_With_Escapes(); - test_report.tests[i++] = test_String_Repetitive(); - test_report.tests[i++] = test_String_ASCII_Printable(); - test_report.tests[i++] = test_String_Code_Like(); - test_report.tests[i++] = test_String_JSON_Like(); - test_report.tests[i++] = test_String_URL(); - test_report.tests[i++] = test_String_Email(); - test_report.tests[i++] = test_String_Unix_Path(); - test_report.tests[i++] = test_String_Windows_Path(); - test_report.tests[i++] = test_String_SQL_Like(); - test_report.tests[i++] = test_String_Regex_Like(); - test_report.tests[i++] = test_String_Unclosed(); - test_report.tests[i++] = test_String_Unescaped_Newline(); - test_report.tests[i++] = test_String_Invalid_Escape(); - test_report.tests[i++] = test_String_Hex_Too_Short(); - test_report.tests[i++] = test_String_Hex_Too_Long(); - test_report.tests[i++] = test_String_Hex_Invalid_Digit(); - test_report.tests[i++] = test_String_Single_Quotes(); - test_report.tests[i++] = test_String_Backslash_At_End(); - test_report.tests[i++] = test_String_Only_Escapes(); - test_report.tests[i++] = test_String_With_Nulls(); - test_report.tests[i++] = test_String_Many_Escapes(); - test_report.tests[i++] = test_Identifier_Simple_Lowercase(); - test_report.tests[i++] = test_Identifier_Simple_Uppercase(); - test_report.tests[i++] = test_Identifier_Mixed_Case(); - test_report.tests[i++] = test_Identifier_Single_Letter(); - test_report.tests[i++] = test_Identifier_Single_Letter_Upper(); - test_report.tests[i++] = test_Identifier_With_Numbers(); - test_report.tests[i++] = test_Identifier_Numbers_End(); - test_report.tests[i++] = test_Identifier_Mixed_Numbers(); - test_report.tests[i++] = test_Identifier_With_Underscore(); - test_report.tests[i++] = test_Identifier_Leading_Underscore(); - test_report.tests[i++] = test_Identifier_Multiple_Underscores(); - test_report.tests[i++] = test_Identifier_Double_Underscore(); - test_report.tests[i++] = test_Identifier_Trailing_Underscore(); - test_report.tests[i++] = test_Identifier_Only_Underscores(); - test_report.tests[i++] = test_Identifier_Snake_Case(); - test_report.tests[i++] = test_Identifier_Camel_Case(); - test_report.tests[i++] = test_Identifier_Pascal_Case(); - test_report.tests[i++] = test_Identifier_All_Caps(); - test_report.tests[i++] = test_Identifier_Literal_Simple(); - test_report.tests[i++] = test_Identifier_Literal_Uppercase(); - test_report.tests[i++] = test_Identifier_Literal_Snake_Case(); - test_report.tests[i++] = test_Identifier_Literal_Type_i64(); - test_report.tests[i++] = test_Identifier_Literal_Type_String(); - test_report.tests[i++] = test_Identifier_Literal_Type_Point(); - test_report.tests[i++] = test_Identifier_Literal_Trait_Addable(); - test_report.tests[i++] = test_Identifier_Literal_Trait_Drawable(); - test_report.tests[i++] = test_Identifier_Literal_Field_x(); - test_report.tests[i++] = test_Identifier_Literal_Field_width(); - test_report.tests[i++] = test_Identifier_Literal_With_Underscore(); - test_report.tests[i++] = test_Identifier_Literal_Multiple_Underscores(); - test_report.tests[i++] = test_Identifier_Literal_With_Numbers(); - test_report.tests[i++] = test_Identifier_Leading_Whitespace(); - test_report.tests[i++] = test_Identifier_Trailing_Whitespace(); - test_report.tests[i++] = test_Identifier_Both_Whitespace(); - test_report.tests[i++] = test_Identifier_Tab_Before(); - test_report.tests[i++] = test_Identifier_Literal_Leading_Whitespace(); - test_report.tests[i++] = test_Identifier_Literal_Trailing_Whitespace(); - test_report.tests[i++] = test_Identifier_Literal_Both_Whitespace(); - test_report.tests[i++] = test_Identifier_Moderate_Length(); - test_report.tests[i++] = test_Identifier_Very_Long(); - test_report.tests[i++] = test_Identifier_Long_With_Numbers(); - test_report.tests[i++] = test_Identifier_Starting_With_Number(); - test_report.tests[i++] = test_Identifier_With_Hash(); - test_report.tests[i++] = test_Identifier_With_Dash(); - test_report.tests[i++] = test_Identifier_With_Dot(); - test_report.tests[i++] = test_Identifier_With_Space(); - test_report.tests[i++] = test_Identifier_With_Colon(); - test_report.tests[i++] = test_Identifier_Double_Colon_Inside(); - test_report.tests[i++] = test_Identifier_With_At(); - test_report.tests[i++] = test_Identifier_With_Dollar(); - test_report.tests[i++] = test_Identifier_With_Percent(); - test_report.tests[i++] = test_Identifier_With_Brackets(); - test_report.tests[i++] = test_Identifier_With_Braces(); - test_report.tests[i++] = test_Identifier_With_Parens(); - test_report.tests[i++] = test_Identifier_With_Single_Quote(); - test_report.tests[i++] = test_Identifier_With_Double_Quote(); - test_report.tests[i++] = test_Identifier_Only_Numbers(); - test_report.tests[i++] = test_Identifier_Literal_Empty(); - test_report.tests[i++] = test_Identifier_Case_Lower(); - test_report.tests[i++] = test_Identifier_Case_Upper(); - test_report.tests[i++] = test_Identifier_Case_Mixed(); - test_report.tests[i++] = test_Identifier_Case_Camel(); - test_report.tests[i++] = test_Identifier_Case_Pascal(); - test_report.tests[i++] = test_Identifier_Reserved_Word_true(); - test_report.tests[i++] = test_Identifier_Reserved_Word_false(); - test_report.tests[i++] = test_Identifier_Reserved_Word_if(); - test_report.tests[i++] = test_Identifier_Reserved_Word_while(); - test_report.tests[i++] = test_Identifier_Reserved_Word_for(); - test_report.tests[i++] = test_Identifier_Reserved_Word_match(); - test_report.tests[i++] = test_Identifier_Reserved_Word_break(); - test_report.tests[i++] = test_Identifier_Reserved_Word_continue(); - test_report.tests[i++] = test_Identifier_Reserved_Word_fn(); - test_report.tests[i++] = test_Identifier_Reserved_Word_struct(); - test_report.tests[i++] = test_Identifier_Reserved_Word_union(); - test_report.tests[i++] = test_Identifier_Reserved_Word_enum(); - test_report.tests[i++] = test_Identifier_Reserved_Word_trait(); - test_report.tests[i++] = test_Identifier_Reserved_Word_impl(); - test_report.tests[i++] = test_Identifier_Reserved_Word_inher(); - test_report.tests[i++] = test_Identifier_Reserved_Word_dup(); - test_report.tests[i++] = test_Identifier_Reserved_Word_drop(); - test_report.tests[i++] = test_Identifier_Reserved_Word_swap(); - test_report.tests[i++] = test_Identifier_Reserved_Word_over(); - test_report.tests[i++] = test_Identifier_Reserved_Word_rot(); - test_report.tests[i++] = test_Identifier_Reserved_Word_pick(); - test_report.tests[i++] = test_Identifier_Reserved_Word_roll(); - test_report.tests[i++] = test_Identifier_Reserved_Word_depth(); - test_report.tests[i++] = test_Bool_True(); - test_report.tests[i++] = test_Bool_False(); - test_report.tests[i++] = test_Bool_True_Leading_Whitespace(); - test_report.tests[i++] = test_Bool_True_Trailing_Whitespace(); - test_report.tests[i++] = test_Bool_True_Both_Whitespace(); - test_report.tests[i++] = test_Bool_True_Tab_Before(); - test_report.tests[i++] = test_Bool_False_Leading_Whitespace(); - test_report.tests[i++] = test_Bool_False_Trailing_Whitespace(); - test_report.tests[i++] = test_Bool_False_Both_Whitespace(); - test_report.tests[i++] = test_Bool_False_Tab_Before(); - test_report.tests[i++] = test_Bool_True_Capitalized(); - test_report.tests[i++] = test_Bool_False_Capitalized(); - test_report.tests[i++] = test_Bool_True_All_Caps(); - test_report.tests[i++] = test_Bool_False_All_Caps(); - test_report.tests[i++] = test_Bool_True_Mixed_Case(); - test_report.tests[i++] = test_Bool_False_Mixed_Case(); - test_report.tests[i++] = test_Bool_Numeric_1(); - test_report.tests[i++] = test_Bool_Numeric_0(); - test_report.tests[i++] = test_Bool_String_True(); - test_report.tests[i++] = test_Bool_String_False(); - test_report.tests[i++] = test_Bool_Yes(); - test_report.tests[i++] = test_Bool_No(); - test_report.tests[i++] = test_Bool_Typo_Ture(); - test_report.tests[i++] = test_Bool_Typo_Flase(); - test_report.tests[i++] = test_Bool_Multiple_True_False(); - test_report.tests[i++] = test_Bool_Multiple_Same(); - test_report.tests[i++] = test_Bool_Three_Values(); return test_report; } diff --git a/SLS_Tests/cases.yaml b/SLS_Tests/cases.yaml index baaed97..d6b6c97 100644 --- a/SLS_Tests/cases.yaml +++ b/SLS_Tests/cases.yaml @@ -2317,20 +2317,20 @@ stack_final: - type: char value: '}' -- name: Char Escape Null character - code: '''\0''' +- name: Char Escape Single quote + code: '''\\''''' tokens: - type: char - value: "\0" + value: '''' operations: - function: push type: char - value: "\0" + value: '''' stack_final: - type: char - value: "\0" + value: '''' - name: Char Escape Tab - code: '''\t''' + code: '''\\t''' tokens: - type: char value: "\t" @@ -2341,20 +2341,8 @@ stack_final: - type: char value: "\t" -- name: Char Escape Double quote - code: '''\\"''' - tokens: - - type: char - value: '"' - operations: - - function: push - type: char - value: '"' - stack_final: - - type: char - value: '"' - name: Char Escape Carriage return - code: '''\r''' + code: '''\\r''' tokens: - type: char value: "\r" @@ -2366,7 +2354,7 @@ - type: char value: "\r" - name: Char Escape Backslash - code: '''\\''' + code: '''\\\\''' tokens: - type: char value: \ @@ -2377,20 +2365,8 @@ stack_final: - type: char value: \ -- name: Char Escape Single quote - code: '''\''''' - tokens: - - type: char - value: '''' - operations: - - function: push - type: char - value: '''' - stack_final: - - type: char - value: '''' - name: Char Escape Newline - code: '''\n''' + code: '''\\n''' tokens: - type: char value: ' @@ -2407,86 +2383,8 @@ value: ' ' -- name: Char Newline - code: '''\n''' - tokens: - - type: char - value: ' - - ' - operations: - - function: push - type: char - value: ' - - ' - stack_final: - - type: char - value: ' - - ' -- name: Char Carriage Return - code: '''\r''' - tokens: - - type: char - value: "\r" - operations: - - function: push - type: char - value: "\r" - stack_final: - - type: char - value: "\r" -- name: Char Tab - code: '''\t''' - tokens: - - type: char - value: "\t" - operations: - - function: push - type: char - value: "\t" - stack_final: - - type: char - value: "\t" -- name: Char Backslash - code: '''\\''' - tokens: - - type: char - value: \ - operations: - - function: push - type: char - value: \ - stack_final: - - type: char - value: \ -- name: Char Double Quote - code: '''\\"''' - tokens: - - type: char - value: '"' - operations: - - function: push - type: char - value: '"' - stack_final: - - type: char - value: '"' -- name: Char Single Quote - code: '''\''''' - tokens: - - type: char - value: '''' - operations: - - function: push - type: char - value: '''' - stack_final: - - type: char - value: '''' -- name: Char Null - code: '''\0''' +- name: Char Escape Null character + code: '''\\0''' tokens: - type: char value: "\0" @@ -2497,68 +2395,8 @@ stack_final: - type: char value: "\0" -- name: Char Hex Escape \x41 - code: '''\x41''' - tokens: - - type: char - value: A - operations: - - function: push - type: char - value: A - stack_final: - - type: char - value: A -- name: Char Hex Escape \x61 - code: '''\x61''' - tokens: - - type: char - value: a - operations: - - function: push - type: char - value: a - stack_final: - - type: char - value: a -- name: Char Hex Escape \x20 - code: '''\x20''' - tokens: - - type: char - value: ' ' - operations: - - function: push - type: char - value: ' ' - stack_final: - - type: char - value: ' ' -- name: Char Hex Escape \x00 - code: '''\x00''' - tokens: - - type: char - value: "\0" - operations: - - function: push - type: char - value: "\0" - stack_final: - - type: char - value: "\0" -- name: Char Hex Escape \xFF - code: '''\xFF''' - tokens: - - type: char - value: "\xFF" - operations: - - function: push - type: char - value: "\xFF" - stack_final: - - type: char - value: "\xFF" - name: Char Hex Lowercase A - code: '''\x61''' + code: '''\\x61''' tokens: - type: char value: a @@ -2570,7 +2408,7 @@ - type: char value: a - name: Char Hex Uppercase A - code: '''\x41''' + code: '''\\x41''' tokens: - type: char value: A @@ -2582,7 +2420,7 @@ - type: char value: A - name: Char Hex Space - code: '''\x20''' + code: '''\\x20''' tokens: - type: char value: ' ' @@ -2594,7 +2432,7 @@ - type: char value: ' ' - name: Char Hex Tab - code: '''\x09''' + code: '''\\x09''' tokens: - type: char value: "\t" @@ -2606,7 +2444,7 @@ - type: char value: "\t" - name: Char Hex Newline - code: '''\x0A''' + code: '''\\x0A''' tokens: - type: char value: ' @@ -2624,7 +2462,7 @@ ' - name: Char Hex Max ASCII - code: '''\x7F''' + code: '''\\x7F''' tokens: - type: char value: "\x7F" @@ -2704,7 +2542,7 @@ code: '''AB''' tokens: - type: error - value: 'Invalid character literal: multiple characters without escape sequence.' + value: 'Invalid character literal: unexpected ''B'' in character.' - name: Char Unclosed Quote code: '''A' tokens: @@ -2714,7 +2552,7 @@ code: '''\n''' tokens: - type: error - value: 'Invalid character literal: unescaped newline in character literal.' + value: 'Invalid character literal: unclosed character literal.' - name: Char Invalid Escape code: '''\\q''' tokens: @@ -2735,18 +2573,8 @@ tokens: - type: error value: 'Invalid character literal: invalid hexadecimal digit ''G''.' -- name: Char Double Quotes - code: '"A"' - tokens: - - type: error - value: 'Invalid character literal: character literals must use single quotes.' -- name: Char No Quotes - code: A - tokens: - - type: error - value: 'Not a character literal: missing quotes.' - name: Char ASCII Control SOH - code: '''\x01''' + code: '''\\x01''' tokens: - type: char value: "\x01" @@ -2758,7 +2586,7 @@ - type: char value: "\x01" - name: Char ASCII Control BEL - code: '''\x07''' + code: '''\\x07''' tokens: - type: char value: "\a" @@ -2770,7 +2598,7 @@ - type: char value: "\a" - name: Char ASCII Control ESC - code: '''\x1B''' + code: '''\\x1B''' tokens: - type: char value: "\e" @@ -2782,7 +2610,7 @@ - type: char value: "\e" - name: Char ASCII Control DEL - code: '''\x7F''' + code: '''\\x7F''' tokens: - type: char value: "\x7F" @@ -2794,7 +2622,7 @@ - type: char value: "\x7F" - name: Char Extended ASCII Lower - code: '''\x80''' + code: '''\\x80''' tokens: - type: char value: "\x80" @@ -2806,7 +2634,7 @@ - type: char value: "\x80" - name: Char Extended ASCII Upper - code: '''\xFF''' + code: '''\\xFF''' tokens: - type: char value: "\xFF" @@ -2817,32 +2645,8 @@ stack_final: - type: char value: "\xFF" -- name: Char Backslash Literal - code: '''\\''' - tokens: - - type: char - value: \ - operations: - - function: push - type: char - value: \ - stack_final: - - type: char - value: \ -- name: Char Single Quote Escaped - code: '''\''''' - tokens: - - type: char - value: '''' - operations: - - function: push - type: char - value: '''' - stack_final: - - type: char - value: '''' - name: Char Hex Lowercase x - code: '''\x41''' + code: '''\\x41''' tokens: - type: char value: A @@ -2854,7 +2658,7 @@ - type: char value: A - name: Char Hex Digits Uppercase - code: '''\xFF''' + code: '''\\xFF''' tokens: - type: char value: "\xFF" @@ -2866,7 +2670,7 @@ - type: char value: "\xFF" - name: Char Hex Digits Lowercase - code: '''\xff''' + code: '''\\xff''' tokens: - type: char value: "\xFF" @@ -2878,7 +2682,7 @@ - type: char value: "\xFF" - name: Char Hex Digits Mixed - code: '''\xAb''' + code: '''\\xAb''' tokens: - type: char value: "\xAB" @@ -2889,2018 +2693,3 @@ stack_final: - type: char value: "\xAB" -- name: String Empty - code: '""' - tokens: - - type: string - value: '' - operations: - - function: push - type: string - value: '' - stack_final: - - type: string - value: '' -- name: String Simple - code: '"hello"' - tokens: - - type: string - value: hello - operations: - - function: push - type: string - value: hello - stack_final: - - type: string - value: hello -- name: String With Space - code: '"hello world"' - tokens: - - type: string - value: hello world - operations: - - function: push - type: string - value: hello world - stack_final: - - type: string - value: hello world -- name: String Single Char - code: '"A"' - tokens: - - type: string - value: A - operations: - - function: push - type: string - value: A - stack_final: - - type: string - value: A -- name: String Multiple Words - code: '"The quick brown fox"' - tokens: - - type: string - value: The quick brown fox - operations: - - function: push - type: string - value: The quick brown fox - stack_final: - - type: string - value: The quick brown fox -- name: String With Numbers - code: '"abc123"' - tokens: - - type: string - value: abc123 - operations: - - function: push - type: string - value: abc123 - stack_final: - - type: string - value: abc123 -- name: String Only Numbers - code: '"12345"' - tokens: - - type: string - value: '12345' - operations: - - function: push - type: string - value: '12345' - stack_final: - - type: string - value: '12345' -- name: String Mixed Case - code: '"HeLLo WoRLd"' - tokens: - - type: string - value: HeLLo WoRLd - operations: - - function: push - type: string - value: HeLLo WoRLd - stack_final: - - type: string - value: HeLLo WoRLd -- name: String With Punctuation - code: '"Hello, World!"' - tokens: - - type: string - value: Hello, World! - operations: - - function: push - type: string - value: Hello, World! - stack_final: - - type: string - value: Hello, World! -- name: String With Symbols - code: '"@#$%^&*()"' - tokens: - - type: string - value: '@#$%^&*()' - operations: - - function: push - type: string - value: '@#$%^&*()' - stack_final: - - type: string - value: '@#$%^&*()' -- name: String Multiple Spaces - code: '"hello world"' - tokens: - - type: string - value: hello world - operations: - - function: push - type: string - value: hello world - stack_final: - - type: string - value: hello world -- name: String Leading Space - code: '" hello"' - tokens: - - type: string - value: ' hello' - operations: - - function: push - type: string - value: ' hello' - stack_final: - - type: string - value: ' hello' -- name: String Trailing Space - code: '"hello "' - tokens: - - type: string - value: 'hello ' - operations: - - function: push - type: string - value: 'hello ' - stack_final: - - type: string - value: 'hello ' -- name: String Only Spaces - code: '" "' - tokens: - - type: string - value: ' ' - operations: - - function: push - type: string - value: ' ' - stack_final: - - type: string - value: ' ' -- name: String Newline - code: '"hello\nworld"' - tokens: - - type: string - value: hello\nworld - operations: - - function: push - type: string - value: hello\nworld - stack_final: - - type: string - value: hello\nworld -- name: String Tab - code: '"hello\tworld"' - tokens: - - type: string - value: hello\tworld - operations: - - function: push - type: string - value: hello\tworld - stack_final: - - type: string - value: hello\tworld -- name: String Carriage Return - code: '"hello\rworld"' - tokens: - - type: string - value: hello\rworld - operations: - - function: push - type: string - value: hello\rworld - stack_final: - - type: string - value: hello\rworld -- name: String Backslash - code: '"hello\\world"' - tokens: - - type: string - value: hello\\world - operations: - - function: push - type: string - value: hello\\world - stack_final: - - type: string - value: hello\\world -- name: String Double Quote - code: '"say \\"hello\\""' - tokens: - - type: string - value: say \"hello\" - operations: - - function: push - type: string - value: say \"hello\" - stack_final: - - type: string - value: say \"hello\" -- name: String Single Quote - code: '"it\''s"' - tokens: - - type: string - value: it's - operations: - - function: push - type: string - value: it's - stack_final: - - type: string - value: it's -- name: String Null Char - code: '"hello\0world"' - tokens: - - type: string - value: hello\0world - operations: - - function: push - type: string - value: hello\0world - stack_final: - - type: string - value: hello\0world -- name: String Multiple Escapes - code: '"line1\nline2\nline3"' - tokens: - - type: string - value: line1\nline2\nline3 - operations: - - function: push - type: string - value: line1\nline2\nline3 - stack_final: - - type: string - value: line1\nline2\nline3 -- name: String Mixed Escapes - code: '"tab\there\nnewline\\backslash"' - tokens: - - type: string - value: tab\there\nnewline\\backslash - operations: - - function: push - type: string - value: tab\there\nnewline\\backslash - stack_final: - - type: string - value: tab\there\nnewline\\backslash -- name: String Escape At Start - code: '"\nhello"' - tokens: - - type: string - value: \nhello - operations: - - function: push - type: string - value: \nhello - stack_final: - - type: string - value: \nhello -- name: String Escape At End - code: '"hello\n"' - tokens: - - type: string - value: hello\n - operations: - - function: push - type: string - value: hello\n - stack_final: - - type: string - value: hello\n -- name: String Consecutive Escapes - code: '"\n\n\n"' - tokens: - - type: string - value: \n\n\n - operations: - - function: push - type: string - value: \n\n\n - stack_final: - - type: string - value: \n\n\n -- name: String All Escapes - code: '"\n\r\t\\"\''\0"' - tokens: - - type: string - value: \n\r\t\\\"\'\0 - operations: - - function: push - type: string - value: \n\r\t\\\"\'\0 - stack_final: - - type: string - value: \n\r\t\\\"\'\0 -- name: String Hex Letter A - code: '"\x41"' - tokens: - - type: string - value: A - operations: - - function: push - type: string - value: A - stack_final: - - type: string - value: A -- name: String Hex Letter a - code: '"\x61"' - tokens: - - type: string - value: a - operations: - - function: push - type: string - value: a - stack_final: - - type: string - value: a -- name: String Hex Space - code: '"\x20"' - tokens: - - type: string - value: ' ' - operations: - - function: push - type: string - value: ' ' - stack_final: - - type: string - value: ' ' -- name: String Hex Tab - code: '"\x09"' - tokens: - - type: string - value: \t - operations: - - function: push - type: string - value: \t - stack_final: - - type: string - value: \t -- name: String Hex Newline - code: '"\x0A"' - tokens: - - type: string - value: \n - operations: - - function: push - type: string - value: \n - stack_final: - - type: string - value: \n -- name: String Multiple Hex - code: '"\x48\x65\x6C\x6C\x6F"' - tokens: - - type: string - value: Hello - operations: - - function: push - type: string - value: Hello - stack_final: - - type: string - value: Hello -- name: String Hex Mixed - code: '"Hello\x20World"' - tokens: - - type: string - value: Hello World - operations: - - function: push - type: string - value: Hello World - stack_final: - - type: string - value: Hello World -- name: String Hex Extended ASCII - code: '"\xA9\xAE"' - tokens: - - type: string - value: "\xA9\xAE" - operations: - - function: push - type: string - value: "\xA9\xAE" - stack_final: - - type: string - value: "\xA9\xAE" -- name: String Hex Uppercase - code: '"\xFF"' - tokens: - - type: string - value: \xFF - operations: - - function: push - type: string - value: \xFF - stack_final: - - type: string - value: \xFF -- name: String Hex Lowercase - code: '"\xff"' - tokens: - - type: string - value: \xff - operations: - - function: push - type: string - value: \xff - stack_final: - - type: string - value: \xff -- name: String Hex Mixed Case - code: '"\xAb"' - tokens: - - type: string - value: \xAb - operations: - - function: push - type: string - value: \xAb - stack_final: - - type: string - value: \xAb -- name: String Hex Zero - code: '"\x00"' - tokens: - - type: string - value: \0 - operations: - - function: push - type: string - value: \0 - stack_final: - - type: string - value: \0 -- name: String Hex Max - code: '"\xFF"' - tokens: - - type: string - value: \xFF - operations: - - function: push - type: string - value: \xFF - stack_final: - - type: string - value: \xFF -- name: String With Escaped Newlines - code: '"line1\nline2\nline3"' - tokens: - - type: string - value: line1\nline2\nline3 - operations: - - function: push - type: string - value: line1\nline2\nline3 - stack_final: - - type: string - value: line1\nline2\nline3 -- name: String Paragraph - code: '"First line.\nSecond line.\nThird line."' - tokens: - - type: string - value: First line.\nSecond line.\nThird line. - operations: - - function: push - type: string - value: First line.\nSecond line.\nThird line. - stack_final: - - type: string - value: First line.\nSecond line.\nThird line. -- name: String Mixed Line Endings - code: '"Windows\r\nUnix\nMac\r"' - tokens: - - type: string - value: Windows\r\nUnix\nMac\r - operations: - - function: push - type: string - value: Windows\r\nUnix\nMac\r - stack_final: - - type: string - value: Windows\r\nUnix\nMac\r -- name: String Leading Whitespace Outside - code: ' "hello"' - tokens: - - type: string - value: hello - operations: - - function: push - type: string - value: hello - stack_final: - - type: string - value: hello -- name: String Trailing Whitespace Outside - code: '"hello" ' - tokens: - - type: string - value: hello - operations: - - function: push - type: string - value: hello - stack_final: - - type: string - value: hello -- name: String Both Whitespace Outside - code: ' "hello" ' - tokens: - - type: string - value: hello - operations: - - function: push - type: string - value: hello - stack_final: - - type: string - value: hello -- name: String Tab Before - code: "\t\"hello\"" - tokens: - - type: string - value: hello - operations: - - function: push - type: string - value: hello - stack_final: - - type: string - value: hello -- name: String Tabs And Newlines Inside - code: '"hello\t\tworld\n\ntest"' - tokens: - - type: string - value: hello\t\tworld\n\ntest - operations: - - function: push - type: string - value: hello\t\tworld\n\ntest - stack_final: - - type: string - value: hello\t\tworld\n\ntest -- name: String Only Tabs - code: '"\t\t\t"' - tokens: - - type: string - value: \t\t\t - operations: - - function: push - type: string - value: \t\t\t - stack_final: - - type: string - value: \t\t\t -- name: String Only Newlines - code: '"\n\n\n"' - tokens: - - type: string - value: \n\n\n - operations: - - function: push - type: string - value: \n\n\n - stack_final: - - type: string - value: \n\n\n -- name: String Mixed Whitespace - code: '" \t\n\r "' - tokens: - - type: string - value: ' \t\n\r ' - operations: - - function: push - type: string - value: ' \t\n\r ' - stack_final: - - type: string - value: ' \t\n\r ' -- name: String Sentence - code: '"The quick brown fox jumps over the lazy dog."' - tokens: - - type: string - value: The quick brown fox jumps over the lazy dog. - operations: - - function: push - type: string - value: The quick brown fox jumps over the lazy dog. - stack_final: - - type: string - value: The quick brown fox jumps over the lazy dog. -- name: String Multiple Sentences - code: '"First sentence. Second sentence. Third sentence."' - tokens: - - type: string - value: First sentence. Second sentence. Third sentence. - operations: - - function: push - type: string - value: First sentence. Second sentence. Third sentence. - stack_final: - - type: string - value: First sentence. Second sentence. Third sentence. -- name: String Long With Escapes - code: '"This is a long string.\nIt has multiple lines.\nAnd some tabs\there.\nPlus - quotes "like this"."' - tokens: - - type: string - value: This is a long string.\nIt has multiple lines.\nAnd some tabs\there.\nPlus - quotes \"like this\". - operations: - - function: push - type: string - value: This is a long string.\nIt has multiple lines.\nAnd some tabs\there.\nPlus - quotes \"like this\". - stack_final: - - type: string - value: This is a long string.\nIt has multiple lines.\nAnd some tabs\there.\nPlus - quotes \"like this\". -- name: String Repetitive - code: '"aaaaaaaaaa"' - tokens: - - type: string - value: aaaaaaaaaa - operations: - - function: push - type: string - value: aaaaaaaaaa - stack_final: - - type: string - value: aaaaaaaaaa -- name: String ASCII Printable - code: '" !#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~"' - tokens: - - type: string - value: ' !#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~' - operations: - - function: push - type: string - value: ' !#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~' - stack_final: - - type: string - value: ' !#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~' -- name: String Code Like - code: '"int main() { return 0; }"' - tokens: - - type: string - value: int main() { return 0; } - operations: - - function: push - type: string - value: int main() { return 0; } - stack_final: - - type: string - value: int main() { return 0; } -- name: String JSON Like - code: '"{{\\"key\\": \\"value\\"}}"' - tokens: - - type: string - value: '{\"key\": \"value\"}' - operations: - - function: push - type: string - value: '{\"key\": \"value\"}' - stack_final: - - type: string - value: '{\"key\": \"value\"}' -- name: String URL - code: '"https://example.com/path?query=value"' - tokens: - - type: string - value: https://example.com/path?query=value - operations: - - function: push - type: string - value: https://example.com/path?query=value - stack_final: - - type: string - value: https://example.com/path?query=value -- name: String Email - code: '"user@example.com"' - tokens: - - type: string - value: user@example.com - operations: - - function: push - type: string - value: user@example.com - stack_final: - - type: string - value: user@example.com -- name: String Unix Path - code: '"/home/user/file.txt"' - tokens: - - type: string - value: /home/user/file.txt - operations: - - function: push - type: string - value: /home/user/file.txt - stack_final: - - type: string - value: /home/user/file.txt -- name: String Windows Path - code: '"C:\\Users\\file.txt"' - tokens: - - type: string - value: C:\\Users\\file.txt - operations: - - function: push - type: string - value: C:\\Users\\file.txt - stack_final: - - type: string - value: C:\\Users\\file.txt -- name: String SQL Like - code: '"SELECT * FROM users WHERE id = 1"' - tokens: - - type: string - value: SELECT * FROM users WHERE id = 1 - operations: - - function: push - type: string - value: SELECT * FROM users WHERE id = 1 - stack_final: - - type: string - value: SELECT * FROM users WHERE id = 1 -- name: String Regex Like - code: '"[a-zA-Z0-9]+"' - tokens: - - type: string - value: '[a-zA-Z0-9]+' - operations: - - function: push - type: string - value: '[a-zA-Z0-9]+' - stack_final: - - type: string - value: '[a-zA-Z0-9]+' -- name: String Unclosed - code: '"hello' - tokens: - - type: error - value: 'Invalid string literal: unclosed string literal.' -- name: String Unescaped Newline - code: '"hello\nworld"' - tokens: - - type: error - value: 'Invalid string literal: unescaped newline in string literal.' -- name: String Invalid Escape - code: '"hello\\qworld"' - tokens: - - type: error - value: 'Invalid string literal: unknown escape sequence ''\\q''.' -- name: String Hex Too Short - code: '"\x4"' - tokens: - - type: error - value: 'Invalid string literal: hexadecimal escape must have exactly 2 digits.' -- name: String Hex Too Long - code: '"\\x414"' - tokens: - - type: error - value: 'Invalid string literal: hexadecimal escape must have exactly 2 digits.' -- name: String Hex Invalid Digit - code: '"\\xGG"' - tokens: - - type: error - value: 'Invalid string literal: invalid hexadecimal digit ''G''.' -- name: String Single Quotes - code: '''hello''' - tokens: - - type: error - value: 'Invalid string literal: string literals must use double quotes.' -- name: String Backslash At End - code: '"hello\\"' - tokens: - - type: error - value: 'Invalid string literal: incomplete escape sequence at end.' -- name: String Only Escapes - code: '"\n\t\r"' - tokens: - - type: string - value: \n\t\r - operations: - - function: push - type: string - value: \n\t\r - stack_final: - - type: string - value: \n\t\r -- name: String With Nulls - code: '"a\0b\0c"' - tokens: - - type: string - value: a\0b\0c - operations: - - function: push - type: string - value: a\0b\0c - stack_final: - - type: string - value: a\0b\0c -- name: String Many Escapes - code: '"\n\n\n\n\n\n\n\n\n\n"' - tokens: - - type: string - value: \n\n\n\n\n\n\n\n\n\n - operations: - - function: push - type: string - value: \n\n\n\n\n\n\n\n\n\n - stack_final: - - type: string - value: \n\n\n\n\n\n\n\n\n\n -- name: Identifier Simple Lowercase - code: hello - tokens: - - type: identifier - value: hello - operations: - - function: push - type: identifier - value: hello - stack_final: - - type: identifier - value: hello -- name: Identifier Simple Uppercase - code: HELLO - tokens: - - type: identifier - value: HELLO - operations: - - function: push - type: identifier - value: HELLO - stack_final: - - type: identifier - value: HELLO -- name: Identifier Mixed Case - code: HelloWorld - tokens: - - type: identifier - value: HelloWorld - operations: - - function: push - type: identifier - value: HelloWorld - stack_final: - - type: identifier - value: HelloWorld -- name: Identifier Single Letter - code: x - tokens: - - type: identifier - value: x - operations: - - function: push - type: identifier - value: x - stack_final: - - type: identifier - value: x -- name: Identifier Single Letter Upper - code: X - tokens: - - type: identifier - value: X - operations: - - function: push - type: identifier - value: X - stack_final: - - type: identifier - value: X -- name: Identifier With Numbers - code: var123 - tokens: - - type: identifier - value: var123 - operations: - - function: push - type: identifier - value: var123 - stack_final: - - type: identifier - value: var123 -- name: Identifier Numbers End - code: myVar2 - tokens: - - type: identifier - value: myVar2 - operations: - - function: push - type: identifier - value: myVar2 - stack_final: - - type: identifier - value: myVar2 -- name: Identifier Mixed Numbers - code: a1b2c3 - tokens: - - type: identifier - value: a1b2c3 - operations: - - function: push - type: identifier - value: a1b2c3 - stack_final: - - type: identifier - value: a1b2c3 -- name: Identifier With Underscore - code: hello_world - tokens: - - type: identifier - value: hello_world - operations: - - function: push - type: identifier - value: hello_world - stack_final: - - type: identifier - value: hello_world -- name: Identifier Leading Underscore - code: _private - tokens: - - type: identifier - value: _private - operations: - - function: push - type: identifier - value: _private - stack_final: - - type: identifier - value: _private -- name: Identifier Multiple Underscores - code: my_long_var_name - tokens: - - type: identifier - value: my_long_var_name - operations: - - function: push - type: identifier - value: my_long_var_name - stack_final: - - type: identifier - value: my_long_var_name -- name: Identifier Double Underscore - code: my__var - tokens: - - type: identifier - value: my__var - operations: - - function: push - type: identifier - value: my__var - stack_final: - - type: identifier - value: my__var -- name: Identifier Trailing Underscore - code: var_ - tokens: - - type: identifier - value: var_ - operations: - - function: push - type: identifier - value: var_ - stack_final: - - type: identifier - value: var_ -- name: Identifier Only Underscores - code: ___ - tokens: - - type: identifier - value: ___ - operations: - - function: push - type: identifier - value: ___ - stack_final: - - type: identifier - value: ___ -- name: Identifier Snake Case - code: my_variable_name - tokens: - - type: identifier - value: my_variable_name - operations: - - function: push - type: identifier - value: my_variable_name - stack_final: - - type: identifier - value: my_variable_name -- name: Identifier Camel Case - code: myVariableName - tokens: - - type: identifier - value: myVariableName - operations: - - function: push - type: identifier - value: myVariableName - stack_final: - - type: identifier - value: myVariableName -- name: Identifier Pascal Case - code: MyClassName - tokens: - - type: identifier - value: MyClassName - operations: - - function: push - type: identifier - value: MyClassName - stack_final: - - type: identifier - value: MyClassName -- name: Identifier All Caps - code: MY_CONSTANT - tokens: - - type: identifier - value: MY_CONSTANT - operations: - - function: push - type: identifier - value: MY_CONSTANT - stack_final: - - type: identifier - value: MY_CONSTANT -- name: Identifier Literal Simple - code: ::hello - tokens: - - type: identifier_literal - value: hello - operations: - - function: push - type: identifier_literal - value: hello - stack_final: - - type: identifier_literal - value: hello -- name: Identifier Literal Uppercase - code: ::Point - tokens: - - type: identifier_literal - value: Point - operations: - - function: push - type: identifier_literal - value: Point - stack_final: - - type: identifier_literal - value: Point -- name: Identifier Literal Snake Case - code: ::my_var - tokens: - - type: identifier_literal - value: my_var - operations: - - function: push - type: identifier_literal - value: my_var - stack_final: - - type: identifier_literal - value: my_var -- name: Identifier Literal Type i64 - code: ::i64 - tokens: - - type: identifier_literal - value: i64 - operations: - - function: push - type: identifier_literal - value: i64 - stack_final: - - type: identifier_literal - value: i64 -- name: Identifier Literal Type String - code: ::String - tokens: - - type: identifier_literal - value: String - operations: - - function: push - type: identifier_literal - value: String - stack_final: - - type: identifier_literal - value: String -- name: Identifier Literal Type Point - code: ::Point - tokens: - - type: identifier_literal - value: Point - operations: - - function: push - type: identifier_literal - value: Point - stack_final: - - type: identifier_literal - value: Point -- name: Identifier Literal Trait Addable - code: ::Addable - tokens: - - type: identifier_literal - value: Addable - operations: - - function: push - type: identifier_literal - value: Addable - stack_final: - - type: identifier_literal - value: Addable -- name: Identifier Literal Trait Drawable - code: ::Drawable - tokens: - - type: identifier_literal - value: Drawable - operations: - - function: push - type: identifier_literal - value: Drawable - stack_final: - - type: identifier_literal - value: Drawable -- name: Identifier Literal Field x - code: ::x - tokens: - - type: identifier_literal - value: x - operations: - - function: push - type: identifier_literal - value: x - stack_final: - - type: identifier_literal - value: x -- name: Identifier Literal Field width - code: ::width - tokens: - - type: identifier_literal - value: width - operations: - - function: push - type: identifier_literal - value: width - stack_final: - - type: identifier_literal - value: width -- name: Identifier Literal With Underscore - code: ::_private - tokens: - - type: identifier_literal - value: _private - operations: - - function: push - type: identifier_literal - value: _private - stack_final: - - type: identifier_literal - value: _private -- name: Identifier Literal Multiple Underscores - code: ::my_long_name - tokens: - - type: identifier_literal - value: my_long_name - operations: - - function: push - type: identifier_literal - value: my_long_name - stack_final: - - type: identifier_literal - value: my_long_name -- name: Identifier Literal With Numbers - code: ::var123 - tokens: - - type: identifier_literal - value: var123 - operations: - - function: push - type: identifier_literal - value: var123 - stack_final: - - type: identifier_literal - value: var123 -- name: Identifier Leading Whitespace - code: ' hello' - tokens: - - type: identifier - value: hello - operations: - - function: push - type: identifier - value: hello - stack_final: - - type: identifier - value: hello -- name: Identifier Trailing Whitespace - code: 'hello ' - tokens: - - type: identifier - value: hello - operations: - - function: push - type: identifier - value: hello - stack_final: - - type: identifier - value: hello -- name: Identifier Both Whitespace - code: ' hello ' - tokens: - - type: identifier - value: hello - operations: - - function: push - type: identifier - value: hello - stack_final: - - type: identifier - value: hello -- name: Identifier Tab Before - code: "\thello" - tokens: - - type: identifier - value: hello - operations: - - function: push - type: identifier - value: hello - stack_final: - - type: identifier - value: hello -- name: Identifier Literal Leading Whitespace - code: ' ::hello' - tokens: - - type: identifier_literal - value: hello - operations: - - function: push - type: identifier_literal - value: hello - stack_final: - - type: identifier_literal - value: hello -- name: Identifier Literal Trailing Whitespace - code: '::hello ' - tokens: - - type: identifier_literal - value: hello - operations: - - function: push - type: identifier_literal - value: hello - stack_final: - - type: identifier_literal - value: hello -- name: Identifier Literal Both Whitespace - code: ' ::hello ' - tokens: - - type: identifier_literal - value: hello - operations: - - function: push - type: identifier_literal - value: hello - stack_final: - - type: identifier_literal - value: hello -- name: Identifier Moderate Length - code: thisIsAReasonablyLongVariableName - tokens: - - type: identifier - value: thisIsAReasonablyLongVariableName - operations: - - function: push - type: identifier - value: thisIsAReasonablyLongVariableName - stack_final: - - type: identifier - value: thisIsAReasonablyLongVariableName -- name: Identifier Very Long - code: this_is_a_very_long_identifier_name_that_someone_might_use_for_some_reason - tokens: - - type: identifier - value: this_is_a_very_long_identifier_name_that_someone_might_use_for_some_reason - operations: - - function: push - type: identifier - value: this_is_a_very_long_identifier_name_that_someone_might_use_for_some_reason - stack_final: - - type: identifier - value: this_is_a_very_long_identifier_name_that_someone_might_use_for_some_reason -- name: Identifier Long With Numbers - code: variable_with_many_numbers_123_456_789_000 - tokens: - - type: identifier - value: variable_with_many_numbers_123_456_789_000 - operations: - - function: push - type: identifier - value: variable_with_many_numbers_123_456_789_000 - stack_final: - - type: identifier - value: variable_with_many_numbers_123_456_789_000 -- name: Identifier Starting With Number - code: 123abc - tokens: - - type: error - value: 'Invalid identifier: cannot start with digit.' -- name: Identifier With Hash - code: my#var - tokens: - - type: error - value: 'Invalid identifier: ''#'' is not allowed in identifiers.' -- name: Identifier With Dash - code: my-var - tokens: - - type: error - value: 'Invalid identifier: ''-'' is not allowed in identifiers.' -- name: Identifier With Dot - code: my.var - tokens: - - type: error - value: 'Invalid identifier: ''.'' is not allowed in identifiers.' -- name: Identifier With Space - code: my var - tokens: - - type: error - value: 'Invalid identifier: whitespace not allowed in identifiers.' -- name: Identifier With Colon - code: my:var - tokens: - - type: error - value: 'Invalid identifier: '':'' is not allowed in identifiers.' -- name: Identifier Double Colon Inside - code: my::var - tokens: - - type: error - value: 'Invalid identifier: ''::'' only allowed as prefix for identifier literals.' -- name: Identifier With At - code: '@variable' - tokens: - - type: error - value: 'Invalid identifier: ''@'' is not allowed in identifiers.' -- name: Identifier With Dollar - code: $variable - tokens: - - type: error - value: 'Invalid identifier: ''$'' is not allowed in identifiers.' -- name: Identifier With Percent - code: '%variable' - tokens: - - type: error - value: 'Invalid identifier: ''%'' is not allowed in identifiers.' -- name: Identifier With Brackets - code: my[var] - tokens: - - type: error - value: 'Invalid identifier: brackets not allowed in identifiers.' -- name: Identifier With Braces - code: my{var} - tokens: - - type: error - value: 'Invalid identifier: braces not allowed in identifiers.' -- name: Identifier With Parens - code: my(var) - tokens: - - type: error - value: 'Invalid identifier: parentheses not allowed in identifiers.' -- name: Identifier With Single Quote - code: my'var - tokens: - - type: error - value: 'Invalid identifier: quotes not allowed in identifiers.' -- name: Identifier With Double Quote - code: my"var - tokens: - - type: error - value: 'Invalid identifier: quotes not allowed in identifiers.' -- name: Identifier Only Numbers - code: '123' - tokens: - - type: error - value: 'Not an identifier: numeric literal.' -- name: Identifier Literal Empty - code: '::' - tokens: - - type: error - value: 'Invalid identifier literal: empty identifier after ''::''.' -- name: Identifier Case Lower - code: variable - tokens: - - type: identifier - value: variable - operations: - - function: push - type: identifier - value: variable - stack_final: - - type: identifier - value: variable -- name: Identifier Case Upper - code: VARIABLE - tokens: - - type: identifier - value: VARIABLE - operations: - - function: push - type: identifier - value: VARIABLE - stack_final: - - type: identifier - value: VARIABLE -- name: Identifier Case Mixed - code: Variable - tokens: - - type: identifier - value: Variable - operations: - - function: push - type: identifier - value: Variable - stack_final: - - type: identifier - value: Variable -- name: Identifier Case Camel - code: variableName - tokens: - - type: identifier - value: variableName - operations: - - function: push - type: identifier - value: variableName - stack_final: - - type: identifier - value: variableName -- name: Identifier Case Pascal - code: VariableName - tokens: - - type: identifier - value: VariableName - operations: - - function: push - type: identifier - value: VariableName - stack_final: - - type: identifier - value: VariableName -- name: Identifier Reserved Word true - code: 'true' - tokens: - - type: identifier - value: 'true' - operations: - - function: push - type: identifier - value: 'true' - stack_final: - - type: identifier - value: 'true' -- name: Identifier Reserved Word false - code: 'false' - tokens: - - type: identifier - value: 'false' - operations: - - function: push - type: identifier - value: 'false' - stack_final: - - type: identifier - value: 'false' -- name: Identifier Reserved Word if - code: if - tokens: - - type: identifier - value: if - operations: - - function: push - type: identifier - value: if - stack_final: - - type: identifier - value: if -- name: Identifier Reserved Word while - code: while - tokens: - - type: identifier - value: while - operations: - - function: push - type: identifier - value: while - stack_final: - - type: identifier - value: while -- name: Identifier Reserved Word for - code: for - tokens: - - type: identifier - value: for - operations: - - function: push - type: identifier - value: for - stack_final: - - type: identifier - value: for -- name: Identifier Reserved Word match - code: match - tokens: - - type: identifier - value: match - operations: - - function: push - type: identifier - value: match - stack_final: - - type: identifier - value: match -- name: Identifier Reserved Word break - code: break - tokens: - - type: identifier - value: break - operations: - - function: push - type: identifier - value: break - stack_final: - - type: identifier - value: break -- name: Identifier Reserved Word continue - code: continue - tokens: - - type: identifier - value: continue - operations: - - function: push - type: identifier - value: continue - stack_final: - - type: identifier - value: continue -- name: Identifier Reserved Word fn - code: fn - tokens: - - type: identifier - value: fn - operations: - - function: push - type: identifier - value: fn - stack_final: - - type: identifier - value: fn -- name: Identifier Reserved Word struct - code: struct - tokens: - - type: identifier - value: struct - operations: - - function: push - type: identifier - value: struct - stack_final: - - type: identifier - value: struct -- name: Identifier Reserved Word union - code: union - tokens: - - type: identifier - value: union - operations: - - function: push - type: identifier - value: union - stack_final: - - type: identifier - value: union -- name: Identifier Reserved Word enum - code: enum - tokens: - - type: identifier - value: enum - operations: - - function: push - type: identifier - value: enum - stack_final: - - type: identifier - value: enum -- name: Identifier Reserved Word trait - code: trait - tokens: - - type: identifier - value: trait - operations: - - function: push - type: identifier - value: trait - stack_final: - - type: identifier - value: trait -- name: Identifier Reserved Word impl - code: impl - tokens: - - type: identifier - value: impl - operations: - - function: push - type: identifier - value: impl - stack_final: - - type: identifier - value: impl -- name: Identifier Reserved Word inher - code: inher - tokens: - - type: identifier - value: inher - operations: - - function: push - type: identifier - value: inher - stack_final: - - type: identifier - value: inher -- name: Identifier Reserved Word dup - code: dup - tokens: - - type: identifier - value: dup - operations: - - function: push - type: identifier - value: dup - stack_final: - - type: identifier - value: dup -- name: Identifier Reserved Word drop - code: drop - tokens: - - type: identifier - value: drop - operations: - - function: push - type: identifier - value: drop - stack_final: - - type: identifier - value: drop -- name: Identifier Reserved Word swap - code: swap - tokens: - - type: identifier - value: swap - operations: - - function: push - type: identifier - value: swap - stack_final: - - type: identifier - value: swap -- name: Identifier Reserved Word over - code: over - tokens: - - type: identifier - value: over - operations: - - function: push - type: identifier - value: over - stack_final: - - type: identifier - value: over -- name: Identifier Reserved Word rot - code: rot - tokens: - - type: identifier - value: rot - operations: - - function: push - type: identifier - value: rot - stack_final: - - type: identifier - value: rot -- name: Identifier Reserved Word pick - code: pick - tokens: - - type: identifier - value: pick - operations: - - function: push - type: identifier - value: pick - stack_final: - - type: identifier - value: pick -- name: Identifier Reserved Word roll - code: roll - tokens: - - type: identifier - value: roll - operations: - - function: push - type: identifier - value: roll - stack_final: - - type: identifier - value: roll -- name: Identifier Reserved Word depth - code: depth - tokens: - - type: identifier - value: depth - operations: - - function: push - type: identifier - value: depth - stack_final: - - type: identifier - value: depth -- name: Bool True - code: 'true' - tokens: - - type: bool - value: true - operations: - - function: push - type: bool - value: true - stack_final: - - type: bool - value: true -- name: Bool False - code: 'false' - tokens: - - type: bool - value: false - operations: - - function: push - type: bool - value: false - stack_final: - - type: bool - value: false -- name: Bool True Leading Whitespace - code: ' true' - tokens: - - type: bool - value: true - operations: - - function: push - type: bool - value: true - stack_final: - - type: bool - value: true -- name: Bool True Trailing Whitespace - code: 'true ' - tokens: - - type: bool - value: true - operations: - - function: push - type: bool - value: true - stack_final: - - type: bool - value: true -- name: Bool True Both Whitespace - code: ' true ' - tokens: - - type: bool - value: true - operations: - - function: push - type: bool - value: true - stack_final: - - type: bool - value: true -- name: Bool True Tab Before - code: "\ttrue" - tokens: - - type: bool - value: true - operations: - - function: push - type: bool - value: true - stack_final: - - type: bool - value: true -- name: Bool False Leading Whitespace - code: ' false' - tokens: - - type: bool - value: false - operations: - - function: push - type: bool - value: false - stack_final: - - type: bool - value: false -- name: Bool False Trailing Whitespace - code: 'false ' - tokens: - - type: bool - value: false - operations: - - function: push - type: bool - value: false - stack_final: - - type: bool - value: false -- name: Bool False Both Whitespace - code: ' false ' - tokens: - - type: bool - value: false - operations: - - function: push - type: bool - value: false - stack_final: - - type: bool - value: false -- name: Bool False Tab Before - code: "\tfalse" - tokens: - - type: bool - value: false - operations: - - function: push - type: bool - value: false - stack_final: - - type: bool - value: false -- name: Bool True Capitalized - code: 'True' - tokens: - - type: error - value: 'Invalid boolean: ''True'' is not a boolean literal (use lowercase ''true'').' -- name: Bool False Capitalized - code: 'False' - tokens: - - type: error - value: 'Invalid boolean: ''False'' is not a boolean literal (use lowercase ''false'').' -- name: Bool True All Caps - code: 'TRUE' - tokens: - - type: error - value: 'Invalid boolean: ''TRUE'' is not a boolean literal (use lowercase ''true'').' -- name: Bool False All Caps - code: 'FALSE' - tokens: - - type: error - value: 'Invalid boolean: ''FALSE'' is not a boolean literal (use lowercase ''false'').' -- name: Bool True Mixed Case - code: tRuE - tokens: - - type: error - value: 'Invalid boolean: ''tRuE'' is not a boolean literal (use lowercase ''true'').' -- name: Bool False Mixed Case - code: fAlSe - tokens: - - type: error - value: 'Invalid boolean: ''fAlSe'' is not a boolean literal (use lowercase ''false'').' -- name: Bool Numeric 1 - code: '1' - tokens: - - type: error - value: 'Not a boolean: numeric literal.' -- name: Bool Numeric 0 - code: '0' - tokens: - - type: error - value: 'Not a boolean: numeric literal.' -- name: Bool String True - code: '"true"' - tokens: - - type: error - value: 'Not a boolean: string literal.' -- name: Bool String False - code: '"false"' - tokens: - - type: error - value: 'Not a boolean: string literal.' -- name: Bool Yes - code: 'yes' - tokens: - - type: error - value: 'Invalid boolean: ''yes'' is not a boolean literal.' -- name: Bool No - code: 'no' - tokens: - - type: error - value: 'Invalid boolean: ''no'' is not a boolean literal.' -- name: Bool Typo Ture - code: ture - tokens: - - type: error - value: 'Invalid boolean: ''ture'' is not a boolean literal.' -- name: Bool Typo Flase - code: flase - tokens: - - type: error - value: 'Invalid boolean: ''flase'' is not a boolean literal.' -- name: Bool Multiple True False - code: true false - tokens: - - type: bool - value: true - - type: bool - value: false - operations: - - function: push - type: bool - value: true - - function: push - type: bool - value: false - stack_final: - - type: bool - value: true - - type: bool - value: false -- name: Bool Multiple Same - code: true true - tokens: - - type: bool - value: true - - type: bool - value: true - operations: - - function: push - type: bool - value: true - - function: push - type: bool - value: true - stack_final: - - type: bool - value: true - - type: bool - value: true -- name: Bool Three Values - code: true false true - tokens: - - type: bool - value: true - - type: bool - value: false - - type: bool - value: true - operations: - - function: push - type: bool - value: true - - function: push - type: bool - value: false - - function: push - type: bool - value: true - stack_final: - - type: bool - value: true - - type: bool - value: false - - type: bool - value: true diff --git a/SLS_Tests/generate_tests/char_tests.py b/SLS_Tests/generate_tests/char_tests.py index 449899f..1ef2b3e 100644 --- a/SLS_Tests/generate_tests/char_tests.py +++ b/SLS_Tests/generate_tests/char_tests.py @@ -7,22 +7,12 @@ class CharTestGenerator(BaseTestGenerator): # Common escape sequences ESCAPE_SEQUENCES = { - ("Newline", '\\n', '\n',), # Newline - ("Carriage return", '\\r', '\r',), # Carriage return - ("Tab", '\\t', '\t',), # Tab - ("Backslash", '\\\\', '\\',), # Backslash - ("Double quote", '\\\\"', '"',), # Double quote - ("Single quote", "\\'", "'",), # Single quote - ("Null character", '\\0', '\0',), # Null character - } - - # Hexadecimal escape examples - HEX_ESCAPES = { - '\\x41': 'A', - '\\x61': 'a', - '\\x20': ' ', - '\\x00': '\0', - '\\xFF': 'ÿ', + ("Newline", '\\\\n', '\n',), # Newline + ("Carriage return", '\\\\r', '\r',), # Carriage return + ("Tab", '\\\\t', '\t',), # Tab + ("Backslash", '\\\\\\\\', '\\',), # Backslash + ("Single quote", "\\\\'", "'",), # Single quote + ("Null character", '\\\\0', '\0',), # Null character } # Unicode escape examples @@ -81,35 +71,16 @@ class CharTestGenerator(BaseTestGenerator): name = f"Char Escape {escape_name}" code = f"'{escape_str}'" self.make_success_test(name, code, "char", char_val) - - # Additional escape sequences with descriptions - test_cases = [ - ("Newline", "'\\n'", '\n'), - ("Carriage Return", "'\\r'", '\r'), - ("Tab", "'\\t'", '\t'), - ("Backslash", "'\\\\'", '\\'), - ("Double Quote", "'\\\\\"'", '"'), - ("Single Quote", "'\\''", "'"), - ("Null", "'\\0'", '\0'), - ] - - for desc, code, char_val in test_cases: - self.make_success_test(f"Char {desc}", code, "char", char_val) def generate_hexadecimal_escape_tests(self): """Generate tests for hexadecimal escape sequences.""" - for escape_str, char_val in self.HEX_ESCAPES.items(): - name = f"Char Hex Escape {escape_str}" - code = f"'{escape_str}'" - self.make_success_test(name, code, "char", char_val) - # Additional specific hex escapes - self.make_success_test("Char Hex Lowercase A", "'\\x61'", "char", 'a') - self.make_success_test("Char Hex Uppercase A", "'\\x41'", "char", 'A') - self.make_success_test("Char Hex Space", "'\\x20'", "char", ' ') - self.make_success_test("Char Hex Tab", "'\\x09'", "char", '\t') - self.make_success_test("Char Hex Newline", "'\\x0A'", "char", '\n') - self.make_success_test("Char Hex Max ASCII", "'\\x7F'", "char", '\x7F') + self.make_success_test("Char Hex Lowercase A", "'\\\\x61'", "char", 'a') + self.make_success_test("Char Hex Uppercase A", "'\\\\x41'", "char", 'A') + self.make_success_test("Char Hex Space", "'\\\\x20'", "char", ' ') + self.make_success_test("Char Hex Tab", "'\\\\x09'", "char", '\t') + self.make_success_test("Char Hex Newline", "'\\\\x0A'", "char", '\n') + self.make_success_test("Char Hex Max ASCII", "'\\\\x7F'", "char", '\x7F') def generate_unicode_escape_tests(self): """Generate tests for Unicode escape sequences.""" @@ -176,7 +147,7 @@ class CharTestGenerator(BaseTestGenerator): # Multiple characters (no escape) self.make_error_test("Char Multiple Characters", "'AB'", - "Invalid character literal: multiple characters without escape sequence.") + "Invalid character literal: unexpected 'B' in character.") # Unclosed quote self.make_error_test("Char Unclosed Quote", @@ -186,7 +157,7 @@ class CharTestGenerator(BaseTestGenerator): # Unescaped newline self.make_error_test("Char Unescaped Newline", "'\\n'", - "Invalid character literal: unescaped newline in character literal.") + "Invalid character literal: unclosed character literal.") # Invalid escape sequence self.make_error_test("Char Invalid Escape", @@ -241,28 +212,18 @@ class CharTestGenerator(BaseTestGenerator): self.make_error_test("Char Unicode Unclosed", "'\\u{1F600'", "Invalid character literal: unclosed Unicode escape sequence.") - - # Double quotes instead of single - self.make_error_test("Char Double Quotes", - '"A"', - "Invalid character literal: character literals must use single quotes.") - - # No quotes - self.make_error_test("Char No Quotes", - "A", - "Not a character literal: missing quotes.") def generate_edge_case_tests(self): """Generate edge case tests.""" # ASCII control characters - self.make_success_test("Char ASCII Control SOH", "'\\x01'", "char", '\x01') - self.make_success_test("Char ASCII Control BEL", "'\\x07'", "char", '\x07') - self.make_success_test("Char ASCII Control ESC", "'\\x1B'", "char", '\x1B') - self.make_success_test("Char ASCII Control DEL", "'\\x7F'", "char", '\x7F') + self.make_success_test("Char ASCII Control SOH", "'\\\\x01'", "char", '\x01') + self.make_success_test("Char ASCII Control BEL", "'\\\\x07'", "char", '\x07') + self.make_success_test("Char ASCII Control ESC", "'\\\\x1B'", "char", '\x1B') + self.make_success_test("Char ASCII Control DEL", "'\\\\x7F'", "char", '\x7F') # Extended ASCII - self.make_success_test("Char Extended ASCII Lower", "'\\x80'", "char", '\x80') - self.make_success_test("Char Extended ASCII Upper", "'\\xFF'", "char", '\xFF') + self.make_success_test("Char Extended ASCII Lower", "'\\\\x80'", "char", '\x80') + self.make_success_test("Char Extended ASCII Upper", "'\\\\xFF'", "char", '\xFF') if self.ENABLE_UNICODE: # Zero-width characters @@ -281,23 +242,16 @@ class CharTestGenerator(BaseTestGenerator): # High Unicode values (but valid) self.make_success_test("Char Unicode High Valid", "'\\u{10FFFF}'", "char", '\U0010FFFF') - - # Backslash before valid character - self.make_success_test("Char Backslash Literal", "'\\\\'", "char", '\\') - - # Quote escaping - self.make_success_test("Char Single Quote Escaped", "'\\''", "char", "'") - # self.make_success_test("Char Double Quote Escaped", "'\\\"'", "char", '"') def generate_case_sensitivity_tests(self): """Generate tests for case sensitivity in escape sequences.""" # Hex escapes - lowercase x - self.make_success_test("Char Hex Lowercase x", "'\\x41'", "char", 'A') + self.make_success_test("Char Hex Lowercase x", "'\\\\x41'", "char", 'A') # Hex digits - both cases - self.make_success_test("Char Hex Digits Uppercase", "'\\xFF'", "char", '\xFF') - self.make_success_test("Char Hex Digits Lowercase", "'\\xff'", "char", '\xff') - self.make_success_test("Char Hex Digits Mixed", "'\\xAb'", "char", '\xAB') + self.make_success_test("Char Hex Digits Uppercase", "'\\\\xFF'", "char", '\xFF') + self.make_success_test("Char Hex Digits Lowercase", "'\\\\xff'", "char", '\xff') + self.make_success_test("Char Hex Digits Mixed", "'\\\\xAb'", "char", '\xAB') if self.ENABLE_UNICODE: # Unicode escapes - lowercase u