Skip to content

Commit 0a577eb

Browse files
bangbangsheshotmedownWebFreak001
authored andcommitted
Add support for the new alias this declaration syntax
1 parent 381ff7b commit 0a577eb

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

src/dparse/parser.d

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,17 +282,27 @@ class Parser
282282
* Parses an AliasThisDeclaration.
283283
*
284284
* $(GRAMMAR $(RULEDEF aliasThisDeclaration):
285-
* $(LITERAL 'alias') $(LITERAL Identifier) $(LITERAL 'this') $(LITERAL ';')
286-
* ;)
285+
* $(LITERAL 'alias') $(LITERAL Identifier) $(LITERAL 'this') $(LITERAL ';')
286+
* | $(LITERAL 'alias') $(LITERAL 'this') $(LITERAL '=') $(LITERAL Identifier) $(LITERAL ';')
287+
* ;)
287288
*/
288289
AliasThisDeclaration parseAliasThisDeclaration()
289290
{
290291
mixin(traceEnterAndExit!(__FUNCTION__));
291292
auto startIndex = index;
292293
auto node = allocator.make!AliasThisDeclaration;
293294
mixin(tokenCheck!"alias");
294-
mixin(tokenCheck!(`node.identifier`, "identifier"));
295-
mixin(tokenCheck!"this");
295+
if (currentIs(tok!"this"))
296+
{
297+
advance();
298+
mixin(tokenCheck!"=");
299+
mixin(tokenCheck!(`node.identifier`, "identifier"));
300+
}
301+
else
302+
{
303+
mixin(tokenCheck!(`node.identifier`, "identifier"));
304+
mixin(tokenCheck!"this");
305+
}
296306
return attachCommentFromSemicolon(node, startIndex);
297307
}
298308

@@ -2315,7 +2325,8 @@ class Parser
23152325
mixin(tokenCheck!"}");
23162326
break;
23172327
case tok!"alias":
2318-
if (startsWith(tok!"alias", tok!"identifier", tok!"this"))
2328+
if (startsWith(tok!"alias", tok!"identifier", tok!"this")
2329+
|| startsWith(tok!"alias", tok!"this", tok!"="))
23192330
mixin(parseNodeQ!(`node.aliasThisDeclaration`, `AliasThisDeclaration`));
23202331
else
23212332
mixin(parseNodeQ!(`node.aliasDeclaration`, `AliasDeclaration`));

0 commit comments

Comments
 (0)