dev-master
9999999-dev https://github.com/Webapper/ParzRKitParzRKit
CC-4.0
The Requires
- php >=5.3.0
- ext-json *
parser php
1.0.0-a
1.0.0.0-alpha https://github.com/Webapper/ParzRKitParzRKit
CC-4.0
The Requires
- php >=5.3.0
- ext-json *
parser php
Wallogit.com
2017 © Pedro Peláez
ParzRKit
ParzRKit is an abstract parser library written in PHP for future purposes, (*1)
This is a part of a light-weight framework, Prometheus: http://webapper.vallalatiszolgaltatasok.hu/#!/prometheus (language only in hungarian, sorry), (*2)

ParzRKit by Assarte D'Raven is licensed under a Creative Commons Attribution 4.0 International License., (*3)
Feel free to use my lib, I hope that you may enjoy that and may help you on your better efficiency. Well, you should donate me some credits via PayPal if my help counts for you on your work:, (*4)
...or give me some positive feedback on my e-mail adress (you can see that in my profile)., (*6)
Thanks anyway!, (*7)
It's a quite easy way to use this lib basically:, (*8)
This is a working example of usage:, (*9)
use ParzRKit\Parser\Lexer\AbstractToken;
use ParzRKit\Parser\Lexer;
use ParzRKit\Linker;
use ParzRKit\Parser;
use ParzRKit\Compiler;
use ParzRKit\Parser\Lexer\DataStreamToken;
define('SRC', realpath(dirname(dirname(__FILE__))).'/src/vendor/assarte/parzrkit/lib/');
require SRC.'Parser/Lexer/AbstractToken.php';
require SRC.'Parser/Lexer/ComposedToken.php';
require SRC.'Parser/Lexer/DataStreamToken.php';
require SRC.'Parser/ReturnToParentException.php';
require SRC.'Parser/Lexer.php';
require SRC.'Parser.php';
require SRC.'Linker.php';
require SRC.'Compiler/CompileException.php';
require SRC.'Compiler/Exception/NotAllowedException.php';
require SRC.'Compiler/Exception/NotMetException.php';
require SRC.'Compiler/BasicNode.php';
require SRC.'Compiler/StrictNode.php';
require SRC.'Compiler/RecursiveNodeIterator.php';
require SRC.'Compiler.php';
class TestToken extends DataStreamToken
{
public function isDataStream()
{
return false;
}
public function identifyOpenTag()
{
if ($this->stream{0} == '/') {
$this->openTag = '/';
}
}
}
class TestSubToken extends AbstractToken
{
public function identifyOpenTag()
{
if ($this->stream{0} == '[') {
$this->openTag = '[';
}
}
public function identifyCloseTag($inStream=null)
{
$pos = $this->getCursor();
if ($inStream !== null) {
$pos = 0;
} else {
$inStream = $this->processed;
}
if ($inStream{$pos} == ']') {
$this->closeTag = ']';
return true;
}
return false;
}
public function guessCloseTag()
{
return ']';
}
}
class TestLexer extends Lexer
{
protected function registerTokeners()
{
$this->addTokener('TestToken');
$this->addTokener('TestSubToken');
}
}
class TestLinker extends Linker
{
public function link()
{
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($this));
foreach ($it as $link) {
echo str_repeat('| ', $it->getDepth() - 1).'|-'.json_encode($link).'<br>';
}
}
}
$stream = '[876/t687][aa[bb[dd]]cc]';
$parser = new Parser($stream, TestLexer::getLexer());
$parser->parse();
$compiler = new Compiler(new TestLinker(), $parser->getToken()->getNode());
$compiler->compile();
echo $stream.'<br>';
$compiler->getLinker()->link();
The example above will print:, (*10)
[876/t687][aa[bb[dd]]cc] |-"[876\/t687]" | |-"876" | |-"\/t687" |-"[aa[bb[dd]]cc]" | |-"aa" | |-"[bb[dd]]" | | |-"bb" | | |-"[dd]" | |-"cc"
ParzRKit
CC-4.0
parser php
ParzRKit
CC-4.0
parser php