{"id":19815558,"url":"https://github.com/libgraviton/rql-parser","last_synced_at":"2025-05-01T10:31:36.234Z","repository":{"id":30332408,"uuid":"33884757","full_name":"libgraviton/rql-parser","owner":"libgraviton","description":"PHP RQL parser","archived":false,"fork":false,"pushed_at":"2023-03-13T13:22:52.000Z","size":202,"stargazers_count":31,"open_issues_count":1,"forks_count":15,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2025-04-21T00:54:42.822Z","etag":null,"topics":["fiql","php","rql","rql-parser"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libgraviton.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-04-13T18:01:56.000Z","updated_at":"2024-11-13T07:07:28.000Z","dependencies_parsed_at":"2024-06-18T16:39:45.153Z","dependency_job_id":"e68294ac-d1c7-48d7-8b99-aee1e92c8594","html_url":"https://github.com/libgraviton/rql-parser","commit_stats":{"total_commits":127,"total_committers":7,"mean_commits":"18.142857142857142","dds":"0.44881889763779526","last_synced_commit":"8ccb26ff5e6ae2fcf63b6119e05d2dca0487f87e"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libgraviton%2Frql-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libgraviton%2Frql-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libgraviton%2Frql-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libgraviton%2Frql-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libgraviton","download_url":"https://codeload.github.com/libgraviton/rql-parser/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251859944,"owners_count":21655645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fiql","php","rql","rql-parser"],"created_at":"2024-11-12T10:06:19.968Z","updated_at":"2025-05-01T10:31:35.967Z","avatar_url":"https://github.com/libgraviton.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"RQL parser\n==========\n\n[![CI](https://github.com/libgraviton/rql-parser/actions/workflows/ci.yml/badge.svg)](https://github.com/libgraviton/rql-parser/actions/workflows/ci.yml)\n![Packagist Version](https://img.shields.io/packagist/v/graviton/rql-parser)\n![Packagist Downloads](https://img.shields.io/packagist/dt/graviton/rql-parser)\n![Packagist License](https://img.shields.io/packagist/l/graviton/rql-parser)\n\nThis is a RQL parsing library written in PHP.\n\nThis library consists of the following parts:\n - lexer for tokenization RQL code\n - parser for creating abstract syntax tree\n\n\nInstallation\n------------\n\nThe preferred way to install library is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```\ncomposer require graviton/rql-parser\n```\n\nor add\n\n```json\n\"graviton/rql-parser\": \"*\",\n```\n\nto the require section of your `composer.json`.\n\n\nBasic usage\n-----------\n\n```php\n\u003c?php\nrequire 'vendor/autoload.php';\n\n// default lexer supports all RQL rules\n$lexer = new Graviton\\RqlParser\\Lexer();\n\n// default parser contains all parsing strategies\n$parser = new Graviton\\RqlParser\\Parser();\n\n\n// RQL code\n$rql = '(eq(a,string:1)|lt(b,2)|(c\u003c\u003e3\u0026d\u003e=string:4\u0026e=eq=boolean:1))\u0026u!=5\u0026not(or(u=6,ge(i,10)))\u0026z=1\u0026(a==2|b\u003c-3|in(c,(2,float:3)))\u0026select(a,b)\u0026sort(+a,-b)\u0026limit(1,2)';\n\n// tokenize RQL\n$tokens = $lexer-\u003etokenize($rql);\n\n\n// parsing\nvar_dump($parser-\u003eparse($tokens));\n```\n\nSee also [rql-command library](https://github.com/libgraviton/rql-command).\nThis is a console application to debug RQL lexing and parsing.\n\n\nAdvanced usage\n--------------\n\nSee examples:\n\n - [Enable only FIQL operators](examples/01-only-fiql-operator.php)\n - [Add new query operators](examples/02-new-query-operator.php)\n - [Add support for aggregate functions](examples/03-new-top-operator.php)\n - [Convert RQL to SQL](examples/04-convert-to-sql.php)\n - [Add date support](examples/05-date-support.php)\n - [Use scalars in array nodes](examples/06-improve-array-parser.php)\n - [Add `timestamp` caster](examples/07-timestamp-caster.php)\n - [Wrap strings with quotes](examples/08-string-quoting.php)\n\nCurrent state\n-------------\n\n### Operators ###\n\n#### Basic syntax ####\n\n - scalar operators\n    - `eq(a,b)`\n    - `ne(a,b)`\n    - `lt(a,b)`\n    - `gt(a,b)`\n    - `le(a,b)`\n    - `ge(a,b)`\n - array operators\n    - `in(a,(b,c))`\n    - `out(a,(b,c))`\n - logic operators\n    - `and(eq(a,b),ne(c,d))`\n    - `or(eq(a,b),ne(c,d))`\n    - `not(eq(a,b))`\n\n#### Short logic syntax ####\n\n - `(eq(a,b)\u0026ne(b,c))`\n - `(eq(a,b)|ne(b,c))`\n\n#### FIQL syntax ####\n\n - scalar operators\n    - `a=eq=b`\n    - `a=ne=b`\n    - `a=lt=b`\n    - `a=gt=b`\n    - `a=le=b`\n    - `a=ge=b`\n - array operators\n    - `a=in=(b,c)`\n    - `a=out=(b,c)`\n\n#### Simplified FIQL syntax ####\n\n - `a=b`\n - `a==b`\n - `a\u003c\u003eb`\n - `a!=b`\n - `a\u003cb`\n - `a\u003eb`\n - `a\u003c=b`\n - `a\u003e=b`\n\n#### Other ####\n\n - `select(a,b,c)`\n - `sort(+a,-b)`\n - `limit(1,2)`\n\nAll syntax variations may be used together.\n\n\n### Value types ###\n \n - string\n    - `abc`\n    - `abc%20def`\n - integer\n    - `1`, `+1`, `-1`\n - float\n    - `1.`, `+1.`, `-1.`\n    - `0.1`, `+0.1`, `-0.1`,\n    - `0.1e5`, `+0.1e+5`, `-0.1e-5`\n    - `.1`, `+.1`, `-.1`\n    - `.1e5`, `+.1e+5`, `-.1e-5`\n - boolean\n    - `true()`\n    - `false()`\n - null\n    - `null()`\n - empty\n    - `empty()`\n - date\n    - `2015-06-02T20:00:00Z`\n - glob\n    - `abc*`\n    - `?abc`\n    - `abc*def?`\n\n\n### Type casting ###\n\n - `string:1`\n - `boolean:0`\n - `integer:a`\n - `float:1`\n\n\nEncoding rules\n--------------\n\n### String values ###\n\nIn string values all non-alphanumeric characters must be encoded with a percent (%) sign followed by two hex digits.\n\nExamples:\n\n```\neq(string,2015%2D05%2D30T15%3A10%3A00Z)\nin(string,(%2B1%2E5,%2D1%2E5))\nin(string,(null%28%29,empty%28%29,true%28%29,false%28%29))\n```\n\n#### String encoding in PHP: ####\n\n```php\nfunction encodeString($value)\n{\n    return strtr(rawurlencode($value), [\n        '-' =\u003e '%2D',\n        '_' =\u003e '%5F',\n        '.' =\u003e '%2E',\n        '~' =\u003e '%7E',\n    ]);\n}\n```\n\n#### String encoding in JavaScript: ####\n\n```js\nfunction encodeString(value) {\n    return encodeURIComponent(value).replace(/[\\-_\\.~!\\\\'\\*\\(\\)]/g, function (char) {\n        return '%' + char.charCodeAt(0).toString(16).toUpperCase();\n    });\n}\n```\n\n\n### Other values ###\n\nDate, number and const-function values must not be encoded.\n\nExamples:\n\n```\neq(date,2015-05-30T15:10:00Z)\nin(number,(+1.5,-1.5))\nin(const,(null(),empty(),true(),false()))\n```\n\n\nResources\n---------\n * [RQL Rules](https://github.com/persvr/rql)\n * [RQL documentation](https://doc.apsstandard.org/2.1/spec/rql)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibgraviton%2Frql-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibgraviton%2Frql-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibgraviton%2Frql-parser/lists"}