No description
Find a file
2024-07-11 15:19:22 +02:00
.github/workflows mac: last attempt 2024-07-11 15:19:22 +02:00
bench Improve pretty-printing of infixes 2020-12-11 18:06:33 +03:00
byterun crap code 2024-07-11 15:19:22 +02:00
gdb Added limitation section into the spec; fixed typo in spec; fixed .gdbinit 2021-02-25 08:40:44 +03:00
performance Fixed performance/Sort.lama 2022-10-25 02:57:51 +03:00
regression Uncommented interpretation tests 2024-07-11 15:19:22 +02:00
runtime Fix regex 2024-07-11 15:19:22 +02:00
spec Fixed spec 2023-03-12 05:28:12 +03:00
src Style refactorings for X86_64 2024-07-11 15:19:22 +02:00
stdlib Made compiler working on Linux too 2024-07-11 15:19:22 +02:00
tools README spelling 2020-12-31 11:31:55 +03:00
tutorial Tutorial: fix compilation with locally compiled LaMa 2022-02-15 01:27:04 +03:00
.gitignore upd 2023-09-04 21:46:09 +02:00
.travis.yml Replace git-checkout with volume mounting from Travis sandbox 2018-03-06 17:41:06 +03:00
Changes Typos in Changes 2021-02-10 01:01:22 +03:00
dune-project move to dune; fix warnings 2023-09-04 21:43:28 +02:00
lama-spec.pdf Fixed spec 2023-03-12 05:28:12 +03:00
Lama.opam Made compiler working on Linux too 2024-07-11 15:19:22 +02:00
lama.png Better md 2020-02-18 14:04:25 +03:00
lama.svg Use SVG LaMa icon instead of PNG 2022-02-15 00:49:53 +03:00
LICENSE Add GPLv3 license 2021-02-12 19:36:25 +00:00
Makefile Fix regex 2024-07-11 15:19:22 +02:00
README.md add changelog ) 2023-10-04 09:56:31 +02:00

Lama 1.2
Lama 1.2

Lama

lama 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. Its general characteristics are:

  • procedural with first-class functions - functions can be passed as arguments, placed in data structures, returned and "constructed" at runtime via closure mechanism;
  • with lexical static scoping;
  • strict - all arguments of function application are evaluated before a function body;
  • imperative - variables can be re-assigned, function calls can have side effects;
  • untyped - no static type checking is performed;
  • with S-expressions and pattern-matching;
  • with user-defined infix operators, including those defined in local scopes;
  • with automatic memory management (garbage collection).

The name lama is an acronym for Lambda-Algol since the language has borrowed the syntactic shape of operators from Algol-68; Haskell and OCaml can be mentioned as other languages of inspiration.

The main purpose of lama 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. 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 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. 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

The language specification can be found here.

Installation

Supported target: GNU/Linux x86_32 (x86_64 by running 32-bit mode)

Mac users should use either a virtual machine or docker with a Linux distributive inside.

Windows users should get Windows Subsystem for Linux a.k.a WSL (recommended) or cygwin. Ubuntu-based variant of WSL is recommended.

  • System-wide prerequisites:

    • gcc-multilib

      For example, (for Debian-based GNU/Linux):

      $ sudo apt install gcc-multilib
      

      On some versions, you need to install the additional package lib32gcc-9-dev in case of errors like

      /usr/bin/ld: cannot find -lgcc
      /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a when searching for -lgcc
      
    • opam (>= 2.0.4)

    • OCaml (>= 4.10.1). Optional because it can be easily installed through opam. Compiler variant with flambda switch is recommended.

  • Check that opam is installed (using commands which opam or opam --version)

Installation guide

  1. Install the right switch for the OCaml compiler

    # 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:

      • opam switch create is a subcommand to create a new switch
      • ocaml-variants.4.10.1+flambda 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)

    $ export OPAMSWITCH=lama
    $ eval $(opam env)
    
    • 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
    Standard library directory: /home/user/.opam/lama/lib/ocaml
    
  3. Pin Lama package using opam and right URL (remember of "#" being a comment character in various shells)

    $ opam pin add Lama https://github.com/PLTools/Lama.git\#1.2 --no-action
    

    The extra '#' sign is added because in various Shells it is the start of a comment

  4. Install dependencies on system-wide external packages and lama itself after that.

    $ opam depext Lama --yes
    $ opam install Lama --yes
    
  5. Check that lamac executable was installed: which lamac should answer with

    /home/<USER>/.opam/lama/bin/lamac
    

Smoke-testing (optional)

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

Changes in Lama 1.2