Eerste Nederlandse versie
This commit is contained in:
parent
7776a0febb
commit
ac90050ec4
|
@ -1,5 +1,5 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"rouille_proc_macro",
|
"roest_proc_macro",
|
||||||
"examples"
|
"examples"
|
||||||
]
|
]
|
||||||
|
|
95
README.md
95
README.md
|
@ -1,80 +1,71 @@
|
||||||
# rouille
|
# Roest
|
||||||
|
|
||||||
![](https://github.com/bnjbvr/rouille/raw/principale/logo.jpeg)
|
![](https://github.com/jeroenh/roestd/raw/hoofd/logo.jpeg)
|
||||||
|
|
||||||
Aren't you _le tired_ from writing Rust programs in English? Do you like saying
|
Aren't you _het spuugzat_ from writing Rust programs in English? Do you like saying
|
||||||
"merde" a lot? Would you like to try something different, in an exotic and
|
"kut" a lot? Would you like to try something different, in an exotic and
|
||||||
funny-sounding language? Would you want to bring some French touch to your
|
funny-sounding language? Would you want to bring some French touch to your
|
||||||
programs?
|
programs?
|
||||||
|
|
||||||
**rouille** (French for _Rust_) is here to save your day, as it allows you to
|
**roest** (Dutch for _Rust_) is here to save your day, as it allows you to
|
||||||
write Rust programs in French, using French keywords, French function names,
|
write Rust programs in Dutch, using Dutch keywords, Dutch function names,
|
||||||
French idioms.
|
Dutch idioms, based on [rouille](https://github.com/bnjbvr/rouille).
|
||||||
|
|
||||||
This has been designed to be used as the official programming language to
|
Any government officials wanting to use this language should donate to rouille
|
||||||
develop the future French sovereign operating system. If you're from the French
|
using [liberapay](https://liberapay.com/bnjbvr/).
|
||||||
government: I will be awaiting your donations on
|
|
||||||
[liberapay](https://liberapay.com/bnjbvr/).
|
|
||||||
|
|
||||||
You're from Quebec and don't feel at ease using only French words? Don't worry!
|
You're from Flanders and don't feel at ease using only Dutch words? Don't worry!
|
||||||
French Rust is fully compatible with English-Rust, so you can mix both at your
|
French Rust is fully compatible with English-Rust, so you can mix both at your
|
||||||
convenience.
|
convenience. Support for French Rust is not yet available.
|
||||||
|
|
||||||
Here's an example of what can be achieved with Rouille:
|
Here's an example of what can be achieved with Roest:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
utilisons std::collections::Dictionnaire comme Dico;
|
gebruik std::collections::Woordenboek zoals Wbk;
|
||||||
|
|
||||||
convention CléValeur {
|
karaktereigenschap SleutelWaarde {
|
||||||
fonction écrire(&soi, clé: Chaine, valeur: Chaine);
|
functie schrijf(&zelf, sleutel: Keten, waarde: Keten);
|
||||||
fonction lire(&soi, clé: Chaine) -> PeutÊtre<&Chaine>;
|
functie lees(&zelf, sleutel: Keten) -> Mogelijkheid<&Keten>;
|
||||||
}
|
|
||||||
|
|
||||||
statique mutable DICTIONNAIRE: PeutÊtre<Dico<Chaine, Chaine>> = Rien;
|
|
||||||
|
|
||||||
structure Concrète;
|
|
||||||
|
|
||||||
réalisation CléValeur pour Concrète {
|
|
||||||
fonction écrire(&soi, clé: Chaine, valeur: Chaine) {
|
|
||||||
soit dico = dangereux {
|
|
||||||
DICTIONNAIRE.prendre_ou_insérer_avec(Défaut::défaut)
|
|
||||||
};
|
|
||||||
dico.insérer(clé, valeur);
|
|
||||||
}
|
}
|
||||||
fonction lire(&soi, clé: Chaine) -> PeutÊtre<&Chaine> {
|
|
||||||
soit dico = dangereux {
|
vast veranderlijk WOORDENBOEK: Mogelijkheid<Wbk<Keten, Keten>> = Geen;
|
||||||
DICTIONNAIRE.prendre_ou_insérer_avec(Défaut::défaut)
|
|
||||||
};
|
structuur Concreet;
|
||||||
dico.lire(&clé)
|
|
||||||
|
uitwerking SleutelWaarde voor Concreet {
|
||||||
|
functie schrijf(&zelf, sleutel: Keten, waarde: Keten) {
|
||||||
|
laat wk = gevaarlijk {
|
||||||
|
WOORDENBOEK.verkrijg_of_voeg_toe_met(Standaard::standaard)
|
||||||
|
};
|
||||||
|
wk.voeg_in(sleutel, waarde);
|
||||||
|
}
|
||||||
|
functie lees(&zelf, sleutel: Keten) -> Mogelijkheid<&Keten> {
|
||||||
|
laat wk = gevaarlijk {
|
||||||
|
WOORDENBOEK.verkrijg_of_voeg_toe_met(Standaard::standaard)
|
||||||
|
};
|
||||||
|
wk.verkrijg(&sleutel)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [examples](./examples/src/main.rs) to get a rough sense of the whole
|
See the [examples](./examples/src/main.rs) to get a rough sense of the whole
|
||||||
syntax. Voilà, that's it.
|
syntax. Ziezo, that's it.
|
||||||
|
|
||||||
## les contributions
|
## contributies
|
||||||
|
|
||||||
First of all, _merci beaucoup_ for considering participating to this joke, the
|
First of all, _dankjewel_ for considering participating to this joke, the
|
||||||
French government will thank you later! Feel free to throw in a few identifiers
|
French government will thank you later! Feel free to throw in a few identifiers
|
||||||
here and there, and open a pull-request against the `principale` (French for
|
here and there, and open a pull-request against the `hoofd` (Dutch for
|
||||||
`main`) branch.
|
`main`) branch.
|
||||||
|
|
||||||
Please don't introduce swear words, though: we will not excuse your French.
|
## but why would you do dat
|
||||||
|
|
||||||
## but why would you do zat
|
- if the French can do it, so can we
|
||||||
|
|
||||||
- horsin around
|
## met dank aan
|
||||||
- playing with raw proc macros
|
|
||||||
- making a bit of fun about programming languages that do this seriously,
|
|
||||||
though I can see their utility.
|
|
||||||
- winking at [Marcel](https://github.com/brouberol/marcel)
|
|
||||||
- c'est chic
|
|
||||||
|
|
||||||
## un grand merci
|
- [Benjamin Bouvier] (https://github.com/bnjbvr/), Eric BREHAULT and Anisse Astier for their work on roullie
|
||||||
|
|
||||||
- [@VentGrey](https://twitter.com/VentGrey) for making a logo!
|
## licentie
|
||||||
|
|
||||||
## la license
|
|
||||||
|
|
||||||
[WTFPL](http://www.wtfpl.net/).
|
[WTFPL](http://www.wtfpl.net/).
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
[package]
|
[package]
|
||||||
name = "rouille_examples"
|
name = "roest_examples"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rouille = { path = "../rouille_proc_macro/" }
|
roest = { path = "../roest_proc_macro/" }
|
||||||
|
|
|
@ -1,73 +1,73 @@
|
||||||
rouille::rouille! {
|
roest::roest! {
|
||||||
externe cagette rouille;
|
extern krat roest;
|
||||||
|
|
||||||
utilisons std::collections::Dictionnaire comme Dico;
|
gebruik std::collections::Woordenboek zoals Wbk;
|
||||||
|
|
||||||
convention CléValeur {
|
karaktereigenschap SleutelWaarde {
|
||||||
fonction écrire(&soi, clé: Chaine, valeur: Chaine);
|
functie schrijf(&zelf, sleutel: Keten, waarde: Keten);
|
||||||
fonction lire(&soi, clé: Chaine) -> PeutÊtre<&Chaine>;
|
functie lees(&zelf, sleutel: Keten) -> Mogelijkheid<&Keten>;
|
||||||
}
|
}
|
||||||
|
|
||||||
statique mutable DICTIONNAIRE: PeutÊtre<Dico<Chaine, Chaine>> = Rien;
|
vast veranderlijk WOORDENBOEK: Mogelijkheid<Wbk<Keten, Keten>> = Geen;
|
||||||
|
|
||||||
structure Concrète;
|
structuur Concreet;
|
||||||
|
|
||||||
réalisation CléValeur pour Concrète {
|
uitwerking SleutelWaarde voor Concreet {
|
||||||
fonction écrire(&soi, clé: Chaine, valeur: Chaine) {
|
functie schrijf(&zelf, sleutel: Keten, waarde: Keten) {
|
||||||
soit dico = dangereux {
|
laat wk = gevaarlijk {
|
||||||
DICTIONNAIRE.prendre_ou_insérer_avec(Défaut::défaut)
|
WOORDENBOEK.verkrijg_of_voeg_toe_met(Standaard::standaard)
|
||||||
};
|
};
|
||||||
dico.insérer(clé, valeur);
|
wk.voeg_in(sleutel, waarde);
|
||||||
}
|
}
|
||||||
fonction lire(&soi, clé: Chaine) -> PeutÊtre<&Chaine> {
|
functie lees(&zelf, sleutel: Keten) -> Mogelijkheid<&Keten> {
|
||||||
soit dico = dangereux {
|
laat wk = gevaarlijk {
|
||||||
DICTIONNAIRE.prendre_ou_insérer_avec(Défaut::défaut)
|
WOORDENBOEK.verkrijg_of_voeg_toe_met(Standaard::standaard)
|
||||||
};
|
};
|
||||||
dico.lire(&clé)
|
wk.verkrijg(&sleutel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public(cagette) fonction peut_etre(i: u32) -> PeutÊtre<Résultat<u32, Chaine>> {
|
openbaar(krat) functie misschien(i: u32) -> Mogelijkheid<Resultaat<u32, Keten>> {
|
||||||
si i % 2 == 1 {
|
als i % 2 == 1 {
|
||||||
si i == 42 {
|
als i == 42 {
|
||||||
Quelque(Arf(Chaine::depuis("merde")))
|
Enige(Ft(Keten::van("poep")))
|
||||||
} sinon {
|
} anders {
|
||||||
Quelque(Bien(33))
|
Enige(Goed(33))
|
||||||
}
|
}
|
||||||
} sinon {
|
} anders {
|
||||||
Rien
|
Geen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
asynchrone fonction exemple() {
|
gelijktijdige functie voorbeeld() {
|
||||||
}
|
}
|
||||||
|
|
||||||
asynchrone fonction exemple2() {
|
gelijktijdige functie voorbeeld2() {
|
||||||
exemple().attend;
|
voorbeeld().wacht_af;
|
||||||
}
|
}
|
||||||
|
|
||||||
fonction principale() {
|
functie hoofd() {
|
||||||
soit mutable x = 31;
|
laat veranderlijk x = 31;
|
||||||
|
|
||||||
correspond x {
|
gelijkend x {
|
||||||
42 => {
|
42 => {
|
||||||
affiche!("omelette du fromage")
|
schrijfrgl!("pannekoek")
|
||||||
}
|
}
|
||||||
_ => affiche!("voila")
|
_ => schrijfrgl!("zie daar")
|
||||||
}
|
}
|
||||||
|
|
||||||
pour i de 0..10 {
|
voor i binnen 0..10 {
|
||||||
soit val = boucle {
|
laat val = lus {
|
||||||
arrête i;
|
ontsnap i;
|
||||||
};
|
};
|
||||||
|
|
||||||
tant que x < val {
|
zolang x < val {
|
||||||
x += 1;
|
x += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
x = si soit Quelque(resultat) = peut_etre(i) {
|
x = als laat Enige(resultaat) = misschien(i) {
|
||||||
resultat.déballer()
|
resultaat.pak_uit()
|
||||||
} sinon {
|
} anders {
|
||||||
12
|
12
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "rouille"
|
name = "roest"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
105
roest_proc_macro/src/lib.rs
Normal file
105
roest_proc_macro/src/lib.rs
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
use proc_macro::{Group, Ident, TokenStream, TokenTree};
|
||||||
|
|
||||||
|
fn replace_ident(ident: Ident) -> Option<TokenTree> {
|
||||||
|
let ident_str = ident.to_string();
|
||||||
|
|
||||||
|
let new_str = match ident_str.as_str() {
|
||||||
|
"Ft" => "Err",
|
||||||
|
"Goed" => "Ok",
|
||||||
|
"Keten" => "String",
|
||||||
|
"ktng" => "str",
|
||||||
|
"Woordenboek" => "HashMap",
|
||||||
|
"Standaard" => "Default",
|
||||||
|
"Fout" => "Error",
|
||||||
|
"Mogelijkheid" => "Option",
|
||||||
|
"Enige" => "Some",
|
||||||
|
"Geen" => "None",
|
||||||
|
"Resultaat" => "Result",
|
||||||
|
"Zelf" => "Self",
|
||||||
|
"schrijfrgl" => "println",
|
||||||
|
"ontsnap" => "break",
|
||||||
|
"gelijktijdige" => "async",
|
||||||
|
"wacht_af" => "await",
|
||||||
|
"lus" => "loop",
|
||||||
|
"verplaats" => "move",
|
||||||
|
"krat" => "crate",
|
||||||
|
"zoals" => "as",
|
||||||
|
"onveranderlijk" => "const",
|
||||||
|
"gelijkend" => "match",
|
||||||
|
"gevaarlijk" => "unsafe",
|
||||||
|
"binnen" => "in",
|
||||||
|
"van" => "from",
|
||||||
|
"dynamisch" => "dyn",
|
||||||
|
"pak_uit" => "unwrap",
|
||||||
|
"standaard" => "default",
|
||||||
|
"iu" => "io",
|
||||||
|
"extern" => "extern",
|
||||||
|
"onwaar" => "false",
|
||||||
|
"functie" => "fn",
|
||||||
|
"bovenstaand" => "super",
|
||||||
|
"uitwerking" => "impl",
|
||||||
|
"voeg_in" => "insert",
|
||||||
|
"karaktereigenschap" => "trait",
|
||||||
|
"verkrijg" => "get",
|
||||||
|
"module" => "mod",
|
||||||
|
"veranderlijk" => "mut",
|
||||||
|
"nieuw" => "new",
|
||||||
|
"gegeven" => "where",
|
||||||
|
"voor" => "for",
|
||||||
|
"verkrijg_of_voeg_toe_met" => "get_or_insert_with",
|
||||||
|
"hoofd" => "main",
|
||||||
|
"openbaar" => "pub",
|
||||||
|
"geef_terug" => "return",
|
||||||
|
"als" => "if",
|
||||||
|
"anders" => "else",
|
||||||
|
"zelf" => "self",
|
||||||
|
"laat" => "let",
|
||||||
|
"vast" => "static",
|
||||||
|
"structuur" => "struct",
|
||||||
|
"verwacht" => "expect",
|
||||||
|
"zolang" => "while",
|
||||||
|
"gebruik" => "use",
|
||||||
|
"waar" => "true",
|
||||||
|
"opsomming" => "enum",
|
||||||
|
|
||||||
|
_ => &ident_str,
|
||||||
|
};
|
||||||
|
|
||||||
|
let new_ident = Ident::new(new_str, ident.span());
|
||||||
|
Some(TokenTree::Ident(new_ident))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn replace_tree(tok: TokenTree, out: &mut Vec<TokenTree>) {
|
||||||
|
match tok {
|
||||||
|
TokenTree::Group(group) => {
|
||||||
|
let mut group_elem = Vec::new();
|
||||||
|
replace_stream(group.stream(), &mut group_elem);
|
||||||
|
let mut new_stream = TokenStream::new();
|
||||||
|
new_stream.extend(group_elem);
|
||||||
|
out.push(TokenTree::Group(Group::new(group.delimiter(), new_stream)));
|
||||||
|
}
|
||||||
|
TokenTree::Ident(ident) => {
|
||||||
|
if let Some(ident) = replace_ident(ident) {
|
||||||
|
out.push(ident);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TokenTree::Punct(..) | TokenTree::Literal(..) => {
|
||||||
|
out.push(tok);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn replace_stream(ts: TokenStream, out: &mut Vec<TokenTree>) {
|
||||||
|
for tok in ts {
|
||||||
|
replace_tree(tok, out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[proc_macro]
|
||||||
|
pub fn roest(item: TokenStream) -> TokenStream {
|
||||||
|
let mut returned = Vec::new();
|
||||||
|
replace_stream(item, &mut returned);
|
||||||
|
let mut out = TokenStream::new();
|
||||||
|
out.extend(returned);
|
||||||
|
out
|
||||||
|
}
|
|
@ -1,105 +0,0 @@
|
||||||
use proc_macro::{Group, Ident, TokenStream, TokenTree};
|
|
||||||
|
|
||||||
fn replace_ident(ident: Ident) -> Option<TokenTree> {
|
|
||||||
let ident_str = ident.to_string();
|
|
||||||
|
|
||||||
let new_str = match ident_str.as_str() {
|
|
||||||
"Arf" => "Err",
|
|
||||||
"Bien" => "Ok",
|
|
||||||
"Chaine" => "String",
|
|
||||||
"Dictionnaire" => "HashMap",
|
|
||||||
"Défaut" => "Default",
|
|
||||||
"Erreur" => "Error",
|
|
||||||
"PeutÊtre" => "Option",
|
|
||||||
"Quelque" => "Some",
|
|
||||||
"Rien" => "None",
|
|
||||||
"Résultat" => "Result",
|
|
||||||
"Soi" => "Self",
|
|
||||||
"affiche" => "println",
|
|
||||||
"arrête" => "break",
|
|
||||||
"asynchrone" => "async",
|
|
||||||
"attend" => "await",
|
|
||||||
"boucle" => "loop",
|
|
||||||
"bouge" => "move",
|
|
||||||
"cagette" => "crate",
|
|
||||||
"comme" => "as",
|
|
||||||
"constant" => "const",
|
|
||||||
"correspond" => "match",
|
|
||||||
"dangereux" => "unsafe",
|
|
||||||
"de" => "in",
|
|
||||||
"depuis" => "from",
|
|
||||||
"dynamique" => "dyn",
|
|
||||||
"déballer" => "unwrap",
|
|
||||||
"défaut" => "default",
|
|
||||||
"es" => "io",
|
|
||||||
"externe" => "extern",
|
|
||||||
"faux" => "false",
|
|
||||||
"fonction" => "fn",
|
|
||||||
"génial" => "super",
|
|
||||||
"réalisation" => "impl",
|
|
||||||
"insérer" => "insert",
|
|
||||||
"convention" => "trait",
|
|
||||||
"lire" => "get",
|
|
||||||
"module" => "mod",
|
|
||||||
"mutable" => "mut",
|
|
||||||
"nouveau" => "new",
|
|
||||||
"où" => "where",
|
|
||||||
"pour" => "for",
|
|
||||||
"prendre_ou_insérer_avec" => "get_or_insert_with",
|
|
||||||
"principale" => "main",
|
|
||||||
"public" => "pub",
|
|
||||||
"que" => None?,
|
|
||||||
"renvoie" => "return",
|
|
||||||
"si" => "if",
|
|
||||||
"sinon" => "else",
|
|
||||||
"soi" => "self",
|
|
||||||
"soit" => "let",
|
|
||||||
"statique" => "static",
|
|
||||||
"structure" => "struct",
|
|
||||||
"suppose" => "expect",
|
|
||||||
"tant" => "while",
|
|
||||||
"utilisons" => "use",
|
|
||||||
"vrai" => "true",
|
|
||||||
"énumération" => "enum",
|
|
||||||
|
|
||||||
_ => &ident_str,
|
|
||||||
};
|
|
||||||
|
|
||||||
let new_ident = Ident::new(new_str, ident.span());
|
|
||||||
Some(TokenTree::Ident(new_ident))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn replace_tree(tok: TokenTree, out: &mut Vec<TokenTree>) {
|
|
||||||
match tok {
|
|
||||||
TokenTree::Group(group) => {
|
|
||||||
let mut group_elem = Vec::new();
|
|
||||||
replace_stream(group.stream(), &mut group_elem);
|
|
||||||
let mut new_stream = TokenStream::new();
|
|
||||||
new_stream.extend(group_elem);
|
|
||||||
out.push(TokenTree::Group(Group::new(group.delimiter(), new_stream)));
|
|
||||||
}
|
|
||||||
TokenTree::Ident(ident) => {
|
|
||||||
if let Some(ident) = replace_ident(ident) {
|
|
||||||
out.push(ident);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TokenTree::Punct(..) | TokenTree::Literal(..) => {
|
|
||||||
out.push(tok);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn replace_stream(ts: TokenStream, out: &mut Vec<TokenTree>) {
|
|
||||||
for tok in ts {
|
|
||||||
replace_tree(tok, out)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro]
|
|
||||||
pub fn rouille(item: TokenStream) -> TokenStream {
|
|
||||||
let mut returned = Vec::new();
|
|
||||||
replace_stream(item, &mut returned);
|
|
||||||
let mut out = TokenStream::new();
|
|
||||||
out.extend(returned);
|
|
||||||
out
|
|
||||||
}
|
|
Loading…
Reference in a new issue