Phorward Toolkit (libphorward)

Version 0.21 (2017) 
v0.21 (source code) (more)
License BSD

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


Basically, phorward is a C-library, that provides many tools 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 "@int /[0-9]+/; f: int | '(' e ')'; t: @mul( t '*' f ) | f; e: @add( e '+' t ) | t;" "1+2*(3+4)+5"

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:

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.