PHPackages                             edin/lexicon-syntax - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. edin/lexicon-syntax

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

edin/lexicon-syntax
===================

BNF-style grammar parser, validator, and code generator for Lexicon-powered syntax tools.

v0.1.5(1mo ago)09↓80%MITPHPPHP ^8.2CI passing

Since Jun 10Pushed 1mo agoCompare

[ Source](https://github.com/edin/LexiconSyntax)[ Packagist](https://packagist.org/packages/edin/lexicon-syntax)[ RSS](/packages/edin-lexicon-syntax/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (3)Versions (7)Used By (0)

Lexicon Syntax
==============

[](#lexicon-syntax)

Lexicon Syntax is a companion grammar parser and validator for the `edin/lexicon` package. It parses compact `token` and `rule` declarations into an AST, validates common grammar mistakes, and can pretty-print the grammar back into a normalized BNF-like format.

See [docs/README.md](docs/README.md) for the language, CLI, generation, validation, and roadmap notes.

```
token Digit ::= '0' .. '9';
token Letter ::= 'a' .. 'z' | 'A' .. 'Z' | '_';
token Identifier ::= Letter (Letter | Digit)*;
token Number ::= Digit+;

rule Expression ::= Term ((Plus | Minus) Term)*;
rule Term ::= Factor ((Star | Slash) Factor)*;
rule Factor ::= Number | GroupedExpression;
rule GroupedExpression ::= OpenParen Expression CloseParen;
```

```
use LexiconSyntax\GrammarParser;
use LexiconSyntax\GrammarPrinter;
use LexiconSyntax\Validation\GrammarValidator;

$document = GrammarParser::parse($source);

echo GrammarPrinter::format($document);

$result = GrammarValidator::validate($document);
foreach ($result->diagnostics as $diagnostic) {
    echo $diagnostic->message, PHP_EOL;
}
```

CLI
---

[](#cli)

Install the command globally with Composer:

```
composer global require edin/lexicon-syntax
lsyn help
```

Make sure Composer's global `vendor/bin` directory is on `PATH`. On Windows this is commonly:

```
%APPDATA%\Composer\vendor\bin

```

Create a C-like demo project in an empty directory:

```
lsyn init c-like
lsyn validate
lsyn generate
lsyn parse
```

Those commands read `lexicon-syntax.json` from the current project folder.

Useful inspection commands:

```
lsyn print
lsyn ast
lsyn parse
```

`lsyn print` pretty-prints the grammar, `lsyn ast` prints the grammar AST nodes, and `lsyn parse` generates the demo parser and prints the parsed C-like sample AST.

During development from source, run the binary directly:

```
composer install
php bin/lsyn help
```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance90

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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.

###  Release Activity

Cadence

Every ~0 days

Total

6

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/82bb42da001bbd10ee7a34aa349e7cf749cb509408f40170fa9cfdb80984ca87?d=identicon)[EdinOmeragic](/maintainers/EdinOmeragic)

---

Top Contributors

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

---

Tags

validatorparsercode generatorlexerlintersyntaxastgrammarLexiconbnfebnf

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/edin-lexicon-syntax/health.svg)

```
[![Health](https://phpackages.com/badges/edin-lexicon-syntax/health.svg)](https://phpackages.com/packages/edin-lexicon-syntax)
```

###  Alternatives

[seld/jsonlint

JSON Linter

1.3k228.7M274](/packages/seld-jsonlint)[neilime/php-css-lint

Powerful &amp; memory efficient CSS linter for PHP

131.9M3](/packages/neilime-php-css-lint)[sad_spirit/pg_builder

Query builder for Postgres backed by SQL parser

5940.0k1](/packages/sad-spirit-pg-builder)[yoeunes/regex-parser

A powerful PCRE regex parser with lexer, AST builder, validation, ReDoS analysis, and syntax highlighting. Zero dependencies, blazing fast, and production-ready.

30101.0k8](/packages/yoeunes-regex-parser)

PHPackages © 2026

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