mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Changed how parseCompountToPureValue() is called
This commit is contained in:
@@ -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) {
|
||||
parseIdentifierToValue(interpreter, 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;
|
||||
|
||||
Reference in New Issue
Block a user