1. Go to this page and download the library: Download nielssp/parco 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/ */
nielssp / parco example snippets
class Myparser
{
use \Parco\Combinator\RegexParsers;
}
class Myparser
{
use \Parco\Combinator\RegexParsers;
public function expr()
{
return // a parser for expressions
}
public function term()
{
return // a parser for terms
}
public function factor()
{
return // a parser for factors
}
public function number()
{
return // a parser for numbers
}
}
class MyParser
{
use \Parco\Combinator\RegexParsers;
// ...
public function __invoke($string)
{
return $this->parseAll($this->expr, $string)->get();
}
}