From 96922c593fa549805679604cb405574898870a33 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 7 Oct 2014 23:05:44 +0000 Subject: [PATCH] proper n-ary piping --- main/app/grep/core.hook | 16 +++--- main/app/shell/core.hook | 107 +++++++++++++++++------------------- main/app/terminal/core.hook | 3 +- 3 files changed, 62 insertions(+), 64 deletions(-) diff --git a/main/app/grep/core.hook b/main/app/grep/core.hook index 17c416682f..8ee650ec93 100644 --- a/main/app/grep/core.hook +++ b/main/app/grep/core.hook @@ -2,9 +2,11 @@ ++ sign $% $: %g $% [%nice ~] - [%rush %txt p=cord] - [%rush %tang p=(list tank)] + $: %rush + $% [%txt p=cord] + [%tang p=(list tank)] == == == + == == -- :: !: @@ -13,14 +15,14 @@ |= [ost=bone you=ship arg=cord ~] =. ^arg arg :_ +>.$ + ~& [%grep-subscribing-to /in/[-.imp.hid]] :~ [ost %pass / %g %show [our.hid +.imp.hid] you /in/[-.imp.hid]] == -++ peer - |= - * - `+> +++ peer |=(* `+>) ++ pour - |= [ost=bone pax=path sih=sign] + |= [ost=bone pax=path sih=*] + ~& [%grep sih] + =+ sih=((hard sign) sih) ?^ pax `+>.$ :_ +>.$ ?- +<.sih diff --git a/main/app/shell/core.hook b/main/app/shell/core.hook index 5d83386c9f..f63902aa57 100644 --- a/main/app/shell/core.hook +++ b/main/app/shell/core.hook @@ -29,14 +29,17 @@ [%meta p=vase] :: == == == :: ++ mand ,[p=term q=(list twig)] :: +++ pipa :: + $% [%pipe p=mand q=pipa] :: + [%start mand] :: + == :: ++ coma :: - $% [%start p=term q=(list twig)] :: + $? pipa :: [%end p=(each ,@u cord)] :: [%path p=path] :: [%hoon p=twig] :: [%var p=term q=twig] :: [%rvar p=term] :: - [%pipe p=(list mand)] :: == :: ++ sign :: $% $: %g :: @@ -68,23 +71,32 @@ == :: ++ args - ;~(pfix ace (more ace wide:(vang & pax))) + :: ^- $+(nail (like (list twig))) + (more ace wide:(vang & pax)) :: ++ pipe + %+ knee *[mand pipa] |. ~+ ;~ pfix bar - %+ more - ;~(plug ace bar) - ;~(plug ;~(pfix col sym) (ifix [sel ser] args)) + ;~ plug + ;~(plug sym (maybe (ifix [;~(plug ace sel) ser] args))) + ;~(pfix ace pipable) + == + == +:: +++ pipable + %+ knee *pipa |. ~+ + ;~ pose + (stag %start ;~(pfix col ;~(plug sym (maybe ;~(pfix ace args))))) + (stag %pipe pipe) == :: ++ parse ^- $+(nail (like coma)) =+ paf=?.(=('0' &3.pax) pax pax(&3 (scot da/lat.hid))) ;~ pose - (stag %start ;~(pfix col ;~(plug sym (maybe args(pax paf))))) + pipable(pax paf) (stag %end ;~(pfix sem ;~(pose (stag %& dem) (stag %| sym)))) (stag %path (sear plex rood):(vang & pax)) - (stag %pipe pipe(pax paf)) (stag %var ;~(plug ;~(pfix tis sym) ;~(pfix ace tall:(vang & paf)))) (stag %rvar ;~(pfix ;~(plug tis tis) sym)) (stag %hoon tall:(vang & paf)) @@ -118,6 +130,7 @@ ++ poke-txt |= [ost=bone you=ship txt=cord] ^- [(list move) _+>] + =| inp=(unit span) ?: =('\\' (end 3 1 txt)) ?+ (rsh 3 1 txt) :_ +>.$ @@ -156,15 +169,19 @@ =+ com=(rush txt parse) ?~ com [+>.$ leaf/"Clarify {(trip txt)}" ~] + |- ^- [con=_+>.^$ tak=$|(~ tank) mof=(list move)] ?- -.u.com %path =. pax p.u.com - [+>.$ leaf/"=% {(spud p.u.com)}" ~] + [+>.^$ leaf/"=% {(spud p.u.com)}" ~] :: %start =+ cil=(scot %ud pid) =. pid +(pid) - :- +>.$ :- ~ + =. pip ?~ inp pip (~(put by pip) u.inp cil) + =. pop ?~ inp pip (~(put by pop) cil u.inp) + =. inp ~ + :- +>.^$ :- ~ :* :^ ost %pass /child/[cil]/main :+ %g %meta !> :* %mess [our.hid cil imp.hid] you @@ -179,11 +196,11 @@ ?: ?=(%& -.p.u.com) =+ cil=(scot %ud p.p.u.com) =+ cin=(trip (~(got by cub.hid) cil)) - :- +>.$ :- ~ + :- +>.^$ :- ~ :_ (print ost you leaf/"- :{cin}({(trip cil)})" ~) [ost %pass /child/[cil] %g %cide cil] =* cil p.p.u.com - =- [+>.$ leaf/"-{<(lent moz)>} :{(trip cil)}" moz] + =- [+>.^$ leaf/"-{<(lent moz)>} :{(trip cil)}" moz] ^= moz %+ murn (~(tap by cub.hid)) |= [a=span b=term] ?. =(b cil) ~ @@ -191,58 +208,35 @@ [ost %pass /child/[a] %g %cide a] :: %pipe - ~& [%pipsqueak ] - =+ ^= por - %+ roll - |- ^- (list ,[p=mand q=(unit mand)]) - ?~ p.u.com ~ - :- [i.p.u.com ?~(t.p.u.com ~ `i.t.p.u.com)] - $(p.u.com t.p.u.com) - =< .(pid ^pid, pip ^pip, pop ^pop) - |= $: [p=mand q=(unit mand)] - mov=(list move) - pid=@u - pip=(map span span) - pop=(map span span) - == - ^- [(list move) @u (map span span) (map span span)] - =+ cia=(scot %ud pid) - =+ cib=(scot %ud +(pid)) - =. pid +(pid) - =. pip ?~(q pip (~(put by pip) cia cib)) - =. pop ?~(q pop (~(put by pop) cib cia)) - :_ [pid pip pop] - :^ ^- move - :^ ost %pass /child/[cia]/main - :+ %g %meta !> - :* %mess [our.hid cia imp.hid] you - (cat 3 p.p '-args') (run [%clsg q.p]) - == - ^- move - [ost %pass /child/[cia]/out %g %show [our.hid cia imp.hid] you /out] - ^- move - [ost %pass /child/[cia] %g %sire p.p cia] - ^- (list move) - mov - =. pid pid.por - =. pip pip.por - =. pop pop.por - :- +>.$ :- ~ - %+ welp - mov.por - :- [ost %give %nice ~] - (print ost you leaf/"piping {}" ~) + ~& [%pipsqueak ] + =+ cil=(scot %ud pid) + =. pid +(pid) + =. pip ?~ inp pip (~(put by pip) u.inp cil) + =. pop ?~ inp pip (~(put by pop) cil u.inp) + =. inp `cil + =+ nex=$(u.com q.u.com) + :: =. +>.^$ con.nex XX whu?? + :+ con.nex tak.nex + %- welp :_ mof.nex + :~ :^ ost %pass /child/[cil]/main + :+ %g %meta !> + :* %mess [our.hid cil imp.hid] you + (cat 3 p.p.u.com '-args') (run [%clsg q.p.u.com]) + == + [ost %pass /child/[cil]/out %g %show [our.hid cil imp.hid] you /out] + [ost %pass /child/[cil] %g %sire p.p.u.com cil] + == :: %var =. var (~(put by var) p.u.com (run q.u.com)) - [+>.$ leaf/"created variable '{(trip p.u.com)}'" ~] + [+>.^$ leaf/"created variable '{(trip p.u.com)}'" ~] :: %rvar =. var (~(del by var) p.u.com) - [+>.$ leaf/"deleted variable '{(trip p.u.com)}'" ~] + [+>.^$ leaf/"deleted variable '{(trip p.u.com)}'" ~] :: %hoon - [+>.$ (sell (run p.u.com)) ~] + [+>.^$ (sell (run p.u.com)) ~] == :: ++ purr @@ -274,6 +268,7 @@ ?. ?=(?(%rust %rush) +<.sih) ~ ?: (~(has by pip) &2.pax) ~& [%yay &2.pax ] + ~& [%spamming-to /in/(~(got by pip) &2.pax) (~(get ju pus.hid) /in/(~(got by pip) &2.pax))] (spam /in/(~(got by pip) &2.pax) %meta (slot 3 typ sih)) ~& [%nay &2.pax ] %^ print-vase ost our.hid diff --git a/main/app/terminal/core.hook b/main/app/terminal/core.hook index 066d039325..7761ca8119 100644 --- a/main/app/terminal/core.hook +++ b/main/app/terminal/core.hook @@ -226,8 +226,9 @@ (some (jell ost pax)) :: ++ pour - |= [ost=bone pax=path sih=sign] + |= [ost=bone pax=path sih=*] ^- [(list move) _+>] + =+ sih=((hard sign) sih) ?: ?=(%veer +<.sih) :: vomit [[ost %give +.sih]~ +>.$] ?: ?=(%vega +<.sih) :: vomit