335 /* B 1.2.1 - Numeric Literals */ |
335 /* B 1.2.1 - Numeric Literals */ |
336 /******************************/ |
336 /******************************/ |
337 void *print_datatypes_error_c::visit(real_c *symbol) { |
337 void *print_datatypes_error_c::visit(real_c *symbol) { |
338 if (symbol->candidate_datatypes.size() == 0) { |
338 if (symbol->candidate_datatypes.size() == 0) { |
339 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_REAL data type."); |
339 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_REAL data type."); |
340 } else if (NULL == symbol->datatype) { |
340 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
341 STAGE3_ERROR(4, symbol, symbol, "ANY_REAL data type not valid in this location."); |
341 STAGE3_ERROR(4, symbol, symbol, "ANY_REAL data type not valid in this location."); |
342 } |
342 } |
343 return NULL; |
343 return NULL; |
344 } |
344 } |
345 |
345 |
346 void *print_datatypes_error_c::visit(integer_c *symbol) { |
346 void *print_datatypes_error_c::visit(integer_c *symbol) { |
347 if (symbol->candidate_datatypes.size() == 0) { |
347 if (symbol->candidate_datatypes.size() == 0) { |
348 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type."); |
348 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type."); |
349 } else if (NULL == symbol->datatype) { |
349 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
350 STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location."); |
350 STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location."); |
351 } |
351 } |
352 return NULL; |
352 return NULL; |
353 } |
353 } |
354 |
354 |
355 void *print_datatypes_error_c::visit(neg_real_c *symbol) { |
355 void *print_datatypes_error_c::visit(neg_real_c *symbol) { |
356 if (symbol->candidate_datatypes.size() == 0) { |
356 if (symbol->candidate_datatypes.size() == 0) { |
357 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_REAL data type."); |
357 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_REAL data type."); |
358 } else if (NULL == symbol->datatype) { |
358 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
359 STAGE3_ERROR(4, symbol, symbol, "ANY_REAL data type not valid in this location."); |
359 STAGE3_ERROR(4, symbol, symbol, "ANY_REAL data type not valid in this location."); |
360 } |
360 } |
361 return NULL; |
361 return NULL; |
362 } |
362 } |
363 |
363 |
364 void *print_datatypes_error_c::visit(neg_integer_c *symbol) { |
364 void *print_datatypes_error_c::visit(neg_integer_c *symbol) { |
365 if (symbol->candidate_datatypes.size() == 0) { |
365 if (symbol->candidate_datatypes.size() == 0) { |
366 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type."); |
366 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type."); |
367 } else if (NULL == symbol->datatype) { |
367 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
368 STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location."); |
368 STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location."); |
369 } |
369 } |
370 return NULL; |
370 return NULL; |
371 } |
371 } |
372 |
372 |
373 void *print_datatypes_error_c::visit(binary_integer_c *symbol) { |
373 void *print_datatypes_error_c::visit(binary_integer_c *symbol) { |
374 if (symbol->candidate_datatypes.size() == 0) { |
374 if (symbol->candidate_datatypes.size() == 0) { |
375 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type."); |
375 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type."); |
376 } else if (NULL == symbol->datatype) { |
376 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
377 STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location."); |
377 STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location."); |
378 } |
378 } |
379 return NULL; |
379 return NULL; |
380 } |
380 } |
381 |
381 |
382 void *print_datatypes_error_c::visit(octal_integer_c *symbol) { |
382 void *print_datatypes_error_c::visit(octal_integer_c *symbol) { |
383 if (symbol->candidate_datatypes.size() == 0) { |
383 if (symbol->candidate_datatypes.size() == 0) { |
384 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type."); |
384 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type."); |
385 } else if (NULL == symbol->datatype) { |
385 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
386 STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location."); |
386 STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location."); |
387 } |
387 } |
388 return NULL; |
388 return NULL; |
389 } |
389 } |
390 |
390 |
391 void *print_datatypes_error_c::visit(hex_integer_c *symbol) { |
391 void *print_datatypes_error_c::visit(hex_integer_c *symbol) { |
392 if (symbol->candidate_datatypes.size() == 0) { |
392 if (symbol->candidate_datatypes.size() == 0) { |
393 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type."); |
393 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type."); |
394 } else if (NULL == symbol->datatype) { |
394 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
395 STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location."); |
395 STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location."); |
396 } |
396 } |
397 return NULL; |
397 return NULL; |
398 } |
398 } |
399 |
399 |
400 void *print_datatypes_error_c::visit(integer_literal_c *symbol) { |
400 void *print_datatypes_error_c::visit(integer_literal_c *symbol) { |
401 if (symbol->candidate_datatypes.size() == 0) { |
401 if (symbol->candidate_datatypes.size() == 0) { |
402 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for %s data type.", get_datatype_info_c::get_id_str(symbol->type)); |
402 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for %s data type.", get_datatype_info_c::get_id_str(symbol->type)); |
403 } else if (NULL == symbol->datatype) { |
403 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
404 STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location."); |
404 STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location."); |
405 } |
405 } |
406 return NULL; |
406 return NULL; |
407 } |
407 } |
408 |
408 |
409 void *print_datatypes_error_c::visit(real_literal_c *symbol) { |
409 void *print_datatypes_error_c::visit(real_literal_c *symbol) { |
410 if (symbol->candidate_datatypes.size() == 0) { |
410 if (symbol->candidate_datatypes.size() == 0) { |
411 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for %s data type.", get_datatype_info_c::get_id_str(symbol->type)); |
411 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for %s data type.", get_datatype_info_c::get_id_str(symbol->type)); |
412 } else if (NULL == symbol->datatype) { |
412 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
413 STAGE3_ERROR(4, symbol, symbol, "ANY_REAL data type not valid in this location."); |
413 STAGE3_ERROR(4, symbol, symbol, "ANY_REAL data type not valid in this location."); |
414 } |
414 } |
415 return NULL; |
415 return NULL; |
416 } |
416 } |
417 |
417 |
418 void *print_datatypes_error_c::visit(bit_string_literal_c *symbol) { |
418 void *print_datatypes_error_c::visit(bit_string_literal_c *symbol) { |
419 if (symbol->candidate_datatypes.size() == 0) { |
419 if (symbol->candidate_datatypes.size() == 0) { |
420 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for %s data type.", get_datatype_info_c::get_id_str(symbol->type)); |
420 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for %s data type.", get_datatype_info_c::get_id_str(symbol->type)); |
421 } else if (NULL == symbol->datatype) { |
421 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
422 STAGE3_ERROR(4, symbol, symbol, "ANY_BIT data type not valid in this location."); |
422 STAGE3_ERROR(4, symbol, symbol, "ANY_BIT data type not valid in this location."); |
423 } |
423 } |
424 return NULL; |
424 return NULL; |
425 } |
425 } |
426 |
426 |
427 void *print_datatypes_error_c::visit(boolean_literal_c *symbol) { |
427 void *print_datatypes_error_c::visit(boolean_literal_c *symbol) { |
428 if (symbol->candidate_datatypes.size() == 0) { |
428 if (symbol->candidate_datatypes.size() == 0) { |
429 STAGE3_ERROR(0, symbol, symbol, "Value is not valid for %s data type.", get_datatype_info_c::get_id_str(symbol->type)); |
429 STAGE3_ERROR(0, symbol, symbol, "Value is not valid for %s data type.", get_datatype_info_c::get_id_str(symbol->type)); |
430 } else if (NULL == symbol->datatype) { |
430 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
431 STAGE3_ERROR(4, symbol, symbol, "ANY_BOOL data type not valid in this location."); |
431 STAGE3_ERROR(4, symbol, symbol, "ANY_BOOL data type not valid in this location."); |
432 } |
432 } |
433 return NULL; |
433 return NULL; |
434 } |
434 } |
435 |
435 |
436 void *print_datatypes_error_c::visit(boolean_true_c *symbol) { |
436 void *print_datatypes_error_c::visit(boolean_true_c *symbol) { |
437 if (symbol->candidate_datatypes.size() == 0) { |
437 if (symbol->candidate_datatypes.size() == 0) { |
438 STAGE3_ERROR(0, symbol, symbol, "Value is not valid for ANY_BOOL data type."); |
438 STAGE3_ERROR(0, symbol, symbol, "Value is not valid for ANY_BOOL data type."); |
439 } else if (NULL == symbol->datatype) { |
439 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
440 STAGE3_ERROR(4, symbol, symbol, "ANY_BOOL data type not valid in this location."); |
440 STAGE3_ERROR(4, symbol, symbol, "ANY_BOOL data type not valid in this location."); |
441 } |
441 } |
442 return NULL; |
442 return NULL; |
443 } |
443 } |
444 |
444 |
445 void *print_datatypes_error_c::visit(boolean_false_c *symbol) { |
445 void *print_datatypes_error_c::visit(boolean_false_c *symbol) { |
446 if (symbol->candidate_datatypes.size() == 0) { |
446 if (symbol->candidate_datatypes.size() == 0) { |
447 STAGE3_ERROR(0, symbol, symbol, "Value is not valid for ANY_BOOL data type."); |
447 STAGE3_ERROR(0, symbol, symbol, "Value is not valid for ANY_BOOL data type."); |
448 } else if (NULL == symbol->datatype) { |
448 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
449 STAGE3_ERROR(4, symbol, symbol, "ANY_BOOL data type not valid in this location."); |
449 STAGE3_ERROR(4, symbol, symbol, "ANY_BOOL data type not valid in this location."); |
450 } |
450 } |
451 return NULL; |
451 return NULL; |
452 } |
452 } |
453 |
453 |
491 /* B 1.2.3.2 - Time of day and Date */ |
491 /* B 1.2.3.2 - Time of day and Date */ |
492 /************************************/ |
492 /************************************/ |
493 void *print_datatypes_error_c::visit(time_of_day_c *symbol) { |
493 void *print_datatypes_error_c::visit(time_of_day_c *symbol) { |
494 if (symbol->candidate_datatypes.size() == 0) { |
494 if (symbol->candidate_datatypes.size() == 0) { |
495 STAGE3_ERROR(0, symbol, symbol, "Invalid syntax for TOD data type."); |
495 STAGE3_ERROR(0, symbol, symbol, "Invalid syntax for TOD data type."); |
496 } else if (NULL == symbol->datatype) { |
496 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
497 STAGE3_ERROR(4, symbol, symbol, "TOD data type not valid in this location."); |
497 STAGE3_ERROR(4, symbol, symbol, "TOD data type not valid in this location."); |
498 } |
498 } |
499 return NULL; |
499 return NULL; |
500 } |
500 } |
501 |
501 |
502 void *print_datatypes_error_c::visit(date_c *symbol) { |
502 void *print_datatypes_error_c::visit(date_c *symbol) { |
503 if (symbol->candidate_datatypes.size() == 0) { |
503 if (symbol->candidate_datatypes.size() == 0) { |
504 STAGE3_ERROR(0, symbol, symbol, "Invalid syntax for DATE data type."); |
504 STAGE3_ERROR(0, symbol, symbol, "Invalid syntax for DATE data type."); |
505 } else if (NULL == symbol->datatype) { |
505 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
506 STAGE3_ERROR(4, symbol, symbol, "DATE data type not valid in this location."); |
506 STAGE3_ERROR(4, symbol, symbol, "DATE data type not valid in this location."); |
507 } |
507 } |
508 return NULL; |
508 return NULL; |
509 } |
509 } |
510 |
510 |
511 void *print_datatypes_error_c::visit(date_and_time_c *symbol) { |
511 void *print_datatypes_error_c::visit(date_and_time_c *symbol) { |
512 if (symbol->candidate_datatypes.size() == 0) { |
512 if (symbol->candidate_datatypes.size() == 0) { |
513 STAGE3_ERROR(0, symbol, symbol, "Invalid syntax for DT data type."); |
513 STAGE3_ERROR(0, symbol, symbol, "Invalid syntax for DT data type."); |
514 } else if (NULL == symbol->datatype) { |
514 } else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) { |
515 STAGE3_ERROR(4, symbol, symbol, "DT data type not valid in this location."); |
515 STAGE3_ERROR(4, symbol, symbol, "DT data type not valid in this location."); |
516 } |
516 } |
517 return NULL; |
517 return NULL; |
518 } |
518 } |
519 |
519 |
1196 void *print_datatypes_error_c::visit(for_statement_c *symbol) { |
1196 void *print_datatypes_error_c::visit(for_statement_c *symbol) { |
1197 symbol->control_variable->accept(*this); |
1197 symbol->control_variable->accept(*this); |
1198 symbol->beg_expression->accept(*this); |
1198 symbol->beg_expression->accept(*this); |
1199 symbol->end_expression->accept(*this); |
1199 symbol->end_expression->accept(*this); |
1200 /* Control variable */ |
1200 /* Control variable */ |
1201 if ((NULL == symbol->control_variable->datatype) && |
1201 if ((!get_datatype_info_c::is_type_valid(symbol->control_variable->datatype)) && |
1202 (symbol->control_variable->candidate_datatypes.size() > 0)) { |
1202 (symbol->control_variable->candidate_datatypes.size() > 0)) { |
1203 STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' control variable."); |
1203 STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' control variable."); |
1204 } |
1204 } |
1205 /* BEG expression */ |
1205 /* BEG expression */ |
1206 if ((NULL == symbol->beg_expression->datatype) && |
1206 if ((!get_datatype_info_c::is_type_valid(symbol->beg_expression->datatype)) && |
1207 (symbol->beg_expression->candidate_datatypes.size() > 0)) { |
1207 (symbol->beg_expression->candidate_datatypes.size() > 0)) { |
1208 STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' begin expression."); |
1208 STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' begin expression."); |
1209 } |
1209 } |
1210 /* END expression */ |
1210 /* END expression */ |
1211 if ((NULL == symbol->end_expression->datatype) && |
1211 if ((!get_datatype_info_c::is_type_valid(symbol->end_expression->datatype)) && |
1212 (symbol->end_expression->candidate_datatypes.size() > 0)) { |
1212 (symbol->end_expression->candidate_datatypes.size() > 0)) { |
1213 STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' end expression."); |
1213 STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' end expression."); |
1214 } |
1214 } |
1215 /* BY expression */ |
1215 /* BY expression */ |
1216 if ((NULL != symbol->by_expression) && |
1216 if ((NULL != symbol->by_expression) && |
1217 (NULL == symbol->by_expression->datatype) && |
1217 (!get_datatype_info_c::is_type_valid(symbol->by_expression->datatype)) && |
1218 (symbol->end_expression->candidate_datatypes.size() > 0)) { |
1218 (symbol->end_expression->candidate_datatypes.size() > 0)) { |
1219 STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' by expression."); |
1219 STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' by expression."); |
1220 } |
1220 } |
1221 /* DO statement */ |
1221 /* DO statement */ |
1222 if (NULL != symbol->statement_list) |
1222 if (NULL != symbol->statement_list) |
1223 symbol->statement_list->accept(*this); |
1223 symbol->statement_list->accept(*this); |