I recently released a new PHP package called "Lexical". It provides a set of attributes and objects to build regular expression based lexers in PHP.
As somebody who enjoys experimenting with parsers and text processing, writing lexers has become a somewhat regular task for me.
Lexical provides a set of attributes that can be added to each case in the enumeration: Regex - accepts a single regular expression.
enum TokenType { #[Regex("[0-9]+")] case Number; #[Literal("+")] case Add; #[Literal("-")] case Subtract; #[Literal("*")] case Multiply; #[Literal("/")] case Divide; }
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.