/** * If the $reader can read token $tokName, returns it's contents, otherwise * returns false. */ protected static function readString($tokName, \browserfs\string\Parser $reader) { if (!is_string($tokName)) { throw new \browserfs\runtime\Exception('Invalid argument $tokName: expected string'); } if (array_key_exists($tokName, self::$tokens)) { $matches = $reader->canReadExpression(self::$tokens[$tokName]); if ($matches) { $reader->consume(strlen($matches[0])); return $matches[0]; } else { return false; } } else { throw new \browserfs\runtime\Exception('Unknown parser token name: ' . $tokName); } }