|
@@ -1,12 +1,16 @@
|
|
|
-// import as re.*
|
|
|
-\d re
|
|
|
-\l ngnk-libs/regex/re.k
|
|
|
+\d u
|
|
|
+\l utils.k
|
|
|
+
|
|
|
+\d pat
|
|
|
+\l excelpm.k
|
|
|
+
|
|
|
+\l ngnk-libs/csv/csv.k
|
|
|
|
|
|
\d .
|
|
|
|
|
|
/helpers
|
|
|
/ e exclusive
|
|
|
-slice: {[l;s;e] s_(e-1)#l};
|
|
|
+slice: {[l;s;e] s_(e)#l};
|
|
|
listize: {1_(,/(";",)'{"(",x,")"}'x)};
|
|
|
split: {[l;di] idx: (-1,&(di~'l)),(#l); {slice[x;y[0]+1;y[1]+1]}[l]'(idx@(2':!#idx))};
|
|
|
s2n: {[s] `i$s;}; // string to number
|
|
@@ -20,28 +24,13 @@ cstkey: "Events"; / key indicating start of events condition section
|
|
|
astkey: "Actions"; / key indicating start of actions section
|
|
|
sectionkeys: (tstkey;cstkey;astkey);
|
|
|
|
|
|
-lines: 0: "SS.csv";
|
|
|
-
|
|
|
-/csv parser
|
|
|
-parsel: {[l] comi: &l=",";comi+:1;r: 2':!#comi;r: comi@r;r: (1 2#(0;r[0;0])),r;slice[l].'r};
|
|
|
-csv: parsel'lines;
|
|
|
-
|
|
|
-kw:: "self";
|
|
|
-rep:: "t";
|
|
|
-
|
|
|
-deps:: (#csv;#csv[0])#0;
|
|
|
+lines: {x,"\n",y}/(0: "SS.csv");
|
|
|
+table: csv.csv[lines];
|
|
|
|
|
|
-fnr:{[l;k;rp] e:(#l)-(#k); r:!e; idx: &({y~x}[;k]'({slice[y;x;x+(#z)+1]}[;l;k]'r)); l{[last;x;y;z;r]left:x#last; right:(x+(#z))_last; (left,r,right;right)}[;;l;k;rp]/(|idx)};
|
|
|
-rd: {[r] deps[0;0]::1; r[0]}; // register dep
|
|
|
-dd: {[r] $[r[1;0]~"[";rd[r];r[0]]}; // detect dep
|
|
|
-/ :{[l;kw;rep] r: fnr[l;kw;rep]; $[(@r)=`C;r;dd[r]]}[;kw;rep]''csv;
|
|
|
-/ :deps;
|
|
|
+/ excel patterns
|
|
|
+pats: *''|''(pat.run''table);
|
|
|
|
|
|
-/ initialize data
|
|
|
-/ f:<`"compiled_ss.k";
|
|
|
-/ f 0: kcode;
|
|
|
-para:`0:
|
|
|
-testcases:{para"search ",z;`0:$x z;para"match ",z;`0:$y z}
|
|
|
-test:{para"---";para"regex: ", x;testcases[re.match[re.scmp@x];re.match[re.cmp@x]]'y;};
|
|
|
-cases:("abc";"xxxabbc";"abbbcyyy";"xxxabbbbcyyy");
|
|
|
-test["ab+c";cases]
|
|
|
+:pats {
|
|
|
+ u.ppr (x;y);
|
|
|
+ u.ppr $[x[0]>4;slice[y;x[1];x[2]];'$'];
|
|
|
+}''table;
|