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