ride / lib-tokenizer
Tokenizer library of the Ride framework.
Installs: 6 915
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 8
Forks: 1
Open Issues: 0
Requires
- php: >=5.3
Requires (Dev)
- phpunit/phpunit: ^4.8 | ^5.5 | ^6.5
This package is auto-updated.
Last update: 2024-11-13 00:21:05 UTC
README
This library gives you some classes to parse a string into tokens.
Code Sample
Some example code in the context of the ORM module:
<?php use ride\library\tokenizer\symbol\NestedSymbol; use ride\library\tokenizer\symbol\SimpleSymbol; use ride\library\tokenizer\Tokenizer; $tokenizer = new Tokenizer(); $tokenizer->setWillTrimTokens(true); $tokenizer->addSymbol(new SimpleSymbol('AND')); $tokenizer->addSymbol(new SimpleSymbol('OR')); $tokenizer->addSymbol(new NestedSymbol('(', ')', $tokenizer)); $condition = '{field} = %2% AND {field2} <= %1%'; $tokens = $tokenizer->tokenize($condition); // array( // '{field} = %2%', // 'AND', // '{field2} <= %1%' // ) $condition = '{field} = 5 AND ({field2} <= %1% OR {field2} >= %2%)'; $tokens = $tokenizer->tokenize($condition); // array( // '{field} = 5', // 'AND', // array( // '{field2} <= %1%'), // 'OR', // '{field2} >= %2%'), // ) // )
Implementations
For more examples, you can check the following implementation of this library:
Installation
You can use Composer to install this library.
composer require ride/lib-tokenizer