diff --git a/Lama.opam b/Lama.opam index b3d39c380..45f267708 100644 --- a/Lama.opam +++ b/Lama.opam @@ -1,6 +1,7 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -synopsis: "TODO" +synopsis: + "A programming language (initualy developed by JetBrains Research) for educational purposes as an exemplary language to introduce the domain of programming languages, compilers, and tools." depends: [ "dune" {>= "3.3"} "posix-uname" diff --git a/Makefile b/Makefile index 7df448f80..1fcd18921 100644 --- a/Makefile +++ b/Makefile @@ -1,48 +1,42 @@ -EXECUTABLE = src/lamac +.PHONY: all regression +.PHONY: clean test regression regression-expressions regression-all uninstall install build + INSTALL ?= install -v MKDIR ?= mkdir -BUILDDIR = build +BUILDDIR = _build -.PHONY: all regression -all: - $(MAKE) -C src - $(MAKE) -C runtime - $(MAKE) -C stdlib -STD_FILES=$(shell ls stdlib/*.[oi] stdlib/*.lama runtime/runtime.a runtime/Std.i) +all: dune test regression -build: all - mkdir -p $(BUILDDIR) - cp -r runtime/Std.i runtime/runtime.a stdlib/* src/lamac $(BUILDDIR) +build: dune b regression install: all - $(INSTALL) $(EXECUTABLE) `opam var bin` - $(MKDIR) -p `opam var share`/Lama - $(INSTALL) $(STD_FILES) `opam var share`/Lama/ + dune b @install --profile=release + dune install --profile=release + $(MKDIR) -p `opam var share`/Lama/x64 + $(INSTALL) $(shell ls _build/default/stdlib/x64/*.[oi] _build/default/stdlib/x64/stdlib/*.lama \ + runtime/runtime.a runtime/Std.i) \ + `opam var share`/Lama/x64 + $(MKDIR) -p `opam var share`/Lama/x32 + $(INSTALL) $(shell ls _build/default/stdlib/x32/*.[oi] _build/default/stdlib/x32/stdlib/*.lama \ + runtime32/runtime.a runtime32/Std.i) \ + `opam var share`/Lama/x32 uninstall: $(RM) -r `opam var share`/Lama - $(RM) `opam var bin`/$(EXECUTABLE) + dune uninstall + regression-all: regression regression-expressions +test: regression regression: - $(MAKE) clean check -j8 -C regression - $(MAKE) clean check -j8 -C stdlib/regression + dune test regression regression-expressions: - $(MAKE) clean check -j8 -C regression/expressions - $(MAKE) clean check -j8 -C regression/deep-expressions - -negative_scenarios_tests: - $(MAKE) -C runtime negative_tests + dune test regression_long clean: - $(MAKE) clean -C src - $(MAKE) clean -C runtime - $(MAKE) clean -C stdlib - $(MAKE) clean -C regression - $(MAKE) clean -C byterun - $(MAKE) clean -C bench - rm -rf $(BUILDDIR) + @dune clean + diff --git a/README.md b/README.md index 2b73398e3..d6faee5c2 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ # Lama -![lama](lama.svg) is a programming language developed by JetBrains Research for educational purposes as an exemplary language to introduce the domain of programming languages, compilers, and tools. +![lama](lama.svg) is a programming language (initualy developed by JetBrains Research) for educational purposes as an exemplary language to introduce the domain of programming languages, compilers, and tools. Its general characteristics are: * procedural with first-class functions - functions can be passed as arguments, placed in data structures, @@ -52,8 +52,8 @@ Ubuntu-based variant of WSL is recommended. sudo apt install gcc ``` - - MacOS: `clang` - + - MacOS: `clang` + Should be automatically installed with developer tools. - [opam](http://opam.ocaml.org) (>= 2.0.4) @@ -67,13 +67,13 @@ Ubuntu-based variant of WSL is recommended. 1. Install the right [switch](https://opam.ocaml.org/doc/Manual.html#Switches) for the OCaml compiler ```bash - opam switch create lama --packages=ocaml-variants.4.14.0+options,ocaml-option-flambda + opam switch create lama --packages=ocaml-variants.4.14.2+options,ocaml-option-flambda ``` * In the above command: - `opam switch create` is a subcommand to create a new switch - - `ocaml-variants.4.14.0+options` is the name of a standard template for the switch + - `ocaml-variants.4.14.2+options` is the name of a standard template for the switch - `lama` is an alias for the switch being created; on success a directory `$(HOME)/.opam/lama` should be created 2. Update PATH variable for the fresh switch. (You can add these commands to your `~/.bashrc` for convenience but they should be added by `opam`) @@ -83,7 +83,7 @@ Ubuntu-based variant of WSL is recommended. * Check that the OCaml compiler is now available in PATH by running `which ocamlc`; it should answer with `/home/user/.opam/lama/bin/ocamlc` (or similar) and `ocamlc -v` should answer with ``` - The OCaml compiler, version 4.10.1 + The OCaml compiler, version 4.14.2 Standard library directory: /home/user/.opam/lama/lib/ocaml ``` diff --git a/dune-project b/dune-project index a6817af70..e5384e0e1 100644 --- a/dune-project +++ b/dune-project @@ -6,8 +6,8 @@ (package (name Lama) - (allow_empty) - (synopsis "TODO") + (synopsis + "A programming language (initualy developed by JetBrains Research) for educational purposes as an exemplary language to introduce the domain of programming languages, compilers, and tools.") (depends posix-uname GT diff --git a/src/.ocamlformat-ignore b/src/.ocamlformat-ignore new file mode 100644 index 000000000..fb862a47b --- /dev/null +++ b/src/.ocamlformat-ignore @@ -0,0 +1 @@ +X86_32.ml \ No newline at end of file diff --git a/src/X86_32.ml b/src/X86_32.ml index ea0c88594..ed70a9241 100644 --- a/src/X86_32.ml +++ b/src/X86_32.ml @@ -1,6 +1,5 @@ open GT open Language -open SM (* X86 codegeneration interface *) @@ -241,7 +240,7 @@ let compile cmd env imports code = match instr with | PUBLIC name -> env#register_public name, [] | EXTERN name -> env#register_extern name, [] - | IMPORT name -> env, [] + | IMPORT _name -> env, [] | CLOSURE (name, closure) -> let pushr, popr = @@ -691,7 +690,7 @@ class env prg = (* tag hash: gets a hash for a string tag *) method hash tag = - let h = Pervasives.ref 0 in + let h = Stdlib.ref 0 in for i = 0 to min (String.length tag - 1) 4 do h := (!h lsl 6) lor (String.index chars tag.[i]) done; diff --git a/src/dune b/src/dune index 4c845da60..011251644 100644 --- a/src/dune +++ b/src/dune @@ -76,11 +76,9 @@ (executable (name Driver) + (public_name lamac) (flags - (:standard - -rectypes - ;-dsource - )) + (:standard -rectypes)) (modules Driver) (libraries liba unix)) diff --git a/stdlib/x32/dune b/stdlib/x32/dune index 521a7b7de..292c1620e 100644 --- a/stdlib/x32/dune +++ b/stdlib/x32/dune @@ -18,8 +18,8 @@ ../Timer.lama %{project_root}/src/Driver.exe) (targets - List.i - List.o + Array.i + Array.o Buffer.i Buffer.o Collection.i diff --git a/stdlib/x64/dune b/stdlib/x64/dune index 8f1ae615f..4d4f1fca5 100644 --- a/stdlib/x64/dune +++ b/stdlib/x64/dune @@ -2,7 +2,6 @@ (deps ../Makefile ../../runtime/Std.i - ../List.lama ../Array.lama ../Buffer.lama ../Collection.lama @@ -18,8 +17,8 @@ ../Timer.lama %{project_root}/src/Driver.exe) (targets - List.i - List.o + Array.i + Array.o Buffer.i Buffer.o Collection.i