When getting base from first two values of a number, check both lowercase and uppercase.
This commit is contained in:
parent
739e2e6f17
commit
dffc0d7f17
|
@ -126,7 +126,8 @@ namespace ElohimScript::Parser {
|
||||||
if (n == u8'=') {
|
if (n == u8'=') {
|
||||||
Progress();
|
Progress();
|
||||||
// >>=
|
// >>=
|
||||||
return Create<LexTokenImpl<LexTokenKind::GreaterThanGreaterThanEqualsSymbol>>(TextSpan(start, 3));
|
return Create<LexTokenImpl<LexTokenKind::GreaterThanGreaterThanEqualsSymbol>>(
|
||||||
|
TextSpan(start, 3));
|
||||||
}
|
}
|
||||||
if (n == u8'>') {
|
if (n == u8'>') {
|
||||||
Progress();
|
Progress();
|
||||||
|
@ -233,8 +234,10 @@ namespace ElohimScript::Parser {
|
||||||
}
|
}
|
||||||
case u8'~': return Create<LexTokenImpl<LexTokenKind::TildeSymbol>>(TextSpan(start, start + 1));
|
case u8'~': return Create<LexTokenImpl<LexTokenKind::TildeSymbol>>(TextSpan(start, start + 1));
|
||||||
case u8'.': return Create<LexTokenImpl<LexTokenKind::DotSymbol>>(TextSpan(start, start + 1));
|
case u8'.': return Create<LexTokenImpl<LexTokenKind::DotSymbol>>(TextSpan(start, start + 1));
|
||||||
case u8'[': return Create<LexTokenImpl<LexTokenKind::OpenBlockParenthesisSymbol>>(TextSpan(start, start + 1));
|
case u8'[':
|
||||||
case u8']': return Create<LexTokenImpl<LexTokenKind::CloseBlockParenthesisSymbol>>(TextSpan(start, start + 1));
|
return Create<LexTokenImpl<LexTokenKind::OpenBlockParenthesisSymbol>>(TextSpan(start, start + 1));
|
||||||
|
case u8']':
|
||||||
|
return Create<LexTokenImpl<LexTokenKind::CloseBlockParenthesisSymbol>>(TextSpan(start, start + 1));
|
||||||
case u8'@': return Create<LexTokenImpl<LexTokenKind::AtSymbol>>(TextSpan(start, start + 1));
|
case u8'@': return Create<LexTokenImpl<LexTokenKind::AtSymbol>>(TextSpan(start, start + 1));
|
||||||
|
|
||||||
case u8' ':
|
case u8' ':
|
||||||
|
@ -283,13 +286,14 @@ namespace ElohimScript::Parser {
|
||||||
if (secondChar != '.' && secondValue == 255) {
|
if (secondChar != '.' && secondValue == 255) {
|
||||||
Progress();
|
Progress();
|
||||||
switch (secondChar) {
|
switch (secondChar) {
|
||||||
case 'x': numericalSystem = 16; break;
|
case 'x':
|
||||||
case 'd': numericalSystem = 10; break;
|
case 'X': numericalSystem = 16; break;
|
||||||
|
case 'd':
|
||||||
|
case 'D': numericalSystem = 10; break;
|
||||||
case 'o':
|
case 'o':
|
||||||
numericalSystem = 8;
|
case 'O': numericalSystem = 8; break;
|
||||||
break;
|
case 'b':
|
||||||
;
|
case 'B': numericalSystem = 2; break;
|
||||||
case 'b': numericalSystem = 2; break;
|
|
||||||
default:
|
default:
|
||||||
_diagnostics->LogError(Diagnostics::DiagnosticType::InvalidNumericalBase,
|
_diagnostics->LogError(Diagnostics::DiagnosticType::InvalidNumericalBase,
|
||||||
TextSpan(_position - 1, _position + 1));
|
TextSpan(_position - 1, _position + 1));
|
||||||
|
@ -470,7 +474,8 @@ namespace ElohimScript::Parser {
|
||||||
Progress(offset - 1);
|
Progress(offset - 1);
|
||||||
switch (Hash(str.c_str())) {
|
switch (Hash(str.c_str())) {
|
||||||
case Hash(u8"and"): return Create<LexTokenImpl<LexTokenKind::AndKeyword>>(TextSpan(start, _position));
|
case Hash(u8"and"): return Create<LexTokenImpl<LexTokenKind::AndKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"abstract"): return Create<LexTokenImpl<LexTokenKind::AbstractKeyword>>(TextSpan(start, _position));
|
case Hash(u8"abstract"):
|
||||||
|
return Create<LexTokenImpl<LexTokenKind::AbstractKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"auto"): return Create<LexTokenImpl<LexTokenKind::AutoKeyword>>(TextSpan(start, _position));
|
case Hash(u8"auto"): return Create<LexTokenImpl<LexTokenKind::AutoKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"bool"): return Create<LexTokenImpl<LexTokenKind::BoolKeyword>>(TextSpan(start, _position));
|
case Hash(u8"bool"): return Create<LexTokenImpl<LexTokenKind::BoolKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"break"): return Create<LexTokenImpl<LexTokenKind::BreakKeyword>>(TextSpan(start, _position));
|
case Hash(u8"break"): return Create<LexTokenImpl<LexTokenKind::BreakKeyword>>(TextSpan(start, _position));
|
||||||
|
@ -479,21 +484,27 @@ namespace ElohimScript::Parser {
|
||||||
case Hash(u8"catch"): return Create<LexTokenImpl<LexTokenKind::CatchKeyword>>(TextSpan(start, _position));
|
case Hash(u8"catch"): return Create<LexTokenImpl<LexTokenKind::CatchKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"class"): return Create<LexTokenImpl<LexTokenKind::ClassKeyword>>(TextSpan(start, _position));
|
case Hash(u8"class"): return Create<LexTokenImpl<LexTokenKind::ClassKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"const"): return Create<LexTokenImpl<LexTokenKind::ConstKeyword>>(TextSpan(start, _position));
|
case Hash(u8"const"): return Create<LexTokenImpl<LexTokenKind::ConstKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"continue"): return Create<LexTokenImpl<LexTokenKind::ContinueKeyword>>(TextSpan(start, _position));
|
case Hash(u8"continue"):
|
||||||
case Hash(u8"default"): return Create<LexTokenImpl<LexTokenKind::DefaultKeyword>>(TextSpan(start, _position));
|
return Create<LexTokenImpl<LexTokenKind::ContinueKeyword>>(TextSpan(start, _position));
|
||||||
|
case Hash(u8"default"):
|
||||||
|
return Create<LexTokenImpl<LexTokenKind::DefaultKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"do"): return Create<LexTokenImpl<LexTokenKind::DoKeyword>>(TextSpan(start, _position));
|
case Hash(u8"do"): return Create<LexTokenImpl<LexTokenKind::DoKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"double"): return Create<LexTokenImpl<LexTokenKind::DoubleKeyword>>(TextSpan(start, _position));
|
case Hash(u8"double"): return Create<LexTokenImpl<LexTokenKind::DoubleKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"else"): return Create<LexTokenImpl<LexTokenKind::ElseKeyword>>(TextSpan(start, _position));
|
case Hash(u8"else"): return Create<LexTokenImpl<LexTokenKind::ElseKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"enum"): return Create<LexTokenImpl<LexTokenKind::EnumKeyword>>(TextSpan(start, _position));
|
case Hash(u8"enum"): return Create<LexTokenImpl<LexTokenKind::EnumKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"explicit"): return Create<LexTokenImpl<LexTokenKind::ExplicitKeyword>>(TextSpan(start, _position));
|
case Hash(u8"explicit"):
|
||||||
case Hash(u8"external"): return Create<LexTokenImpl<LexTokenKind::ExternalKeyword>>(TextSpan(start, _position));
|
return Create<LexTokenImpl<LexTokenKind::ExplicitKeyword>>(TextSpan(start, _position));
|
||||||
|
case Hash(u8"external"):
|
||||||
|
return Create<LexTokenImpl<LexTokenKind::ExternalKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"false"): return Create<LexTokenImpl<LexTokenKind::FalseKeyword>>(TextSpan(start, _position));
|
case Hash(u8"false"): return Create<LexTokenImpl<LexTokenKind::FalseKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"final"): return Create<LexTokenImpl<LexTokenKind::FinalKeyword>>(TextSpan(start, _position));
|
case Hash(u8"final"): return Create<LexTokenImpl<LexTokenKind::FinalKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"float"): return Create<LexTokenImpl<LexTokenKind::FloatKeyword>>(TextSpan(start, _position));
|
case Hash(u8"float"): return Create<LexTokenImpl<LexTokenKind::FloatKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"for"): return Create<LexTokenImpl<LexTokenKind::ForKeyword>>(TextSpan(start, _position));
|
case Hash(u8"for"): return Create<LexTokenImpl<LexTokenKind::ForKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"from"): return Create<LexTokenImpl<LexTokenKind::FromKeyword>>(TextSpan(start, _position));
|
case Hash(u8"from"): return Create<LexTokenImpl<LexTokenKind::FromKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"funcdef"): return Create<LexTokenImpl<LexTokenKind::FuncdefKeyword>>(TextSpan(start, _position));
|
case Hash(u8"funcdef"):
|
||||||
case Hash(u8"function"): return Create<LexTokenImpl<LexTokenKind::FunctionKeyword>>(TextSpan(start, _position));
|
return Create<LexTokenImpl<LexTokenKind::FuncdefKeyword>>(TextSpan(start, _position));
|
||||||
|
case Hash(u8"function"):
|
||||||
|
return Create<LexTokenImpl<LexTokenKind::FunctionKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"get"): return Create<LexTokenImpl<LexTokenKind::GetKeyword>>(TextSpan(start, _position));
|
case Hash(u8"get"): return Create<LexTokenImpl<LexTokenKind::GetKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"if"): return Create<LexTokenImpl<LexTokenKind::IfKeyword>>(TextSpan(start, _position));
|
case Hash(u8"if"): return Create<LexTokenImpl<LexTokenKind::IfKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"import"): return Create<LexTokenImpl<LexTokenKind::ImportKeyword>>(TextSpan(start, _position));
|
case Hash(u8"import"): return Create<LexTokenImpl<LexTokenKind::ImportKeyword>>(TextSpan(start, _position));
|
||||||
|
@ -514,9 +525,12 @@ namespace ElohimScript::Parser {
|
||||||
case Hash(u8"null"): return Create<LexTokenImpl<LexTokenKind::NullKeyword>>(TextSpan(start, _position));
|
case Hash(u8"null"): return Create<LexTokenImpl<LexTokenKind::NullKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"or"): return Create<LexTokenImpl<LexTokenKind::OrKeyword>>(TextSpan(start, _position));
|
case Hash(u8"or"): return Create<LexTokenImpl<LexTokenKind::OrKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"out"): return Create<LexTokenImpl<LexTokenKind::OutKeyword>>(TextSpan(start, _position));
|
case Hash(u8"out"): return Create<LexTokenImpl<LexTokenKind::OutKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"override"): return Create<LexTokenImpl<LexTokenKind::OverrideKeyword>>(TextSpan(start, _position));
|
case Hash(u8"override"):
|
||||||
case Hash(u8"private"): return Create<LexTokenImpl<LexTokenKind::PrivateKeyword>>(TextSpan(start, _position));
|
return Create<LexTokenImpl<LexTokenKind::OverrideKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"property"): return Create<LexTokenImpl<LexTokenKind::PropertyKeyword>>(TextSpan(start, _position));
|
case Hash(u8"private"):
|
||||||
|
return Create<LexTokenImpl<LexTokenKind::PrivateKeyword>>(TextSpan(start, _position));
|
||||||
|
case Hash(u8"property"):
|
||||||
|
return Create<LexTokenImpl<LexTokenKind::PropertyKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"protected"):
|
case Hash(u8"protected"):
|
||||||
return Create<LexTokenImpl<LexTokenKind::ProtectedKeyword>>(TextSpan(start, _position));
|
return Create<LexTokenImpl<LexTokenKind::ProtectedKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"return"): return Create<LexTokenImpl<LexTokenKind::ReturnKeyword>>(TextSpan(start, _position));
|
case Hash(u8"return"): return Create<LexTokenImpl<LexTokenKind::ReturnKeyword>>(TextSpan(start, _position));
|
||||||
|
@ -527,7 +541,8 @@ namespace ElohimScript::Parser {
|
||||||
case Hash(u8"this"): return Create<LexTokenImpl<LexTokenKind::ThisKeyword>>(TextSpan(start, _position));
|
case Hash(u8"this"): return Create<LexTokenImpl<LexTokenKind::ThisKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"true"): return Create<LexTokenImpl<LexTokenKind::TrueKeyword>>(TextSpan(start, _position));
|
case Hash(u8"true"): return Create<LexTokenImpl<LexTokenKind::TrueKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"try"): return Create<LexTokenImpl<LexTokenKind::TryKeyword>>(TextSpan(start, _position));
|
case Hash(u8"try"): return Create<LexTokenImpl<LexTokenKind::TryKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"typedef"): return Create<LexTokenImpl<LexTokenKind::TypedefKeyword>>(TextSpan(start, _position));
|
case Hash(u8"typedef"):
|
||||||
|
return Create<LexTokenImpl<LexTokenKind::TypedefKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"uint"): return Create<LexTokenImpl<LexTokenKind::UintKeyword>>(TextSpan(start, _position));
|
case Hash(u8"uint"): return Create<LexTokenImpl<LexTokenKind::UintKeyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"uint8"): return Create<LexTokenImpl<LexTokenKind::Uint8Keyword>>(TextSpan(start, _position));
|
case Hash(u8"uint8"): return Create<LexTokenImpl<LexTokenKind::Uint8Keyword>>(TextSpan(start, _position));
|
||||||
case Hash(u8"uint16"): return Create<LexTokenImpl<LexTokenKind::Uint16Keyword>>(TextSpan(start, _position));
|
case Hash(u8"uint16"): return Create<LexTokenImpl<LexTokenKind::Uint16Keyword>>(TextSpan(start, _position));
|
||||||
|
|
|
@ -30,6 +30,7 @@ using namespace ElohimScript::Parser;
|
||||||
// Decimal lexing
|
// Decimal lexing
|
||||||
INTEGER_TEST("123456", 123456);
|
INTEGER_TEST("123456", 123456);
|
||||||
INTEGER_TEST("0d123456", 123456);
|
INTEGER_TEST("0d123456", 123456);
|
||||||
|
INTEGER_TEST("0D123456", 123456);
|
||||||
INTEGER_TEST("50000000000", 50000000000);
|
INTEGER_TEST("50000000000", 50000000000);
|
||||||
|
|
||||||
// Decimal float lexing
|
// Decimal float lexing
|
||||||
|
@ -48,6 +49,7 @@ INTEGER_TEST("0xFFF", 4095);
|
||||||
INTEGER_TEST("0xFFFF", 65535);
|
INTEGER_TEST("0xFFFF", 65535);
|
||||||
INTEGER_TEST("0xFFFFF", 1048575);
|
INTEGER_TEST("0xFFFFF", 1048575);
|
||||||
INTEGER_TEST("0xFFFFFF", 16777215);
|
INTEGER_TEST("0xFFFFFF", 16777215);
|
||||||
|
INTEGER_TEST("0XFFFFFF", 16777215);
|
||||||
|
|
||||||
// Octal lexing
|
// Octal lexing
|
||||||
INTEGER_TEST("0o0", 0);
|
INTEGER_TEST("0o0", 0);
|
||||||
|
@ -55,6 +57,7 @@ INTEGER_TEST("0o7", 7);
|
||||||
INTEGER_TEST("0o77", 63);
|
INTEGER_TEST("0o77", 63);
|
||||||
INTEGER_TEST("0o777", 511);
|
INTEGER_TEST("0o777", 511);
|
||||||
INTEGER_TEST("0o7777", 4095);
|
INTEGER_TEST("0o7777", 4095);
|
||||||
|
INTEGER_TEST("0O7777", 4095);
|
||||||
|
|
||||||
// Binary lexing
|
// Binary lexing
|
||||||
INTEGER_TEST("0b0", 0);
|
INTEGER_TEST("0b0", 0);
|
||||||
|
@ -63,6 +66,7 @@ INTEGER_TEST("0b11", 3);
|
||||||
INTEGER_TEST("0b111", 7);
|
INTEGER_TEST("0b111", 7);
|
||||||
INTEGER_TEST("0b1111", 15);
|
INTEGER_TEST("0b1111", 15);
|
||||||
INTEGER_TEST("0b110011", 51);
|
INTEGER_TEST("0b110011", 51);
|
||||||
|
INTEGER_TEST("0B110011", 51);
|
||||||
|
|
||||||
#undef INTEGER_TEST
|
#undef INTEGER_TEST
|
||||||
#undef FLOAT_TEST
|
#undef FLOAT_TEST
|
||||||
|
|
Loading…
Reference in New Issue