PHPackages                             elerium/lexer - 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. elerium/lexer

ActiveLibrary

elerium/lexer
=============

06PHP

Since Dec 28Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Elerium/Lexer)[ Packagist](https://packagist.org/packages/elerium/lexer)[ RSS](/packages/elerium-lexer/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Elerium\\Lexer [![Build Status](https://camo.githubusercontent.com/bb23768103dcb2895d00ca5389a616cd227ce72738bc5f17265758befeebd329/68747470733a2f2f7472617669732d63692e6f72672f456c657269756d2f4c657865722e706e67)](https://travis-ci.org/Elerium/Lexer)
=========================================================================================================================================================================================================================================================

[](#eleriumlexer-)

Lexical analysis tool for PHP.

Usage
-----

[](#usage)

Here is an example usage:

```
$patterns = array(
    'number' => '[0-9]',
);

$lexer = new \Elerium\Lexer\Lexer($patterns);
$lexemes = $lexer->getLexemes('12'); // Returns two lexemes

```

Patterns
--------

[](#patterns)

Pattern name should be numeric or non-numeric value. Pattern name should contains named sub patterns, marked with **?P** on beginning of pattern or sub pattern, but it's important that the patterns and sub patterns names must be unique. Ignored patterns are marked with **?:**.

Named patterns:

```
$namedPattern = array(
    'address' => '(?P[a-zA-Z]+) (?P[a-zA-Z0-9]+)',
    'name' => '(?P[a-zA-Z]+) (?P[a-zA-Z]+)' // error: repeating name!
);

```

Ignored patterns:

```
$ignoredPatterns = array(
    'whitespace' => '?:\s', // lexeme won't be added to list
);

```

Errors
------

[](#errors)

If there is no pattern exist for input, then Lexer throw **Elerium\\Lexer\\LexerException**.

```
$lexer = new \Elerium\Lexer\Lexer(array(
    'foo' => 'foo'
));
$lexer->getLexemes('bar'); // Invalid lexeme near 'bar' at line 1.

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

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/0c99ae9c35469e9cf9652fd5498871f72072cd2579ab2911e1bd1c2d019f4701?d=identicon)[Elerium](/maintainers/Elerium)

---

Top Contributors

[![Elerium](https://avatars.githubusercontent.com/u/3747647?v=4)](https://github.com/Elerium "Elerium (7 commits)")

### Embed Badge

![Health badge](/badges/elerium-lexer/health.svg)

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

PHPackages © 2026

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