protected static function eatString($input)
{
$length = strlen($input);
$collected = '';
for ($i = 0; $i < $length; $i++) {
$c = $input[$i];
if ($c === '\\') {
// escape, skip to the next character
$i++;
$collected .= $input[$i];
continue;
} elseif ($c === '"') {
break;
} else {
$collected .= $c;
}
}
return [$collected, substr($input, $i + 1)];
}