This commit is contained in:
parent
ffc243d528
commit
8793c64f1c
|
@ -25,6 +25,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <iostream>
|
||||
#include "Parser.h"
|
||||
|
||||
void Parser::parse() {
|
||||
|
@ -61,6 +62,7 @@ void Parser::parse() {
|
|||
Declaration currentDeclaration;
|
||||
|
||||
while (true) {
|
||||
try{
|
||||
c = getByte();
|
||||
if (c == '\n' || c == '\0' || (!isComment && (c == ' ' || c == '\t' || c == ',' || c == ';'))) {
|
||||
//End token
|
||||
|
@ -97,7 +99,7 @@ void Parser::parse() {
|
|||
if (isRegisterLocation(currentValue)) {
|
||||
currentDeclaration.tokens.emplace_back(
|
||||
Token(t.first, currentValue.substr(1, std::string::npos),
|
||||
std::stoi(currentValue.substr(1, std::string::npos), nullptr, 0)));
|
||||
std::stoul(currentValue.substr(1, std::string::npos), nullptr, 0)));
|
||||
foundToken = true;
|
||||
}
|
||||
break;
|
||||
|
@ -112,14 +114,14 @@ void Parser::parse() {
|
|||
if (isCodeLocation(currentValue)) {
|
||||
currentDeclaration.tokens.emplace_back(
|
||||
Token(t.first, currentValue.substr(1, std::string::npos),
|
||||
std::stoi(currentValue.substr(1, std::string::npos), nullptr, 0)));
|
||||
std::stoul(currentValue.substr(1, std::string::npos), nullptr, 0)));
|
||||
foundToken = true;
|
||||
}
|
||||
break;
|
||||
case Token::Type::Immediate:
|
||||
if (isImmediate(currentValue)) {
|
||||
currentDeclaration.tokens.emplace_back(
|
||||
Token(t.first, currentValue, std::stoi(currentValue, nullptr, 0)));
|
||||
Token(t.first, currentValue, std::stoul(currentValue, nullptr, 0)));
|
||||
foundToken = true;
|
||||
}
|
||||
break;
|
||||
|
@ -218,6 +220,10 @@ void Parser::parse() {
|
|||
} else if (!isComment) {
|
||||
currentValue += c;
|
||||
}
|
||||
}catch (const std::exception& e){
|
||||
std::cerr << "Exception: " << e.what() << " on " << currentFunction.label << "\n";
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,8 +173,8 @@ namespace Instruction {
|
|||
segments.push_back(segment);
|
||||
}
|
||||
|
||||
uint8_t offset1 = segments.size() > 1 ? std::stoi(segments.at(1).substr(0, 1), nullptr, 10) : 0;
|
||||
uint8_t offset2 = (segments.size() > 1 && segments.at(1).size() > 1) ? std::stoi(
|
||||
uint8_t offset1 = segments.size() > 1 ? std::stoul(segments.at(1).substr(0, 1), nullptr, 10) : 0;
|
||||
uint8_t offset2 = (segments.size() > 1 && segments.at(1).size() > 1) ? std::stoul(
|
||||
segments.at(1).substr(1, 1), nullptr, 10) : 0;
|
||||
|
||||
return Instruction::parseOperatorResult{
|
||||
|
|
Loading…
Reference in a new issue