From 1589340f369c13dca159254e248a7a7fb305c55b Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 17 Aug 2017 17:36:30 -0400 Subject: [PATCH] changes --- parseManager/Program.cs | 6 +-- parseManager/bin/Debug/parsetest2.txt | 66 +++++++++++++++++++++++++++ parseManager/parseManager.cs | 50 ++++++++++---------- 3 files changed, 94 insertions(+), 28 deletions(-) create mode 100644 parseManager/bin/Debug/parsetest2.txt diff --git a/parseManager/Program.cs b/parseManager/Program.cs index 3d2fba2..f362db7 100644 --- a/parseManager/Program.cs +++ b/parseManager/Program.cs @@ -13,7 +13,7 @@ public class define { public void testM(string arg1) { - Console.WriteLine(arg1 + " it works!"); + Console.WriteLine(arg1); } public void testM2(string arg1) { @@ -27,8 +27,8 @@ namespace parseManager public static void Main(string[] args) { Console.WriteLine("Hello World!"); - parseManager test = new parseManager("path","define"); - test.invokeA("testM",new object[]{""}); + parseManager test = new parseManager("parsetest2.txt","define"); + test.invokeA("testM",new object[]{"This is invoked!"}); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); } diff --git a/parseManager/bin/Debug/parsetest2.txt b/parseManager/bin/Debug/parsetest2.txt new file mode 100644 index 0000000..04d0632 --- /dev/null +++ b/parseManager/bin/Debug/parsetest2.txt @@ -0,0 +1,66 @@ +ENTRY START +[START]{ + a=10>1 + b=10<1 + "test: $a$ $b$" + test["name"]="Ryan" + name=test["name"] + "Hi $test[name]$! $name$" + testfunc("hello",(5!),15@1) + test("hello",sqrt(5!),(15@1)/2) +} +[@:construct]{ -- get % out of 100 + ret=l/(r/100) + return(ret) +} +[>:construct]{ -- get % out of 100 + ret=rshift(l,r) + return(ret) +} +[<:construct]{ -- get % out of 100 + ret=lshift(l,r) + return(ret) +} +[~:construct]{ -- negate variable + if r~=NONE then GOTO(sub)|GOTO(neg) + ::sub:: + ret=l-r + return(ret) + GOTO(end) + ::neg:: + ret=0-r + return(ret) + ::end:: +} +[test:function(a,b,c)]{ + "$a$ $b$ $c$" +} +-- You dont have too many symbols left to use though. For now a symbol is only 1 char long so you are limited +[fact:function(n)]{ + count=1 + stop=n + ::loop:: -- for loop kinda, can become a stateloop as well + n=n*count + count=count+1 + if count==stop then GOTO(end)|GOTO(loop) + ::end:: + ret=n +} +[neg:function(n)]{ + ret=n*(0-1) +} +--Bind the fact function to the symbol '!' +[!:construct]{ + env=fact(l) + ret=env["ret"] + return(ret) +} +[NOVAR]{ + ::go:: + "I AM HERE!!!" + NOVAR="TEST" + JUMP(START) +} +[TEST]{ + "We are now here" +} \ No newline at end of file diff --git a/parseManager/parseManager.cs b/parseManager/parseManager.cs index c19a77b..3320364 100644 --- a/parseManager/parseManager.cs +++ b/parseManager/parseManager.cs @@ -18,57 +18,57 @@ namespace parseManager /// public class parseManager { - string filepath; - bool hasDefine; - string define; - string entry="START"; - Type defineType; - MethodInfo defineMethod; - object defineClassObject; - Dictionary chunks = new Dictionary(); + string _filepath; + bool _hasDefine; + string _define; + string _entry="START"; + Type _defineType; + MethodInfo _defineMethod; + object _defineClassObject; + Dictionary _chunks = new Dictionary(); private void parse(){ try { - StreamReader sr = File.OpenText (filepath); + StreamReader sr = File.OpenText (_filepath); string CDFDATA = sr.ReadToEnd (); string pattern = @"\[(.+)\][\r\n]*?\{([^\0]+?)\}"; var match = Regex.Matches( CDFDATA, pattern ); foreach (Match m in match) - chunks.Add (m.Groups [1].ToString (), m.Groups [2].ToString ()); + _chunks.Add (m.Groups [1].ToString (), m.Groups [2].ToString ()); } catch (FileNotFoundException ex) { - Console.WriteLine("File '"+filepath+"' does not exist!\n"+ex); + Console.WriteLine("File '"+_filepath+"' does not exist!\n"+ex); } } public parseManager(string filepath) { - this.filepath=filepath; - hasDefine=false; + _filepath=filepath; + _hasDefine=false; parse(); } public parseManager(string filepath,string define){ - this.define=define; - hasDefine=true; - this.filepath=filepath; - defineType = Type.GetType(define); - ConstructorInfo defineConstructor = defineType.GetConstructor(Type.EmptyTypes); - defineClassObject = defineConstructor.Invoke(new object[]{}); + _define=define; + _hasDefine=true; + _filepath=filepath; + _defineType = Type.GetType(define); + ConstructorInfo defineConstructor = _defineType.GetConstructor(Type.EmptyTypes); + _defineClassObject = defineConstructor.Invoke(new object[]{}); parse(); } public int invokeA(string method, object[] args){ // TODO collect the returned arguments if any - if (!hasDefine) + if (!_hasDefine) return -1; - defineMethod = defineType.GetMethod(method); - defineMethod.Invoke(defineClassObject, args); + _defineMethod = _defineType.GetMethod(method); + _defineMethod.Invoke(_defineClassObject, args); return 0; } public int invokeNA(string method, object[] args){ // Simple Invoking! - if (!hasDefine) + if (!_hasDefine) return -1; - defineMethod = defineType.GetMethod(method); - defineMethod.Invoke(defineClassObject, args); + _defineMethod = _defineType.GetMethod(method); + _defineMethod.Invoke(_defineClassObject, args); return 0; } public nextType next(){