From 88883e6e0feec4121f839cd998222d956438dd31 Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Tue, 29 Apr 2014 15:51:25 -0700 Subject: [PATCH 1/4] Whitespace cleanup --- std/d/ast.d | 4 ++-- std/d/parser.d | 63 +++++++++++++++++++++++++------------------------- 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/std/d/ast.d b/std/d/ast.d index 02c2134..0a760f3 100644 --- a/std/d/ast.d +++ b/std/d/ast.d @@ -1873,12 +1873,12 @@ final class LinkageAttribute : ASTNode public: override void accept(ASTVisitor visitor) const { - version (DIP61) mixin (visitIfNotNull!(identifier, identifierChain)); + version (DIP61) mixin (visitIfNotNull!(identifier, identifierChain)); else mixin (visitIfNotNull!(identifier)); } /** */ Token identifier; /** */ bool hasPlusPlus; - version (DIP61) /** */ IdentifierChain identifierChain; + version (DIP61) /** */ IdentifierChain identifierChain; mixin OpEquals; } diff --git a/std/d/parser.d b/std/d/parser.d index 952d20e..ec60cf2 100644 --- a/std/d/parser.d +++ b/std/d/parser.d @@ -113,7 +113,7 @@ class Parser node.linkageAttribute = parseLinkageAttribute(); } warn("Prefer the new \"'alias' identifier '=' type ';'\" syntax" - ~ " to the old \"'alias' type identifier ';'\" syntax"); + ~ " to the old \"'alias' type identifier ';'\" syntax"); if ((node.type = parseType()) is null) return null; auto ident = expect(tok!"identifier"); if (ident is null) @@ -1982,14 +1982,13 @@ class ClassFour(A, B) if (someTest()) : Super {}}c; if (currentIs(tok!";")) advance(); else - { - MemberFunctionAttribute[] memberFunctionAttributes; - while(moreTokens() && currentIsMemberFunctionAttribute()) - memberFunctionAttributes ~= parseMemberFunctionAttribute(); - node.memberFunctionAttributes = ownArray(memberFunctionAttributes); - - node.functionBody = parseFunctionBody(); - } + { + MemberFunctionAttribute[] memberFunctionAttributes; + while(moreTokens() && currentIsMemberFunctionAttribute()) + memberFunctionAttributes ~= parseMemberFunctionAttribute(); + node.memberFunctionAttributes = ownArray(memberFunctionAttributes); + node.functionBody = parseFunctionBody(); + } return node; } @@ -3414,11 +3413,11 @@ invariant() foo(); { advance(); node.hasPlusPlus = true; - version(DIP61) if (currentIs(tok!",")) - { - advance(); - node.identifierChain = parseIdentifierChain(); - } + version(DIP61) if (currentIs(tok!",")) + { + advance(); + node.identifierChain = parseIdentifierChain(); + } } expect(tok!")"); return node; @@ -4545,18 +4544,18 @@ q{(int a, ...) if (!currentIs(tok!"]")) { node.lower = parseAssignExpression(); - if (node.lower is null) - { - error("assignExpression expected"); - return null; - } + if (node.lower is null) + { + error("assignExpression expected"); + return null; + } expect(tok!".."); node.upper = parseAssignExpression(); - if (node.upper is null) - { - error("assignExpression expected"); - return null; - } + if (node.upper is null) + { + error("assignExpression expected"); + return null; + } } if (expect(tok!"]") is null) return null; return node; @@ -4810,13 +4809,13 @@ q{(int a, ...) mixin(traceEnterAndExit!(__FUNCTION__)); auto node = allocate!StructInitializer; expect(tok!"{"); - if (currentIs(tok!"}")) - advance(); - else - { - node.structMemberInitializers = parseStructMemberInitializers(); - expect(tok!"}"); - } + if (currentIs(tok!"}")) + advance(); + else + { + node.structMemberInitializers = parseStructMemberInitializers(); + expect(tok!"}"); + } return node; } @@ -6349,7 +6348,7 @@ protected: case tok!"abstract": case tok!"pure": case tok!"nothrow": - return true; + return true; mixin(BASIC_TYPE_CASES); return !peekIs(tok!"."); case tok!"case": From f89bd7d3e078ffe3ce8442e648b28ff000bd9e02 Mon Sep 17 00:00:00 2001 From: Matthew Brennan Jones Date: Wed, 30 Apr 2014 12:37:02 -0700 Subject: [PATCH 2/4] Updated a few remaining stdx references to std. --- README.md | 2 +- build.sh | 8 ++++---- dub.json | 2 +- std/lexer.d | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1c1ac31..d1cfbaa 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,6 @@ but not yet implemented. # Useful code The source code for DScanner has a complete lexer, parser, and abstact syntax -tree library for D code under the stdx/d/ directory. It is intended that these +tree library for D code under the std/d/ directory. It is intended that these modules eventually end up in Phobos, so feel free to use them for your own D tools. diff --git a/build.sh b/build.sh index 1a4c7de..2b3cd32 100755 --- a/build.sh +++ b/build.sh @@ -24,8 +24,8 @@ dmd\ # astprinter.d\ # formatter.d\ # outliner.d\ -# stdx/*.d\ -# stdx/d/*.d\ +# std/*.d\ +# std/d/*.d\ # analysis/*.d\ # -O3 -frelease -fno-bounds-check\ # -odscanner\ @@ -39,8 +39,8 @@ dmd\ # astprinter.d\ # formatter.d\ # outliner.d\ -# stdx/*.d\ -# stdx/d/*.d\ +# std/*.d\ +# std/d/*.d\ # analysis/*.d\ # -O3 -release\ # -oq -of=dscanner\ diff --git a/dub.json b/dub.json index 086d89e..c67d6fb 100644 --- a/dub.json +++ b/dub.json @@ -9,7 +9,7 @@ { "name": "library", "targetType": "library", - "sourcePaths": ["stdx"], + "sourcePaths": ["std"], }, { "name": "dscanner", diff --git a/std/lexer.d b/std/lexer.d index 1072e45..84fd384 100644 --- a/std/lexer.d +++ b/std/lexer.d @@ -33,7 +33,7 @@ * ) * Examples: * $(UL - * $(LI A _lexer for D is available $(LINK2 https://github.com/Hackerpilot/Dscanner/blob/master/stdx/d/lexer.d, here).) + * $(LI A _lexer for D is available $(LINK2 https://github.com/Hackerpilot/Dscanner/blob/master/std/d/lexer.d, here).) * $(LI A _lexer for Lua is available $(LINK2 https://github.com/Hackerpilot/lexer-demo/blob/master/lualexer.d, here).) * $(LI A _lexer for JSON is available $(LINK2 https://github.com/Hackerpilot/lexer-demo/blob/master/jsonlexer.d, here).) * ) From 8a8ddf45ebcd94f2062a0c13c0fe318b113a0a6f Mon Sep 17 00:00:00 2001 From: Matthew Brennan Jones Date: Wed, 30 Apr 2014 13:01:42 -0700 Subject: [PATCH 3/4] Fixed small typos. --- README.md | 2 +- std/d/parser.d | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d1cfbaa..f2b72a1 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ The following examples assume that we are analyzing a simple file called hellowo ### Token Count The "--tokenCount" or "-t" option prints the number of tokens in the given file - $ dscanner --tokencount helloworld.d + $ dscanner --tokenCount helloworld.d 20 ### Import Listing diff --git a/std/d/parser.d b/std/d/parser.d index ec60cf2..e380ead 100644 --- a/std/d/parser.d +++ b/std/d/parser.d @@ -2281,7 +2281,7 @@ class ClassFour(A, B) if (someTest()) : Super {}}c; { if (!canBeRange) { - error(`Cannot have more than one foreach varible for a foreach range statement`); + error(`Cannot have more than one foreach variable for a foreach range statement`); return null; } advance(); From 86243af5c612a9fbadf5dc5d90305bce1178f13c Mon Sep 17 00:00:00 2001 From: Matthew Brennan Jones Date: Wed, 30 Apr 2014 13:14:11 -0700 Subject: [PATCH 4/4] Fixed issues with using ulong instead of size_t that would break only on 32bit. --- std/allocator.d | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/std/allocator.d b/std/allocator.d index b8ae114..f9c5796 100644 --- a/std/allocator.d +++ b/std/allocator.d @@ -2860,7 +2860,7 @@ private struct BasicRegion(uint minAlign = platformAlignment) static if (minAlign > 1) { auto newStore = cast(void*) roundUpToMultipleOf( - cast(ulong) store.ptr, + cast(size_t) store.ptr, alignment); assert(newStore <= store.ptr + store.length); _current = newStore; @@ -2904,7 +2904,7 @@ private struct BasicRegion(uint minAlign = platformAlignment) // Just bump the pointer to the next good allocation auto save = _current; _current = cast(void*) roundUpToMultipleOf( - cast(ulong) _current, a); + cast(size_t) _current, a); if (auto b = allocate(bytes)) return b; // Failed, rollback _current = save; @@ -3064,7 +3064,7 @@ struct InSituRegion(size_t size, size_t minAlign = platformAlignment) { assert(!_crt); _crt = cast(void*) roundUpToMultipleOf( - cast(ulong) _store.ptr, alignment); + cast(size_t) _store.ptr, alignment); _end = _store.ptr + _store.length; } @@ -3109,7 +3109,7 @@ struct InSituRegion(size_t size, size_t minAlign = platformAlignment) // Just bump the pointer to the next good allocation auto save = _crt; _crt = cast(void*) roundUpToMultipleOf( - cast(ulong) _crt, a); + cast(size_t) _crt, a); if (auto b = allocate(bytes)) return b; // Failed, rollback _crt = save;