Phorward Toolkit (libphorward)

Version 0.19.0 (2017) 
License BSD


phorward is a free toolkit for parser development, lexical analysis, regular expressions and more.

The toolkit is primarily a library, written in C, that provides an interface for defining, running and processing parsers, lexical anlyzers and regular expressions through a consistent and easy-to-use interface. The following example program defines a simple expressional language, runs a parser on it and prints the generated abstract syntax tree.

 #include <phorward.h> 

int main()
    pparse* parser;
    ppast*  ast;
    char*   input = "1+2*(3+4)+5";
    char*   end;

    parser = pp_create( 0,  "@int /[0-9]+/ ;"
                            "fact : int | '(' expr ')' ;"
                            "term : @mul( term '*' fact ) | fact ;"
                            "expr : @add( expr '+' term ) | term ;" );

    if( !pp_parse_to_ast( &ast, parser, input, &end ) )
        return 1; /* parse error */

    pp_ast_dump_short( stdout, ast );
    return 0;

It can easily be compiled with: cc -o example example.c -lphorward

Furthermore, the toolkit comes with a command-line tool serving testing and prototyping facilities. The following command call yields in an equivalent parser and its abstract syntax tree, althought some symbol names are shortened.

 $ pparse -e "1+2*(3+4)+5" -g "@int /[0-9]+/; f: int | '(' e ')'; t: @mul( t '*' f ) | f; e: @add( e '+' t ) | t;"

phorward also provides useful general-purpose extensions for C programming. This includes dynamic data structures (e.g. linked lists, hash-tables, stacks and arrays), extended string management functions and platform-independent, system-specific helper functions.


phorward provides the following features:

Please check out continuously to get latest news, documentation, updates and support on the Phorward Toolkit.

Development Note

The Phorward Toolkit is under heavy development and will be entirely documented soon. The current documentation stub (unfinished!) can already be viewed here!

Building / Setup

Setup instructions can be obtained from the README-file of the project.


The Phorward Foundation Libraries can be used, modified and distributed under the BSD open source license.