lvar cmd lvar args lvar param $def # args @ swap -- [] $def tostr 1 array_make array_interpret $def mpize dup not if pop "" else tostr then $def }dbg }cat prog "?" flag? if prog owner swap ansi_notify else pop then $libdef num? : num?[ x:input -- i:number? ] input @ float? input @ int? or if 1 exit then input @ number? if 1 exit then input @ "{0.0|0.|.0}" smatch if 1 exit then input @ "." instring if input @ strtof if 1 exit then then 0 ; PUBLIC num? $libdef fromstr : fromstr[ s:input -- x:output ] input @ string? not if "FROMSTR: expected string" abort then input @ "#*" smatch if input @ "" "#" subst dup num? if atoi dbref exit else pop then then input @ num? if input @ "." instr if input @ strtof exit else input @ atoi exit then then input @ ; PUBLIC fromstr : resolve[ s:target -- d:newtarget ] target @ case "me" smatch when me @ end "here" smatch when me @ location end "this" smatch when trig end default pop target @ match end endcase ; ( ^^^ MPI support functions ^^^ ) ( vvv MPI expansion functions vvv ) : m.prop { "@" 2 # not if me @ 1 # envprop swap pop else 2 # resolve 1 # envprop swap pop then mpize }cat ; SAFECALL m.prop : m.prop! { "@" 2 # not if me @ 1 # getprop else 2 # resolve 1 # getprop then mpize }cat ; SAFECALL m.prop! : m.exec { "@" 2 # not if me @ 1 # envprop mpize swap pop me @ swap "MPI" 0 parsempi else 2 # resolve 1 # envprop mpize swap pop me @ swap "MPI" 0 parsempi then mpize }cat ; SAFECALL m.exec : m.exec! { "@" 2 # not if me @ 1 # getprop mpize me @ swap "MPI" 0 parsempi else 2 # resolve 1 # getprop mpize me @ swap "MPI" 0 parsempi then mpize }cat ; SAFECALL m.exec! : m.store { "@" 3 # not if me @ 2 # 1 # setprop else 3 # resolve 2 # 1 # setprop then 1 # mpize }cat ; SAFECALL m.store : m.store! { "@" 3 # not if me @ 2 # 1 # fromstr setprop else 3 # resolve 2 # 1 # fromstr setprop then 1 # mpize }cat ; SAFECALL m.store! : m.raise { "!" 1 # }cat ; SAFECALL m.raise : m.add { "@" { args @ foreach swap pop strtof repeat }array array_sum }cat ; SAFECALL m.add : m.+ { "&{add:" args @ "," array_join "}" }cat ; SAFECALL m.+ ( ^^^ MPI expansion functions ^^^ ) ( vvv MPI handler functions vvv ) : mpi.parseargs[ s:x -- s:cmd a:args ] var cur 0 var! lit 0 var! blvl 0 array_make var! args "" var! cmd x @ ":" instr not if x @ 0 array_make exit then x @ ":" split var! x ( leave cmd on the stack ) { { 1 x @ strlen 1 for x @ swap 1 midstr cur ! cur @ not if break then lit @ if cur @ 0 lit ! continue then cur @ "\\" instr if 1 lit ! continue then cur @ "{" instr if blvl ++ cur @ continue then cur @ "}" instr if blvl -- cur @ continue then blvl @ not if cur @ "," instr if }cat { continue then then cur @ repeat }cat }array ; : mpi.recurse ( Now check all the arguments for more MPI and reenter the handler if so ) { swap foreach var! cur ++ var! argn cur @ 1 strcut pop "{" instr if cur @ cur @ strlen -- strcut swap pop "}" smatch if me @ cur @ "MUF-MPI-Handler" 0 parsempi else { "!End brace not found (arg " argn @ ")" }cat exit then else cur @ then repeat }array ; : althandler { "@" param @ 1 strcut swap pop }cat 1 parse_ansi ; : main debug_line param ! param @ "@" instr 1 = if althandler exit then ( Clip the main brackets off ) param @ 1 strcut swap pop dup strlen -- strcut pop param ! ( An early check to see if this MPI statement will even be executable.. ) prog "m." param @ ":" split pop strcat cancall? not if "" exit then ( Seperate the cmd and the args ) param @ mpi.parseargs args ! cmd ! { "Command: " cmd @ ", arguments " args @ "|" array_join }dbg args @ mpi.recurse args ! prog "m." cmd @ strcat call ;