Giter Club home page Giter Club logo

compiler's Introduction

compiler

Compiler for a C/Go/Jai inspired language, written in C99.

This is a hobby project for fun, I don't expect people to write real code with it. This is the result of countless attempts to create a functioning compiler over the last four years, you can find my very first attempt here.

Right now it only compiles on Linux, because I'm developing it under Windows Subsystem for Linux version 2. Just run /build.sh and it will spit out an ELF executable called lang, providing you have gcc installed on your Linux system.

Syntax example

#import "std/basic.lang"

// Type inference, same as:
//    msg: string = get_message();
msg := get_message();

proc main() {
    print(msg.data);
}

proc get_message(): string {
    return "Hello, world\n";
}

Progress

I consider this project pre-alpha software, it has some bugs, but it mostly works. I'm working towards the basic feature set of the language being implemented robustly, then I will move onto real additions, right now it's basically a skin over C.

I am actively developing this project (as of September 2020), but here's some notes on the current progress:

  • Currently outputting C code, this will change in the future.
  • The bytecode interpreter for compile-time code execution is not currently working at all. It has been #if'd out for the time being while I redesign it.
  • The lexer, parser, "resolver" (symbol resolution, expression-to-type evaluation, type inference) and checker (semantic and type checking) are fairly robust, though they most likely contain undiscovered bugs.

How the code is organized

  • /scratch: random files in the language itself which I use to test various aspects of the compiler, most of the code in here is nonsense and doesn't do anything lol.

  • /demos: actual functioning code which serves some purpose.

  • src/headers/: header files, this is where most of the types are declared.

  • src/headers/stb: headers from the public-domain libraries by Sean Barrett.

  • src/: actual C code, the file names should be self-explanatory, and each file has a comment describing what it contains at the very top.

compiler's People

Contributors

anthony-y avatar

Stargazers

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