function imprimer()
 {
     Analyse::echo_debug("[SI {$this->nom}]");
     if ($this->contenu[0]) {
         $this->contenu[0]->imprimer();
     }
     Analyse::echo_debug("[SINON {$this->nom}]");
     if ($this->contenu[1]) {
         $this->contenu[1]->imprimer();
     }
     Analyse::echo_debug("[FINSI {$this->nom}]");
 }
 function evaluer(&$substitutions = array())
 {
     if (DEBUG_EVAL) {
         Analyse::echo_debug("Eval contenu {$this->idx}");
     }
     $val = '';
     foreach ($this->elements as $element) {
         if (DEBUG_EVAL) {
             Analyse::echo_debug("CONT:eval " . $element->type());
             $element->imprimer();
         }
         $val .= $element->evaluer($substitutions);
     }
     return $val;
 }
 function imprimer()
 {
     Analyse::echo_debug("[DEBUT {$this->nom}, args: ", $this->args, "]");
     $this->contenu->imprimer();
     Analyse::echo_debug("[FIN {$this->nom}]");
 }
 function imprimer()
 {
     Analyse::echo_debug("[TEST_VRAI {$this->nom} {$args}]");
     if ($this->contenu[0]) {
         $this->contenu[0]->imprimer();
     }
     Analyse::echo_debug("[TEST_FAUX {$this->nom}]");
     if ($this->contenu[1]) {
         $this->contenu[1]->imprimer();
     }
     Analyse::echo_debug("[TEST_FIN {$this->nom}]");
 }
 function process_token(&$atoken)
 {
     //if (DEBUG_PARSER) { Analyse::echo_debug("enter process_token ", $atoken);}
     $token_type = PexToken::TXT;
     if ($atoken == '<') {
         $no_match = false;
         $token = next($this->tokens);
         if (DEBUG_PARSER) {
             Analyse::echo_debug("Next PexToken:[{$token}]");
         }
         // Optimisation (gain: ~= 0,1 sec. sur index standard)
         if ($token[0] != 'T' && strpos($token, '/T') !== 0 && strpos($token, '//T') !== 0 && $token[0] != 'R' && strpos($token, '/R') !== 0) {
             //if (DEBUG_PARSER) { Analyse::echo_debug("N'est pas une boucle thelia");}
             $no_match = true;
         } else {
             // Get token type
             if (strpos($token, 'THELIA_') === 0) {
                 $token_type = PexToken::OBS;
             } else {
                 if (strpos($token, '/THELIA_') === 0) {
                     $token_type = PexToken::FBS;
                 } else {
                     if (strpos($token, 'TEST_') === 0) {
                         $token_type = PexToken::OBT;
                     } else {
                         if (strpos($token, '/TEST_') === 0) {
                             $token_type = PexToken::EBT;
                         } else {
                             if (strpos($token, '//TEST_') === 0) {
                                 $token_type = PexToken::FBT;
                             } else {
                                 if (strpos($token, 'T_') === 0) {
                                     $token_type = PexToken::OBC;
                                 } else {
                                     if (strpos($token, '/T_') === 0) {
                                         $token_type = PexToken::EBC;
                                     } else {
                                         if (strpos($token, '//T_') === 0) {
                                             $token_type = PexToken::FBC;
                                         } else {
                                             if (strpos($token, 'REM') === 0) {
                                                 $token_type = PexToken::OCM;
                                             } else {
                                                 if (strpos($token, '/REM') === 0) {
                                                     $token_type = PexToken::FCM;
                                                 } else {
                                                     if (strpos($token, 'REPETER') === 0) {
                                                         $token_type = PexToken::OBR;
                                                     } else {
                                                         if (strpos($token, '/REPETER') === 0) {
                                                             $token_type = PexToken::FBR;
                                                         } else {
                                                             if (strpos($token, 'T:') === 0) {
                                                                 $token_type = PexToken::OBCV;
                                                             } else {
                                                                 if (strpos($token, '/T:') === 0) {
                                                                     $token_type = PexToken::EBCV;
                                                                 } else {
                                                                     if (strpos($token, '//T:') === 0) {
                                                                         $token_type = PexToken::FBCV;
                                                                     } else {
                                                                         //if (DEBUG_PARSER) { Analyse::echo_debug("Token type texte");}
                                                                         $no_match = true;
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if ($no_match) {
             prev($this->tokens);
             $token = $atoken;
         }
     } else {
         if ($atoken == '#') {
             // Traiter les cas similaires à ##REF
             $tmp = next($this->tokens);
             if ($tmp == '#') {
                 $token = '#';
                 prev($this->tokens);
             } else {
                 $token = '#' . $tmp;
                 $this->add_var($token);
             }
         } else {
             $token = $atoken;
         }
     }
     //if (DEBUG_PARSER) { Analyse::echo_debug( "Token:[$token], type $token_type"); }
     // Dans un commentaire, on attend la fin sans rien analyser
     if ($this->in_comment && $token_type !== PexToken::FCM) {
         //if (DEBUG_PARSER) { Analyse::echo_debug("ignore: $token_type:", $token); }
         return 'vide';
     }
     // BOUCLE SIMPLE et boucle REPETER
     if ($token_type === PexToken::OBS || $token_type === PexToken::OBR) {
         if ($token_type === PexToken::OBS) {
             $boucle = new BoucleSimple(substr($token, 7));
         } else {
             $boucle = new BoucleRepeter(substr($token, 8));
         }
         array_push($this->pile_nom_boucles, $token);
         // Parse args se fait avant le push, car les variables dans les args doivent être valuées
         // par la boucle enclosante.
         $boucle->set_args($this->parse_args());
         array_push($this->pile_boucle_courante, $boucle);
         //if (DEBUG_PARSER) { Analyse::echo_debug("Push boucle courante $boucle->nom\n", $this->pile_boucle_courante); }
         $boucle->ajouter($this->parse_content());
         // Skip remaining > TODO check >
         $this->skipto('>');
         return $boucle;
     } else {
         if ($token_type === PexToken::FBS || $token_type === PexToken::FBR) {
             $this->controle_fermeture_boucle($token);
             array_pop($this->pile_boucle_courante);
             //if (DEBUG_PARSER) { Analyse::echo_debug("Pop boucle courante $token\n", $this->pile_boucle_courante); }
             return 'stop';
         } else {
             if ($token_type === PexToken::OBC) {
                 $boucle = new BoucleConditionnelle(substr($token, 2));
                 $this->skipto('>');
                 array_push($this->pile_nom_boucles, $token);
                 //if (DEBUG_PARSER) { Analyse::echo_debug("Push boucle conditionnelle $token\n", $this->pile_boucle_courante); }
                 // Si
                 $boucle->ajouter($this->parse_content());
                 $this->skipto('>');
                 array_push($this->pile_nom_boucles, '/' . $token);
                 //if (	const ) { Analyse::echo_debug("Push SI boucle conditionnelle $token\n", $this->pile_boucle_courante); }
                 // Sinon
                 $boucle->ajouter($this->parse_content());
                 $this->skipto('>');
                 return $boucle;
             } else {
                 if ($token_type === PexToken::EBC) {
                     //if (DEBUG_PARSER) { Analyse::echo_debug("Controle fermeture SI: $token\n", $this->pile_boucle_courante); }
                     $this->controle_fermeture_boucle($token);
                     return 'stop';
                 } else {
                     if ($token_type === PexToken::FBC) {
                         //if (DEBUG_PARSER) { Analyse::echo_debug("Controle fermeture ELSE: $token\n", $this->pile_boucle_courante);}
                         $this->controle_fermeture_boucle($token);
                         return 'stop';
                     } else {
                         if ($token_type === PexToken::OBCV) {
                             $var = substr($token, 2);
                             // Ajouter la variable à la boucle enclosante
                             $this->add_var($var);
                             $boucle = new BoucleConditionnelleVariable($var);
                             $this->skipto('>');
                             array_push($this->pile_nom_boucles, $token);
                             //if (DEBUG_PARSER) { Analyse::echo_debug("Push boucle conditionnelle $token\n", $this->pile_boucle_courante); }
                             // Si
                             $boucle->ajouter($this->parse_content());
                             $this->skipto('>');
                             array_push($this->pile_nom_boucles, '/' . $token);
                             //if (	const ) { Analyse::echo_debug("Push SI boucle conditionnelle $token\n", $this->pile_boucle_courante); }
                             // Sinon
                             $boucle->ajouter($this->parse_content());
                             $this->skipto('>');
                             return $boucle;
                         } else {
                             if ($token_type === PexToken::EBCV) {
                                 //if (DEBUG_PARSER) { Analyse::echo_debug("Controle fermeture SI: $token\n", $this->pile_boucle_courante); }
                                 $this->controle_fermeture_boucle($token);
                                 return 'stop';
                             } else {
                                 if ($token_type === PexToken::FBCV) {
                                     //if (DEBUG_PARSER) { Analyse::echo_debug("Controle fermeture ELSE: $token\n", $this->pile_boucle_courante);}
                                     $this->controle_fermeture_boucle($token);
                                     return 'stop';
                                 } else {
                                     if ($token_type === PexToken::OBT) {
                                         $boucle = new BoucleTest(substr($token, 5));
                                         // Parse args se fait avant le push, car les variables dans les args doivent être valuées
                                         // par la boucle enclosante.
                                         $boucle->set_args($this->parse_args());
                                         array_push($this->pile_nom_boucles, $token);
                                         //if (DEBUG_PARSER) { Analyse::echo_debug("Push boucle Test $boucle->nom\n", $this->pile_boucle_courante);}
                                         // Si
                                         $boucle->ajouter($this->parse_content());
                                         $this->skipto('>');
                                         array_push($this->pile_nom_boucles, '/' . $token);
                                         // Sinon
                                         $boucle->ajouter($this->parse_content());
                                         $this->skipto('>');
                                         return $boucle;
                                     } else {
                                         if ($token_type === PexToken::EBT) {
                                             //if (DEBUG_PARSER) { Analyse::echo_debug("Controle fermeture TEST SI: $token\n", $this->pile_boucle_courante);}
                                             $this->controle_fermeture_boucle($token);
                                             return 'stop';
                                         } else {
                                             if ($token_type === PexToken::FBT) {
                                                 //if (DEBUG_PARSER) { Analyse::echo_debug("Controle fermeture TEST ELSE: $token\n", $this->pile_boucle_courante); }
                                                 $this->controle_fermeture_boucle($token);
                                                 return 'stop';
                                             } else {
                                                 if ($token_type === PexToken::OCM) {
                                                     //if (DEBUG_PARSER) { Analyse::echo_debug("Ouverture commentaire: $token\n", $this->pile_boucle_courante); }
                                                     $this->in_comment = true;
                                                     return 'vide';
                                                 } else {
                                                     if ($token_type === PexToken::FCM) {
                                                         //if (DEBUG_PARSER) { Analyse::echo_debug("Controle fermeture TEST ELSE: $token\n", $this->pile_boucle_courante); }
                                                         $this->in_comment = false;
                                                         $this->skipto('>');
                                                         return 'vide';
                                                     } else {
                                                         if ($token !== '') {
                                                             return new PexTexte($token);
                                                         } else {
                                                             return 'vide';
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 function imprimer()
 {
     Analyse::echo_debug($this->texte);
 }