Version: 0.3.1
Installation & Requirements
- Command line
- composer.json
composer require mathiasverraes/parsica
Requirements
- PHP 7.4 or higher
- The multibyte string extension for PHP (aka mbstring)
(@TODO: add polyfill for mbstring).
Usage
In a .php file, make sure the Composer autoloader is included:
require_once __DIR__.'/../vendor/autoload.php';
Import parsers and combinators:
use function Verraes\Parsica\char;
You can combine multiple imports in one statement:
use function Verraes\Parsica\{between, char, atLeastOne, alphaChar};
Finally, add some code:
<?php
$parser = between(char('{'), char('}'), atLeastOne(alphaChar()));
$result = $parser->try("{Hello}");
echo $result->output();
// outputs "Hello"