Skip to content
πŸš€ Language implementation in C# using LLVM
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Missing spaces May 2, 2019
.vscode Move .vscode folder to top-level Apr 14, 2019
Ion.Tests Use wrappers to simplify tests May 18, 2019
Ion Use StatementParser within BlockParser, fix tests, fixes #28 May 17, 2019
.gitignore
README.md Finish technology stack message May 18, 2019
ion.sln Rename solution project name May 2, 2019

README.md

Ion language

A language implemented in C# using LLVM 5.0 bindings.

What is Ion? Ion is a high-level (and low-level), strongly-typed language implemented using the LLVM project, currently undergoing early development.

What is the purpose of this project? A research project. The purpose of this language is to serve as the basis for learning, and experimenting with compiler design. However, the language is to be fully implemented and functional.

Why should I use Ion? If you're a fan of fast development, and simply want your development workflow to be smooth, yet rigid when necessary, Ion is a language for you.

How can I learn compiler design? We strongly recommend you start your journey into the mysterious and complex world of compiler design through this book. Wikipedia is also your best friend.

What is the technology stack used for this project? The C# language is the main language used to implement both the core compiler library (this repository) and the CLI utility. LLVM (using C# bindings) is used for code generation. NUnit is used for both compiler and CLI tests, although a partial custom testing framework (based upon NUnit) is currently being implemented in order to satisfy the specific unit testing needs of the projects.

File extension: .ion

Installation

Head over to the releases page on the CLI utility's repository to get your installer!

View releases

Getting started

Make sure you have Ion installed on your machine at this point.

Windows

Use the following instructions to initialize and run a project in Windows.

cmd> mkdir myproject
cmd> cd myproject
cmd> ion init
cmd> mkdir Src
cmd> notepad Src/main.ion

Paste the following source code:

extern int printf(string, ...);

int main()
{
    printf("Hello world!");

    return 0;
}

Now, save your file and close the Notepad editor.

You're now ready to run your program! Use the following command to compile & run your program:

cmd> ion run

Linux

Use the following instructions to initialize and run a project in Linux.

$ mkdir myproject
$ cd myproject
$ ion init
$ mkdir Src
$ nano Src/main.ion

Paste the following source code:

extern int printf(string, ...);

int main()
{
    printf("Hello world!");

    return 0;
}

Now, save your file by pressing CTRL + X, then pressing Y and finally ENTER.

You're now ready to run your program! Use the following command to compile & run your program:

$ ion run

Core principles

  1. Simplicity. The language should be simple, or as powerful as the programmer wishes. This means that some symbols and patterns are optional and infered by the compiler.

  2. Flexible. The language should contain tools and shortcuts to make the programming experience smooth, not rigid. Pipes are the best example of a planned feature that will add flexibility in the development environment.

An example usage of pipes:

...
"Hello %s", "world!" | printf;

// Is equivalent to:

printf("Hello %s", "world!");
...
  1. Built-in DOM support.

Inspired by React.js' JSX syntax, the language will have built-in DOM and HTML support.

int main() 
{
    Web.Mount(<div>Built-in HTML syntax is awesome!</div>);

    return 0;
}

This feature, along with decorators & anonymous functions, will come super handy when building APIs!

string @name = "John Doe";

[@Web.Route("/")]
void GetRoot() {
    return <p>Hello, {@name}.</p>; // Hello, John Doe.
}
  1. Portable.

Examples

Hello world

extern int printf(string message, ...);

int main()
{
    printf("Hello world!");

    return 0;
}

Fibonacci sequence algorithm implementation

int fibonacci(number)
{
    if (number <= 1)
    {
        return 1;
    }

    return fibonacci(number - 1) + fibonacci(number - 2);
}

Naming convention

Functions

All function names should be in PascalCase.

void main()
{
    //
}

Classes

Class names should be in PascalCase, and members in camelCase.

import Core.Console;

class Example
{
    pub string name = "John Doe";

    void SayHello()
    {
        Console.Log("Hello, " + this.name);
    }
}

Attributes

Attributes are considered proxy functions, thus they should be treated as functions and be named in PascalCase.

[Transform(0)]
int main()
{
    // Return value will be transformed to '0'.
    return 1;
}
You can’t perform that action at this time.