Fixes issue #41

This commit is contained in:
Hackerpilot 2013-07-29 13:34:34 -07:00
parent ae0299c38d
commit 0a07ae5862
3 changed files with 5 additions and 40 deletions

View File

@ -195,7 +195,7 @@ class XMLPrinter : ASTVisitor
override void visit(BreakStatement breakStatement) override void visit(BreakStatement breakStatement)
{ {
if (breakStatement.label.type == TokenType.invalid) if (breakStatement.label.type == TokenType.invalid)
output.writeln("<breakStatement>"); output.writeln("<breakStatement/>");
else else
output.writeln("<breakStatement label=\"", breakStatement.label, "\">"); output.writeln("<breakStatement label=\"", breakStatement.label, "\">");
} }
@ -1098,11 +1098,6 @@ class XMLPrinter : ASTVisitor
mixin (tagAndAccept!"structMemberInitializers"); mixin (tagAndAccept!"structMemberInitializers");
} }
override void visit(SwitchBody switchBody)
{
mixin (tagAndAccept!"switchBody");
}
override void visit(SwitchStatement switchStatement) override void visit(SwitchStatement switchStatement)
{ {
mixin (tagAndAccept!"switchStatement"); mixin (tagAndAccept!"switchStatement");

View File

@ -186,7 +186,6 @@ public:
/** */ void visit(StructInitializer structInitializer) { structInitializer.accept(this); } /** */ void visit(StructInitializer structInitializer) { structInitializer.accept(this); }
/** */ void visit(StructMemberInitializer structMemberInitializer) { structMemberInitializer.accept(this); } /** */ void visit(StructMemberInitializer structMemberInitializer) { structMemberInitializer.accept(this); }
/** */ void visit(StructMemberInitializers structMemberInitializers) { structMemberInitializers.accept(this); } /** */ void visit(StructMemberInitializers structMemberInitializers) { structMemberInitializers.accept(this); }
/** */ void visit(SwitchBody switchBody) { switchBody.accept(this); }
/** */ void visit(SwitchStatement switchStatement) { switchStatement.accept(this); } /** */ void visit(SwitchStatement switchStatement) { switchStatement.accept(this); }
/** */ void visit(Symbol symbol) { symbol.accept(this); } /** */ void visit(Symbol symbol) { symbol.accept(this); }
/** */ void visit(SynchronizedStatement synchronizedStatement) { synchronizedStatement.accept(this); } /** */ void visit(SynchronizedStatement synchronizedStatement) { synchronizedStatement.accept(this); }
@ -2254,27 +2253,16 @@ public:
/** */ StructMemberInitializer[] structMemberInitializers; /** */ StructMemberInitializer[] structMemberInitializers;
} }
///
class SwitchBody : ASTNode
{
public:
override void accept(ASTVisitor visitor)
{
mixin (visitIfNotNull!(statements));
}
/** */ Statement[] statements;
}
/// ///
class SwitchStatement : ASTNode class SwitchStatement : ASTNode
{ {
public: public:
override void accept(ASTVisitor visitor) override void accept(ASTVisitor visitor)
{ {
mixin (visitIfNotNull!(expression, switchBody)); mixin (visitIfNotNull!(expression, statement));
} }
/** */ Expression expression; /** */ Expression expression;
/** */ SwitchBody switchBody; /** */ Statement statement;
} }
/// ///

View File

@ -4640,29 +4640,11 @@ q{(int a, ...)
return node; return node;
} }
/**
* Parses a SwitchBody
*
* $(GRAMMAR $(RULEDEF switchBody):
* $(LITERAL '{') $(RULE statement)+ $(LITERAL '}')
* ;)
*/
SwitchBody parseSwitchBody()
{
mixin(traceEnterAndExit!(__FUNCTION__));
auto node = new SwitchBody;
expect(TokenType.lBrace);
while (moreTokens() && tokens[index] != TokenType.rBrace)
node.statements ~= parseStatement();
expect(TokenType.rBrace);
return node;
}
/** /**
* Parses a SwitchStatement * Parses a SwitchStatement
* *
* $(GRAMMAR $(RULEDEF switchStatement): * $(GRAMMAR $(RULEDEF switchStatement):
* $(LITERAL 'switch') $(LITERAL '$(LPAREN)') $(RULE expression) $(LITERAL '$(RPAREN)') $(RULE switchBody) * $(LITERAL 'switch') $(LITERAL '$(LPAREN)') $(RULE expression) $(LITERAL '$(RPAREN)') $(RULE statement)
* ;) * ;)
*/ */
SwitchStatement parseSwitchStatement() SwitchStatement parseSwitchStatement()
@ -4673,7 +4655,7 @@ q{(int a, ...)
expect(TokenType.lParen); expect(TokenType.lParen);
node.expression = parseExpression(); node.expression = parseExpression();
expect(TokenType.rParen); expect(TokenType.rParen);
node.switchBody = parseSwitchBody(); node.statement = parseStatement();
return node; return node;
} }