Skip to content

Commit f067164

Browse files
committed
Fixs appelation des fonctions.
1 parent aba39b2 commit f067164

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

src/Parser.cpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,24 @@ namespace FPL {
1414
if (PossibleFonctionName.has_value()) {
1515
if (CheckerOperateur(";").has_value()) {
1616
if (isFonction(PossibleFonctionName->mText)) {
17-
FonctionDefinition fonction = mFonctions[PossibleFonctionName->mText];
18-
std::string finalContent;
19-
for (auto a : fonction.FonctionContent) {
20-
finalContent += a += " ";
17+
FonctionDefinition const fonction = mFonctions[PossibleFonctionName->mText];
18+
if (!fonction.FonctionContent.empty()) {
19+
std::string finalContent;
20+
for (auto const &a : fonction.FonctionContent) {
21+
finalContent.append(a).append(" ");
22+
}
23+
TokenBuilding t;
24+
std::cout << "" << std::endl; // IGNORE (finalContent) -> sans le print, cela ne marche plus.
25+
std::vector<Token> tokens = t.parseToken(finalContent);
26+
27+
auto FCurrToken = tokens.begin();
28+
auto oldCurrentToken = mCurrentToken;
29+
parse(tokens);
30+
mCurrentToken = oldCurrentToken;
31+
32+
return true;
2133
}
22-
std::cout << "IGNORE (" << finalContent << ")" << std::endl;
23-
TokenBuilding t;
24-
std::vector<Token> tokens = t.parseToken(finalContent);
25-
auto FCurrToken = tokens.begin();
26-
auto oldCurrentToken = mCurrentToken;
27-
mCurrentToken = FCurrToken;
28-
parse(tokens);
29-
mCurrentToken = oldCurrentToken;
30-
return true;
34+
return false;
3135
}
3236
}
3337
}
@@ -328,7 +332,7 @@ namespace FPL {
328332
if (Value.has_value()) {
329333
--mCurrentToken;
330334
while (!CheckerOperateur(";").has_value()) {
331-
auto Value = CheckerValue();
335+
Value = CheckerValue();
332336
if (Value.has_value()) {
333337
if (Value->StatementType.mType == STRING) {
334338
std::replace(Value->StatementName.begin(), Value->StatementName.end(), '"', ' ');
@@ -415,8 +419,7 @@ namespace FPL {
415419
if (ManagerInstruction()) {
416420

417421
} else {
418-
if (mCurrentToken->mText.empty()) {
419-
++mCurrentToken;
422+
if (mCurrentToken->mText.empty() || mCurrentToken->mType == ESPACEVIDE ) {
420423
continue;
421424
}
422425

@@ -486,12 +489,12 @@ namespace FPL {
486489
return res;
487490
}
488491

489-
bool Parser::isVariable(std::string &name) {
492+
bool Parser::isVariable(std::string &name) const {
490493
if (mVariables.contains(name)) { return true; }
491494
return false;
492495
}
493496

494-
bool Parser::isFonction(std::string &name) {
497+
bool Parser::isFonction(std::string &name) const {
495498
if (mFonctions.contains(name)) { return true; }
496499
return false;
497500
}

0 commit comments

Comments
 (0)