Stable ish 👍

This commit is contained in:
Ryan 2017-08-24 17:29:32 -04:00
parent ca279d07dc
commit 433ec4eb81
2 changed files with 47 additions and 31 deletions

View File

@ -1,4 +1,3 @@
ENABLE leaking
[TEST]{ [TEST]{
"Jump was successful!" "Jump was successful!"
--GOTO("HERE") --GOTO("HERE")
@ -36,7 +35,8 @@ ENABLE leaking
env=CreateENV() env=CreateENV()
msg="Hi" msg="Hi"
SetENV(env) SetENV(env)
msg="Hello" "BEFORE_CHANGE: $msg$"
msg=21+7
"IN_HERE $msg$" "IN_HERE $msg$"
env=GetDefualtENV() env=GetDefualtENV()
SetENV(env) SetENV(env)
@ -44,7 +44,10 @@ ENABLE leaking
test=CallMe("This","is a test!") test=CallMe("This","is a test!")
"FENV: $test$" "FENV: $test$"
"Did it work!" "Did it work!"
QUIT() "HMMM"
test=CallMe("This","is a test too!")
"FENV: $test$"
EXIT()
} }
[CallMe:function(args1,args2)]{ [CallMe:function(args1,args2)]{
"function was called!" "function was called!"

View File

@ -113,6 +113,7 @@ namespace parseManager
try { try {
StreamReader sr = File.OpenText(_filepath); StreamReader sr = File.OpenText(_filepath);
_Parse(sr.ReadToEnd()); _Parse(sr.ReadToEnd());
sr.Close();
} catch (FileNotFoundException) { } catch (FileNotFoundException) {
Console.WriteLine("File '" + _filepath + "' does not exist! Loading failled!"); Console.WriteLine("File '" + _filepath + "' does not exist! Loading failled!");
} }
@ -122,6 +123,7 @@ namespace parseManager
try { try {
StreamReader sr = File.OpenText(filename); StreamReader sr = File.OpenText(filename);
_Parse(sr.ReadToEnd()); _Parse(sr.ReadToEnd());
sr.Close();
} catch (FileNotFoundException) { } catch (FileNotFoundException) {
Console.WriteLine("Load '" + filename + "' File not found. Loading failled!"); Console.WriteLine("Load '" + filename + "' File not found. Loading failled!");
} }
@ -317,8 +319,10 @@ namespace parseManager
} }
var truth = truths[0]; var truth = truths[0];
if (truths.Length == 1 && truth) { if (truths.Length == 1 && truth) {
//Console.WriteLine(funcif+"|"+ResolveVar(argsif)[0]);
InvokeNR(funcif, ResolveVar(argsif)); InvokeNR(funcif, ResolveVar(argsif));
} else if (truths.Length == 1) { } else if (truths.Length == 1) {
//Console.WriteLine(funcelse + "|"+ResolveVar(argselse)[0]);
InvokeNR(funcelse, ResolveVar(argselse)); InvokeNR(funcelse, ResolveVar(argselse));
} else { } else {
for (int i = 1; i < andors.Length; i++) { for (int i = 1; i < andors.Length; i++) {
@ -331,10 +335,10 @@ namespace parseManager
} }
} }
if (truth) { if (truth) {
Console.WriteLine(funcif); //Console.WriteLine(funcif);
InvokeNR(funcif, ResolveVar(argsif)); InvokeNR(funcif, ResolveVar(argsif));
} else { } else {
Console.WriteLine("|" + funcelse + "|"); //Console.WriteLine("|" + funcelse + "|");
InvokeNR(funcelse, ResolveVar(argselse)); InvokeNR(funcelse, ResolveVar(argselse));
} }
} }
@ -398,6 +402,7 @@ namespace parseManager
tempReturn.SetText(_currentChunk.GetLine()); tempReturn.SetText(_currentChunk.GetLine());
return tempReturn; return tempReturn;
} }
return tempReturn;
} }
public void AssignmentHandler(string[] vars, object[] types) public void AssignmentHandler(string[] vars, object[] types)
{ {
@ -508,13 +513,13 @@ namespace parseManager
} }
public bool isVar(string val, out object v) public bool isVar(string val, out object v)
{ {
object va;
debug("TESTING: " + val); debug("TESTING: " + val);
if (_defualtENV == null) { if (_defualtENV == null) {
_defualtENV = _mainENV; _defualtENV = _mainENV;
} }
if (_defualtENV.TryGetValue(val, out va)) { debug("GETTING VAL FROM ENV: " + _defualtENV[val]);
v = va; if (_defualtENV[val] != null) {
v = _defualtENV[val];
return true; return true;
} }
if (val.EndsWith("]")) { if (val.EndsWith("]")) {
@ -566,15 +571,6 @@ namespace parseManager
{ {
_BLOCK = name; _BLOCK = name;
_type = type; _type = type;
if (type.Contains("function")) {
isFunc = true;
var func = Regex.Match(type, @"\((.+)\)");
args = GLOBALS.Split(func.Groups[1].Value);
_compiledlines.Add(new CMD("FUNC", new object[] {
"TRACEBACK",
new string[]{ }
})); // Append the traceback method to the chunk
}
_clean(cont); _clean(cont);
} }
public bool isFunction() public bool isFunction()
@ -667,9 +663,9 @@ namespace parseManager
} else if (FuncWReturn.ToString() != "") { } else if (FuncWReturn.ToString() != "") {
var var1 = (FuncWReturn.Groups[1]).ToString(); var var1 = (FuncWReturn.Groups[1]).ToString();
var func = (FuncWReturn.Groups[2]).ToString(); var func = (FuncWReturn.Groups[2]).ToString();
var args = (FuncWReturn.Groups[3]).ToString(); var args2 = (FuncWReturn.Groups[3]).ToString();
var retargs = var1.Split(','); var retargs = var1.Split(',');
var result = Regex.Split(args, ",(?=(?:[^\"'\\[\\]]*[\"'\\[\\]][^\"'\\[\\]]*[\"'\\[\\]])*[^\"'\\[\\]]*$)"); var result = Regex.Split(args2, ",(?=(?:[^\"'\\[\\]]*[\"'\\[\\]][^\"'\\[\\]]*[\"'\\[\\]])*[^\"'\\[\\]]*$)");
_compiledlines.Add(new CMD("FUNC_R", new object[] { _compiledlines.Add(new CMD("FUNC_R", new object[] {
retargs, retargs,
func, func,
@ -677,8 +673,8 @@ namespace parseManager
})); }));
} else if (FuncWOReturn.ToString() != "") { } else if (FuncWOReturn.ToString() != "") {
var func = (FuncWOReturn.Groups[1]).ToString(); var func = (FuncWOReturn.Groups[1]).ToString();
var args = (FuncWOReturn.Groups[2]).ToString(); var args2 = (FuncWOReturn.Groups[2]).ToString();
var result = Regex.Split(args, ",(?=(?:[^\"'\\[\\]]*[\"'\\[\\]][^\"'\\[\\]]*[\"'\\[\\]])*[^\"'\\[\\]]*$)"); var result = Regex.Split(args2, ",(?=(?:[^\"'\\[\\]]*[\"'\\[\\]][^\"'\\[\\]]*[\"'\\[\\]])*[^\"'\\[\\]]*$)");
_compiledlines.Add(new CMD("FUNC", new object[]{ func, result })); _compiledlines.Add(new CMD("FUNC", new object[]{ func, result }));
} else if (pureLine.ToString() != "") { } else if (pureLine.ToString() != "") {
_compiledlines.Add(new CMD("LINE", new object[]{ pureLine.ToString() })); _compiledlines.Add(new CMD("LINE", new object[]{ pureLine.ToString() }));
@ -692,6 +688,15 @@ namespace parseManager
_compiledlines.Add(new CMD("UNKNOWN", new object[]{ })); _compiledlines.Add(new CMD("UNKNOWN", new object[]{ }));
} }
} }
if (_type.Contains("function")) {
isFunc = true;
var func = Regex.Match(_type, @"\((.+)\)");
args = GLOBALS.Split(func.Groups[1].Value);
_compiledlines.Add(new CMD("FUNC", new object[] {
"TRACEBACK",
new string[]{}
})); // Append the traceback method to the chunk
}
} }
public string GetName() public string GetName()
{ {
@ -849,6 +854,7 @@ namespace parseManager
} }
if (!loop) { if (!loop) {
object t; object t;
if (env != null)
if (env.TryGetValue(cmd, out t)) { if (env.TryGetValue(cmd, out t)) {
double te; double te;
if (t.GetType().ToString().Contains("Double")) if (t.GetType().ToString().Contains("Double"))
@ -878,7 +884,11 @@ namespace parseManager
{ {
string str = "("; string str = "(";
foreach (KeyValuePair<string, object> entry in _vars) { foreach (KeyValuePair<string, object> entry in _vars) {
str += "[\"" + entry.Key + "\"] = " + entry.Value + ", "; var val = entry.Value;
if (val.GetType().ToString().Contains("ENV")) {
val = "ENV";
}
str += "[\"" + entry.Key + "\"] = " + val + ", ";
} }
foreach (KeyValuePair<int, object> entry in _varsI) { foreach (KeyValuePair<int, object> entry in _varsI) {
str += "[" + entry.Key + "] = " + entry.Value + ", "; str += "[" + entry.Key + "] = " + entry.Value + ", ";
@ -1119,7 +1129,10 @@ public class standardDefine
} }
public ENV CreateENV() public ENV CreateENV()
{ {
return new ENV(); var temp = new ENV();
var PM = GLOBALS.GetPM();
temp.SetParent(PM.GetENV());
return temp;
} }
public int GOTO(string label) public int GOTO(string label)
{ {