Fewer TODO comments

This commit is contained in:
Hackerpilot 2013-06-27 22:08:46 -07:00
parent ad8b4fdeaa
commit 859ddd3d20
2 changed files with 129 additions and 100 deletions

View File

@ -58,7 +58,6 @@ abstract class ASTVisitor
/** */ void visit(AssertExpression assertExpression) { assertExpression.accept(this); } /** */ void visit(AssertExpression assertExpression) { assertExpression.accept(this); }
/** */ void visit(AssertStatement assertStatement) { assertStatement.accept(this); } /** */ void visit(AssertStatement assertStatement) { assertStatement.accept(this); }
/** */ void visit(AssignExpression assignExpression) { assignExpression.accept(this); } /** */ void visit(AssignExpression assignExpression) { assignExpression.accept(this); }
/** */ void visit(AssignStatement assignStatement) { assignStatement.accept(this); }
/** */ void visit(AssocArrayLiteral assocArrayLiteral) { assocArrayLiteral.accept(this); } /** */ void visit(AssocArrayLiteral assocArrayLiteral) { assocArrayLiteral.accept(this); }
/** */ void visit(AtAttribute atAttribute) { atAttribute.accept(this); } /** */ void visit(AtAttribute atAttribute) { atAttribute.accept(this); }
/** */ void visit(Attribute attribute) { attribute.accept(this); } /** */ void visit(Attribute attribute) { attribute.accept(this); }
@ -542,18 +541,6 @@ public:
/** */ TokenType operator; /** */ TokenType operator;
} }
///
class AssignStatement : ASTNode
{
public:
mixin(DEFAULT_ACCEPT);
/** */ PreIncDecExpression preIncDecExpression;
/** */ PostIncDecExpression postIncDecExpression;
/** */ UnaryExpression[] unaryExpressions;
/** */ AssignExpression[] assignExpressions;
/** */ TokenType[] assignOperators;
}
/// ///
class AssocArrayLiteral : ASTNode class AssocArrayLiteral : ASTNode
{ {
@ -1482,7 +1469,6 @@ public:
mixin(DEFAULT_ACCEPT); mixin(DEFAULT_ACCEPT);
/** */ LabeledStatement labeledStatement; /** */ LabeledStatement labeledStatement;
/** */ BlockStatement blockStatement; /** */ BlockStatement blockStatement;
/** */ AssignStatement assignStatement;
/** */ IfStatement ifStatement; /** */ IfStatement ifStatement;
/** */ WhileStatement whileStatement; /** */ WhileStatement whileStatement;
/** */ DoStatement doStatement; /** */ DoStatement doStatement;

View File

@ -375,7 +375,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmAndExp parseAsmAndExp() AsmAndExp parseAsmAndExp()
{ {
auto node = new AsmAndExp; auto node = new AsmAndExp;
// TODO // TODO asm
return node; return node;
} }
@ -390,7 +390,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmBrExp parseAsmBrExp() AsmBrExp parseAsmBrExp()
{ {
auto node = new AsmBrExp; auto node = new AsmBrExp;
// TODO // TODO asm
return node; return node;
} }
@ -404,7 +404,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmEqualExp parseAsmEqualExp() AsmEqualExp parseAsmEqualExp()
{ {
auto node = new AsmEqualExp; auto node = new AsmEqualExp;
// TODO // TODO asm
return node; return node;
} }
@ -418,7 +418,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmExp parseAsmExp() AsmExp parseAsmExp()
{ {
auto node = new AsmExp; auto node = new AsmExp;
// TODO // TODO asm
return node; return node;
} }
@ -437,7 +437,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmInstruction parseAsmInstruction() AsmInstruction parseAsmInstruction()
{ {
auto node = new AsmInstruction; auto node = new AsmInstruction;
// TODO // TODO asm
return node; return node;
} }
@ -451,7 +451,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmLogAndExp parseAsmLogAndExp() AsmLogAndExp parseAsmLogAndExp()
{ {
auto node = new AsmLogAndExp; auto node = new AsmLogAndExp;
// TODO // TODO asm
return node; return node;
} }
@ -465,7 +465,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmLogOrExp parseAsmLogOrExp() AsmLogOrExp parseAsmLogOrExp()
{ {
auto node = new AsmLogOrExp; auto node = new AsmLogOrExp;
// TODO // TODO asm
return node; return node;
} }
@ -479,7 +479,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmMulExp parseAsmMulExp() AsmMulExp parseAsmMulExp()
{ {
auto node = new AsmMulExp; auto node = new AsmMulExp;
// TODO // TODO asm
return node; return node;
} }
@ -493,7 +493,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmOrExp parseAsmOrExp() AsmOrExp parseAsmOrExp()
{ {
auto node = new AsmOrExp; auto node = new AsmOrExp;
// TODO // TODO asm
return node; return node;
} }
@ -511,7 +511,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmPrimaryExp parseAsmPrimaryExp() AsmPrimaryExp parseAsmPrimaryExp()
{ {
auto node = new AsmPrimaryExp; auto node = new AsmPrimaryExp;
// TODO // TODO asm
return node; return node;
} }
@ -525,7 +525,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmRelExp parseAsmRelExp() AsmRelExp parseAsmRelExp()
{ {
auto node = new AsmRelExp; auto node = new AsmRelExp;
// TODO // TODO asm
return node; return node;
} }
@ -539,7 +539,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmShiftExp parseAsmShiftExp() AsmShiftExp parseAsmShiftExp()
{ {
auto node = new AsmShiftExp; auto node = new AsmShiftExp;
// TODO // TODO asm
return node; return node;
} }
@ -553,7 +553,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmStatement parseAsmStatement() AsmStatement parseAsmStatement()
{ {
auto node = new AsmStatement; auto node = new AsmStatement;
// TODO // TODO asm
return node; return node;
} }
@ -573,7 +573,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmTypePrefix parseAsmTypePrefix() AsmTypePrefix parseAsmTypePrefix()
{ {
auto node = new AsmTypePrefix; auto node = new AsmTypePrefix;
// TODO // TODO asm
return node; return node;
} }
@ -593,7 +593,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmUnaExp parseAsmUnaExp() AsmUnaExp parseAsmUnaExp()
{ {
auto node = new AsmUnaExp; auto node = new AsmUnaExp;
// TODO // TODO asm
return node; return node;
} }
@ -607,7 +607,7 @@ alias core.sys.posix.stdio.fileno fileno;
AsmXorExp parseAsmXorExp() AsmXorExp parseAsmXorExp()
{ {
auto node = new AsmXorExp; auto node = new AsmXorExp;
// TODO // TODO asm
return node; return node;
} }
@ -674,21 +674,6 @@ alias core.sys.posix.stdio.fileno fileno;
return node; return node;
} }
/**
* Parses an AssignStatement
*
* $(GRAMMAR $(RULEDEF assignStatement):
* $(RULE unaryExpression) $(RULE assignOperator) $(RULE assignExpression) ($(LITERAL ',') $(RULE unaryExpression) $(RULE assignOperator) $(RULE assignExpression))* $(LITERAL ';')
* ;)
*/
AssignStatement parseAssignStatement()
{
auto node = new AssignStatement;
// TODO
if (expect(TokenType.semicolon) is null) return null;
return node;
}
/** /**
* Parses an AssocArrayLiteral * Parses an AssocArrayLiteral
* *
@ -855,7 +840,22 @@ alias core.sys.posix.stdio.fileno fileno;
AutoDeclaration parseAutoDeclaration() AutoDeclaration parseAutoDeclaration()
{ {
auto node = new AutoDeclaration; auto node = new AutoDeclaration;
// TODO node.storageClass = parseStorageClass();
if (node.storageClass is null) return null;
do
{
auto ident = expect(TokenType.identifier);
if (ident is null) return null;
node.identifiers ~= *ident;
if (expect(TokenType.assign) is null) return null;
auto init = parseInitializer();
if (init is null) return null;
node.initializers ~= init;
if (currentIs(TokenType.comma))
advance();
else
break;
} while (true);
return node; return node;
} }
@ -2014,7 +2014,7 @@ class ClassFour(A, B) if (someTest()) : Super {}}c;
EnumMember parseEnumMember() EnumMember parseEnumMember()
{ {
auto node = new EnumMember; auto node = new EnumMember;
// TODO // TODO: ambiguity between type and identifier
return node; return node;
} }
@ -2103,13 +2103,17 @@ class ClassFour(A, B) if (someTest()) : Super {}}c;
*/ */
ForStatement parseForStatement() ForStatement parseForStatement()
{ {
// forStatement:
// 'for' '(' declarationOrStatement expression? ';' expression? ')' statementNoCaseNoDefault
// ;
auto node = new ForStatement; auto node = new ForStatement;
expect(TokenType.for_); if (expect(TokenType.for_) is null) return null;
expect(TokenType.lParen); if (expect(TokenType.lParen) is null) return null;
// TODO // TODO
assert (0); assert (0);
expect(TokenType.rParen); if (expect(TokenType.rParen) is null) return null;
node.statementNoCaseNoDefault = parseStatementNoCaseNoDefault(); node.statementNoCaseNoDefault = parseStatementNoCaseNoDefault();
if (node.statementNoCaseNoDefault is null) return null;
return node; return node;
} }
@ -2417,7 +2421,31 @@ body {} // six
FunctionLiteralExpression parseFunctionLiteralExpression() FunctionLiteralExpression parseFunctionLiteralExpression()
{ {
auto node = new FunctionLiteralExpression; auto node = new FunctionLiteralExpression;
// TODO if (currentIsOneOf(TokenType.function_, TokenType.delegate_))
{
node.functionOrDelegate = advance().type;
if (!currentIsOneOf(TokenType.lParen, TokenType.in_, TokenType.body_,
TokenType.out_, TokenType.rBrace))
{
node.type = parseType();
if (node.type is null) return null;
}
}
if (currentIs(TokenType.lParen))
{
node.parameters = parseParameters();
if (node.parameters is null) return null;
do
{
auto attr = parseFunctionAttribute(false);
if (attr is null)
break;
else
node.functionAttributes ~= attr;
} while (true);
}
node.functionBody = parseFunctionBody();
if (node.functionBody is null) return null;
return node; return node;
} }
@ -3319,7 +3347,6 @@ invariant() foo();
* $(GRAMMAR $(RULEDEF statementNoCaseNoDefault): * $(GRAMMAR $(RULEDEF statementNoCaseNoDefault):
* $(RULE labeledStatement) * $(RULE labeledStatement)
* | $(RULE blockStatement) * | $(RULE blockStatement)
* | $(RULE assignStatement)
* | $(RULE ifStatement) * | $(RULE ifStatement)
* | $(RULE whileStatement) * | $(RULE whileStatement)
* | $(RULE doStatement) * | $(RULE doStatement)
@ -4801,7 +4828,7 @@ q{(int a, ...)
TraitsArgument parseTraitsArgument() TraitsArgument parseTraitsArgument()
{ {
auto node = new TraitsArgument; auto node = new TraitsArgument;
// TODO if ()
return node; return node;
} }
@ -5100,7 +5127,16 @@ q{(int a, ...)
auto node = new TypeidExpression; auto node = new TypeidExpression;
expect(TokenType.typeid_); expect(TokenType.typeid_);
expect(TokenType.lParen); expect(TokenType.lParen);
// TODO if (isExpression())
{
node.expression = parseExpression();
if (node.expression is null) return null;
}
else
{
node.type = parseType();
if (node.type is null) return null;
}
expect(TokenType.rParen); expect(TokenType.rParen);
return node; return node;
} }
@ -5481,6 +5517,13 @@ private:
return parseStatement() !is null; return parseStatement() !is null;
} }
bool isExpression()
{
auto b = setBookmark();
scope (exit) goToBookmark(b);
return parseExpression() !is null;
}
bool currentIsMemberFunctionAttribute() const bool currentIsMemberFunctionAttribute() const
{ {
switch (current.type) switch (current.type)