This commit is contained in:
Hackerpilot 2013-10-29 13:54:22 -07:00
parent 9952bfced1
commit f593299623
3 changed files with 34 additions and 22 deletions

View File

@ -493,6 +493,20 @@ class XMLPrinter : ASTVisitor
{ {
output.writeln("<foreachStatement type=\"", getTokenValue( output.writeln("<foreachStatement type=\"", getTokenValue(
foreachStatement.type), "\">"); foreachStatement.type), "\">");
if (foreachStatement.foreachType !is null)
visit(foreachStatement.foreachType);
if (foreachStatement.foreachTypeList !is null)
visit(foreachStatement.foreachTypeList);
output.writeln("<low>");
visit(foreachStatement.low);
output.writeln("</low>");
if (foreachStatement.high !is null)
{
output.writeln("<high>");
visit(foreachStatement.high);
output.writeln("</high>");
}
visit(foreachStatement.declarationOrStatement);
output.writeln("</foreachStatement>"); output.writeln("</foreachStatement>");
} }
@ -571,18 +585,14 @@ class XMLPrinter : ASTVisitor
} }
} }
override void visit(IdentifierChain chain) override void visit(IdentifierChain identifierChain)
{ {
output.writeln("<identifierChain>"); mixin (tagAndAccept!"identifierChain");
chain.accept(this);
output.writeln("</identifierChain>");
} }
override void visit(IdentifierList list) override void visit(IdentifierList identifierList)
{ {
output.writeln("<identifierList>"); mixin (tagAndAccept!"identifierList");
list.accept(this);
output.writeln("</identifierList>");
} }
override void visit(IdentifierOrTemplateChain identifierOrTemplateChain) override void visit(IdentifierOrTemplateChain identifierOrTemplateChain)

View File

@ -1205,14 +1205,14 @@ public:
override void accept(ASTVisitor visitor) override void accept(ASTVisitor visitor)
{ {
mixin (visitIfNotNull!(foreachType, foreachTypeList, low, high, mixin (visitIfNotNull!(foreachType, foreachTypeList, low, high,
statementNoCaseNoDefault)); declarationOrStatement));
} }
/** */ TokenType type; /** */ TokenType type;
/** */ ForeachTypeList foreachTypeList; /** */ ForeachTypeList foreachTypeList;
/** */ ForeachType foreachType; /** */ ForeachType foreachType;
/** */ Expression low; /** */ Expression low;
/** */ Expression high; /** */ Expression high;
/** */ StatementNoCaseNoDefault statementNoCaseNoDefault; /** */ DeclarationOrStatement declarationOrStatement;
/** */ size_t startIndex; /** */ size_t startIndex;
} }

View File

@ -1815,12 +1815,12 @@ class ClassFour(A, B) if (someTest()) : Super {}}c;
// Declarations are resolved by the declarations taking precedence." // Declarations are resolved by the declarations taking precedence."
if (isDeclaration()) if (isDeclaration())
{ {
trace("+++ parsing declaration"); trace("\033[01;36mparsing declaration");
node.declaration = parseDeclaration(); node.declaration = parseDeclaration();
} }
else else
{ {
trace("+++ parsing statement"); trace("\033[01;36mparsing statement");
node.statement = parseStatement(); node.statement = parseStatement();
} }
@ -2232,13 +2232,13 @@ class ClassFour(A, B) if (someTest()) : Super {}}c;
node.foreachTypeList = feType; node.foreachTypeList = feType;
} }
if (expect(TokenType.rParen) is null) return null; if (expect(TokenType.rParen) is null) return null;
if (currentIs(TokenType.rBrace)) if (currentIs(TokenType.rBrace))
{ {
error("Statement expected", false); error("Statement expected", false);
return node; // this line makes DCD better return node; // this line makes DCD better
} }
node.statementNoCaseNoDefault = parseStatementNoCaseNoDefault(); node.declarationOrStatement = parseDeclarationOrStatement();
if (node.statementNoCaseNoDefault is null) return null; if (node.declarationOrStatement is null) return null;
return node; return node;
} }
@ -2256,7 +2256,7 @@ class ClassFour(A, B) if (someTest()) : Super {}}c;
if (currentIsOneOf(TokenType.ref_, TokenType.const_, TokenType.immutable_, if (currentIsOneOf(TokenType.ref_, TokenType.const_, TokenType.immutable_,
TokenType.shared_, TokenType.inout_)) TokenType.shared_, TokenType.inout_))
{ {
trace("+++ Type constructor"); trace("\033[01;36mType constructor");
if ((node.typeConstructors = parseTypeConstructors()) is null) if ((node.typeConstructors = parseTypeConstructors()) is null)
return null; return null;
} }
@ -6507,8 +6507,10 @@ protected:
template traceEnterAndExit(string fun) template traceEnterAndExit(string fun)
{ {
enum traceEnterAndExit = `version (std_parser_verbose) trace(">>> ` ~ fun ~ ` ");` enum traceEnterAndExit = `version (std_parser_verbose) trace("`
~ `version (std_parser_verbose) scope(exit) trace("<<< ` ~ fun ~ ` ");`; ~ "\033[01;32m" ~ fun ~ "\033[0m" ~ ` ");`
~ `version (std_parser_verbose) scope(exit) trace("`
~ "\033[01;31m" ~ fun ~ "\033[0m" ~ ` ");`;
} }
version (std_parser_verbose) version (std_parser_verbose)