2020-02-18 14:07:39 +03:00
|
|
|
# Lama
|
2018-02-14 15:58:05 +03:00
|
|
|
|
2020-02-18 14:00:13 +03:00
|
|
|
 is a programming language developed by JetBrains Research for educational purposes as an exemplary language to introduce
|
2020-02-18 13:38:13 +03:00
|
|
|
the domain of programming languages, compilers and tools. Its general characteristics are:
|
2018-02-14 15:58:05 +03:00
|
|
|
|
2020-02-18 13:39:53 +03:00
|
|
|
* procedural with first-class functions - functions can be passed as arguments, placed in data structures,
|
|
|
|
|
returned and "constructed" at runtime via closure mechanism;
|
2020-02-18 13:38:13 +03:00
|
|
|
* with lexical static scoping;
|
2020-02-18 13:39:53 +03:00
|
|
|
* strict - all arguments of function application are evaluated before function body;
|
|
|
|
|
* imperative - variables can be re-assigned, function calls can have side effects;
|
|
|
|
|
* untyped - no static type checking is performed;
|
2020-02-18 13:38:13 +03:00
|
|
|
* with S-expressions and pattern-matching;
|
|
|
|
|
* with user-defined infix operators, including those defined in local scopes;
|
|
|
|
|
* with automatic memory management (garbage collection).
|
2018-02-14 15:58:05 +03:00
|
|
|
|
2020-02-18 14:08:39 +03:00
|
|
|
The name  is an acronym for *Lambda-Algol* since the language has borrowed the syntactic shape of
|
2020-02-18 13:38:13 +03:00
|
|
|
operators from **Algol-68**; [**Haskell**](www.haskell.org) and [**OCaml**](www.ocaml.org) can be
|
|
|
|
|
mentioned as other languages of inspiration.
|
|
|
|
|
|
2020-02-18 14:07:39 +03:00
|
|
|
The main purpose of  is to present a repertoire of constructs with certain runtime behavior and
|
2020-02-18 13:38:13 +03:00
|
|
|
relevant implementation techniques. The lack of a type system (a vital feature for a real-word language
|
|
|
|
|
for software engineering) is an intensional decision which allows to show the unchained diversity
|
|
|
|
|
of runtime behaviors, including those which a typical type system is called to prevent. On the other hand
|
|
|
|
|
the language can be used in future as a raw substrate to apply various ways of software verification (including
|
|
|
|
|
type systems) on.
|
|
|
|
|
|
|
|
|
|
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
|
2020-02-18 14:07:39 +03:00
|
|
|
standard library, written in  itself. The native code compiler uses **gcc** as a toolchain.
|
2020-02-18 13:38:13 +03:00
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
2020-02-19 20:11:58 +03:00
|
|
|
## Language Specification
|
|
|
|
|
|
|
|
|
|
The language specification can be found [here](lama-spec.pdf).
|
|
|
|
|
|
2020-02-18 13:38:13 +03:00
|
|
|
## Installation
|
|
|
|
|
|
|
|
|
|
Prerequisites:
|
|
|
|
|
|
|
|
|
|
* gcc-multilib
|
2020-02-26 15:43:42 +03:00
|
|
|
* ocaml (>= 4.07.1) [http://ocaml.org]
|
|
|
|
|
* opam (>= 2.0.4) [http://opam.ocaml.org]
|
2020-02-18 13:38:13 +03:00
|
|
|
|
|
|
|
|
Installing:
|
|
|
|
|
|
2020-02-19 20:13:37 +03:00
|
|
|
* `opam pin add -n ostap https://github.com/dboulytchev/ostap.git#memoCPS` (remember of "#" being a comment character in bash)
|
2020-02-19 15:30:33 +03:00
|
|
|
* `opam pin add -y lama https://github.com/JetBrains-Research/Lama.git`
|
|
|
|
|
|
2020-02-19 20:11:58 +03:00
|
|
|
Smoke-testing:
|
|
|
|
|
|
|
|
|
|
* `pushd tutorial`
|
|
|
|
|
* `make`
|
|
|
|
|
* `popd`
|
2020-02-19 15:30:33 +03:00
|
|
|
|
|
|
|
|
|