colors
This commit is contained in:
parent
90322f7bcf
commit
16d6ff8311
|
@ -1 +1 @@
|
|||
{"categories":[{"name":"todo","content":[{"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":"error ligne compilation","description":"// Hello there","id":2},{"name":"commentaires","description":"// Hello there","id":3},{"name":"compile time verification","description":"odre des termes rpn","id":1},{"name":"test multiple space in texte","description":"// Hello there","id":3},{"name":"test puis in texte","description":"// Hello there","id":2},{"name":"enchainement puis","description":"// Hello there","id":5},{"name":"guillemet mal ferme","description":"// Hello there","id":4},{"name":"display element","description":"for better print","id":6},{"name":"puis à la ligne, alinéa","description":"// Hello there","id":1},{"name":"teste double tiret","description":"// Hello there","id":2},{"name":"teste puis seul","description":"tout seul, seul devant, seul fin","id":3},{"name":"erreur calcul bool/nombre","description":"affiche element precedent lorsque mauvais enchainement","id":1}]},{"name":"bug","content":[]},{"name":"to test","content":[{"name":"tests mod","description":"// Hello there","id":3},{"name":"test variable","description":"// Hello there","id":2}]},{"name":"bonus","content":[{"name":"stop cheating with \"-\"","description":"// Hello there","id":5},{"name":"affiche ligne et position erreur","description":"// Hello there","id":1},{"name":"pour numero de ligne execution","description":"sauvegarde numero de ligne dans la commande\n\ncommande.ligne(12)","id":3},{"name":"standardizer erreur","description":"regarder les texte répétés","id":1}]},{"name":"+","content":[]}]}
|
||||
{"categories":[{"name":"todo","content":[{"name":"multiple compilation error","description":"// Hello there","id":1},{"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":"error ligne compilation","description":"// Hello there","id":2},{"name":"commentaires","description":"// Hello there","id":3},{"name":"compile time verification","description":"odre des termes rpn","id":1},{"name":"test multiple space in texte","description":"// Hello there","id":3},{"name":"test puis in texte","description":"// Hello there","id":2},{"name":"enchainement puis","description":"// Hello there","id":5},{"name":"guillemet mal ferme","description":"// Hello there","id":4},{"name":"display element","description":"for better print","id":6},{"name":"puis à la ligne, alinéa","description":"// Hello there","id":1},{"name":"teste double tiret","description":"// Hello there","id":2},{"name":"teste puis seul","description":"tout seul, seul devant, seul fin","id":3},{"name":"erreur calcul bool/nombre","description":"affiche element precedent lorsque mauvais enchainement","id":1}]},{"name":"bug","content":[]},{"name":"to test","content":[{"name":"tests mod","description":"// Hello there","id":3},{"name":"test variable","description":"// Hello there","id":2}]},{"name":"bonus","content":[{"name":"stop cheating with \"-\"","description":"// Hello there","id":5},{"name":"affiche ligne et position erreur","description":"// Hello there","id":1},{"name":"pour numero de ligne execution","description":"sauvegarde numero de ligne dans la commande\n\ncommande.ligne(12)","id":3},{"name":"standardizer erreur","description":"regarder les texte répétés","id":1}]},{"name":"+","content":[]}]}
|
15
src/main.rs
15
src/main.rs
|
@ -21,31 +21,30 @@ fn main() {
|
|||
let lecture = fs::read_to_string(chemin_de_fichier);
|
||||
|
||||
if let Err(raison) = lecture {
|
||||
eprintln!("Fichier illisible : {}", raison);
|
||||
eprintln!("{}Fichier illisible :{} {}", debug::TEXTE_ROUGE, raison, debug::TEXTE_NORMAL);
|
||||
return
|
||||
}
|
||||
|
||||
println!("# Compilation de '{}'.", chemin_de_fichier);
|
||||
debug::message_compilation(chemin_de_fichier);
|
||||
let debut = Instant::now();
|
||||
if let Err(raison) = pendragon.compile(lecture.unwrap()) {
|
||||
eprintln!("\n{}", raison);
|
||||
eprintln!("\n# Échec de la compilation.");
|
||||
debug::message_compilation_echec();
|
||||
return
|
||||
}
|
||||
println!("# Compilation Ok. ({:.2?})\n", debut.elapsed());
|
||||
debug::message_compilation_ok(debut.elapsed());
|
||||
|
||||
if debug_mode {
|
||||
println!("{}\n", pendragon.programme);
|
||||
}
|
||||
|
||||
|
||||
println!("# Exécution de '{}'.\n", chemin_de_fichier);
|
||||
debug::message_execution(chemin_de_fichier);
|
||||
let debut = Instant::now();
|
||||
if let Err(raison) = pendragon.programme.execute() {
|
||||
eprintln!("\nErreur : {}", raison);
|
||||
eprintln!("\n# Échec de l'exécution.");
|
||||
debug::message_execution_echec();
|
||||
return
|
||||
}
|
||||
|
||||
println!("\n# Exécution Ok. ({:.2?})", debut.elapsed());
|
||||
debug::message_execution_ok(debut.elapsed());
|
||||
}
|
||||
|
|
|
@ -1,18 +1,54 @@
|
|||
use std::fmt;
|
||||
use std::time::Duration;
|
||||
use super::*;
|
||||
|
||||
pub const TEXTE_ROUGE: &str = "\x1b[31m";
|
||||
//pub const TEXTE_VERT: &str = "\x1b[32m";
|
||||
//pub const TEXTE_JAUNE: &str = "\x1b[33m";
|
||||
//pub const TEXTE_BLEU: &str = "\x1b[34m";
|
||||
pub const TEXTE_GRIS: &str = "\x1b[37m";
|
||||
pub const TEXTE_NORMAL: &str = "\x1b[0m";
|
||||
|
||||
pub fn message_compilation(chemin_de_fichier: &str) {
|
||||
println!("# Compilation de '{}'.", chemin_de_fichier);
|
||||
}
|
||||
|
||||
pub fn message_compilation_echec() {
|
||||
eprintln!("\n# Échec de la compilation.");
|
||||
}
|
||||
|
||||
pub fn message_compilation_ok(temps: Duration) {
|
||||
println!("# Compilation Ok. ({:.2?})\n", temps);
|
||||
}
|
||||
|
||||
pub fn message_execution(chemin_de_fichier: &str) {
|
||||
println!("# Exécution de '{}'.\n", chemin_de_fichier);
|
||||
}
|
||||
|
||||
pub fn message_execution_echec() {
|
||||
eprintln!("\n# Échec de l'exécution.");
|
||||
}
|
||||
|
||||
pub fn message_execution_ok(temps: Duration) {
|
||||
println!("\n# Exécution Ok. ({:.2?})", temps);
|
||||
}
|
||||
|
||||
pub struct ErreurCompilation {
|
||||
index_ligne: usize,
|
||||
ligne: String,
|
||||
erreur: ErreurPendragon,
|
||||
}
|
||||
|
||||
impl ErreurCompilation {
|
||||
pub fn nouvelle(index_ligne: usize, erreur: ErreurPendragon) -> Self {
|
||||
pub fn nouvelle(index_ligne: usize, ligne: String, erreur: ErreurPendragon) -> Self {
|
||||
Self {
|
||||
index_ligne,
|
||||
ligne,
|
||||
erreur,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn raison(&self) -> ErreurPendragon {
|
||||
self.erreur.clone()
|
||||
}
|
||||
|
@ -21,7 +57,7 @@ impl ErreurCompilation {
|
|||
|
||||
impl fmt::Display for ErreurCompilation {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {//'
|
||||
write!(f, "Erreur ligne {} : {}", self.index_ligne + 1, self.erreur)
|
||||
write!(f, "{}Erreur :{} {}\n{}ligne {} : {}{}", TEXTE_ROUGE, TEXTE_NORMAL, self.erreur, TEXTE_GRIS, self.index_ligne + 1, self.ligne, TEXTE_NORMAL)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ impl Pendragon {
|
|||
continue
|
||||
};
|
||||
if !derniere_phrase.ends_with('.') && !derniere_phrase.ends_with(',') {
|
||||
return Err(ErreurCompilation::nouvelle(index_ligne, ErreurPendragon::ManquePonctuation))
|
||||
return Err(ErreurCompilation::nouvelle(index_ligne, ligne.into(), ErreurPendragon::ManquePonctuation))
|
||||
}
|
||||
for phrase in phrases {
|
||||
if phrase.ends_with(".") {
|
||||
|
@ -37,7 +37,7 @@ impl Pendragon {
|
|||
}
|
||||
match self.compile_commande(&phrase[..phrase.len() - 1]) {
|
||||
Ok(commande) => self.programme.ajoute_commande(commande),
|
||||
Err(raison) => return Err(ErreurCompilation::nouvelle(index_ligne, raison)),
|
||||
Err(raison) => return Err(ErreurCompilation::nouvelle(index_ligne, ligne.into(), raison)),
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ impl Pendragon {
|
|||
expression.push(Element::Operateur(Operateur::Puis));
|
||||
}
|
||||
expression.extend(self.puis(&expression, &pile_inconnu)?);
|
||||
pile_inconnu = Vec::new();
|
||||
expression.push(Element::Operateur(Operateur::Puis));
|
||||
Ok(expression)
|
||||
}
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
|
||||
|
||||
pub enum MotCle {
|
||||
Definis,
|
||||
Modifie,
|
||||
Affiche,
|
||||
Demande,
|
||||
Si,
|
||||
Sinon,
|
||||
NotaBene,
|
||||
Plus,
|
||||
Moins,
|
||||
Fois,
|
||||
Divise,
|
||||
Et,
|
||||
Ou,
|
||||
Non,
|
||||
OuvreParenthese,
|
||||
FermeParenthese,
|
||||
Puis,
|
||||
Alinea,
|
||||
RetourLigne,
|
||||
}
|
||||
|
||||
pub impl MotCle {
|
||||
fn comme_texte(&self) -> String {
|
||||
match Self {
|
||||
Self::Definis,
|
||||
Self::Modifie,
|
||||
Self::Affiche,
|
||||
Self::Demande,
|
||||
Self::Si,
|
||||
Self::Sinon,
|
||||
Self::NotaBene,
|
||||
Plus,
|
||||
Moins,
|
||||
Fois,
|
||||
Divise,
|
||||
Et,
|
||||
Ou,
|
||||
Non,
|
||||
OuvreParenthese,
|
||||
FermeParenthese,
|
||||
Puis,
|
||||
Alinea,
|
||||
RetourLigne,
|
||||
}
|
||||
}
|
||||
|
||||
fn depuis_texte(texte: &str) -> Self {
|
||||
match texte {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue