-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add nockma evaluator #2564
Add nockma evaluator #2564
Conversation
b04b97a
to
5838988
Compare
24e0135
to
72be53c
Compare
248a851
to
7bb63d3
Compare
1fab9e6
to
a6028b0
Compare
import Juvix.Compiler.Nockma.Translation.FromSource.QQ | ||
import Juvix.Prelude | ||
|
||
stdlib :: Term Natural |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be used anywhere. Is it used for compilation? I think it might be a pain to keep it up-to-date with the actual Nockma stdlib. Maybe a better solution is to have an extra instruction StdLibCall
with an enum of functions and translate them to library calls only at serialization, and implement them directly in Haskell for the interpreter?
The nockma standatd library contains numbers like 1.953.718.630
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]
.See
juvix/src/Juvix/Compiler/Nockma/Language.hs
Line 79 in a6028b0
In pretty Nock, paths are represented as strings of
L
(for head) andR
(for tail) instead of the number encoding in standard nock. The characterS
is used to refer to the whole subject, i.e it is sugar for1
in standard Nock.See
juvix/src/Juvix/Compiler/Nockma/Language.hs
Line 177 in a6028b0
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 assubject / formula
, e.g:The subject can be set using
:set-stack
.The subject can be viewed using
:get-stack
.You can assign a Nock term to a variable and use it in another expression:
A list of assignments can be read from a file: