702 } |
702 } |
703 |
703 |
704 |
704 |
705 void *visit(var1_list_c *symbol) {return print_list(symbol, "", ", ");} |
705 void *visit(var1_list_c *symbol) {return print_list(symbol, "", ", ");} |
706 |
706 |
|
707 /* | [var1_list ','] variable_name '..' */ |
|
708 /* NOTE: This is an extension to the standard!!! */ |
|
709 /* In order to be able to handle extensible standard functions |
|
710 * (i.e. standard functions that may have a variable number of |
|
711 * input parameters, such as AND(word#33, word#44, word#55, word#66), |
|
712 * we have extended the acceptable syntax to allow var_name '..' |
|
713 * in an input variable declaration. |
|
714 * |
|
715 * This allows us to parse the declaration of standard |
|
716 * extensible functions and load their interface definition |
|
717 * into the abstract syntax tree just like we do to other |
|
718 * user defined functions. |
|
719 * This has the advantage that we can later do semantic |
|
720 * checking of calls to functions (be it a standard or user defined |
|
721 * function) in (almost) exactly the same way. |
|
722 * |
|
723 * Of course, we have a flag that disables this syntax when parsing user |
|
724 * written code, so we only allow this extra syntax while parsing the |
|
725 * 'header' file that declares all the standard IEC 61131-3 functions. |
|
726 */ |
|
727 void *visit(extensible_input_parameter_c *symbol) { |
|
728 symbol->var_name->accept(*this); |
|
729 s4o.print(" .. "); |
|
730 return NULL; |
|
731 } |
|
732 |
707 |
733 |
708 /* var1_list ':' array_spec_init */ |
734 /* var1_list ':' array_spec_init */ |
709 void *visit(array_var_init_decl_c *symbol) { |
735 void *visit(array_var_init_decl_c *symbol) { |
710 symbol->var1_list->accept(*this); |
736 symbol->var1_list->accept(*this); |
711 s4o.print(" : "); |
737 s4o.print(" : "); |
928 s4o.print(" : "); |
954 s4o.print(" : "); |
929 symbol->single_byte_string_spec->accept(*this); |
955 symbol->single_byte_string_spec->accept(*this); |
930 return NULL; |
956 return NULL; |
931 } |
957 } |
932 |
958 |
933 /* STRING ['[' integer ']'] [ASSIGN single_byte_character_string] */ |
959 /* single_byte_limited_len_string_spec [ASSIGN single_byte_character_string] */ |
934 /* integer ->may be NULL ! */ |
|
935 /* single_byte_character_string ->may be NULL ! */ |
960 /* single_byte_character_string ->may be NULL ! */ |
936 void *visit(single_byte_string_spec_c *symbol) { |
961 void *visit(single_byte_string_spec_c *symbol) { |
937 s4o.print("STRING ["); |
962 symbol->string_spec->accept(*this); |
938 if (symbol->integer != NULL) |
|
939 symbol->integer->accept(*this); |
|
940 s4o.print("]"); |
|
941 if (symbol->single_byte_character_string != NULL) { |
963 if (symbol->single_byte_character_string != NULL) { |
942 s4o.print(" := "); |
964 s4o.print(" := "); |
943 symbol->single_byte_character_string->accept(*this); |
965 symbol->single_byte_character_string->accept(*this); |
944 } |
966 } |
945 return NULL; |
967 return NULL; |
946 } |
968 } |
947 |
969 |
|
970 /* STRING ['[' integer ']'] */ |
|
971 /* integer ->may be NULL ! */ |
|
972 void *visit(single_byte_limited_len_string_spec_c *symbol) { |
|
973 symbol->string_type_name->accept(*this); |
|
974 if (symbol->character_string_len != NULL) { |
|
975 s4o.print(" ["); |
|
976 symbol->character_string_len->accept(*this); |
|
977 s4o.print("]"); |
|
978 } |
|
979 return NULL; |
|
980 } |
|
981 |
948 /* var1_list ':' double_byte_string_spec */ |
982 /* var1_list ':' double_byte_string_spec */ |
949 void *visit(double_byte_string_var_declaration_c *symbol) { |
983 void *visit(double_byte_string_var_declaration_c *symbol) { |
950 symbol->var1_list->accept(*this); |
984 symbol->var1_list->accept(*this); |
951 s4o.print(" : "); |
985 s4o.print(" : "); |
952 symbol->double_byte_string_spec->accept(*this); |
986 symbol->double_byte_string_spec->accept(*this); |
953 return NULL; |
987 return NULL; |
954 } |
988 } |
955 |
989 |
956 /* WSTRING ['[' integer ']'] [ASSIGN double_byte_character_string] */ |
990 /* double_byte_limited_len_string_spec [ASSIGN double_byte_character_string] */ |
957 /* integer ->may be NULL ! */ |
991 /* integer ->may be NULL ! */ |
958 /* double_byte_character_string ->may be NULL ! */ |
992 /* double_byte_character_string ->may be NULL ! */ |
959 void *visit(double_byte_string_spec_c *symbol) { |
993 void *visit(double_byte_string_spec_c *symbol) { |
960 s4o.print("WSTRING ["); |
994 symbol->string_spec->accept(*this); |
961 if (symbol->integer != NULL) |
|
962 symbol->integer->accept(*this); |
|
963 s4o.print("]"); |
|
964 if (symbol->double_byte_character_string != NULL) { |
995 if (symbol->double_byte_character_string != NULL) { |
965 s4o.print(" := "); |
996 s4o.print(" := "); |
966 symbol->double_byte_character_string->accept(*this); |
997 symbol->double_byte_character_string->accept(*this); |
|
998 } |
|
999 return NULL; |
|
1000 } |
|
1001 |
|
1002 /* WSTRING ['[' integer ']'] */ |
|
1003 /* integer ->may be NULL ! */ |
|
1004 void *visit(double_byte_limited_len_string_spec_c *symbol) { |
|
1005 symbol->string_type_name->accept(*this); |
|
1006 if (symbol->character_string_len != NULL) { |
|
1007 s4o.print(" ["); |
|
1008 symbol->character_string_len->accept(*this); |
|
1009 s4o.print("]"); |
967 } |
1010 } |
968 return NULL; |
1011 return NULL; |
969 } |
1012 } |
970 |
1013 |
971 /*| VAR [RETAIN|NON_RETAIN] incompl_located_var_decl_list END_VAR */ |
1014 /*| VAR [RETAIN|NON_RETAIN] incompl_located_var_decl_list END_VAR */ |