mirror of
https://github.com/anoma/juvix.git
synced 2024-12-12 14:28:08 +03:00
a9995b8e1c
This PR adds an parser, pretty printer, evaluator, repl and quasi-quoter for Nock terms. ## Parser / Pretty Printer The parser and pretty printer handle both standard Nock terms and 'pretty' Nock terms (where op codes and paths can be named). Standard and pretty Nock forms can be mixed in the same term. For example instead of `[0 2]` you can write `[@ L]`. Seea6028b0d92/src/Juvix/Compiler/Nockma/Language.hs (L79)
for the correspondence between pretty Nock and Nock operators. In pretty Nock, paths are represented as strings of `L` (for head) and `R` (for tail) instead of the number encoding in standard nock. The character `S` is used to refer to the whole subject, i.e it is sugar for `1` in standard Nock. Seea6028b0d92/src/Juvix/Compiler/Nockma/Language.hs (L177)
for the correspondence between pretty Nock path and standard Nock position. ## Quasi-quoter A quasi-quoter is added so Nock terms can be included in the source, e.g `[nock| [@ LL] |]`. ## REPL Launch the repl with `juvix dev nockma repl`. A Nock `[subject formula]` cell is input as `subject / formula` , e.g: ``` nockma> [1 0] / [@ L] 1 ``` The subject can be set using `:set-stack`. ``` nockma> :set-stack [1 0] nockma> [@ L] 1 ``` The subject can be viewed using `:get-stack`. ``` nockma> :set-stack [1 0] nockma> :get-stack [1 0] ``` You can assign a Nock term to a variable and use it in another expression: ``` nockma> r := [@ L] nockma> [1 0] / r 1 ``` A list of assignments can be read from a file: ``` $ cat stack.nock r := [@ L] $ juvix dev nockma repl nockma> :load stack.nock nockma> [1 0] / r 1 ``` * Closes https://github.com/anoma/juvix/issues/2557 --------- Co-authored-by: Jan Mas Rovira <janmasrovira@gmail.com> Co-authored-by: Lukasz Czajka <lukasz@heliax.dev>
55 lines
1.2 KiB
Haskell
55 lines
1.2 KiB
Haskell
module Main (main) where
|
|
|
|
import Asm qualified
|
|
import BackendGeb qualified
|
|
import BackendMarkdown qualified
|
|
import Base
|
|
import Compilation qualified
|
|
import Core qualified
|
|
import Examples qualified
|
|
import Format qualified
|
|
import Formatter qualified
|
|
import Internal qualified
|
|
import Nockma qualified
|
|
import Package qualified
|
|
import Parsing qualified
|
|
import Resolver qualified
|
|
import Runtime qualified
|
|
import Scope qualified
|
|
import Termination qualified
|
|
import Typecheck qualified
|
|
import VampIR qualified
|
|
|
|
slowTests :: TestTree
|
|
slowTests =
|
|
testGroup
|
|
"Juvix slow tests"
|
|
[ BackendGeb.allTests,
|
|
Runtime.allTests,
|
|
Asm.allTests,
|
|
Core.allTests,
|
|
Internal.allTests,
|
|
Compilation.allTests,
|
|
Examples.allTests,
|
|
VampIR.allTests
|
|
]
|
|
|
|
fastTests :: TestTree
|
|
fastTests =
|
|
testGroup
|
|
"Juvix fast tests"
|
|
[ Parsing.allTests,
|
|
Resolver.allTests,
|
|
Scope.allTests,
|
|
Termination.allTests,
|
|
Typecheck.allTests,
|
|
Format.allTests,
|
|
Formatter.allTests,
|
|
Package.allTests,
|
|
BackendMarkdown.allTests,
|
|
Nockma.allTests
|
|
]
|
|
|
|
main :: IO ()
|
|
main = defaultMain (testGroup "Juvix tests" [fastTests, slowTests])
|