1 | /*
|
---|
2 | * TOPPERS Software
|
---|
3 | * Toyohashi Open Platform for Embedded Real-Time Systems
|
---|
4 | *
|
---|
5 | * Copyright (C) 2007-2009 by TAKAGI Nobuhisa
|
---|
6 | *
|
---|
7 | * ãLì ÒÍCȺÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
|
---|
8 | * Ai{\tgEFAðüϵ½àÌðÜÞDȺ¯¶jðgpE¡»Eü
|
---|
9 | * ÏEÄzziȺCpÆÄÔj·é±Æð³Åø·éD
|
---|
10 | * (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
|
---|
11 | * \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
|
---|
12 | * XR[hÉÜÜêĢ鱯D
|
---|
13 | * (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJÉg
|
---|
14 | * pÅ«é`ÅÄzz·éêÉÍCÄzzɺ¤hL
|
---|
15 | gip
|
---|
16 | * Ò}j
|
---|
17 | AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
|
---|
18 | * Ì³ÛØKèðfÚ·é±ÆD
|
---|
19 | * (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJÉg
|
---|
20 | * pūȢ`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
|
---|
21 | * ÆD
|
---|
22 | * (a) Äzzɺ¤hL
|
---|
23 | gipÒ}j
|
---|
24 | AÈÇjÉCãLÌ
|
---|
25 | * ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
|
---|
26 | * (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
|
---|
27 | * ñ·é±ÆD
|
---|
28 | * (4) {\tgEFAÌpÉæè¼ÚIܽÍÔÚIɶ¶é¢©Èé¹
|
---|
29 | * Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
|
---|
30 | * ܽC{\tgEFAÌ[UܽÍGh[U©çÌ¢©Èé
|
---|
31 | * RÉîÿ©çàCãLì Ò¨æÑTOPPERSvWFNgð
|
---|
32 | * ÆÓ·é±ÆD
|
---|
33 | *
|
---|
34 | * {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
|
---|
35 | * æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
|
---|
36 | * ÉηéK«àÜßÄC¢©ÈéÛØàsíÈ¢DܽC{\tgEF
|
---|
37 | * AÌpÉæè¼ÚIܽÍÔÚIɶ¶½¢©Èé¹QÉÖµÄàC»
|
---|
38 | * ÌÓCðíÈ¢D
|
---|
39 | *
|
---|
40 | */
|
---|
41 |
|
---|
42 |
|
---|
43 | #ifndef OIL_PARSER_H
|
---|
44 | #define OIL_PARSER_H
|
---|
45 |
|
---|
46 | #include <boost/spirit/core.hpp>
|
---|
47 | #include <boost/spirit/error_handling.hpp>
|
---|
48 | #include <boost/spirit/tree/ast.hpp>
|
---|
49 | #include <boost/spirit/utility/functor_parser.hpp>
|
---|
50 | #include <boost/spirit/utility/regex.hpp>
|
---|
51 | #include <vector>
|
---|
52 | #include <map>
|
---|
53 | #include <algorithm>
|
---|
54 |
|
---|
55 | #include "toppers/text.hpp"
|
---|
56 | #include "toppers/oil/oil_object.hpp"
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 | using namespace boost::spirit;
|
---|
61 |
|
---|
62 | namespace toppers
|
---|
63 | {
|
---|
64 | namespace oil
|
---|
65 | {
|
---|
66 | typedef std::vector<toppers::oil::oil_implementation::oil_object_impl*> oil_impl;
|
---|
67 | typedef std::vector<toppers::oil::oil_definition::object_definition*> oil_def;
|
---|
68 |
|
---|
69 | class oil_parser
|
---|
70 | {
|
---|
71 | public:
|
---|
72 | oil_parser(std::string* txt , std::vector<std::string> const& objlist)
|
---|
73 | {
|
---|
74 | description = txt;
|
---|
75 | param_addable = true;
|
---|
76 | m_object_list = objlist;
|
---|
77 | }
|
---|
78 | ~oil_parser()
|
---|
79 | {
|
---|
80 | std::vector<toppers::oil::oil_implementation::oil_object_impl*>::iterator p;
|
---|
81 |
|
---|
82 | for(p = impl_list.begin() ; p != impl_list.end() ; p++)
|
---|
83 | {
|
---|
84 | delete *p;
|
---|
85 | }
|
---|
86 |
|
---|
87 | std::vector<toppers::oil::oil_definition::object_definition*>::iterator q;
|
---|
88 |
|
---|
89 | for(q = def_list.begin() ; q != def_list.end() ; q++)
|
---|
90 | {
|
---|
91 | delete *q;
|
---|
92 | }
|
---|
93 | }
|
---|
94 | int do_parse(oil_impl **impl , oil_def **def);
|
---|
95 | int start_objimpl_analysis(std::string object_name);
|
---|
96 | int start_objdef_analysis(std::string object_name_type);
|
---|
97 | int add_parameter_objimpl(std::string parameter);
|
---|
98 | int set_nextparam_name(std::string name);
|
---|
99 | int add_attr_value(std::string str);
|
---|
100 | int end_objimpl_analysis(void);
|
---|
101 | int end_objdef_analysis(void);
|
---|
102 | void enable_addparam(bool enabled);
|
---|
103 | void dump_implementation(void);
|
---|
104 | void dump_definition(void);
|
---|
105 | void set_error(int position , std::string message);
|
---|
106 | void get_error(int *position , std::string *message);
|
---|
107 |
|
---|
108 | std::string* get_description(void)
|
---|
109 | {
|
---|
110 | return description;
|
---|
111 | }
|
---|
112 | std::vector<std::string> m_object_list;
|
---|
113 | protected:
|
---|
114 | std::string *description;
|
---|
115 | oil_impl impl_list;
|
---|
116 | oil_def def_list;
|
---|
117 | private:
|
---|
118 | toppers::oil::oil_implementation::oil_object_impl* current_impl;
|
---|
119 | std::string next_param_name;
|
---|
120 | std::string attr_description;
|
---|
121 | bool param_addable;
|
---|
122 | toppers::oil::oil_definition::object_definition* current_def;
|
---|
123 | std::string error_message;
|
---|
124 | int error_position;
|
---|
125 | };
|
---|
126 |
|
---|
127 | // ¶@G[íÊ
|
---|
128 | enum oil_grammer_error
|
---|
129 | {
|
---|
130 | open_brace , close_brace , semicolon , equal , keyword , comma
|
---|
131 | };
|
---|
132 | // ¶@G[^è`
|
---|
133 | typedef assertion<oil_grammer_error> oil_assertion;
|
---|
134 | typedef boost::spirit::guard<oil_grammer_error> oil_error_guard;
|
---|
135 |
|
---|
136 | // G[nh
|
---|
137 | struct error_handler
|
---|
138 | {
|
---|
139 | oil_parser* container;
|
---|
140 | error_handler(oil_parser* _container) : container(_container)
|
---|
141 | {
|
---|
142 | }
|
---|
143 | template < class Scanner, class oil_grammer_error >
|
---|
144 | boost::spirit::error_status<> operator()( Scanner const& scan, oil_grammer_error const& error ) const
|
---|
145 | {
|
---|
146 | std::string message;
|
---|
147 | int pos;
|
---|
148 | boost::spirit::error_status<> result =
|
---|
149 | boost::spirit::error_status<>( boost::spirit::error_status<>::fail );
|
---|
150 |
|
---|
151 | // G[o»ÊuÌZo
|
---|
152 | pos = error.where - &((container->get_description()->c_str())[0]);
|
---|
153 |
|
---|
154 | // bZ[WÌo^
|
---|
155 | switch ( error.descriptor )
|
---|
156 | {
|
---|
157 | case open_brace:
|
---|
158 | message = "missing '{'";
|
---|
159 | break;
|
---|
160 | case close_brace:
|
---|
161 | message = "missing '}'";
|
---|
162 | break;
|
---|
163 | case semicolon:
|
---|
164 | message = "missing ';'";
|
---|
165 | break;
|
---|
166 | case equal:
|
---|
167 | message = "missing '='";
|
---|
168 | break;
|
---|
169 | case keyword:
|
---|
170 | message = "can't use keyword";
|
---|
171 | break;
|
---|
172 | case comma:
|
---|
173 | message = "missing ','";
|
---|
174 | break;
|
---|
175 | }
|
---|
176 |
|
---|
177 | container->set_error(pos , message);
|
---|
178 | return result;
|
---|
179 | }
|
---|
180 | };
|
---|
181 |
|
---|
182 | // t@N^
|
---|
183 | struct match_objimpl_name
|
---|
184 | {
|
---|
185 | oil_parser* container;
|
---|
186 | match_objimpl_name(oil_parser* _container) : container(_container)
|
---|
187 | {
|
---|
188 | }
|
---|
189 | void operator()(char const *first, char const *last) const
|
---|
190 | {
|
---|
191 | std::string str(first , last);
|
---|
192 | std::vector<std::string>::iterator p;
|
---|
193 | bool hit = false;
|
---|
194 |
|
---|
195 | for(p = container->m_object_list.begin() ; p != container->m_object_list.end() ; p++)
|
---|
196 | {
|
---|
197 | if(*p == str)
|
---|
198 | {
|
---|
199 | hit = true;
|
---|
200 | break;
|
---|
201 | }
|
---|
202 | }
|
---|
203 | container->start_objimpl_analysis(str);
|
---|
204 | }
|
---|
205 | };
|
---|
206 |
|
---|
207 | struct find_implparam_name
|
---|
208 | {
|
---|
209 | oil_parser* container;
|
---|
210 | find_implparam_name(oil_parser* _container) : container(_container)
|
---|
211 | {
|
---|
212 | }
|
---|
213 |
|
---|
214 | void operator()(char const *first, char const *last) const
|
---|
215 | {
|
---|
216 | string str(first , last);
|
---|
217 | container->set_nextparam_name(str);
|
---|
218 | }
|
---|
219 | };
|
---|
220 |
|
---|
221 | struct match_impl_parameter
|
---|
222 | {
|
---|
223 | oil_parser* container;
|
---|
224 | match_impl_parameter(oil_parser* _container) : container(_container)
|
---|
225 | {
|
---|
226 | }
|
---|
227 |
|
---|
228 | void operator()(char const *first, char const *last) const
|
---|
229 | {
|
---|
230 | string str(first , last);
|
---|
231 | container->add_parameter_objimpl(str);
|
---|
232 | }
|
---|
233 | };
|
---|
234 |
|
---|
235 | // À̶Êðo·ét@N^
|
---|
236 | struct match_objimpl_end
|
---|
237 | {
|
---|
238 | oil_parser* container;
|
---|
239 | match_objimpl_end(oil_parser* _container) : container(_container)
|
---|
240 | {
|
---|
241 | }
|
---|
242 |
|
---|
243 | void operator()(char val) const
|
---|
244 | {
|
---|
245 | container->end_objimpl_analysis();
|
---|
246 | }
|
---|
247 | };
|
---|
248 |
|
---|
249 | // IuWFNgè`æªðo·ét@N^
|
---|
250 | struct match_objdef_name
|
---|
251 | {
|
---|
252 | oil_parser* container;
|
---|
253 | match_objdef_name(oil_parser* _container) : container(_container)
|
---|
254 | {
|
---|
255 | }
|
---|
256 | void operator()(char const *first, char const *last) const
|
---|
257 | {
|
---|
258 | string str(first , last);
|
---|
259 | container->start_objdef_analysis(str);
|
---|
260 | }
|
---|
261 | };
|
---|
262 |
|
---|
263 | // p[^è`ðÇÁ·ét@N^
|
---|
264 | struct find_attrname
|
---|
265 | {
|
---|
266 | oil_parser* container;
|
---|
267 | find_attrname(oil_parser* _container) : container(_container)
|
---|
268 | {
|
---|
269 | }
|
---|
270 | void operator()(char const *first, char const *last) const
|
---|
271 | {
|
---|
272 | string str(first , last);
|
---|
273 | container->set_nextparam_name(str);
|
---|
274 | }
|
---|
275 | };
|
---|
276 |
|
---|
277 | // IuWFNgè`I[ðo·ét@N^
|
---|
278 | struct match_objdef_end
|
---|
279 | {
|
---|
280 | oil_parser* container;
|
---|
281 | match_objdef_end(oil_parser* _container) : container(_container){}
|
---|
282 |
|
---|
283 | void operator()(char val) const
|
---|
284 | {
|
---|
285 | container->end_objdef_analysis();
|
---|
286 | }
|
---|
287 | };
|
---|
288 |
|
---|
289 | // è`Ìp[^^Cvð¯Ê·ét@N^
|
---|
290 | struct find_attribute
|
---|
291 | {
|
---|
292 | oil_parser* container;
|
---|
293 | find_attribute(oil_parser* _container) : container(_container)
|
---|
294 | {
|
---|
295 | }
|
---|
296 | void operator()(char const *first, char const *last) const
|
---|
297 | {
|
---|
298 | string str(first , last);
|
---|
299 | container->add_attr_value(str);
|
---|
300 | }
|
---|
301 | };
|
---|
302 |
|
---|
303 | // è`Ìp[^^Cvð¯Ê·é(®¬_Å)
|
---|
304 | struct find_attribute_float
|
---|
305 | {
|
---|
306 | oil_parser* container;
|
---|
307 | find_attribute_float(oil_parser* _container) : container(_container)
|
---|
308 | {
|
---|
309 | }
|
---|
310 | void operator()(double val) const
|
---|
311 | {
|
---|
312 | char buf[256];
|
---|
313 | sprintf_s(buf , "%lf" , val);
|
---|
314 | string str(buf);
|
---|
315 |
|
---|
316 | container->add_attr_value(str);
|
---|
317 | }
|
---|
318 | };
|
---|
319 |
|
---|
320 |
|
---|
321 |
|
---|
322 | // ENUMÌp[^³·é½ßÌt@N^
|
---|
323 | struct enum_start
|
---|
324 | {
|
---|
325 | oil_parser* container;
|
---|
326 | enum_start(oil_parser* _container) : container(_container){}
|
---|
327 |
|
---|
328 | void operator()(char val) const
|
---|
329 | {
|
---|
330 | container->enable_addparam(false);
|
---|
331 | }
|
---|
332 | };
|
---|
333 |
|
---|
334 | // ENUMÌp[^³ðð·é½ßÌt@N^
|
---|
335 | struct enum_end
|
---|
336 | {
|
---|
337 | oil_parser* container;
|
---|
338 | enum_end(oil_parser* _container) : container(_container){}
|
---|
339 |
|
---|
340 | void operator()(char val) const
|
---|
341 | {
|
---|
342 | container->enable_addparam(true);
|
---|
343 | }
|
---|
344 | };
|
---|
345 |
|
---|
346 | // OILp[TNX
|
---|
347 | struct oil_grammer : public grammar<oil_grammer>
|
---|
348 | {
|
---|
349 | oil_parser* m_container;
|
---|
350 | oil_grammer(oil_parser* container)
|
---|
351 | {
|
---|
352 | m_container = container;
|
---|
353 | }
|
---|
354 | template <typename T> struct definition
|
---|
355 | {
|
---|
356 | // ¶@G[íÞè`
|
---|
357 | oil_assertion assertion_open_brace , assertion_close_brace , assertion_semicolon;
|
---|
358 | oil_assertion assertion_equal , assertion_keyword , assertion_comma;
|
---|
359 | // G[nhOè`
|
---|
360 | oil_error_guard guard_implementation , guard_object , guard_object_def;
|
---|
361 |
|
---|
362 | // BNF
|
---|
363 | rule<T> file;
|
---|
364 | rule<T> oil_version , implementation_definition , application_definition;
|
---|
365 | rule<T> implementation_spec_list , implementation_spec , implementation_def;
|
---|
366 | rule<T> object , object_ref_type , object_name , object_temp;
|
---|
367 |
|
---|
368 | rule<T> name , null_str , boolean , string_literal;
|
---|
369 | rule<T> multiple_specifier , auto_specifier;
|
---|
370 | rule<T> number_range , number_list , number , float_range , default_number , default_float;
|
---|
371 | rule<T> attribute_name;
|
---|
372 | rule<T> default_string , default_bool , default_name;
|
---|
373 | rule<T> bool_values;
|
---|
374 | rule<T> enumerator , enumeration , enumerator_list;
|
---|
375 |
|
---|
376 | rule<T> impl_parameter_list;
|
---|
377 |
|
---|
378 | rule<T> uint32_impl_attr_def , int32_impl_attr_def , uint64_impl_attr_def , int64_impl_attr_def;
|
---|
379 | rule<T> float_impl_attr_def , string_impl_attr_def , bool_impl_attr_def , enum_impl_attr_def;
|
---|
380 | rule<T> reference_name;
|
---|
381 | rule<T> impl_attr_def , impl_ref_def;
|
---|
382 |
|
---|
383 | rule<T> object_definition;
|
---|
384 | rule<T> parameter , attribute_value;
|
---|
385 |
|
---|
386 | definition(oil_grammer const& self) :
|
---|
387 | assertion_open_brace(open_brace) ,
|
---|
388 | assertion_close_brace(close_brace) ,
|
---|
389 | assertion_semicolon(semicolon) ,
|
---|
390 | assertion_equal(equal) ,
|
---|
391 | assertion_keyword(keyword) ,
|
---|
392 | assertion_comma(comma)
|
---|
393 | {
|
---|
394 | // LÖW
|
---|
395 | null_str = str_p("");
|
---|
396 | name = (alpha_p | ch_p('_')) >> +(alnum_p | ch_p('_'));
|
---|
397 | string_literal = ch_p('"') >> name >> ch_p('"');
|
---|
398 | multiple_specifier = !(ch_p('[') >> ch_p(']'));
|
---|
399 | auto_specifier = !str_p("WITH_AUTO");
|
---|
400 | number = (str_p("0x") >> +xdigit_p) | (str_p("0X") >> xdigit_p) | int_p | uint_p;
|
---|
401 | boolean = str_p("TRUE") | str_p("FALSE");
|
---|
402 |
|
---|
403 | // WAftHgl
|
---|
404 | number_list = ch_p('[') >> number >> *(ch_p(',') >> number) >> ch_p(']');
|
---|
405 | number_range = !((ch_p('[') >> number >> str_p("..") >> number >> ch_p(']'))
|
---|
406 | | number_list);
|
---|
407 | default_number = !((ch_p('=') >> number)
|
---|
408 | | (ch_p('=') >> str_p("NO_DEFAULT"))
|
---|
409 | | (ch_p('=') >> str_p("AUTO")));
|
---|
410 | float_range = !(ch_p('[') >> real_p >> str_p("..") >> real_p >> ch_p(']'));
|
---|
411 | default_float = !((ch_p('=') >> real_p)
|
---|
412 | | (ch_p('=') >> str_p("NO_DEFAULT"))
|
---|
413 | | (ch_p('=') >> str_p("AUTO")));
|
---|
414 |
|
---|
415 | enumerator = name >> !(ch_p('{') >> implementation_def >> ch_p('}'));
|
---|
416 | enumerator_list = enumerator >> *(ch_p(',') >> enumerator);
|
---|
417 | enumeration = ch_p('[')[enum_start(self.m_container)] >>
|
---|
418 | enumerator_list >> ch_p(']')[enum_end(self.m_container)];
|
---|
419 |
|
---|
420 | default_name = !((ch_p('=') >> name)
|
---|
421 | | (ch_p('=') >> str_p("NO_DEFAULT"))
|
---|
422 | | (ch_p('=') >> str_p("AUTO")));
|
---|
423 |
|
---|
424 | attribute_name = name | object;
|
---|
425 | attribute_value = (boolean >> !(ch_p('{')[enum_start(self.m_container)] >>
|
---|
426 | *parameter >> (ch_p('}')[enum_end(self.m_container)])))
|
---|
427 | [find_attribute(self.m_container)]
|
---|
428 | | number[find_attribute(self.m_container)]
|
---|
429 | | real_p[find_attribute_float(self.m_container)]
|
---|
430 | | string_literal[find_attribute(self.m_container)]
|
---|
431 | // AUTOͺÌè`ÅãpÂ\
|
---|
432 | | (name >> !(ch_p('{')[enum_start(self.m_container)] >>
|
---|
433 | *parameter >> ch_p('}')[enum_end(self.m_container)]))
|
---|
434 | [find_attribute(self.m_container)];
|
---|
435 |
|
---|
436 | default_string = !((ch_p('=') >> ch_p('"') >> name >> ch_p('"'))
|
---|
437 | | (ch_p('=') >> str_p("NO_DEFAULT"))
|
---|
438 | | (ch_p('=') >> str_p("AUTO")));
|
---|
439 | default_bool = !((ch_p('=') >> boolean)
|
---|
440 | | (ch_p('=') >> str_p("NO_DEFAULT"))
|
---|
441 | | (ch_p('=') >> str_p("AUTO")));
|
---|
442 | bool_values = !(ch_p('[')[enum_start(self.m_container)] >>
|
---|
443 | str_p("TRUE") >> !(ch_p('{') >> implementation_def >> ch_p('}')) >>
|
---|
444 | ch_p(',') >>
|
---|
445 | str_p("FALSE") >> !(ch_p('{') >> implementation_def >> ch_p('}')) >>
|
---|
446 | ch_p(']')[enum_end(self.m_container)]);
|
---|
447 |
|
---|
448 | std::vector<std::string>::iterator p;
|
---|
449 | std::string objtype = "(" , objref = "(";
|
---|
450 |
|
---|
451 | // ³K\»ÌXgðì¬
|
---|
452 | for(p = self.m_container->m_object_list.begin() ; p != self.m_container->m_object_list.end() ; p++)
|
---|
453 | {
|
---|
454 | objtype += (*p) + "|";
|
---|
455 | objref += (*p) + "_TYPE" + "|";
|
---|
456 | }
|
---|
457 |
|
---|
458 | objtype[objtype.size() - 1] = ')';
|
---|
459 | objref[objref.size() - 1] = ')';
|
---|
460 |
|
---|
461 | object = regex_p(objtype.c_str());
|
---|
462 | object_ref_type = regex_p(objref.c_str());
|
---|
463 |
|
---|
464 | // IuWFNgè`
|
---|
465 | parameter = attribute_name[find_attrname(self.m_container)] >>
|
---|
466 | assertion_equal(ch_p("=")) >> attribute_value >>
|
---|
467 | assertion_semicolon(ch_p(";"));
|
---|
468 | object_name = (object >> name)[match_objdef_name(self.m_container)];
|
---|
469 | object_definition = guard_object(
|
---|
470 | object_name >> assertion_open_brace(ch_p('{')) >>
|
---|
471 | *parameter >> assertion_close_brace(ch_p('}')) >>
|
---|
472 | assertion_semicolon(ch_p(';'))[match_objdef_end(self.m_container)])
|
---|
473 | [error_handler(self.m_container)];
|
---|
474 |
|
---|
475 | // ^ÊÌp[^wèq
|
---|
476 | uint32_impl_attr_def = str_p("UINT32") >> auto_specifier >> number_range >>
|
---|
477 | attribute_name[find_implparam_name(self.m_container)] >>
|
---|
478 | multiple_specifier >> default_number >>
|
---|
479 | assertion_semicolon(ch_p(';'));
|
---|
480 | int32_impl_attr_def = str_p("INT32") >> auto_specifier >> number_range >>
|
---|
481 | attribute_name[find_implparam_name(self.m_container)] >>
|
---|
482 | multiple_specifier >> default_number >>
|
---|
483 | assertion_semicolon(ch_p(';'));
|
---|
484 | uint64_impl_attr_def = str_p("UINT64") >> auto_specifier >> number_range >>
|
---|
485 | attribute_name[find_implparam_name(self.m_container)] >>
|
---|
486 | multiple_specifier >> default_number >>
|
---|
487 | assertion_semicolon(ch_p(';'));
|
---|
488 | int64_impl_attr_def = str_p("INT64") >> auto_specifier >> number_range >>
|
---|
489 | attribute_name[find_implparam_name(self.m_container)] >>
|
---|
490 | multiple_specifier >> default_number >>
|
---|
491 | assertion_semicolon(ch_p(';'));
|
---|
492 | float_impl_attr_def = str_p("FLOAT") >> auto_specifier >> float_range >>
|
---|
493 | attribute_name[find_implparam_name(self.m_container)] >>
|
---|
494 | multiple_specifier >> default_float >>
|
---|
495 | assertion_semicolon(ch_p(';'));
|
---|
496 | string_impl_attr_def = str_p("STRING") >> auto_specifier >>
|
---|
497 | attribute_name[find_implparam_name(self.m_container)] >>
|
---|
498 | multiple_specifier >> default_string >>
|
---|
499 | assertion_semicolon(ch_p(';'));
|
---|
500 | bool_impl_attr_def = str_p("BOOLEAN") >>
|
---|
501 | auto_specifier >> bool_values >>
|
---|
502 | attribute_name[find_implparam_name(self.m_container)] >>
|
---|
503 | multiple_specifier >> default_bool >>
|
---|
504 | assertion_semicolon(ch_p(';'));
|
---|
505 | enum_impl_attr_def = str_p("ENUM") >>
|
---|
506 | auto_specifier >> enumeration >>
|
---|
507 | attribute_name[find_implparam_name(self.m_container)] >>
|
---|
508 | multiple_specifier >> default_name >>
|
---|
509 | assertion_semicolon(ch_p(';'));
|
---|
510 |
|
---|
511 | // ®«l
|
---|
512 | impl_attr_def = uint32_impl_attr_def | int32_impl_attr_def
|
---|
513 | | uint64_impl_attr_def | int64_impl_attr_def
|
---|
514 | | float_impl_attr_def | string_impl_attr_def
|
---|
515 | | bool_impl_attr_def | enum_impl_attr_def;
|
---|
516 |
|
---|
517 | reference_name = name | object;
|
---|
518 | impl_ref_def = object_ref_type >> reference_name[find_implparam_name(self.m_container)] >>
|
---|
519 | multiple_specifier >> assertion_semicolon(ch_p(';'));
|
---|
520 |
|
---|
521 | // p[^Ì`®
|
---|
522 | implementation_def = *((impl_attr_def | impl_ref_def)
|
---|
523 | [match_impl_parameter(self.m_container)]);
|
---|
524 |
|
---|
525 | // {Ìè`
|
---|
526 | application_definition =
|
---|
527 | str_p("CPU") >> name >> ch_p('{') >>
|
---|
528 | *object_definition >> ch_p('}') >> ch_p(';');
|
---|
529 |
|
---|
530 | // å«ÈPÊ̶@
|
---|
531 | implementation_spec =
|
---|
532 | guard_object(object[match_objimpl_name(self.m_container)] >>
|
---|
533 | assertion_open_brace(ch_p('{')) >>
|
---|
534 | implementation_def >>
|
---|
535 | assertion_close_brace(ch_p('}')) >>
|
---|
536 | assertion_semicolon(ch_p(';')[match_objimpl_end(self.m_container)]))
|
---|
537 | [error_handler(self.m_container)];
|
---|
538 | implementation_spec_list = *implementation_spec;
|
---|
539 |
|
---|
540 | implementation_definition = "IMPLEMENTATION" >> name >> ch_p('{')
|
---|
541 | >> implementation_spec_list >> ch_p('}') >> ch_p(';');
|
---|
542 |
|
---|
543 | oil_version = str_p("OIL_VERSION")
|
---|
544 | >> ch_p('=') >> ch_p('\"') >> real_p >> ch_p('\"') >> ch_p(';'); //
|
---|
545 | file = oil_version >> implementation_definition >> application_definition >> *space_p;
|
---|
546 | };
|
---|
547 | rule<T> const& start() const
|
---|
548 | {
|
---|
549 | return file; // è`µ½[ðÔ·
|
---|
550 | }
|
---|
551 | };
|
---|
552 |
|
---|
553 | };
|
---|
554 |
|
---|
555 |
|
---|
556 | }
|
---|
557 | }
|
---|
558 |
|
---|
559 | #endif /* OIL_PARSER_H */
|
---|