doctrine/lexer ? reverse-engineered prompt

Reverse engineered prompt

Build me a small PHP library that provides a reusable lexer for simple parsers.

I want it to take an input string, break it into tokens, and let me move through those tokens in a predictable way so it can be used for things like annotations or simple query languages. It should be clean, easy to extend, and focused on being a base library rather than a full parser. Please include a few solid tests that show the lexer working with different inputs, empty input, invalid characters, and advancing through tokens correctly.

Keep it simple and well organized, with clear README notes on how to use it and how someone could build their own lexer rules on top of it. If you need to check current PHP best practices or docs while working, go ahead and look them up online.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab