This commit is contained in:
WanderingPenwing 2024-12-11 14:58:26 +01:00
parent 20eba421d7
commit 19ec0dcf36
5 changed files with 15 additions and 12 deletions

View file

@ -1 +1 @@
{"categories":[{"name":"todo","content":[{"name":"booleen type","description":"// Hello there","id":4},{"name":"if","description":"implémente if avec des guillemets de délimitation","id":1},{"name":"while","description":"implémente un while","id":2},{"name":"compilation","description":"// Hello there","id":3},{"name":"soixante-dix","description":"// Hello there","id":1}]},{"name":"in progress","content":[]},{"name":"done","content":[]},{"name":"bug","content":[]},{"name":"to test","content":[]},{"name":"+","content":[]}]}
{"categories":[{"name":"todo","content":[{"name":"commentaires","description":"// Hello there","id":3},{"name":"compile time verification","description":"odre des termes rpn","id":1},{"name":"error context","description":"// Hello there","id":2},{"name":"test correct error","description":"// Hello there","id":3},{"name":"if","description":"implémente if avec des guillemets de délimitation","id":1},{"name":"scope variable","description":"// Hello there","id":6},{"name":"while","description":"implémente un while","id":2},{"name":"else","description":"// Hello there","id":7},{"name":"break","description":"// Hello there","id":8},{"name":"continue","description":"// Hello there","id":9},{"name":"compilation","description":"// Hello there","id":3}]},{"name":"in progress","content":[]},{"name":"done","content":[{"name":"comparaison","description":"// Hello there","id":2},{"name":"booleen type","description":"// Hello there","id":4},{"name":"soixante-dix","description":"// Hello there","id":1},{"name":"parenthese comparaison","description":"// Hello there","id":1},{"name":"test comparaison","description":"// Hello there","id":4}]},{"name":"bug","content":[]},{"name":"to test","content":[]},{"name":"bonus","content":[{"name":"stop cheating with \"-\"","description":"// Hello there","id":5}]},{"name":"+","content":[]}]}

View file

@ -24,13 +24,12 @@ fn main() {
return
};
if debug_mode {
println!("{}\n-----------", pendragon.programme);
println!("{}\n", pendragon.programme);
}
if let Err(raison) = pendragon.programme.execute() {
eprintln!("Erreur Execution : {}", raison);
return
}
println!("\n# Success");
}
Err(raison) => {
eprintln!("Fichier illisible : {}", raison);

View file

@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::time::Instant;
pub mod nombre;
pub mod texte;
@ -8,9 +9,6 @@ use structure::*;
pub mod debug;
use debug::*;
//#[cfg(test)]
//mod tests;
pub struct Pendragon {
pub programme: Programme,
}
@ -23,7 +21,9 @@ impl Pendragon {
}
pub fn compile(&mut self, contenu: String) -> Result<(), ErreurPendragon> {
let contenu_propre = contenu.replace("\n", "");
println!();
let debut = Instant::now();
let contenu_propre = contenu.replace("\n", " ");
let mut texte: Vec<&str> = contenu_propre.split('.').collect();
let reste = texte.pop();
if reste != Some("") {
@ -31,6 +31,7 @@ impl Pendragon {
return Err(ErreurPendragon::ManquePoint)
}
for (index_phrase, phrase) in texte.iter().enumerate() {
let phrase = phrase.trim();
match self.compile_phrase(phrase) {
Ok(commande) => {self.programme.ajoute_commande(commande)},
Err(raison) => {
@ -39,6 +40,7 @@ impl Pendragon {
}
}
}
println!("# Compilation Ok. ({:.2?})\n", debut.elapsed());
Ok(())
}

View file

@ -1,5 +1,6 @@
use std::io;
use std::collections::HashMap;
use std::time::Instant;
use super::*;
@ -53,6 +54,8 @@ impl Programme {
}
pub fn execute(&self) -> Result<(), ErreurPendragon> {
let debut = Instant::now();
println!("# Execution...\n");
let mut variables_globales: HashMap<String, Element> = HashMap::new();
for commande in &self.commandes {
match commande {
@ -76,6 +79,7 @@ impl Programme {
}
}
}
println!("\n# Exécution Ok. ({:.2?})", debut.elapsed());
Ok(())
}
}

View file

@ -1,5 +1,3 @@
Définis A comme entier.
Modifie A avec dix-huit.
Définis B comme booléen.
Modifie B avec non faux et ouvre la parenthèse trois-mille-un divisé par A est supérieur ou égal à sept ou faux ferme la parenthèse.
Affiche B.
Affiche soixante-dix.
Affiche soixante-et-onze.
Affiche vrai et ouvre la parenthèse six plus un est supérieur à ouvre la parenthèse deux fois deux ferme la parenthèse ferme la parenthèse.