1 | %include { |
---|
2 | #include <iostream> |
---|
3 | #include <sstream> |
---|
4 | #include "lemonglobal.h" |
---|
5 | #include "conv_f8tof1.h" |
---|
6 | #include "conv_f8_utils.h" |
---|
7 | #define PARSER_DEBUG 0 |
---|
8 | } |
---|
9 | %token_type {Token} |
---|
10 | %default_type {Token} |
---|
11 | %type production_tail {ProductionTailToken} |
---|
12 | %type prod_piece {ProdPieceToken} |
---|
13 | |
---|
14 | %left COMMA. |
---|
15 | %left PLUS MINUS. |
---|
16 | %left DIV TIMES. |
---|
17 | |
---|
18 | program ::= counter start_params delim first_prod productions. { |
---|
19 | *syntaxOk = true; |
---|
20 | } |
---|
21 | |
---|
22 | counter ::= double_val(A) NEWLINE. { |
---|
23 | if (!syntaxOnly) { |
---|
24 | { |
---|
25 | #if PARSER_DEBUG > 0 |
---|
26 | std::cout << "counter ::= double_val NEWLINE." << std::endl; |
---|
27 | #endif |
---|
28 | } |
---|
29 | lsys->iterations = (int) A.dblValue; |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | delim ::= DELIMETER NEWLINE. |
---|
34 | |
---|
35 | start_params ::= start_parameter start_params. |
---|
36 | start_params ::= . |
---|
37 | |
---|
38 | start_parameter ::= param_name(A) ASSIGN double_val(B) NEWLINE. { |
---|
39 | if (!syntaxOnly) { |
---|
40 | { |
---|
41 | #if PARSER_DEBUG > 0 |
---|
42 | std::cout << "start_parameter ::= param_name ASSIGN double_val NEWLINE." << std::endl; |
---|
43 | #endif |
---|
44 | } |
---|
45 | lsys->startParams[sstringToString(*(A.strValue))] = B.dblValue; |
---|
46 | #if PARSER_DEBUG > 0 |
---|
47 | //cout << "**** " << lsys->startParams["n0"] << endl; |
---|
48 | //cout << "**** " << lsys->startParams["n1"] << endl; |
---|
49 | #endif |
---|
50 | delete A.strValue; |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | productions ::= production productions. |
---|
55 | productions ::= . |
---|
56 | |
---|
57 | first_prod ::= prod_name(A) NEWLINE. { |
---|
58 | if (!syntaxOnly) { |
---|
59 | { |
---|
60 | #if PARSER_DEBUG > 0 |
---|
61 | std::cout << "first_prod ::= prod_name NEWLINE." << std::endl; |
---|
62 | #endif |
---|
63 | } |
---|
64 | lsys->firstProductionName = sstringToString(*(A.strValue)); |
---|
65 | delete A.strValue; |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | production ::= production_head(A) SEMICOLON production_tail(B) NEWLINE. { |
---|
70 | if (!syntaxOnly) { |
---|
71 | { |
---|
72 | #if PARSER_DEBUG > 0 |
---|
73 | std::cout << "production ::= production_head SEMICOLON production_tail NEWLINE." << std::endl; |
---|
74 | #endif |
---|
75 | } |
---|
76 | Production *p = lsys->productions[sstringToString(*(A.strValue))]; |
---|
77 | for (vector<SString>::iterator paramIter = A.vectorStr->begin(); paramIter != A.vectorStr->end(); paramIter++) { |
---|
78 | #if PARSER_DEBUG > 0 |
---|
79 | std::cout << "1.1 " << *paramIter << std::endl; |
---|
80 | std::cout << *(A.strValue) << " # " << (p == NULL) << " # " << true << std::endl; |
---|
81 | #endif |
---|
82 | p->parameters.addParameter(*paramIter); |
---|
83 | } |
---|
84 | p->subproductions = *(B.subproductions); |
---|
85 | delete A.strValue; |
---|
86 | delete A.vectorStr; |
---|
87 | delete B.subproductions; |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | production_head(A) ::= prod_name(B) LPAREN prod_params(C) RPAREN. { |
---|
92 | if (!syntaxOnly) { |
---|
93 | { |
---|
94 | #if PARSER_DEBUG > 0 |
---|
95 | std::cout << "production_head ::= prod_name LPAREN prod_params RPAREN." << std::endl; |
---|
96 | #endif |
---|
97 | } |
---|
98 | #if PARSER_DEBUG > 0 |
---|
99 | std::cout << "---------" << *(B.strValue) << std::endl; |
---|
100 | #endif |
---|
101 | A.strValue = new SString(*(B.strValue)); |
---|
102 | A.vectorStr = new vector<SString>(*(C.vectorStr)); |
---|
103 | delete B.strValue; |
---|
104 | delete C.vectorStr; |
---|
105 | } |
---|
106 | } |
---|
107 | production_head(A) ::= prod_name(B) LPAREN RPAREN. { |
---|
108 | if (!syntaxOnly) { |
---|
109 | { |
---|
110 | #if PARSER_DEBUG > 0 |
---|
111 | std::cout << "production_head ::= prod_name LPAREN RPAREN." << std::endl; |
---|
112 | #endif |
---|
113 | } |
---|
114 | #if PARSER_DEBUG > 0 |
---|
115 | std::cout << "---------" << *(B.strValue) << std::endl; |
---|
116 | #endif |
---|
117 | A.strValue = new SString(*(B.strValue)); |
---|
118 | A.vectorStr = new vector<SString>(); |
---|
119 | delete B.strValue; |
---|
120 | } |
---|
121 | } |
---|
122 | |
---|
123 | prod_params(A) ::= param_name(B) COMMA prod_params(C). { |
---|
124 | if (!syntaxOnly) { |
---|
125 | { |
---|
126 | #if PARSER_DEBUG > 0 |
---|
127 | std::cout << "prod_params ::= param_name COMMA prod_params." << std::endl; |
---|
128 | #endif |
---|
129 | } |
---|
130 | A.vectorStr = new vector<SString>(); |
---|
131 | A.vectorStr->push_back(*(B.strValue)); |
---|
132 | for (vector<SString>::iterator iter = C.vectorStr->begin(); iter != C.vectorStr->end(); iter++) { |
---|
133 | A.vectorStr->push_back(*iter); |
---|
134 | } |
---|
135 | delete B.strValue; |
---|
136 | delete C.vectorStr; |
---|
137 | } |
---|
138 | } |
---|
139 | prod_params(A) ::= param_name(B). { |
---|
140 | if (!syntaxOnly) { |
---|
141 | { |
---|
142 | #if PARSER_DEBUG > 0 |
---|
143 | std::cout << "prod_params ::= param_name." << std::endl; |
---|
144 | #endif |
---|
145 | } |
---|
146 | A.vectorStr = new vector<SString>(); |
---|
147 | A.vectorStr->push_back(*(B.strValue)); |
---|
148 | delete B.strValue; |
---|
149 | } |
---|
150 | } |
---|
151 | |
---|
152 | production_tail(A) ::= subproduction(B) SEMICOLON production_tail(C). { |
---|
153 | if (!syntaxOnly) { |
---|
154 | { |
---|
155 | #if PARSER_DEBUG > 0 |
---|
156 | std::cout << "production_tail ::= subproduction SEMICOLON production_tail." << std::endl; |
---|
157 | #endif |
---|
158 | } |
---|
159 | SubProduction sp; |
---|
160 | sp.conditions = *(B.vectorConditions); |
---|
161 | vector<ActionStrP> actions; |
---|
162 | actions.reserve(B.vectorActions->size()); |
---|
163 | for (int i = 0; i < B.vectorActions->size() && i < B.parameters->size(); i++) { |
---|
164 | ActionStrP ap; |
---|
165 | ap.action = (*(B.vectorActions)).at(i); |
---|
166 | ap.params = (*(B.parameters)).at(i); |
---|
167 | actions.push_back(ap); |
---|
168 | } |
---|
169 | sp.actions = actions; |
---|
170 | A.subproductions = new vector<SubProduction>(); |
---|
171 | A.subproductions->push_back(sp); |
---|
172 | for (vector<SubProduction>::iterator iter = C.subproductions->begin(); iter != C.subproductions->end(); iter++) { |
---|
173 | A.subproductions->push_back(*iter); |
---|
174 | } |
---|
175 | delete B.vectorConditions; |
---|
176 | delete B.vectorActions; |
---|
177 | delete B.parameters; |
---|
178 | delete C.subproductions; |
---|
179 | } |
---|
180 | } |
---|
181 | production_tail(A) ::= subproduction(B). { |
---|
182 | if (!syntaxOnly) { |
---|
183 | { |
---|
184 | #if PARSER_DEBUG > 0 |
---|
185 | std::cout << "production_tail ::= subproduction." << std::endl; |
---|
186 | #endif |
---|
187 | } |
---|
188 | SubProduction sp; |
---|
189 | sp.conditions = *(B.vectorConditions); |
---|
190 | vector<ActionStrP> actions; |
---|
191 | actions.reserve(B.vectorActions->size()); |
---|
192 | for (int i = 0; i < B.vectorActions->size() && i < B.parameters->size(); i++) { |
---|
193 | ActionStrP ap; |
---|
194 | ap.action = (*(B.vectorActions)).at(i); |
---|
195 | ap.params = (*(B.parameters)).at(i); |
---|
196 | actions.push_back(ap); |
---|
197 | } |
---|
198 | sp.actions = actions; |
---|
199 | A.subproductions = new vector<SubProduction>(); |
---|
200 | A.subproductions->push_back(sp); |
---|
201 | delete B.vectorConditions; |
---|
202 | delete B.vectorActions; |
---|
203 | delete B.parameters; |
---|
204 | } |
---|
205 | } |
---|
206 | |
---|
207 | subproduction(A) ::= conditions(B) PIPE real_prod(C). { |
---|
208 | if (!syntaxOnly) { |
---|
209 | { |
---|
210 | #if PARSER_DEBUG > 0 |
---|
211 | std::cout << "subproduction ::= conditions PIPE real_prod." << std::endl; |
---|
212 | #endif |
---|
213 | } |
---|
214 | A.vectorConditions = new vector<Condition>(*(B.vectorConditions)); |
---|
215 | A.vectorActions = new vector<Action*>(*(C.vectorActions)); |
---|
216 | A.parameters = new vector<vector<SString> >(*(C.parameters)); |
---|
217 | delete B.vectorConditions; |
---|
218 | delete C.vectorActions; |
---|
219 | delete C.parameters; |
---|
220 | } |
---|
221 | } |
---|
222 | subproduction(A) ::= real_prod(C). { |
---|
223 | if (!syntaxOnly) { |
---|
224 | { |
---|
225 | #if PARSER_DEBUG > 0 |
---|
226 | std::cout << "subproduction ::= real_prod." << std::endl; |
---|
227 | #endif |
---|
228 | } |
---|
229 | A.vectorConditions = new vector<Condition>(); |
---|
230 | A.vectorActions = new vector<Action*>(*(C.vectorActions)); |
---|
231 | A.parameters = new vector<vector<SString> >(*(C.parameters)); |
---|
232 | delete C.vectorActions; |
---|
233 | delete C.parameters; |
---|
234 | } |
---|
235 | } |
---|
236 | |
---|
237 | conditions(A) ::= conditions(B) COMMA conditions(C). { |
---|
238 | if (!syntaxOnly) { |
---|
239 | { |
---|
240 | #if PARSER_DEBUG > 0 |
---|
241 | std::cout << "conditions ::= condition COMMA conditions." << std::endl; |
---|
242 | #endif |
---|
243 | } |
---|
244 | A.vectorConditions = new vector<Condition>(*(B.vectorConditions)); |
---|
245 | for (vector<Condition>::iterator iter = C.vectorConditions->begin(); |
---|
246 | iter != C.vectorConditions->end(); iter++) { |
---|
247 | A.vectorConditions->push_back(*iter); |
---|
248 | } |
---|
249 | delete B.vectorConditions; |
---|
250 | delete C.vectorConditions; |
---|
251 | } |
---|
252 | } |
---|
253 | conditions(A) ::= condition(B). { |
---|
254 | if (!syntaxOnly) { |
---|
255 | { |
---|
256 | #if PARSER_DEBUG > 0 |
---|
257 | std::cout << "conditions ::= condition." << std::endl; |
---|
258 | #endif |
---|
259 | } |
---|
260 | A.vectorConditions = new vector<Condition>(); |
---|
261 | A.vectorConditions->push_back(*(B.cond)); |
---|
262 | delete B.cond; |
---|
263 | } |
---|
264 | } |
---|
265 | |
---|
266 | condition(A) ::= param_name(B) LESS double_val(C). { |
---|
267 | if (!syntaxOnly) { |
---|
268 | { |
---|
269 | #if PARSER_DEBUG > 0 |
---|
270 | std::cout << "condition ::= param_name LESS double_val." << std::endl; |
---|
271 | #endif |
---|
272 | } |
---|
273 | A.cond = new Condition(); |
---|
274 | A.cond->relation = r_less; |
---|
275 | A.cond->parameter = *(B.strValue); |
---|
276 | A.cond->value = C.dblValue; |
---|
277 | delete B.strValue; |
---|
278 | } |
---|
279 | } |
---|
280 | condition(A) ::= param_name(B) LESS_EQUAL double_val(C). { |
---|
281 | if (!syntaxOnly) { |
---|
282 | { |
---|
283 | #if PARSER_DEBUG > 0 |
---|
284 | std::cout << "condition ::= param_name LESS_EQUAL double_val." << std::endl; |
---|
285 | #endif |
---|
286 | } |
---|
287 | A.cond = new Condition(); |
---|
288 | A.cond->relation = r_lessEqual; |
---|
289 | A.cond->parameter = *(B.strValue); |
---|
290 | A.cond->value = C.dblValue; |
---|
291 | delete B.strValue; |
---|
292 | } |
---|
293 | } |
---|
294 | condition(A) ::= param_name(B) NOT_EQUAL double_val(C). { |
---|
295 | if (!syntaxOnly) { |
---|
296 | { |
---|
297 | #if PARSER_DEBUG > 0 |
---|
298 | std::cout << "condition ::= param_name NOT_EQUAL double_val." << std::endl; |
---|
299 | #endif |
---|
300 | } |
---|
301 | A.cond = new Condition(); |
---|
302 | A.cond->relation = r_different; |
---|
303 | A.cond->parameter = *(B.strValue); |
---|
304 | A.cond->value = C.dblValue; |
---|
305 | delete B.strValue; |
---|
306 | } |
---|
307 | } |
---|
308 | condition(A) ::= param_name(B) EQUAL double_val(C). { |
---|
309 | if (!syntaxOnly) { |
---|
310 | { |
---|
311 | #if PARSER_DEBUG > 0 |
---|
312 | std::cout << "condition ::= param_name EQUAL double_val." << std::endl; |
---|
313 | #endif |
---|
314 | } |
---|
315 | A.cond = new Condition(); |
---|
316 | A.cond->relation = r_equal; |
---|
317 | A.cond->parameter = *(B.strValue); |
---|
318 | A.cond->value = C.dblValue; |
---|
319 | delete B.strValue; |
---|
320 | } |
---|
321 | } |
---|
322 | condition(A) ::= param_name(B) GREATER_EQUAL double_val(C). { |
---|
323 | if (!syntaxOnly) { |
---|
324 | { |
---|
325 | #if PARSER_DEBUG > 0 |
---|
326 | std::cout << "condition ::= param_name GREATER_EQUAL double_val." << std::endl; |
---|
327 | #endif |
---|
328 | } |
---|
329 | A.cond = new Condition(); |
---|
330 | A.cond->relation = r_greaterEqual; |
---|
331 | A.cond->parameter = *(B.strValue); |
---|
332 | A.cond->value = C.dblValue; |
---|
333 | delete B.strValue; |
---|
334 | } |
---|
335 | } |
---|
336 | condition(A) ::= param_name(B) GREATER double_val(C). { |
---|
337 | if (!syntaxOnly) { |
---|
338 | { |
---|
339 | #if PARSER_DEBUG > 0 |
---|
340 | std::cout << "condition ::= param_name GREATER double_val." << std::endl; |
---|
341 | #endif |
---|
342 | } |
---|
343 | A.cond = new Condition(); |
---|
344 | A.cond->relation = r_greater; |
---|
345 | A.cond->parameter = *(B.strValue); |
---|
346 | A.cond->value = C.dblValue; |
---|
347 | delete B.strValue; |
---|
348 | } |
---|
349 | } |
---|
350 | |
---|
351 | real_prod(A) ::= . { |
---|
352 | if (!syntaxOnly) { |
---|
353 | { |
---|
354 | #if PARSER_DEBUG > 0 |
---|
355 | std::cout << "real_prod ::= ." << std::endl; |
---|
356 | #endif |
---|
357 | } |
---|
358 | A.vectorActions = new vector<Action*>(); |
---|
359 | A.parameters = new vector<vector<SString> >(); |
---|
360 | } |
---|
361 | } |
---|
362 | real_prod(A) ::= prod_piece(B) real_prod(C). { |
---|
363 | if (!syntaxOnly) { |
---|
364 | { |
---|
365 | #if PARSER_DEBUG > 0 |
---|
366 | std::cout << "real_prod ::= prod_piece real_prod." << std::endl; |
---|
367 | for (vector<Action*>::iterator actIter = B.actions->begin(); actIter != B.actions->end(); actIter++) { |
---|
368 | cout << "\t" << (*actIter)->name << endl; |
---|
369 | } |
---|
370 | #endif |
---|
371 | } |
---|
372 | //A = B.clone() && A.append(C) |
---|
373 | A.vectorActions = new vector<Action*>(*(B.actions)); |
---|
374 | A.parameters = new vector<vector<SString> >(*(B.parameters)); |
---|
375 | if (C.vectorActions != NULL && C.parameters != NULL) { |
---|
376 | for (vector<Action*>::iterator iter = C.vectorActions->begin(); iter != C.vectorActions->end(); iter++) { |
---|
377 | A.vectorActions->push_back(*iter); |
---|
378 | } |
---|
379 | for(vector<vector<SString> >::iterator iter = C.parameters->begin(); iter != C.parameters->end(); iter++) { |
---|
380 | A.parameters->push_back(*iter); |
---|
381 | } |
---|
382 | delete C.vectorActions; |
---|
383 | delete C.parameters; |
---|
384 | } else { |
---|
385 | #if PARSER_DEBUG > 0 |
---|
386 | cout << "\tNULL~~~~~~~~~~~~" << endl; |
---|
387 | #endif |
---|
388 | } |
---|
389 | delete B.actions; |
---|
390 | delete B.parameters; |
---|
391 | } |
---|
392 | } |
---|
393 | real_prod(A) ::= FORLOOP_BEGIN real_prod(B) FORLOOP_END LPAREN single_val(C) RPAREN real_prod(D). { |
---|
394 | if (!syntaxOnly) { |
---|
395 | { |
---|
396 | #if PARSER_DEBUG > 0 |
---|
397 | std::cout << "real_prod ::= FORLOOP_BEGIN real_prod FORLOOP_END LPAREN single_val RPAREN." << std::endl; |
---|
398 | #endif |
---|
399 | } |
---|
400 | A.vectorActions = new vector<Action*>(); |
---|
401 | A.parameters = new vector<vector<SString> >(); |
---|
402 | int iterations = (int) parseExpression(*(C.strValue)); |
---|
403 | for (int i = 0; i < iterations; i++) { |
---|
404 | for (vector<Action*>::iterator iter = B.vectorActions->begin(); iter != B.vectorActions->end(); iter++) { |
---|
405 | A.vectorActions->push_back(*iter); |
---|
406 | } |
---|
407 | for (vector<vector<SString> >::iterator iter = B.parameters->begin(); iter != B.parameters->end(); iter++) { |
---|
408 | A.parameters->push_back(*iter); |
---|
409 | } |
---|
410 | } |
---|
411 | for (vector<Action*>::iterator iter = D.vectorActions->begin(); iter != D.vectorActions->end(); iter++) { |
---|
412 | A.vectorActions->push_back(*iter); |
---|
413 | } |
---|
414 | for (vector<vector<SString> >::iterator iter = D.parameters->begin(); iter != D.parameters->end(); iter++) { |
---|
415 | A.parameters->push_back(*iter); |
---|
416 | } |
---|
417 | delete B.vectorActions; |
---|
418 | delete B.parameters; |
---|
419 | delete C.strValue; |
---|
420 | delete D.vectorActions; |
---|
421 | delete D.parameters; |
---|
422 | } |
---|
423 | } |
---|
424 | |
---|
425 | prod_piece(A) ::= prod_name(B) LPAREN multiple_val(C) RPAREN. { |
---|
426 | if (!syntaxOnly) { |
---|
427 | { |
---|
428 | #if PARSER_DEBUG > 0 |
---|
429 | std::cout << "prod_piece ::= prod_name LPAREN multiple_val RPAREN." << std::endl; |
---|
430 | #endif |
---|
431 | } |
---|
432 | A.actions = new vector<Action*>(); |
---|
433 | A.parameters = new vector<vector<SString> >(); |
---|
434 | |
---|
435 | Production *p = lsys->productions.find(sstringToString(*(B.strValue)))->second; |
---|
436 | A.actions->push_back(p); |
---|
437 | A.parameters->push_back(*(C.vectorStr)); |
---|
438 | delete B.strValue; |
---|
439 | delete C.vectorStr; |
---|
440 | } |
---|
441 | } |
---|
442 | prod_piece(A) ::= prod_name(B) LPAREN RPAREN. { |
---|
443 | if (!syntaxOnly) { |
---|
444 | { |
---|
445 | #if PARSER_DEBUG > 0 |
---|
446 | std::cout << "prod_piece ::= prod_name LPAREN RPAREN." << std::endl; |
---|
447 | #endif |
---|
448 | } |
---|
449 | A.actions = new vector<Action*>(); |
---|
450 | vector<SString> param; |
---|
451 | A.parameters = new vector<vector<SString> >(); |
---|
452 | A.parameters->push_back(param); |
---|
453 | |
---|
454 | Production *p = lsys->productions.find(sstringToString(*(B.strValue)))->second; |
---|
455 | A.actions->push_back(p); |
---|
456 | delete B.strValue; |
---|
457 | } |
---|
458 | } |
---|
459 | prod_piece(A) ::= command(B). { |
---|
460 | if (!syntaxOnly) { |
---|
461 | { |
---|
462 | #if PARSER_DEBUG > 0 |
---|
463 | std::cout << "prod_piece ::= command." << std::endl; |
---|
464 | #endif |
---|
465 | } |
---|
466 | A.actions = new vector<Action*>(); |
---|
467 | A.parameters = new vector<vector<SString> >(); |
---|
468 | PrimitiveProduction *pp = lsys->getPrimitiveProduction(*(B.strValue)); |
---|
469 | A.actions->push_back(pp); |
---|
470 | vector<SString> param; |
---|
471 | A.parameters->push_back(param); |
---|
472 | delete B.strValue; |
---|
473 | } |
---|
474 | } |
---|
475 | prod_piece(A) ::= param_name(B). { |
---|
476 | if (!syntaxOnly) { |
---|
477 | { |
---|
478 | #if PARSER_DEBUG > 0 |
---|
479 | std::cout << "prod_piece ::= paramName." << std::endl; |
---|
480 | #endif |
---|
481 | } |
---|
482 | A.actions = new vector<Action*>(); |
---|
483 | A.parameters = new vector<vector<SString> >(); |
---|
484 | ParamProduction *pp = lsys->getParamProduction(*(B.strValue)); |
---|
485 | A.actions->push_back(pp); |
---|
486 | vector<SString> param; |
---|
487 | param.push_back(*(B.strValue)); |
---|
488 | A.parameters->push_back(param); |
---|
489 | delete B.strValue; |
---|
490 | } |
---|
491 | } |
---|
492 | prod_piece(A) ::= neuron(B). { |
---|
493 | if (!syntaxOnly) { |
---|
494 | { |
---|
495 | #if PARSER_DEBUG > 0 |
---|
496 | std::cout << "prod_piece ::= neuron." << std::endl; |
---|
497 | #endif |
---|
498 | } |
---|
499 | A.actions = new vector<Action*>(); |
---|
500 | A.parameters = new vector<vector<SString> >(); |
---|
501 | NeuronProduction *np = new NeuronProduction(*(B.strValue)); |
---|
502 | lsys->neuronProductions.push_back(np); |
---|
503 | A.actions->push_back(np); |
---|
504 | vector<SString> param; |
---|
505 | A.parameters->push_back(param); |
---|
506 | delete B.strValue; |
---|
507 | } |
---|
508 | } |
---|
509 | |
---|
510 | multiple_val(A) ::= single_val(B). { |
---|
511 | if (!syntaxOnly) { |
---|
512 | { |
---|
513 | #if PARSER_DEBUG > 0 |
---|
514 | std::cout << "multiple_val ::= single_val." << std::endl; |
---|
515 | #endif |
---|
516 | } |
---|
517 | A.vectorStr = new vector<SString>(); |
---|
518 | A.vectorStr->push_back(SString(*(B.strValue))); |
---|
519 | delete B.strValue; |
---|
520 | } |
---|
521 | } |
---|
522 | multiple_val(A) ::= multiple_val(B) COMMA multiple_val(C). { |
---|
523 | if (!syntaxOnly) { |
---|
524 | { |
---|
525 | #if PARSER_DEBUG > 0 |
---|
526 | std::cout << "multiple_val ::= multiple_val COMMA multiple_val." << std::endl; |
---|
527 | #endif |
---|
528 | } |
---|
529 | A.vectorStr = new vector<SString>(); |
---|
530 | for (vector<SString>::iterator iter = B.vectorStr->begin(); iter != B.vectorStr->end(); iter++) { |
---|
531 | A.vectorStr->push_back(*iter); |
---|
532 | } |
---|
533 | for (vector<SString>::iterator iter = C.vectorStr->begin(); iter != C.vectorStr->end(); iter++) { |
---|
534 | A.vectorStr->push_back(*iter); |
---|
535 | } |
---|
536 | delete B.vectorStr; |
---|
537 | delete C.vectorStr; |
---|
538 | } |
---|
539 | } |
---|
540 | |
---|
541 | single_val(A) ::= double_val(B). { |
---|
542 | if (!syntaxOnly) { |
---|
543 | { |
---|
544 | #if PARSER_DEBUG > 0 |
---|
545 | std::cout << "single_val ::= double_val." << std::endl; |
---|
546 | #endif |
---|
547 | } |
---|
548 | A.strValue = new SString(SString::valueOf(B.dblValue) + ";"); |
---|
549 | delete B.strValue; |
---|
550 | } |
---|
551 | } |
---|
552 | single_val(A) ::= param_name(B). { |
---|
553 | if (!syntaxOnly) { |
---|
554 | { |
---|
555 | #if PARSER_DEBUG > 0 |
---|
556 | std::cout << "single_val ::= param_name." << std::endl; |
---|
557 | #endif |
---|
558 | } |
---|
559 | A.strValue = new SString(*(B.strValue) + ";"); |
---|
560 | delete B.strValue; |
---|
561 | } |
---|
562 | } |
---|
563 | single_val(A) ::= single_val(B) PLUS single_val(C). { |
---|
564 | if (!syntaxOnly) { |
---|
565 | { |
---|
566 | #if PARSER_DEBUG > 0 |
---|
567 | std::cout << "single_val ::= single_val PLUS single_val." << std::endl; |
---|
568 | #endif |
---|
569 | } |
---|
570 | A.strValue = new SString(*(B.strValue) + *(C.strValue) + "+;"); |
---|
571 | delete B.strValue; |
---|
572 | delete C.strValue; |
---|
573 | } |
---|
574 | } |
---|
575 | single_val(A) ::= single_val(B) MINUS single_val(C). { |
---|
576 | if (!syntaxOnly) { |
---|
577 | { |
---|
578 | #if PARSER_DEBUG > 0 |
---|
579 | std::cout << "single_val ::= single_val MINUS single_val." << std::endl; |
---|
580 | #endif |
---|
581 | } |
---|
582 | A.strValue = new SString(*(B.strValue) + *(C.strValue) + "-;"); |
---|
583 | delete B.strValue; |
---|
584 | delete C.strValue; |
---|
585 | } |
---|
586 | } |
---|
587 | single_val(A) ::= single_val(B) TIMES single_val(C). { |
---|
588 | if (!syntaxOnly) { |
---|
589 | { |
---|
590 | #if PARSER_DEBUG > 0 |
---|
591 | std::cout << "single_val ::= single_val TIMES single_val." << std::endl; |
---|
592 | #endif |
---|
593 | } |
---|
594 | A.strValue = new SString(*(B.strValue) + *(C.strValue) + "*;"); |
---|
595 | delete B.strValue; |
---|
596 | delete C.strValue; |
---|
597 | } |
---|
598 | } |
---|
599 | single_val(A) ::= single_val(B) DIV single_val(C). { |
---|
600 | if (!syntaxOnly) { |
---|
601 | { |
---|
602 | #if PARSER_DEBUG > 0 |
---|
603 | std::cout << "single_val ::= single_val DIV single_val." << std::endl; |
---|
604 | #endif |
---|
605 | } |
---|
606 | A.strValue = new SString(*(B.strValue) + *(C.strValue) + "/;"); |
---|
607 | delete B.strValue; |
---|
608 | delete C.strValue; |
---|
609 | } |
---|
610 | } |
---|
611 | |
---|
612 | double_val(A) ::= DOUBLE_VAL(B). { |
---|
613 | if (!syntaxOnly) { |
---|
614 | { |
---|
615 | #if PARSER_DEBUG > 0 |
---|
616 | std::cout << "double_val ::= DOUBLE_VAL. -> " << (string(B.strArrValue)).c_str() << std::endl; |
---|
617 | #endif |
---|
618 | } |
---|
619 | A.dblValue = atof((string(B.strArrValue)).c_str()); |
---|
620 | } |
---|
621 | } |
---|
622 | param_name(A) ::= PARAM_NAME(B). { |
---|
623 | if (!syntaxOnly) { |
---|
624 | { |
---|
625 | #if PARSER_DEBUG > 0 |
---|
626 | std::cout << "param_name ::= PARAM_NAME. -> " << (string(B.strArrValue)).c_str() << std::endl; |
---|
627 | #endif |
---|
628 | } |
---|
629 | A.strValue = new SString(string(B.strArrValue).c_str()); |
---|
630 | } |
---|
631 | } |
---|
632 | prod_name(A) ::= PROD_NAME(B). { |
---|
633 | if (!syntaxOnly) { |
---|
634 | { |
---|
635 | #if PARSER_DEBUG > 0 |
---|
636 | std::cout << "prod_name ::= PROD_NAME." << std::endl; |
---|
637 | #endif |
---|
638 | } |
---|
639 | A.strValue = new SString(string(B.strArrValue).c_str()); |
---|
640 | } |
---|
641 | } |
---|
642 | command(A) ::= COMMAND(B). { |
---|
643 | if (!syntaxOnly) { |
---|
644 | { |
---|
645 | #if PARSER_DEBUG > 0 |
---|
646 | std::cout << "command ::= COMMAND." << std::endl; |
---|
647 | #endif |
---|
648 | } |
---|
649 | A.strValue = new SString(string(B.strArrValue).c_str()); |
---|
650 | } |
---|
651 | } |
---|
652 | neuron(A) ::= NEURON(B). { |
---|
653 | if (!syntaxOnly) { |
---|
654 | { |
---|
655 | #if PARSER_DEBUG > 0 |
---|
656 | std::cout << "neuron ::= NEURON." << std::endl; |
---|
657 | #endif |
---|
658 | } |
---|
659 | A.strValue = new SString(string(B.strArrValue).c_str()); |
---|
660 | } |
---|
661 | } |
---|