diff --git a/src/Parser/Lexer/Lexer.cpp b/src/Parser/Lexer/Lexer.cpp index bfac094..3420ea6 100644 --- a/src/Parser/Lexer/Lexer.cpp +++ b/src/Parser/Lexer/Lexer.cpp @@ -126,7 +126,8 @@ namespace ElohimScript::Parser { if (n == u8'=') { Progress(); // >>= - return Create>(TextSpan(start, 3)); + return Create>( + TextSpan(start, 3)); } if (n == u8'>') { Progress(); @@ -233,8 +234,10 @@ namespace ElohimScript::Parser { } case u8'~': return Create>(TextSpan(start, start + 1)); case u8'.': return Create>(TextSpan(start, start + 1)); - case u8'[': return Create>(TextSpan(start, start + 1)); - case u8']': return Create>(TextSpan(start, start + 1)); + case u8'[': + return Create>(TextSpan(start, start + 1)); + case u8']': + return Create>(TextSpan(start, start + 1)); case u8'@': return Create>(TextSpan(start, start + 1)); case u8' ': @@ -283,13 +286,14 @@ namespace ElohimScript::Parser { if (secondChar != '.' && secondValue == 255) { Progress(); switch (secondChar) { - case 'x': numericalSystem = 16; break; - case 'd': numericalSystem = 10; break; + case 'x': + case 'X': numericalSystem = 16; break; + case 'd': + case 'D': numericalSystem = 10; break; case 'o': - numericalSystem = 8; - break; - ; - case 'b': numericalSystem = 2; break; + case 'O': numericalSystem = 8; break; + case 'b': + case 'B': numericalSystem = 2; break; default: _diagnostics->LogError(Diagnostics::DiagnosticType::InvalidNumericalBase, TextSpan(_position - 1, _position + 1)); @@ -470,7 +474,8 @@ namespace ElohimScript::Parser { Progress(offset - 1); switch (Hash(str.c_str())) { case Hash(u8"and"): return Create>(TextSpan(start, _position)); - case Hash(u8"abstract"): return Create>(TextSpan(start, _position)); + case Hash(u8"abstract"): + return Create>(TextSpan(start, _position)); case Hash(u8"auto"): return Create>(TextSpan(start, _position)); case Hash(u8"bool"): return Create>(TextSpan(start, _position)); case Hash(u8"break"): return Create>(TextSpan(start, _position)); @@ -479,21 +484,27 @@ namespace ElohimScript::Parser { case Hash(u8"catch"): return Create>(TextSpan(start, _position)); case Hash(u8"class"): return Create>(TextSpan(start, _position)); case Hash(u8"const"): return Create>(TextSpan(start, _position)); - case Hash(u8"continue"): return Create>(TextSpan(start, _position)); - case Hash(u8"default"): return Create>(TextSpan(start, _position)); + case Hash(u8"continue"): + return Create>(TextSpan(start, _position)); + case Hash(u8"default"): + return Create>(TextSpan(start, _position)); case Hash(u8"do"): return Create>(TextSpan(start, _position)); case Hash(u8"double"): return Create>(TextSpan(start, _position)); case Hash(u8"else"): return Create>(TextSpan(start, _position)); case Hash(u8"enum"): return Create>(TextSpan(start, _position)); - case Hash(u8"explicit"): return Create>(TextSpan(start, _position)); - case Hash(u8"external"): return Create>(TextSpan(start, _position)); + case Hash(u8"explicit"): + return Create>(TextSpan(start, _position)); + case Hash(u8"external"): + return Create>(TextSpan(start, _position)); case Hash(u8"false"): return Create>(TextSpan(start, _position)); case Hash(u8"final"): return Create>(TextSpan(start, _position)); case Hash(u8"float"): return Create>(TextSpan(start, _position)); case Hash(u8"for"): return Create>(TextSpan(start, _position)); case Hash(u8"from"): return Create>(TextSpan(start, _position)); - case Hash(u8"funcdef"): return Create>(TextSpan(start, _position)); - case Hash(u8"function"): return Create>(TextSpan(start, _position)); + case Hash(u8"funcdef"): + return Create>(TextSpan(start, _position)); + case Hash(u8"function"): + return Create>(TextSpan(start, _position)); case Hash(u8"get"): return Create>(TextSpan(start, _position)); case Hash(u8"if"): return Create>(TextSpan(start, _position)); case Hash(u8"import"): return Create>(TextSpan(start, _position)); @@ -514,9 +525,12 @@ namespace ElohimScript::Parser { case Hash(u8"null"): return Create>(TextSpan(start, _position)); case Hash(u8"or"): return Create>(TextSpan(start, _position)); case Hash(u8"out"): return Create>(TextSpan(start, _position)); - case Hash(u8"override"): return Create>(TextSpan(start, _position)); - case Hash(u8"private"): return Create>(TextSpan(start, _position)); - case Hash(u8"property"): return Create>(TextSpan(start, _position)); + case Hash(u8"override"): + return Create>(TextSpan(start, _position)); + case Hash(u8"private"): + return Create>(TextSpan(start, _position)); + case Hash(u8"property"): + return Create>(TextSpan(start, _position)); case Hash(u8"protected"): return Create>(TextSpan(start, _position)); case Hash(u8"return"): return Create>(TextSpan(start, _position)); @@ -527,7 +541,8 @@ namespace ElohimScript::Parser { case Hash(u8"this"): return Create>(TextSpan(start, _position)); case Hash(u8"true"): return Create>(TextSpan(start, _position)); case Hash(u8"try"): return Create>(TextSpan(start, _position)); - case Hash(u8"typedef"): return Create>(TextSpan(start, _position)); + case Hash(u8"typedef"): + return Create>(TextSpan(start, _position)); case Hash(u8"uint"): return Create>(TextSpan(start, _position)); case Hash(u8"uint8"): return Create>(TextSpan(start, _position)); case Hash(u8"uint16"): return Create>(TextSpan(start, _position)); diff --git a/tests/LexerTests/NumericalLexTests.cpp b/tests/LexerTests/NumericalLexTests.cpp index 5204698..dc25ceb 100644 --- a/tests/LexerTests/NumericalLexTests.cpp +++ b/tests/LexerTests/NumericalLexTests.cpp @@ -30,6 +30,7 @@ using namespace ElohimScript::Parser; // Decimal lexing INTEGER_TEST("123456", 123456); INTEGER_TEST("0d123456", 123456); +INTEGER_TEST("0D123456", 123456); INTEGER_TEST("50000000000", 50000000000); // Decimal float lexing @@ -48,6 +49,7 @@ INTEGER_TEST("0xFFF", 4095); INTEGER_TEST("0xFFFF", 65535); INTEGER_TEST("0xFFFFF", 1048575); INTEGER_TEST("0xFFFFFF", 16777215); +INTEGER_TEST("0XFFFFFF", 16777215); // Octal lexing INTEGER_TEST("0o0", 0); @@ -55,6 +57,7 @@ INTEGER_TEST("0o7", 7); INTEGER_TEST("0o77", 63); INTEGER_TEST("0o777", 511); INTEGER_TEST("0o7777", 4095); +INTEGER_TEST("0O7777", 4095); // Binary lexing INTEGER_TEST("0b0", 0); @@ -63,6 +66,7 @@ INTEGER_TEST("0b11", 3); INTEGER_TEST("0b111", 7); INTEGER_TEST("0b1111", 15); INTEGER_TEST("0b110011", 51); +INTEGER_TEST("0B110011", 51); #undef INTEGER_TEST #undef FLOAT_TEST