move idris version to orig and newt version to src.
Development is being done on the newt version now.
This commit is contained in:
41
Makefile
41
Makefile
@@ -1,24 +1,47 @@
|
|||||||
SRCS=$(shell find src -name "*.idr")
|
OSRCS=$(shell find orig -name "*.idr")
|
||||||
|
SRCS=$(shell find src -name "*.newt")
|
||||||
|
|
||||||
.PHONY:
|
.PHONY:
|
||||||
|
|
||||||
all: build/exec/newt build/exec/newt.js build/exec/newt.min.js
|
all: build/exec/newt build/exec/newt.js build/exec/newt.min.js newt.js
|
||||||
|
|
||||||
build/exec/newt: ${SRCS}
|
# Original idris version
|
||||||
|
|
||||||
|
build/exec/newt: ${OSRCS}
|
||||||
idris2 --build newt.ipkg
|
idris2 --build newt.ipkg
|
||||||
|
|
||||||
build/exec/newt.js: ${SRCS}
|
build/exec/newt.js: ${OSRCS}
|
||||||
idris2 --cg node -o newt.js -p contrib -c src/Main.idr
|
idris2 --cg node -o newt.js -p contrib -c orig/Main.idr
|
||||||
|
|
||||||
build/exec/newt.min.js: ${SRCS}
|
build/exec/newt.min.js: ${OSRCS}
|
||||||
idris2 --cg node -o newt.min.js -p contrib -c src/Main.idr --directive minimal
|
idris2 --cg node -o newt.min.js -p contrib -c orig/Main.idr --directive minimal
|
||||||
|
|
||||||
test: build/exec/newt
|
orig_aoctest: build/exec/newt
|
||||||
|
scripts/orig_aoc
|
||||||
|
|
||||||
|
orig_test: build/exec/newt
|
||||||
|
scripts/orig_test
|
||||||
|
|
||||||
|
# New version
|
||||||
|
|
||||||
|
newt.js: ${SRCS}
|
||||||
|
bun run bootstrap/newt.js src/Main.newt -o newt.js
|
||||||
|
|
||||||
|
newt2.js: newt.js
|
||||||
|
bun run newt.js src/Main.newt -o newt2.js
|
||||||
|
|
||||||
|
newt3.js: newt2.js
|
||||||
|
bun run newt2.js src/Main.newt -o newt3.js
|
||||||
|
cmp newt2.js newt3.js
|
||||||
|
|
||||||
|
test: newt.js
|
||||||
scripts/test
|
scripts/test
|
||||||
|
|
||||||
aoctest: build/exec/newt
|
aoctest: newt.js
|
||||||
scripts/aoc
|
scripts/aoc
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
|
||||||
vscode:
|
vscode:
|
||||||
cd newt-vscode && vsce package && code --install-extension *.vsix
|
cd newt-vscode && vsce package && code --install-extension *.vsix
|
||||||
|
|
||||||
|
|||||||
18
README.md
18
README.md
@@ -12,23 +12,27 @@ The web playground can be at https://dunhamsteve.github.io/newt. The top left co
|
|||||||
has a dropdown with some samples. Currently the web playground is using the Idris-built
|
has a dropdown with some samples. Currently the web playground is using the Idris-built
|
||||||
version of newt because most browsers lack tail call optimization.
|
version of newt because most browsers lack tail call optimization.
|
||||||
|
|
||||||
The directory `port` contains a port of newt to itself. Currently it needs to be run by `bun` rather than `node` because `bun` does tail call optimization.
|
The directory `orig` contains the original version of newt written in Idris. It is used by the playground until TCO is added to newt.
|
||||||
|
|
||||||
## Sample code
|
## Sample code
|
||||||
|
|
||||||
- `port` contains a copy of newt written in newt
|
- `src` contains a copy of newt written in newt
|
||||||
- `newt` contains miscellaneous files
|
- `newt` contains miscellaneous samples
|
||||||
- `aoc2024` contains solutions for 2024 Advent of Code in newt
|
- `aoc2024` contains solutions for 2024 Advent of Code in newt
|
||||||
- `tests` contains some test cases.
|
- `tests` contains test cases
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
There is a `Makefile` that builds both chez and javascript versions. They end up in
|
The `Makefile` will build both the original Idris version of `newt`, which will end up in `build/exec` and the current version of newt, which will be `./newt.js`. There is a `pack.toml` file to allow building the original version of newt with `pack build`.
|
||||||
`build/exec` as usual. I've also added a `pack.toml`, so `pack build` also works.
|
|
||||||
|
Newt can also be built by running `bun run bootstrap/newt.js src/Main.newt -o newt.js`.
|
||||||
|
|
||||||
There is a vscode extension in `newt-vscode`. Running `make vscode` will build and install it. The extension expects `build/exec/newt` to exist in the workspace. And `make test` will run a few black box tests. Currently it simply checks return codes, since the output format is in flux.
|
There is a vscode extension in `newt-vscode`. Running `make vscode` will build and install it. The extension expects `build/exec/newt` to exist in the workspace. And `make test` will run a few black box tests. Currently it simply checks return codes, since the output format is in flux.
|
||||||
|
|
||||||
The web playground is in playground.
|
## Playground
|
||||||
|
|
||||||
|
The web playground is found in the `playground` directory. It uses the original version of newt, which takes advantage of Idris' tail call optimization.
|
||||||
|
|
||||||
- `npm install` will pull down dependencies.
|
- `npm install` will pull down dependencies.
|
||||||
- `./build` will build the web workers and install sample files (`make` must be run in root first).
|
- `./build` will build the web workers and install sample files (`make` must be run in root first).
|
||||||
- `npx vite` will run the dev server.
|
- `npx vite` will run the dev server.
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ main = Main
|
|||||||
-- name of executable
|
-- name of executable
|
||||||
executable = "newt"
|
executable = "newt"
|
||||||
-- opts =
|
-- opts =
|
||||||
sourcedir = "src"
|
sourcedir = "orig"
|
||||||
-- builddir =
|
-- builddir =
|
||||||
-- outputdir =
|
-- outputdir =
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
mkdir -p tmp
|
mkdir -p tmp
|
||||||
echo "Test AoC 2024 solutions"
|
echo "Test AoC 2024 solutions"
|
||||||
|
NCC="bun run newt.js"
|
||||||
total=0
|
total=0
|
||||||
failed=0
|
failed=0
|
||||||
for fn in aoc2024/Day*.newt; do
|
for fn in aoc2024/Day*.newt; do
|
||||||
total=$((total + 1))
|
total=$((total + 1))
|
||||||
echo Test $fn
|
echo Test $fn
|
||||||
bn=$(basename $fn)
|
bn=$(basename $fn)
|
||||||
./build/exec/newt $fn -o out.js > tmp/${bn}.compile
|
$NCC $fn -o out.js > tmp/${bn}.compile
|
||||||
if [ $? != "0" ]; then
|
if [ $? != "0" ]; then
|
||||||
echo Compile failed for $fn
|
echo Compile failed for $fn
|
||||||
failed=$((failed + 1))
|
failed=$((failed + 1))
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
mkdir -p tmp
|
mkdir -p tmp
|
||||||
echo "Test AoC 2024 solutions"
|
echo "Test AoC 2024 solutions"
|
||||||
NCC="bun run newt.js"
|
|
||||||
total=0
|
total=0
|
||||||
failed=0
|
failed=0
|
||||||
for fn in aoc2024/Day*.newt; do
|
for fn in aoc2024/Day*.newt; do
|
||||||
total=$((total + 1))
|
total=$((total + 1))
|
||||||
echo Test $fn
|
echo Test $fn
|
||||||
bn=$(basename $fn)
|
bn=$(basename $fn)
|
||||||
$NCC $fn -o out.js > tmp/${bn}.compile
|
./build/exec/newt $fn -o out.js > tmp/${bn}.compile
|
||||||
if [ $? != "0" ]; then
|
if [ $? != "0" ]; then
|
||||||
echo Compile failed for $fn
|
echo Compile failed for $fn
|
||||||
failed=$((failed + 1))
|
failed=$((failed + 1))
|
||||||
31
scripts/orig_test
Executable file
31
scripts/orig_test
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
SAMPLES=$(find playground/samples -name "*.newt")
|
||||||
|
total=0
|
||||||
|
failed=0
|
||||||
|
for fn in tests/*.newt ; do
|
||||||
|
total=$((total + 1))
|
||||||
|
echo Test $fn
|
||||||
|
bn=$(basename $fn)
|
||||||
|
./build/exec/newt $fn -o out.js > tmp/${bn}.compile
|
||||||
|
if [ $? != "0" ]; then
|
||||||
|
echo Compile failed for $fn
|
||||||
|
failed=$((failed + 1))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# if there is a golden file, run the code and compare output
|
||||||
|
if [ -f ${fn}.golden ]; then
|
||||||
|
bun run out.js > tmp/${bn}.out
|
||||||
|
if [ $? != "0" ]; then
|
||||||
|
echo Run failed for $fn
|
||||||
|
failed=$((failed + 1))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if ! diff -q tmp/${bn}.out ${fn}.golden; then
|
||||||
|
echo "Output mismatch for $fn"
|
||||||
|
failed=$((failed + 1))
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "Total tests: $total"
|
||||||
|
echo "Failed tests: $failed"
|
||||||
|
|
||||||
@@ -1,12 +1,18 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
SAMPLES=$(find playground/samples -name "*.newt")
|
SAMPLES=$(find playground/samples -name "*.newt")
|
||||||
|
NCC="bun run newt.js"
|
||||||
total=0
|
total=0
|
||||||
failed=0
|
failed=0
|
||||||
for fn in tests/*.newt ; do
|
for fn in tests/*.newt ; do
|
||||||
total=$((total + 1))
|
total=$((total + 1))
|
||||||
echo Test $fn
|
echo Test $fn
|
||||||
bn=$(basename $fn)
|
bn=$(basename $fn)
|
||||||
./build/exec/newt $fn -o out.js > tmp/${bn}.compile
|
if [ -f ${fn}.golden ]; then
|
||||||
|
$NCC $fn -o out.js > tmp/${bn}.compile
|
||||||
|
else
|
||||||
|
# we've dropped support for compiling things without main for now.
|
||||||
|
$NCC $fn > tmp/${bn}.compile
|
||||||
|
fi
|
||||||
if [ $? != "0" ]; then
|
if [ $? != "0" ]; then
|
||||||
echo Compile failed for $fn
|
echo Compile failed for $fn
|
||||||
failed=$((failed + 1))
|
failed=$((failed + 1))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Experimental serializer / deserializer for modules
|
// Experimental serializer / deserializer for modules
|
||||||
// not completely wired in yet, serialization is running.
|
// not completely wired in yet, serialization is running, deserialization is not
|
||||||
|
|
||||||
const END = 0;
|
const END = 0;
|
||||||
const LIST = 1;
|
const LIST = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user