Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/jocktest.jam
Binary file not shown.
45 changes: 35 additions & 10 deletions common/hoon/lib/jock.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -2340,9 +2340,15 @@
~| %print
=+ [val val-jyp]=$(j +.body.j)
=+ [nex nex-jyp]=$(j next.j)
:: resolve against jyp here?
~& > print+val
=/ trp=(trap tank) (pprint val val-jyp)
~& > %print-out
~& >> trap+[-.trp]
~& > %print-final
:_ nex-jyp
:+ %11
[%slog [%1 0] %1 (pprint val val-jyp)]
[%slog [%1 0] %1 -:trp %9 2 %0 1]
nex
::
%crash
Expand Down Expand Up @@ -2593,33 +2599,52 @@
%atom
[%5 [%1 `@`+.p.jock] %0 axis]
==
--
::
:: Prettyprinter
++ pprint
|= [=nock =jype]
|= [=noun =jype]
^- (trap tank)
:: => bus :: w/ tiny or whatever, jock-pprint in hoon, this is alias for hoon.jock-pprint, execution at runtime is the goal
=- ~&(inner+[-<] -)
|.
^- tank
:: ?^ -<.j [$(j p.j) $(j q.j)]
:+ %rose
[" " "[" "]"]
|- ^- (list tank)
?^ -<.jype
%+ weld
$(jype p.jype, noun -.noun)
$(jype q.jype, noun +.noun)
:_ ~ :: XXX %rose takes a list
?+ -<.jype
:: fall-through case, no type specialization
:- %leaf
"print: {<[-.jype]>} {<`*`nock>}"
"print: {<[-.jype]>} {<noun>}"
::
%atom
%- crip
?- ->-.jype
::
%loobean
"{<;;(? +.nock)>}"
=/ str (scot %f ;;(@ noun))
(cut 3 [1 (dec (met 3 str))] str)
::
%number
"{<;;(@ud +.nock)>}"
=/ str (scot %ui ;;(@ noun))
(cut 3 [2 (dec (dec (met 3 str)))] str)
::
%hexadecimal
"{<;;(@ux +.nock)>}"
=/ str (scot %x ;;(@ noun))
str
::
%string
"{<;;(@t +.nock)>}"
=/ str (scot %t ;;(@ noun))
(cut 3 [2 (dec (dec (met 3 str)))] str) :: XXX scot %t adds ~~ to a cord
::
==
::
%list
%- crip
"{<noun>}"
==
--
--
16 changes: 12 additions & 4 deletions crates/jockt/hoon/lib/test-jock.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
/* hoon-alias %jock /lib/tests/hoon-alias/jock
/* fib %jock /lib/tests/fib/jock
/* lists-indexing %jock /lib/tests/lists-indexing/jock
/* print-test %jock /lib/tests/print-test/jock
::
/* test-let-edit %hoon /tests/lib/let-edit/hoon
/* test-let-inner-exp %hoon /tests/lib/let-inner-exp/hoon
Expand Down Expand Up @@ -73,9 +74,11 @@
:: /* test-hoon-alias %hoon /tests/lib/hoon-alias/hoon
:: /* test-fib %hoon /tests/lib/fib/hoon
:: /* test-lists-indexing %hoon /tests/lib/lists-indexing/hoon
:: /* test-print-test %hoon /tests/lib/print-test/hoon
::
|%
++ list-jocks
~+
^- (list [term @t])
:~ [%let-edit q.let-edit] :: 0
[%let-inner-exp q.let-inner-exp] :: 1
Expand Down Expand Up @@ -113,6 +116,7 @@
[%hoon-alias q.hoon-alias] :: 33
[%fib q.fib] :: 34
[%lists-indexing q.lists-indexing] :: 35
[%print-test q.print-test] :: 36
==
::
++ test-jocks
Expand Down Expand Up @@ -218,10 +222,10 @@
[%test-type-point-jeam test-jeam:test-type-point]
[%test-type-point-mint test-mint:test-type-point]
[%test-type-point-nock test-nock:test-type-point]
:: [%test-type-point-2-tokens test-tokenize:test-type-point-2]
:: [%test-type-point-2-jeam test-jeam:test-type-point-2]
:: [%test-type-point-2-mint test-mint:test-type-point-2]
:: [%test-type-point-2-nock test-nock:test-type-point-2]
[%test-type-point-2-tokens test-tokenize:test-type-point-2]
[%test-type-point-2-jeam test-jeam:test-type-point-2]
[%test-type-point-2-mint test-mint:test-type-point-2]
[%test-type-point-2-nock test-nock:test-type-point-2]
:: [%test-type-point-3-tokens test-tokenize:test-type-point-3]
:: [%test-type-point-3-jeam test-jeam:test-type-point-3]
:: [%test-type-point-3-mint test-mint:test-type-point-3]
Expand Down Expand Up @@ -258,6 +262,10 @@
:: [%test-lists-indexing-jeam test-jeam:test-lists-indexing]
:: [%test-lists-indexing-mint test-mint:test-lists-indexing]
:: [%test-lists-indexing-nock test-nock:test-lists-indexing]
:: [%test-print-test-tokens test-tokenize:test-print-test]
:: [%test-print-test-jeam test-jeam:test-print-test]
:: [%test-print-test-mint test-mint:test-print-test]
:: [%test-print-test-nock test-nock:test-print-test]
==
::
++ parse
Expand Down
2 changes: 2 additions & 0 deletions crates/jockt/hoon/lib/tests/let-edit.jock
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ let a: ? = true;

a = false;

print(a);

a

6 changes: 6 additions & 0 deletions crates/jockt/hoon/lib/tests/print-test.jock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
print('Hello world!');
print(0x42);
print(42);
print(true);
print((0x42 42));
42
29 changes: 29 additions & 0 deletions hoon/tests/lib/let-edit.hoon
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
:: /lib/tests/let-edit
/+ jock,
test
::
|%
++ text
'let a: ? = true;\0a\0aa = false;\0a\0aprint(a);\0a\0aa'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %a] [%punctuator %':'] [%punctuator %'?'] [%punctuator %'='] [%literal [[%loobean p=%.y] q=%.n]] [%punctuator %';'] [%name %a] [%punctuator %'='] [%literal [[%loobean p=%.n] q=%.n]] [%punctuator %';'] [%keyword %print] [%punctuator %'('] [%name %a] [%punctuator %')'] [%punctuator %';'] [%name %a]]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%let type=[p=[%atom p=%loobean q=%.n] name='a'] val=[%atom p=[[%loobean p=%.y] q=%.n]] next=[%edit limb=~[[%name p=%a]] val=[%atom p=[[%loobean p=%.n] q=%.n]] next=[%print body=[%jock [%limb p=~[[%name p=%a]]]] next=[%limb p=~[[%name p=%a]]]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [1 0] 7 [10 [2 1 1] 0 1] 11 [1.735.355.507 [1 0] 1 1.717.658.988 112 114 105 110 116 58 32 112 61 91 37 97 116 111 109 32 112 61 37 108 111 111 98 101 97 110 32 113 61 37 46 110 93 32 50 0] 0 2]
!> (mint:jock text)
::
++ test-nock
%+ expect-eq:test
!> .*(0 [8 [1 0] 7 [10 [2 1 1] 0 1] 11 [1.735.355.507 [1 0] 1 1.717.658.988 112 114 105 110 116 58 32 112 61 91 37 97 116 111 109 32 112 61 37 108 111 111 98 101 97 110 32 113 61 37 46 110 93 32 50 0] 0 2])
!> .*(0 (mint:jock text))
::
--