From 51a9d7e3c8116e203bd87a95afbc5f574adbf44d Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Sat, 4 Oct 2014 01:05:44 +0000 Subject: [PATCH] n-ary piping --- main/app/shell/core.hook | 74 ++++++++++++++++++++++++-------------- main/sur/cp-args/gate.hook | 2 +- main/sur/mv-args/gate.hook | 2 +- main/sur/rm-args/gate.hook | 2 +- 4 files changed, 51 insertions(+), 29 deletions(-) diff --git a/main/app/shell/core.hook b/main/app/shell/core.hook index 50dd7d8e2..5d83386c9 100644 --- a/main/app/shell/core.hook +++ b/main/app/shell/core.hook @@ -28,6 +28,7 @@ [%mess p=hapt q=ship r=cage] :: [%meta p=vase] :: == == == :: +++ mand ,[p=term q=(list twig)] :: ++ coma :: $% [%start p=term q=(list twig)] :: [%end p=(each ,@u cord)] :: @@ -35,7 +36,7 @@ [%hoon p=twig] :: [%var p=term q=twig] :: [%rvar p=term] :: - [%pipe p=term q=(list twig) r=term s=(list twig)] :: + [%pipe p=(list mand)] :: == :: ++ sign :: $% $: %g :: @@ -70,10 +71,10 @@ ;~(pfix ace (more ace wide:(vang & pax))) :: ++ pipe - ;~ plug - ;~(pfix bar sym) - (ifix [sel ser] args) - ;~(pfix bar ;~(plug sym args)) + ;~ pfix bar + %+ more + ;~(plug ace bar) + ;~(plug ;~(pfix col sym) (ifix [sel ser] args)) == :: ++ parse @@ -190,28 +191,47 @@ [ost %pass /child/[a] %g %cide a] :: %pipe - =+ cia=(scot %ud pid) - =+ cib=(scot %ud +(pid)) - =. pid +(+(pid)) - =. pip (~(put by pip) cia cib) - =. pop (~(put by pop) cib cia) + ~& [%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 :- +>.$ :- ~ - :* :^ ost %pass /child/[cia]/main - :+ %g %meta !> - :* %mess [our.hid cia imp.hid] you - (cat 3 p.u.com '-args') (run [%clsg q.u.com]) - == - :^ ost %pass /child/[cib]/main - :+ %g %meta !> - :* %mess [our.hid cib imp.hid] you - (cat 3 r.u.com '-args') (run [%clsg s.u.com]) - == - [ost %pass /child/[cia]/out %g %show [our.hid cia imp.hid] you /out] - [ost %pass /child/[cia] %g %sire p.u.com cia] :: XX strange order? - [ost %pass /child/[cib]/out %g %show [our.hid cib imp.hid] you /out] - [ost %pass /child/[cib] %g %sire r.u.com cib] - (print ost you leaf/"running {(trip p.u.com)} into {(trip r.u.com)}" ~) - == + %+ welp + mov.por + :- [ost %give %nice ~] + (print ost you leaf/"piping {}" ~) :: %var =. var (~(put by var) p.u.com (run q.u.com)) @@ -253,7 +273,9 @@ %out ?. ?=(?(%rust %rush) +<.sih) ~ ?: (~(has by pip) &2.pax) + ~& [%yay &2.pax ] (spam /in/(~(got by pip) &2.pax) %meta (slot 3 typ sih)) + ~& [%nay &2.pax ] %^ print-vase ost our.hid ?+ p.sih !>([(sell (slot 15 [typ sih]))]~) diff --git a/main/sur/cp-args/gate.hook b/main/sur/cp-args/gate.hook index 5290dee9c..4f989376f 100644 --- a/main/sur/cp-args/gate.hook +++ b/main/sur/cp-args/gate.hook @@ -1 +1 @@ -[input=path output=path ~] +,[input=path output=path ~] diff --git a/main/sur/mv-args/gate.hook b/main/sur/mv-args/gate.hook index 5290dee9c..4f989376f 100644 --- a/main/sur/mv-args/gate.hook +++ b/main/sur/mv-args/gate.hook @@ -1 +1 @@ -[input=path output=path ~] +,[input=path output=path ~] diff --git a/main/sur/rm-args/gate.hook b/main/sur/rm-args/gate.hook index 79e413439..9f7f4507b 100644 --- a/main/sur/rm-args/gate.hook +++ b/main/sur/rm-args/gate.hook @@ -1 +1 @@ -[pax=path ~] +,[pax=path ~]