function Parser::parseImportSpecifier
Parses an import specifier
Return value
Node\ImportSpecifier|null
1 call to Parser::parseImportSpecifier()
- Parser::parseNamedImports in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php - Parses a named imports
File
-
vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php, line 2321
Class
- Parser
- Parser class
Namespace
Peast\SyntaxCode
protected function parseImportSpecifier() {
$requiredAs = false;
$imported = $this->parseIdentifier(static::$importedBinding);
if (!$imported) {
$imported = $this->parseModuleExportName();
if (!$imported) {
return null;
}
$requiredAs = true;
}
$node = $this->createNode("ImportSpecifier", $imported);
$node->setImported($imported);
if ($this->scanner
->consume("as")) {
if (!($local = $this->parseIdentifier(static::$importedBinding))) {
$this->error();
}
$node->setLocal($local);
}
elseif ($requiredAs) {
$this->error();
}
else {
$node->setLocal($imported);
}
return $this->completeNode($node);
}