Compare commits

..

2 commits

Author SHA1 Message Date
Benjamin Bouvier 67b763f20f toujours plus 2021-09-11 15:59:40 +02:00
Benjamin Bouvier 66718968a4 new keywords, who diz 2021-09-11 15:55:13 +02:00
10 changed files with 232 additions and 199 deletions

View file

@ -2,9 +2,9 @@ name: Rust
on:
push:
branches: [ hoofd ]
branches: [ principale ]
pull_request:
branches: [ hoofd ]
branches: [ principale ]
jobs:
ci:
@ -26,7 +26,7 @@ jobs:
toolchain: ${{ matrix.rust }}
override: true
- name: Draai de voorbeelden
- name: Lancer les exemples
uses: actions-rs/cargo@v1
with:
command: run

View file

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

101
README.md
View file

@ -1,71 +1,98 @@
# Roest
# rouille
![](https://raw.githubusercontent.com/jeroenhd/roest/hoofd/logo.png)
![](https://github.com/bnjbvr/rouille/raw/principale/logo.jpeg)
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
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
funny-sounding language? Would you want to bring some French touch to your
programs?
**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).
**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.
Any government officials wanting to use this language should donate to rouille
using [liberapay](https://liberapay.com/bnjbvr/).
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/).
You're from Flanders and don't feel at ease using only Dutch words? Don't worry!
You're from Quebec and don't feel at ease using only French words? Don't worry!
French Rust is fully compatible with English-Rust, so you can mix both at your
convenience. Support for French Rust is not yet available.
convenience.
Here's an example of what can be achieved with Roest:
Here's an example of what can be achieved with Rouille:
### struct and impl (aka convention et réalisation)
```rust
gebruik std::collections::Woordenboek zoals Wbk;
rouille::rouille! {
utilisons std::collections::Dictionnaire comme Dico;
karaktereigenschap SleutelWaarde {
functie schrijf(&zelf, sleutel: Keten, waarde: Keten);
functie lees(&zelf, sleutel: Keten) -> Mogelijkheid<&Keten>;
convention CléValeur {
fonction écrire(&soi, clé: Chaine, valeur: Chaine);
fonction lire(&soi, clé: Chaine) -> PeutÊtre<&Chaine>;
}
vast veranderlijk WOORDENBOEK: Mogelijkheid<Wbk<Keten, Keten>> = Geen;
statique mutable DICTIONNAIRE: PeutÊtre<Dico<Chaine, Chaine>> = Rien;
structuur Concreet;
structure Concrète;
uitwerking SleutelWaarde voor Concreet {
functie schrijf(&zelf, sleutel: Keten, waarde: Keten) {
laat wk = gevaarlijk {
WOORDENBOEK.verkrijg_of_voeg_toe_met(Standaard::standaard)
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)
};
wk.voeg_in(sleutel, waarde);
dico.insérer(clé, valeur);
}
functie lees(&zelf, sleutel: Keten) -> Mogelijkheid<&Keten> {
laat wk = gevaarlijk {
WOORDENBOEK.verkrijg_of_voeg_toe_met(Standaard::standaard)
};
wk.verkrijg(&sleutel)
fonction lire(&soi, clé: Chaine) -> Résultat<PeutÊtre<&Chaine>, Chaine> {
si soit Quelque(dico) = dangereux { DICTIONNAIRE.en_réf() } {
Bien(dico.lire(&clé))
} sinon {
Arf("fetchez le dico".vers())
}
}
}
}
```
### Support for regional languages
```rust
#[légal(code_inaccessible)]
fonction secondaire() {
merde!("oh non"); // for the true French experience
calisse!("tabernacle"); // for friends speaking fr-ca
oups!("fetchez la vache"); // in SFW contexts
}
```
### Other examples
See the [examples](./examples/src/main.rs) to get a rough sense of the whole
syntax. Ziezo, that's it.
syntax. Voilà, that's it.
## contributies
## les contributions
First of all, _dankjewel_ for considering participating to this joke, the
First of all, _merci beaucoup_ 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 `hoofd` (Dutch for
here and there, and open a pull-request against the `principale` (French for
`main`) branch.
## but why would you do dat
Please don't introduce swear words, though: we will not excuse your French.
- if the French can do it, so can we
## but why would you do zat
## met dank aan
- 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
- [Benjamin Bouvier] (https://github.com/bnjbvr/), Eric BREHAULT and Anisse Astier for their work on [rouille](https://github.com/bnjbvr/rouille)
## un grand merci
## licentie
- [@VentGrey](https://twitter.com/VentGrey) for making a logo!
## la license
[WTFPL](http://www.wtfpl.net/).

View file

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

View file

@ -1,80 +1,85 @@
roest::roest! {
extern krat roest;
rouille::rouille! {
externe cagette rouille;
gebruik std::collections::Woordenboek zoals Wbk;
utilisons std::collections::Dictionnaire comme Dico;
karaktereigenschap SleutelWaarde {
functie schrijf(&zelf, sleutel: Keten, waarde: Keten);
functie lees(&zelf, sleutel: Keten) -> Resultaat<Mogelijkheid<&Keten>, Keten>;
convention CléValeur {
fonction écrire(&soi, clé: Chaine, valeur: Chaine);
fonction lire(&soi, clé: Chaine) -> Résultat<PeutÊtre<&Chaine>, Chaine>;
}
vast veranderlijk WOORDENBOEK: Mogelijkheid<Wbk<Keten, Keten>> = Geen;
statique mutable DICTIONNAIRE: PeutÊtre<Dico<Chaine, Chaine>> = Rien;
structuur Concreet;
structure Concrète;
uitwerking SleutelWaarde voor Concreet {
functie schrijf(&zelf, sleutel: Keten, waarde: Keten) {
laat wk = gevaarlijk {
WOORDENBOEK.verkrijg_of_voeg_toe_met(Standaard::standaard)
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)
};
wk.voeg_in(sleutel, waarde);
dico.insérer(clé, valeur);
}
functie lees(&zelf, sleutel: Keten) -> Resultaat<Mogelijkheid<&Keten>, Keten> {
// laat wk = gevaarlijk {
// WOORDENBOEK.verkrijg_of_voeg_toe_met(Standaard::standaard)
// };
// wk.verkrijg(&sleutel)
als laat Enige(wbk) = gevaarlijk { WOORDENBOEK.als_verw() } {
Goed(wbk.verkrijg(&sleutel))
} anders {
Ft("ophalen uit woordenboek".tot())
fonction lire(&soi, clé: Chaine) -> Résultat<PeutÊtre<&Chaine>, Chaine> {
si soit Quelque(dico) = dangereux { DICTIONNAIRE.en_réf() } {
Bien(dico.lire(&clé))
} sinon {
Arf("fetchez le dico".vers())
}
}
}
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))
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))
}
} anders {
Geen
} sinon {
Rien
}
}
gelijktijdige functie voorbeeld() {
asynchrone fonction exemple() {
}
gelijktijdige functie voorbeeld2() {
voorbeeld().wacht_af;
asynchrone fonction exemple2() {
exemple().attend;
}
functie hoofd() {
laat veranderlijk x = 31;
fonction principale() {
soit mutable x = 31;
gelijkend x {
selon x {
42 => {
schrijfrgl!("pannekoek")
affiche!("omelette du fromage")
}
_ => schrijfrgl!("zie daar")
_ => affiche!("voila")
}
voor i binnen 0..10 {
laat val = lus {
ontsnap i;
pour i de 0..10 {
soit val = boucle {
arrête i;
};
zolang x < val {
tant que x < val {
x += 1;
}
x = als laat Enige(resultaat) = misschien(i) {
resultaat.pak_uit()
} anders {
x = si soit Quelque(resultat) = peut_etre(i) {
resultat.déballer()
} sinon {
12
};
}
secondaire();
}
#[légal(code_inaccessible)]
fonction secondaire() {
merde!("oh non"); // for the true French experience
calisse!("tabernacle"); // for friends speaking fr-ca
oups!("fetchez la vache"); // in SFW contexts
}
}

BIN
logo.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 KiB

BIN
logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 365 KiB

View file

@ -1,110 +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() {
"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",
"tot" => "into",
"verw" => "ref",
"als_verw" => "as_ref",
"onbereikbare_code" => "unreachable_code",
"sta_toe" => "allow",
_ => &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,5 +1,5 @@
[package]
name = "roest"
name = "rouille"
version = "0.1.0"
edition = "2018"

View file

@ -0,0 +1,111 @@
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",
"code_inaccessible" => "unreachable_code",
"comme" => "as",
"constant" => "const",
"convention" => "trait",
"dangereux" => "unsafe",
"de" => "in",
"depuis" => "from",
"dynamique" => "dyn",
"déballer" => "unwrap",
"défaut" => "default",
"en_réf" => "as_ref",
"es" => "io",
"externe" => "extern",
"faux" => "false",
"fonction" => "fn",
"génial" => "super",
"insérer" => "insert",
"lire" => "get",
"légal" => "allow",
"merde" | "calisse" | "oups" => "panic",
"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",
"réalisation" => "impl",
"réf" => "ref",
"selon" => "match",
"si" => "if",
"sinon" => "else",
"soi" => "self",
"soit" => "let",
"statique" => "static",
"structure" => "struct",
"suppose" => "expect",
"tant" => "while",
"utilisons" => "use",
"vers" => "into",
"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
}