nice ui
This commit is contained in:
parent
20eba421d7
commit
19ec0dcf36
|
@ -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":[]}]}
|
|
@ -24,13 +24,12 @@ fn main() {
|
||||||
return
|
return
|
||||||
};
|
};
|
||||||
if debug_mode {
|
if debug_mode {
|
||||||
println!("{}\n-----------", pendragon.programme);
|
println!("{}\n", pendragon.programme);
|
||||||
}
|
}
|
||||||
if let Err(raison) = pendragon.programme.execute() {
|
if let Err(raison) = pendragon.programme.execute() {
|
||||||
eprintln!("Erreur Execution : {}", raison);
|
eprintln!("Erreur Execution : {}", raison);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
println!("\n# Success");
|
|
||||||
}
|
}
|
||||||
Err(raison) => {
|
Err(raison) => {
|
||||||
eprintln!("Fichier illisible : {}", raison);
|
eprintln!("Fichier illisible : {}", raison);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
pub mod nombre;
|
pub mod nombre;
|
||||||
pub mod texte;
|
pub mod texte;
|
||||||
|
@ -8,9 +9,6 @@ use structure::*;
|
||||||
pub mod debug;
|
pub mod debug;
|
||||||
use debug::*;
|
use debug::*;
|
||||||
|
|
||||||
//#[cfg(test)]
|
|
||||||
//mod tests;
|
|
||||||
|
|
||||||
pub struct Pendragon {
|
pub struct Pendragon {
|
||||||
pub programme: Programme,
|
pub programme: Programme,
|
||||||
}
|
}
|
||||||
|
@ -23,7 +21,9 @@ impl Pendragon {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compile(&mut self, contenu: String) -> Result<(), ErreurPendragon> {
|
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 mut texte: Vec<&str> = contenu_propre.split('.').collect();
|
||||||
let reste = texte.pop();
|
let reste = texte.pop();
|
||||||
if reste != Some("") {
|
if reste != Some("") {
|
||||||
|
@ -31,6 +31,7 @@ impl Pendragon {
|
||||||
return Err(ErreurPendragon::ManquePoint)
|
return Err(ErreurPendragon::ManquePoint)
|
||||||
}
|
}
|
||||||
for (index_phrase, phrase) in texte.iter().enumerate() {
|
for (index_phrase, phrase) in texte.iter().enumerate() {
|
||||||
|
let phrase = phrase.trim();
|
||||||
match self.compile_phrase(phrase) {
|
match self.compile_phrase(phrase) {
|
||||||
Ok(commande) => {self.programme.ajoute_commande(commande)},
|
Ok(commande) => {self.programme.ajoute_commande(commande)},
|
||||||
Err(raison) => {
|
Err(raison) => {
|
||||||
|
@ -39,6 +40,7 @@ impl Pendragon {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
println!("# Compilation Ok. ({:.2?})\n", debut.elapsed());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -53,6 +54,8 @@ impl Programme {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn execute(&self) -> Result<(), ErreurPendragon> {
|
pub fn execute(&self) -> Result<(), ErreurPendragon> {
|
||||||
|
let debut = Instant::now();
|
||||||
|
println!("# Execution...\n");
|
||||||
let mut variables_globales: HashMap<String, Element> = HashMap::new();
|
let mut variables_globales: HashMap<String, Element> = HashMap::new();
|
||||||
for commande in &self.commandes {
|
for commande in &self.commandes {
|
||||||
match commande {
|
match commande {
|
||||||
|
@ -76,6 +79,7 @@ impl Programme {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
println!("\n# Exécution Ok. ({:.2?})", debut.elapsed());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
8
test.dr
8
test.dr
|
@ -1,5 +1,3 @@
|
||||||
Définis A comme entier.
|
Affiche soixante-dix.
|
||||||
Modifie A avec dix-huit.
|
Affiche soixante-et-onze.
|
||||||
Définis B comme booléen.
|
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.
|
||||||
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.
|
|
Loading…
Reference in a new issue