author | Edouard Tisserant |
Wed, 24 Nov 2021 08:58:58 +0100 | |
changeset 1095 | 36bbd0b64816 |
parent 1016 | 91bef6704b44 |
permissions | -rw-r--r-- |
181 | 1 |
/* |
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
2 |
* matiec - a compiler for the programming languages defined in IEC 61131-3 |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
3 |
* |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
377
diff
changeset
|
4 |
* Copyright (C) 2003-2012 Mario de Sousa (msousa@fe.up.pt) |
279
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
265
diff
changeset
|
5 |
* Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant |
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
6 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
7 |
* This program is free software: you can redistribute it and/or modify |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
8 |
* it under the terms of the GNU General Public License as published by |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
9 |
* the Free Software Foundation, either version 3 of the License, or |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
10 |
* (at your option) any later version. |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
11 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
12 |
* This program is distributed in the hope that it will be useful, |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
15 |
* GNU General Public License for more details. |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
16 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
19 |
* |
181 | 20 |
* |
21 |
* This code is made available on the understanding that it will not be |
|
22 |
* used in safety-critical situations without a full and competent review. |
|
23 |
*/ |
|
24 |
||
25 |
/* |
|
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
26 |
* An IEC 61131-3 compiler. |
181 | 27 |
* |
28 |
* Based on the |
|
29 |
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
|
30 |
* |
|
31 |
*/ |
|
32 |
||
33 |
||
858
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
34 |
/* Determine the data type on which another data type is based on. */ |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
35 |
|
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
36 |
/* |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
37 |
* What is a Base Type? |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
38 |
* A base type is the fundamental data type from which the type is derived. |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
39 |
* The main idea is that if two datatyes (A and B) share a common base type, |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
40 |
* then these two datatypes may be used interchangeably in an expression. |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
41 |
* |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
42 |
* What is an Equivalent Type? |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
43 |
* An equivalent type is the data type from which the type is derived. |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
44 |
* The Base type and the Equivalent type will always be the same, with the |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
45 |
* exception of subranges! |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
46 |
* |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
47 |
* E.g. TYPE new_int_t : INT; END_TYPE; |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
48 |
* TYPE new_int2_t : INT := 2; END_TYPE; |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
49 |
* TYPE new_int3_t : new_int2_t := 3; END_TYPE; |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
50 |
* TYPE new_sub_t : INT (4..10); END_TYPE; |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
51 |
* TYPE new_sub2_t : new_sub_t := 5 ; END_TYPE; |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
52 |
* TYPE new_sub3_t : new_sub2_t := 6 ; END_TYPE; |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
53 |
* TYPE new_sub4_t : new_int3_t (4..10); END_TYPE; <----- This is NOT legal syntax! |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
54 |
* |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
55 |
* new_int_t : base type->INT equivalent type->INT |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
56 |
* new_int2_t : base type->INT equivalent type->INT |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
57 |
* new_int3_t : base type->INT equivalent type->INT |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
58 |
* new_sub_t : base type->INT equivalent type->new_sub_t |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
59 |
* new_sub2_t : base type->INT equivalent type->new_sub_t |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
60 |
* new_sub3_t : base type->INT equivalent type->new_sub_t |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
61 |
* |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
62 |
* Note too that a FB declaration is also considered a base type, as |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
63 |
* we may have FB instances declared of a specific FB type. |
181 | 64 |
*/ |
65 |
||
66 |
||
67 |
class search_base_type_c: public null_visitor_c { |
|
68 |
||
69 |
private: |
|
858
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
70 |
symbol_c *current_basetype_name; |
726
9b61eb4f00dc
Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents:
718
diff
changeset
|
71 |
symbol_c *current_basetype; |
858
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
72 |
symbol_c *current_equivtype; |
718
a9f8cc778444
Make search_base_type_c a singleton!
Mario de Sousa <msousa@fe.up.pt>
parents:
625
diff
changeset
|
73 |
static search_base_type_c *search_base_type_singleton; // Make this a singleton class! |
a9f8cc778444
Make search_base_type_c a singleton!
Mario de Sousa <msousa@fe.up.pt>
parents:
625
diff
changeset
|
74 |
|
a9f8cc778444
Make search_base_type_c a singleton!
Mario de Sousa <msousa@fe.up.pt>
parents:
625
diff
changeset
|
75 |
private: |
a9f8cc778444
Make search_base_type_c a singleton!
Mario de Sousa <msousa@fe.up.pt>
parents:
625
diff
changeset
|
76 |
static void create_singleton(void); |
945
477393b00f95
Add support for relaxed datatype model for array datatypes.
mjsousa
parents:
921
diff
changeset
|
77 |
void *handle_datatype_identifier(token_c *type_name); |
181 | 78 |
|
79 |
public: |
|
80 |
search_base_type_c(void); |
|
858
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
81 |
static symbol_c *get_equivtype_decl(symbol_c *symbol); /* get the Equivalent Type declaration */ |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
82 |
static symbol_c *get_basetype_decl (symbol_c *symbol); /* get the Base Type declaration */ |
c5f145364a4f
Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents:
854
diff
changeset
|
83 |
static symbol_c *get_basetype_id (symbol_c *symbol); /* get the Base Type identifier */ |
181 | 84 |
|
85 |
public: |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
377
diff
changeset
|
86 |
/*************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
377
diff
changeset
|
87 |
/* B.1 - Common elements */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
377
diff
changeset
|
88 |
/*************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
377
diff
changeset
|
89 |
/*******************************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
377
diff
changeset
|
90 |
/* B 1.1 - Letters, digits and identifiers */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
377
diff
changeset
|
91 |
/*******************************************/ |
945
477393b00f95
Add support for relaxed datatype model for array datatypes.
mjsousa
parents:
921
diff
changeset
|
92 |
void *visit( identifier_c *type_name); |
477393b00f95
Add support for relaxed datatype model for array datatypes.
mjsousa
parents:
921
diff
changeset
|
93 |
void *visit(derived_datatype_identifier_c *type_name); |
958
7474d2cd1d6e
Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents:
945
diff
changeset
|
94 |
void *visit( poutype_identifier_c *type_name); |
7474d2cd1d6e
Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents:
945
diff
changeset
|
95 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
377
diff
changeset
|
96 |
/*********************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
377
diff
changeset
|
97 |
/* B 1.2 - Constants */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
377
diff
changeset
|
98 |
/*********************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
377
diff
changeset
|
99 |
/******************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
377
diff
changeset
|
100 |
/* B 1.2.1 - Numeric Literals */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
377
diff
changeset
|
101 |
/******************************/ |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
102 |
/* Numeric literals without any explicit type cast have unknown data type, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
103 |
* so we continue considering them as their own basic data types until |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
104 |
* they can be resolved (for example, when using '30+x' where 'x' is a LINT variable, the |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
105 |
* numeric literal '30' must then be considered a LINT so the ADD function may be called |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
106 |
* with all inputs of the same data type. |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
107 |
* If 'x' were a SINT, then the '30' would have to be a SINT too! |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
108 |
*/ |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
109 |
void *visit(real_c *symbol); |
257 | 110 |
void *visit(neg_real_c *symbol); |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
111 |
void *visit(integer_c *symbol); |
257 | 112 |
void *visit(neg_integer_c *symbol); |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
113 |
void *visit(binary_integer_c *symbol); |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
114 |
void *visit(octal_integer_c *symbol); |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
115 |
void *visit(hex_integer_c *symbol); |
257 | 116 |
void *visit(boolean_true_c *symbol); |
117 |
void *visit(boolean_false_c *symbol); |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
118 |
|
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
119 |
|
181 | 120 |
/***********************************/ |
121 |
/* B 1.3.1 - Elementary Data Types */ |
|
122 |
/***********************************/ |
|
123 |
void *visit(time_type_name_c *symbol); |
|
124 |
void *visit(bool_type_name_c *symbol); |
|
125 |
void *visit(sint_type_name_c *symbol); |
|
126 |
void *visit(int_type_name_c *symbol); |
|
127 |
void *visit(dint_type_name_c *symbol); |
|
128 |
void *visit(lint_type_name_c *symbol); |
|
129 |
void *visit(usint_type_name_c *symbol); |
|
130 |
void *visit(uint_type_name_c *symbol); |
|
131 |
void *visit(udint_type_name_c *symbol); |
|
132 |
void *visit(ulint_type_name_c *symbol); |
|
133 |
void *visit(real_type_name_c *symbol); |
|
134 |
void *visit(lreal_type_name_c *symbol); |
|
135 |
void *visit(date_type_name_c *symbol); |
|
136 |
void *visit(tod_type_name_c *symbol); |
|
706
31553c22f318
Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents:
625
diff
changeset
|
137 |
void *visit(dt_type_name_c *symbol); |
181 | 138 |
void *visit(byte_type_name_c *symbol); |
139 |
void *visit(word_type_name_c *symbol); |
|
140 |
void *visit(dword_type_name_c *symbol); |
|
141 |
void *visit(lword_type_name_c *symbol); |
|
142 |
void *visit(string_type_name_c *symbol); |
|
143 |
void *visit(wstring_type_name_c *symbol); |
|
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
144 |
void *visit(void_type_name_c *symbol); /* A non standard datatype! */ |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
145 |
|
181 | 146 |
/******************************************************/ |
147 |
/* Extensions to the base standard as defined in */ |
|
148 |
/* "Safety Software Technical Specification, */ |
|
149 |
/* Part 1: Concepts and Function Blocks, */ |
|
150 |
/* Version 1.0 – Official Release" */ |
|
151 |
/* by PLCopen - Technical Committee 5 - 2006-01-31 */ |
|
152 |
/******************************************************/ |
|
257 | 153 |
void *visit(safetime_type_name_c *symbol); |
181 | 154 |
void *visit(safebool_type_name_c *symbol); |
257 | 155 |
void *visit(safesint_type_name_c *symbol); |
156 |
void *visit(safeint_type_name_c *symbol); |
|
157 |
void *visit(safedint_type_name_c *symbol); |
|
158 |
void *visit(safelint_type_name_c *symbol); |
|
159 |
void *visit(safeusint_type_name_c *symbol); |
|
160 |
void *visit(safeuint_type_name_c *symbol); |
|
161 |
void *visit(safeudint_type_name_c *symbol); |
|
162 |
void *visit(safeulint_type_name_c *symbol); |
|
163 |
void *visit(safereal_type_name_c *symbol); |
|
164 |
void *visit(safelreal_type_name_c *symbol); |
|
165 |
void *visit(safedate_type_name_c *symbol); |
|
166 |
void *visit(safetod_type_name_c *symbol); |
|
706
31553c22f318
Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents:
625
diff
changeset
|
167 |
void *visit(safedt_type_name_c *symbol); |
257 | 168 |
void *visit(safebyte_type_name_c *symbol); |
169 |
void *visit(safeword_type_name_c *symbol); |
|
170 |
void *visit(safedword_type_name_c *symbol); |
|
171 |
void *visit(safelword_type_name_c *symbol); |
|
172 |
void *visit(safestring_type_name_c *symbol); |
|
173 |
void *visit(safewstring_type_name_c *symbol); |
|
181 | 174 |
|
175 |
/********************************/ |
|
921
d228aaa4d616
Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents:
919
diff
changeset
|
176 |
/* B.1.3.2 - Generic data types */ |
d228aaa4d616
Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents:
919
diff
changeset
|
177 |
/********************************/ |
d228aaa4d616
Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents:
919
diff
changeset
|
178 |
void *visit(generic_type_any_c *symbol); |
d228aaa4d616
Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents:
919
diff
changeset
|
179 |
|
d228aaa4d616
Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents:
919
diff
changeset
|
180 |
/********************************/ |
181 | 181 |
/* B 1.3.3 - Derived data types */ |
182 |
/********************************/ |
|
183 |
/* simple_type_name ':' simple_spec_init */ |
|
184 |
void *visit(simple_type_declaration_c *symbol); |
|
185 |
/* simple_specification ASSIGN constant */ |
|
186 |
void *visit(simple_spec_init_c *symbol); |
|
187 |
/* subrange_type_name ':' subrange_spec_init */ |
|
188 |
void *visit(subrange_type_declaration_c *symbol); |
|
189 |
/* subrange_specification ASSIGN signed_integer */ |
|
190 |
void *visit(subrange_spec_init_c *symbol); |
|
191 |
/* integer_type_name '(' subrange')' */ |
|
192 |
void *visit(subrange_specification_c *symbol); |
|
193 |
/* signed_integer DOTDOT signed_integer */ |
|
194 |
void *visit(subrange_c *symbol); |
|
195 |
||
196 |
/* enumerated_type_name ':' enumerated_spec_init */ |
|
197 |
void *visit(enumerated_type_declaration_c *symbol); |
|
198 |
/* enumerated_specification ASSIGN enumerated_value */ |
|
199 |
void *visit(enumerated_spec_init_c *symbol); |
|
200 |
/* helper symbol for enumerated_specification->enumerated_spec_init */ |
|
201 |
/* enumerated_value_list ',' enumerated_value */ |
|
202 |
void *visit(enumerated_value_list_c *symbol); |
|
203 |
/* enumerated_type_name '#' identifier */ |
|
204 |
// SYM_REF2(enumerated_value_c, type, value) |
|
205 |
void *visit(enumerated_value_c *symbol); |
|
206 |
/* identifier ':' array_spec_init */ |
|
207 |
void *visit(array_type_declaration_c *symbol); |
|
208 |
/* array_specification [ASSIGN array_initialization} */ |
|
209 |
/* array_initialization may be NULL ! */ |
|
210 |
void *visit(array_spec_init_c *symbol); |
|
211 |
/* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */ |
|
212 |
void *visit(array_specification_c *symbol); |
|
213 |
/* helper symbol for array_specification */ |
|
214 |
/* array_subrange_list ',' subrange */ |
|
215 |
void *visit(array_subrange_list_c *symbol); |
|
216 |
/* array_initialization: '[' array_initial_elements_list ']' */ |
|
217 |
/* helper symbol for array_initialization */ |
|
218 |
/* array_initial_elements_list ',' array_initial_elements */ |
|
219 |
void *visit(array_initial_elements_list_c *symbol); |
|
220 |
/* integer '(' [array_initial_element] ')' */ |
|
221 |
/* array_initial_element may be NULL ! */ |
|
222 |
void *visit(array_initial_elements_c *symbol); |
|
223 |
/* structure_type_name ':' structure_specification */ |
|
224 |
/* NOTE: structure_specification will point to either a |
|
225 |
* initialized_structure_c |
|
226 |
* OR A |
|
227 |
* structure_element_declaration_list_c |
|
228 |
*/ |
|
229 |
void *visit(structure_type_declaration_c *symbol); |
|
412
aad38592bdde
Fix bug with InOut variable of structured type
Laurent Bessard
parents:
377
diff
changeset
|
230 |
/* var1_list ':' structure_type_name */ |
aad38592bdde
Fix bug with InOut variable of structured type
Laurent Bessard
parents:
377
diff
changeset
|
231 |
void *visit(structured_var_declaration_c *symbol); |
181 | 232 |
/* structure_type_name ASSIGN structure_initialization */ |
233 |
/* structure_initialization may be NULL ! */ |
|
234 |
void *visit(initialized_structure_c *symbol); |
|
235 |
/* helper symbol for structure_declaration */ |
|
236 |
/* structure_declaration: STRUCT structure_element_declaration_list END_STRUCT */ |
|
237 |
/* structure_element_declaration_list structure_element_declaration ';' */ |
|
238 |
void *visit(structure_element_declaration_list_c *symbol); |
|
239 |
/* structure_element_name ':' *_spec_init */ |
|
240 |
void *visit(structure_element_declaration_c *symbol); |
|
241 |
/* helper symbol for structure_initialization */ |
|
242 |
/* structure_initialization: '(' structure_element_initialization_list ')' */ |
|
243 |
/* structure_element_initialization_list ',' structure_element_initialization */ |
|
244 |
void *visit(structure_element_initialization_list_c *symbol); |
|
245 |
/* structure_element_name ASSIGN value */ |
|
246 |
void *visit(structure_element_initialization_c *symbol); |
|
247 |
/* string_type_name ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init */ |
|
248 |
/* |
|
706
31553c22f318
Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents:
625
diff
changeset
|
249 |
SYM_REF4(string_type_declaration_c, string_type_name, |
181 | 250 |
elementary_string_type_name, |
251 |
string_type_declaration_size, |
|
252 |
string_type_declaration_init) // may be == NULL! |
|
253 |
*/ |
|
254 |
void *visit(string_type_declaration_c *symbol); |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
255 |
|
810
d9c48ad646f1
Add a new node to the abstract symtax tree, which will let us do datatype checking of FB variable declarations using the standard algorithm, and no special cases.
Mario de Sousa <msousa@fe.up.pt>
parents:
808
diff
changeset
|
256 |
/* function_block_type_name ASSIGN structure_initialization */ |
808
7a6b53d61ea3
Consider fb_name_decl_c a non base data type class!
Mario de Sousa <msousa@fe.up.pt>
parents:
793
diff
changeset
|
257 |
/* structure_initialization -> may be NULL ! */ |
810
d9c48ad646f1
Add a new node to the abstract symtax tree, which will let us do datatype checking of FB variable declarations using the standard algorithm, and no special cases.
Mario de Sousa <msousa@fe.up.pt>
parents:
808
diff
changeset
|
258 |
void *visit(fb_spec_init_c *symbol); |
808
7a6b53d61ea3
Consider fb_name_decl_c a non base data type class!
Mario de Sousa <msousa@fe.up.pt>
parents:
793
diff
changeset
|
259 |
|
909
8b2a31dea131
Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents:
858
diff
changeset
|
260 |
/* REF_TO (non_generic_type_name | function_block_type_name) */ |
8b2a31dea131
Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents:
858
diff
changeset
|
261 |
void *visit(ref_spec_c *symbol); // Defined in IEC 61131-3 v3 |
8b2a31dea131
Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents:
858
diff
changeset
|
262 |
/* ref_spec [ ASSIGN ref_initialization ]; *//* NOTE: ref_initialization may be NULL!! */ |
8b2a31dea131
Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents:
858
diff
changeset
|
263 |
void *visit(ref_spec_init_c *symbol); // Defined in IEC 61131-3 v3 |
8b2a31dea131
Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents:
858
diff
changeset
|
264 |
/* identifier ':' ref_spec_init */ |
8b2a31dea131
Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents:
858
diff
changeset
|
265 |
void *visit(ref_type_decl_c *symbol); // Defined in IEC 61131-3 v3 |
8b2a31dea131
Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents:
858
diff
changeset
|
266 |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
267 |
/*****************************/ |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
268 |
/* B 1.5.2 - Function Blocks */ |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
269 |
/*****************************/ |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
270 |
/* FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */ |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
271 |
// SYM_REF3(function_block_declaration_c, fblock_name, var_declarations, fblock_body) |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
272 |
void *visit(function_block_declaration_c *symbol); |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
194
diff
changeset
|
273 |
|
619
f8c9ac5c529a
Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
274 |
/*********************************************/ |
f8c9ac5c529a
Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
275 |
/* B.1.6 Sequential function chart elements */ |
f8c9ac5c529a
Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
276 |
/*********************************************/ |
f8c9ac5c529a
Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
277 |
/* INITIAL_STEP step_name ':' action_association_list END_STEP */ |
f8c9ac5c529a
Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
278 |
// SYM_REF2(initial_step_c, step_name, action_association_list) |
f8c9ac5c529a
Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
279 |
void *visit(initial_step_c *symbol); |
f8c9ac5c529a
Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
280 |
|
f8c9ac5c529a
Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
281 |
/* STEP step_name ':' action_association_list END_STEP */ |
f8c9ac5c529a
Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
282 |
// SYM_REF2(step_c, step_name, action_association_list) |
f8c9ac5c529a
Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
283 |
void *visit(step_c *symbol); |
f8c9ac5c529a
Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
284 |
|
f8c9ac5c529a
Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
285 |
|
181 | 286 |
}; // search_base_type_c |
287 |
||
288 |
||
289 |
||
290 |