Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Compile-time metaprogramming for OCaml
OCaml Standard ML HTML Shell Python Makefile

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
back
cold
doc
examples
man
poly
src
test
tools
.gitignore
.ignore
.ocamlinit
LICENSE
Makefile
README.org
_tags
cb
dist
foo.itarget
g
hb
myocamlbuild.ml
re
reset_cold
snapshot
swap

README.org

The Programming Language Fan

Fan is a full blow programming language, it’s a superset of ocaml with Lisp-like macro’s features. It shares the same run-time with ocaml, so it’s 100% compatible with ocaml.

Why a new Programming Language?

We see that a lot of computer scientists are creating languages to target their domain, but creating a language is itself a domain, Fan is targeted at this domain. Yes, Fan is targeted to compiler domains. Fan aims to make creating a language easier.

There are some projects like Microsoft’s Rosyln which aims to make “Compiler as service”, but unlike Rosyln, we do not only expose the compiler API, but also we provide built-in language support to make those API easier to use instead, since for any non-trivial languages, the API is quite complex that average programmers will be frustrated ans move away.

Credits:

Fan is a successor to Camlp4, which was mainly developed by Daniel de Rauglaudre and Michel Mauny, and later was largely renovated by Nicolas Pouillard.

Unfortunately, though Camlp4 is a very powerful tool to program OCaml Ast and Extending OCaml language, Camlp4 is a really complex beast, that lately it grows out of control. Fan adopts some good ideas of Camlp4 and merges some new ideas.

Fan is way more faster than Camlp4, generally 100 times faster! and Fan has a very robust bootstrapping system compared with Camlp4.

Fan has all the features that Camlp4 has, and much more!

Status:

Designing a non-toy language is not easy, though Fan is already very powerful right now, but I have a bunch of ideas which take some time to implement, so it’s not usable now(mostly because some API is unstable ).

Contribution

Feel free to send me a pull request

Install

Requirements

Currently we depend on batteries and ocamlfind, but the dependency is quite loose, we will remove the dependency on them when polished

Initial Install

just type ./dist

What it mainly did

  • Start

    It will make cold/Fan.byte from original syntax This is mainly for the cold start(compile from the original syntax code). Actually all work is done.

  • Bootstrap

    Using the generated binary to preprocess the revised syntax to verify Fan reaches a fix point now.

If it reaches fix point, then it succeeds. You can also test hb Fan.native for fun!

Develop

Everytime, you made some nontrival changes(change the grammar, lexer), make sure to type ./hb Fan.byte or ./hb Fan.native to verify it can be hot-bootstrapped.

Then type ./snapshot to snapshot your changes to cold.(This is for distribute purpose)

If there’s no bugs in src/Pprintast.ml, then it will work smoothly

Directory Structure

src

The main dev strcuture

cold

The mirror of src, for distribute purpose

For dev

the common practice is

./hb Fan.byte # verify
./snapshot # snapshot and verify again

Docs

It will be coming soon ;-)

Something went wrong with that request. Please try again.