@@ -94,7 +94,7 @@ namespace FPL {
94
94
auto VarValue = CheckerValue ();
95
95
if (VarValue.has_value ()) {
96
96
if (VarValue->StatementType .mType == VarType->mType ) {
97
- if (CheckerOperateur (" | " )) {
97
+ if (CheckerOperateur (" ; " )) {
98
98
VariableDefinition variable;
99
99
variable.VariableName = VarName->mText ;
100
100
variable.VariableType = Type (VarType->mName , VarType->mType );
@@ -108,6 +108,24 @@ namespace FPL {
108
108
} else {
109
109
std::cerr << " Vous devez donner une valeur qui est de même type que la variable." << std::endl;
110
110
}
111
+ } else if (CheckerIdentifiant ().has_value ()) {
112
+ --mCurrentToken ;
113
+ auto PossibleVariable = CheckerIdentifiant ();
114
+ if (PossibleVariable.has_value ()) {
115
+ if (isVariable (PossibleVariable->mText )) {
116
+ if (CheckerOperateur (" ;" ).has_value ()) {
117
+ VariableDefinition variable;
118
+ variable.VariableName = VarName->mText ;
119
+ variable.VariableType = Type (VarType->mName , VarType->mType );
120
+ variable.VariableValue = mVariables [PossibleVariable->mText ].VariableValue ;
121
+
122
+ mVariables [variable.VariableName ] = variable;
123
+ return true ;
124
+ } else {
125
+ std::cerr << " Merci de signifier la fin de la déclaration de la variable avec '|'." << std::endl;
126
+ }
127
+ }
128
+ }
111
129
} else {
112
130
std::cerr << " Vous devez donner une valeur a la variable qui correspond au type." << std::endl;
113
131
}
@@ -134,8 +152,12 @@ namespace FPL {
134
152
auto Value = CheckerValue ();
135
153
if (Value.has_value ()) {
136
154
if (Value->StatementType .mType == VarType.mType ) {
137
- mVariables [VarName->mText ].VariableValue = Value->StatementName ;
138
- return true ;
155
+ if (CheckerOperateur (" ;" ).has_value ()) {
156
+ mVariables [VarName->mText ].VariableValue = Value->StatementName ;
157
+ return true ;
158
+ } else {
159
+ std::cerr << " Vous devez mettre le symbole ';' pour mettre fin à l'instruction." << std::endl;
160
+ }
139
161
} else {
140
162
std::cerr << " Veuillez donner une valeur en rapport avec le type de la variable." << std::endl;
141
163
}
@@ -160,26 +182,29 @@ namespace FPL {
160
182
bool Parser::PrintInstruction (auto parseStart) {
161
183
auto Value = CheckerValue ();
162
184
if (Value.has_value ()) {
163
- if (Value->StatementType .mType == STRING) {
164
- std::replace (Value->StatementName .begin (), Value->StatementName .end (), ' "' , ' ' );
185
+ if (CheckerOperateur (" ;" ).has_value ()) {
186
+ if (Value->StatementType .mType == STRING) {
187
+ std::replace (Value->StatementName .begin (), Value->StatementName .end (), ' "' , ' ' );
188
+ }
189
+ std::cout << Value->StatementName << std::endl;
190
+ return true ;
191
+ } else {
192
+ std::cerr << " Vous devez mettre le symbole ';' pour mettre fin à l'instruction." << std::endl;
165
193
}
166
- std::cout << Value->StatementName << std::endl;
167
- return true ;
168
194
} else {
169
195
mCurrentToken = parseStart;
170
196
++mCurrentToken ;
171
197
auto value = CheckerIdentifiant ();
172
198
if (value.has_value ()) {
173
- if (CheckerOperateur (" <" ).has_value ()) {
174
- if (CheckerOperateur (" -" ).has_value ()) {
175
- if (isVariable (value->mText )) {
176
- std::cout << mVariables [value->mText ].VariableValue << std::endl;
177
- return true ;
178
- } else {
179
- mCurrentToken = parseStart;
180
- std::cerr << " La variable n'existe pas." << std::endl;
181
- }
199
+ if (isVariable (value->mText )) {
200
+ if (CheckerOperateur (" ;" ).has_value ()) {
201
+ std::cout << mVariables [value->mText ].VariableValue << std::endl;
202
+ return true ;
203
+ } else {
204
+ std::cerr << " Vous devez mettre le symbole ';' pour mettre fin à l'instruction." << std::endl;
182
205
}
206
+ } else {
207
+ std::cerr << " La variable n'existe pas." << std::endl;
183
208
}
184
209
}
185
210
std::cerr << " Vous devez ouvrir les guillemets pour transmettre une chaine de caractères ou le nom de votre variable sous ce format : 'envoyer (variable) <-" << std::endl;
@@ -287,6 +312,12 @@ namespace FPL {
287
312
return res;
288
313
}
289
314
315
+ bool Parser::isVariable (std::string &name) {
316
+ if (mVariables .contains (name)) {
317
+ return true ;
318
+ }
319
+ return false ;
320
+ }
290
321
291
322
void Parser::DebugPrint () const {
292
323
for (auto &funcPair: mFonctions ) {
@@ -295,11 +326,4 @@ namespace FPL {
295
326
}
296
327
}
297
328
}
298
-
299
- bool Parser::isVariable (std::string &name) {
300
- if (mVariables .contains (name)) {
301
- return true ;
302
- }
303
- return false ;
304
- }
305
329
}
0 commit comments