@@ -208,50 +208,65 @@ namespace FPL {
208208 auto PossibleVar = CheckerIdentifiant ();
209209 if (PossibleVar.has_value ()) {
210210 if (CheckerOperateur (" {" ).has_value ()) {
211+ bool needToIgnore = false ;
211212 while (!CheckerOperateur (" }" ).has_value ()) {
212- std::vector<std::string> contentChecking;
213- std::vector<std::string> contentValues;
214- bool morethanoneValue = false ;
213+ if (!needToIgnore) {
214+ std::vector<std::string> contentChecking;
215+ std::vector<std::string> contentValues;
216+ bool morethanoneValue = false ;
215217
216- auto checkerInstruction = CheckerIdentifiant ();
217- if (!checkerInstruction.has_value () && CheckerOperateur (" }" ).has_value ()) {
218- break ;
219- } else if (checkerInstruction->mText != " quand" ) {
220- std::cerr << " Vous devez verifier une valeur avec 'quand' !" << std::endl;
221- exit (1 );
222- }
218+ auto checkerInstruction = CheckerIdentifiant ();
219+ if (!checkerInstruction.has_value () && CheckerOperateur (" }" ).has_value ()) {
220+ break ;
221+ } else if (checkerInstruction->mText != " quand" ) {
222+ std::cerr << " Vous devez verifier une valeur avec 'quand' !" << std::endl;
223+ exit (1 );
224+ }
223225
224- auto wantCheckValue = CheckerValue ();
225- if (!wantCheckValue.has_value ()) {
226- std::cerr << " Vous devez mettre une valeur que vous souhaitez verifier !" << std::endl;
227- exit (1 );
228- }
226+ auto wantCheckValue = CheckerValue ();
227+ if (!wantCheckValue.has_value ()) {
228+ std::cerr << " Vous devez mettre une valeur que vous souhaitez verifier !" << std::endl;
229+ exit (1 );
230+ }
229231
230- if (CheckerOperateur (" ," ).has_value ()) {
231- auto wantCheckValue2 = CheckerValue ();
232- if (wantCheckValue2.has_value ()) {
233- morethanoneValue = true ;
234- contentValues.push_back (wantCheckValue2->StatementName );
235- contentValues.push_back (wantCheckValue->StatementName );
236-
237- while (!CheckerOperateur (" :" ).has_value ()) {
238- auto nextValue = CheckerValue ();
239- if (!nextValue.has_value ()) {
240- std::cerr << " Vous devez mettre une valeur que vous souhaitez verifier !" << std::endl;
241- exit (1 );
242- }
232+ if (CheckerOperateur (" ," ).has_value ()) {
233+ auto wantCheckValue2 = CheckerValue ();
234+ if (wantCheckValue2.has_value ()) {
235+ morethanoneValue = true ;
236+ contentValues.push_back (wantCheckValue2->StatementName );
237+ contentValues.push_back (wantCheckValue->StatementName );
238+
239+ while (!CheckerOperateur (" :" ).has_value ()) {
240+ auto nextValue = CheckerValue ();
241+ if (!nextValue.has_value ()) {
242+ std::cerr << " Vous devez mettre une valeur que vous souhaitez verifier !" << std::endl;
243+ exit (1 );
244+ }
243245
244- contentValues.push_back (nextValue->StatementName );
246+ contentValues.push_back (nextValue->StatementName );
245247
246- if (!CheckerOperateur (" ," ).has_value ()) {
247- break ;
248+ if (!CheckerOperateur (" ," ).has_value ()) {
249+ break ;
250+ }
248251 }
249252 }
250253 }
251- }
252254
253- if (!morethanoneValue) {
254- if (CheckerOperateur (" :" ).has_value ()) {
255+ if (!morethanoneValue) {
256+ if (CheckerOperateur (" :" ).has_value ()) {
257+ while (!CheckerOperateur (" ," ).has_value ()) {
258+ if (mCurrentToken ->mType == CHAINE_LITERAL) {
259+ mCurrentToken ->mText += " \" " ;
260+ }
261+
262+ contentChecking.push_back (mCurrentToken ->mText );
263+ ++mCurrentToken ;
264+ }
265+ } else {
266+ std::cerr << " Vous devez mettre le symbole ':' pour mettre votre code." << std::endl;
267+ exit (1 );
268+ }
269+ } else {
255270 while (!CheckerOperateur (" ," ).has_value ()) {
256271 if (mCurrentToken ->mType == CHAINE_LITERAL) {
257272 mCurrentToken ->mText += " \" " ;
@@ -260,109 +275,101 @@ namespace FPL {
260275 contentChecking.push_back (mCurrentToken ->mText );
261276 ++mCurrentToken ;
262277 }
263- } else {
264- std::cerr << " Vous devez mettre le symbole ':' pour mettre votre code." << std::endl;
265- exit (1 );
266278 }
267- } else {
268- while (!CheckerOperateur (" ," ).has_value ()) {
269- if (mCurrentToken ->mType == CHAINE_LITERAL) {
270- mCurrentToken ->mText += " \" " ;
271- }
272279
273- contentChecking.push_back (mCurrentToken ->mText );
274- ++mCurrentToken ;
280+ std::string finalContent;
281+ for (auto const &a : contentChecking) {
282+ finalContent.append (a).append (" " );
275283 }
276- }
277284
278- std::string finalContent;
279- for (auto const &a : contentChecking) {
280- finalContent.append (a).append (" " );
281- }
282-
283- TokenBuilding t;
284- std::cout << " " << std::endl; // IGNORE (finalContent) -> sans le print, cela ne marche plus.
285- std::vector<Token> tokens = t.parseToken (finalContent);
285+ TokenBuilding t;
286+ std::cout << " " << std::endl; // IGNORE (finalContent) -> sans le print, cela ne marche plus.
287+ std::vector<Token> tokens = t.parseToken (finalContent);
286288
287- auto FCurrToken = tokens.begin ();
288- auto oldCurrentToken = mCurrentToken ;
289- std::optional<FonctionDefinition> f = fonction;
289+ auto FCurrToken = tokens.begin ();
290+ auto oldCurrentToken = mCurrentToken ;
291+ std::optional<FonctionDefinition> f = fonction;
290292
291- bool didNotExecuteTheCodeWithif = false ;
293+ bool didNotExecuteTheCodeWithif = false ;
292294
293- if (fonction.has_value () && isArgument (fonction->FonctionName , PossibleVar->mText )) {
294- auto argument = mArguments [fonction->FonctionName ][PossibleVar->mText ];
295- if (!morethanoneValue) {
296- if (argument.ArgValue == wantCheckValue->StatementName ) {
297- parse (tokens, f);
298- mCurrentToken = oldCurrentToken;
299- didNotExecuteTheCodeWithif = true ;
300- }
301- } else {
302- if (ValueInSTRvector (contentValues, argument.ArgValue )) {
303- parse (tokens, f);
304- mCurrentToken = oldCurrentToken;
305- didNotExecuteTheCodeWithif = true ;
306- }
307- }
308- } else if (isVariable (PossibleVar->mText )) {
309- auto variable = mVariables [PossibleVar->mText ];
310- if (!morethanoneValue) {
311- if (variable.VariableValue == wantCheckValue->StatementName ) {
312- parse (tokens, f);
313- mCurrentToken = oldCurrentToken;
314- didNotExecuteTheCodeWithif = true ;
295+ if (fonction.has_value () && isArgument (fonction->FonctionName , PossibleVar->mText )) {
296+ auto argument = mArguments [fonction->FonctionName ][PossibleVar->mText ];
297+ if (!morethanoneValue) {
298+ if (argument.ArgValue == wantCheckValue->StatementName ) {
299+ parse (tokens, f);
300+ mCurrentToken = oldCurrentToken;
301+ didNotExecuteTheCodeWithif = true ;
302+ needToIgnore = true ;
303+ }
304+ } else {
305+ if (ValueInSTRvector (contentValues, argument.ArgValue )) {
306+ parse (tokens, f);
307+ mCurrentToken = oldCurrentToken;
308+ didNotExecuteTheCodeWithif = true ;
309+ needToIgnore = true ;
310+ }
315311 }
316- } else {
317- if (ValueInSTRvector (contentValues, variable.VariableValue )) {
318- parse (tokens, f);
319- mCurrentToken = oldCurrentToken;
320- didNotExecuteTheCodeWithif = true ;
312+ } else if (isVariable (PossibleVar->mText )) {
313+ auto variable = mVariables [PossibleVar->mText ];
314+ if (!morethanoneValue) {
315+ if (variable.VariableValue == wantCheckValue->StatementName ) {
316+ parse (tokens, f);
317+ mCurrentToken = oldCurrentToken;
318+ didNotExecuteTheCodeWithif = true ;
319+ needToIgnore = true ;
320+ }
321+ } else {
322+ if (ValueInSTRvector (contentValues, variable.VariableValue )) {
323+ parse (tokens, f);
324+ mCurrentToken = oldCurrentToken;
325+ didNotExecuteTheCodeWithif = true ;
326+ needToIgnore = true ;
327+ }
321328 }
322329 }
323- }
324330
325- auto elseInstruction = CheckerIdentifiant ();
326- if (elseInstruction.has_value () && elseInstruction->mText == " defaut" ) {
327- if (CheckerOperateur (" :" ).has_value ()) {
328- if (!didNotExecuteTheCodeWithif) {
329- std::vector<std::string> newContent;
330- while (!CheckerOperateur (" ," ).has_value ()) {
331- if (mCurrentToken ->mType == CHAINE_LITERAL) {
332- mCurrentToken ->mText += " \" " ;
333- }
331+ auto elseInstruction = CheckerIdentifiant ();
332+ if (elseInstruction.has_value () && elseInstruction->mText == " defaut" ) {
333+ if (CheckerOperateur (" :" ).has_value ()) {
334+ if (!didNotExecuteTheCodeWithif) {
335+ std::vector<std::string> newContent;
336+ while (!CheckerOperateur (" ," ).has_value ()) {
337+ if (mCurrentToken ->mType == CHAINE_LITERAL) {
338+ mCurrentToken ->mText += " \" " ;
339+ }
334340
335- newContent.push_back (mCurrentToken ->mText );
336- ++mCurrentToken ;
337- }
341+ newContent.push_back (mCurrentToken ->mText );
342+ ++mCurrentToken ;
343+ }
338344
339- std::string finalContent2;
340- for (auto const &a : newContent) {
341- finalContent2.append (a).append (" " );
342- }
345+ std::string finalContent2;
346+ for (auto const &a : newContent) {
347+ finalContent2.append (a).append (" " );
348+ }
343349
344- TokenBuilding t2;
345- std::cout << " " << std::endl; // IGNORE (finalContent) -> sans le print, cela ne marche plus.
346- std::vector<Token> tokens2 = t2.parseToken (finalContent2);
350+ TokenBuilding t2;
351+ std::cout << " " << std::endl; // IGNORE (finalContent) -> sans le print, cela ne marche plus.
352+ std::vector<Token> tokens2 = t2.parseToken (finalContent2);
347353
348- auto FCurrToken2 = tokens2.begin ();
349- auto oldCurrentToken2 = mCurrentToken ;
354+ auto FCurrToken2 = tokens2.begin ();
355+ auto oldCurrentToken2 = mCurrentToken ;
350356
351- parse (tokens2, f);
352- mCurrentToken = oldCurrentToken2;
357+ parse (tokens2, f);
358+ mCurrentToken = oldCurrentToken2;
353359
354- if (!CheckerOperateur (" }" ).has_value ()) {
355- std::cerr << " Vous devez l'instruction 'defaut' en dernier et terminer par la fermeture de l'instruction 'verifier' !" << std::endl;
356- exit (1 );
360+ if (!CheckerOperateur (" }" ).has_value ()) {
361+ std::cerr << " Vous devez l'instruction 'defaut' en dernier et terminer par la fermeture de l'instruction 'verifier' !" << std::endl;
362+ exit (1 );
363+ }
364+ needToIgnore = true ;
365+ return true ;
357366 }
358- return true ;
367+ } else {
368+ std::cerr << " Vous devez mettre le symbole ':' pour mettre votre code." << std::endl;
369+ exit (1 );
359370 }
360- } else {
361- std::cerr << " Vous devez mettre le symbole ':' pour mettre votre code." << std::endl;
362- exit (1 );
363371 }
364372 }
365-
366373 if (CheckerOperateur (" }" ).has_value ()) {
367374 break ;
368375 }
0 commit comments