Skip to content

Commit

Permalink
Merge pull request #7 from Rudxain/palabras_y_tildes
Browse files Browse the repository at this point in the history
+ palabras y tildes, también correcciones
  • Loading branch information
UltiRequiem authored May 19, 2024
2 parents 4e76cd4 + c60b859 commit f73646e
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 80 deletions.
54 changes: 27 additions & 27 deletions examples/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
rustico::rustico! {
usando std::collections::Diccionario;
usar estd::colecciones::Diccionario;

sobrecarga Hola {
funcion escribe(&yo, llave: Texto, valor: Texto);
funcion consigue(&yo, llave: Texto) -> Resultado<Opcion<&Texto>, Texto>;
rasgo Hola {
función escribe(&yo, llave: Cadena, valor: Cadena);
// `fn` alias sin tilde
funcion consigue(&mismo, llave: Cadena) -> Resultado<Opción<&Cadena>, Cadena>;
}

statico mutable DICCIONARIO: Opcion<Diccionario<Texto, Texto>> = Ninguno;
estático mutable DICCIONARIO: Opcion<Diccionario<Cadena, Cadena>> = Ninguno;

structura Concreto;

implementa Hola para Concreto {
funcion escribe(&yo, llave: Texto, valor: Texto) {
deja dico = inseguro {
funcion escribe(&yo, llave: Cadena, valor: Cadena) {
sea dic = inseguro {
DICCIONARIO.obten_o_inserta_con(Defecto::defecto)
};
dico.insérer(llave, valor);
dic.insertar(llave, valor);
}
funcion consigue(&yo, llave: Texto) -> Resultado<Opcion<&Texto>, Texto> {
si deja Algunos(dico) = inseguro { DICCIONARIO.como_referencia() } {
Bien(dico.consigue(&llave))
funcion consigue(&yo, llave: Cadena) -> Resultado<Opcion<&Cadena>, Cadena> {
si deja Alguno(dic) = inseguro { DICCIONARIO.como_referencia() } {
Bien(dic.consigue(&llave))
} sino {
Error("fetchez le dico".dentro_de())
Error("llave no existe en diccionario".dentro_de())
}
}
}

publico(caja) funcion quizas(i: u32) -> Opcion<Resultado<u32, Texto>> {
púb(jaula) funcion quizas(i: n32) -> Opcion<Resultado<n32, Cadena>> {
si i % 2 == 1 {
si i == 42 {
Algunos(Error(Texto::desde("merde")))
Alguno(Error(Cadena::desde("caca")))
} sino {
Algunos(Bien(33))
Alguno(Bien(33))
}
} sino {
Ninguno
}
}

asyncrona funcion example() {
}
asinc función ejemplo() {}

asyncrona funcion example2() {
example().espera;
asínc funcion ejemplo2() {
ejemplo().espera;
}

funcion principal() {
deja mutable x = 31;
sea mutable x = 31;

machea x {
42 => {
imprime!("chales")
imprimeln!("chales")
}
_ => imprime!("Buenas!")
_ => imprimeln!("Buenas!")
}

para i de 0..10 {
deja val = loopea {
sea val = bucle {
rompe i;
};

mientras Difuso x < val {
x += 1;
}

x = si deja Algunos(resultado) = quizas(i) {
x = si deja Alguno(resultado) = quizas(i) {
resultado.pelar()
} sino {
12
Expand All @@ -73,9 +73,9 @@ rustico::rustico! {

}

#[permite(codigo_inusado)]
#[permite(código_inalcanzable)]
funcion secundario() {
chales!("oh non");
ups!("fetchez la vache");
chales!("ay no!");
ups!("cuando las vacas vuelen");
}
}
20 changes: 9 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# rustico
# rústico

![Para divertirme](https://raw.githubusercontent.com/UltiRequiem/rustico/e9e5c1c50f566f1946d9e506bb501b2e78cb551c/para_divertirme.png)
![Residente diciendo "Esto lo hago pa' divertirme"](https://raw.githubusercontent.com/UltiRequiem/rustico/e9e5c1c50f566f1946d9e506bb501b2e78cb551c/para_divertirme.png)

> [Doing it for the fun.](https://youtu.be/v3rOpmlpFsM)
> [Doing it for fun.](https://youtu.be/v3rOpmlpFsM)
Aren't you _cansado_ from writing Rust Programs in English? Do you like saying
_"chales"_ a lot? Would you like to try something different, in an exotic and
funny-sounding language?

**rustico** (Spanish for Rust) is here to save your day, as it allows you to
**rústico** (Spanish for Rust) is here to save your day, as it allows you to
write Rust programs in Latam Spanish.

You are from Costa Rica and don't feel at ease using only Spanish Words? Don't
Worry! Rustico is fully compatible English-Rust, you can mix both at your
convenience.
You are from Costa Rica and don't feel at ease using only Spanish Words? Don't Worry! Rústico is fully compatible English-Rust, you can mix both at your convenience.

## instalación

Expand All @@ -23,18 +21,18 @@ cargo install rustico

## uso

Here's an exmple of what can be achieved with Rustico.
Here's an example of what can be achieved with Rustico.

```rust
rustico::rustico! {
funcion principal() {
deja mutable x = 31;
función principal() {
sea mutable x: e32 = 31;

machea x {
42 => {
chales!("Like panic")
}
_ => imprime!("Buenas!")
_ => imprimeln!("Buenas!")
}

para numero de 0..10 {
Expand Down
6 changes: 3 additions & 3 deletions rustico/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ description = "Rust programming, in Spanish."
readme = "../readme.md"
license = "MIT"
homepage = "https://github.com/UltiRequiem/rustico"
keywords = ["spanish"]
keywords = ["spanish", "translate", "translation", "latino"]
authors = ["UltiRequiem"]
categories = ["acessability"]
version = "0.1.2"
categories = ["accessibility"]
version = "0.2.0"
edition = "2018"

[lib]
Expand Down
114 changes: 75 additions & 39 deletions rustico/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,69 +4,105 @@ fn replace_ident(ident: Ident) -> Option<TokenTree> {
let ident_str = ident.to_string();

let new_str = match ident_str.as_str() {
"núcleo" => "core",
"estd" | "estándar" => "std",
"colecciones" => "collections",
"e8" => "i8",
"e16" => "i16",
"e32" => "i32",
"e64" => "i64",
"e128" => "i128",
"etam" | "etalla" | "etamaño" => "isize",
// Esto es muy repetitivo.
// Y todavía falta `NonZero`!
"n8" => "u8",
"n16" => "u16",
"n32" => "u32",
"n64" => "u64",
"n128" => "u128",
"ntam" | "ntalla" | "ntamaño" => "usize",
"Error" => "Err",
"Bien" => "Ok",
"Texto" => "String",
"Diccionario" => "HashMap",
"Cadena" => "String",
"cad" => "str",
"como_cadena" => "to_string",
"como_cad" => "to_str",
"Hilo" => "Thread",
"hilo" => "thread",
"crear" => "spawn", // debería ser "aparecer"?
"Diccionario" => "HashMap", // no hay traducción satisfactoria para "hash"
"Conjunto" => "HashSet",
"Defecto" => "Default",
"Errorsaso" => "Error",
"Opcion" => "Option",
"Algunos" => "Some",
"Ninguno" => "None",
"defecto" => "default",
"Errorsaso" => "Error", // errorsasasaso!!!
"Opcion" | "Opción" => "Option",
"Alguno" => "Some", // Algo == !Nada
"Ninguno" => "None", // Nada = Nothing
"Resultado" => "Result",
"Yo" => "Self",
"imprime" => "println",
"rompe" => "break",
"asyncrona" => "async",
"Yo" | "Mismo" => "Self",
"yo" | "mismo" => "self",
"imprimeln" => "println", // línea
"imprime" => "print", // no hay línea
"rompe" | "romper" => "break",
"proceso" => "process",
"Comando" => "Command",
"salir" => "exit",
"asinc" | "asínc" => "async",
"espera" => "await",
"loopea" => "loop",
"muevete" => "move",
"caja" => "crate",
"codigo_inusado" => "unreachable_code",
"como" => "as",
"ciclo" | "bucle" => "loop",
"muevete" | "muévete" | "mover" => "move",
"jaula" => "crate",
"Caja" => "Box",
"codigo_inalcanzable" | "código_inalcanzable" => "unreachable_code",
"como" => "as", // no confundir con "¿Cómo?"
"constante" => "const",
"sobrecarga" => "trait",
"rasgo" => "trait", // sobrecarga = overload, overloads no existen
"inseguro" => "unsafe",
"de" => "in",
"desde" => "from",
"dinamico" => "dyn",
"pelar" => "unwrap",
"defecto" => "default",
"din" | "dinamico" | "dinámico" => "dyn",
"pelar" | "desenvolver" => "unwrap",
// debería haber "destapar"?
"pelar_o" => "unwrap_or",
"pelar_o_sino" => "unwrap_or_else",
"como_referencia" => "as_ref",
"es" => "io",
"externa" => "extern",
"externa" | "externo" => "extern",
"falso" => "false",
"funcion" => "fn",
"piola" => "super",
"insérer" => "insert",
"consigue" => "get",
"permite" => "allow",
"verdad" => "true",
"bul" | "bulin" | "bulín" | "boleano" => "bool",
"funcion" | "función" => "fn",
"súper" | "piola" => "super",
"insertar" => "insert",
"consigue" | "obtén" => "get",
"permite" | "permitir" => "allow",
"advertir" => "warn",
"denegar" => "deny",
"prohibir" => "forbid",
"chales" | "ups" => "panic",
"modulo" => "mod",
"mód" | "módulo" => "mod",
"mutable" => "mut",
"nuevo" => "new",
"donde" => "where",
"para" => "for",
"obten_o_inserta_con" => "get_or_insert_with",
"donde" => "where", // no confundir con "¿Dónde?"
"para" | "por" => "for",
"obten_o_inserta_con" | "obtén_o_inserta_con" => "get_or_insert_with",
"principal" => "main",
"publico" => "pub",
"púb" | "publico" | "público" => "pub",
"Difuso" => None?,
"retorna" => "return",
"retorna" | "devuelve" | "devolver" => "return",
"implementa" => "impl",
"referencia" => "ref",
"machea" => "match",
"machea" | "encaja" => "match",
"si" => "if",
"sino" => "else",
"yo" => "self",
"deja" => "let",
"estatico" => "static",
"deja" | "sea" => "let",
"estatico" | "estático" => "static",
"estructura" => "struct",
"confia" => "expect",
"confia" | "confía" | "asume" => "expect",
"mientras" => "while",
"usando" => "use",
"usando" | "usar" => "use",
"dentro_de" => "into",
"verdad" => "true",
"enumerado" => "enum",
"enumerado" | "enumeración" => "enum",
"Rasgo" => "Trait"

Check failure on line 106 in rustico/src/lib.rs

View workflow job for this annotation

GitHub Actions / Rust project

expected `,` following `match` arm
_ => &ident_str,
};
Expand Down

0 comments on commit f73646e

Please sign in to comment.