diff --git a/assets/jocktest.jam b/assets/jocktest.jam new file mode 100644 index 0000000..b1fa47c Binary files /dev/null and b/assets/jocktest.jam differ diff --git a/common/hoon/lib/jock.hoon b/common/hoon/lib/jock.hoon index 50fc560..f79239b 100644 --- a/common/hoon/lib/jock.hoon +++ b/common/hoon/lib/jock.hoon @@ -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 @@ -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]>} {}" :: %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 + "{}" == + -- -- diff --git a/crates/jockt/hoon/lib/test-jock.hoon b/crates/jockt/hoon/lib/test-jock.hoon index ce95cca..42aac34 100644 --- a/crates/jockt/hoon/lib/test-jock.hoon +++ b/crates/jockt/hoon/lib/test-jock.hoon @@ -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 @@ -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 @@ -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 @@ -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] @@ -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 diff --git a/crates/jockt/hoon/lib/tests/let-edit.jock b/crates/jockt/hoon/lib/tests/let-edit.jock index 025ecbc..3b6599a 100644 --- a/crates/jockt/hoon/lib/tests/let-edit.jock +++ b/crates/jockt/hoon/lib/tests/let-edit.jock @@ -2,5 +2,7 @@ let a: ? = true; a = false; +print(a); + a diff --git a/crates/jockt/hoon/lib/tests/print-test.jock b/crates/jockt/hoon/lib/tests/print-test.jock new file mode 100644 index 0000000..d3515fc --- /dev/null +++ b/crates/jockt/hoon/lib/tests/print-test.jock @@ -0,0 +1,6 @@ +print('Hello world!'); +print(0x42); +print(42); +print(true); +print((0x42 42)); +42 diff --git a/hoon/tests/lib/let-edit.hoon b/hoon/tests/lib/let-edit.hoon new file mode 100644 index 0000000..a4e6e70 --- /dev/null +++ b/hoon/tests/lib/let-edit.hoon @@ -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)) +:: +--