hoon: add +mino, a new virtual nock interpreter

+mink, the current virtual nock interpreter, has a couple of problems.
 1. it propagates blocks as a list of paths, which is inconsistent with
    the way the jet behaves (only a single path is ever blocked on, with
    exception semantics).
 2. +mush was not updated after the change to molds to crash instead of
    bunting. it crashes when not given the right kind of data, which is
    inconsistent with the intended semantics of ++mink.
 3. it "eats" hints, causing (for example) slogs to disappear when running
    without a mink jet.
 4. the naming/style was typically cryptic. since +mink will never really
    be run, one could argue that its primary purpose is to be read.

+mino (which will be renamed to +mink after some staging) has had its
return type (+tono, to be renamed +tone) modified in the block case so
that it only blocks on one path, has a corrected +mush, carefully
"passes through" all hints to the underlying interpreter, and has more
meaningful names, with the intention of improving readability.

A generator (gen/mino.hoon) is also included in this commit; it contains
tests that were used during the development of +mino. It should be removed
before integration, and is included for posterity. The stack trace semantics
are expected to change in the near future (since they are dependent on jets
faithfully preserving the stack pushes of the pure nock, an onerous burden).
They are, however, tested in gen/mino.hoon, which makes it unsuitable as a
long-term test.
This commit is contained in:
Paul Driver 2019-12-01 10:47:06 -08:00 committed by Jared Tobin
parent f848d60b68
commit 50aaa27ed1
No known key found for this signature in database
GPG Key ID: 0E4647D58F8A69E4
5 changed files with 329 additions and 6 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:407a763f44eb91db0dd4a1ec2dbd12ed4332b48decefd3999c4313844daa2c0b
size 7226043
oid sha256:6ac64033689e7910f389da18b59e8d3b03479099ad6d254c1b0eab0079d22805
size 7236757

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f900509c3277b9eb194299605ce588f25dea6f92622748ced15554b7bb5914ce
size 1214375
oid sha256:e8b72448edf98d72c5ba7ccdf64ab0fb6dd62312a5504e639db7b93bb4be52f0
size 1234968

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:df629686e06b0c56db132076439b03d095bb235fc1a77668022d110559d9b840
size 9650987
oid sha256:7cc9cdfe755d72f143d7cae47e059d93422e760796f701e46535f02b43ec4535
size 9669049

139
pkg/arvo/gen/mino.hoon Normal file
View File

