PHP 5/7 framework for creating complex scanners, lexer, tokenizers and parsers based on BNF (and variant) formal syntax definitions.
MIT License
Build object oriented LR(1) lexer, tokenizers and parsers in PHP using BNF-based syntax.
Copyright © 2011-2024 Martijn W. van der Lee Toyls.com, MIT license applies.
word = [A-Za-z]+
list = word *[ ',' word ]
$word = new Repeat(new Regex('/[a-z][A-Z]/'), 1);
$list = new Sequence($word, new Repeat(new Sequence(',', $word)));
$word = new Repeat(new Regex('/[a-z][A-Z]/'), 1);
$list = new Sequence($word, new Repeat([',', $word]));
$word = plus(regex('/[a-z][A-Z]/'));
$list = s($word, star([',', $word]));
$list = new Ruleset([
'word' => plus(regex('/[a-z][A-Z]/')),
Ruleset::ROOT => s($word, star([',', $word])),
]);