Merge pull request #144 from callumenator/class-decl

Allow for just identifier in class and interface decl
This commit is contained in:
Hackerpilot 2014-03-08 20:31:00 -08:00
commit 6db7a268dc
1 changed files with 12 additions and 2 deletions

View File

@ -1309,7 +1309,7 @@ incorrect;
* Parses a ClassDeclaration * Parses a ClassDeclaration
* *
* $(GRAMMAR $(RULEDEF classDeclaration): * $(GRAMMAR $(RULEDEF classDeclaration):
* $(LITERAL 'class') $(LITERAL Identifier) ($(RULE templateParameters) $(RULE constraint)?)? ($(LITERAL ':') $(RULE baseClassList))? $(RULE structBody) * $(LITERAL 'class') $(LITERAL Identifier) ($(LITERAL ';') | ($(RULE templateParameters) $(RULE constraint)?)? ($(LITERAL ':') $(RULE baseClassList))? $(RULE structBody))
* ;) * ;)
*/ */
ClassDeclaration parseClassDeclaration() ClassDeclaration parseClassDeclaration()
@ -1322,6 +1322,11 @@ incorrect;
node.name = *ident; node.name = *ident;
node.comment = comment; node.comment = comment;
comment = null; comment = null;
if (currentIs(tok!";"))
{
advance();
return node;
}
if (currentIs(tok!"(")) if (currentIs(tok!"("))
{ {
node.templateParameters = parseTemplateParameters(); node.templateParameters = parseTemplateParameters();
@ -3186,7 +3191,7 @@ import core.stdc.stdio, std.string : KeepTerminator;
* Parses an InterfaceDeclaration * Parses an InterfaceDeclaration
* *
* $(GRAMMAR $(RULEDEF interfaceDeclaration): * $(GRAMMAR $(RULEDEF interfaceDeclaration):
* $(LITERAL 'interface') $(LITERAL Identifier) ($(RULE templateParameters) $(RULE constraint)?)? ($(LITERAL ':') $(RULE baseClassList))? $(RULE structBody) * $(LITERAL 'interface') $(LITERAL Identifier) ($(LITERAL ';') | ($(RULE templateParameters) $(RULE constraint)?)? ($(LITERAL ':') $(RULE baseClassList))? $(RULE structBody))
* ;) * ;)
*/ */
InterfaceDeclaration parseInterfaceDeclaration() InterfaceDeclaration parseInterfaceDeclaration()
@ -3198,6 +3203,11 @@ import core.stdc.stdio, std.string : KeepTerminator;
node.name = *ident; node.name = *ident;
node.comment = comment; node.comment = comment;
comment = null; comment = null;
if (currentIs(tok!";"))
{
advance();
return node;
}
if (currentIs(tok!"(")) if (currentIs(tok!"("))
{ {
node.templateParameters = parseTemplateParameters(); node.templateParameters = parseTemplateParameters();