Eerste Nederlandse versie

This commit is contained in:
Jeroen Hoegen Dijkhof 2021-09-11 16:08:47 +02:00
parent 7776a0febb
commit ac90050ec4
No known key found for this signature in database
GPG Key ID: 1B26DDB69F21CB8C
9 changed files with 192 additions and 201 deletions

View File

@ -1,5 +1,5 @@
[workspace]
members = [
"rouille_proc_macro",
"roest_proc_macro",
"examples"
]

View File

@ -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
"merde" a lot? Would you like to try something different, in an exotic and
Aren't you _het spuugzat_ from writing Rust programs in English? Do you like saying
"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
programs?
**rouille** (French for _Rust_) is here to save your day, as it allows you to
write Rust programs in French, using French keywords, French function names,
French idioms.
**roest** (Dutch for _Rust_) is here to save your day, as it allows you to
write Rust programs in Dutch, using Dutch keywords, Dutch function names,
Dutch idioms, based on [rouille](https://github.com/bnjbvr/rouille).
This has been designed to be used as the official programming language to
develop the future French sovereign operating system. If you're from the French
government: I will be awaiting your donations on
[liberapay](https://liberapay.com/bnjbvr/).
Any government officials wanting to use this language should donate to rouille
using [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
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
utilisons std::collections::Dictionnaire comme Dico;
gebruik std::collections::Woordenboek zoals Wbk;
convention CléValeur {
fonction écrire(&soi, clé: Chaine, valeur: Chaine);
fonction lire(&soi, clé: Chaine) -> PeutÊtre<&Chaine>;
}
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);
karaktereigenschap SleutelWaarde {
functie schrijf(&zelf, sleutel: Keten, waarde: Keten);
functie lees(&zelf, sleutel: Keten) -> Mogelijkheid<&Keten>;
}
fonction lire(&soi, clé: Chaine) -> PeutÊtre<&Chaine> {
soit dico = dangereux {
DICTIONNAIRE.prendre_ou_insérer_avec(Défaut::défaut)
};
dico.lire(&clé)
vast veranderlijk WOORDENBOEK: Mogelijkheid<Wbk<Keten, Keten>> = Geen;
structuur Concreet;
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
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
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.
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
- 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
## met dank aan
## 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!
## la license
## licentie
[WTFPL](http://www.wtfpl.net/).

View File

@ -1,9 +1,9 @@
[package]
name = "rouille_examples"
name = "roest_examples"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rouille = { path = "../rouille_proc_macro/" }
roest = { path = "../roest_proc_macro/" }

View File

@ -1,73 +1,73 @@
rouille::rouille! {
externe cagette rouille;
roest::roest! {
extern krat roest;
utilisons std::collections::Dictionnaire comme Dico;
gebruik std::collections::Woordenboek zoals Wbk;
convention CléValeur {
fonction écrire(&soi, clé: Chaine, valeur: Chaine);
fonction lire(&soi, clé: Chaine) -> PeutÊtre<&Chaine>;
karaktereigenschap SleutelWaarde {
functie schrijf(&zelf, sleutel: Keten, waarde: Keten);
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 {
fonction écrire(&soi, clé: Chaine, valeur: Chaine) {
soit dico = dangereux {
DICTIONNAIRE.prendre_ou_insérer_avec(Défaut::défaut)
uitwerking SleutelWaarde voor Concreet {
functie schrijf(&zelf, sleutel: Keten, waarde: Keten) {
laat wk = gevaarlijk {
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> {
soit dico = dangereux {
DICTIONNAIRE.prendre_ou_insérer_avec(Défaut::défaut)
functie lees(&zelf, sleutel: Keten) -> Mogelijkheid<&Keten> {
laat wk = gevaarlijk {
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>> {
si i % 2 == 1 {
si i == 42 {
Quelque(Arf(Chaine::depuis("merde")))
} sinon {
Quelque(Bien(33))
openbaar(krat) functie misschien(i: u32) -> Mogelijkheid<Resultaat<u32, Keten>> {
als i % 2 == 1 {
als i == 42 {
Enige(Ft(Keten::van("poep")))
} anders {
Enige(Goed(33))
}
} sinon {
Rien
} anders {
Geen
}
}
asynchrone fonction exemple() {
gelijktijdige functie voorbeeld() {
}
asynchrone fonction exemple2() {
exemple().attend;
gelijktijdige functie voorbeeld2() {
voorbeeld().wacht_af;
}
fonction principale() {
soit mutable x = 31;
functie hoofd() {
laat veranderlijk x = 31;
correspond x {
gelijkend x {
42 => {
affiche!("omelette du fromage")
schrijfrgl!("pannekoek")
}
_ => affiche!("voila")
_ => schrijfrgl!("zie daar")
}
pour i de 0..10 {
soit val = boucle {
arrête i;
voor i binnen 0..10 {
laat val = lus {
ontsnap i;
};
tant que x < val {
zolang x < val {
x += 1;
}
x = si soit Quelque(resultat) = peut_etre(i) {
resultat.déballer()
} sinon {
x = als laat Enige(resultaat) = misschien(i) {
resultaat.pak_uit()
} anders {
12
};
}

BIN
logo.jpeg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 KiB

BIN
logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 KiB

View File

@ -1,5 +1,5 @@
[package]
name = "rouille"
name = "roest"
version = "0.1.0"
edition = "2018"

105
roest_proc_macro/src/lib.rs Normal file
View 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
}

View File

@ -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",
"" => "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
}