creation de la structure Entree et de la structure Structure. Une entrée contient une liste de structure.
This commit is contained in:
parent
b6b1ad629d
commit
da52af342b
1 changed files with 75 additions and 0 deletions
|
@ -1,3 +1,78 @@
|
||||||
|
|
||||||
|
// Definition des structures utilisés par le parseur.
|
||||||
|
// s'utilise par l'appel de la fonction static parse, qui prends en param une ligne de commande
|
||||||
|
// (Vect<String>) et qui renvois une Entree.
|
||||||
|
|
||||||
|
struct Structure {
|
||||||
|
/*
|
||||||
|
* Il y à 5 types de structs differentes.
|
||||||
|
* - commande
|
||||||
|
* - control
|
||||||
|
* - def variable
|
||||||
|
* - def function
|
||||||
|
* - pipes
|
||||||
|
*
|
||||||
|
* Cas 1; commande
|
||||||
|
* name: "commande"
|
||||||
|
* contents: ["nom commande", "parametter", "arg1", ...]
|
||||||
|
*
|
||||||
|
* Cas 2; control
|
||||||
|
* name: "control"
|
||||||
|
* contents: ["if|elif|else|while|for", "condition", "liste String avec (faudra la reparser
|
||||||
|
* quand on tomberas dessus pour obtenir son objet de classe Entree) "]
|
||||||
|
*
|
||||||
|
* Cas 3; def variable
|
||||||
|
* name: "variable"
|
||||||
|
* contents: ["type [string|list]", "name", "value"]
|
||||||
|
*
|
||||||
|
* Cas 4; def function
|
||||||
|
* name: "function"
|
||||||
|
* contents: ["name", "nb parametter", "param1", ..., "liste String interieur fonction(faudra
|
||||||
|
* la repasser quand on tomberas dessus pour obtenir son objet de classe Entree)"]
|
||||||
|
*
|
||||||
|
* Cas 5; pipes
|
||||||
|
* name: "pipe"
|
||||||
|
* contents: ["String Commande1 (faudra la repasser dans le parser)", "String Commande2(tout
|
||||||
|
* le reste du pipe faudra le repasser dans le parser)"]
|
||||||
|
*/
|
||||||
|
|
||||||
|
name: String,
|
||||||
|
contents: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Structure {
|
||||||
|
fn new_commande(cont: Vec<String>) -> Self {
|
||||||
|
Self {
|
||||||
|
name: String::from("commande"),
|
||||||
|
contents: cont,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn new_control(cont: Vec<String>) -> Self {
|
||||||
|
Self {
|
||||||
|
name: String::from("control"),
|
||||||
|
contents: cont,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Entree {
|
||||||
|
/*
|
||||||
|
* Correspond à une entrée. C'est ce que renvois le parser.
|
||||||
|
*/
|
||||||
|
size: i32,
|
||||||
|
inputs: Vec<Structure>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Entree {
|
||||||
|
fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
size: 0,
|
||||||
|
inputs: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fn parse_after_whitespace(char_splitted_command_line: &mut Vec<char>, argv: &mut Vec<String>) -> Vec<String> {
|
fn parse_after_whitespace(char_splitted_command_line: &mut Vec<char>, argv: &mut Vec<String>) -> Vec<String> {
|
||||||
let current_char_option = char_splitted_command_line.pop();
|
let current_char_option = char_splitted_command_line.pop();
|
||||||
|
|
||||||
|
|
Reference in a new issue