Fixed an index out of bounds bug. Updated ddoc
This commit is contained in:
parent
e91316cc9a
commit
50ddf8abf8
|
@ -90,8 +90,8 @@ Module parseModule(const(Token)[] tokens, string fileName)
|
|||
parser.fileName = fileName;
|
||||
parser.tokens = tokens;
|
||||
auto mod = parser.parseModule();
|
||||
writefln("Parsing finished with %d errors and %d warnings.",
|
||||
parser.errorCount, parser.warningCount);
|
||||
// writefln("Parsing finished with %d errors and %d warnings.",
|
||||
// parser.errorCount, parser.warningCount);
|
||||
return mod;
|
||||
}
|
||||
|
||||
|
@ -1774,6 +1774,7 @@ class ClassFour(A, B) if (someTest()) : Super {}}c;
|
|||
break;
|
||||
default:
|
||||
error("Declaration expected");
|
||||
if (moreTokens())
|
||||
advance();
|
||||
return null;
|
||||
}
|
||||
|
@ -1785,7 +1786,7 @@ class ClassFour(A, B) if (someTest()) : Super {}}c;
|
|||
*
|
||||
* $(GRAMMAR $(RULEDEF declarationsAndStatements):
|
||||
* $(RULE declarationOrStatement)+
|
||||
* ;
|
||||
* ;)
|
||||
*/
|
||||
DeclarationsAndStatements parseDeclarationsAndStatements()
|
||||
{
|
||||
|
@ -3176,7 +3177,10 @@ invariant() foo();
|
|||
* Parses a LambdaExpression
|
||||
*
|
||||
* $(GRAMMAR $(RULEDEF lambdaExpression):
|
||||
* ($(LITERAL Identifier) | $(RULE parameters) $(RULE functionAttribute)* ) $(LITERAL '=>') $(RULE assignExpression)
|
||||
* $(LITERAL Identifier) $(LITERAL '=>') $(RULE assignExpression)
|
||||
* | $(LITERAL 'function') $(RULE parameters) $(RULE functionAttribute)* $(LITERAL '=>') $(RULE assignExpression)
|
||||
* | $(LITERAL 'delegate') $(RULE parameters) $(RULE functionAttribute)* $(LITERAL '=>') $(RULE assignExpression)
|
||||
* | $(RULE parameters) $(RULE functionAttribute)* $(LITERAL '=>') $(RULE assignExpression)
|
||||
* ;)
|
||||
*/
|
||||
LambdaExpression parseLambdaExpression()
|
||||
|
@ -3301,8 +3305,13 @@ invariant() foo();
|
|||
auto node = new MixinDeclaration;
|
||||
if (peekIs(TokenType.identifier))
|
||||
node.templateMixinExpression = parseTemplateMixinExpression();
|
||||
else
|
||||
else if (peekIs(TokenType.lParen))
|
||||
node.mixinExpression = parseMixinExpression();
|
||||
else
|
||||
{
|
||||
error(`"(" or identifier expected`);
|
||||
return null;
|
||||
}
|
||||
expect(TokenType.semicolon);
|
||||
return node;
|
||||
}
|
||||
|
@ -4034,6 +4043,20 @@ q{(int a, ...)
|
|||
break;
|
||||
case function_:
|
||||
case delegate_:
|
||||
if (peekIs(lParen))
|
||||
{
|
||||
auto b = setBookmark();
|
||||
advance(); // function | delegate
|
||||
skipParens();
|
||||
if (currentIs(goesTo))
|
||||
{
|
||||
goToBookmark(b);
|
||||
goto lambda;
|
||||
}
|
||||
else
|
||||
goToBookmark(b);
|
||||
}
|
||||
goto case;
|
||||
case lBrace:
|
||||
case in_:
|
||||
case out_:
|
||||
|
@ -4063,6 +4086,7 @@ q{(int a, ...)
|
|||
if (currentIs(goesTo))
|
||||
{
|
||||
goToBookmark(b);
|
||||
lambda:
|
||||
node.lambdaExpression = parseLambdaExpression();
|
||||
}
|
||||
else if (currentIs(lBrace))
|
||||
|
@ -6140,7 +6164,7 @@ private:
|
|||
auto column = index < tokens.length ? tokens[index].column : 0;
|
||||
auto line = index < tokens.length ? tokens[index].line : 0;
|
||||
if (messageFunction is null)
|
||||
writefln("^^ %s(%d:%d): %s", fileName, line, column, message);
|
||||
writefln("%s(%d:%d)[warn]: %s", fileName, line, column, message);
|
||||
else
|
||||
messageFunction(fileName, line, column, message);
|
||||
}
|
||||
|
@ -6155,7 +6179,7 @@ private:
|
|||
column++;
|
||||
auto line = index < tokens.length ? tokens[index].line : 0;
|
||||
if (messageFunction is null)
|
||||
stderr.writefln("!! %s(%d:%d): %s", fileName, line, column, message);
|
||||
writefln("%s(%d:%d)[error]: %s", fileName, line, column, message);
|
||||
else
|
||||
messageFunction(fileName, line, column, message);
|
||||
}
|
||||
|
@ -6275,7 +6299,7 @@ private:
|
|||
* Returns a token of the specified type if it was the next token, otherwise
|
||||
* calls the error function and returns null.
|
||||
*/
|
||||
const(Token)* expect(TokenType type, string loc = __PRETTY_FUNCTION__)
|
||||
const(Token)* expect(TokenType type)
|
||||
{
|
||||
if (index < tokens.length && tokens[index].type == type)
|
||||
return &tokens[index++];
|
||||
|
@ -6283,10 +6307,10 @@ private:
|
|||
{
|
||||
if (tokenValues[type] is null)
|
||||
error("Expected " ~ to!string(type) ~ " instead of "
|
||||
~ (index < tokens.length ? tokens[index].value : "EOF") ~ " at " ~ loc);
|
||||
~ (index < tokens.length ? tokens[index].value : "EOF"));
|
||||
else
|
||||
error("Expected " ~ tokenValues[type] ~ " instead of "
|
||||
~ (index < tokens.length ? tokens[index].value : "EOF") ~ " at " ~ loc);
|
||||
~ (index < tokens.length ? tokens[index].value : "EOF"));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue