diff --git a/.editorconfig b/.editorconfig index 91b492ed6..730d51b8b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,19 +1,12 @@ -# See editorconfig.org for details - root = true [*] -end_of_line = lf -insert_final_newline = true -charset = utf-8 - -[*.{ml,mli,mll,mly}] -indent_style = space -indent_size = 2 - -[*.{saty,satyh}] indent_style = space indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true [Makefile] indent_style = tab diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..ca79ca5b4 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 40b8baaaa..000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: CI - -on: - - push - - pull_request - -jobs: - build: - name: Build - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - - macos-latest - ocaml-compiler: - - "4.14" - - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout tree - uses: actions/checkout@v4 - - - name: Cache dist fonts - uses: actions/cache@v4 - id: fonts-cache - with: - path: lib-satysfi/dist/fonts - key: cache-dist-fonts-${{ hashFiles('download-fonts.sh') }} - - - name: Set-up OCaml ${{ matrix.ocaml-compiler }} - uses: ocaml/setup-ocaml@v2 - with: - ocaml-compiler: ${{ matrix.ocaml-compiler }} - dune-cache: true - allow-prerelease-opam: true - opam-repositories: | - satysfi-external: https://github.com/gfngfn/satysfi-external-repo.git - default: https://github.com/ocaml/opam-repository.git - - - name: Install SATySFi dependencies - run: opam install . --deps-only --with-doc --with-test - - - name: Build SATySFi - run: opam exec -- make all - - - name: Run tests - run: opam exec -- dune runtest - - - name: Download fonts - if: steps.fonts-cache.outputs.cache-hit != 'true' - run: ./download-fonts.sh - - - name: Install SATySFi - run: | - opam install -y . - ./install-libs.sh ~/.satysfi - - - name: Build demo docs - run: | - (cd demo; opam exec -- make) - (cd doc; opam exec -- make) - (cd tests; opam exec -- make) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..8dba93f7b --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,97 @@ +name: Builds, tests & co + +on: + push: + pull_request: + schedule: + - cron: 0 1 * * MON + +jobs: + build-and-test: + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-latest + # - windows-latest + ocaml-compiler: + - 4 + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout tree + uses: actions/checkout@v4 + + # - name: Set SHELLOPTS=igncr on Windows + # if: runner.os == 'Windows' + # run: echo "SHELLOPTS=igncr" >>"$GITHUB_ENV" + + - name: Restore fonts cache + uses: actions/cache@v4 + id: fonts-cache + with: + path: lib-satysfi/dist/fonts + key: cache-dist-fonts-${{ hashFiles('download-fonts.sh') }} + + - name: Set-up OCaml + uses: ocaml/setup-ocaml@v3 + with: + ocaml-compiler: ${{ matrix.ocaml-compiler }} + dune-cache: true + opam-repositories: | + satysfi-external: git+https://github.com/gfngfn/satysfi-external-repo.git + default: git+https://github.com/ocaml/opam-repository.git + + - name: Install SATySFi dependencies + run: opam install . --deps-only + + - name: Build SATySFi + run: opam exec -- make all + + - name: Run tests + run: opam exec -- dune runtest + + - name: Download fonts + if: steps.fonts-cache.outputs.cache-hit != 'true' + run: ./download-fonts.sh + + - name: Install SATySFi + run: | + opam install . + ./install-libs.sh ~/.satysfi + + - name: Build demo docs + run: | + (cd demo; opam exec -- make) + (cd doc; opam exec -- make) + (cd tests; opam exec -- make) + + lint-fmt: + runs-on: ubuntu-latest + steps: + - name: Checkout tree + uses: actions/checkout@v4 + - name: Set-up OCaml + uses: ocaml/setup-ocaml@v3 + with: + ocaml-compiler: 4 + opam-repositories: | + satysfi-external: git+https://github.com/gfngfn/satysfi-external-repo.git + default: git+https://github.com/ocaml/opam-repository.git + - uses: ocaml/setup-ocaml/lint-fmt@v3 + + lint-opam: + runs-on: ubuntu-latest + steps: + - name: Checkout tree + uses: actions/checkout@v4 + - name: Set-up OCaml + uses: ocaml/setup-ocaml@v3 + with: + ocaml-compiler: 4 + opam-repositories: | + satysfi-external: git+https://github.com/gfngfn/satysfi-external-repo.git + default: git+https://github.com/ocaml/opam-repository.git + - uses: ocaml/setup-ocaml/lint-opam@v3 diff --git a/.github/workflows/opam-dependency-submission.yml b/.github/workflows/opam-dependency-submission.yml new file mode 100644 index 000000000..5bf56dc92 --- /dev/null +++ b/.github/workflows/opam-dependency-submission.yml @@ -0,0 +1,29 @@ +name: Opam Dependency Submission + +on: + push: + branches: + - master + +concurrency: + group: opam-dependency-submission + cancel-in-progress: true + +permissions: read-all + +jobs: + opam-dependency-submission: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout tree + uses: actions/checkout@v4 + - name: Set-up OCaml + uses: ocaml/setup-ocaml@v3 + with: + ocaml-compiler: 4 + opam-repositories: | + satysfi-external: git+https://github.com/gfngfn/satysfi-external-repo.git + default: git+https://github.com/ocaml/opam-repository.git + - uses: ocaml/setup-ocaml/analysis@v3 diff --git a/.gitignore b/.gitignore index 2d473ae3e..8fdd2b02e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,75 +1,6 @@ -.DS_Store -\#* -.\#* -*~ -*.exe -*.tex -*.log -*.aux -*.dvi -*.fdb_latexmk -*.fls -*.synctex.gz -*.pdf -*.out -*.html -obsolete/*.txt -old/ -*.png -satysfi -*.ttf -*.otf -*.ttc -*.dfont -*.afm -*.t1a -*.svg -!/logo/macrodown.svg -*.dat -*.ttx -*.jpg -!/demo/satysfi-logo.jpg -!/tests/images/satysfi-logo-cmyk.jpg -!/tests/images/satysfi-logo-gray.jpg -!/tests/images/satysfi-logo-rgb.jpg -!/tests/images/peppers-cmyk.jpg -!/tests/images/peppers-gray.jpg -!/tests/images/peppers-rgb.jpg -*.satysfi-aux -external/ - -# Created by https://www.toptal.com/developers/gitignore/api/ocaml -# Edit at https://www.toptal.com/developers/gitignore?templates=ocaml - -### OCaml ### -*.annot -*.cmo -*.cma -*.cmi -*.a -*.o -*.cmx -*.cmxs -*.cmxa - -# ocamlbuild working directory -_build/ - -# ocamlbuild targets -*.byte -*.native - -# oasis generated files -setup.data -setup.log - -# Merlin configuring file for Vim and Emacs -.merlin - -# Dune generated files -*.install - -# Local OPAM switch -_opam - -# End of https://www.toptal.com/developers/gitignore/api/ocaml +/_build/ +/_opam/ +/lib-satysfi/dist/fonts/ +/temp/IPAexfont00401/ +/temp/latinmodern-math-1959/ +/temp/*.zip diff --git a/Makefile b/Makefile index 1f030db1c..7e486bfe9 100644 --- a/Makefile +++ b/Makefile @@ -1,27 +1,17 @@ PREFIX=/usr/local LIBDIR=$(PREFIX)/share/satysfi -TARGET=satysfi BINDIR=$(PREFIX)/bin -RM=rm -f -DUNE=dune -.PHONY: all install lib uninstall clean +.PHONY: all clean install uninstall all: - $(DUNE) build --root . - cp _build/install/default/bin/$(TARGET) . + dune build -install: $(TARGET) - mkdir -p $(BINDIR) - install $(TARGET) $(BINDIR) +clean: + dune clean -#preliminary: -# [ -d .git ] && git submodule update -i || echo "Skip git submodule update -i" +install: + dune install --bindir=$(BINDIR) uninstall: - rm -rf $(BINDIR)/$(TARGET) - rm -rf $(LIBDIR) - -clean: - $(DUNE) clean - $(RM) satysfi + dune uninstall --bindir=$(BINDIR) diff --git a/bin/dune b/bin/dune index 3207d88c1..766c26f5d 100644 --- a/bin/dune +++ b/bin/dune @@ -2,7 +2,6 @@ (name satysfi) (public_name satysfi) (libraries - main - cmdliner) - (preprocess no_preprocessing) -) + main + cmdliner) + (preprocess no_preprocessing)) diff --git a/download-fonts.sh b/download-fonts.sh index 50f3e974f..2b7eef22c 100755 --- a/download-fonts.sh +++ b/download-fonts.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash set -ue @@ -7,14 +7,14 @@ MESSAGE_PREFIX="[download-fonts.sh]" cd "$(dirname "$0")" mkdir -p "$CACHE" -show_message () { +show_message() { echo "$MESSAGE_PREFIX $1." } -if command shasum --version >/dev/null 2>&1 ; then +if command shasum --version >/dev/null 2>&1; then show_message "Using shasum" SHA1SUM=shasum -elif command sha1sum --version >/dev/null 2>&1 ; then +elif command sha1sum --version >/dev/null 2>&1; then show_message "Using sha1sum" SHA1SUM=sha1sum else @@ -22,25 +22,25 @@ else exit 1 fi -validate_file () { +validate_file() { ( - NAME="$1" - cd "$CACHE" - $SHA1SUM --check "$NAME.sha1" + NAME="$1" + cd "$CACHE" + $SHA1SUM --check "$NAME.sha1" ) } -download_file () { +download_file() { ( - NAME="$1" - URL="$2" - if [ -f "$CACHE/$NAME" ] && validate_file "$NAME" ; then - show_message "'$NAME' found in '$CACHE/'." - else - show_message "downloading '$NAME' ..." - wget -O "$CACHE/$NAME" "$URL" - show_message "finished downloading '$NAME'." - fi + NAME="$1" + URL="$2" + if [ -f "$CACHE/$NAME" ] && validate_file "$NAME"; then + show_message "'$NAME' found in '$CACHE/'." + else + show_message "downloading '$NAME' ..." + wget -O "$CACHE/$NAME" "$URL" + show_message "finished downloading '$NAME'." + fi ) } diff --git a/dune-project b/dune-project index 4050ce0f5..1d4beb1fa 100644 --- a/dune-project +++ b/dune-project @@ -1,3 +1,87 @@ -(lang dune 1.0) +(lang dune 3.16) + +(using menhir 2.1) + +(formatting + (enabled_for dune)) + (name satysfi) -(using menhir 1.0) + +(license LGPL-3.0-only) + +(authors "Takashi Suwa") + +(maintainers "Takashi Suwa") + +(source + (github gfngfn/SATySFi)) + +(generate_opam_files true) + +(package + (name satysfi) + (synopsis "A statically-typed, functional typesetting system") + (description + "SATySFi is a typesetting system equipped with a statically-typed, functional programming language. It consists mainly of two “layers” ― the text layer and the program layer. The former is for writing documents in LaTeX-like syntax. The latter, which has OCaml-like syntax, is for defining functions and commands. SATySFi enables you to write documents markuped with flexible commands of your own making. In addition, its informative type error reporting will be a good help to your writing.") + (depends + (ocaml + (and + (>= 4.12.0) + (< 5.0.0))) + (alcotest + (and + :with-test + (>= 1.4.0))) + (batteries + (and + (>= 3.6.0) + (< 4.0))) + (camlimages + (and + (>= 5.0.1) + (< 5.0.5))) + (camlpdf + (= 2.3.1+satysfi)) + (core_kernel + (and + (>= v0.15) + (< v0.18))) + (cppo + (and + (>= 1.6.4) + (< 1.7))) + dune-build-info + (menhir + (>= 20231231)) + (menhirLib + (>= 20231231)) + (omd + (and + (>= 1.3.2) + (< 2.0))) + (otfed + (and + (>= 0.3.1) + (< 0.4))) + (ppx_deriving + (and + (>= 5.2.1) + (< 6.0))) + (re + (and + (>= 1.10.4) + (< 2.0))) + (uutf + (and + (>= 1.0.3) + (< 2.0))) + (uunf + (and + (>= 15.0.0) + (< 16.0))) + (uuseg + (and + (>= 15.0.0) + (< 16.0))) + (yojson-with-position + (= 1.4.2+satysfi)))) diff --git a/install-libs.sh b/install-libs.sh index 9c7dd1170..c1a1bfd2e 100755 --- a/install-libs.sh +++ b/install-libs.sh @@ -1,18 +1,18 @@ -#!/bin/sh +#!/usr/bin/env bash LIBDIR=${1:-/usr/local/share/satysfi} -install -d ${LIBDIR} -install -d ${LIBDIR}/dist -install -d ${LIBDIR}/dist/unidata -install -m 644 lib-satysfi/dist/unidata/*.txt ${LIBDIR}/dist/unidata -install -d ${LIBDIR}/dist/fonts -install -m 644 lib-satysfi/dist/fonts/* ${LIBDIR}/dist/fonts -install -d ${LIBDIR}/dist/hash -install -m 644 lib-satysfi/dist/hash/* ${LIBDIR}/dist/hash -install -d ${LIBDIR}/dist/hyph -install -m 644 lib-satysfi/dist/hyph/* ${LIBDIR}/dist/hyph -install -d ${LIBDIR}/dist/packages -install -m 644 lib-satysfi/dist/packages/* ${LIBDIR}/dist/packages -install -d ${LIBDIR}/dist/md -install -m 644 lib-satysfi/dist/md/* ${LIBDIR}/dist/md +install -d "${LIBDIR}" +install -d "${LIBDIR}/dist" +install -d "${LIBDIR}/dist/unidata" +install -m 644 lib-satysfi/dist/unidata/*.txt "${LIBDIR}/dist/unidata" +install -d "${LIBDIR}/dist/fonts" +install -m 644 lib-satysfi/dist/fonts/* "${LIBDIR}/dist/fonts" +install -d "${LIBDIR}"/dist/hash +install -m 644 lib-satysfi/dist/hash/* "${LIBDIR}/dist/hash" +install -d "${LIBDIR}/dist/hyph" +install -m 644 lib-satysfi/dist/hyph/* "${LIBDIR}/dist/hyph" +install -d "${LIBDIR}"/dist/packages +install -m 644 lib-satysfi/dist/packages/* "${LIBDIR}/dist/packages" +install -d "${LIBDIR}"/dist/md +install -m 644 lib-satysfi/dist/md/* "${LIBDIR}/dist/md" diff --git a/satysfi.opam b/satysfi.opam index 31bfdad28..3066be47a 100644 --- a/satysfi.opam +++ b/satysfi.opam @@ -1,46 +1,47 @@ +# This file is generated by dune, edit dune-project instead opam-version: "2.0" -name: "satysfi" -version: "0.0.11" -maintainer: "Takashi Suwa" -authors: [ - "Takashi Suwa" -] +synopsis: "A statically-typed, functional typesetting system" +description: + "SATySFi is a typesetting system equipped with a statically-typed, functional programming language. It consists mainly of two “layers” ― the text layer and the program layer. The former is for writing documents in LaTeX-like syntax. The latter, which has OCaml-like syntax, is for defining functions and commands. SATySFi enables you to write documents markuped with flexible commands of your own making. In addition, its informative type error reporting will be a good help to your writing." +maintainer: ["Takashi Suwa"] +authors: ["Takashi Suwa"] +license: "LGPL-3.0-only" homepage: "https://github.com/gfngfn/SATySFi" -dev-repo: "git+https://github.com/gfngfn/SATySFi.git" bug-reports: "https://github.com/gfngfn/SATySFi/issues" -build: [ - ["mkdir" "-p" "temp"] - [make "-f" "Makefile" "PREFIX=%{prefix}%"] -] -install: [ - [make "-f" "Makefile" "install" "PREFIX=%{prefix}%"] -] -remove: [ - [make "-f" "Makefile" "uninstall" "PREFIX=%{prefix}%"] -] -# Packages whose version suffix is "+satysfi" are distributed on satysfi-external-repo. depends: [ - "ocaml" {>= "4.14.0" & < "5.0.0"} - "batteries" {>= "3.6.0" & < "4.0.0"} + "dune" {>= "3.16"} + "ocaml" {>= "4.12.0" & < "5.0.0"} + "alcotest" {with-test & >= "1.4.0"} + "batteries" {>= "3.6.0" & < "4.0"} "camlimages" {>= "5.0.1" & < "5.0.5"} "camlpdf" {= "2.3.1+satysfi"} - "cmdliner" {>= "1.1.1"} - "core_kernel" {>= "v0.15" & < "v0.16"} - "cppo" {build & >= "1.6.4" & < "1.7.0"} - "dune" {build} - "menhir" - "ocamlfind" {build} + "core_kernel" {>= "v0.15" & < "v0.18"} + "cppo" {>= "1.6.4" & < "1.7"} + "dune-build-info" + "menhir" {>= "20231231"} + "menhirLib" {>= "20231231"} + "omd" {>= "1.3.2" & < "2.0"} "otfed" {>= "0.3.1" & < "0.4"} - "ppx_deriving" {>= "5.2.1" & < "6.0.0"} - "re" {build & >= "1.10.4" & < "2.0.0"} - "uutf" {>= "1.0.3" & < "2.0.0"} - "uunf" {>= "15.0.0" & < "16.0.0"} - "uuseg" {>= "15.0.0" & < "16.0.0"} + "ppx_deriving" {>= "5.2.1" & < "6.0"} + "re" {>= "1.10.4" & < "2.0"} + "uutf" {>= "1.0.3" & < "2.0"} + "uunf" {>= "15.0.0" & < "16.0"} + "uuseg" {>= "15.0.0" & < "16.0"} "yojson-with-position" {= "1.4.2+satysfi"} - "omd" {>= "1.3.2" & < "2.0.0~"} - "ocamlgraph" - "alcotest" {with-test & >= "1.4.0"} + "odoc" {with-doc} ] -synopsis: "A statically-typed, functional typesetting system" -description: """ -SATySFi is a typesetting system equipped with a statically-typed, functional programming language. It consists mainly of two “layers” ― the text layer and the program layer. The former is for writing documents in LaTeX-like syntax. The latter, which has OCaml-like syntax, is for defining functions and commands. SATySFi enables you to write documents markuped with flexible commands of your own making. In addition, its informative type error reporting will be a good help to your writing.""" +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/gfngfn/SATySFi.git" diff --git a/src/backend/Makefile b/src/backend/Makefile deleted file mode 100644 index 2f30fd34c..000000000 --- a/src/backend/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -OCBFLAGS = ocamlbuild -use-ocamlfind -pkgs "core,ctypes" -tag thread -CFLAGS = ocamlc.opt -c - -pageBreak.native: pageBreak.ml lineBreak.ml flowGraph.ml horzBox.ml handlePdf.ml fontInfo.ml base85.ml mutableSet.ml - $(OCBFLAGS) pageBreak.native - -all: - cp external/camlpdf/*.c ./ - cp external/camlpdf/*.h ./ -# $(CFLAGS) flatestubs.c -# $(CFLAGS) rijndael-alg-fst.c -# $(CFLAGS) stubs-aes.c -# $(CFLAGS) miniz.c -# $(CFLAGS) sha2.c -# $(CFLAGS) stubs-sha2.c -# ocamlc -c external/camlpdf/flatestubs.c -# ocamlc -c external/camlpdf/rijndael-alg-fst.c -# ocamlc -c external/camlpdf/stubs-aes.c -# ocamlc -c external/camlpdf/miniz.c -# ocamlc -c external/camlpdf/sha2.c -# ocamlc -c external/camlpdf/stubs-sha2.c - mv *.c _build/ - mv *.h _build/ -# ocamlbuild -use-ocamlfind -use-menhir -tag thread -pkgs "core,ctypes,otfm" -lflags "external/camlpdf/flatestubs.o external/camlpdf/rijndael-alg-fst.o external/camlpdf/stubs-aes.o external/camlpdf/miniz.o external/camlpdf/sha2.o external/camlpdf/stubs-sha2.o" -I external/camlpdf/ pageBreak.native -# ocamlbuild -use-ocamlfind -use-menhir -tag thread -pkgs "core,ctypes,otfm" -lflags "flatestubs.o rijndael-alg-fst.o stubs-aes.o miniz.o sha2.o stubs-sha2.o" -no-hygiene -I external/camlpdf/ pageBreak.native - ocamlbuild -use-ocamlfind -use-menhir -tag thread -pkgs "core,ctypes,result,uutf" -lflags "flatestubs.c rijndael-alg-fst.c stubs-aes.c sha2.c stubs-sha2.c" -I external/camlpdf/ -I external/otfm/ pageBreak.native -# ocamlbuild -use-ocamlfind -use-menhir -tag thread -pkgs "core,ctypes,otfm" -no-hygiene -I external/camlpdf/ pageBreak.native diff --git a/src/backend/how-to-compile.md b/src/backend/how-to-compile.md deleted file mode 100644 index c728bb523..000000000 --- a/src/backend/how-to-compile.md +++ /dev/null @@ -1,3 +0,0 @@ -# How to Compile - -Type `ocamlbuild -use-ocamlfind pageBreak.native`. diff --git a/src/dune b/src/dune index 476e43ea2..7026fdd40 100644 --- a/src/dune +++ b/src/dune @@ -1,40 +1,48 @@ (library (name main) (public_name satysfi) - (flags (:standard -bin-annot -thread -safe-string)) - (libraries str - batteries - camlimages.core - camlimages.jpeg - camlimages.png - camlpdf - core_kernel - core_kernel.pairing_heap - menhirLib - otfed - uutf - uunf - uunf.string - uuseg - uuseg.string - yojson-with-position - omd - ocamlgraph - ) - (preprocess (pps - ppx_deriving.show - )) - ) + (flags + (-w -3 -bin-annot -thread -safe-string)) + (libraries + str + batteries + camlimages.core + camlimages.jpeg + camlimages.png + camlpdf + core_kernel + core_kernel.pairing_heap + dune-build-info + menhirLib + otfed + uutf + uunf + uunf.string + uuseg + uuseg.string + yojson-with-position + omd + ocamlgraph) + (preprocess + (pps ppx_deriving.show))) ;; dune requires all the .ml/.mli files to be in the same directory as the jbuild. ;; https://github.com/ocaml/dune/issues/109 + (copy_files# backend/*.{ml,mli}) + (copy_files# text-mode/*.{ml,mli}) + (copy_files# md/*.{ml,mli}) + (copy_files# chardecoder/*.{ml,mli}) -(copy_files chardecoder/*.{mll,mly}) + +(copy_files chardecoder/*.{mll,mly}) + (copy_files# frontend/*.{ml,mli}) -(copy_files frontend/*.{mll,mly}) + +(copy_files frontend/*.{mll,mly}) + (copy_files# frontend/bytecomp/*.{ml,mli}) (ocamllex @@ -42,89 +50,139 @@ (menhir (modules parser dataParser) - (flags (--table --explain))) - -(rule - (targets version.ml) - (deps ../tools/genversion/genversion.exe (:src ../satysfi.opam)) - (action (with-stdout-to %{targets} (run %{deps})))) + (flags + (--table --explain))) (rule (targets types.ml) - (deps (:src types.cppo.ml) __insttype.gen.ml __attype.gen.ml __codetype.gen.ml __unliftcode.gen.ml) - (action (run %{bin:cppo} %{src} -o %{targets}))) + (deps + (:src types.cppo.ml) + __insttype.gen.ml + __attype.gen.ml + __codetype.gen.ml + __unliftcode.gen.ml) + (action + (run %{bin:cppo} %{src} -o %{targets}))) (rule (targets vm.ml) - (deps (:src vm.cppo.ml) __vm.gen.ml) - (action (run %{bin:cppo} %{src} -o %{targets}))) + (deps + (:src vm.cppo.ml) + __vm.gen.ml) + (action + (run %{bin:cppo} %{src} -o %{targets}))) (rule (targets ir.ml) - (deps (:src ir.cppo.ml) __ir_0.gen.ml __ir_1.gen.ml) - (action (run %{bin:cppo} %{src} -o %{targets}))) + (deps + (:src ir.cppo.ml) + __ir_0.gen.ml + __ir_1.gen.ml) + (action + (run %{bin:cppo} %{src} -o %{targets}))) (rule (targets evaluator.ml) - (deps (:src evaluator.cppo.ml) __evaluator_0.gen.ml __evaluator_1.gen.ml) - (action (run %{bin:cppo} %{src} -o %{targets}))) + (deps + (:src evaluator.cppo.ml) + __evaluator_0.gen.ml + __evaluator_1.gen.ml) + (action + (run %{bin:cppo} %{src} -o %{targets}))) (rule (targets primitives.ml) - (deps (:src primitives.cppo.ml) __primitives_pdf_mode.gen.ml __primitives_text_mode.gen.ml) - (action (run %{bin:cppo} %{src} -o %{targets}))) + (deps + (:src primitives.cppo.ml) + __primitives_pdf_mode.gen.ml + __primitives_text_mode.gen.ml) + (action + (run %{bin:cppo} %{src} -o %{targets}))) (rule (targets __attype.gen.ml) (deps ../tools/gencode/gencode.exe) - (action (with-stdout-to %{targets} (run %{deps} --gen-attype)))) + (action + (with-stdout-to + %{targets} + (run %{deps} --gen-attype)))) (rule (targets __insttype.gen.ml) (deps ../tools/gencode/gencode.exe) - (action (with-stdout-to %{targets} (run %{deps} --gen-insttype)))) + (action + (with-stdout-to + %{targets} + (run %{deps} --gen-insttype)))) (rule (targets __codetype.gen.ml) (deps ../tools/gencode/gencode.exe) - (action (with-stdout-to %{targets} (run %{deps} --gen-codetype)))) + (action + (with-stdout-to + %{targets} + (run %{deps} --gen-codetype)))) (rule (targets __unliftcode.gen.ml) (deps ../tools/gencode/gencode.exe) - (action (with-stdout-to %{targets} (run %{deps} --gen-unliftcode)))) + (action + (with-stdout-to + %{targets} + (run %{deps} --gen-unliftcode)))) (rule (targets __vm.gen.ml) (deps ../tools/gencode/gencode.exe) - (action (with-stdout-to %{targets} (run %{deps} --gen-vm)))) + (action + (with-stdout-to + %{targets} + (run %{deps} --gen-vm)))) (rule (targets __ir_0.gen.ml) (deps ../tools/gencode/gencode.exe) - (action (with-stdout-to %{targets} (run %{deps} --gen-ir-0)))) + (action + (with-stdout-to + %{targets} + (run %{deps} --gen-ir-0)))) (rule (targets __ir_1.gen.ml) (deps ../tools/gencode/gencode.exe) - (action (with-stdout-to %{targets} (run %{deps} --gen-ir-1)))) + (action + (with-stdout-to + %{targets} + (run %{deps} --gen-ir-1)))) (rule (targets __evaluator_0.gen.ml) (deps ../tools/gencode/gencode.exe) - (action (with-stdout-to %{targets} (run %{deps} --gen-interps-0)))) + (action + (with-stdout-to + %{targets} + (run %{deps} --gen-interps-0)))) (rule (targets __evaluator_1.gen.ml) (deps ../tools/gencode/gencode.exe) - (action (with-stdout-to %{targets} (run %{deps} --gen-interps-1)))) + (action + (with-stdout-to + %{targets} + (run %{deps} --gen-interps-1)))) (rule (targets __primitives_pdf_mode.gen.ml) (deps ../tools/gencode/gencode.exe) - (action (with-stdout-to %{targets} (run %{deps} --gen-pdf-mode-prims)))) + (action + (with-stdout-to + %{targets} + (run %{deps} --gen-pdf-mode-prims)))) (rule (targets __primitives_text_mode.gen.ml) (deps ../tools/gencode/gencode.exe) - (action (with-stdout-to %{targets} (run %{deps} --gen-text-mode-prims)))) + (action + (with-stdout-to + %{targets} + (run %{deps} --gen-text-mode-prims)))) diff --git a/src/frontend/evaluator.cppo.ml b/src/frontend/evaluator.cppo.ml index e67d6ff59..100c7af58 100644 --- a/src/frontend/evaluator.cppo.ml +++ b/src/frontend/evaluator.cppo.ml @@ -566,6 +566,37 @@ and interpret_1 (env : environment) (ast : abstract_tree) : code_value = | PrimitiveTuple(asts) -> let codes = asts |> TupleList.map (interpret_1 env) in CdTuple(codes) +(* + | Module(ast1, ast2) -> + let (code1, envopt1) = interpret_1 env ast1 in + begin + match envopt1 with + | Some(env) -> + let (code2, envopt2) = interpret_1 env ast2 in + (CdModule(code1, code2), envopt2) + + | None -> + report_bug_ast "not a module contents" ast + end + + | BackendMathList(astlst) -> + let codelst = astlst |> List.map (interpret_1_value env) in + return @@ CdMathList(codelst) + + | PrimitiveTuple(astlst) -> + let codelst = List.map (interpret_1_value env) astlst in + (* -- should be left-to-right -- *) + return @@ CdTuple(codelst) + + | Path(astpt0, pathcomplst, cycleopt) -> + let (codept0, _) = interpret_1 env astpt0 in + let cdpathcomplst = pathcomplst |> List.map (map_path_component (interpret_1_value env) (interpret_1_value env)) in + let cdcycleopt = + cycleopt |> Option.map (map_path_component (interpret_1_value env) (fun () -> ()) + ) + in + return @@ CdPath(codept0, cdpathcomplst, cdcycleopt) +*) | Prev(ast1) -> let value1 = interpret_0 env ast1 in diff --git a/src/frontend/types.cppo.ml b/src/frontend/types.cppo.ml index cebe8b65c..bc3d41b54 100644 --- a/src/frontend/types.cppo.ml +++ b/src/frontend/types.cppo.ml @@ -1374,6 +1374,35 @@ let rec unlift_code (code : code_value) : abstract_tree = | CdConstructor(constrnm, code1) -> NonValueConstructor(constrnm, aux code1) | CdTuple(codes) -> PrimitiveTuple(TupleList.map aux codes) #include "__unliftcode.gen.ml" + +(* + and aux_letrec_binding (CdLetRecBinding(symb, cdpatbr)) = + LetRecBinding(CodeSymbol.unlift symb, aux_pattern_branch cdpatbr) + + and aux_pattern_branch = function + | CdPatternBranch(cdpat, code) -> PatternBranch(aux_pattern cdpat, aux code) + | CdPatternBranchWhen(cdpat, code, codeB) -> PatternBranchWhen(aux_pattern cdpat, aux code, aux codeB) + + and aux_pattern = function + | CdPUnitConstant -> PUnitConstant + | CdPBooleanConstant(b) -> PBooleanConstant(b) + | CdPIntegerConstant(n) -> PIntegerConstant(n) + | CdPStringConstant(s) -> PStringConstant(s) + | CdPListCons(cdpat1, cdpat2) -> PListCons(aux_pattern cdpat1, aux_pattern cdpat2) + | CdPEndOfList -> PEndOfList + | CdPTuple(cdpats) -> PTuple(List.map aux_pattern cdpats) + | CdPWildCard -> PWildCard + | CdPVariable(symb) -> PVariable(CodeSymbol.unlift symb) + | CdPAsVariable(symb, cdpat) -> PAsVariable(CodeSymbol.unlift symb, aux_pattern cdpat) + | CdPConstructor(ctor, cdpat) -> PConstructor(ctor, aux_pattern cdpat) + + and aux_path cdpath = + List.map (map_path_component aux aux) cdpath + + and aux_cycle cdcycleopt = + cdcycleopt |> Option.map (map_path_component aux (fun () -> ())) + +*) in aux code diff --git a/src/myYojsonUtil.ml b/src/myYojsonUtil.ml index ac484f47f..bfc650846 100644 --- a/src/myYojsonUtil.ml +++ b/src/myYojsonUtil.ml @@ -18,7 +18,7 @@ let syntax_error srcpath msg = let make_range (pos : Yojson.position) = let open Yojson in - let fname = BatOption.default "(none)" pos.file_name in + let fname = Option.value ~default:"(none)" pos.file_name in Range.make_large fname pos.start_line pos.start_column pos.end_line pos.end_column diff --git a/src/version.ml b/src/version.ml new file mode 100644 index 000000000..a037540df --- /dev/null +++ b/src/version.ml @@ -0,0 +1,4 @@ +let version = + match Build_info.V1.version () with + | None -> "dev" + | Some v -> Build_info.V1.Version.to_string v diff --git a/temp/.gitignore b/temp/.gitignore deleted file mode 100644 index a872f3e09..000000000 --- a/temp/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.zip -latinmodern-math-1959/ -IPAexfont00301/ diff --git a/test/parsing/dune b/test/parsing/dune index 0e21d55cb..6cbffc585 100644 --- a/test/parsing/dune +++ b/test/parsing/dune @@ -1,26 +1,29 @@ (rule (targets parser.output) (deps - "nx.saty" - "variants.saty" - "txprod.saty" - "txlist.saty" - "txrecord.saty" - "pats.saty" - "pattuple.saty" - "patlist.saty" - "sxlist.saty" - "mathlist.saty" - "toplevel.saty" - ) + "nx.saty" + "variants.saty" + "txprod.saty" + "txlist.saty" + "txrecord.saty" + "pats.saty" + "pattuple.saty" + "patlist.saty" + "sxlist.saty" + "mathlist.saty" + "toplevel.saty") (action - (with-stdout-to parser.output (run ./parser_test.exe %{deps})))) + (with-stdout-to + parser.output + (run ./parser_test.exe %{deps})))) -(alias - (name runtest) - (action (diff parser.expected parser.output))) +(rule + (alias runtest) + (action + (diff parser.expected parser.output))) (executable (name parser_test) (libraries main core_kernel) - (preprocess (pps ppx_deriving.show))) + (preprocess + (pps ppx_deriving.show))) diff --git a/tools/gencode/dune-project b/tools/gencode/dune-project deleted file mode 100644 index de4fc2092..000000000 --- a/tools/gencode/dune-project +++ /dev/null @@ -1 +0,0 @@ -(lang dune 1.0) diff --git a/tools/genversion/dune b/tools/genversion/dune deleted file mode 100644 index abde6685f..000000000 --- a/tools/genversion/dune +++ /dev/null @@ -1,3 +0,0 @@ -(executable - (name genversion) - (libraries str)) diff --git a/tools/genversion/dune-project b/tools/genversion/dune-project deleted file mode 100644 index de4fc2092..000000000 --- a/tools/genversion/dune-project +++ /dev/null @@ -1 +0,0 @@ -(lang dune 1.0) diff --git a/tools/genversion/genversion.ml b/tools/genversion/genversion.ml deleted file mode 100644 index d4791f201..000000000 --- a/tools/genversion/genversion.ml +++ /dev/null @@ -1,21 +0,0 @@ -let version_regex = Str.regexp {|^version: ?"\([0-9]+\.[0-9]+\.[0-9]+\)"$|} - -let () = - let version = ref "" in - let opam_file_path = Sys.argv.(1) in - let channel_in = open_in opam_file_path in - let search_version () = - let cond = ref true in - while !cond do - let line = input_line channel_in in - try - let _ = Str.search_forward version_regex line 0 in - version := Str.matched_group 1 line; - cond := false - with Not_found -> - () - done - in - search_version (); - close_in channel_in; - print_endline ("let version = \"" ^ !version ^ "\"")