PHP code example of xiag / rql-parser

1. Go to this page and download the library: Download xiag/rql-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xiag / rql-parser example snippets



efault lexer supports all RQL rules
$lexer = new Graviton\RqlParser\Lexer();

// default parser contains all parsing strategies
$parser = new Graviton\RqlParser\Parser();


// RQL code
$rql = '(eq(a,string:1)|lt(b,2)|(c<>3&d>=string:4&e=eq=boolean:1))&u!=5&not(or(u=6,ge(i,10)))&z=1&(a==2|b<-3|in(c,(2,float:3)))&select(a,b)&sort(+a,-b)&limit(1,2)';

// tokenize RQL
$tokens = $lexer->tokenize($rql);


// parsing
var_dump($parser->parse($tokens));

function encodeString($value)
{
    return strtr(rawurlencode($value), [
        '-' => '%2D',
        '_' => '%5F',
        '.' => '%2E',
        '~' => '%7E',
    ]);
}