# doctrine/lexer

Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.

Repository: https://github.com/doctrine/lexer
Canonical: https://ross.abutalabs.com/products/lexer
Homepage: https://www.doctrine-project.org/projects/lexer.html
Language: PHP
License: MIT
License Family: permissive
Last push: 2026-06-14T20:44:09+00:00

## Health v2 (maintenance only)
Score: 62/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 87, release rhythm 8, longevity 100
- inputs: {"age_days": 4981, "days_push": 80, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 11146, forks 65 (observed 2026-08-28T04:10:46.227007+00:00)

## What it is
A PHP base library providing an abstract lexer for building Top-Down, Recursive Descent Parsers. It tokenizes input strings and is used internally by Doctrine Annotations and Doctrine ORM's DQL parser.

## Use cases
- write a custom lexer for a DSL in PHP
- tokenize input strings for a recursive descent parser
- build a query language parser like DQL
- parse annotation syntax in PHP
- walk a string token by token with lookahead

## When to choose
- you are building a top-down or recursive descent parser in PHP
- you need a small, battle-tested tokenizer base class
- you are already in the Doctrine ecosystem (ORM, Annotations)

## When to avoid
- you need a full parser generator or grammar tool (use ANTLR or similar)
- you need high-performance lexing outside PHP
- you want a ready-made parser for an existing format

## Facets
- artifact type: library
- maturity: stable
- function: parser, developer-tools
- domain: parsers, developer-tools, programming-languages
- platform: php
- tags: lexer, tokenizer, recursive-descent, doctrine, dql

## Member repositories
- doctrine/lexer (main) score 62

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:10:46.227007+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T17:16:45.505729+00:00, confidence not recorded.
  - readme: https://github.com/doctrine/lexer (fetched 2026-08-28T04:10:46.227007+00:00, sha c9274d68574e)
  - homepage: https://www.doctrine-project.org/projects/lexer.html (fetched 2026-08-29T08:15:22.833106+00:00, sha 0049457f107b)
  - site_page: https://www.doctrine-project.org/projects/doctrine-lexer/en/3.1/index.html (fetched 2026-08-29T08:15:22.835923+00:00, sha 762c30c119a7)
  - site_page: https://www.doctrine-project.org/projects/doctrine-lexer/en/latest/index.html (fetched 2026-08-29T08:15:22.838883+00:00, sha f66d2975c561)
  - site_page: https://www.doctrine-project.org/projects/doctrine-lexer/en/2.1/index.html (fetched 2026-08-29T08:15:22.841226+00:00, sha 82cb6db6f742)
  - site_page: https://www.doctrine-project.org/projects/doctrine-lexer/en/2.0/index.html (fetched 2026-08-29T08:15:22.843155+00:00, sha 7d8b4c898481)
  - site_page: https://www.doctrine-project.org/projects/doctrine-lexer/en/1.2/index.html (fetched 2026-08-29T08:15:22.844956+00:00, sha 018dd689df94)
  - site_page: https://www.doctrine-project.org/projects/doctrine-lexer/en/1.1/index.html (fetched 2026-08-29T08:15:22.846968+00:00, sha 538cca910e27)
  - site_page: https://www.doctrine-project.org/projects/doctrine-lexer/en/1.0/index.html (fetched 2026-08-29T08:15:22.848726+00:00, sha 62fb9c0efa68)
- Data as of 2026-08-30T08:39:29.467469+00:00.
