wandu / compiler
This package is abandoned and no longer maintained.
No replacement package was suggested.
[EXPERIMENT] PHP Base Compiler(Lexical Analyzer).
v3.0.4
2016-10-25 16:33 UTC
Requires
- php: >=5.6
- wandu/fastelper: ^0.1.0
This package is not auto-updated.
Last update: 2022-04-02 05:19:27 UTC
README
[EXPERIMENT] PHP Base Compiler(Lexical Analyzer).
Installation
composer require wandu/compiler
Useage
LexicalAnalyzer
Example.
$lexer = new \Wandu\Compiler\LexicalAnalyzer([ '\\+' => function () { return 't_add'; }, '\\-' => function () { return 't_minus'; }, '\\*' => function () { return 't_multi'; }, '\\/' => function () { return 't_divide'; }, '\\=' => function () { return 't_equal'; }, '[1-9][0-9]*|0([0-7]+|(x|X)[0-9A-Fa-f]*)?' => function ($word) { return "t_number"; }, '\s' => null, ]); $lexer->analyze('10 + 20 = 0')); // ['t_number', 't_add', 't_number', 't_equal', 't_number',]