Home

Awesome

🥭 Mango Language

📝 Mango is still under development

Introduction

Let's address the elephant in the room: why yet another programming language? Well, I don't really know, I just wanted to make a compiler. The language itself is just a byproduct of it.

This repository houses the compiler for Mango, a statically-typed, general-purpose programming language inspired by Python, Swift, C, C++, and Rust.

Mango Language

About

Mango is a compiled, statically-typed, general purpose programming language created as a byproduct of my passion project, the Mango compiler.

In creating Mango, I took inspiration from the syntax of Swift, C/C++, and Python type-hinting. The following example calculates the factorial of a 32-bit integer.

func factorial(i32 n) -> i32 {
  if (n == 0) {
    return 1;
  }
  return n * factorial(n-1);
}
Typing

As mentioned above, Mango is both statically and strongly typed which is mainly inspired by the type system Rust implements.

i8 x = 10;
i16 y = 356;

x + y;

Compiling this bit of code yields a TypeError because i8 and i16 are not the same type and therefore not compatible in a binary expression.

samples/types.mg -> [4,3]
  |
4 | x + y;
  | ^~~~~  
TypeError: i8 and i16 are not compatible in binary expression

Directory

StageModule
Lexical analysissrc/Lexer.cpp
Syntax analysissrc/Parser.cpp
Semantic analysissrc/visitors/ASTValidator.cpp
IR generationsrc/visitors/ASTCodegenner.cpp

Development Progress