protected function match(string $line, int $lineNumber, int $offset) : array
    {
        $restLine = substr($line, $offset);

        foreach ($this->terminals as $pattern => $name) {
            if (preg_match($pattern, $restLine, $matches)) {
                return [
                    $name,
                    $matches,
                ];
            }
        }

        throw new SyntaxErrorException(sprintf('Lexer error: unable to parse "%s" at line %s.', $line, $lineNumber));
    }
protected function match(string $line, int $lineNumber, int $offset) : array
    {
        $restLine = substr($line, $offset);

        foreach ($this->terminals as $pattern => $name) {
            if (preg_match($pattern, $restLine, $matches)) {
                return [
                    $name,
                    $matches,
                ];
            }
        }

        throw new SyntaxErrorException(sprintf('Lexer error: unable to parse "%s" at line %s.', $line, $lineNumber));
    }
protected function match ( string $ line , int $ lineNumber , int $ offset ) : array { $ restLine = substr ( $ line , $ offset ) ; foreach ( $ this -> terminals as $ pattern => $ name ) { if ( preg_match ( $ pattern , $ restLine , $ matches ) ) { return [ $ name , $ matches , ] ; } } throw new SyntaxErrorException ( sprintf ( 'Lexer error: unable to parse "%s" at line %s.' , $ line , $ lineNumber ) ) ; }
Returns the first match with the list of terminals

@return array An array with the following keys:
[0] (string): name of the token
[1] (array): matches of the regular expression

@throws SyntaxErrorException If the line does not contain any token
Returns the first match with the list of terminals