Code Monkey home page Code Monkey logo

leo-ard / ribbit-x86 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ift3065-ift6232/ribbit-x86

0.0 0.0 0.0 6.02 MB

A small and portable Scheme implementation with AOT and incremental compilers that fits in 4K. It supports closures, tail calls, first-class continuations and a REPL.

License: BSD 3-Clause "New" or "Revised" License

Makefile 2.41% C 3.62% Scheme 79.57% Python 1.64% JavaScript 1.29% HTML 0.79% Go 2.05% Shell 3.87% CMake 0.02% Haskell 0.03% Idris 4.60% Java 0.04% Ruby 0.02% Rust 0.03% Scala 0.02%

ribbit-x86's Introduction

Travail pratique en compilation de Léonard Oest O'Leary et Simon Jassen

Après maintes préripécies, nous avons réussi à bootstraper 2 fois le compilateur et à exécuter tous les tests.

Pour constater notre succès, il faut faire make test-bootstrap2, se faire une tasse de thé et attendre un bon 30 minutes.

Ribbit-x86

Usage

The Ribbit AOT compiler is written in Scheme and can be executed with Gambit, Guile or Chicken. It has been tested with Gambit v4.7.5 and above. For the best experience install Gambit from https://github.com/gambit/gambit .

The original Ribbit AOT compiler's source code is in a single file: src/rsc.scm . This Scheme file can be executed as a program with the Gambit, Guile or Chicken interpreters.

The file src/rsc-x86.scm contains the main part of the AOT compiler that targets x86 machine code.

Both the original and x86 AOT compilers can be executed using the src/rsc shell script, which has the additional -c option to select a specific build of the Ribbit AOT compiler which is useful for bootstrapping Ribbit.

Ribbit currently supports the target languages C, JavaScript, Python, Scheme and x86 machine code which are selectable with the compiler's -t option with c, js, py, scm, and x86 respectively. The compacted RVM code can be obtained with the target rvm which is the default.

The -m option causes a minification of the generated program. This requires a recent version of Gambit.

The -l option allows selecting the Scheme runtime library (located in the lib subdirectory). The min library has the fewest procedures and a REPL that supports the core Scheme forms only. The max library has most of the R4RS predefined procedures, except for file I/O. The max-tc library is like max but with run time type checking. The default is the max-tc library.

Here are a few examples:

Compile a hello world program to JavaScript and then execute it:

  $ echo "(display 'hello) (newline)" > hello.scm
  $ ./rsc -t js -l max hello.scm -o hello.js
  $ node hello.js
  hello

Compile the REPL to Python and then execute an expression:

  $ ./rsc -t py -l max repl-max.scm -o repl-max.py
  $ echo "(+ 1 (* 2 3))" | python3 repl-max.py
  > 7
  > 

Compile the REPL to x86 and then execute an expression:

  $ make rsc-x86.bundle.scm
  $ ./rsc -t x86 -l max repl-max.scm -o repl-max.s -c "gsi rsc-x86.bundle.scm"
  $ gcc repl-max.s -o repl-max.exe
  $ echo "(+ 1 (* 2 3))" | ./repl-max.exe
  > 7
  > 

ribbit-x86's People

Contributors

samuelyvon avatar feeley avatar leo-ard avatar janssensimon 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.