function Scanner::consumeUntil
Consumes characters until one of the given characters is found
Parameters
array|LSM $stops Characters to search:
bool $handleEscape True to handle escaping:
bool $collectStop True to include the stop character:
Return value
array|null
3 calls to Scanner::consumeUntil()
- Scanner::reconsumeCurrentTokenAsRegexp in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Scanner.php - Tries to reconsume the current token as a regexp if possible
- Scanner::scanString in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Scanner.php - String scanning method
- Scanner::scanTemplate in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Scanner.php - Template scanning method
File
-
vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Scanner.php, line 1796
Class
- Scanner
- Base class for scanners.
Namespace
Peast\SyntaxCode
protected function consumeUntil($stops, $handleEscape = true, $collectStop = true) {
$isLSM = $stops instanceof LSM;
$buffer = "";
$escaped = false;
while (($char = $this->charAt()) !== null) {
$incrIndex = 1;
$isStop = false;
if ($isLSM) {
$m = $stops->match($this, $this->index, $char);
if ($m) {
$isStop = true;
$incrIndex = $m[0];
$char = $m[1];
}
}
else {
$isStop = in_array($char, $stops);
}
$validStop = $isStop && !$escaped;
if (!$validStop || $collectStop) {
$this->index += $incrIndex;
$buffer .= $char;
}
if ($validStop) {
if (!$collectStop && $buffer === "") {
return null;
}
$this->adjustColumnAndLine($buffer);
return array(
$buffer,
$char,
);
}
elseif (!$escaped && $char === "\\" && $handleEscape) {
$escaped = true;
}
else {
$escaped = false;
}
}
return null;
}