Skip to content

Commit 6d48a6b

Browse files
committed
Updated parser to create a function, in a func, in another func.....
1 parent 2060867 commit 6d48a6b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/Essentials/Parser.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,30 @@ namespace FPL::Parser {
207207

208208
if (ExpectOperator(data, "{").has_value()) {
209209
// On récupère le contenu de la fonction
210-
while (!ExpectOperator(data, "}").has_value()) {
210+
211+
int totalInstructionInDefinition = 0;
212+
213+
while (true) {
211214
auto currentToken = data.current_token;
215+
if (currentToken->TokenText == "definir") {
216+
totalInstructionInDefinition += 1;
217+
}
218+
212219
if (currentToken->TokenType == FPL::Tokenizer::CHAINE_LITTERAL) {
213220
currentToken->TokenText = "\"" + currentToken->TokenText += "\"";
214221
}
215222
fonction.FonctionContentCode.push_back(currentToken->TokenText);
216223
data.incrementeTokens(data);
217224

218-
if (ExpectOperator(data, "}").has_value()) { break; }
225+
if (ExpectOperator(data, "}").has_value()) {
226+
if (totalInstructionInDefinition > 0) {
227+
fonction.FonctionContentCode.emplace_back("}");
228+
totalInstructionInDefinition -= 1;
229+
} else {
230+
break;
231+
}
232+
}
233+
219234
}
220235

221236
data.Map_Fonctions[fonction.FonctionName] = fonction;

0 commit comments

Comments
 (0)