Lexluthor | Github Extra Quality
🔗 GitHub repo: https://github.com/lexluthor/luthor | Feature | Description | |---------|-------------| | Rule-based | Define token patterns using regular expressions | | PHP-native | Written in pure PHP, no extra extensions | | Streaming support | Process input character by character (memory efficient) | | Callback actions | Attach PHP callbacks to token rules | | Context switching | Supports lexer states (e.g., inside strings/comments) | Basic Usage Example use LexLuthor\Lexer; use LexLuthor\Token; $lexer = new Lexer();
$lexer->rule('/[a-z]+/', function(Token $token) echo "Word: $token->getValue()\n"; ); lexluthor github
LexLuthor is a GitHub username (and associated project) belonging to a developer who has created LexLuthor/luthor – a lightweight, rule-based lexer generator for PHP. It’s designed to help you build custom tokenizers/lexers for domain-specific languages (DSLs), configuration files, or simple programming languages. 🔗 GitHub repo: https://github
$lexer->rule('/\d+/', function(Token $token) echo "Number: $token->getValue()\n"; ); $lexer = new Lexer()
$lexer->rule('/\s+/', function(Token $token) // skip whitespace );