Skip to content

Commit

Permalink
Merge branch '1.2' of https://github.com/PLTools/Lama into blonded04/…
Browse files Browse the repository at this point in the history
…readme-installation-fixes
  • Loading branch information
blonded04 committed Oct 12, 2023
2 parents 9de3e98 + 3b8c658 commit 1b91a66
Show file tree
Hide file tree
Showing 43 changed files with 5,286 additions and 3,501 deletions.
37 changes: 17 additions & 20 deletions .github/workflows/blank.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,37 @@
name: Build
name: Main workflow

on:
pull_request:
push:
paths-ignore:
- 'README.md'
branches:
- '1.10'

permissions: read-all

jobs:
build:
strategy:
fail-fast: false
matrix:
os:
#- macos-latest
- ubuntu-20.04
#- windows-latest
ocaml-version:
#- 4.11.0
- 4.10.1
#- 4.09.1
#- 4.08.1
- ubuntu-latest
ocaml-compiler:
- 4.13.1

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

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Use OCaml ${{ matrix.ocaml-version }}
uses: avsm/setup-ocaml@v1
- name: Checkout tree
uses: actions/checkout@v3

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

- run: opam pin add Lama.dev . --no-action
- run: opam depext Lama.dev --yes --with-test
- run: opam install . --deps-only --with-test
- run: opam exec -- make #dune build
- run: opam exec -- make regression # dune runtest
- run: eval $(opam env)
- run: opam exec -- make
- run: opam exec -- make regression-all
- run: opam exec -- make unit_tests
- run: opam exec -- make negative_scenarios_tests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
*.o
.merlin

.vscode
24 changes: 14 additions & 10 deletions Lama.opam
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
opam-version: "2.0"
version: "1.10"
version: "1.2"

synopsis: "Lama programming system"
synopsis: "Lama programming language"
maintainer: "[email protected]"
authors: "[email protected]"
homepage: "https://github.com/JetBrains-Research/Lama"
bug-reports: "https://github.com/JetBrains-Research/Lama/issues"
authors: [
"Dmitry Boulytchev <[email protected]>"
"Daniil Berezun <[email protected]>"
"Egor Sheremetov <[email protected]>"
]
homepage: "https://github.com/PLTools/Lama"
bug-reports: "https://github.com/PLTools/Lama/issues"

depends: [
"ocaml" { >= "4.07.1" }
"ocaml" { >= "4.13.1" }
"ocamlfind" { build }
"camlp5" { >= "8.00.05" }
"ostap" { >= "0.5"}
"GT" { >= "0.5.0" }
"GT" { >= "0.5.1" }
]

build: [
[make]
[make "regression"] {with-test}
[make "regression-all"] {with-test}
]
install: [make "install"]

depexts: [
["gcc-multilib"] {os-family = "debian"}
]

dev-repo: "git+https://github.com/JetBrains-Research/Lama.git"
dev-repo: "git+https://github.com/PLTools/Lama.git"
url {
src: "git+https://github.com/JetBrains-Research/Lama.git#1.10+ocaml4.10"
src: "git+https://github.com/PLTools/Lama.git#1.20"
}
22 changes: 20 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ all:
$(MAKE) -C runtime
$(MAKE) -C byterun
$(MAKE) -C stdlib
$(MAKE) -C runtime unit_tests.o
$(MAKE) -C runtime invariants_check.o
$(MAKE) -C runtime invariants_check_debug_print.o

