Skip to content

Commit

Permalink
sumtype gen
Browse files Browse the repository at this point in the history
  • Loading branch information
burner committed Dec 22, 2023
1 parent 2b658ae commit 9f6245b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions fakerjs2generator/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ import generator;
void main() {
writeln("Edit source/app.d to start your project.");

/*
foreach(d; dirEntries("faker/src/locale/", SpanMode.shallow)) {
string n = d.name;
ptrdiff_t s = n.lastIndexOf('/');
n = n[s + 1 .. $ - 3];
writeln(n);
Language en = parseLanguage(n);
}
*/

Language en = parseLanguage("en");
generate(en, "en");
}
3 changes: 1 addition & 2 deletions fakerjs2generator/source/generator.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import defis;
void generate(Language lang, string langName) {
auto app = appender!string();
traverse(lang, app, []);
writeln(app.data);
}

void traverse(T,Out)(T t, ref Out o, string[] path) {
Expand All @@ -33,7 +32,7 @@ void traverse(T,Out)(T t, ref Out o, string[] path) {
} else static if(is(T == SumType!(TT), TT...)) {
static foreach(R; TT) {
t.match!(
(R r) { traverse(r, o, path); }
(R r) { writeln("SumType " ~ R.stringof); traverse(r, o, path); }
, (_) { return; }
);
}
Expand Down

0 comments on commit 9f6245b

Please sign in to comment.