123456789101112131415161718192021222324252627282930313233343536 |
- /helpers
- / e exclusive
- slice: {[l;s;e] s_(e-1)#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
- parseidx: {core: slice[x;1;#x]; split[core;";"]};
- :parseidx["[1;2]"];
- /:split["1;2;3";";"];
- tstkey: "States/Events"; / key indicating start of transition section
- 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;
- 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;
- / initialize data
- / f:<`"compiled_ss.k";
- / f 0: kcode;
|