Skip to content

Instantly share code, notes, and snippets.

@GoaLitiuM
Created May 28, 2019
Embed
What would you like to do?
import dmd.permissivevisitor;
import dmd.transitivevisitor;
import dmd.tokens;
import dmd.root.outbuffer;
import core.stdc.stdio;
import std.stdio;
import std.file;
import std.path : buildPath, dirName;
import dmd.errors;
import dmd.parse;
import dmd.astbase;
import dmd.id;
import dmd.globals;
import dmd.identifier;
import core.memory;
extern(C++) class ImportVisitor(AST) : ParseTimeTransitiveVisitor!AST
{
alias visit = ParseTimeTransitiveVisitor!AST.visit;
override void visit(AST.Import imp)
{
}
}
void main()
{
GC.disable();
string path = __FILE_FULL_PATH__.dirName();
string regex = "*.d";
auto dFiles = dirEntries(path, regex, SpanMode.depth);
foreach (f; dFiles)
{
string fn = f.name;
//writeln("Processing ", fn);
Id.initialize();
global._init();
global.params.isWindows = true;
global.params.is64bit = (size_t.sizeof == 8);
global.params.useUnitTests = true;
ASTBase.Type._init();
auto id = Identifier.idPool(fn);
auto m = new ASTBase.Module(&(fn.dup)[0], id, false, false);
auto input = readText(fn);
//writeln("Started parsing...");
scope diagnosticReporter = new StderrDiagnosticReporter(global.params.useDeprecated);
scope p = new Parser!ASTBase(m, input, false, diagnosticReporter);
p.nextToken();
m.members = p.parseModule();
//writeln("Finished parsing. Starting transitive visitor");
scope vis = new ImportVisitor!ASTBase();
m.accept(vis);
//writeln("Finished!");
}
}
import dmd.permissivevisitor;
import dmd.transitivevisitor;
import dmd.tokens;
import dmd.root.outbuffer;
import core.stdc.stdio;
import std.stdio;
import std.file;
import std.path : buildPath, dirName;
import dmd.errors;
import dmd.parse;
import dmd.astbase;
import dmd.id;
import dmd.globals;
import dmd.identifier;
import core.memory;
extern(C++) class ImportVisitor(AST) : ParseTimeTransitiveVisitor!AST
{
alias visit = ParseTimeTransitiveVisitor!AST.visit;
override void visit(AST.Import imp)
{
}
}
void main()
{
GC.disable();
string path = __FILE_FULL_PATH__.dirName();
string regex = "*.d";
auto dFiles = dirEntries(path, regex, SpanMode.depth);
foreach (f; dFiles)
{
string fn = f.name;
//writeln("Processing ", fn);
initDMD();
global.params.isWindows = true;
global.params.is64bit = (size_t.sizeof == 8);
global.params.useUnitTests = true;
ASTBase.Type._init();
auto id = Identifier.idPool(fn);
auto m = new ASTBase.Module(&(fn.dup)[0], id, false, false);
auto input = readText(fn);
//writeln("Started parsing...");
scope diagnosticReporter = new StderrDiagnosticReporter(global.params.useDeprecated);
scope p = new Parser!ASTBase(m, input, false, diagnosticReporter);
p.nextToken();
m.members = p.parseModule();
//writeln("Finished parsing. Starting transitive visitor");
scope vis = new ImportVisitor!ASTBase();
m.accept(vis);
//writeln("Finished!");
deinitializeDMD();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment