GithubHelp home page GithubHelp logo

dkaznacheev / lama Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pltools/lama

0.0 1.0 0.0 15.88 MB

License: GNU General Public License v3.0

Makefile 1.89% OCaml 49.91% Shell 0.04% Assembly 0.88% C 15.31% Standard ML 0.01% TeX 31.54% GDB 0.04% M4 0.38%

lama's Introduction

Branch 1.10
Lama 1.10

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

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:

    • sudo apt install gcc-multilib (in Debian-based GNU/Linux)

      On some versions you need to install 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)

  • Install right switch for OCaml compiler

    opam switch create lama ocaml-variants.4.10.1+fp+flambda

    In above command:

    • opam switch create is a subcommand to create a new switch
    • ocaml-variants.4.10.1+fp+flambda is name of a standart template for the switch
    • lama is an alias for the switch being created; on success a directory $(HOME)/.opam/lama should be created
  • 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 OCaml compiler is now available in PATH: running which ocamlc should give /home/user/.opam/lama/bin/ocamlc (or similar) and ocamlc -v should give

    The OCaml compiler, version 4.10.1
    Standard library directory: /home/user/.opam/lama/lib/ocaml
    
  • Pin Lama package using opam and right URL (remember of "#" being a comment character in various shells)

    opam pin add Lama https://github.com/JetBrains-Research/Lama-devel.git\#1.10+ocaml4.10 --no-action

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

    opam depext Lama --yes
    opam install Lama --yes
    
  • Check that lamac exectuable was installed: which lamac should give

    /home/user/.opam/lama/bin/lamac
    

Smoke-testing (optional)

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

lama's People

Contributors

dboulytchev avatar anlun avatar kakadu avatar danyaberezun avatar agordeevw avatar xjie6 avatar kry127 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.