Merge pull request #379 from TysonAndre/fix-base-clause
Add MissingToken for missing QualifiedName
This commit is contained in:
Коммит
6f49c640c0
|
@ -3307,7 +3307,7 @@ class Parser {
|
|||
if ($classBaseClause->extendsKeyword === null) {
|
||||
return null;
|
||||
}
|
||||
$classBaseClause->baseClass = $this->parseQualifiedName($classBaseClause);
|
||||
$classBaseClause->baseClass = $this->parseQualifiedName($classBaseClause) ?? new MissingToken(TokenKind::QualifiedName, $this->token->fullStart);
|
||||
|
||||
return $classBaseClause;
|
||||
}
|
||||
|
@ -3500,12 +3500,18 @@ class Parser {
|
|||
$namespaceDefinition->namespaceKeyword = $this->eat1(TokenKind::NamespaceKeyword);
|
||||
|
||||
if (!$this->checkToken(TokenKind::NamespaceKeyword)) {
|
||||
$namespaceDefinition->name = $this->parseQualifiedName($namespaceDefinition); // TODO only optional with compound statement block
|
||||
$namespaceDefinition->name = $this->parseQualifiedName($namespaceDefinition);
|
||||
}
|
||||
|
||||
$namespaceDefinition->compoundStatementOrSemicolon =
|
||||
$this->checkToken(TokenKind::OpenBraceToken) ?
|
||||
$this->parseCompoundStatement($namespaceDefinition) : $this->eatSemicolonOrAbortStatement();
|
||||
if ($this->checkToken(TokenKind::OpenBraceToken)) {
|
||||
$namespaceDefinition->compoundStatementOrSemicolon = $this->parseCompoundStatement($namespaceDefinition);
|
||||
} else {
|
||||
if (!$namespaceDefinition->name) {
|
||||
// only optional with compound statement block
|
||||
$namespaceDefinition->name = new MissingToken(TokenKind::QualifiedName, $this->token->fullStart);
|
||||
}
|
||||
$namespaceDefinition->compoundStatementOrSemicolon = $this->eatSemicolonOrAbortStatement();
|
||||
}
|
||||
|
||||
return $namespaceDefinition;
|
||||
}
|
||||
|
@ -3531,13 +3537,17 @@ class Parser {
|
|||
$namespaceUseClause = new NamespaceUseClause();
|
||||
$namespaceUseClause->parent = $parentNode;
|
||||
$namespaceUseClause->namespaceName = $this->parseQualifiedName($namespaceUseClause);
|
||||
if ($this->checkToken(TokenKind::AsKeyword)) {
|
||||
$namespaceUseClause->namespaceAliasingClause = $this->parseNamespaceAliasingClause($namespaceUseClause);
|
||||
}
|
||||
elseif ($this->checkToken(TokenKind::OpenBraceToken)) {
|
||||
if ($this->checkToken(TokenKind::OpenBraceToken)) {
|
||||
$namespaceUseClause->openBrace = $this->eat1(TokenKind::OpenBraceToken);
|
||||
$namespaceUseClause->groupClauses = $this->parseNamespaceUseGroupClauseList($namespaceUseClause);
|
||||
$namespaceUseClause->closeBrace = $this->eat1(TokenKind::CloseBraceToken);
|
||||
} else {
|
||||
if (!$namespaceUseClause->namespaceName) {
|
||||
$namespaceUseClause->namespaceName = new MissingToken(TokenKind::QualifiedName, $this->token->fullStart);
|
||||
}
|
||||
if ($this->checkToken(TokenKind::AsKeyword)) {
|
||||
$namespaceUseClause->namespaceAliasingClause = $this->parseNamespaceAliasingClause($namespaceUseClause);
|
||||
}
|
||||
}
|
||||
|
||||
return $namespaceUseClause;
|
||||
|
@ -3558,7 +3568,7 @@ class Parser {
|
|||
$namespaceUseGroupClause->parent = $parentNode;
|
||||
|
||||
$namespaceUseGroupClause->functionOrConst = $this->eatOptional(TokenKind::FunctionKeyword, TokenKind::ConstKeyword);
|
||||
$namespaceUseGroupClause->namespaceName = $this->parseQualifiedName($namespaceUseGroupClause);
|
||||
$namespaceUseGroupClause->namespaceName = $this->parseQualifiedName($namespaceUseGroupClause) ?? new MissingToken(TokenKind::QualifiedName, $this->token->fullStart);
|
||||
if ($this->checkToken(TokenKind::AsKeyword)) {
|
||||
$namespaceUseGroupClause->namespaceAliasingClause = $this->parseNamespaceAliasingClause($namespaceUseGroupClause);
|
||||
}
|
||||
|
|
|
@ -1 +1,8 @@
|
|||
[]
|
||||
[
|
||||
{
|
||||
"kind": 0,
|
||||
"message": "'QualifiedName' expected.",
|
||||
"start": 48,
|
||||
"length": 0
|
||||
}
|
||||
]
|
|
@ -30,7 +30,11 @@
|
|||
"kind": "ExtendsKeyword",
|
||||
"textLength": 7
|
||||
},
|
||||
"baseClass": null
|
||||
"baseClass": {
|
||||
"error": "MissingToken",
|
||||
"kind": "QualifiedName",
|
||||
"textLength": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"classInterfaceClause": null,
|
||||
|
|
|
@ -1 +1,8 @@
|
|||
[]
|
||||
[
|
||||
{
|
||||
"kind": 0,
|
||||
"message": "'QualifiedName' expected.",
|
||||
"start": 64,
|
||||
"length": 0
|
||||
}
|
||||
]
|
|
@ -17,7 +17,11 @@
|
|||
"kind": "NamespaceKeyword",
|
||||
"textLength": 9
|
||||
},
|
||||
"name": null,
|
||||
"name": {
|
||||
"error": "MissingToken",
|
||||
"kind": "QualifiedName",
|
||||
"textLength": 0
|
||||
},
|
||||
"compoundStatementOrSemicolon": {
|
||||
"kind": "SemicolonToken",
|
||||
"textLength": 1
|
||||
|
|
|
@ -1,10 +1,22 @@
|
|||
[
|
||||
{
|
||||
"kind": 0,
|
||||
"message": "'QualifiedName' expected.",
|
||||
"start": 16,
|
||||
"length": 0
|
||||
},
|
||||
{
|
||||
"kind": 0,
|
||||
"message": "';' expected.",
|
||||
"start": 16,
|
||||
"length": 0
|
||||
},
|
||||
{
|
||||
"kind": 0,
|
||||
"message": "'QualifiedName' expected.",
|
||||
"start": 26,
|
||||
"length": 0
|
||||
},
|
||||
{
|
||||
"kind": 0,
|
||||
"message": "';' expected.",
|
||||
|
|
|
@ -17,7 +17,11 @@
|
|||
"kind": "NamespaceKeyword",
|
||||
"textLength": 9
|
||||
},
|
||||
"name": null,
|
||||
"name": {
|
||||
"error": "MissingToken",
|
||||
"kind": "QualifiedName",
|
||||
"textLength": 0
|
||||
},
|
||||
"compoundStatementOrSemicolon": {
|
||||
"error": "MissingToken",
|
||||
"kind": "SemicolonToken",
|
||||
|
@ -31,7 +35,11 @@
|
|||
"kind": "NamespaceKeyword",
|
||||
"textLength": 9
|
||||
},
|
||||
"name": null,
|
||||
"name": {
|
||||
"error": "MissingToken",
|
||||
"kind": "QualifiedName",
|
||||
"textLength": 0
|
||||
},
|
||||
"compoundStatementOrSemicolon": {
|
||||
"error": "MissingToken",
|
||||
"kind": "SemicolonToken",
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
<?php
|
||||
use A\{ function };
|
|
@ -0,0 +1,8 @@
|
|||
[
|
||||
{
|
||||
"kind": 0,
|
||||
"message": "'QualifiedName' expected.",
|
||||
"start": 22,
|
||||
"length": 0
|
||||
}
|
||||
]
|
|
@ -0,0 +1,88 @@
|
|||
{
|
||||
"SourceFileNode": {
|
||||
"statementList": [
|
||||
{
|
||||
"InlineHtml": {
|
||||
"scriptSectionEndTag": null,
|
||||
"text": null,
|
||||
"scriptSectionStartTag": {
|
||||
"kind": "ScriptSectionStartTag",
|
||||
"textLength": 6
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"NamespaceUseDeclaration": {
|
||||
"useKeyword": {
|
||||
"kind": "UseKeyword",
|
||||
"textLength": 3
|
||||
},
|
||||
"functionOrConst": null,
|
||||
"useClauses": {
|
||||
"NamespaceUseClauseList": {
|
||||
"children": [
|
||||
{
|
||||
"NamespaceUseClause": {
|
||||
"namespaceName": {
|
||||
"QualifiedName": {
|
||||
"globalSpecifier": null,
|
||||
"relativeSpecifier": null,
|
||||
"nameParts": [
|
||||
{
|
||||
"kind": "Name",
|
||||
"textLength": 1
|
||||
},
|
||||
{
|
||||
"kind": "BackslashToken",
|
||||
"textLength": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"namespaceAliasingClause": null,
|
||||
"openBrace": {
|
||||
"kind": "OpenBraceToken",
|
||||
"textLength": 1
|
||||
},
|
||||
"groupClauses": {
|
||||
"NamespaceUseGroupClauseList": {
|
||||
"children": [
|
||||
{
|
||||
"NamespaceUseGroupClause": {
|
||||
"functionOrConst": {
|
||||
"kind": "FunctionKeyword",
|
||||
"textLength": 8
|
||||
},
|
||||
"namespaceName": {
|
||||
"error": "MissingToken",
|
||||
"kind": "QualifiedName",
|
||||
"textLength": 0
|
||||
},
|
||||
"namespaceAliasingClause": null
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"closeBrace": {
|
||||
"kind": "CloseBraceToken",
|
||||
"textLength": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"semicolon": {
|
||||
"kind": "SemicolonToken",
|
||||
"textLength": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"endOfFileToken": {
|
||||
"kind": "EndOfFileToken",
|
||||
"textLength": 0
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче