conti@748: /* conti@748: * matiec - a compiler for the programming languages defined in IEC 61131-3 conti@748: * conti@748: * Copyright (C) 2009-2012 Mario de Sousa (msousa@fe.up.pt) conti@748: * Copyright (C) 2012 Manuele Conti (conti.ma@alice.it) conti@748: * conti@748: * conti@748: * This program is free software: you can redistribute it and/or modify conti@748: * it under the terms of the GNU General Public License as published by conti@748: * the Free Software Foundation, either version 3 of the License, or conti@748: * (at your option) any later version. conti@748: * conti@748: * This program is distributed in the hope that it will be useful, conti@748: * but WITHOUT ANY WARRANTY; without even the implied warranty of conti@748: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the conti@748: * GNU General Public License for more details. conti@748: * conti@748: * You should have received a copy of the GNU General Public License conti@748: * along with this program. If not, see . conti@748: * conti@748: * conti@748: * This code is made available on the understanding that it will not be conti@748: * used in safety-critical situations without a full and competent review. conti@748: */ conti@748: conti@748: /* conti@748: * An IEC 61131-3 compiler. conti@748: * conti@748: * Based on the conti@748: * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) conti@748: * conti@748: */ conti@748: conti@748: /* conti@748: * create_enumtype_conversion_functions_c generates ST conversion functions source code for conti@748: * enumerate user defined data types. conti@748: * conti@748: */ conti@748: conti@748: #ifndef _CREATE_ENUMTYPE_CONVERSION_FUNCTIONS_HH conti@748: #define _CREATE_ENUMTYPE_CONVERSION_FUNCTIONS_HH conti@748: conti@748: #include conti@748: #include conti@748: conti@748: #include "../absyntax_utils/absyntax_utils.hh" conti@748: conti@748: conti@748: class create_enumtype_conversion_functions_c: public iterator_visitor_c { msousa@756: private: msousa@756: static create_enumtype_conversion_functions_c *singleton; msousa@756: conti@748: public: conti@748: explicit create_enumtype_conversion_functions_c(symbol_c *ignore); conti@748: virtual ~create_enumtype_conversion_functions_c(void); msousa@756: static std::string &get_declaration(symbol_c *symbol); conti@748: mjsousa@958: void *visit( identifier_c *symbol); mjsousa@958: void *visit( poutype_identifier_c *symbol); mjsousa@958: void *visit(derived_datatype_identifier_c *symbol); mjsousa@958: conti@748: /**********************/ conti@748: /* B 1.3 - Data types */ conti@748: /**********************/ conti@748: /********************************/ conti@748: /* B 1.3.3 - Derived data types */ conti@748: /********************************/ conti@748: void *visit(enumerated_type_declaration_c *symbol); conti@748: void *visit(enumerated_value_list_c *symbol); conti@748: conti@748: private: conti@748: std::string text; conti@748: std::string currentToken; conti@748: std::list currentTokenList; conti@748: std::string getIntegerName(bool isSigned, size_t size); conti@748: void printStringToEnum (std::string &enumerateName, std::list &enumerateValues); conti@748: void printEnumToString (std::string &enumerateName, std::list &enumerateValues); conti@748: void printIntegerToEnum (std::string &enumerateName, std::list &enumerateValues, bool isSigned, size_t size); conti@748: void printEnumToInteger (std::string &enumerateName, std::list &enumerateValues, bool isSigned, size_t size); conti@748: }; conti@748: conti@748: #endif /* _CREATE_ENUMTYPE_CONVERSION_FUNCTIONS_HH */