Large chunk of work in parser for getting expressions to work.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-11-08 15:41:18 +01:00
parent c20a1089a9
commit 5fb64e12e1
12 changed files with 344 additions and 41 deletions

View File

@@ -338,16 +338,16 @@ namespace MalachScript::Parser {
return pow10[n];
}
LexToken* Lexer::LexDecimal(uint64_t initial) {
LexToken* Lexer::LexDecimal(ParseInt initial) {
auto start = _position;
uint64_t value = initial;
uint64_t decimalValue = 0;
uint64_t exponentValue = 0;
ParseInt value = initial;
ParseInt decimalValue = 0;
ParseInt exponentValue = 0;
uint8_t decimalLength = 0;
bool isDecimal = false;
bool isExponent = false;
while (true) {
auto v = (uint64_t)LexDecimalValue(Peek());
auto v = (ParseInt)LexDecimalValue(Peek());
if (v == 255) {
if (!isDecimal && Peek() == u8'.') {
isDecimal = true;
@@ -376,7 +376,7 @@ namespace MalachScript::Parser {
}
}
if (isDecimal || isExponent) {
auto val = value + ((double)decimalValue / quick_pow10(decimalLength));
auto val = value + ((ParseFloat)decimalValue / quick_pow10(decimalLength));
if (isExponent) {
val *= pow(10, exponentValue);
}
@@ -387,7 +387,7 @@ namespace MalachScript::Parser {
IntegerLiteral* Lexer::LexHexadecimal() {
auto start = _position;
uint64_t value = 0;
ParseInt value = 0;
while (true) {
auto v = LexHexadecimalValue(Peek());
if (v == 255) {
@@ -401,7 +401,7 @@ namespace MalachScript::Parser {
}
IntegerLiteral* Lexer::LexOctal() {
auto start = _position;
uint64_t value = 0;
ParseInt value = 0;
while (true) {
auto v = LexOctalValue(Peek());
if (v == 255) {
@@ -415,7 +415,7 @@ namespace MalachScript::Parser {
}
IntegerLiteral* Lexer::LexBinary() {
auto start = _position;
uint64_t value = 0;
ParseInt value = 0;
while (true) {
auto v = LexBinaryValue(Peek());
if (v == 255) {
@@ -457,7 +457,7 @@ namespace MalachScript::Parser {
if (heredoc) {
Progress(2);
}
return Create<StringLiteral>(TextSpan(start, start + _position), std::u8string(_script.substr(start, offset)));
return Create<StringLiteral>(TextSpan(start, start + _position), ParseString(_script.substr(start, offset)));
}
LexToken* Lexer::LexKeywordOrIdentifier() {