/helpers / e exclusive slice: {[l;s;e] s_(e-1)#l}; listize: {1_(,/(";",)'{"(",x,")"}'x)}; 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: "tempST.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}; tempST: parsel'lines; tname: tempST[0;0]; / st compile / separate sections si: (*'&'{(y~)'x}[*'tempST]'sectionkeys),(#tempST-1); / sections line numbers slices: si@(2':!#si); (t;c;a):1_'slice[tempST;] .'slices; / postprocess sections s:*'t; t:2_'t; a:*'a; c:*'c; / TODO: make dynamic args: `isOff `T ! `i `i; fname: tname,".k"; kcode: "/ ",fname,".csv compiled\n\n"; tstr: ""; /a TODO: make dynamic avars: ("A",'$((!#a)+1)) a:,[;"\"};\n"]'((,[;":{\""]'avars),'a); a: ,/a; avars: 1_,/(";",'avars); /c vars: {x,":args["}'$'!args; cargs:,[;"];"]'(vars,'($!#vars)); cargs: ,/cargs; c:"{[args]",cargs,"(",listize[c],")}"; /s s:,[;"\""]'("\"",'s); s:listize[s]; /at at: ,/("`",'$:args@!args); / t t:listize[listize't]; kcode ,: a; kcode ,: ("a:(",avars,");\n"); kcode ,: ("c:",c,";\n"); kcode ,: ("s:(",s,");\n"); kcode ,: ("t:(",t,");\n"); kcode ,: ("at:",at,";\n"); / initialize data f:<`"tempST.k"; f 0: kcode; / -======== notes ========- / / how the parser works / t: lines[0]; / comi: &t=","; / commas idx / comi+:1; / help exlude commas (later use -1 on upper) / / r: 2':!#comi; / ranges of comma separated parts / r: comi@r; / apply ranges to comma idx / r: (1 2#(0;r[0;0])),r; / add 0-first comma range / slice[t].'r