This commit is contained in:
Ryan 2017-08-24 13:36:25 -04:00
parent 505879f80e
commit ca279d07dc
2 changed files with 16 additions and 8 deletions

View File

@ -34,15 +34,15 @@ ENABLE leaking
-- "Done!" -- "Done!"
--JUMP("CallMe") --JUMP("CallMe")
env=CreateENV() env=CreateENV()
food="Hi" msg="Hi"
SetENV(env) SetENV(env)
food="Hello" msg="Hello"
"IN_HERE $food$" "IN_HERE $msg$"
env=GetDefualtENV() env=GetDefualtENV()
SetENV(env) SetENV(env)
"OUT_HERE $food$" "OUT_HERE $msg$"
test=CallMe("This","is a test!") test=CallMe("This","is a test!")
"$test$" "FENV: $test$"
"Did it work!" "Did it work!"
QUIT() QUIT()
} }

View File

@ -77,7 +77,7 @@ namespace parseManager
void debug(object msg) void debug(object msg)
{ {
if (_flags["debugging"]) if (_flags["debugging"])
Console.WriteLine(msg); Console.WriteLine("DEBUGGING: "+msg);
} }
void _Parse(string data) void _Parse(string data)
{ {
@ -175,7 +175,6 @@ namespace parseManager
PushError("Stack Overflow!"); PushError("Stack Overflow!");
} }
_defualtENV = fEnv; _defualtENV = fEnv;
Console.WriteLine(fEnv);
def.JUMP(method); def.JUMP(method);
return fEnv; // TODO Handle returns return fEnv; // TODO Handle returns
} }
@ -341,6 +340,7 @@ namespace parseManager
} }
tempReturn.SetCMDType("conditional"); tempReturn.SetCMDType("conditional");
tempReturn.SetText("test turned out to be: " + truth); tempReturn.SetText("test turned out to be: " + truth);
return tempReturn;
} else if (type == "LABEL") { } else if (type == "LABEL") {
cCMD = _currentChunk.GetCLine(); cCMD = _currentChunk.GetCLine();
if (cCMD == null) { if (cCMD == null) {
@ -354,6 +354,7 @@ namespace parseManager
} }
type = cCMD.GetCMDType(); type = cCMD.GetCMDType();
stuff = cCMD.GetArgs(); stuff = cCMD.GetArgs();
return tempReturn;
} }
if (type == "FUNC") { if (type == "FUNC") {
var func = (string)stuff[0]; var func = (string)stuff[0];
@ -365,10 +366,12 @@ namespace parseManager
} }
tempReturn.SetCMDType("method"); tempReturn.SetCMDType("method");
tempReturn.SetText("INVOKED METHOD: " + func); tempReturn.SetText("INVOKED METHOD: " + func);
return tempReturn;
} else if (type == "LINE") { } else if (type == "LINE") {
tempReturn.SetCMDType("line"); tempReturn.SetCMDType("line");
var test = parseHeader((string)stuff[0]); var test = parseHeader((string)stuff[0]);
tempReturn.SetText(test.Substring(1, test.Length - 2)); tempReturn.SetText(test.Substring(1, test.Length - 2));
return tempReturn;
} else if (type == "FUNC_R") { } else if (type == "FUNC_R") {
var retargs = (string[])stuff[0]; var retargs = (string[])stuff[0];
var func = (string)stuff[1]; var func = (string)stuff[1];
@ -384,6 +387,7 @@ namespace parseManager
GLOBALS.Add_Var(retargs[0]); GLOBALS.Add_Var(retargs[0]);
tempReturn.SetCMDType("method"); tempReturn.SetCMDType("method");
tempReturn.SetText("INVOKED METHOD: " + func); tempReturn.SetText("INVOKED METHOD: " + func);
return tempReturn;
} else if (type == "ASSIGN") { // TODO add lists/dictonaries support } else if (type == "ASSIGN") { // TODO add lists/dictonaries support
var vars = (string[])stuff[0]; var vars = (string[])stuff[0];
var vals = (string[])stuff[1]; var vals = (string[])stuff[1];
@ -392,8 +396,8 @@ namespace parseManager
AssignmentHandler(vars, types); AssignmentHandler(vars, types);
tempReturn.SetCMDType("assignment"); tempReturn.SetCMDType("assignment");
tempReturn.SetText(_currentChunk.GetLine()); tempReturn.SetText(_currentChunk.GetLine());
return tempReturn;
} }
return tempReturn;
} }
public void AssignmentHandler(string[] vars, object[] types) public void AssignmentHandler(string[] vars, object[] types)
{ {
@ -505,6 +509,10 @@ namespace parseManager
public bool isVar(string val, out object v) public bool isVar(string val, out object v)
{ {
object va; object va;
debug("TESTING: "+val);
if(_defualtENV==null){
_defualtENV=_mainENV;
}
if (_defualtENV.TryGetValue(val, out va)) { if (_defualtENV.TryGetValue(val, out va)) {
v = va; v = va;
return true; return true;