UniCC is a target-language independent parser generator.
UniCC (UNIversal Compiler Compiler) is a LALR(1) parser generator. It compiles an augmented grammar definition into a program source code that parses that grammar. Parsing is the process of transferring input matching a particular grammar, like e.g. a source code written in a programming language, into a well-formed data structure. Because UniCC is intended to be target-language independent, it can be configured via template definition files to emit parsers in nearly any programming language.
UniCC supports parser code generation for the following programming languages so far:
More target languages can easily be added by creating specific target language templates.
This is the full definition for a four-function arithmetic syntax including their integer calculation semantics (in C).
#!language "C"; // <- target language!
#whitespaces ' \t';
#lexeme int;
#default action [* @@ = @1 *];
#left '+' '-';
#left '*' '/';
//Defining the grammar
calc$ : expr [* printf( "= %d\n", @expr ) *]
;
expr : expr '+' expr [* @@ = @1 + @3 *]
| expr '-' expr [* @@ = @1 - @3 *]
| expr '*' expr [* @@ = @1 * @3 *]
| expr '/' expr [* @@ = @1 / @3 *]
| '(' expr ')' [* @@ = @2 *]
| int
;
int : '0-9' [* @@ = @1 - '0' *]
| int '0-9' [* @@ = @int * 10 + @2 - '0' *]
;
To build and run this example, do
$ unicc expr.par
$ cc -o expr expr.c
$ ./expr -sl
3*10-(2*4)+1
= 23
More real-world examples for parsers implemented with UniCC can are xpl and rapidbatch, or can be found in the examples-folder.
UniCC features the following features, tools and possibilities.
The UniCC User's Manual is the official documentation of the UniCC Parser Generator. Download it for free here.
UniCC can be build and installed like any GNU-style program, with
./configure
make
make install
Previously, the Phorward Toolkit must be compiled and installed, because UniCC depends on it.
Contributions, ideas, concepts and code is always welcome!
Please feel free to contact us if you have any questions.
UniCC is developed and maintained by Jan Max Meyer, Phorward Software Technologies.
Some other projects by the author are:
This software is an open source project released under the terms and conditions of the 3-clause BSD license. See the LICENSE file for more information.
Copyright (C) 2006-2017 by Phorward Software Technologies, Jan Max Meyer.
You may use, modify and distribute this software under the terms and conditions of the 3-clause BSD license. The full license terms can be obtained from the file LICENSE.