Git Product home page Git Product logo

programming-language-x's Introduction

Programming Language X

Programming Language X is a compiler written in C.

Current State

The compiler implements parsing, name resolution, type checking, and code generation for a limited number of programming language features and includes two backends: LLVM IR and WebAssembly.

Building

In order to build the compiler from source, CMake and a C compiler such as Clang or GCC is required. First, ensure these dependencies are installed on your system. Next, clone this repository and open a shell in the directory. Lastly, build the compiler by running the following commands:

mkdir build
cd build
cmake ..
cmake --build .

Syntax

Definitions

Define a constant.

const foo = 1;

Define a variable.

var foo = 1;

Declare a variable.

var foo: s32;

Define a function.

func foo(bar: s32) -> s32 {
  return bar;
}

Types

Integer types:

s8
s16
s32
s64
u8
u16
u32
u64

Floating point types:

f32
f64

Boolean type:

bool

Function types:

func (s32) -> s32

Array types:

[8]s32

Slice types:

[]s32

Examples

Add two integers.

func add(a: s32, b: s32) -> s32 {
  return a + b;
}

Fibonacci sequence.

func fib(n: s32) -> s32 {
  if n == 0 {
    return 0;
  } else if n == 1 or n == 2 {
    return 1;
  } else {
    return fib(n - 1) + fib(n - 2);
  }
}

programming-language-x's People

Contributors

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