The project builds an Abstract Syntax Tree (AST) from HackLang source code
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

HackLang parser

What is this?

This project is a parser for HackLang written in PHP. It is based on Sara Golemon's project Phack. It builds an abstract Syntax Tree (AST) from HackLang source code.

Any attempt to use HackLang files which have not passed hh_client is a terrible mistake, and you should feel bad.

How does it work?

Hack Parser extends PHP-Parser by amending the PHP 7 parsing rules and overriding the Lexer's pre/post processor hooks.

How do I use it?

The prefered way of installation is via composer. For this, add the following to your composer.json:

"repositories": [
        "type": "vcs",
        "url": "<git_repository_url>"
"require": {
    "adel/hackparser": "*"

To Parse a HackLang file, use new PhpLang\Phack\PhpParser\ParserFactory)->create(PhpLang\Phack\PhpParser\ParserFactory::HACKLANG)->parse($str);. This returns an abstract syntax tree that can be used for static analysis for example. More informations in the PHP-Parser documentation.

To see the AST of a given HackLang file, you can run vendor/bin/hackParser which will invoke compileString for you and dump the tree.