Indrek's home
|
Crystal Space
|
SableCC
|
JIT-PHP
|
JTLT
|
libCHMxx
|
SUSHI
|
Ephi
|
Varphi
|
AVR: timer
|
AVR: speakit
|
AVR: flashme
|
AVR: IR troll
|
Octave
|
Misc
|
Geiger
|
Battery
|
Scintillation
|
libfbm
|
Indrek's SableCC page
SableCC is a cool parser generator that generates LALR(1) based parsers in the Java language. Its approach to parser technology is extremely minimalistic and clean. This results in very readable and maintainable grammars as opposed to other systems (notably messy bison and alikes where code and grammar rules are mixed). I have created a system for SableCC to generate alternative output for other programming languages. Like C++ and C#. Of course this is not limited to only targeting languages. For example you can write a XSS or XSL stylesheet to generate an alternative tree walker. The system used to consist of three parts but that has changed now. All code has been intergrated into the SableCC and there is no longer dependencies on Apache Xalan. This release is built on the sablecc-3-beta.3 that contains the advanced AST transformation syntax developed by Komivi Agbakpem. There is not much documentation available, all you have are some examples on this site and elsewhere. Also note that beta.3 is quite different from beta.2 as it requires complete specification of AST target production operator and does not allow any ambiguities. See http://www.sablecc.org/ for more information. News
Installation Binary sablecc.altgen distribution file: sablecc-3-beta.3.altgen.20041114.zip. Installation should be exactly the same as for regular sablecc. You only need this file, it contains all of sablecc and the new output generation framework. Subversion repository to the source code:
Sablecc.altgen: svn://svn.sablecc.org/developers/indrek/sandbox/sablecc-indrek/ Please also read the README.altgen. Supported languages (backends)
Technology The development and evolution of alternative generation system:
Deprecated and old packages The alternative generation used to consist of multiple packages and was built on Apache Xalan-Java to get XSL support. That has changed now but I'll provide links to the old stuff anyway for people who might want it. Most of it is either incorporated into the altgen sablecc package or rewritten/overriden by other solutions.
The newly developed SableCC version 3 introduces several new features. The most important of those is ability to specify transformation rules to create an AST (Abstract Syntax Tree) out of the more mundane default grammar tree (CST - Concerete Syntax Tree). This greatly reduces work needed to be carried out by the programmer and also results in cleaner grammars. This is a simple example I threw together to get into the SableCC3 transformation magic. Here's the link to the complete example sablecc3example.tar.gz and you can view the example grammar inline: test.sablecc3.txt.
1 + 2 * 3 This took some work to get converted and tested (two days) from my college thesis project's plain SableCC grammar. It is a PHP language grammar. Oriented towards version 4. It's currently distributed under the GNU LGPL license. Get it here: php4sablecc-0.9e.tar.gz. And here's the grammar itself for a quick look: php4.sablecc3.txt. Note that the grammar has been updated to work with sablecc-3-beta.3.altgen.20040327 and later. The PHP4 grammar is also stored in the SableCC's subversion repository. If you're looking for bleeding edge or changes that have not made it to the release please check it out:
Here's the changelog:
Missing, incomplete or buggy parts:
Please note that you need a custom lexer class for the generated parser to function. You can find that in the archive.
<?php echo 'Hello, world!\n'; for ( $i = 1; $i < 10; $i++ ) echo $i; function func (&$b, $c = "wof") { return $c; } ?> |
|