PHPackages                             face/parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. face/parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

face/parser
===========

helper to write parser with php

063PHP

Since Dec 4Pushed 10y ago1 watchersCompare

[ Source](https://github.com/face-orm/face-parser)[ Packagist](https://packagist.org/packages/face/parser)[ RSS](/packages/face-parser/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Face Parser
===========

[](#face-parser)

[![Latest Stable Version](https://camo.githubusercontent.com/9f5cdb008087d8822482055761f55d3965e410227035fa7e59b33c1388f25f96/68747470733a2f2f706f7365722e707567782e6f72672f666163652f7061727365722f762f737461626c65)](https://packagist.org/packages/face/parser)[![Build Status](https://camo.githubusercontent.com/81b5936166884805679e3b8463c028dc9f4f8acab67e9500909e09a24d331fc9/68747470733a2f2f7472617669732d63692e6f72672f666163652d6f726d2f666163652d7061727365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/face-orm/face-parser)[![Test Coverage](https://camo.githubusercontent.com/ef3a96369389f576dd27726f1c4914552290b5ce33467eeac00244884962a932/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f666163652d6f726d2f666163652d7061727365722f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/face-orm/face-parser/coverage)

Tool to help to create a parser with php. Originally built to parse FQL queries but might be used for anything else.

Usage
-----

[](#usage)

```
    use Face\Parser\RegexpLexer as Lexer;
    use Face\Parser\TokenNavigation;

    $lexer = new Lexer();

    $lexer->setTokens([

        "function"                  => "T_FUNCTION",
        "class"                     => "T_CLASS",
        "[a-zA-Z_][a-zA-Z0-9_]*"    => "T_IDENTIFIER",
        "\\{"                       => "T_L_BRACKET",
        "\\}"                       => "T_R_BRACKET",
        "\\("                       => "T_L_PARENTHESIS",
        "\\)"                       => "T_R_PARENTHESIS",
        ";"                         => "T_SEMICOLON",
        "\\s+"                      => "T_WHITESPACE"

    ]);

    $string = 'class foo{
        function bar(){}
    }';

    $tokenArray = $lexer->tokenize($string);

    $tokens = new TokenNavigation($tokenArray);

    // Check if the first token is a "class" keyword or throws an exception
    $tokens->expectToBe("T_CLASS");

    $tokens->next();
    $tokens->expectToBe("T_IDENTIFIER");

    $className = $tokens->current()->getTokenValue();

    // while next token is a function keyword
    while($tokens->hasNext() && $tokens->look(1)->is("T_FUNCTION")){
        // Parse the function body
        someFunctionThatParsesTheFunctionAndJumpsToTheNextToken($tokens);
    }

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e6f24737cd0c46fea5e7a294f91582b35a052ce23cd2375f8f48e2faecb6fd78?d=identicon)[gsouf](/maintainers/gsouf)

---

Top Contributors

[![gsouf](https://avatars.githubusercontent.com/u/3215399?v=4)](https://github.com/gsouf "gsouf (14 commits)")

### Embed Badge

![Health badge](/badges/face-parser/health.svg)

```
[![Health](https://phpackages.com/badges/face-parser/health.svg)](https://phpackages.com/packages/face-parser)
```

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19139.2M47](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9843.5k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

45153.1k6](/packages/jstewmc-rtf)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.2k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
