nemorize/fexpr
最新稳定版本:0.0.2
Composer 安装命令:
composer require nemorize/fexpr
包简介
Simple filter query language parser (originally written in go by ganigeorgiev/fexpr)
README 文档
README
php-fexpr is a PHP-ported version of ganigeorgiev/fexpr that allows you to parse a filter query language and provides easy to work with AST structures.
Supports parenthesis and various conditional expression operators (see original project's Grammar)
Example usage
composer require nemorize/fexpr
$ast = (new \Nemorize\Fexpr\Parser())->parse('id = 123 && status = "active"'); // json_encode($ast): [ // { // "operation": { // "type": "join", // "literal": "&&" // }, // "item": { // "left": { // "type": "identifier", // "literal": "id" // }, // "operation": { // "type": "sign", // "literal": "=", // }, // "right": { // "type": "number", // "literal": "123" // } // } // }, // { // "operation": { // "type": "join", // "literal": "&&" // }, // "item": { // "left": { // "type": "identifier", // "literal": "status" // }, // "operation": { // "type": "sign", // "literal": "=", // }, // "right": { // "type": "string", // "literal": "active" // } // } // } // ]
Using only the scanner
The tokenizer (aka. \Nemorize\Fexpr\Scanner) could be used without the parser\s state machine
so that you can write your own custom tokens processing:
$scanner = new \Nemorize\Fexpr\Scanner(); foreach ($scanner->scan('id > 123') as $token) { var_dump($token); }
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2023-07-14