What's Caper?

Caper is a LALR(1) parser generator that generates modern and clean C++ code.

In addition, it can generate JavaScript, C#, D, Java, Boo, Ruby, PHP and Haxe parsers.

Check out News and History at Downloads page.

Japanese page is here.

Concept

You can mix the generated code into another project easily. The generated code looks like a handwritten parser.

Easy to use even for command analysis of a battle game!!

For example?

An input file like this:

%token Number<int> Add Sub Mul Div;
%namespace calc;
%dont_use_stl;

Expr<int> : [Identity] Term(0)
          | [MakeAdd] Expr(0) Add Term(1)
          | [MakeSub] Expr(0) Sub Term(1)
          ;

Term<int> : [Identity] Number(0)
          | [MakeMul] Term(0) Mul Number(1)
          | [MakeDiv] Term(0) Div Number(1)
          ;

generates an output file like this (implementation is omitted):

namespace calc {

enum Token {
    token_eof,
    token_Add,
    token_Div,
    token_Mul,
    token_Number,
    token_Sub,
};

template < class Value, class SemanticAction, int StackSize >
class Parser {
public:
    typedef Token token_type;
    typedef Value value_type;

public:
    Parser( SemanticAction& sa );

    void reset();
    bool post( token_type token, const value_type& value );
    bool accept( value_type& v );
    bool error();
};

} // namespace calc

Just include this one header file, and your application can use the parser.

For more details, see Turorials!