Fixes issue in lexing numerical base consuming character after it, removes test for invalid numerical base.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
namespace MalachScript::Diagnostics {
|
||||
enum class DiagnosticType : uint8_t {
|
||||
UnknownCharacter,
|
||||
InvalidNumericalBase,
|
||||
ExpectedEndOfString,
|
||||
UnexpectedToken,
|
||||
DoubleProperty,
|
||||
|
||||
@@ -11,8 +11,6 @@ namespace MalachScript::Diagnostics {
|
||||
switch (diag->GetType()) {
|
||||
case DiagnosticType::UnknownCharacter:
|
||||
return util::Format("Unknown character: '{0}'", diag->GetFormats());
|
||||
case DiagnosticType::InvalidNumericalBase:
|
||||
return util::Format("Invalid numerical base: '0{0}'", diag->GetFormats());
|
||||
case DiagnosticType::ExpectedEndOfString:
|
||||
return util::Format("Expected end of string, found {0}", diag->GetFormats());
|
||||
case DiagnosticType::UnexpectedToken:
|
||||
|
||||
@@ -292,16 +292,27 @@ namespace MalachScript::Parser {
|
||||
auto secondChar = Peek();
|
||||
auto secondValue = LexDecimalValue(secondChar);
|
||||
if (secondChar != '.' && secondValue == 255) {
|
||||
Progress();
|
||||
switch (secondChar) {
|
||||
case 'x':
|
||||
case 'X': numericalSystem = 16; break;
|
||||
case 'X':
|
||||
Progress();
|
||||
numericalSystem = 16;
|
||||
break;
|
||||
case 'd':
|
||||
case 'D': numericalSystem = 10; break;
|
||||
case 'D':
|
||||
Progress();
|
||||
numericalSystem = 10;
|
||||
break;
|
||||
case 'o':
|
||||
case 'O': numericalSystem = 8; break;
|
||||
case 'O':
|
||||
Progress();
|
||||
numericalSystem = 8;
|
||||
break;
|
||||
case 'b':
|
||||
case 'B': numericalSystem = 2; break;
|
||||
case 'B':
|
||||
Progress();
|
||||
numericalSystem = 2;
|
||||
break;
|
||||
default: return Create<IntegerLiteral>(TextSpan(_position - 1, _position), 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user