1. Go to this page and download the library: Download dbeurive/lexer 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/ */
/**
* Lexer constructor.
* @param array $inSpecifications This array represents the tokens specifications.
* Each element of this array is an array that specifies a token.
* It contains 2 or 3 elements.
* - First element: a regular expression that describes the token.
* - Second element: the name of the token.
* - Third element: an optional callback function.
* The signature of this function must be:
* null|string function(array $inMatches)
* @throws \Exception
*/
public function __construct(array $inSpecifications)
/**
* Explode a given string into a list of tokens.
* @param string $inString The string to explode into tokens.
* @return array The method returns a list of tokens.
* Each element of the returned list is an instance of the class Token.
* @throws \Exception
* @see Token
*/
public function lex($inString)
/**
* Class Token
*
* This class implements a token.
*
* @package dbeurive\Lexer
*/
class Token
{
/** @var null|mixed Token's value. */
public $value = null;
/** @var null|string Token's type. */
public $type = null;
/**
* Token constructor.
* @param string $inOptValue The token's value.
* @param string $inOptType The token's type.
*/
public function __construct($inOptValue=null, $inOptType=null)
{
$this->value = $inOptValue;
$this->type = $inOptType;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.