diff --git a/Cargo.toml b/Cargo.toml index a23b4e6..fb8c227 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,6 @@ members = [ "kifu/l10n", "l10n", "memorycache", - "messages-codegen", "nom-training", "result-extended", "screenplay", diff --git a/messages-codegen/src/main.rs b/l10n/src/bin/codegen-rust.rs similarity index 98% rename from messages-codegen/src/main.rs rename to l10n/src/bin/codegen-rust.rs index f41b3af..57bd009 100644 --- a/messages-codegen/src/main.rs +++ b/l10n/src/bin/codegen-rust.rs @@ -130,6 +130,5 @@ fn main() { for message in messages { println!(); println!("{}", message.rust_code()); - // println!("{}", message.content()); } } diff --git a/l10n/src/bin/msggen.rs b/l10n/src/bin/msggen.rs new file mode 100644 index 0000000..8d6473e --- /dev/null +++ b/l10n/src/bin/msggen.rs @@ -0,0 +1,3 @@ +fn main() { + println!("msggen running"); +} diff --git a/messages-codegen/Cargo.toml b/messages-codegen/Cargo.toml deleted file mode 100644 index c62ac76..0000000 --- a/messages-codegen/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "messages-codegen" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -proc-macro = true - -[dependencies] -convert_case = { version = "0.6" } -quote = { version = "*" } -syn = { version = "*" } -serde_yaml = { version = "*" } -serde = { version = "*", features = [ "derive" ] } diff --git a/messages-codegen/src/lib.rs b/messages-codegen/src/lib.rs deleted file mode 100644 index cb17e37..0000000 --- a/messages-codegen/src/lib.rs +++ /dev/null @@ -1,87 +0,0 @@ -/* Given that fluent doesn't provide an ability to see all of the placeholders within a message, - * and that the placeholders may change depending on the values of others, I don't have a way to - * ensure that the translation code remains entirely connected to the source messages themselves. - * - * Given that I can't really enforce it, I can, perhaps, codegen it in a way that at least the two - * are right next to one another. A macro that generates the data structure and can write the - * source strings file. - * - * For overall file structure, I want the messages, L10N, and FluentErgo tied together. - */ - -use proc_macro::TokenStream; -use quote::quote; -use syn; - -/* I want to write a macro that reads something like this: - * messages! { - * Welcome(name: String) => "Hello, ${name}", - * GamesInDatabase(count: usize) => "{$count -> - * [one] There is one game in the database - * *[other] There are ${count} games in the database - * }", - * - * It generates an enumeration with all of the named values (Welcome, GamesInDatabase), it - * generates corresponding structures (Welcome{ name: String }, GamesInDatabase{ count: usize }), - * and it generates two implementations. One is an implementation that can be used to write all of - * the strings after => into a file. The other is an implementation that can be imported into a - * program, but which *does not* contain the strings. That would look more like this: - * - * messages.rs: - * - * enum Messages { - * Welcome(Welcome), - * GamesInDatabase(GamesInDatabase), - * } - * - * struct Welcome{ name: String } - * struct GamesInDatabase{ count: usize } - * - * message_strings.ftl: - * - * welcome = "Hello, ${name}", - * games-in-database = "{$count -> - * [one] There is one game in the database - * *[other] There are ${count} games in the database - * }", - * - * messages.rs can be imported into the resulting program, and the names of the strings are thus a - * part of the program, but the strings themselves are still data files. - */ - -/* -#[macro_export] -macro_rules! messages { - ($($name:ident($($arg:ident: $argtype:ty)*) => $message:literal,)+) => { - pub enum Messages { - $($name($name)),+ - } - - impl Messages { - fn gen_strings() -> Vec { - vec![ - $(concat!(stringify!($name), " => ", $message).to_string(),)+ - ] - } - } - - $(pub struct $name { - $($arg: $argtype)* - })+ - } -} -*/ - -#[proc_macro_derive(Messages)] -pub fn messages_macro(input: TokenStream) -> TokenStream { - let syn::DeriveInput { ident, .. } = syn::parse_macro_input! {input}; - - let gen = quote! { - impl Messages for #ident { - fn hello() { - println!("Hello from {}", stringify!(#ident)); - } - } - }; - gen.into() -} diff --git a/messages-codegen/test-data/messages.yaml b/messages-codegen/test-data/messages.yaml deleted file mode 100644 index 3b67f31..0000000 --- a/messages-codegen/test-data/messages.yaml +++ /dev/null @@ -1,14 +0,0 @@ -welcome: - content: "Welcome to Kifu" -hello: - parameters: - name: string - content: "Hello, ${name}" -games-in-database: - parameters: - count: count - content: | - {$count -> - [one] There is one game in the database - *[other] There are ${count} games in the database - }