nemorize/fexpr 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2023-07-14