Coder Social home page Coder Social logo

gmh5225 / language-mlang Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moritzgoeckel/mlang

0.0 1.0 0.0 331 KB

๐Ÿ“‘๐Ÿš€ Programming language with full type inference that compiles to LLVM

CMake 2.26% C++ 95.22% MATLAB 1.01% Shell 0.11% C 0.07% LLVM 1.33%

language-mlang's Introduction

MLang

MLang is my strictly typed programming language with full type inference that compiles to LLVM. The language uses a custom recursive descent parser as the front-end and targets LLVM JIT as the backend. The project is tested with the google test framework. This is a multiplatform project targeting both Linux and Windows.

This language is build solely for fun and educational purposes, so maybe you should not use this in production ๐Ÿด

You can download the executables for Windows and Linux in the release section.

Features

  • Type inference
  • Strictly typed
  • Functions
  • Arithmetic operations
  • Boolean operations
  • Branching (if)
  • Loops (while)
  • Integer type
  • Boolean type
  • Float type
  • Operator precedence
  • Linux support
  • Windows support
  • Error reporting
  • Heap allocation
  • Arrays
  • Pointers
  • String type
  • Printing
  • Structs
  • Closures

Examples

For more examples refer to the mfiles folder

# Loops
let i = 0;
let j = 1;
while(i < 10){
    j = j * 2;
    i = i + 1;
}
ret j;
# Infix notation
let i = 1 + 2;
# Prefix notation
let j = +(1, 2);
# Functions
let f(x) = x + 2;
ret f(11);
# Multi-line functions
let f(x) = {
    let y = x + 2;
    ret y + 3;
};
ret f(10);
# Branching
let x = 1;
if(x < 3){
    ret true;
}
ret false;
# Operator precedence
let x = 3 + 10 + 6 / 3 - 2 * 5;
ret x; # is 5

Error reporting

Following you find an example on how parsing errors are reported to the user

Parsing failed:
Expecting ';' but found 'ret' @3:17

1:  let f(x) = {
2:      let y = x + 2
3:                  ^

Consider adding a semicolon to the end of the statement

Dependencies

  • LLVM
  • GTest

Getting started

You can find an installation guide in INSTALL.md

language-mlang's People

Contributors

moritzgoeckel avatar

Watchers

 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.