author | laurent |
Fri, 02 Sep 2011 18:15:55 +0200 | |
changeset 347 | 44ff2a6fcadc |
parent 279 | c0453b7f99df |
child 382 | ac6dfec701c9 |
permissions | -rwxr-xr-x |
181 | 1 |
/* |
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
238
diff
changeset
|
2 |
* matiec - a compiler for the programming languages defined in IEC 61131-3 |
181 | 3 |
* |
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
238
diff
changeset
|
4 |
* Copyright (C) 2003-2011 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 |
181 | 6 |
* |
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
238
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:
238
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:
238
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:
238
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:
238
diff
changeset
|
11 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
238
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:
238
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:
238
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:
238
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:
238
diff
changeset
|
16 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
238
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:
238
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:
238
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:
238
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 |
||
34 |
||
35 |
/* Decomposes a variable instance name into its constituents, |
|
36 |
* example: |
|
37 |
* window.points[1].coordinate.x |
|
38 |
* |
|
39 |
* will succesfully return |
|
40 |
* - window |
|
41 |
* - points |
|
42 |
* - coordinate |
|
43 |
* - x |
|
44 |
* on succesive calls to decompose_var_instance_name_c::next_part() |
|
45 |
*/ |
|
46 |
||
47 |
||
48 |
||
49 |
#include "../absyntax/visitor.hh" |
|
50 |
||
51 |
||
52 |
||
53 |
class decompose_var_instance_name_c: null_visitor_c { |
|
54 |
||
55 |
private: |
|
56 |
symbol_c *variable_name; |
|
57 |
symbol_c *next_variable_name; |
|
58 |
symbol_c *current_recursive_variable_name; |
|
59 |
symbol_c *previously_returned_variable_name; |
|
60 |
||
61 |
public: |
|
62 |
decompose_var_instance_name_c(symbol_c *variable_instance_name); |
|
63 |
||
238
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
202
diff
changeset
|
64 |
symbol_c *next_part(bool increment = true); |
181 | 65 |
|
66 |
private: |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
67 |
/*************************/ |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
68 |
/* B.1 - Common elements */ |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
69 |
/*************************/ |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
70 |
/*******************************************/ |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
71 |
/* B 1.1 - Letters, digits and identifiers */ |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
72 |
/*******************************************/ |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
73 |
void *visit(identifier_c *symbol); |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
74 |
|
181 | 75 |
/*********************/ |
76 |
/* B 1.4 - Variables */ |
|
77 |
/*********************/ |
|
78 |
void *visit(symbolic_variable_c *symbol); |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
79 |
|
181 | 80 |
/********************************************/ |
81 |
/* B.1.4.1 Directly Represented Variables */ |
|
82 |
/********************************************/ |
|
83 |
void *visit(direct_variable_c *symbol); |
|
84 |
||
85 |
/*************************************/ |
|
86 |
/* B.1.4.2 Multi-element Variables */ |
|
87 |
/*************************************/ |
|
88 |
/* subscripted_variable '[' subscript_list ']' */ |
|
89 |
// SYM_REF2(array_variable_c, subscripted_variable, subscript_list) |
|
90 |
void *visit(array_variable_c *symbol); |
|
91 |
||
92 |
/* record_variable '.' field_selector */ |
|
93 |
/* WARNING: input and/or output variables of function blocks |
|
94 |
* may be accessed as fields of a tructured variable! |
|
95 |
* Code handling a structured_variable_c must take |
|
96 |
* this into account! |
|
97 |
*/ |
|
98 |
//SYM_REF2(structured_variable_c, record_variable, field_selector) |
|
99 |
void *visit(structured_variable_c *symbol); |
|
100 |
||
101 |
}; // decompose_var_instance_name_c |
|
102 |
||
103 |
||
104 |
||
105 |