mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-17 11:51:32 +03:00
Dojo with command parser, etc.
This commit is contained in:
parent
46f4f89183
commit
ff0f2d2c22
@ -101,6 +101,11 @@
|
||||
++ nail ,[p=hair q=tape] :: parsing input
|
||||
++ numb ,@ :: just a number
|
||||
++ pair |*([a=$+(* *) b=$+(* *)] ,[p=a q=b]) :: just a pair
|
||||
++ wand |* a=(list $+(* *)) :: hetero list
|
||||
|= b=* ::
|
||||
?~ a ~ ::
|
||||
?@ b ~ ::
|
||||
[i=(i.a -.b) t=$(a t.a, b +.b)] ::
|
||||
++ pass ,@ :: public key
|
||||
++ path (list span) :: filesys location
|
||||
++ pint ,[p=[p=@ q=@] q=[p=@ q=@]] :: line/column range
|
||||
|
@ -18,21 +18,44 @@
|
||||
old=(set term) :: used TLVs
|
||||
== ::
|
||||
++ dojo-command ::
|
||||
$% [%poke p=hapt q=dojo-source] :: make and poke
|
||||
[%save p=? q=term r=dojo-source] :: save/print
|
||||
$% [%poke p=goal q=dojo-source] :: make and poke
|
||||
[%save p=term q=dojo-source] :: save/print
|
||||
[%show p=dojo-source] :: print
|
||||
== ::
|
||||
++ dojo-source ::
|
||||
$: inx=@ud :: index, assigned
|
||||
mod=dojo-model ::
|
||||
++ dojo-source :: construction node
|
||||
$: p=@ud :: assembly index
|
||||
q=dojo-build :: general build
|
||||
== ::
|
||||
++ dojo-model :: data source
|
||||
$% [%& twig] :: direct expression
|
||||
[%| (trel term term dojo-config)] :: command engine
|
||||
++ dojo-build :: one ford step
|
||||
$& [p=dojo-build q=dojo-build] :: build cell
|
||||
$% [%ex p=twig] :: hoon expression
|
||||
[%fi p=(list dojo-filter) q=dojo-build] :: filter pipeline
|
||||
[%fo p=dojo-model] :: form
|
||||
[%sc p=dojo-model] :: script
|
||||
[%va p=term] :: dojo variable
|
||||
== ::
|
||||
++ dojo-filter :: pipeline filter
|
||||
$% [%a p=twig] :: direct gate
|
||||
[%b p=mark] :: simple transmute
|
||||
[%c p=dojo-model] :: full filter
|
||||
== ::
|
||||
++ dojo-model :: data construction
|
||||
$: p=dojo-server :: core source
|
||||
q=dojo-config :: configuration
|
||||
== ::
|
||||
++ dojo-server :: numbered device
|
||||
$: p=@ud :: assembly index
|
||||
q=dojo-device :: loadable
|
||||
== ::
|
||||
++ dojo-device :: core devices
|
||||
$% [%& p=term] :: general device
|
||||
[%| p=term q=path] :: special device
|
||||
== ::
|
||||
++ dojo-config :: configuration
|
||||
$: ord=(list dojo-source) :: by order
|
||||
key=(map term dojo-source) :: by keyword
|
||||
$: p=(list dojo-source) :: by order
|
||||
q=(map term dojo-source) :: by keyword
|
||||
== ::
|
||||
++ dojo-problem (each dojo-source dojo-server) :: construction problem
|
||||
++ dojo-project :: construction state
|
||||
$: mad=dojo-command :: operation
|
||||
num=@ud :: number of tasks
|
||||
@ -40,10 +63,11 @@
|
||||
pro=(unit vase) :: prompting loop
|
||||
idl=? :: not calling ford
|
||||
per=(unit console-edit) :: pending reverse
|
||||
job=(map ,@ud dojo-source) :: problems
|
||||
job=(map ,@ud dojo-problem) :: problems
|
||||
rez=(map ,@ud cage) :: results
|
||||
== ::
|
||||
++ bead ,[p=(set beam) q=cage] :: computed result
|
||||
++ goal ,[p=ship q=term] :: flat application
|
||||
++ gift :: out result <-$
|
||||
$% [%mean p=ares] :: error
|
||||
[%nice ~] :: acknowledge
|
||||
@ -126,16 +150,99 @@
|
||||
== ::
|
||||
++ he :: per session
|
||||
|_ [[ost=bone moz=(list move)] session] ::
|
||||
++ dp :: dojo parser
|
||||
|%
|
||||
++ dp-command :: ++dojo-command
|
||||
%+ knee *dojo-command |. ~+
|
||||
;~ pose
|
||||
%+ stag %poke
|
||||
;~ pfix zap
|
||||
;~(plug dp-goal ;~(pfix ace dp-source))
|
||||
==
|
||||
::
|
||||
%+ stag %save
|
||||
;~ pfix tis
|
||||
;~(plug sym ;~(pfix ace dp-source))
|
||||
==
|
||||
::
|
||||
(stag %show dp-source)
|
||||
==
|
||||
++ dp-source (stag 0 dp-build) :: ++dojo-source
|
||||
++ dp-build :: ++dojo-build
|
||||
%+ knee *dojo-build |. ~+
|
||||
;~ pose
|
||||
(ifix [sel ser] dp-many)
|
||||
;~(pfix col (stag %fo dp-model))
|
||||
;~(pfix bar (stag %sc dp-model))
|
||||
;~(pfix buc (stag %va sym))
|
||||
(stag %ex dp-twig)
|
||||
==
|
||||
++ dp-many :: ++dojo-build
|
||||
%+ cook
|
||||
|= a=(list dojo-build)
|
||||
^- dojo-build
|
||||
?~(a !! ?~(t.a i.a [i.a $(a t.a)]))
|
||||
(most ace dp-build)
|
||||
::
|
||||
++ dp-goal :: ++goal
|
||||
%+ cook |=(a=goal a)
|
||||
;~ pose
|
||||
;~ plug
|
||||
;~(pfix sig fed:ag)
|
||||
;~(pfix fas sym)
|
||||
==
|
||||
(cook |=(a=term `goal`[our.hid a]) sym)
|
||||
==
|
||||
++ dp-model ;~(plug dp-server dp-config) :: ++dojo-model
|
||||
++ dp-server (stag 0 dp-device) :: ++dojo-server
|
||||
++ dp-twig wide:(vang & ~) :: ++twig
|
||||
++ dp-device :: ++dojo-device
|
||||
%+ cook
|
||||
|= [a=term b=path]
|
||||
^- dojo-device
|
||||
?~(b [%& a] [%| a b])
|
||||
;~(plug sym (more fas sym))
|
||||
::
|
||||
++ dp-value :: ++dojo-source
|
||||
%+ cook |=(a=dojo-source a)
|
||||
%+ stag 0
|
||||
;~ pose
|
||||
(ifix [kel ker] dp-many)
|
||||
(stag %va ;~(pfix buc sym))
|
||||
(stag %ex dp-twig)
|
||||
==
|
||||
::
|
||||
++ dp-config :: ++dojo-config
|
||||
%+ cook |=(a=dojo-config a)
|
||||
;~ plug
|
||||
(more ;~(plug com ace) dp-value)
|
||||
%+ cook
|
||||
|= a=(list (pair term (unit dojo-source)))
|
||||
%- ~(gas by *(map term dojo-source))
|
||||
%+ turn a
|
||||
|= b=(pair term (unit dojo-source))
|
||||
[p.b ?~(q.b [0 %ex [%dtzy %f &]] u.q.b)]
|
||||
%+ more ;~(plug com ace)
|
||||
;~ plug
|
||||
;~(pfix tis sym)
|
||||
;~ pose
|
||||
;~(pfix ace (stag ~ dp-value))
|
||||
(easy ~)
|
||||
==
|
||||
==
|
||||
==
|
||||
--
|
||||
::
|
||||
++ dy :: project work
|
||||
|_ dojo-project ::
|
||||
++ dy-abet +>(poy `+<) :: resolve
|
||||
++ dy-amok +>(poy ~) :: terminate
|
||||
++ dy-ford :: send to ford
|
||||
++ dy-ford :: silk to ford
|
||||
|= [pax=path kas=silk]
|
||||
^+ +>+>
|
||||
(he-pass(poy `+>+<(idl %|)) pax %f %exec our.hid `kas)
|
||||
::
|
||||
++ dy-slam :: call to ford
|
||||
++ dy-slam :: call by ford
|
||||
|= [pax=path gat=vase sam=vase]
|
||||
^+ +>+>
|
||||
(dy-ford pax %call [%done ~ %noun gat] [%done ~ %noun sam])
|
||||
@ -150,7 +257,59 @@
|
||||
^+ +>+>
|
||||
(he-rush(poy ~) fec)
|
||||
::
|
||||
++ dy-init-ordered :: prepare source list
|
||||
++ dy-init-command :: ++dojo-command
|
||||
|= mad=dojo-command
|
||||
^+ [mad +>]
|
||||
?- -.mad
|
||||
%poke =^(src +>.$ (dy-init-source q.mad) [[%poke p.mad src] +>.$])
|
||||
%save =^(src +>.$ (dy-init-source q.mad) [[%save p.mad src] +>.$])
|
||||
%show =^(src +>.$ (dy-init-source p.mad) [[%show p.mad] +>.$])
|
||||
==
|
||||
::
|
||||
++ dy-init-source :: ++dojo-source
|
||||
|= src=dojo-source
|
||||
^+ [src +>]
|
||||
=^ bul +> (dy-init-build q.src)
|
||||
=: p.src num
|
||||
q.src bul
|
||||
==
|
||||
[src +>.$(num +(num), job (~(put by job) num [%& src]))]
|
||||
::
|
||||
++ dy-init-build :: ++dojo-build
|
||||
|= bul=dojo-build
|
||||
^+ [bul +>]
|
||||
?^ -.bul
|
||||
=^ one +>.$ $(bul -.bul)
|
||||
=^ two +>.$ $(bul +.bul)
|
||||
[[one two] +>.$]
|
||||
?- -.bul
|
||||
%ex [bul +>.$]
|
||||
%fi !!
|
||||
%fo =^(mod +>.$ (dy-init-model p.bul) [[%fo mod] +>.$])
|
||||
%sc !!
|
||||
%va [bul +>.$]
|
||||
==
|
||||
::
|
||||
++ dy-init-model :: ++dojo-model
|
||||
|= mol=dojo-model
|
||||
^+ [mol +>]
|
||||
=^ one +>.$ (dy-init-server p.mol)
|
||||
=^ two +>.$ (dy-init-config q.mol)
|
||||
[[one two] +>.$]
|
||||
::
|
||||
++ dy-init-server :: ++dojo-server
|
||||
|= srv=dojo-server
|
||||
=. p.srv num
|
||||
[srv +>.$(num +(num), job (~(put by job) num [%| srv]))]
|
||||
::
|
||||
++ dy-init-config :: prepare config
|
||||
|= cig=dojo-config
|
||||
^+ [cig +>]
|
||||
=^ ord +>.$ (dy-init-ordered p.cig)
|
||||
=^ key +>.$ (dy-init-named q.cig)
|
||||
[[ord key] +>.$]
|
||||
::
|
||||
++ dy-init-ordered :: (list dojo-source)
|
||||
|= ord=(list dojo-source)
|
||||
^+ [ord +>]
|
||||
?~ ord [~ +>.$]
|
||||
@ -158,7 +317,7 @@
|
||||
=^ mor +>.$ $(ord t.ord)
|
||||
[[fir mor] +>.$]
|
||||
::
|
||||
++ dy-init-named :: prepare source map
|
||||
++ dy-init-named :: (map @tas dojo-src)
|
||||
|= key=(map term dojo-source)
|
||||
^+ [key +>.$]
|
||||
?~ key [~ +>.$]
|
||||
@ -167,46 +326,16 @@
|
||||
=^ rit +>.$ $(key r.key)
|
||||
[[[p.n.key top] lef rit] +>.$]
|
||||
::
|
||||
++ dy-init-model :: prepare dojo-model
|
||||
|= mod=dojo-model
|
||||
^+ [mod +>]
|
||||
?- -.mod
|
||||
%& [mod +>]
|
||||
%| =^ cig +> (dy-init-config r.mod)
|
||||
[mod(r cig) +>.$]
|
||||
==
|
||||
::
|
||||
++ dy-init-source :: prepare source
|
||||
|= src=dojo-source
|
||||
^+ [src +>]
|
||||
=^ mod +> (dy-init-model mod.src)
|
||||
=: inx.src num
|
||||
mod.src mod
|
||||
==
|
||||
[src +>.$(num +(num), job (~(put by job) num src))]
|
||||
::
|
||||
++ dy-init-config :: prepare config
|
||||
|= cig=dojo-config
|
||||
^+ [cig +>]
|
||||
=^ ord +>.$ (dy-init-ordered ord.cig)
|
||||
=^ key +>.$ (dy-init-named key.cig)
|
||||
[[ord key] +>.$]
|
||||
::
|
||||
++ dy-init
|
||||
=+ dam=mad
|
||||
?- -.dam
|
||||
%poke =^ src + (dy-init-source q.dam)
|
||||
+>(mad dam(q src))
|
||||
%save =^ src + (dy-init-source r.dam)
|
||||
+>(mad dam(r src))
|
||||
==
|
||||
++ dy-init :: full initialize
|
||||
^+ .
|
||||
=^(dam . (dy-init-command mad) +(mad dam))
|
||||
::
|
||||
++ dy-work :: console action
|
||||
|= act=console-action
|
||||
?- -.act
|
||||
%det (he-stir +.act)
|
||||
%ret (he-done (tufa buf.say))
|
||||
==
|
||||
?- -.act
|
||||
%det (he-stir +.act)
|
||||
%ret (he-done (tufa buf.say))
|
||||
==
|
||||
::
|
||||
++ dy-hand :: complete step
|
||||
|= cag=cage
|
||||
@ -259,13 +388,20 @@
|
||||
^+ +>
|
||||
?- -.mad
|
||||
%poke
|
||||
(he-pass(poy ~) /poke %g %mess p.mad our.hid (~(got by rez) inx.q.mad))
|
||||
%- he-pass(poy ~)
|
||||
:* /poke
|
||||
%g
|
||||
%mess
|
||||
[p.p.mad [q.p.mad ~]]
|
||||
our.hid
|
||||
(~(got by rez) p.q.mad)
|
||||
==
|
||||
::
|
||||
%save
|
||||
=+ cag=(~(got by rez) inx.r.mad)
|
||||
=. var (~(put by var) q.mad cag)
|
||||
?. p.mad +>+
|
||||
(he-rush(poy ~) [%tan (sell q.cag) ~])
|
||||
dy-amok(var (~(put by var) p.mad (~(got by rez) p.q.mad)))
|
||||
::
|
||||
%show
|
||||
(dy-rash %tan (sell q:(~(got by rez) p.p.mad)) ~)
|
||||
==
|
||||
::
|
||||
++ dy-edit :: handle edit
|
||||
@ -288,31 +424,55 @@
|
||||
%ret (dy-done (tufa buf.say))
|
||||
==
|
||||
::
|
||||
++ dy-silk-build :: build to silk
|
||||
|= bul=dojo-build
|
||||
^- silk
|
||||
?^ -.bul [$(bul -.bul) $(bul +.bul)]
|
||||
?+ -.bul !!
|
||||
%ex [%ride p.bul [%reef ~]]
|
||||
==
|
||||
::
|
||||
++ dy-silk-device :: device to silk
|
||||
|= dov=dojo-device
|
||||
^- silk
|
||||
:* %boil
|
||||
%noun
|
||||
:- [our.hid %main %da lat.hid]
|
||||
?- -.dov
|
||||
%& [%mad p.dov ~]
|
||||
%| [%app p.dov %mad q.dov]
|
||||
==
|
||||
~
|
||||
==
|
||||
::
|
||||
++ dy-step :: advance project
|
||||
^+ +>
|
||||
?: =(cur num)
|
||||
dy-over
|
||||
=+ src=(~(got by job) cur)
|
||||
?- -.mod.src
|
||||
%&
|
||||
%- he-pass(poy `+>-)
|
||||
[/hand %f %exec our.hid `[%ride +.mod.src [%reef ~]]]
|
||||
::
|
||||
%|
|
||||
%- he-pass(poy `+>-)
|
||||
:* /make
|
||||
%f
|
||||
%exec
|
||||
our.hid
|
||||
~
|
||||
%boil
|
||||
%noun
|
||||
[[our.hid %main %da lat.hid] [p.mod.src %mad q.mod.src ~]]
|
||||
~
|
||||
==
|
||||
=+ pob=(~(got by job) cur)
|
||||
?- -.pob
|
||||
%& (dy-ford /hand (dy-silk-build q.p.pob))
|
||||
%| (dy-ford /make (dy-silk-device q.p.pob))
|
||||
==
|
||||
--
|
||||
::
|
||||
++ he-dope :: sole user of ++dp
|
||||
|= txt=tape ::
|
||||
^- (each (unit dojo-command) hair) :: prefix/result
|
||||
=+ vex=(dp-command:dp [1 1] txt)
|
||||
?. =(+((lent txt)) q.p.vex) :: fully parsed
|
||||
[%| p.vex] :: syntax error
|
||||
[%& ?~(q.vex ~ `p.u.q.vex)] :: prefix/complete
|
||||
::
|
||||
++ he-duke :: ++he-dope variant
|
||||
|= txt=tape
|
||||
^- (each dojo-command ,@ud)
|
||||
=+ foy=(he-dope txt)
|
||||
?- -.foy
|
||||
%| [%| q.p.foy]
|
||||
%& ?~(p.foy [%| (lent txt)] [%& u.p.foy])
|
||||
==
|
||||
::
|
||||
++ he-abet :: resolve
|
||||
[(flop moz) %_(+> hoc (~(put by hoc) ost +<+))]
|
||||
::
|
||||
@ -339,7 +499,7 @@
|
||||
:- %pro
|
||||
[& %$ (tuba (weld (scow %p our.hid) ":dojo> "))]
|
||||
::
|
||||
++ he-ford :: sign from ford
|
||||
++ he-ford :: result from ford
|
||||
|= [pax=path rey=(each bead (list tank))]
|
||||
^+ +>
|
||||
?> ?=(^ poy)
|
||||
@ -355,11 +515,9 @@
|
||||
%| (he-rush(poy ~) %tan p.rey)
|
||||
==
|
||||
::
|
||||
++ he-like :: filter line
|
||||
++ he-like :: accept line
|
||||
|= buf=(list ,@c)
|
||||
^- ?
|
||||
=+ txt=(tufa buf)
|
||||
=(+((lent txt)) q.p:(wide:(vang & ~) [1 1] txt))
|
||||
=(%& -:(he-dope (tufa buf)))
|
||||
::
|
||||
++ he-stir :: apply change
|
||||
|= cal=console-change
|
||||
@ -379,19 +537,27 @@
|
||||
++ he-done :: parse command
|
||||
|= txt=tape
|
||||
^+ +>
|
||||
=+ foy=(rust txt wide:(vang & ~))
|
||||
?~ foy
|
||||
(he-rush %bel ~)
|
||||
=+ old=(weld "> " (tufa buf.say))
|
||||
=^ cal say (~(transmit cs say) [%set ~])
|
||||
%- =< he-plan
|
||||
%- he-rush
|
||||
:~ %mor
|
||||
[%txt old]
|
||||
[%nex ~]
|
||||
[%det cal]
|
||||
==
|
||||
`dojo-command`[%save & %foo 0 %& u.foy]
|
||||
=+ doy=(he-duke txt)
|
||||
?- -.doy
|
||||
%|
|
||||
%- he-rush
|
||||
:~ %mor
|
||||
[%tan [%leaf "syntax error at {<p.doy>}"]~]
|
||||
[%bel ~]
|
||||
==
|
||||
::
|
||||
%&
|
||||
=+ old=(weld "> " (tufa buf.say))
|
||||
=^ cal say (~(transmit cs say) [%set ~])
|
||||
%. p.doy
|
||||
=< he-plan
|
||||
%- he-rush
|
||||
:~ %mor
|
||||
[%txt old]
|
||||
[%nex ~]
|
||||
[%det cal]
|
||||
==
|
||||
==
|
||||
::
|
||||
++ he-work :: apply input
|
||||
|= act=console-action
|
||||
|
Loading…
Reference in New Issue
Block a user