Skip to content

sacado/arc2c

Repository files navigation

                _
    .-.   --\  /    arc2c
   /   \  --/  \_

This is the Arc to C compiler.

Arc is the new Lisp from Paul Graham (http://arclanguage.org). It's official release is currently implemented as an interpreter above mzscheme.

Here, we are trying to make a compiler translating Arc code to C code, written in Arc. The goal is to see if (and how) a dynamically typed language conceived for exploratory programing and protoyping can be compiled efficiently. The current implementation is based on a tutorial proposed by Marc Feeley : The 90 Minute Scheme to C compiler (http://www.iro.umontreal.ca/~boucherd/mslug/meetings/20041020/minutes-en.html).

Currently, the compiler implements numerical operations on fixnums (+, -, *, <, >, <=, >=, is, isnt), comparison on symbols (is, isnt), comparison on characters (is, isnt), comparison and modification on strings (is, isnt, sref), annotations (type, rep, annotate) and cons cells construction, deconstruction and comparison (cons, car, cdr, is, isnt). All values can be printed with pr or prn. Unicode is supposed to be fully supported. The language supports first class continuations (with ccc) and is tail-recursive/tail-call-optimizing. Memory is managed via a home-made GC.

The let, set, sref, and fn syntaxes are partially implemented.  quote and if syntax are fully implemented. Symbols, numbers, and cons cells of symbols, numbers and cons cells can be quoted. Primitive operations cannot be overriden. If you call an undefined global function, the compiled program will silently crash (many but NOT all such errors are caught by the compiler). Some primitive operations expect certain type guarantees and do not check for correct types. There are probably bugs in every part of the program...

Use freely, at your own risk. If you want to improve the tool with us, send mail to sacado.sacado@gmail.com.

To use the compiler, in arc :

(load "arc2c.arc")
(compile-file "foo.arc")

Notes about the compiler's output code is available in the NOTES file.

About

Arc Lisp to C compiler

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published