1 /* |
|
2 * matiec - a compiler for the programming languages defined in IEC 61131-3 |
|
3 * |
|
4 * Copyright (C) 2009-2012 Mario de Sousa (msousa@fe.up.pt) |
|
5 * Copyright (C) 2012 Manuele Conti (conti.ma@alice.it) |
|
6 * |
|
7 * |
|
8 * This program is free software: you can redistribute it and/or modify |
|
9 * it under the terms of the GNU General Public License as published by |
|
10 * the Free Software Foundation, either version 3 of the License, or |
|
11 * (at your option) any later version. |
|
12 * |
|
13 * This program is distributed in the hope that it will be useful, |
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 * GNU General Public License for more details. |
|
17 * |
|
18 * You should have received a copy of the GNU General Public License |
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20 * |
|
21 * |
|
22 * This code is made available on the understanding that it will not be |
|
23 * used in safety-critical situations without a full and competent review. |
|
24 */ |
|
25 |
|
26 /* |
|
27 * An IEC 61131-3 compiler. |
|
28 * |
|
29 * Based on the |
|
30 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
|
31 * |
|
32 */ |
|
33 |
|
34 #ifndef _DERIVED_CONVERSION_FUNCTIONS_HH |
|
35 #define _DERIVED_CONVERSION_FUNCTIONS_HH |
|
36 |
|
37 #include <string> |
|
38 #include <list> |
|
39 |
|
40 #include "../absyntax_utils/absyntax_utils.hh" |
|
41 |
|
42 |
|
43 class derived_conversion_functions_c: public iterator_visitor_c { |
|
44 public: |
|
45 explicit derived_conversion_functions_c(symbol_c *ignore); |
|
46 virtual ~derived_conversion_functions_c(void); |
|
47 std::string &get_declaration(symbol_c *root); |
|
48 |
|
49 const static char *functionDataType []; |
|
50 |
|
51 void *visit(identifier_c *symbol); |
|
52 /**********************/ |
|
53 /* B 1.3 - Data types */ |
|
54 /**********************/ |
|
55 /********************************/ |
|
56 /* B 1.3.3 - Derived data types */ |
|
57 /********************************/ |
|
58 void *visit(enumerated_type_declaration_c *symbol); |
|
59 void *visit(enumerated_value_list_c *symbol); |
|
60 |
|
61 private: |
|
62 std::string text; |
|
63 std::string currentToken; |
|
64 std::list <std::string> currentTokenList; |
|
65 std::string getIntegerName(bool isSigned, size_t size); |
|
66 void printStringToEnum (std::string &enumerateName, std::list <std::string> &enumerateValues); |
|
67 void printEnumToString (std::string &enumerateName, std::list <std::string> &enumerateValues); |
|
68 void printIntegerToEnum (std::string &enumerateName, std::list <std::string> &enumerateValues, bool isSigned, size_t size); |
|
69 void printEnumToInteger (std::string &enumerateName, std::list <std::string> &enumerateValues, bool isSigned, size_t size); |
|
70 }; |
|
71 |
|
72 #endif /* _DERIVED_CONVERSION_FUNCTIONS_H */ |
|