@@ -204,7 +204,7 @@ namespace FPL {
204204 auto checkerInstruction = CheckerIdentifiant ();
205205 if (!checkerInstruction.has_value () && CheckerOperateur (" }" ).has_value ()) {
206206 break ;
207- } else if (!checkerInstruction. has_value () || checkerInstruction->mText != " quand" ) {
207+ } else if (checkerInstruction->mText != " quand" ) {
208208 std::cerr << " Vous devez verifier une valeur avec 'quand' !" << std::endl;
209209 exit (1 );
210210 }
@@ -230,7 +230,6 @@ namespace FPL {
230230 }
231231
232232 std::string finalContent;
233-
234233 for (auto const &a : contentChecking) {
235234 finalContent.append (a).append (" " );
236235 }
@@ -243,17 +242,63 @@ namespace FPL {
243242 auto oldCurrentToken = mCurrentToken ;
244243 std::optional<FonctionDefinition> f = fonction;
245244
245+ bool didNotExecuteTheCodeWithif = false ;
246+
246247 if (fonction.has_value () && isArgument (fonction->FonctionName , PossibleVar->mText )) {
247248 auto argument = mArguments [fonction->FonctionName ][PossibleVar->mText ];
248249 if (argument.ArgValue == wantCheckValue->StatementName ) {
249250 parse (tokens, f);
250251 mCurrentToken = oldCurrentToken;
252+ didNotExecuteTheCodeWithif = true ;
251253 }
252254 } else if (isVariable (PossibleVar->mText )) {
253255 auto variable = mVariables [PossibleVar->mText ];
254256 if (variable.VariableValue == wantCheckValue->StatementName ) {
255257 parse (tokens, f);
256258 mCurrentToken = oldCurrentToken;
259+ didNotExecuteTheCodeWithif = true ;
260+ }
261+ }
262+
263+
264+ auto elseInstruction = CheckerIdentifiant ();
265+ if (elseInstruction.has_value () && elseInstruction->mText == " defaut" ) {
266+ if (CheckerOperateur (" :" ).has_value ()) {
267+ if (!didNotExecuteTheCodeWithif) {
268+ std::vector<std::string> newContent;
269+ while (!CheckerOperateur (" ," ).has_value ()) {
270+ if (mCurrentToken ->mType == CHAINE_LITERAL) {
271+ mCurrentToken ->mText += " \" " ;
272+ }
273+
274+ newContent.push_back (mCurrentToken ->mText );
275+ ++mCurrentToken ;
276+ }
277+
278+ std::string finalContent2;
279+ for (auto const &a : newContent) {
280+ finalContent2.append (a).append (" " );
281+ }
282+
283+ TokenBuilding t2;
284+ std::cout << " " << std::endl; // IGNORE (finalContent) -> sans le print, cela ne marche plus.
285+ std::vector<Token> tokens2 = t2.parseToken (finalContent2);
286+
287+ auto FCurrToken2 = tokens2.begin ();
288+ auto oldCurrentToken2 = mCurrentToken ;
289+
290+ parse (tokens2, f);
291+ mCurrentToken = oldCurrentToken2;
292+
293+ if (!CheckerOperateur (" }" ).has_value ()) {
294+ std::cerr << " Vous devez l'instruction 'defaut' en dernier et terminer par la fermeture de l'instruction 'verifier' !" << std::endl;
295+ exit (1 );
296+ }
297+ return true ;
298+ }
299+ } else {
300+ std::cerr << " Vous devez mettre le symbole ':' pour mettre votre code." << std::endl;
301+ exit (1 );
257302 }
258303 }
259304
0 commit comments