Skip to content

Commit 35f601c

Browse files
committed
Opti, possibilité de mettre des variables + args pour la valeur 'quand'
1 parent 52b97ef commit 35f601c

File tree

1 file changed

+49
-44
lines changed

1 file changed

+49
-44
lines changed

src/Parser.cpp

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -223,31 +223,54 @@ namespace FPL {
223223
exit(1);
224224
}
225225

226+
227+
std::string finalValue;
226228
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);
229+
std::optional<Token> wantCheckIdf;
230+
231+
if (wantCheckValue.has_value()) {
232+
finalValue = wantCheckValue->StatementName;
233+
} else {
234+
wantCheckIdf = CheckerIdentifiant();
235+
if (wantCheckIdf.has_value()) {
236+
if (fonction.has_value() && isArgument(fonction->FonctionName, wantCheckIdf->mText)) {
237+
finalValue = mArguments[fonction->FonctionName][wantCheckIdf->mText].ArgValue;
238+
} else if (isVariable(wantCheckIdf->mText)) {
239+
finalValue = mVariables[wantCheckIdf->mText].VariableValue;
240+
}
241+
} else {
242+
std::cerr << "Vous devez mettre une valeur que vous souhaitez verifier !" << std::endl;
243+
exit(1);
244+
}
230245
}
246+
contentValues.push_back(finalValue);
247+
231248

232249
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()) {
250+
while (!CheckerOperateur(":").has_value()) {
251+
std::string value;
252+
auto nextValue = CheckerValue();
253+
std::optional<Token> nextValueIdf;
254+
if (nextValue.has_value()) {
255+
value = nextValue->StatementName;
256+
} else {
257+
nextValueIdf = CheckerIdentifiant();
258+
if (nextValueIdf.has_value()) {
259+
if (fonction.has_value() && isArgument(fonction->FonctionName, nextValueIdf->mText)) {
260+
value = mArguments[fonction->FonctionName][nextValueIdf->mText].ArgValue;
261+
} else if (isVariable(nextValueIdf->mText)) {
262+
value = mVariables[nextValueIdf->mText].VariableValue;
263+
}
264+
} else {
242265
std::cerr << "Vous devez mettre une valeur que vous souhaitez verifier !" << std::endl;
243266
exit(1);
244267
}
268+
}
245269

246-
contentValues.push_back(nextValue->StatementName);
270+
contentValues.push_back(value);
247271

248-
if (!CheckerOperateur(",").has_value()) {
249-
break;
250-
}
272+
if (!CheckerOperateur(",").has_value()) {
273+
break;
251274
}
252275
}
253276
}
@@ -294,37 +317,19 @@ namespace FPL {
294317

295318
if (fonction.has_value() && isArgument(fonction->FonctionName, PossibleVar->mText)) {
296319
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-
}
320+
if (ValueInSTRvector(contentValues, argument.ArgValue)) {
321+
parse(tokens, f);
322+
mCurrentToken = oldCurrentToken;
323+
didNotExecuteTheCodeWithif = true;
324+
needToIgnore = true;
311325
}
312326
} else if (isVariable(PossibleVar->mText)) {
313327
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-
}
328+
if (ValueInSTRvector(contentValues, variable.VariableValue)) {
329+
parse(tokens, f);
330+
mCurrentToken = oldCurrentToken;
331+
didNotExecuteTheCodeWithif = true;
332+
needToIgnore = true;
328333
}
329334
}
330335

0 commit comments

Comments
 (0)