Skip to content

Commit

Permalink
Restructure project layout
Browse files Browse the repository at this point in the history
  • Loading branch information
maolonglong committed Jul 27, 2023
1 parent 34aaac8 commit 252650c
Show file tree
Hide file tree
Showing 34 changed files with 60 additions and 25 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/ocaml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: OCaml

on:
push:
branches:
- main
pull_request:

jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
ocaml-compiler:
- "4.14"

runs-on: ${{ matrix.os }}

steps:
- name: Checkout tree
uses: actions/checkout@v3

- name: Set-up OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}

- run: opam install . --deps-only --with-test

- run: opam exec -- dune build

- run: opam exec -- dune runtest
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ test:
.PHONY: test

examples:
dune exec ./main.exe -- ./examples/factorial.bs
dune exec ./main.exe -- ./examples/fibonacci.bs
dune exec ./main.exe -- ./examples/test_factorial.bs
dune exec ./main.exe -- ./examples/test_intdef.bs
dune exec ./main.exe -- ./examples/test_lambda.bs
dune exec ./main.exe -- ./examples/test_multi.bs
dune exec ./main.exe -- ./examples/test_primitives.bs
dune exec ./main.exe -- ./examples/test_scoping.bs
dune exec ./main.exe -- ./examples/test_my_lib.bs
./bs ./examples/factorial.scm
./bs ./examples/fibonacci.scm
./bs ./examples/test_factorial.scm
./bs ./examples/test_intdef.scm
./bs ./examples/test_lambda.scm
./bs ./examples/test_multi.scm
./bs ./examples/test_primitives.scm
./bs ./examples/test_scoping.scm
./bs ./examples/test_my_lib.scm
.PHONY: examples

clean:
@dune clean
.PHONY: clean

embed:
ocaml-embed-file -output embed ./primitives.bs
ocaml-embed-file -output embed -output-dir lib ./primitives.scm
dune fmt >/dev/null 2>&1 || true
.PHONY: embed
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A subset of [Scheme](https://www.gnu.org/software/mit-scheme/)

```bash
# Interprets a file
$ ./bs ./examples/fibonacci.bs
$ ./bs ./examples/fibonacci.scm
0
1
1
Expand Down
5 changes: 5 additions & 0 deletions bin/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(executable
(name main)
(modes byte exe)
(modules main)
(libraries bogoscheme))
File renamed without changes.
4 changes: 2 additions & 2 deletions bs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -euo pipefail

if [ "$(command -v rlwrap)" ]; then
rlwrap dune exec ./main.exe -- "$@"
rlwrap dune exec ./bin/main.exe -- "$@"
else
dune exec ./main.exe -- "$@"
dune exec ./bin/main.exe -- "$@"
fi
1 change: 0 additions & 1 deletion embed.mli

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions examples/test_my_lib.bs

This file was deleted.

3 changes: 3 additions & 0 deletions examples/test_my_lib.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(load "my_lib.scm")

(say-hello)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions dune → lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,3 @@
(library
(name bogoscheme)
(modules ast sexpr parser lexer env eval primitives embed))

(executable
(name main)
(modes byte exe)
(modules main)
(libraries bogoscheme))
2 changes: 1 addition & 1 deletion embed.ml → lib/embed.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let primitives_dot_bs =
let primitives_dot_scm =
"(define not\n\
\ (lambda (b)\n\
\ (if b\n\
Expand Down
1 change: 1 addition & 0 deletions lib/embed.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
val primitives_dot_scm : string
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion primitives.ml → lib/primitives.ml
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,5 @@ let load env =
]
in
List.iter (fun (op, name) -> Env.add env name (Val_prim op)) ops;
load_from_string env Embed.primitives_dot_bs
load_from_string env Embed.primitives_dot_scm
;;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 252650c

Please sign in to comment.