22
33namespace FPL ::Parser {
44
5- void Parser::PaquetInstruction (FPL::Data::Data& data, const std::optional<FPL::FonctionDef>& fonction , std::optional<FPL::Paquet::Paquet> paquet) {
5+ void Parser::PaquetInstruction (FPL::Data::Data &data , std::optional<FPL::Paquet::Paquet> paquet) {
66 auto nomPaquet = ExpectIdentifiant (data);
77 if (nomPaquet.has_value ()) {
88 FPL::Paquet::Paquet Paquet;
@@ -125,15 +125,7 @@ namespace FPL::Parser {
125125 if (possibleFunctionName.has_value ()) {
126126 auto fonction = data.getFonction (possibleFunctionName->TokenText );
127127
128- std::stringstream FonctionContentCode_STR;
129- for (auto it = fonction->FonctionContentCode .begin (); it != fonction->FonctionContentCode .end (); it++) {
130- if (it != fonction->FonctionContentCode .begin ()) {
131- FonctionContentCode_STR << " " ;
132- }
133- FonctionContentCode_STR << *it;
134- }
135-
136- std::vector<Tokenizer::Token> FileCode_Tokens = FPL::Tokenizer::TokenBuilder::ParseToken (FonctionContentCode_STR.str ());
128+ std::vector<Tokenizer::Token> FileCode_Tokens = FPL::Tokenizer::TokenBuilder::ParseToken (FPL::Instruction::FunctionUtils::ReturnStringVector (fonction->FonctionContentCode ));
137129
138130 if (fonction->FonctionNumberArgument < 1 ) {
139131 if (!ExpectOperator (data, " ;" ).has_value ()) {
@@ -263,6 +255,7 @@ namespace FPL::Parser {
263255 if (currentToken->TokenType == FPL::Tokenizer::CHAINE_LITTERAL) {
264256 currentToken->TokenText = " \" " + currentToken->TokenText += " \" " ;
265257 }
258+
266259 fonction.FonctionContentCode .push_back (currentToken->TokenText );
267260 data.incrementeTokens (data);
268261
@@ -273,6 +266,9 @@ namespace FPL::Parser {
273266 } else {
274267 break ;
275268 }
269+ } else if (data.current_token == data.end_token ) {
270+ fonction.FonctionContentCode .emplace_back (" }" );
271+ break ;
276272 }
277273 }
278274
@@ -541,7 +537,7 @@ namespace FPL::Parser {
541537 variable.VariableType ,
542538 variable.NeedDelete ,
543539 variable.IsGlobal
544- );
540+ );
545541 } else {
546542 forgotEndInstructionOperator (data);
547543 }
@@ -556,15 +552,7 @@ namespace FPL::Parser {
556552 auto possibleFunction = data.getFonction (possibleId->TokenText );
557553 if (possibleFunction.has_value ()) {
558554
559- std::stringstream FonctionContentCode_STR;
560- for (auto it = possibleFunction->FonctionContentCode .begin (); it != possibleFunction->FonctionContentCode .end (); it++) {
561- if (it != possibleFunction->FonctionContentCode .begin ()) {
562- FonctionContentCode_STR << " " ;
563- }
564- FonctionContentCode_STR << *it;
565- }
566-
567- std::vector<Tokenizer::Token> FileCode_Tokens = FPL::Tokenizer::TokenBuilder::ParseToken (FonctionContentCode_STR.str ());
555+ std::vector<Tokenizer::Token> FileCode_Tokens = FPL::Tokenizer::TokenBuilder::ParseToken (FPL::Instruction::FunctionUtils::ReturnStringVector (possibleFunction->FonctionContentCode ));
568556
569557 if (ExpectOperator (data, " :" ).has_value () && possibleFunction->FonctionNumberArgument > 0 ) {
570558 int totalArgs = possibleFunction->FonctionNumberArgument ;
@@ -776,7 +764,7 @@ namespace FPL::Parser {
776764 ImporterInstruction (data, fonction);
777765 return true ;
778766 }else if (Instruction->TokenText == " paquet" ) {
779- PaquetInstruction (data, fonction, paquet);
767+ PaquetInstruction (data, paquet);
780768 return true ;
781769 }
782770 }
0 commit comments