From fb35acbf451f6214f9e21b3d2dab20319c306ca2 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 20 Aug 2017 00:04:08 -0400 Subject: [PATCH] More stuff Added function returns Added assignments(Simple) TODO: Assignments and lists Assignments and Dicts --- parseManager/bin/Debug/parsetest2.txt | 14 ++--- parseManager/parseManager.cs | 81 ++++++++++++++++----------- 2 files changed, 54 insertions(+), 41 deletions(-) diff --git a/parseManager/bin/Debug/parsetest2.txt b/parseManager/bin/Debug/parsetest2.txt index bee1917..5838c26 100644 --- a/parseManager/bin/Debug/parsetest2.txt +++ b/parseManager/bin/Debug/parsetest2.txt @@ -1,11 +1,9 @@ ENTRY START -ENABLE debugging [START]{ - "Hello!" - "NO!" - TEST() - TEST2("food is $test$") - TEST3(12345,test) - num=TEST4(15) - TEST2(num) + "Test 1:" + num=ADD(5,5) + "num = $num$" + c=5 + a,b="sdf",true + "a,b,c = $a$ $b$ $c$" } \ No newline at end of file diff --git a/parseManager/parseManager.cs b/parseManager/parseManager.cs index c82288c..bc8345c 100644 --- a/parseManager/parseManager.cs +++ b/parseManager/parseManager.cs @@ -179,13 +179,11 @@ namespace parseManager public nextType Next() { GLOBALS.SetPM(this); - nextType tempReturn = new nextType(); + var tempReturn = new nextType(); if (_currentChunk == null) { SetBlock(); } - // TODO Add commands lol - //Console.WriteLine(_currentChunk.GetPos()); - CMD cCMD = _currentChunk.GetCLine(); + var cCMD = _currentChunk.GetCLine(); object[] stuff; if (cCMD == null) { if (_flags["leaking"]) { @@ -196,13 +194,11 @@ namespace parseManager tempReturn.SetText("Reached the end of the file!"); return tempReturn; } - string type = cCMD.GetCMDType(); + var type = cCMD.GetCMDType(); stuff = cCMD.GetArgs(); - //Console.WriteLine(type); if (type == "FUNC") { - string func = (string)stuff[0]; - string[] args = (string[])stuff[1]; - //debug(args.Length); + var func = (string)stuff[0]; + var args = (string[])stuff[1]; if (args.Length == 1 && args[0] == "") { // assume no args inserted! InvokeNR(func, new object[]{ }); } else { @@ -211,9 +207,29 @@ namespace parseManager tempReturn.SetCMDType("method"); tempReturn.SetText("INVOKED METHOD: " + func); } else if (type == "LINE") { - //Console.WriteLine(stuff[0]); tempReturn.SetCMDType("line"); tempReturn.SetText(parseHeader((string)stuff[0])); + } else if (type == "FUNC_R") { + var retargs = (string[])stuff[0]; + var func = (string)stuff[1]; + var args = (string[])stuff[2]; + object data; + if (args.Length == 1 && args[0] == "") { // assume no args inserted! + data = InvokeR(func, new object[]{ }); + } else { + data = InvokeR(func, ResolveVar(args)); + } + // For Now handle 1 var name to 1 value + var env = GetENV(); + env[retargs[0]] = data; + } else if(type=="ASSIGN"){ + var vars=(string[])stuff[0]; + var vals=(string[])stuff[1]; + var env = GetENV(); + var types=ResolveVar(vals); + for(int i=0;i