#!/usr/bin/env perl
use strict;
use warnings;

my @algorithms = @ARGV;

print("// Generated by generate_algorithms.pl - DO NOT EDIT\n\n");
print("const snowball = \@import(\"env.zig\");\n\n");
foreach my $alg (@algorithms) {
    # Suffix constant with `_stemmer` to avoid generating bad code if
    # the algorithm name is a zig reserved word.
    print("const ${alg}_stemmer = \@import(\"${alg}_stemmer.zig\");\n");
}
print("\npub const StemFn = *const fn (*snowball.Env) bool;\n\n");
print("pub const algorithms = [_]struct { name: []const u8, stem: StemFn }{\n");
foreach my $alg (@algorithms) {
    print("    .{ .name = \"$alg\", .stem = ${alg}_stemmer.stem },\n");
}
print("};\n");
