More complex type parsing

This commit is contained in:
Rafał Grodziński
2025-07-08 17:31:56 +09:00
parent 18dd7d05d4
commit 9e7747dcbc
10 changed files with 128 additions and 62 deletions

View File

@@ -11,20 +11,20 @@ Expression(ExpressionKind::LITERAL, nullptr) {
switch (token->getKind()) {
case TokenKind::BOOL:
boolValue = token->getLexme().compare("true") == 0;
valueType = ValueType::valueTypeForToken(token);
valueType = ValueType::valueTypeForToken(token, nullptr, 0);
break;
case TokenKind::INTEGER_DEC: {
string numString = token->getLexme();
erase(numString, '_');
sint32Value = stoi(numString, nullptr, 10);
valueType = ValueType::valueTypeForToken(token);
valueType = ValueType::valueTypeForToken(token, nullptr, 0);
break;
}
case TokenKind::INTEGER_HEX: {
string numString = token->getLexme();
erase(numString, '_');
sint32Value = stoi(numString, nullptr, 16);
valueType = ValueType::valueTypeForToken(token);
valueType = ValueType::valueTypeForToken(token, nullptr, 0);
break;
}
case TokenKind::INTEGER_BIN: {
@@ -32,13 +32,13 @@ Expression(ExpressionKind::LITERAL, nullptr) {
erase(numString, '_');
numString = numString.substr(2, numString.size()-1);
sint32Value = stoi(numString, nullptr, 2);
valueType = ValueType::valueTypeForToken(token);
valueType = ValueType::valueTypeForToken(token, nullptr, 0);
break;
}
case TokenKind::INTEGER_CHAR: {
string charString = token->getLexme();
valueType = ValueType::valueTypeForToken(token);
valueType = ValueType::valueTypeForToken(token, nullptr, 0);
if (charString.length() == 3) {
sint32Value = charString[1];
} else if (charString.length() == 4 && charString[1] == '\\') {
@@ -67,7 +67,7 @@ Expression(ExpressionKind::LITERAL, nullptr) {
}
case TokenKind::REAL:
real32Value = stof(token->getLexme());
valueType = ValueType::valueTypeForToken(token);
valueType = ValueType::valueTypeForToken(token, nullptr, 0);
break;
default:
exit(1);