With Parle, it is possible to implement lexing and parsing in PHP while relying on features and principles of the parser/lexer generator tools for C/C++.
Documentation: http://php.net/parle
Package built for PHP 8.3 as Software Collection (php83 by remi).