|
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_H |
|
35 #define _DERIVED_CONVERSION_FUNCTIONS_H |
|
36 |
|
37 #include "../absyntax_utils/absyntax_utils.hh" |
|
38 #include <string> |
|
39 #include <list> |
|
40 |
|
41 class derived_conversion_functions_c: public iterator_visitor_c { |
|
42 public: |
|
43 explicit derived_conversion_functions_c(symbol_c *ignore); |
|
44 virtual ~derived_conversion_functions_c(void); |
|
45 std::string &get_declaration(symbol_c *root); |
|
46 |
|
47 void *visit(identifier_c *symbol); |
|
48 /**********************/ |
|
49 /* B 1.3 - Data types */ |
|
50 /**********************/ |
|
51 /********************************/ |
|
52 /* B 1.3.3 - Derived data types */ |
|
53 /********************************/ |
|
54 void *visit(enumerated_type_declaration_c *symbol); |
|
55 void *visit(enumerated_value_list_c *symbol); |
|
56 |
|
57 private: |
|
58 std::string text; |
|
59 std::string currentToken; |
|
60 std::list< std::string> currentTokenList; |
|
61 std::string getIntegerName(bool isSigned, size_t size); |
|
62 void printStringToEnum (std::string &enumerateName, std::list<std::string> &enumerateValues); |
|
63 void printEnumToString (std::string &enumerateName, std::list<std::string> &enumerateValues); |
|
64 void printIntegerToEnum (std::string &enumerateName, std::list<std::string> &enumerateValues, bool isSigned, size_t size); |
|
65 void printEnumToInteger (std::string &enumerateName, std::list<std::string> &enumerateValues, bool isSigned, size_t size); |
|
66 }; |
|
67 |
|
68 #endif /* _DERIVED_CONVERSION_FUNCTIONS_H */ |