When an integer starts with a 0, and is followed by a non numerical symbol just lex it as a 0 literal, followed by another token.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2021-01-06 00:53:02 +01:00
parent 807fe63828
commit cf8d6ce18b
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 4 additions and 9 deletions

View File

@ -302,12 +302,7 @@ namespace MalachScript::Parser {
case 'O': numericalSystem = 8; break;
case 'b':
case 'B': numericalSystem = 2; break;
default:
LogError(Diagnostics::DiagnosticType::InvalidNumericalBase,
TextSpan(_position - 1, _position + 1), {std::string(1, secondChar)});
// Set to the largest numerical system, so we can prevent errors down the line.
numericalSystem = 16;
break;
default: return Create<IntegerLiteral>(TextSpan(_position - 1, _position), 0);
}
}
}
@ -403,7 +398,7 @@ namespace MalachScript::Parser {
value <<= 4;
value += v;
}
return Create<IntegerLiteral>(TextSpan(start, _position), value);
return Create<IntegerLiteral>(TextSpan(start - 1, _position), value);
}
IntegerLiteral* Lexer::LexOctal() {
auto start = _position;
@ -417,7 +412,7 @@ namespace MalachScript::Parser {
value <<= 3;
value += v;
}
return Create<IntegerLiteral>(TextSpan(start, _position), value);
return Create<IntegerLiteral>(TextSpan(start - 1, _position), value);
}
IntegerLiteral* Lexer::LexBinary() {
auto start = _position;
@ -431,7 +426,7 @@ namespace MalachScript::Parser {
value <<= 1;
value += v;
}
return Create<IntegerLiteral>(TextSpan(start, _position), value);
return Create<IntegerLiteral>(TextSpan(start - 1, _position), value);
}
StringLiteral* Lexer::LexString(char8_t opening, bool heredoc) {
auto openingPos = _position;