Use libdparse instead of dscanner

This commit is contained in:
Hackerpilot 2014-06-26 12:44:51 -07:00
parent 4f99f1746b
commit 3aba4955e5
10 changed files with 19 additions and 22 deletions

7
.gitmodules vendored
View File

@ -1,9 +1,6 @@
[submodule "msgpack-d"] [submodule "msgpack-d"]
path = msgpack-d path = msgpack-d
url = https://github.com/msgpack/msgpack-d.git url = https://github.com/msgpack/msgpack-d.git
[submodule "dscanner"]
path = dscanner
url = https://github.com/Hackerpilot/Dscanner.git
[submodule "editors/ktexteditor"] [submodule "editors/ktexteditor"]
path = editors/ktexteditor path = editors/ktexteditor
url = https://github.com/Dav1dde/lumen.git url = https://github.com/Dav1dde/lumen.git
@ -13,3 +10,7 @@
[submodule "containers"] [submodule "containers"]
path = containers path = containers
url = https://github.com/economicmodeling/containers.git url = https://github.com/economicmodeling/containers.git
[submodule "libdparse"]
path = libdparse
url = https://github.com/Hackerpilot/libdparse.git
branch = master

View File

@ -205,8 +205,7 @@ auto getTokensBeforeCursor(const(ubyte[]) sourceCode, size_t cursorPosition,
{ {
LexerConfig config; LexerConfig config;
config.fileName = "stdin"; config.fileName = "stdin";
auto tokens = byToken(cast(ubyte[]) sourceCode, config, cache); tokenArray = getTokensForParser(cast(ubyte[]) sourceCode, config, cache);
tokenArray = tokens.array();
auto sortedTokens = assumeSorted(tokenArray); auto sortedTokens = assumeSorted(tokenArray);
return sortedTokens.lowerBound(cast(size_t) cursorPosition); return sortedTokens.lowerBound(cast(size_t) cursorPosition);
} }

View File

@ -23,13 +23,13 @@ dmd\
server.d\ server.d\
stupidlog.d\ stupidlog.d\
string_interning.d\ string_interning.d\
dscanner/std/d/ast.d\ libdparse/src/std/d/ast.d\
dscanner/std/d/entities.d\ libdparse/src/std/d/entities.d\
dscanner/std/d/lexer.d\ libdparse/src/std/d/lexer.d\
dscanner/std/d/parser.d\ libdparse/src/std/d/parser.d\
dscanner/std/lexer.d\ libdparse/src/std/lexer.d\
dscanner/std/allocator.d\ libdparse/src/std/allocator.d\
dscanner/formatter.d\ libdparse/src/std/d/formatter.d\
containers/src/memory/allocators.d\ containers/src/memory/allocators.d\
containers/src/memory/appender.d\ containers/src/memory/appender.d\
containers/src/containers/dynamicarray.d\ containers/src/containers/dynamicarray.d\

@ -1 +1 @@
Subproject commit 6e9aa02eda657fd0a3e820641cbcdecc3dfbd0ce Subproject commit 2a72525f649850f452f21e7f362f70440f487a61

View File

@ -63,6 +63,7 @@ class SimpleParser : Parser
override Unittest parseUnittest() override Unittest parseUnittest()
{ {
expect(tok!"unittest"); expect(tok!"unittest");
if (currentIs(tok!"{"))
skipBraces(); skipBraces();
return null; return null;
} }

View File

@ -19,7 +19,7 @@
module conversion.first; module conversion.first;
import actypes; import actypes;
import formatter; import std.d.formatter;
import std.allocator; import std.allocator;
import memory.allocators; import memory.allocators;
import memory.appender; import memory.appender;

View File

@ -190,7 +190,7 @@ private:
ACSymbol* processSuffix(ACSymbol* symbol, const TypeSuffix suffix) ACSymbol* processSuffix(ACSymbol* symbol, const TypeSuffix suffix)
{ {
import formatter; import std.d.formatter;
if (suffix.star) if (suffix.star)
return symbol; return symbol;
if (suffix.array || suffix.type) if (suffix.array || suffix.type)

@ -1 +0,0 @@
Subproject commit ade1a718aced45992ecd232b1227c8779b9f9603

1
libdparse Submodule

@ -0,0 +1 @@
Subproject commit d9387eb3b275295cd0263bdc273c4b0b63f29f98

View File

@ -137,7 +137,6 @@ struct ModuleCache
ACSymbol*[] symbols; ACSymbol*[] symbols;
// try // try
// { // {
import core.memory;
import std.stdio; import std.stdio;
import std.typecons; import std.typecons;
File f = File(cachedLocation); File f = File(cachedLocation);
@ -150,12 +149,9 @@ struct ModuleCache
config.fileName = cachedLocation; config.fileName = cachedLocation;
auto parseStringCache = StringCache(StringCache.defaultBucketCount); auto parseStringCache = StringCache(StringCache.defaultBucketCount);
auto semanticAllocator = scoped!(CAllocatorImpl!(BlockAllocator!(1024 * 64))); auto semanticAllocator = scoped!(CAllocatorImpl!(BlockAllocator!(1024 * 64)));
DynamicArray!(Token, false) tokens; const(Token)[] tokens = getTokensForParser(
auto tokenRange = byToken(
(source.length >= 3 && source[0 .. 3] == "\xef\xbb\xbf"c) ? source[3 .. $] : source, (source.length >= 3 && source[0 .. 3] == "\xef\xbb\xbf"c) ? source[3 .. $] : source,
config, &parseStringCache); config, &parseStringCache);
foreach (t; tokenRange)
tokens.insert(t);
Mallocator.it.deallocate(source); Mallocator.it.deallocate(source);
Module m = parseModuleSimple(tokens[], cachedLocation, semanticAllocator); Module m = parseModuleSimple(tokens[], cachedLocation, semanticAllocator);