@ -0,0 +1,139 @@
:: test the behavior of the new mink (temporary file)
:- %say
|= [[now=@da * [our=@p *]] *]
:- %noun
?> ?= [%2 *]
(mino [0 11 [%slog 1 2 leaf+"CHECK FOR ME"] 0 0] |=(* ~))
=/ pass
|= [ref=* gof=*]
=/ fol [12 [1 ref] 1 gof]
=/ pro .*(~ fol)
``pro
=/ good
|= =path
^- ?
=/ raw=@t .^(@t %cx path)
=/ virt=tono
(mino [. !=(.^(@t %cx path))] pass)
?. ?=(%0 -.virt) |
=(product.virt raw)
?> (good /(scot %p our)/home/(scot %da now)/gen/hello/hoon)
=/ scry
|= [a=* b=*]
^- (unit (unit))
=/ al=? (? a)
:: not a (list @ta), so mush will give an empty rose
=/ c=(pair path *) ((pair path *) b)
?. &(=(a al) =(b c)) [~ ~]
?. al ~
?~ p.c [~ ~]
``q.c
?> ?&
=([%0 42] (mino [0 12 [1 0] [1 /foo] 1 42] scry))
=([%1 /foo 42] (mino [0 12 [1 1] [1 /foo] 1 42] scry))
=([%1 0 42] (mino [0 12 [1 1] [1 ~] 1 42] scry))
?=([%2 *] (mino [0 12 [1 0] [1 ~] 1 42] scry))
.= :- 2
:~ [%spot 1]
[%lose 2]
[%mean 3]
[%hand 4]
[%hunk 5]
==
%+ mino
:- 0
:* 11 [%hunk 1 5]
11 [%hand 1 4]
11 [%mean 1 3]
11 [%lose 1 2]
11 [%spot 1 1]
0 0
==
|=(* ~)
==
=/ tests=(list [subject=* formula=* product=(unit *)])
:~ :+ 0 [0 0] ~
:+ 0 [0 1] `0
:+ 0 [0 2] ~
:+ [0 1 2] [0 2] `0
:+ [0 1 2] [0 3] `[1 2]
:+ [0 1 2] [0 4] ~
:+ [0 1 2] [0 5] ~
:+ [0 1 2] [0 6] `1
:+ [0 1 2] [0 7] `2
:+ 0 [1 42] `42
:+ 0 [1 1 2 3 4] `[1 2 3 4]
:+ [[0 3] 1 2 3] [2 [0 3] 0 2] `[2 3]
:+ 42 [3 0 1] `1
:+ [0 42] [3 0 1] `0
:+ 41 [4 0 1] `42
:+ [0 41] [4 0 1] ~
:+ [42 43] [5 [0 2] [0 3]] `1
:+ [42 43] [5 [4 0 2] [0 3]] `0
:+ [42 43] [5 0 1] ~
:+ 0 [6 [1 0] [1 42] 0] `42
:+ 0 [6 [1 1] [1 42] 0] ~
:+ 0 [6 [1 0] [1 42] 1 43] `42
:+ 0 [6 [1 1] [1 42] 1 43] `43
:+ 0 [6 [1 2] [1 42] 1 42] ~
:+ 0 [7 [1 2 3] 4 4 4 0 2] `5
:+ 0 [8 [1 2 3] 4 4 4 0 4] `5
:+ 0 [8 [1 2 3] 0 3] `0
:+ 0 [9 2 1 [0 6] 42 0] `42
:+ [0 0 42] [7 [10 [6 0 7] 0 1] 0 6] `42
:+ [0 0] [10 [1 1 42] 0 2] `42
:+ 0 [10 [1 1 42] 0 2] ~
:+ 0 [10 [2 1 42] 0 1] ~
:+ 0 [10 [3 1 42] 0 1] ~
:+ [0 0] [10 [3 1 42] 0 1] `[0 42]
:+ [0 0] [10 [2 1 42] 0 1] `[42 0]
:+ [0 0 0] [10 [6 1 42] 0 1] `[0 42 0]
:+ [0 0 0] [10 [7 1 42] 0 1] `[0 0 42]
:+ 0 [11 %hint 1 42] `42
:+ 0 [11 [%hint 1 42] 1 42] `42
:+ 0 [11 [%hint 0] 1 42] ~
:+ 0 != =< (fib 5)
|%
++ dec
|= n=@
?: =(0 n) !!
=| i=@
|-
=/ ip +(i)
?: =(n ip) i
$(i ip)
++ add
|= [a=@ b=@]
?: =(0 a) b
$(a (dec a), b +(b))
++ mul
|= [a=@ b=@]
?: |(=(0 a) =(0 b)) 0
=/ r=@ a
|-
?: =(b 1) r
$(b (dec b), r (add a r))
++ fib
|= n=@
?: =(0 n) 0
=/ a=@ 1
|-
?: =(1 n) a
$(n (dec n), a (mul a n))
--
[~ :(mul 5 4 3 2)]
==
=/ scry |=(* ~)
|- ^- ?
?~ tests &
=/ t i.tests
=/ r (mino [subject.t formula.t] scry)
?~ product.t
?. ?=(%0 -.r)
$(tests t.tests)
~& [no-crash=t got=product.r]
%.n
?: &(?=(%0 -.r) =(product.r u.product.t))
$(tests t.tests)
~& [failed=t got=r]
%.n

View File

