Giter Site home page Giter Site logo

calroc / scheme2cps2c4py Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jtolio/scheme2cps2c4py

0.0 0.0 0.0 52 KB

A Scheme to CPS to C compiler in Python

Home Page: http://www.jtolds.com/projects/

License: MIT License

Python 99.98% Scheme 0.02%

scheme2cps2c4py's Introduction

python scheme compiler
jt olds

usage:
./compiler.py < input.scm > out.c
./compiler.py --output=c < input.scm > out.c

alternatively:
./compiler.py --output=cps < input.scm > output.scm

other flags include
  --curry            if you want the intermediate representation to curry all
                     function calls, why you would i don't know
  --recursion_limit  if you are having trouble with call depth size of the
                     python interpreter.
  --nogc             disables usage of the boehm garbage collector
                     (not recommended)

the story so far:
 this is a scheme-to-c compiler written in python. it does not support all of
r5rs by any means (there aren't many valid data types besides integers. lists
aren't supported, for example (bwa?!)), but it is a definitely solid starting
point.
 the biggest novelty of this compiler is that it compiles by first transforming
scheme to continuation-passing-style, which means that call/cc actually does
work.
 i wrote this for advanced compilers (cs6470) with matt might (matt.might.net)
at utah.edu. it was a tight schedule and i barely made it, so the documentation
is poor, and there are two intermediate representations (instead of fixing the
initial ir once i realized it was broken, i just wrote a quick translator for
the ir instead of rewriting the other code).
 at some point i definitely hope to clean this up.

scheme2cps2c4py's People

Contributors

calroc avatar jtolio avatar

scheme2cps2c4py's Issues

AssertionError

Having used 2to3 and black and compiling hello world, we encounter the first problem:

scheme2cps2c4py % ./compiler.py < hello.scm > hello.c
Traceback (most recent call last):
  File "/usr/home/sforman/src/scheme2cps2c4py/./compiler.py", line 7, in <module>
    main()
  File "/usr/home/sforman/src/scheme2cps2c4py/lib/compile.py", line 248, in main
    print(compile(sys.stdin))
  File "/usr/home/sforman/src/scheme2cps2c4py/lib/compile.py", line 164, in compile
    program = parse_program(input)
  File "/usr/home/sforman/src/scheme2cps2c4py/lib/compile.py", line 52, in parse_program
    return check_unbound(rename(cps_transform(tree)))
  File "/usr/home/sforman/src/scheme2cps2c4py/lib/compile.py", line 44, in check_unbound
    assert len(program.freeVariables()) == 0
AssertionError

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.