From d964b6139f127c6720e927d0e6f467293d6d9eba Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Thu, 24 Apr 2014 22:37:20 +0200 Subject: Some updates --- io.trt | 11 ----------- pshpll.trt | 38 -------------------------------------- test.trt | 3 +++ treetree.js | 31 +++++++++++++++++++++++++++---- 4 files changed, 30 insertions(+), 53 deletions(-) delete mode 100644 io.trt delete mode 100644 pshpll.trt create mode 100644 test.trt diff --git a/io.trt b/io.trt deleted file mode 100644 index 1986ff3..0000000 --- a/io.trt +++ /dev/null @@ -1,11 +0,0 @@ -inp out -"io.trt" ifi -inp out " -" out -"io.out.txt" ofi -inp out " -" out -ius -inp out -ous -inp out \ No newline at end of file diff --git a/pshpll.trt b/pshpll.trt deleted file mode 100644 index 5418c15..0000000 --- a/pshpll.trt +++ /dev/null @@ -1,38 +0,0 @@ -2 pll - -{ -[3, - [2, - [1,false,false], - ["a", - false, - ["b",false,false]]], - ["b", - ["xx",false,false], - false]] - - -3--"b" -| | -| "xx" -| -2--"a"--"b" -| -| -| -1 - -----------> -1 -| -| -| -3--"b" -| | -| "xx" -| -2--"a"--"b" - - -[1,[3,[2,false,["a",false,["b",false,false]]],["b",["xx",false,false],false]],false] -} \ No newline at end of file diff --git a/test.trt b/test.trt new file mode 100644 index 0000000..e2a3afa --- /dev/null +++ b/test.trt @@ -0,0 +1,3 @@ +1 2 stk +swp stk +dup stk \ No newline at end of file diff --git a/treetree.js b/treetree.js index 1c0e0ff..f32bfdd 100755 --- a/treetree.js +++ b/treetree.js @@ -233,9 +233,32 @@ function runCmds(cmds,TR){ TR[1]=objcpy(TR[2]); TR[2]=temp; break; - case "POP":break; - case "DUP":break; - case "GRB":break; + case "POP": + if(TR==false)throw new TTerror("Cannot POP a non-existant root node!"); + TR=TR[1]; + break; + case "DUP": + var newroot; + newroot=[TR[0],TR,objcpy(TR[2])]; + TR=newroot; + break; + case "GRB": //TODO CHECK WHETHER THIS SHIT WORKS + var inserted_tree,end_tree,rest_tree,i,n; + if(TR==false)throw new TTerror("Cannot GRB from a non-existant root node!"); + n=TR[0]; + if(typeof n!="number")throw new TTerror("Integer expected (in GRB), got '"+n.toString()+"'!") + TR=TR[1]; + if(n==0)break; + inserted_tree=objcpy(TR[1]); + if(inserted_tree==false)throw new TTerror("No primary child of root node to GRB!"); + end_tree=inserted_tree; + for(i=0;i