Skip to content

marionauta/simple-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-compiler Travis Build Status

A simple compiler for a very simple toy language. This is a learning project that focuses on simplicity to keep things easy to understand. There will be things that could be done more efficiently, but that's not the point.

What I want is to write a little compiler with hopefully nothing more than Rust's standard library.

The language

I didn't name it, as that isn't important. The aim is to make a simple language that transpiles to C, making type definition a bit easier. This little snippet:

tipo Circulo(centro: Punto, radio: Real);
tipo Punto(x: Entero, y: Entero);

Will produce this output:

typedef struct Punto {
    long x;
    long y;
} Punto;

typedef struct Circulo {
    Punto centro;
    double radio;
} Circulo;

Note that the order in the input language doesn't matter, it will produce C code that compiles nicely.

Installing

To build simple-compiler you need:

  • Rust 1.31.0 or better.
  • Cargo

And just run cargo build --release

Inspiration

About

Very simple lexer, parser, semantic analyzer and compiler.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages