Skip to content

Commit

Permalink
Add symbol to read anoma/nock stdlib
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcadman committed Dec 22, 2023
1 parent 0c20daf commit 24e0135
Show file tree
Hide file tree
Showing 2 changed files with 298 additions and 0 deletions.
290 changes: 290 additions & 0 deletions include/nock/Stdlib.nock
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
[ [ [ 7
[ 8
[1 1 1]
[ 1
8
[1 0]
8
[ 1
6
[5 [1 0] 0 60]
[0 6]
9
2
10
[60 8 [9 342 0 31] 9 2 10 [6 0 124] 0 2]
10
[6 8 [9 20 0 31] 9 2 10 [6 [0 125] 0 14] 0 2]
0
1
]
9
2
0
1
]
0
1
]
11
[1.953.718.630 1 7.107.949 [0 7] 0]
0
1
]
[ [ 7
[ 8
[1 0 0]
[ 1
6
[5 [1 0] 0 12]
[0 13]
9
2
10
[6 [8 [9 342 0 7] 9 2 10 [6 0 28] 0 2] 4 0 13]
0
1
]
0
1
]
11
[1.953.718.630 1 6.579.297 [0 7] 0]
0
1
]
[ [ 7
[ 8
[1 0 0]
[ 1
6
[5 [0 12] 0 13]
[1 0]
6
[8 [9 343 0 7] 9 2 10 [6 [0 28] 0 29] 0 2]
[1 0]
1
1
]
0
1
]
11
[1.953.718.630 1 6.648.940 [0 7] 0]
0
1
]
[ 7
[ 8
[1 1 1]
[ 1
6
[5 [1 0] 0 13]
[0 0]
8
[1 0]
8
[ 1
6
[8 [9 343 0 31] 9 2 10 [6 [0 124] 0 125] 0 2]
[0 6]
9
2
10
[60 8 [9 47 0 31] 9 2 10 [6 [0 124] 0 125] 0 2]
10
[6 4 0 6]
0
1
]
9
2
0
1
]
0
1
]
11
[1.953.718.630 1 7.760.228 [0 7] 0]
0
1
]
[ 7
[ 8
[1 0]
[ 1
6
[5 [1 0] 0 6]
[0 0]
8
[1 0]
8
[1 6 [5 [0 30] 4 0 6] [0 6] 9 2 10 [6 4 0 6] 0 1]
9
2
0
1
]
0
1
]
11
[1.953.718.630 1 6.514.020 [0 7] 0]
0
1
]
7
[ 8
[1 0 0]
[ 1
6
[6 [5 [0 12] 0 13] [1 1] 1 0]
[ 6
[ 8
[ 1
6
[5 [1 0] 0 28]
[1 0]
6
[ 6
[6 [5 [1 0] 0 29] [1 1] 1 0]
[ 6
[ 9
2
10
[ 14
[8 [9 342 0 15] 9 2 10 [6 0 60] 0 2]
8
[9 342 0 15]
9
2
10
[6 0 61]
0
2
]
0
1
]
[1 0]
1
1
]
1
1
]
[1 0]
1
1
]
9
2
0
1
]
[1 0]
1
1
]
1
1
]
0
1
]
11
[1.953.718.630 1 6.845.548 [0 7] 0]
0
1
]
7
[8 [1 0 0] [1 6 [8 [9 84 0 7] 9 2 10 [6 [0 28] 0 29] 0 2] [1 1] 1 0] 0 1]
11
[1.953.718.630 1 6.845.543 [0 7] 0]
0
1
]
[ 7
[ 8
[1 0 0]
[1 6 [8 [9 343 0 7] 9 2 10 [6 [0 28] 0 29] 0 2] [1 1] 1 0]
0
1
]
11
[1.953.718.630 1 6.648.935 [0 7] 0]
0
1
]
[ 7
[ 8
[1 1 1]
[ 1
6
[5 [1 0] 0 13]
[0 0]
8
[9 47 0 7]
9
2
10
[ 6
[0 28]
7
[0 3]
8
[9 4 0 7]
9
2
10
[6 [0 29] 7 [0 3] 8 [9 170 0 7] 9 2 10 [6 [0 28] 0 29] 0 2]
0
2
]
0
2
]
0
1
]
11
[1.953.718.630 1 6.582.125 [0 7] 0]
0
1
]
7
[ 8
[1 0 0]
[ 1
6
[5 [1 0] 0 13]
[0 12]
9
2
10
[ 6
[8 [9 342 0 7] 9 2 10 [6 0 28] 0 2]
8
[9 342 0 7]
9
2
10
[6 0 29]
0
2
]
0
1
]
0
1
]
11
[1.953.718.630 1 6.452.595 [0 7] 0]
0
1
]
[0 3]
909
]
8 changes: 8 additions & 0 deletions src/Juvix/Compiler/Nockma/Translation/FromSource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Data.HashMap.Internal.Strict qualified as HashMap
import Data.List.NonEmpty qualified as NonEmpty
import Data.Text qualified as Text
import Juvix.Compiler.Nockma.Language qualified as N
import Juvix.Extra.Paths
import Juvix.Parser.Error
import Juvix.Prelude hiding (Atom, many, some)
import Juvix.Prelude.Parsing hiding (runParser)
Expand All @@ -12,6 +13,13 @@ import Text.Megaparsec.Char.Lexer qualified as L

type Parser = Parsec Void Text

stdlib :: IO (N.Term Natural)
stdlib = do
txt <- readFile (toFilePath (relToProject nockStdlibPath))
case parseText txt of
Left {} -> impossible
Right t -> return t

parseText :: Text -> Either MegaparsecError (N.Term Natural)
parseText = runParser ""

Expand Down

0 comments on commit 24e0135

Please sign in to comment.