STD_FILES=$(shell ls stdlib/*.[oi] stdlib/*.lama runtime/runtime.a runtime/Std.i)

Expand All @@ -21,13 +24,28 @@ uninstall:
$(RM) -r `opam var share`/Lama
$(RM) `opam var bin`/$(EXECUTABLE)

regression-all: regression regression-expressions

regression:
$(MAKE) clean check -C regression
$(MAKE) clean check -C stdlib/regression
$(MAKE) clean check -j8 -C regression
$(MAKE) clean check -j8 -C stdlib/regression

regression-expressions:
$(MAKE) clean check -j8 -C regression/expressions
$(MAKE) clean check -j8 -C regression/deep-expressions

unit_tests:
./runtime/unit_tests.o
./runtime/invariants_check.o
./runtime/invariants_check_debug_print.o

negative_scenarios_tests:
$(MAKE) -C runtime negative_tests

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
40 changes: 23 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
| Lama 1.10 | Lama-devel 1.10 |
| -------------------- | -------------------------- |
| [![Lama 1.10][1]][2] | [![Lama-devel 1.10][3]][4] |
| Lama 1.2 |
| ------------------- |
| [![Lama 1.2][1]][2] |

[1]: https://github.com/JetBrains-Research/Lama/workflows/Build/badge.svg?branch=1.10
[2]: https://github.com/JetBrains-Research/Lama/actions
[3]: https://github.com/JetBrains-Research/Lama-devel/workflows/Build/badge.svg?branch=1.10
[4]: https://github.com/JetBrains-Research/Lama-devel/actions
[1]: https://github.com/PLTools/Lama/workflows/Build/badge.svg?branch=1.10
[2]: https://github.com/PLTools/Lama/actions

# Lama

Expand All @@ -26,13 +24,13 @@ The name ![lama](lama.svg) is an acronym for *Lambda-Algol* since the language h

The main purpose of ![lama](lama.svg) is to present a repertoire of constructs with certain runtime behavior and relevant implementation techniques.
The lack of a type system (a vital feature for a real-world language
for software engineering) is an intensional decision that allows showing the unchained diversity of runtime behaviors, including those that a typical type system is called to prevent.
for software engineering) is an intensional decision that allows showing the unchained diversity of runtime behaviors, including those that a typical type system is called to prevent.
On the other hand the language can be used in the future as a raw substrate to apply various ways of software verification (including type systems).

The current implementation contains a native code compiler for **x86-32**, written in **OCaml**, a runtime library with garbage-collection support, written in **C**, and a small standard library, written in ![lama](lama.svg) itself.
The native code compiler uses **gcc** as a toolchain.

In addition, a source-level reference interpreter is implemented as well as a compiler to a small stack machine.
In addition, a source-level reference interpreter is implemented as well as a compiler to a small stack machine.
The stack machine code can in turn be either interpreted on a stack machine interpreter, or used as an intermediate representation by the native code compiler.

## Language Specification
Expand All @@ -51,9 +49,9 @@ Ubuntu-based variant of WSL is recommended.
* System-wide prerequisites:

- `gcc-multilib`

For example, (for Debian-based GNU/Linux):
```bash
```bash
$ sudo apt install gcc-multilib
```

Expand All @@ -73,10 +71,10 @@ 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
# for fresh opam
$ opam switch create lama --packages=ocaml-variants.4.14.0+options,ocaml-option-flambda
# for old opam
$ opam switch create lama ocaml-variants.4.10.1+flambda
# for fresh opam
$ opam switch create lama --packages=ocaml-variants.4.14.0+options,ocaml-option-flambda
# for old opam
$ opam switch create lama ocaml-variants.4.13.1+flambda
```

* In the above command:
Expand All @@ -100,7 +98,7 @@ Ubuntu-based variant of WSL is recommended.
3. Pin Lama package using `opam` and right URL (remember of "#" being a comment character in various shells)

```bash
$ opam pin add Lama https://github.com/JetBrains-Research/Lama.git\#1.10 --no-action
$ opam pin add Lama https://github.com/PLTools/Lama.git\#v1.2 --no-action
```

The extra '#' sign is added because in various Shells it is the start of a comment
Expand All @@ -120,5 +118,13 @@ Ubuntu-based variant of WSL is recommended.

### Smoke-testing (optional)

Clone the repository and run `make -C tutorial`.
Clone the repository and run `make -C tutorial`.
It should build a local compiler `src/lamac` and a few tutorial executables in `tutorial/`.

### Useful links

* [Plugin for VS Code](https://marketplace.visualstudio.com/items?itemName=arsavelev.lsp-lama)

### Changes in Lama 1.2

* New garbage collector: single-threaded stop-the-world `LISP2` (see GC Handbook for details: [1st edition](https://www.cs.kent.ac.uk/people/staff/rej/gcbook/), [2nd edition](http://gchandbook.org/)) [mark-compact](https://www.memorymanagement.org/glossary/m.html#term-mark-compact).
8 changes: 5 additions & 3 deletions byterun/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FLAGS=-m32 -g2 -fstack-protector-all

all: byterun.o
$(CC) -m32 -g -o byterun byterun.o ../runtime/runtime.a
$(CC) $(FLAGS) -o byterun byterun.o ../runtime/runtime.a

byterun.o: byterun.c
$(CC) -g -fstack-protector-all -m32 -c byterun.c
$(CC) $(FLAGS) -g -c byterun.c

clean:
$(RM) *.a *.o *~
$(RM) *.a *.o *~ byterun
3 changes: 3 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(lang dune 3.3)

(cram enable)
20 changes: 13 additions & 7 deletions regression/Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
TESTS=$(sort $(basename $(wildcard test*.lama)))
DEBUG_FILES=stack-dump-before data-dump-before extra-roots-dump-before heap-dump-before stack-dump-after data-dump-after extra-roots-dump-after heap-dump-after
TESTS=$(sort $(filter-out test111, $(basename $(wildcard test*.lama))))

LAMAC=../src/lamac

.PHONY: check $(TESTS)

check: $(TESTS)

check: ctest111 $(TESTS)

$(TESTS): %: %.lama
@echo $@
cat $@.input | LAMA=../runtime $(LAMAC) -i $< > $@.log && diff $@.log orig/$@.log
cat $@.input | LAMA=../runtime $(LAMAC) -ds -s $< > $@.log && diff $@.log orig/$@.log
LAMA=../runtime $(LAMAC) $< && cat $@.input | ./$@ > $@.log && diff $@.log orig/$@.log
@echo "regression/$@"
@cat $@.input | LAMA=../runtime $(LAMAC) -i $< > $@.log && diff $@.log orig/$@.log
@cat $@.input | LAMA=../runtime $(LAMAC) -ds -s $< > $@.log && diff $@.log orig/$@.log
@LAMA=../runtime $(LAMAC) $< && cat $@.input | ./$@ > $@.log && diff $@.log orig/$@.log

ctest111:
@echo "regression/test111"
@LAMA=../runtime $(LAMAC) test111.lama && cat test111.input | ./test111 > test111.log && diff test111.log orig/test111.log

clean:
$(RM) test*.log *.s *~ $(TESTS) *.i
$(RM) test*.log *.s *.sm *~ $(TESTS) *.i $(DEBUG_FILES) test111
$(MAKE) clean -C expressions
$(MAKE) clean -C deep-expressions
6 changes: 3 additions & 3 deletions regression/deep-expressions/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ LAMAC = ../../src/lamac
check: $(TESTS)

$(TESTS): %: %.lama
@echo $@
@echo "regression/deep-expressions/$@"
@LAMA=../../runtime $(LAMAC) $< && cat $@.input | ./$@ > $@.log && diff $@.log orig/$@.log
@cat $@.input | $(LAMAC) -i $< > $@.log && diff $@.log orig/$@.log
@cat $@.input | $(LAMAC) -s $< > $@.log && diff $@.log orig/$@.log
@cat $@.input | LAMA=../../runtime $(LAMAC) -i $< > $@.log && diff $@.log orig/$@.log
@cat $@.input | LAMA=../../runtime $(LAMAC) -s $< > $@.log && diff $@.log orig/$@.log

clean:
rm -f *.log *.s *~
Expand Down
6 changes: 3 additions & 3 deletions regression/expressions/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ RC = ../../src/lamac
check: $(TESTS)

$(TESTS): %: %.lama
@echo $@
@echo "regression/expressions/$@"
@LAMA=../../runtime $(RC) $< && cat $@.input | ./$@ > $@.log && diff $@.log orig/$@.log
@cat $@.input | $(RC) -i $< > $@.log && diff $@.log orig/$@.log
@cat $@.input | $(RC) -s $< > $@.log && diff $@.log orig/$@.log
@cat $@.input | LAMA=../../runtime $(RC) -i $< > $@.log && diff $@.log orig/$@.log
@cat $@.input | LAMA=../../runtime $(RC) -s $< > $@.log && diff $@.log orig/$@.log

clean:
rm -f *.log *.s *~
Expand Down
6 changes: 6 additions & 0 deletions regression/orig/test111.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
97
98
99
100
97
98
Empty file added regression/test111.input
Empty file.
21 changes: 21 additions & 0 deletions regression/test111.lama
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Std;

fun printString (s) {
var i;
for i := 0, i < s.length, i := i + 1 do
write (s[i])
od
}

fun printListConcat ( str_list ) {
printString (stringcat ( str_list ))
}

var l = { "a" , "b" , "c" , "d" };
printListConcat (l);

l := { "ab" };
printListConcat (l);

l := {};
printListConcat (l)
Loading

0 comments on commit 1b91a66

Please sign in to comment.