Coder Social home page Coder Social logo

azimmuradov / miniml-compiler-haskell-spbu Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 471 KB

MiniML compiler written in Haskell

Home Page: https://azimmuradov.github.io/miniml-compiler-haskell-spbu/

License: MIT License

Haskell 82.75% OCaml 1.22% C 4.89% LLVM 11.14%
compiler haskell mini-ml miniml spbu llvm

miniml-compiler-haskell-spbu's Introduction

MiniML Compiler

MiniML is a minimal dialect of ML (Meta Language).

Note

Work In Progress

See supported features and CLI app docs.

Supported Features

  • Basic data types (unit, bool, int, 'a -> 'b)
  • Basic literals (true, false, decimal integers)
  • Basic boolean operators (&&, ||) and arithmetic operators (+, -, *, /)
  • Comparison operators (=, <>, <, <=, >, >=)
  • Unary operators (-)
  • Standard library
    • not : bool -> bool
    • print_bool : bool -> unit
    • print_int : int -> unit
  • Anonymous functions (fun a b -> a + b)
  • Functions and recursive functions declarations, let-bindings (let f x = x * x, let rec f x = x * f x, let x = 42)
  • Top-level expressions
  • Type annotations (let int_eq (a : int) (b : int) = a = b)
  • Let expressions (let f x = x * x in ..., let rec f x = x * f x in ..., let x = 42 in ...)
  • Currying
  • Conditionals (if x > 15 then x * 16 else x / 23)

Command-Line Interface Application

Examples of Usage

(* fibonacci.ml *)

let rec fib n =
  if n < 2
    then n
    else fib (n - 1) + fib (n - 2);;

print_int (fib 10)
$ miniml run fibonacci.ml
55
$ cat fibonacci.ml | miniml run
55
$ miniml compile fibonacci.ml
$ ./fibonacci.out
55
$ miniml compile fibonacci.ml -o "fib"
$ ./fib
55

Full Documentation

-- MiniML Runner & Compiler --

Usage: miniml COMMAND [-d|--debug]

  MiniML is a minimal dialect of ML (Meta Language)

Available options:
  -d,--debug               Execute in debug mode
  -h,--help                Show this help text

Available commands:
  run                      Run MiniML program
  compile                  Compile MiniML program to the provided target
Run MiniML program

Usage: miniml run [FILE]

  Run MiniML program

Available options:
  FILE                     Program file path (optional)
  -h,--help                Show this help text

Global options:
  -d,--debug               Execute in debug mode
Compile MiniML program

Usage: miniml compile [FILE] [-t|--target TARGET] [-o|--output OUTPUT]

  Compile MiniML program to the provided target

Available options:
  FILE                     Program file path (optional)
  -t,--target TARGET       Compilation target (binary|llvm-ir) (default: binary)
  -o,--output OUTPUT       Output file path (default: filename taken from the
                           MiniML program)
  -h,--help                Show this help text

Global options:
  -d,--debug               Execute in debug mode

Developer Documentation

Build Requirements

  • GHC: 9.4.8
  • Cabal: 3.8
  • LLVM: 17

miniml-compiler-haskell-spbu's People

Contributors

alexander-zadorozhnyy avatar azimmuradov avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

miniml-compiler-haskell-spbu's Issues

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.