Hime Parser Generator

Hime is a parser generator that targets .Net, Java and Rust. Hime relies on the LR family of parsing techniques, including the state of the art RNGLR algorithm for generalized LR parsing used for ambiguous grammars. Hime provides a powerful, expressive, and feature-rich grammar language with support for template syntactic rules, context-sensitive lexing (useful for contextal keywords), tree actions (useful for clean syntax trees), and more!

Downloads

Download Hime v3.4.0

Hime is also available through packet managers (NuGet, Maven, Cargo). Head to the Download page for more information.

Some features

grammar MathExp
{
    options
    {
        Axiom = "exp"; ? // the top variable for this grammar
        Separator = "SEPARATOR"; ? // the terminal that represent white space
    }
    terminals
    {
        fragment ? WHITE_SPACE -> U+0020 | U+0009 | U+000B | U+000C ? ;
        SEPARATOR -> WHITE_SPACE+ ;

        INTEGER -> [1-9] [0-9]* | '0' ;
        REAL -> INTEGER? '.' INTEGER  (('e' | 'E') ('+' | '-')? INTEGER)?
                    |  INTEGER ('e' | 'E') ('+' | '-')? INTEGER ;
        NUMBER -> INTEGER | REAL ;

        IDENTIFIER -> [_a-zA-Z] [_a-zA-Z0-9]* ;
        context my_context ?
        {
          // 'keyword' is a keyword only when 'my_context' is active, it remains a normal IDENTIFIER otherwise
          SOFT_KEYWORD -> 'keyword' ;
        }
    }
    rules
    {
        exp_atom   -> NUMBER^ ? @OnNumber
                    | '('! exp^ ')'! ?;
        exp_factor -> exp_atom^
                    |  exp_factor '*'^ exp_atom @OnMult
                    |  exp_factor '/'^ exp_atom @OnDiv;
        exp_term   -> exp_factor^
                    |  exp_term '+'^ exp_factor @OnPlus ?
                    |  exp_term '-'^ exp_factor @OnMinus;
        exp        -> exp_term^ ;
    }
}
The Axiom grammar option specifies the axiom variables, i.e. the top variable to be matched by the parser. Learn more
The Separator grammar option specifies the special terminal to be designated as matching presumably white space. Learn more
Lexical fragment are reusable bits of expression to be reused in the definition of more complex terminals. They are never matched by the lexer on their own. Learn more
Hime offers full Unicode support with the expression of any Unicode character, Unicode block, or Unicode character category.
Hime supports context-sensitive lexing, i.e. matching different terminals according to the parser's context. This is useful for the definition of contextual (soft) keywords, for example. Learn more
The '^' (promote) tree action modifies the produced syntax tree to puts the marked node as root of the sub-tree to be produced for the rule. See the tutorials for how to use tree actions, or head to the reference documentation
The '!' (drop) tree action removes from the syntax tree the marked node and its children, if any. See the tutorials for how to use tree actions, or head to the reference documentation
Semantic actions define callbacks to be executed by the parser when they are reached. See the tutorials for how to use semantic actions, or head to the reference documentation

Sources

Main repository for runtimes and SDK
Library of ready-to-use grammars
Language server for Hime grammars
Visual Studio Code extension for Hime grammars

License

The Hime parser generator and its redistributable runtimes are all provided under the LGPL v3 license.

History

  • August 2018 : Released version 3.4.0 with the support for visitor generation and bug fixes for the SDK.
  • May 2018 : Released version 3.3.2 with bug fixes for the SDK.
  • February 2018 : Released version 3.3.1 with bug fixes for Java and Rust.
  • January 2018 : Released version 3.3.0 with the support for a Rust runtime.
  • October 2017 : Update of the .Net and Java runtime and SDK to version 3.2.0 with support for .Net Standard and .Net Core.
  • September 2017 : Update of the .Net SDK to version 3.1.0 for the support of compilation options in grammars.
  • August 2017 : Update of the .Net SDK to version 3.0.1 for the support of Unicode 10.
  • May 2017 : Update of the .Net and Java runtime and SDK to version 3.0.0.
  • February 2017 : Update of the Java runtime to version 2.0.6.
  • September 2016 : Update of the .Net and Java runtime and SDK to version 2.0.5.
  • March 2016 : Update of the .Net and Java runtime and SDK to version 2.0.4.
  • October 2015 : Update of the .Net and Java runtime and SDK to version 2.0.1.