From 3aba4955e5d3998726c05e1ca4cba2d74b1bf32b Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Thu, 26 Jun 2014 12:44:51 -0700 Subject: [PATCH] Use libdparse instead of dscanner --- .gitmodules | 7 ++++--- autocomplete.d | 3 +-- build.sh | 14 +++++++------- containers | 2 +- conversion/astconverter.d | 3 ++- conversion/first.d | 2 +- conversion/third.d | 2 +- dscanner | 1 - libdparse | 1 + modulecache.d | 6 +----- 10 files changed, 19 insertions(+), 22 deletions(-) delete mode 160000 dscanner create mode 160000 libdparse diff --git a/.gitmodules b/.gitmodules index f8aa23d..fac66e6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "msgpack-d"] path = msgpack-d url = https://github.com/msgpack/msgpack-d.git -[submodule "dscanner"] - path = dscanner - url = https://github.com/Hackerpilot/Dscanner.git [submodule "editors/ktexteditor"] path = editors/ktexteditor url = https://github.com/Dav1dde/lumen.git @@ -13,3 +10,7 @@ [submodule "containers"] path = containers url = https://github.com/economicmodeling/containers.git +[submodule "libdparse"] + path = libdparse + url = https://github.com/Hackerpilot/libdparse.git + branch = master diff --git a/autocomplete.d b/autocomplete.d index 12eab8f..c91968f 100644 --- a/autocomplete.d +++ b/autocomplete.d @@ -205,8 +205,7 @@ auto getTokensBeforeCursor(const(ubyte[]) sourceCode, size_t cursorPosition, { LexerConfig config; config.fileName = "stdin"; - auto tokens = byToken(cast(ubyte[]) sourceCode, config, cache); - tokenArray = tokens.array(); + tokenArray = getTokensForParser(cast(ubyte[]) sourceCode, config, cache); auto sortedTokens = assumeSorted(tokenArray); return sortedTokens.lowerBound(cast(size_t) cursorPosition); } diff --git a/build.sh b/build.sh index 31095cd..d80d54d 100755 --- a/build.sh +++ b/build.sh @@ -23,13 +23,13 @@ dmd\ server.d\ stupidlog.d\ string_interning.d\ - dscanner/std/d/ast.d\ - dscanner/std/d/entities.d\ - dscanner/std/d/lexer.d\ - dscanner/std/d/parser.d\ - dscanner/std/lexer.d\ - dscanner/std/allocator.d\ - dscanner/formatter.d\ + libdparse/src/std/d/ast.d\ + libdparse/src/std/d/entities.d\ + libdparse/src/std/d/lexer.d\ + libdparse/src/std/d/parser.d\ + libdparse/src/std/lexer.d\ + libdparse/src/std/allocator.d\ + libdparse/src/std/d/formatter.d\ containers/src/memory/allocators.d\ containers/src/memory/appender.d\ containers/src/containers/dynamicarray.d\ diff --git a/containers b/containers index 6e9aa02..2a72525 160000 --- a/containers +++ b/containers @@ -1 +1 @@ -Subproject commit 6e9aa02eda657fd0a3e820641cbcdecc3dfbd0ce +Subproject commit 2a72525f649850f452f21e7f362f70440f487a61 diff --git a/conversion/astconverter.d b/conversion/astconverter.d index 67657fb..ac17f56 100644 --- a/conversion/astconverter.d +++ b/conversion/astconverter.d @@ -63,7 +63,8 @@ class SimpleParser : Parser override Unittest parseUnittest() { expect(tok!"unittest"); - skipBraces(); + if (currentIs(tok!"{")) + skipBraces(); return null; } diff --git a/conversion/first.d b/conversion/first.d index 6e107f7..b4411d8 100644 --- a/conversion/first.d +++ b/conversion/first.d @@ -19,7 +19,7 @@ module conversion.first; import actypes; -import formatter; +import std.d.formatter; import std.allocator; import memory.allocators; import memory.appender; diff --git a/conversion/third.d b/conversion/third.d index 9d34561..5a832e2 100644 --- a/conversion/third.d +++ b/conversion/third.d @@ -190,7 +190,7 @@ private: ACSymbol* processSuffix(ACSymbol* symbol, const TypeSuffix suffix) { - import formatter; + import std.d.formatter; if (suffix.star) return symbol; if (suffix.array || suffix.type) diff --git a/dscanner b/dscanner deleted file mode 160000 index ade1a71..0000000 --- a/dscanner +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ade1a718aced45992ecd232b1227c8779b9f9603 diff --git a/libdparse b/libdparse new file mode 160000 index 0000000..d9387eb --- /dev/null +++ b/libdparse @@ -0,0 +1 @@ +Subproject commit d9387eb3b275295cd0263bdc273c4b0b63f29f98 diff --git a/modulecache.d b/modulecache.d index 1fe21c9..5d13a84 100644 --- a/modulecache.d +++ b/modulecache.d @@ -137,7 +137,6 @@ struct ModuleCache ACSymbol*[] symbols; // try // { - import core.memory; import std.stdio; import std.typecons; File f = File(cachedLocation); @@ -150,12 +149,9 @@ struct ModuleCache config.fileName = cachedLocation; auto parseStringCache = StringCache(StringCache.defaultBucketCount); auto semanticAllocator = scoped!(CAllocatorImpl!(BlockAllocator!(1024 * 64))); - DynamicArray!(Token, false) tokens; - auto tokenRange = byToken( + const(Token)[] tokens = getTokensForParser( (source.length >= 3 && source[0 .. 3] == "\xef\xbb\xbf"c) ? source[3 .. $] : source, config, &parseStringCache); - foreach (t; tokenRange) - tokens.insert(t); Mallocator.it.deallocate(source); Module m = parseModuleSimple(tokens[], cachedLocation, semanticAllocator);