evictor/phun


Phun -- PHP worth writing home about.

Language: ANTLR


Phun 0.6

Usage

TODO

Building the compiler

The Phun compiler is currently written in Java and Scala; not as strange as it sounds in light of the following:

  1. The lexicon and grammar are written in ANTLR 4, which at this time only supports lexer/parser generation into Java.
  2. When forced into the JVM, I prefer Scala which is millions of times better than Java. :)

There are two SBT projects, grammar and compiler. You must first compile and run the GrammarCompiler Scala app:

$ sbt grammar/compile
$ sbt grammar/run

What this does is bootstrap the ANTLR 4 Tool to compile Phun.g4—the Phun lexicon and grammar—into lexer and parser Java classes. Those Java classes are stuffed into the compiler project under src/main/java/com/phun/compiler/.

Then you can use SBT to compile the compiler project into a JAR:

$ sbt compiler/package

Here is a great StackOverflow post about how the compiler works with the generated lexer/parser.

Developing on the grammar (Phun.g4)

To ease development on the grammar, you can either use ANTLRWorks 2 or you can enter the following commands into SBT:

> project grammar
> ~ ; grammar/run; compiler/compile; compiler/run

This sets up a watch so that when you change Phun.g4, the following automatically happen:

  1. grammar is automatically recompiled (i.e. ANTLR v4 generates lexer and parser)
  2. compiler is recompiled with the new lexer/parser
  3. compiler is run in test mode.

Project Statistics

Sourcerank 2
Repository Size 152 KB
Stars 0
Forks 0
Watchers 1
Open issues 0
Dependencies 0
Contributors 1
Tags 0
Created
Last updated
Last pushed

Top Contributors See all

Ezekiel Victor

Something wrong with this page? Make a suggestion

Login to resync this repository