181
|
1 |
/*
|
|
2 |
* (c) 2003 Mario de Sousa
|
|
3 |
*
|
|
4 |
* Offered to the public under the terms of the GNU General Public License
|
|
5 |
* as published by the Free Software Foundation; either version 2 of the
|
|
6 |
* License, or (at your option) any later version.
|
|
7 |
*
|
|
8 |
* This program is distributed in the hope that it will be useful, but
|
|
9 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
11 |
* Public License for more details.
|
|
12 |
*
|
|
13 |
* 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.
|
|
15 |
*/
|
|
16 |
|
|
17 |
/*
|
|
18 |
* An IEC 61131-3 IL and ST compiler.
|
|
19 |
*
|
|
20 |
* Based on the
|
|
21 |
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
|
|
26 |
/*
|
|
27 |
* Separation of type specification and default value constructs
|
|
28 |
* (for e.g. simple_spec_init_c), into a type specificiation part,
|
|
29 |
* and a default value part.
|
|
30 |
*/
|
|
31 |
|
|
32 |
#include "../absyntax/absyntax.hh"
|
|
33 |
#include "../absyntax/visitor.hh"
|
|
34 |
|
|
35 |
class spec_init_sperator_c: public null_visitor_c {
|
|
36 |
|
|
37 |
private:
|
|
38 |
/* this is a singleton class... */
|
|
39 |
static spec_init_sperator_c *class_instance;
|
|
40 |
static spec_init_sperator_c *get_class_instance(void);
|
|
41 |
|
|
42 |
private:
|
|
43 |
typedef enum {search_spec, search_init} search_what_t;
|
|
44 |
static search_what_t search_what;
|
|
45 |
|
|
46 |
public:
|
|
47 |
/* the only two public functions... */
|
|
48 |
static symbol_c *get_spec(symbol_c *spec_init);
|
|
49 |
|
|
50 |
static symbol_c *get_init(symbol_c *spec_init);
|
|
51 |
|
|
52 |
|
|
53 |
private:
|
|
54 |
|
|
55 |
|
|
56 |
/*******************************************/
|
|
57 |
/* B 1.1 - Letters, digits and identifiers */
|
|
58 |
/*******************************************/
|
|
59 |
// SYM_TOKEN(identifier_c)
|
|
60 |
void *visit(identifier_c *symbol);
|
|
61 |
|
|
62 |
|
|
63 |
/********************************/
|
|
64 |
/* B 1.3.3 - Derived data types */
|
|
65 |
/********************************/
|
|
66 |
|
|
67 |
/* simple_specification ASSIGN constant */
|
|
68 |
void *visit(simple_spec_init_c *symbol);
|
|
69 |
|
|
70 |
/* subrange_specification ASSIGN signed_integer */
|
|
71 |
void *visit(subrange_spec_init_c *symbol);
|
|
72 |
|
|
73 |
/* integer_type_name '(' subrange')' */
|
|
74 |
void *visit(subrange_specification_c *symbol);
|
|
75 |
|
|
76 |
/* array_specification [ASSIGN array_initialization} */
|
|
77 |
/* array_initialization may be NULL ! */
|
|
78 |
void *visit(array_spec_init_c *symbol);
|
|
79 |
|
|
80 |
/* enumerated_specification ASSIGN enumerated_value */
|
|
81 |
void *visit(enumerated_spec_init_c *symbol);
|
|
82 |
|
|
83 |
/* structure_type_name ASSIGN structure_initialization */
|
|
84 |
/* structure_initialization may be NULL ! */
|
|
85 |
//SYM_REF2(initialized_structure_c, structure_type_name, structure_initialization)
|
|
86 |
void *visit(initialized_structure_c *symbol);
|
|
87 |
|
|
88 |
|
|
89 |
/******************************************/
|
|
90 |
/* B 1.4.3 - Declaration & Initialisation */
|
|
91 |
/******************************************/
|
|
92 |
|
|
93 |
/* fb_name_list ':' function_block_type_name ASSIGN structure_initialization */
|
|
94 |
/* structure_initialization -> may be NULL ! */
|
|
95 |
void *visit(fb_name_decl_c *symbol);
|
|
96 |
}; /* class spec_init_sperator_c */
|