author | Edouard Tisserant |
Mon, 04 Apr 2011 17:19:35 +0200 | |
changeset 272 | 579db02bebd9 |
parent 265 | 4d222f46f8cc |
child 279 | c0453b7f99df |
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:
181
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:
181
diff
changeset
|
4 |
* Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) |
181 | 5 |
* |
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
6 |
* 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:
181
diff
changeset
|
7 |
* 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:
181
diff
changeset
|
8 |
* 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:
181
diff
changeset
|
9 |
* (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:
181
diff
changeset
|
10 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
11 |
* 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:
181
diff
changeset
|
12 |
* 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:
181
diff
changeset
|
13 |
* 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:
181
diff
changeset
|
14 |
* 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:
181
diff
changeset
|
15 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
16 |
* 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:
181
diff
changeset
|
17 |
* 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:
181
diff
changeset
|
18 |
* |
181 | 19 |
* |
20 |
* This code is made available on the understanding that it will not be |
|
21 |
* used in safety-critical situations without a full and competent review. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
25 |
* An IEC 61131-3 compiler. |
181 | 26 |
* |
27 |
* Based on the |
|
28 |
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
|
29 |
* |
|
30 |
*/ |
|
31 |
||
32 |
||
33 |
/* |
|
34 |
* Separation of type specification and default value constructs |
|
35 |
* (for e.g. simple_spec_init_c), into a type specificiation part, |
|
36 |
* and a default value part. |
|
37 |
*/ |
|
38 |
||
39 |
#include "../absyntax/absyntax.hh" |
|
40 |
#include "../absyntax/visitor.hh" |
|
41 |
||
42 |
class spec_init_sperator_c: public null_visitor_c { |
|
43 |
||
44 |
private: |
|
45 |
/* this is a singleton class... */ |
|
46 |
static spec_init_sperator_c *class_instance; |
|
47 |
static spec_init_sperator_c *get_class_instance(void); |
|
48 |
||
49 |
private: |
|
50 |
typedef enum {search_spec, search_init} search_what_t; |
|
51 |
static search_what_t search_what; |
|
52 |
||
53 |
public: |
|
54 |
/* the only two public functions... */ |
|
55 |
static symbol_c *get_spec(symbol_c *spec_init); |
|
56 |
||
57 |
static symbol_c *get_init(symbol_c *spec_init); |
|
58 |
||
59 |
||
60 |
private: |
|
61 |
||
62 |
||
63 |
/*******************************************/ |
|
64 |
/* B 1.1 - Letters, digits and identifiers */ |
|
65 |
/*******************************************/ |
|
66 |
// SYM_TOKEN(identifier_c) |
|
67 |
void *visit(identifier_c *symbol); |
|
68 |
||
69 |
||
70 |
/********************************/ |
|
71 |
/* B 1.3.3 - Derived data types */ |
|
72 |
/********************************/ |
|
73 |
||
74 |
/* simple_specification ASSIGN constant */ |
|
75 |
void *visit(simple_spec_init_c *symbol); |
|
76 |
||
77 |
/* subrange_specification ASSIGN signed_integer */ |
|
78 |
void *visit(subrange_spec_init_c *symbol); |
|
79 |
||
80 |
/* integer_type_name '(' subrange')' */ |
|
81 |
void *visit(subrange_specification_c *symbol); |
|
82 |
||
83 |
/* array_specification [ASSIGN array_initialization} */ |
|
84 |
/* array_initialization may be NULL ! */ |
|
85 |
void *visit(array_spec_init_c *symbol); |
|
86 |
||
87 |
/* enumerated_specification ASSIGN enumerated_value */ |
|
88 |
void *visit(enumerated_spec_init_c *symbol); |
|
89 |
||
90 |
/* structure_type_name ASSIGN structure_initialization */ |
|
91 |
/* structure_initialization may be NULL ! */ |
|
92 |
//SYM_REF2(initialized_structure_c, structure_type_name, structure_initialization) |
|
93 |
void *visit(initialized_structure_c *symbol); |
|
94 |
||
95 |
||
96 |
/******************************************/ |
|
97 |
/* B 1.4.3 - Declaration & Initialisation */ |
|
98 |
/******************************************/ |
|
99 |
||
100 |
/* fb_name_list ':' function_block_type_name ASSIGN structure_initialization */ |
|
101 |
/* structure_initialization -> may be NULL ! */ |
|
102 |
void *visit(fb_name_decl_c *symbol); |
|
103 |
}; /* class spec_init_sperator_c */ |