simple.cc - generated code example
[prop.git] / include / AD / automata / ebnf.h
blob47a766a25107973c34081afca514cd33c90126d5
1 ///////////////////////////////////////////////////////////////////////////////
2 // This file is generated automatically using Prop (version 2.1.4),
3 // last updated on August 28, 1995.
4 // The original source file is "ebnf.ph".
5 ///////////////////////////////////////////////////////////////////////////////
7 #line 1 "ebnf.ph"
8 //////////////////////////////////////////////////////////////////////////////
9 // NOTICE:
11 // ADLib, Prop and their related set of tools and documentation are in the
12 // public domain. The author(s) of this software reserve no copyrights on
13 // the source code and any code generated using the tools. You are encouraged
14 // to use ADLib and Prop to develop software, in both academic and commercial
15 // settings, and are welcomed to incorporate any part of ADLib and Prop into
16 // your programs.
18 // Although you are under no obligation to do so, we strongly recommend that
19 // you give away all software developed using our tools.
21 // We also ask that credit be given to us when ADLib and/or Prop are used in
22 // your programs, and that this notice be preserved intact in all the source
23 // code.
25 // This software is still under development and we welcome(read crave for)
26 // any suggestions and help from the users.
28 // Allen Leung
29 // 1994
30 //////////////////////////////////////////////////////////////////////////////
32 #ifndef extended_Backus_Naur_form_h
33 #define extended_Backus_Naur_form_h
35 #include <iostream>
36 #include <AD/automata/grammar.h> // grammar
37 #include <AD/memory/mem.h> // memory manager
39 //////////////////////////////////////////////////////////////////////////////
40 // Extended BNF syntax definition
41 //////////////////////////////////////////////////////////////////////////////
42 #line 35 "ebnf.ph"
43 #line 53 "ebnf.ph"
44 ///////////////////////////////////////////////////////////////////////////////
45 // Forward class definition for EBNF
46 ///////////////////////////////////////////////////////////////////////////////
47 #ifndef datatype_EBNF_defined
48 #define datatype_EBNF_defined
49 typedef class a_EBNF * EBNF;
50 #endif
52 ///////////////////////////////////////////////////////////////////////////////
53 // Class hierarchy for datatype EBNF
54 ///////////////////////////////////////////////////////////////////////////////
55 class a_EBNF; // base class for datatype EBNF
56 class EBNF_ebnf_or; // subclass for 'ebnf_or (EBNF, EBNF)'
57 class EBNF_ebnf_dot; // subclass for 'ebnf_dot (EBNF, EBNF)'
58 class EBNF_ebnf_star; // subclass for 'ebnf_star EBNF'
59 class EBNF_ebnf_plus; // subclass for 'ebnf_plus EBNF'
60 class EBNF_ebnf_terminal; // subclass for 'ebnf_terminal Grammar::Terminal'
61 class EBNF_ebnf_nonterminal; // subclass for 'ebnf_nonterminal Grammar::NonTerminal'
62 class EBNF_ebnf_action; // subclass for 'ebnf_action Grammar::Action'
63 class EBNF_syntactic_predicate; // subclass for 'syntactic_predicate EBNF'
64 class EBNF_semantic_predicate; // subclass for 'semantic_predicate EBNF'
66 ///////////////////////////////////////////////////////////////////////////////
67 // Base class for datatype 'EBNF'
68 ///////////////////////////////////////////////////////////////////////////////
69 class a_EBNF {
70 public:
71 enum Tag_EBNF {
72 tag_ebnf_or = 0, tag_ebnf_dot = 1, tag_ebnf_star = 2, tag_ebnf_plus = 3,
73 tag_ebnf_terminal = 4, tag_ebnf_nonterminal = 5, tag_ebnf_action = 6, tag_syntactic_predicate = 7,
74 tag_semantic_predicate = 8
77 protected:
78 const Tag_EBNF _tag_;
79 inline a_EBNF(Tag_EBNF _t_) : _tag_(_t_) {}
80 public:
81 inline int untag() const { return _tag_; }
82 inline friend int boxed(const a_EBNF * x) { return 1; }
83 inline friend int untag(const a_EBNF * x) { return x->_tag_; }
84 ////////////////////////////////////////////////////////////////////////////
85 // Downcasting functions for EBNF
86 ////////////////////////////////////////////////////////////////////////////
87 inline friend EBNF_ebnf_or * _ebnf_or(EBNF _x_) { return (EBNF_ebnf_or *)_x_; }
88 inline friend EBNF_ebnf_dot * _ebnf_dot(EBNF _x_) { return (EBNF_ebnf_dot *)_x_; }
89 inline friend EBNF_ebnf_star * _ebnf_star(EBNF _x_) { return (EBNF_ebnf_star *)_x_; }
90 inline friend EBNF_ebnf_plus * _ebnf_plus(EBNF _x_) { return (EBNF_ebnf_plus *)_x_; }
91 inline friend EBNF_ebnf_terminal * _ebnf_terminal(EBNF _x_) { return (EBNF_ebnf_terminal *)_x_; }
92 inline friend EBNF_ebnf_nonterminal * _ebnf_nonterminal(EBNF _x_) { return (EBNF_ebnf_nonterminal *)_x_; }
93 inline friend EBNF_ebnf_action * _ebnf_action(EBNF _x_) { return (EBNF_ebnf_action *)_x_; }
94 inline friend EBNF_syntactic_predicate * _syntactic_predicate(EBNF _x_) { return (EBNF_syntactic_predicate *)_x_; }
95 inline friend EBNF_semantic_predicate * _semantic_predicate(EBNF _x_) { return (EBNF_semantic_predicate *)_x_; }
96 #line 45 "ebnf.ph"
98 ///////////////////////////////////////////////////////////////////////////
99 // We redefine the memory management operators to allocate from a
100 // memory pool.
101 ///////////////////////////////////////////////////////////////////////////
102 inline void * operator new (size_t n) { return new char [n]; }
103 inline void * operator new (size_t n, Mem& m) { return m.m_alloc(n); }
104 inline void operator delete (void * x) { delete (char*) x; }
105 #line 53 "ebnf.ph"
108 ///////////////////////////////////////////////////////////////////////////////
109 // class for constructor 'EBNF::ebnf_or (EBNF, EBNF)'
110 ///////////////////////////////////////////////////////////////////////////////
111 class EBNF_ebnf_or : public a_EBNF {
112 public:
113 #line 35 "ebnf.ph"
114 EBNF _1; EBNF _2;
115 inline EBNF_ebnf_or (EBNF _x1, EBNF _x2)
116 : a_EBNF(a_EBNF::tag_ebnf_or), _1(_x1), _2(_x2) {}
117 inline friend a_EBNF * ebnf_or (EBNF _x1, EBNF _x2)
118 { return new EBNF_ebnf_or (_x1, _x2); }
121 ///////////////////////////////////////////////////////////////////////////////
122 // class for constructor 'EBNF::ebnf_dot (EBNF, EBNF)'
123 ///////////////////////////////////////////////////////////////////////////////
124 class EBNF_ebnf_dot : public a_EBNF {
125 public:
126 #line 36 "ebnf.ph"
127 EBNF _1; EBNF _2;
128 inline EBNF_ebnf_dot (EBNF _x1, EBNF _x2)
129 : a_EBNF(a_EBNF::tag_ebnf_dot), _1(_x1), _2(_x2) {}
130 inline friend a_EBNF * ebnf_dot (EBNF _x1, EBNF _x2)
131 { return new EBNF_ebnf_dot (_x1, _x2); }
134 ///////////////////////////////////////////////////////////////////////////////
135 // class for constructor 'EBNF::ebnf_star EBNF'
136 ///////////////////////////////////////////////////////////////////////////////
137 class EBNF_ebnf_star : public a_EBNF {
138 public:
139 #line 37 "ebnf.ph"
140 EBNF ebnf_star;
141 inline EBNF_ebnf_star (EBNF _xebnf_star)
142 : a_EBNF(a_EBNF::tag_ebnf_star), ebnf_star(_xebnf_star) {}
143 inline friend a_EBNF * ebnf_star (EBNF _xebnf_star)
144 { return new EBNF_ebnf_star (_xebnf_star); }
147 ///////////////////////////////////////////////////////////////////////////////
148 // class for constructor 'EBNF::ebnf_plus EBNF'
149 ///////////////////////////////////////////////////////////////////////////////
150 class EBNF_ebnf_plus : public a_EBNF {
151 public:
152 #line 38 "ebnf.ph"
153 EBNF ebnf_plus;
154 inline EBNF_ebnf_plus (EBNF _xebnf_plus)
155 : a_EBNF(a_EBNF::tag_ebnf_plus), ebnf_plus(_xebnf_plus) {}
156 inline friend a_EBNF * ebnf_plus (EBNF _xebnf_plus)
157 { return new EBNF_ebnf_plus (_xebnf_plus); }
160 ///////////////////////////////////////////////////////////////////////////////
161 // class for constructor 'EBNF::ebnf_terminal Grammar::Terminal'
162 ///////////////////////////////////////////////////////////////////////////////
163 class EBNF_ebnf_terminal : public a_EBNF {
164 public:
165 #line 39 "ebnf.ph"
166 Grammar::Terminal ebnf_terminal;
167 inline EBNF_ebnf_terminal (Grammar::Terminal _xebnf_terminal)
168 : a_EBNF(a_EBNF::tag_ebnf_terminal), ebnf_terminal(_xebnf_terminal) {}
169 inline friend a_EBNF * ebnf_terminal (Grammar::Terminal _xebnf_terminal)
170 { return new EBNF_ebnf_terminal (_xebnf_terminal); }
173 ///////////////////////////////////////////////////////////////////////////////
174 // class for constructor 'EBNF::ebnf_nonterminal Grammar::NonTerminal'
175 ///////////////////////////////////////////////////////////////////////////////
176 class EBNF_ebnf_nonterminal : public a_EBNF {
177 public:
178 #line 40 "ebnf.ph"
179 Grammar::NonTerminal ebnf_nonterminal;
180 inline EBNF_ebnf_nonterminal (Grammar::NonTerminal _xebnf_nonterminal)
181 : a_EBNF(a_EBNF::tag_ebnf_nonterminal), ebnf_nonterminal(_xebnf_nonterminal) {}
182 inline friend a_EBNF * ebnf_nonterminal (Grammar::NonTerminal _xebnf_nonterminal)
183 { return new EBNF_ebnf_nonterminal (_xebnf_nonterminal); }
186 ///////////////////////////////////////////////////////////////////////////////
187 // class for constructor 'EBNF::ebnf_action Grammar::Action'
188 ///////////////////////////////////////////////////////////////////////////////
189 class EBNF_ebnf_action : public a_EBNF {
190 public:
191 #line 41 "ebnf.ph"
192 Grammar::Action ebnf_action;
193 inline EBNF_ebnf_action (Grammar::Action _xebnf_action)
194 : a_EBNF(a_EBNF::tag_ebnf_action), ebnf_action(_xebnf_action) {}
195 inline friend a_EBNF * ebnf_action (Grammar::Action _xebnf_action)
196 { return new EBNF_ebnf_action (_xebnf_action); }
199 ///////////////////////////////////////////////////////////////////////////////
200 // class for constructor 'EBNF::syntactic_predicate EBNF'
201 ///////////////////////////////////////////////////////////////////////////////
202 class EBNF_syntactic_predicate : public a_EBNF {
203 public:
204 #line 42 "ebnf.ph"
205 EBNF syntactic_predicate;
206 inline EBNF_syntactic_predicate (EBNF _xsyntactic_predicate)
207 : a_EBNF(a_EBNF::tag_syntactic_predicate), syntactic_predicate(_xsyntactic_predicate) {}
208 inline friend a_EBNF * syntactic_predicate (EBNF _xsyntactic_predicate)
209 { return new EBNF_syntactic_predicate (_xsyntactic_predicate); }
212 ///////////////////////////////////////////////////////////////////////////////
213 // class for constructor 'EBNF::semantic_predicate EBNF'
214 ///////////////////////////////////////////////////////////////////////////////
215 class EBNF_semantic_predicate : public a_EBNF {
216 public:
217 #line 43 "ebnf.ph"
218 EBNF semantic_predicate;
219 inline EBNF_semantic_predicate (EBNF _xsemantic_predicate)
220 : a_EBNF(a_EBNF::tag_semantic_predicate), semantic_predicate(_xsemantic_predicate) {}
221 inline friend a_EBNF * semantic_predicate (EBNF _xsemantic_predicate)
222 { return new EBNF_semantic_predicate (_xsemantic_predicate); }
225 #line 53 "ebnf.ph"
226 #line 53 "ebnf.ph"
229 //////////////////////////////////////////////////////////////////////////////
230 // Class EBNFGrammar represents a grammar in extended Backus/Naur form.
231 //////////////////////////////////////////////////////////////////////////////
232 class EBNFGrammar : public Grammar {
234 EBNFGrammar(const EBNFGrammar&); // no copy constructor
235 void operator = (EBNFGrammar&); // no assignment
237 public:
239 ///////////////////////////////////////////////////////////////////////////
240 // Import some types
241 ///////////////////////////////////////////////////////////////////////////
242 typedef Grammar Super;
243 typedef Super::Symbol Symbol;
244 typedef Super::Terminal Terminal;
245 typedef Super::NonTerminal NonTerminal;
246 typedef Super::Action Action;
247 typedef Super::Production Production;
249 public:
251 ///////////////////////////////////////////////////////////////////////////
252 // Constructor and destructor
253 ///////////////////////////////////////////////////////////////////////////
254 EBNFGrammar();
255 ~EBNFGrammar();
257 ///////////////////////////////////////////////////////////////////////////
258 // Selectors
259 ///////////////////////////////////////////////////////////////////////////
260 inline int size() const;
263 #endif
264 #line 90 "ebnf.ph"
266 ------------------------------- Statistics -------------------------------
267 Merge matching rules = yes
268 Number of DFA nodes merged = 0
269 Number of ifs generated = 0
270 Number of switches generated = 0
271 Number of labels = 0
272 Number of gotos = 0
273 Adaptive matching = disabled
274 Fast string matching = disabled
275 Inline downcasts = disabled
276 --------------------------------------------------------------------------