1 /* |
1 /* |
2 * (c) 2003 Mario de Sousa |
2 * matiec - a compiler for the programming languages defined in IEC 61131-3 |
3 * |
3 * |
4 * Offered to the public under the terms of the GNU General Public License |
4 * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) |
5 * as published by the Free Software Foundation; either version 2 of the |
|
6 * License, or (at your option) any later version. |
|
7 * |
5 * |
8 * This program is distributed in the hope that it will be useful, but |
6 * This program is free software: you can redistribute it and/or modify |
9 * WITHOUT ANY WARRANTY; without even the implied warranty of |
7 * it under the terms of the GNU General Public License as published by |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
8 * the Free Software Foundation, either version 3 of the License, or |
11 * Public License for more details. |
9 * (at your option) any later version. |
|
10 * |
|
11 * This program is distributed in the hope that it will be useful, |
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 * GNU General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU General Public License |
|
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
18 * |
12 * |
19 * |
13 * This code is made available on the understanding that it will not be |
20 * This code is made available on the understanding that it will not be |
14 * used in safety-critical situations without a full and competent review. |
21 * used in safety-critical situations without a full and competent review. |
15 */ |
22 */ |
16 |
23 |
17 /* |
24 /* |
18 * An IEC 61131-3 IL and ST compiler. |
25 * An IEC 61131-3 compiler. |
19 * |
26 * |
20 * Based on the |
27 * Based on the |
21 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
28 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
22 * |
29 * |
23 */ |
30 */ |
65 static ulint_type_name_c ulint_type_name; |
72 static ulint_type_name_c ulint_type_name; |
66 static bool_type_name_c bool_type_name; |
73 static bool_type_name_c bool_type_name; |
67 static time_type_name_c time_type_name; |
74 static time_type_name_c time_type_name; |
68 static int_type_name_c int_type_name; |
75 static int_type_name_c int_type_name; |
69 |
76 |
70 /* |
|
71 static constant_real_type_name_c constant_real_type_name; |
|
72 static constant_int_type_name_c constant_int_type_name; |
|
73 */ |
|
74 /* temporarily here until we remove the st_code_gen.c and il_code_gen.c files... */ |
77 /* temporarily here until we remove the st_code_gen.c and il_code_gen.c files... */ |
75 static integer_c integer; |
78 static integer_c integer; |
76 |
79 |
77 /******************************************************/ |
80 /******************************************************/ |
78 /* Extensions to the base standard as defined in */ |
81 /* Extensions to the base standard as defined in */ |
79 /* "Safety Software Technical Specification, */ |
82 /* "Safety Software Technical Specification, */ |
80 /* Part 1: Concepts and Function Blocks, */ |
83 /* Part 1: Concepts and Function Blocks, */ |
81 /* Version 1.0 – Official Release" */ |
84 /* Version 1.0 – Official Release" */ |
82 /* by PLCopen - Technical Committee 5 - 2006-01-31 */ |
85 /* by PLCopen - Technical Committee 5 - 2006-01-31 */ |
83 /******************************************************/ |
86 /******************************************************/ |
84 static safebool_type_name_c safebool_type_name; |
87 |
|
88 // static safebool_type_name_c safebool_type_name; |
|
89 /* The following is required because the expression (TOD_var - TOD_var) will result in a data type |
|
90 * (in this case, TIME) that is neither of the expression elements... |
|
91 */ |
|
92 static safetime_type_name_c safetime_type_name; |
|
93 static safetod_type_name_c safetod_type_name; |
|
94 static safedt_type_name_c safedt_type_name; |
|
95 |
85 |
96 |
86 |
97 |
87 public: |
98 public: |
88 symbol_c *get_type(symbol_c *constant); |
99 symbol_c *get_type(symbol_c *constant); |
89 |
100 |
95 |
106 |
96 /******************************/ |
107 /******************************/ |
97 /* B 1.2.1 - Numeric Literals */ |
108 /* B 1.2.1 - Numeric Literals */ |
98 /******************************/ |
109 /******************************/ |
99 void *visit(real_c *symbol); |
110 void *visit(real_c *symbol); |
|
111 void *visit(neg_real_c *symbol); |
100 void *visit(integer_c *symbol); |
112 void *visit(integer_c *symbol); |
|
113 void *visit(neg_integer_c *symbol); |
101 void *visit(binary_integer_c *symbol); |
114 void *visit(binary_integer_c *symbol); |
102 void *visit(octal_integer_c *symbol); |
115 void *visit(octal_integer_c *symbol); |
103 void *visit(hex_integer_c *symbol); |
116 void *visit(hex_integer_c *symbol); |
104 |
117 |
105 void *visit(integer_literal_c *symbol); |
118 void *visit(integer_literal_c *symbol); |