C C++ Inno Setup Makefile Roff Awk Other
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples Added C++ example Apr 17, 2018
min_lalr1 min_lalr1 README fixed. Oct 22, 2017
packaging Issue #1, fixing some typos Dec 31, 2017
targets Python parser: Check for node in Node.dump() Jul 4, 2018
.gitattributes Added .gitattributes Mar 30, 2018
.gitignore Last changes v1.4 Apr 17, 2018
.travis.sh Adding travis build files. Sep 25, 2017
.travis.yml Use phorward v0.22 in travis build Apr 17, 2018
CHANGELOG.md Forgotten to update release date, now its there Apr 17, 2018
LICENSE Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
Makefile.am Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
Makefile.gnu Fixed #3, renamed unicc.1.man to unicc.man Mar 30, 2018
Makefile.in Last changes v1.4 Apr 17, 2018
README.md Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
aclocal.m4 Last changes v1.4 Apr 17, 2018
build.c Renaming functions p_ccl_* to pccl_* May 18, 2018
buildxml.c Renaming functions p_ccl_* to pccl_* May 18, 2018
compile Updating autotools build toolchain. Sep 9, 2016
configure Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
configure.ac Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
debug.c Renaming functions p_ccl_* to pccl_* May 18, 2018
depcomp Updating autotools build toolchain. Sep 9, 2016
error.c Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
first.c Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
install-sh Updating autotools build toolchain. Sep 9, 2016
integrity.c Renaming functions p_ccl_* to pccl_* May 18, 2018
lalr.c Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
lex.c Renaming functions p_ccl_* to pccl_* May 18, 2018
list.c Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
localenv.sh Either allow ":" for "->" in grammar definitions. Dec 6, 2017
main.c Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
mem.c Renaming functions p_ccl_* to pccl_* May 18, 2018
missing Updating autotools build toolchain. Sep 9, 2016
parse.c Renaming functions p_ccl_* to pccl_* May 18, 2018
parse.h Improving the code generator and updating targets Dec 13, 2017
parse.min Renaming functions p_ccl_* to pccl_* May 18, 2018
parse.par Renaming functions p_ccl_* to pccl_* May 18, 2018
proto.h Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
rewrite.c Renaming functions p_ccl_* to pccl_* May 18, 2018
string.c Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
unicc.dtd Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
unicc.h Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
unicc.man Fixed #3, renamed unicc.1.man to unicc.man Mar 30, 2018
unicc.t2t Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
utils.c Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
virtual.c Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
xml.c Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018
xml.h Updated READMEs, C++ & Python target to v1.0 Apr 17, 2018

README.md

UniCC Build Status

UniCC is a target-language independent parser generator.

About

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:

  • C is fully supported (and reference implementation),
  • C++ is well supported,
  • Python is well supported,
  • ECMAScript is prototyped, and may come soon.

More targets can easily be added by creating specific template files.

Example

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.

Features

UniCC features the following features, tools and possibilities.

  • Powerful BNF-based grammar definition language
  • Full unicode support
  • Build-in lexical analyzer
  • Grammar prototyping features
  • Abstract Syntax Tree notations
  • Virtual productions
  • Anonymous nonterminals
  • Semantically determined symbols
  • Two parser construction modes allow the use of different algorithmic approaches relating the whitespace handling
  • Target-language independent parser development
  • Template-based program-module generator and XML-based parser description file generator
  • Platform-independent (console-based)
  • Standard LALR(1) conflict resolution
  • Parser generation in C, C++ and Python so far

Documentation

The UniCC User's Manual is the official documentation of the UniCC Parser Generator. Download it for free here.

Installation

On Linux and OS X, 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.

Windows users may checkout the pre-built setup package that can be found on the Phorward download server at https://phorward.info/download/unicc.

Contributions

Contributions, ideas, concepts and code is always welcome! Please feel free to contact us if you have any questions.

Credits

UniCC is developed and maintained by Jan Max Meyer, Phorward Software Technologies.

Some other projects by the author are:

  • libphorward, a free toolkit for parser development, lexical analysis, regular expressions and more.
  • RapidBATCH, a scripting language.
  • pynetree, a light-weight parsing toolkit written in pure Python.
  • JS/CC, the JavaScript parser generator.

License

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-2018 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.