diff --git a/dastworx/src/common.d b/dastworx/src/common.d index a9f9a11b..478208f9 100644 --- a/dastworx/src/common.d +++ b/dastworx/src/common.d @@ -340,9 +340,19 @@ T parseAndVisit(T : ASTVisitor)(const(char)[] source) LexerConfig config = LexerConfig("", StringBehavior.source, WhitespaceBehavior.skip); StringCache cache = StringCache(StringCache.defaultBucketCount); const(Token)[] tokens = getTokensForParser(cast(ubyte[]) source, config, &cache); - Module mod = parseModule(tokens, "", &allocator); + Module mod = parseModule(tokens, "", &allocator, &handleErrors); T result = construct!(T); result.visit(mod); return result; } +/** + * By default libdparse outputs errors and warnings to the standard streams. + * This function prevents that. + */ +void handleErrors(string fname, size_t line, size_t col, string message, + bool err) +{ + // dont pollute output +} + diff --git a/dastworx/src/imports.d b/dastworx/src/imports.d index 6f7e39a0..2cbcab6c 100644 --- a/dastworx/src/imports.d +++ b/dastworx/src/imports.d @@ -53,19 +53,25 @@ void listFilesImports(string[] files) { ubyte[] source = cast(ubyte[]) std.file.read(fname); Module mod = parseModule(getTokensForParser(source, config, &cache), - fname, &allocator); + fname, &allocator, &handleErrors); writeln('"', mod.moduleDeclaration.moduleName.identifiers .map!(a => a.text).join("."), '"'); il.visit(mod); + stdout.flush; } } - private final class ImportLister: ASTVisitor { alias visit = ASTVisitor.visit; size_t mixinDepth; + override void visit(const(Module) mod) + { + mixinDepth = 0; + mod.accept(this); + } + override void visit(const ConditionalDeclaration decl) { const VersionCondition ver = decl.compileCondition.versionCondition; diff --git a/dastworx/src/mainfun.d b/dastworx/src/mainfun.d index 9cc4015d..8bd5da38 100644 --- a/dastworx/src/mainfun.d +++ b/dastworx/src/mainfun.d @@ -25,6 +25,7 @@ void detectMainFun(const(Module) mod) MainFunctionDetector mfd = construct!(MainFunctionDetector); mfd.visit(mod); write(mfd.hasMain); + stdout.flush; } private final class MainFunctionDetector: ASTVisitor diff --git a/dastworx/src/symlist.d b/dastworx/src/symlist.d index af6e8954..f3b66bc0 100644 --- a/dastworx/src/symlist.d +++ b/dastworx/src/symlist.d @@ -24,6 +24,7 @@ void listSymbols(const(Module) mod, AstErrors errors, bool ddeep = true) SL sl = construct!(SL); sl.visit(mod); sl.serialize.writeln; + stdout.flush; } private: diff --git a/dastworx/src/todos.d b/dastworx/src/todos.d index 727690b3..abc337b6 100644 --- a/dastworx/src/todos.d +++ b/dastworx/src/todos.d @@ -26,6 +26,7 @@ void getTodos(string[] files) } stream.put(">end"); writeln(stream.data); + stdout.flush; } private void analyze(const(Token) token, string fname)