Changed how parseCompountToPureValue() is called

This commit is contained in:
2022-09-11 05:51:25 +01:00
parent cbc937884e
commit 5b420e0799

View File

@@ -56,24 +56,10 @@ bool injectNativeFn(Interpreter* interpreter, char* name, NativeFn func) {
return true;
}
bool parseIdentifierToValue(Interpreter* interpreter, Literal* literalPtr) {
//this converts identifiers to values
if (IS_IDENTIFIER(*literalPtr)) {
// Literal idn = *literalPtr;
if (!getScopeVariable(interpreter->scope, *literalPtr, literalPtr)) {
interpreter->errorOutput("Undeclared variable ");;
printLiteralCustom(*literalPtr, interpreter->errorOutput);
interpreter->errorOutput("\n");
return false;
}
// freeLiteral(idn);
}
return true;
}
void parseCompoundToPureValues(Interpreter* interpreter, Literal* literalPtr) {
if (IS_IDENTIFIER(*literalPtr)) {
parseIdentifierToValue(interpreter, literalPtr);
}
//parse out an array
if (IS_ARRAY(*literalPtr)) {
@@ -129,6 +115,24 @@ void parseCompoundToPureValues(Interpreter* interpreter, Literal* literalPtr) {
}
}
bool parseIdentifierToValue(Interpreter* interpreter, Literal* literalPtr) {
//this converts identifiers to values
if (IS_IDENTIFIER(*literalPtr)) {
if (!getScopeVariable(interpreter->scope, *literalPtr, literalPtr)) {
interpreter->errorOutput("Undeclared variable ");
printLiteralCustom(*literalPtr, interpreter->errorOutput);
interpreter->errorOutput("\n");
return false;
}
}
if (IS_ARRAY(*literalPtr) || IS_DICTIONARY(*literalPtr)) {
parseCompoundToPureValues(interpreter, literalPtr);
}
return true;
}
//utilities for the host program
void setInterpreterPrint(Interpreter* interpreter, PrintFn printOutput) {
interpreter->printOutput = printOutput;