Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LSM.php

function LSM::add

Adds a sequence

Parameters

string $sequence Sequence to add:

Return value

$this

1 call to LSM::add()
LSM::__construct in vendor/mck89/peast/lib/Peast/Syntax/LSM.php
Class constructor

File

vendor/mck89/peast/lib/Peast/Syntax/LSM.php, line 55

Class

LSM
Longest Sequence Matcher. Utility class used by the scanner to consume the longest sequence of character given a set of allowed characters sequences.

Namespace

Peast\Syntax

Code

public function add($sequence) {
    if ($this->handleEncoding) {
        $s = Utils::stringToUTF8Array($sequence);
        $first = $s[0];
        $len = count($s);
    }
    else {
        $first = $sequence[0];
        $len = strlen($sequence);
    }
    if (!isset($this->map[$first])) {
        $this->map[$first] = array(
            "maxLen" => $len,
            "map" => array(
                $sequence,
            ),
        );
    }
    else {
        $this->map[$first]["map"][] = $sequence;
        $this->map[$first]["maxLen"] = max($this->map[$first]["maxLen"], $len);
    }
    return $this;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal