Dojo with command parser, etc.

This commit is contained in:
C. Guy Yarvin 2015-03-06 01:11:01 -08:00
parent 46f4f89183
commit ff0f2d2c22
2 changed files with 264 additions and 93 deletions

View File

@ -101,6 +101,11 @@
++ nail ,[p=hair q=tape] :: parsing input ++ nail ,[p=hair q=tape] :: parsing input
++ numb ,@ :: just a number ++ numb ,@ :: just a number
++ pair |*([a=$+(* *) b=$+(* *)] ,[p=a q=b]) :: just a pair ++ 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 ++ pass ,@ :: public key
++ path (list span) :: filesys location ++ path (list span) :: filesys location
++ pint ,[p=[p=@ q=@] q=[p=@ q=@]] :: line/column range ++ pint ,[p=[p=@ q=@] q=[p=@ q=@]] :: line/column range

View File

@ -18,21 +18,44 @@
old=(set term) :: used TLVs old=(set term) :: used TLVs
== :: == ::
++ dojo-command :: ++ dojo-command ::
$% [%poke p=hapt q=dojo-source] :: make and poke $% [%poke p=goal q=dojo-source] :: make and poke
[%save p=? q=term r=dojo-source] :: save/print [%save p=term q=dojo-source] :: save/print
[%show p=dojo-source] :: print
== :: == ::
++ dojo-source :: ++ dojo-source :: construction node
$: inx=@ud :: index, assigned $: p=@ud :: assembly index
mod=dojo-model :: q=dojo-build :: general build
== :: == ::
++ dojo-model :: data source ++ dojo-build :: one ford step
$% [%& twig] :: direct expression $& [p=dojo-build q=dojo-build] :: build cell
[%| (trel term term dojo-config)] :: command engine $% [%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 ++ dojo-config :: configuration
$: ord=(list dojo-source) :: by order $: p=(list dojo-source) :: by order
key=(map term dojo-source) :: by keyword q=(map term dojo-source) :: by keyword
== :: == ::
++ dojo-problem (each dojo-source dojo-server) :: construction problem
++ dojo-project :: construction state ++ dojo-project :: construction state
$: mad=dojo-command :: operation $: mad=dojo-command :: operation
num=@ud :: number of tasks num=@ud :: number of tasks
@ -40,10 +63,11 @@
pro=(unit vase) :: prompting loop pro=(unit vase) :: prompting loop
idl=? :: not calling ford idl=? :: not calling ford
per=(unit console-edit) :: pending reverse per=(unit console-edit) :: pending reverse
job=(map ,@ud dojo-source) :: problems job=(map ,@ud dojo-problem) :: problems
rez=(map ,@ud cage) :: results rez=(map ,@ud cage) :: results
== :: == ::
++ bead ,[p=(set beam) q=cage] :: computed result ++ bead ,[p=(set beam) q=cage] :: computed result
++ goal ,[p=ship q=term] :: flat application
++ gift :: out result <-$ ++ gift :: out result <-$
$% [%mean p=ares] :: error $% [%mean p=ares] :: error
[%nice ~] :: acknowledge [%nice ~] :: acknowledge
@ -126,16 +150,99 @@
== :: == ::
++ he :: per session ++ he :: per session
|_ [[ost=bone moz=(list move)] 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 ++ dy :: project work
|_ dojo-project :: |_ dojo-project ::
++ dy-abet +>(poy `+<) :: resolve ++ dy-abet +>(poy `+<) :: resolve
++ dy-amok +>(poy ~) :: terminate ++ dy-amok +>(poy ~) :: terminate
++ dy-ford :: send to ford ++ dy-ford :: silk to ford
|= [pax=path kas=silk] |= [pax=path kas=silk]
^+ +>+> ^+ +>+>
(he-pass(poy `+>+<(idl %|)) pax %f %exec our.hid `kas) (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] |= [pax=path gat=vase sam=vase]
^+ +>+> ^+ +>+>
(dy-ford pax %call [%done ~ %noun gat] [%done ~ %noun sam]) (dy-ford pax %call [%done ~ %noun gat] [%done ~ %noun sam])
@ -150,7 +257,59 @@
^+ +>+> ^+ +>+>
(he-rush(poy ~) fec) (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=(list dojo-source)
^+ [ord +>] ^+ [ord +>]
?~ ord [~ +>.$] ?~ ord [~ +>.$]
@ -158,7 +317,7 @@
=^ mor +>.$ $(ord t.ord) =^ mor +>.$ $(ord t.ord)
[[fir mor] +>.$] [[fir mor] +>.$]
:: ::
++ dy-init-named :: prepare source map ++ dy-init-named :: (map @tas dojo-src)
|= key=(map term dojo-source) |= key=(map term dojo-source)
^+ [key +>.$] ^+ [key +>.$]
?~ key [~ +>.$] ?~ key [~ +>.$]
@ -167,46 +326,16 @@
=^ rit +>.$ $(key r.key) =^ rit +>.$ $(key r.key)
[[[p.n.key top] lef rit] +>.$] [[[p.n.key top] lef rit] +>.$]
:: ::
++ dy-init-model :: prepare dojo-model ++ dy-init :: full initialize
|= mod=dojo-model ^+ .
^+ [mod +>] =^(dam . (dy-init-command mad) +(mad dam))
?- -.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-work :: console action ++ dy-work :: console action
|= act=console-action |= act=console-action
?- -.act ?- -.act
%det (he-stir +.act) %det (he-stir +.act)
%ret (he-done (tufa buf.say)) %ret (he-done (tufa buf.say))
== ==
:: ::
++ dy-hand :: complete step ++ dy-hand :: complete step
|= cag=cage |= cag=cage
@ -259,13 +388,20 @@
^+ +> ^+ +>
?- -.mad ?- -.mad
%poke %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 %save
=+ cag=(~(got by rez) inx.r.mad) dy-amok(var (~(put by var) p.mad (~(got by rez) p.q.mad)))
=. var (~(put by var) q.mad cag) ::
?. p.mad +>+ %show
(he-rush(poy ~) [%tan (sell q.cag) ~]) (dy-rash %tan (sell q:(~(got by rez) p.p.mad)) ~)
== ==
:: ::
++ dy-edit :: handle edit ++ dy-edit :: handle edit
@ -288,31 +424,55 @@
%ret (dy-done (tufa buf.say)) %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 ++ dy-step :: advance project
^+ +> ^+ +>
?: =(cur num) ?: =(cur num)
dy-over dy-over
=+ src=(~(got by job) cur) =+ pob=(~(got by job) cur)
?- -.mod.src ?- -.pob
%& %& (dy-ford /hand (dy-silk-build q.p.pob))
%- he-pass(poy `+>-) %| (dy-ford /make (dy-silk-device q.p.pob))
[/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 ~]]
~
==
== ==
-- --
:: ::
++ 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 ++ he-abet :: resolve
[(flop moz) %_(+> hoc (~(put by hoc) ost +<+))] [(flop moz) %_(+> hoc (~(put by hoc) ost +<+))]
:: ::
@ -339,7 +499,7 @@
:- %pro :- %pro
[& %$ (tuba (weld (scow %p our.hid) ":dojo> "))] [& %$ (tuba (weld (scow %p our.hid) ":dojo> "))]
:: ::
++ he-ford :: sign from ford ++ he-ford :: result from ford
|= [pax=path rey=(each bead (list tank))] |= [pax=path rey=(each bead (list tank))]
^+ +> ^+ +>
?> ?=(^ poy) ?> ?=(^ poy)
@ -355,11 +515,9 @@
%| (he-rush(poy ~) %tan p.rey) %| (he-rush(poy ~) %tan p.rey)
== ==
:: ::
++ he-like :: filter line ++ he-like :: accept line
|= buf=(list ,@c) |= buf=(list ,@c)
^- ? =(%& -:(he-dope (tufa buf)))
=+ txt=(tufa buf)
=(+((lent txt)) q.p:(wide:(vang & ~) [1 1] txt))
:: ::
++ he-stir :: apply change ++ he-stir :: apply change
|= cal=console-change |= cal=console-change
@ -379,19 +537,27 @@
++ he-done :: parse command ++ he-done :: parse command
|= txt=tape |= txt=tape
^+ +> ^+ +>
=+ foy=(rust txt wide:(vang & ~)) =+ doy=(he-duke txt)
?~ foy ?- -.doy
(he-rush %bel ~) %|
=+ old=(weld "> " (tufa buf.say)) %- he-rush
=^ cal say (~(transmit cs say) [%set ~]) :~ %mor
%- =< he-plan [%tan [%leaf "syntax error at {<p.doy>}"]~]
%- he-rush [%bel ~]
:~ %mor ==
[%txt old] ::
[%nex ~] %&
[%det cal] =+ old=(weld "> " (tufa buf.say))
== =^ cal say (~(transmit cs say) [%set ~])
`dojo-command`[%save & %foo 0 %& u.foy] %. p.doy
=< he-plan
%- he-rush
:~ %mor
[%txt old]
[%nex ~]
[%det cal]
==
==
:: ::
++ he-work :: apply input ++ he-work :: apply input
|= act=console-action |= act=console-action