PHPackages                             remorhaz/php-unilex - 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. remorhaz/php-unilex

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

remorhaz/php-unilex
===================

Unilex: lexical analyzer generator with Unicode support written in PHP

v0.5.3(2y ago)6168.7k↓53.6%42MITPHPPHP ~8.1.0 || ~8.2.0 || ~8.3.0CI failing

Since Apr 18Pushed 2y ago2 watchersCompare

[ Source](https://github.com/remorhaz/php-unilex)[ Packagist](https://packagist.org/packages/remorhaz/php-unilex)[ Docs](https://github.com/remorhaz/php-unilex)[ RSS](/packages/remorhaz-php-unilex/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (8)Versions (28)Used By (2)

UniLex
======

[](#unilex)

[![Latest Stable Version](https://camo.githubusercontent.com/b747c41e260dec9639ebe7f6146f9c36cff9633b02d6039fcd539ff9622d5239/68747470733a2f2f706f7365722e707567782e6f72672f72656d6f7268617a2f7068702d756e696c65782f76657273696f6e)](https://packagist.org/packages/remorhaz/php-unilex)[![Build](https://github.com/remorhaz/php-unilex/actions/workflows/build.yml/badge.svg)](https://github.com/remorhaz/php-unilex/actions/workflows/build.yml)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5e456e7a06523fbac99ffa80103c98880ea867e3bb9b7dbc13f57ff34e1c0d5c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f72656d6f7268617a2f7068702d756e696c65782f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/remorhaz/php-unilex/?branch=master)[![codecov](https://camo.githubusercontent.com/294348c9aba407bc5c05b7b545c62f67ad93b08b04b740e158227e72c48772c0/68747470733a2f2f636f6465636f762e696f2f67682f72656d6f7268617a2f7068702d756e696c65782f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/remorhaz/php-unilex)[![Mutation testing badge](https://camo.githubusercontent.com/7d73561f261496bc030a457a8dd50db84b0dcf1fe93514751d694abb593c72aa/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d25324672656d6f7268617a2532467068702d756e696c65782532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/remorhaz/php-unilex/master)[![Total Downloads](https://camo.githubusercontent.com/f0b15787b6a0b952c94a53df4fb83c93da53d9a667d5663100deb79a9c93068e/68747470733a2f2f706f7365722e707567782e6f72672f72656d6f7268617a2f7068702d756e696c65782f646f776e6c6f616473)](https://packagist.org/packages/remorhaz/php-unilex)[![License](https://camo.githubusercontent.com/0a17f18e22c0f6a754ed827717d4d480185630a6f498930ed94d9d524d74bdad/68747470733a2f2f706f7365722e707567782e6f72672f72656d6f7268617a2f7068702d756e696c65782f6c6963656e7365)](https://packagist.org/packages/remorhaz/php-unilex)

UniLex is lexical analyzer generator (similar to `lex` and `flex`) with Unicode support. It's written in PHP and generates code in PHP.

```
[WIP] Work in progress

```

Requirements
------------

[](#requirements)

- PHP 8

---

License
-------

[](#license)

UniLex library is licensed under MIT license.

Installation
------------

[](#installation)

Installation is as simple as any other [composer](https://getcomposer.org/) library's one:

```
composer require remorhaz/php-unilex

```

Usage
-----

[](#usage)

### Quick start in example

[](#quick-start-in-example)

Let's imagine we want to write a simple calculator and we need a lexer (lexical analyzer) that provides a stream of IDs, numbers and operators. Create a new Composer project and execute following command from project directory:

```
composer require --dev remorhaz/php-unilex

```

Next step is creating a lexer specification in `LexerSpec.php` file. We use `@lexToken` tag in comments to specify regular expression for a token:

```
