Coder Social home page Coder Social logo

leaf-compiler's Introduction

Leaf Compiler

A compiler for an object-oriented, dynamically typed, general-purpose programming language that supports mathematical algebraic expressions (graphing expressions, integrals, derivatives), written in C. Includes a Pratt operator-precedence parser, bytecode assembler, bytecode virtual machine, bytecode disassembler, and a read-eval-print-loop.

Repl.it

Example 'Leaf' code

var x = sin(3.14);
print x;

Output: 0

fun fib(n) {
	if(n < 2) return n;
	return fib(n-2) + fib(n-1);
}

print fib(30);

Output: 832040

Instructions to run

You can either use your own Makefile or the one already here in this repo to run the program using make -s. After you've done that, it'll output to a file called main, so you can run ./main to use the read-eval-print-loop (REPL) or ./main filename.lilac to run a file.

Licensing

This uses the MIT License and follows Robert Nystrom's Clox implementation from his book Crafting Interpreters. It's an amazing book that has taught me most of what I know about compilers today, and if you haven't read it I really recommend it!

leaf-compiler's People

Contributors

reverie99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

hiperiondev

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.