args
variable allows access to command line args
This commit is contained in:
@@ -78,25 +78,17 @@ void Interpreter::interpret(vector<Token> tokenList) {
|
||||
|
||||
if (varIt != variables.end()) {
|
||||
// This is pretty crappy code but it exists for now. Lists are gonna break this so much it's not even gonna be funny
|
||||
if (varIt->second.type == valtype::LIST) {
|
||||
if (peek()->keyword == keywords::OSQUA) {
|
||||
if (peek(2)->keyword == keywords::VALUE && peek(2)->type == valtype::INT && peek(2)->type == valtype::INT && peek(3)->keyword == keywords::CSQUA) {
|
||||
Token newToken;
|
||||
Value tokenVal = get<List>(varIt->second.value).value[get<int>(peek(2)->value.value)];
|
||||
newToken.keyword = keywords::VALUE;
|
||||
newToken.type = tokenVal.type;
|
||||
newToken.value.value = tokenVal.value;
|
||||
// Do this later
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//if (varIt->second.type == valtype::LIST) {
|
||||
|
||||
//} else {
|
||||
// Replace the token with the variable's value
|
||||
Token newToken;
|
||||
newToken.keyword = keywords::VALUE;
|
||||
if (varIt->second.type == valtype::LIST) newToken.keyword = keywords::LISTOBJ;
|
||||
newToken.type = varIt->second.type;
|
||||
newToken.value = varIt->second;
|
||||
currentInstruction[i] = newToken;
|
||||
}
|
||||
//}
|
||||
}
|
||||
} else if (currentInstruction[i].keyword == keywords::INPUT) {
|
||||
Token newToken;
|
||||
@@ -273,7 +265,7 @@ void Interpreter::interpret(vector<Token> tokenList) {
|
||||
newToken.type = valtype::LIST;
|
||||
newToken.value.type = valtype::LIST;
|
||||
newToken.value.value = buf;
|
||||
newToken.keyword = keywords::LIST;
|
||||
newToken.keyword = keywords::LISTOBJ;
|
||||
currentInstruction.insert(currentInstruction.begin() + startIndex, newToken);
|
||||
}
|
||||
}
|
||||
@@ -368,7 +360,7 @@ void Interpreter::executeCode(vector<Token> tokens) {
|
||||
if (tokens.size() <= i) syntaxError.fnNotSufficientArgs("printlist", 1, 1, 0);
|
||||
Token nextToken = tokens[i];
|
||||
log.debug("Printing a list. Type of next token is " + log.getTypeString(nextToken.value.type));
|
||||
if (nextToken.keyword == keywords::LIST && nextToken.type == valtype::LIST) {
|
||||
if (nextToken.keyword == keywords::LISTOBJ && nextToken.type == valtype::LIST) {
|
||||
List list = get<List>(nextToken.value.value);
|
||||
log.debug("List obtained");
|
||||
if (list.value[0].type == valtype::INT) {
|
||||
|
@@ -39,7 +39,7 @@ enum class keywords {
|
||||
EQUAL, INEQUAL, LESS, GREATER, EQLESS, EQGREATER,
|
||||
INCREMENT, DECREMENT,
|
||||
PRINT, PRINTLN, PRINTLIST, LET, INPUT, EXIT,
|
||||
VALUE, LIST, SEMICOLON, VARIABLE,
|
||||
VALUE, LISTOBJ, SEMICOLON, VARIABLE,
|
||||
COMMENT
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user