@ -4012,6 +4012,10 @@
++ pint {p/{p/@ q/@} q/{p/@ q/@}} :: line+column range
++ rule _|:($:nail $:edge) :: parsing rule
++ spot {p/path q/pint} :: range in file
++ tono $% {$0 product/*} :: success
{$1 block/*} :: single block
{$2 trace/(list {@ta *})} :: error report
== ::
++ tone $% {$0 p/*} :: success
{$1 p/(list)} :: blocks
{$2 p/(list {@ta *})} :: error report
@ -6319,6 +6323,186 @@
=+ ton=(mink [sub fol] |=({* *} ~))
?.(?=({$0 *} ton) ~ [~ p.ton])
::
++ mino !.
~/ %mino
|= $: [subject=* formula=*]
scry=$-(^ (unit (unit)))
==
=| trace=(list [@ta *])
|^ ^- tono
?+ formula [%2 trace]
[^ *]
=/ head $(formula -.formula)
?. ?=(%0 -.head) head
=/ tail $(formula +.formula)
?. ?=(%0 -.tail) tail
[%0 product.head product.tail]
::
[%0 axis=@]
=/ part (frag axis.formula subject)
?~ part [%2 trace]
[%0 u.part]
::
[%1 constant=*]
[%0 constant.formula]
::
[%2 subject=* formula=*]
=/ subject $(formula subject.formula)
?. ?=(%0 -.subject) subject
=/ formula $(formula formula.formula)
?. ?=(%0 -.formula) formula
%= $
subject product.subject
formula product.formula
==
::
[%3 argument=*]
=/ argument $(formula argument.formula)
?. ?=(%0 -.argument) argument
[%0 .?(product.argument)]
::
[%4 argument=*]
=/ argument $(formula argument.formula)
?. ?=(%0 -.argument) argument
?^ product.argument [%2 trace]
[%0 .+(product.argument)]
::
[%5 a=* b=*]
=/ a $(formula a.formula)
?. ?=(%0 -.a) a
=/ b $(formula b.formula)
?. ?=(%0 -.b) b
[%0 =(product.a product.b)]
::
[%6 test=* yes=* no=*]
=/ result $(formula test.formula)
?. ?=(%0 -.result) result
?: =(& product.result)
$(formula yes.formula)
?: =(| product.result)
$(formula no.formula)
[%2 trace]
::
[%7 subject=* next=*]
=/ subject $(formula subject.formula)
?. ?=(%0 -.subject) subject
%= $
subject product.subject
formula next.formula
==
::
[%8 head=* next=*]
=/ head $(formula head.formula)
?. ?=(%0 -.head) head
%= $
subject [product.head subject]
formula next.formula
==
::
[%9 axis=@ core=*]
=/ core $(formula core.formula)
?. ?=(%0 -.core) core
=/ arm (frag axis.formula product.core)
?~ arm [%2 trace]
%= $
subject product.core
formula u.arm
==
::
[%10 [axis=@ value=*] target=*]
?: =(0 axis.formula) [%2 trace]
=/ target $(formula target.formula)
?. ?=(%0 -.target) target
=/ value $(formula value.formula)
?. ?=(%0 -.value) value
=/ mutant=(unit *)
(edit axis.formula product.target product.value)
?~ mutant [%2 trace]
[%0 u.mutant]
::
[%11 tag=@ next=*]
%- tono
.* .
:+ 11 tag.formula
!= $(formula next.formula)
::
[%11 [tag=@ clue=*] next=*]
=/ clue $(formula clue.formula)
?. ?=(%0 -.clue) clue
%- tono
.* .
:+ 11 [tag.formula 1 product.clue]
?. ?=(?(%hunk %hand %lose %mean %spot) tag.formula)
!= $(formula next.formula)
!= %= $
formula next.formula
trace :_ trace
[tag.formula product.clue]
==
::
[%12 ref=* path=*]
=/ ref $(formula ref.formula)
?. ?=(%0 -.ref) ref
=/ path $(formula path.formula)
?. ?=(%0 -.path) path
=/ result (scry product.ref product.path)
?~ result
[%1 product.path]
?~ u.result
[%2 [%hunk (mush product.path)] trace]
[%0 u.u.result]
==
::
++ mush
|= path=*
^- tank
:+ %rose ["/" "/" ""]
=| out=(list tank)
|- ^+ out
?@ path
?: =(0 path)
(flop out)
~
?^ -.path ~
%= $
path +.path
out :_ out
leaf+(trip -.path)
==
::
++ frag
|= [axis=@ noun=*]
^- (unit *)
?: =(0 axis) ~
|-
?: =(1 axis)
`noun
?@ noun ~
%= $
axis (mas axis)
noun ?: =(2 (cap axis))
-.noun
+.noun
==
::
++ edit
|= [axis=@ target=* value=*]
^- (unit *)
?: =(1 axis) `value
?@ target ~
=/ left=? =(2 (cap axis))
=/ mutant
%= $
axis (mas axis)
target ?:(left -.target +.target)
==
?~ mutant ~
:- ~
?: left
[u.mutant +.target]
[-.target u.mutant]
--
::
++ mink !.
~/ %mink
|= {{sub/* fol/*} gul/$-({* *} (unit (unit)))}