diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.gitmodules b/.gitmodules old mode 100644 new mode 100755 diff --git a/LICENSE_1_0.txt b/LICENSE_1_0.txt old mode 100644 new mode 100755 diff --git a/autocomplete.d b/autocomplete.d old mode 100644 new mode 100755 diff --git a/createTable.sql b/createTable.sql old mode 100644 new mode 100755 diff --git a/ctags.d b/ctags.d old mode 100644 new mode 100755 diff --git a/dsc.sublime-project b/dsc.sublime-project old mode 100644 new mode 100755 diff --git a/editors/textadept/README.txt b/editors/textadept/README.txt old mode 100644 new mode 100755 diff --git a/editors/vim/README.md b/editors/vim/README.md old mode 100644 new mode 100755 diff --git a/editors/vim/autoload/dcomplete.vim b/editors/vim/autoload/dcomplete.vim old mode 100644 new mode 100755 diff --git a/editors/vim/ftplugin/d.vim b/editors/vim/ftplugin/d.vim old mode 100644 new mode 100755 diff --git a/makefile b/makefile old mode 100644 new mode 100755 diff --git a/schema/dscanner-schema.json b/schema/dscanner-schema.json old mode 100644 new mode 100755 diff --git a/std/d/ast.d b/std/d/ast.d index e2b76e4..b126982 100755 --- a/std/d/ast.d +++ b/std/d/ast.d @@ -141,6 +141,7 @@ abstract class ASTVisitor /** */ void visit(MemberFunctionAttribute memberFunctionAttribute) { memberFunctionAttribute.accept(this); } /** */ void visit(MixinDeclaration mixinDeclaration) { mixinDeclaration.accept(this); } /** */ void visit(MixinExpression mixinExpression) { mixinExpression.accept(this); } + /** */ void visit(MixinTemplateDeclaration mixinTemplateDeclaration) { mixinTemplateDeclaration.accept(this); } /** */ void visit(MixinTemplateName mixinTemplateName) { mixinTemplateName.accept(this); } /** */ void visit(Module module_) { module_.accept(this); } /** */ void visit(ModuleDeclaration moduleDeclaration) { moduleDeclaration.accept(this); } @@ -195,7 +196,7 @@ abstract class ASTVisitor /** */ void visit(TemplateArguments templateArguments) { templateArguments.accept(this); } /** */ void visit(TemplateDeclaration templateDeclaration) { templateDeclaration.accept(this); } /** */ void visit(TemplateInstance templateInstance) { templateInstance.accept(this); } - /** */ void visit(TemplateMixinStatement templateMixinStatement) { templateMixinStatement.accept(this); } + /** */ void visit(TemplateMixinExpression templateMixinExpression) { templateMixinExpression.accept(this); } /** */ void visit(TemplateParameter templateParameter) { templateParameter.accept(this); } /** */ void visit(TemplateParameterList templateParameterList) { templateParameterList.accept(this); } /** */ void visit(TemplateParameters templateParameters) { templateParameters.accept(this); } @@ -812,6 +813,7 @@ public: if (enumDeclaration !is null) visitor.visit(enumDeclaration); if (aliasDeclaration !is null) visitor.visit(aliasDeclaration); if (mixinDeclaration !is null) visitor.visit(mixinDeclaration); + if (mixinTemplateDeclaration !is null) visitor.visit(mixinTemplateDeclaration); if (unittest_ !is null) visitor.visit(unittest_); if (staticAssertDeclaration !is null) visitor.visit(staticAssertDeclaration); if (templateDeclaration !is null) visitor.visit(templateDeclaration); @@ -838,6 +840,7 @@ public: /** */ EnumDeclaration enumDeclaration; /** */ AliasDeclaration aliasDeclaration; /** */ MixinDeclaration mixinDeclaration; + /** */ MixinTemplateDeclaration mixinTemplateDeclaration; /** */ Unittest unittest_; /** */ StaticAssertDeclaration staticAssertDeclaration; /** */ TemplateDeclaration templateDeclaration; @@ -1363,6 +1366,7 @@ class MixinDeclaration : ASTNode public: mixin(DEFAULT_ACCEPT); /** */ MixinExpression mixinExpression; + /** */ TemplateMixinExpression templateMixinExpression; } /// @@ -1373,6 +1377,14 @@ public: /** */ AssignExpression assignExpression; } +/// +class MixinTemplateDeclaration : ASTNode +{ +public: + mixin(DEFAULT_ACCEPT); + /** */ TemplateDeclaration templateDeclaration; +} + /// class MixinTemplateName : ASTNode { @@ -1466,7 +1478,6 @@ public: /** */ AsmStatement asmStatement; /** */ ConditionalStatement conditionalStatement; /** */ StaticAssertStatement staticAssertStatement; - /** */ TemplateMixinStatement templateMixinStatement; /** */ VersionSpecification versionSpecification; /** */ DebugSpecification debugSpecification; /** */ FunctionCallStatement functionCallStatement; @@ -1605,6 +1616,7 @@ class PrimaryExpression : ASTNode { public: mixin(DEFAULT_ACCEPT); + /** */ bool hasDot; /** */ Token primary; /** */ IdentifierOrTemplateInstance identifierOrTemplateInstance; /** */ TokenType basicType; @@ -1915,7 +1927,7 @@ public: } /// -class TemplateMixinStatement : ASTNode +class TemplateMixinExpression : ASTNode { public: mixin(DEFAULT_ACCEPT); diff --git a/std/d/parser.d b/std/d/parser.d index 096696f..c99f6f9 100755 --- a/std/d/parser.d +++ b/std/d/parser.d @@ -255,10 +255,10 @@ alias core.sys.posix.stdio.fileno fileno; * $(RULE assignExpression) ($(LITERAL ',') $(RULE assignExpression)?)* * ;) */ - ArgumentList parseArgumentList() + ArgumentList parseArgumentList(bool allowTrailingComma = false) { mixin(traceEnterAndExit!(__FUNCTION__)); - return parseCommaSeparatedRule!(ArgumentList, AssignExpression)(); + return parseCommaSeparatedRule!(ArgumentList, AssignExpression)(allowTrailingComma); } /** @@ -284,7 +284,7 @@ alias core.sys.posix.stdio.fileno fileno; * * $(GRAMMAR $(RULEDEF arrayInitializer): * $(LITERAL '[') $(LITERAL ']') - * | $(LITERAL '[') $(RULE arrayMemberInitialization) ($(LITERAL ',') $(RULE arrayMemberInitialization))* $(LITERAL ']') + * | $(LITERAL '[') $(RULE arrayMemberInitialization) ($(LITERAL ',') $(RULE arrayMemberInitialization)?)* $(LITERAL ']') * ;) */ ArrayInitializer parseArrayInitializer() @@ -298,7 +298,10 @@ alias core.sys.posix.stdio.fileno fileno; if (currentIs(TokenType.comma)) { advance(); - continue; + if (currentIs(TokenType.rBracket)) + break; + else + continue; } else break; @@ -312,7 +315,7 @@ alias core.sys.posix.stdio.fileno fileno; * Parses an ArrayLiteral * * $(GRAMMAR $(RULEDEF arrayLiteral): - * $(LITERAL '[') $(RULE argumentList) $(LITERAL ']') + * $(LITERAL '[') ($(RULE assignExpression) ($(LITERAL ',') $(RULE assignExpression))*)? $(LITERAL ']') * ;) */ ArrayLiteral parseArrayLiteral() @@ -320,7 +323,7 @@ alias core.sys.posix.stdio.fileno fileno; mixin(traceEnterAndExit!(__FUNCTION__)); auto node = new ArrayLiteral; if (expect(TokenType.lBracket) is null) return null; - node.argumentList = parseArgumentList(); + node.argumentList = parseArgumentList(true); if (expect(TokenType.rBracket) is null) return null; return node; } @@ -1458,52 +1461,19 @@ class ClassFour(A, B) if (someTest()) : Super {}}c; mixin(traceEnterAndExit!(__FUNCTION__)); auto node = new ConditionalDeclaration; node.compileCondition = parseCompileCondition(); - if (currentIs(TokenType.lBrace)) - { - advance(); - do - { - auto dec = parseDeclaration(); - if (dec is null) return null; - node.trueDeclarations ~= dec; - if (!moreTokens() || currentIs(TokenType.rBrace)) - break; - } - while (true); - if (expect(TokenType.rBrace) is null) return null; - } - else - { - auto dec = parseDeclaration(); - if (dec is null) return null; - node.trueDeclarations ~= dec; - } + + auto dec = parseDeclaration(); + if (dec is null) return null; + node.trueDeclarations ~= dec; if(currentIs(TokenType.else_)) advance(); else return node; - if (currentIs(TokenType.lBrace)) - { - advance(); - do - { - auto dec = parseDeclaration(); - if (dec is null) return null; - node.falseDeclarations ~= dec; - if (!moreTokens() || currentIs(TokenType.rBrace)) - break; - } - while (true); - if (expect(TokenType.rBrace) is null) return null; - } - else - { - auto dec = parseDeclaration(); - if (dec is null) return null; - node.falseDeclarations ~= dec; - } + auto elseDec = parseDeclaration(); + if (elseDec is null) return null; + node.falseDeclarations ~= elseDec; return node; } @@ -1682,6 +1652,7 @@ class ClassFour(A, B) if (someTest()) : Super {}}c; * | $(RULE importDeclaration) * | $(RULE interfaceDeclaration) * | $(RULE mixinDeclaration) + * | $(RULE mixinTemplateDeclaration) * | $(RULE pragmaDeclaration) * | $(RULE sharedStaticConstructor) * | $(RULE sharedStaticDestructor) @@ -1769,7 +1740,10 @@ class ClassFour(A, B) if (someTest()) : Super {}}c; node.interfaceDeclaration = parseInterfaceDeclaration(); break; case mixin_: - node.mixinDeclaration = parseMixinDeclaration(); + if (peekIs(TokenType.template_)) + node.mixinTemplateDeclaration = parseMixinTemplateDeclaration(); + else + node.mixinDeclaration = parseMixinDeclaration(); break; case pragma_: node.pragmaDeclaration = parsePragmaDeclaration(); @@ -3185,7 +3159,7 @@ invariant() foo(); * Parses an IsExpression * * $(GRAMMAR $(RULEDEF isExpression): - * $(LITERAL'is') $(LITERAL '$(LPAREN)') $(RULE type) $(LITERAL Identifier)? (($(LITERAL ':') | $(LITERAL '==')) $(RULE typeSpecialization) ($(LITERAL ',') $(RULE templateParameterList))?)? $(LITERAL '$(RPAREN)') + * $(LITERAL'is') $(LITERAL '$(LPAREN)') ($(RULE type) $(LITERAL Identifier)? (($(LITERAL ':') | $(LITERAL '==')) $(RULE typeSpecialization) ($(LITERAL ',') $(RULE templateParameterList))?)?)) $(LITERAL '$(RPAREN)') * ;) */ IsExpression parseIsExpression() @@ -3391,14 +3365,18 @@ invariant() foo(); * Parses a MixinDeclaration * * $(GRAMMAR $(RULEDEF mixinDeclaration): - * $(RULE mixinExpression) $(LITERAL ';') + * $(RULE mixinExpression) $(LITERAL ';') + * | $(RULE templateMixinStatement) $(LITERAL ';') * ;) */ MixinDeclaration parseMixinDeclaration() { mixin(traceEnterAndExit!(__FUNCTION__)); auto node = new MixinDeclaration; - node.mixinExpression = parseMixinExpression(); + if (peekIs(TokenType.identifier)) + node.templateMixinExpression = parseTemplateMixinExpression(); + else + node.mixinExpression = parseMixinExpression(); expect(TokenType.semicolon); return node; } @@ -3421,6 +3399,23 @@ invariant() foo(); return node; } + /** + * Parses a MixinTemplateDeclaration + * + * $(GRAMMAR $(RULEDEF mixinTemplateDeclaration): + * $(LITERAL 'mixin') $RULE templateDeclaration + * ;) + */ + MixinTemplateDeclaration parseMixinTemplateDeclaration() + { + mixin(traceEnterAndExit!(__FUNCTION__)); + auto node = new MixinTemplateDeclaration; + if (expect(TokenType.mixin_) is null) return null; + node.templateDeclaration = parseTemplateDeclaration(); + if (node.templateDeclaration is null) return null; + return node; + } + /** * Parses a MixinTemplateName * @@ -4023,6 +4018,7 @@ q{(int a, ...) * * $(GRAMMAR $(RULEDEF primaryExpression): * $(RULE identifierOrTemplateInstance) + * | $(LITERAL '.') $(RULE identifierOrTemplateInstance) * | $(RULE basicType) $(LITERAL '.') $(LITERAL Identifier) * | $(RULE typeofExpression) * | $(RULE typeidExpression) @@ -4064,6 +4060,10 @@ q{(int a, ...) auto node = new PrimaryExpression; with (TokenType) switch (current.type) { + case dot: + node.hasDot = true; + advance(); + goto case; case identifier: if (peekIs(TokenType.goesTo)) node.lambdaExpression = parseLambdaExpression(); @@ -4209,10 +4209,10 @@ q{(int a, ...) { mixin(traceEnterAndExit!(__FUNCTION__)); auto node = new ReturnStatement; - expect(TokenType.return_); - if (tokens[index] != TokenType.semicolon) + if (expect(TokenType.return_) is null) return null; + if (!currentIs(TokenType.semicolon)) node.expression = parseExpression(); - expect(TokenType.semicolon); + if (expect(TokenType.semicolon) is null) return null; return node; } @@ -4890,23 +4890,22 @@ q{(int a, ...) } /** - * Parses a TemplateMixinStatement + * Parses a TemplateMixinExpression * - * $(GRAMMAR $(RULEDEF templateMixinStatement): - * $(LITERAL 'mixin') $(RULE mixinTemplateName) $(RULE templateArguments)? $(LITERAL Identifier)? $(LITERAL ';') + * $(GRAMMAR $(RULEDEF templateMixinExpression): + * $(LITERAL 'mixin') $(RULE mixinTemplateName) $(RULE templateArguments)? $(LITERAL Identifier)? * ;) */ - TemplateMixinStatement parseTemplateMixinStatement() + TemplateMixinExpression parseTemplateMixinExpression() { mixin(traceEnterAndExit!(__FUNCTION__)); - auto node = new TemplateMixinStatement; - expect(TokenType.mixin_); + auto node = new TemplateMixinExpression; + if (expect(TokenType.mixin_) is null) return null; node.mixinTemplateName = parseMixinTemplateName(); if (currentIs(TokenType.not)) node.templateArguments = parseTemplateArguments(); if (currentIs(TokenType.identifier)) node.identifier = advance(); - expect(TokenType.semicolon); return node; } @@ -5201,8 +5200,11 @@ q{(int a, ...) auto ident = expect(TokenType.identifier); if (ident is null) return null; node.identifier = *ident; - if (expect(TokenType.comma) is null) return null; - if ((node.templateArgumentList = parseTemplateArgumentList()) is null) return null; + if (currentIs(TokenType.comma)) + { + advance(); + if ((node.templateArgumentList = parseTemplateArgumentList()) is null) return null; + } if (expect(TokenType.rParen) is null) return null; return node; } @@ -6009,14 +6011,23 @@ private: return node; } - ListType parseCommaSeparatedRule(alias ListType, alias ItemType)() + ListType parseCommaSeparatedRule(alias ListType, alias ItemType)(bool allowTrailingComma = false) { auto node = new ListType; while (true) { mixin ("node.items ~= parse" ~ ItemType.stringof ~ "();"); if (currentIs(TokenType.comma)) + { advance(); + if (allowTrailingComma && currentIsOneOf(TokenType.rParen, + TokenType.rBrace, TokenType.rBracket)) + { + break; + } + else + continue; + } else break; } diff --git a/std/d/runtester.sh b/std/d/runtester.sh index beb29fa..e2655d1 100755 --- a/std/d/runtester.sh +++ b/std/d/runtester.sh @@ -8,8 +8,5 @@ for file in /usr/include/d/std/*.d; do ./tester $file > $outFile done echo -echo "Good files:" -grep -l "Parsing finished with 0 errors" runs/*.txt | sed -e "s/runs\///" -e "s/.txt//" -echo -echo "Bad files:" -grep -L "Parsing finished with 0 errors" runs/*.txt | sed -e "s/runs\///" -e "s/.txt//" +grep -l "Parsing finished with 0 errors" runs/*.txt | sed -e "s/runs\//Pass /" -e "s/.txt//" +grep -L "Parsing finished with 0 errors" runs/*.txt | sed -e "s/runs\//Fail /" -e "s/.txt//" diff --git a/versions.d b/versions.d old mode 100644 new mode 100755