OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
array.hpp
Go to the documentation of this file.
1 //
2 // Copyright & License: See Copyright.readme in src directory
3 //
4 
9 #ifndef ARRAY_HPP_
10 #define ARRAY_HPP_
11 
12 #include "ast.hpp"
13 #include "skipper.hpp"
14 #include "error_handler.hpp"
15 
16 #include <boost/config/warning_disable.hpp>
17 #include <boost/spirit/include/qi.hpp>
18 #include <boost/fusion/include/adapt_struct.hpp>
19 
20 #include <list>
21 
22 #define BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
23 #define BOOST_SPIRIT_QI_DEBUG
24 
25 namespace SDDS {
26  struct array
27  {
34  , TYPE
38  };
39 
40  template <attributes A>
42  {
43  static bool apply()
44  {
45  std::string attributeString;
46  switch(A)
47  {
48  case NAME:
49  attributeString = "name";
50  break;
51  case SYMBOL:
52  attributeString = "symbol";
53  break;
54  case UNITS:
55  attributeString = "units";
56  break;
57  case DESCRIPTION:
58  attributeString = "description";
59  break;
60  case FORMAT_STRING:
61  attributeString = "format_string";
62  break;
63  case GROUP_NAME:
64  attributeString = "group_name";
65  break;
66  case TYPE:
67  attributeString = "type";
68  break;
69  case FIELD_LENGTH:
70  attributeString = "field_length";
71  break;
72  case DIMENSIONS:
73  attributeString = "dimensions";
74  break;
75  case ARRAY:
76  attributeString = "array";
77  break;
78  default:
79  return true;
80  }
81  std::cerr << attributeString << " not supported yet" << std::endl;
82  return false;
83  }
84  };
85  };
86 
87  struct arrayList: std::list<array> {};
88 
89  inline std::ostream& operator<<(std::ostream& out, const array& ) {
90  return out;
91  }
92 }
93 
94 namespace SDDS { namespace parser
95 {
96  namespace qi = boost::spirit::qi;
97  namespace ascii = boost::spirit::ascii;
98  namespace phx = boost::phoenix;
99 
100  template <typename Iterator>
101  struct array_parser: qi::grammar<Iterator, array(), skipper<Iterator> >
102  {
103  array_parser(error_handler<Iterator> & _error_handler);
104 
105  qi::rule<Iterator, array(), skipper<Iterator> > start;
106  qi::rule<Iterator, std::string(), skipper<Iterator> > array_name,
109  qi::rule<Iterator, long(), skipper<Iterator> > array_field,
111  qi::rule<Iterator, ast::datatype, skipper<Iterator> > array_type;
112  qi::rule<Iterator, ast::nil(), skipper<Iterator> > array_unsupported_pre,
114  qi::symbols<char, ast::datatype> arraytype;
115  };
116 }}
117 #endif /* ARRAY_HPP_ */
qi::rule< Iterator, ast::nil(), skipper< Iterator > > array_unsupported_pre
Definition: array.hpp:112
qi::rule< Iterator, std::string(), skipper< Iterator > > array_symbol
Definition: array.hpp:106
array_parser(error_handler< Iterator > &_error_handler)
Definition: array_def.hpp:22
qi::rule< Iterator, array(), skipper< Iterator > > start
Definition: array.hpp:105
qi::rule< Iterator, std::string(), skipper< Iterator > > quoted_string
Definition: array.hpp:106
qi::rule< Iterator, ast::datatype, skipper< Iterator > > array_type
Definition: array.hpp:111
qi::rule< Iterator, long(), skipper< Iterator > > array_dimensions
Definition: array.hpp:109
qi::symbols< char, ast::datatype > arraytype
Definition: array.hpp:114
qi::rule< Iterator, std::string(), skipper< Iterator > > string
Definition: array.hpp:106
qi::rule< Iterator, std::string(), skipper< Iterator > > array_description
Definition: array.hpp:106
qi::rule< Iterator, long(), skipper< Iterator > > array_field
Definition: array.hpp:109
qi::rule< Iterator, std::string(), skipper< Iterator > > array_units
Definition: array.hpp:106
qi::rule< Iterator, std::string(), skipper< Iterator > > array_format
Definition: array.hpp:106
qi::rule< Iterator, std::string(), skipper< Iterator > > array_group
Definition: array.hpp:106
qi::rule< Iterator, ast::nil(), skipper< Iterator > > array_unsupported_post
Definition: array.hpp:112
qi::rule< Iterator, std::string(), skipper< Iterator > > units
Definition: array.hpp:106
qi::rule< Iterator, std::string(), skipper< Iterator > > array_name
Definition: array.hpp:106
std::ostream & operator<<(std::ostream &out, const array &)
Definition: array.hpp:89
Inform & endl(Inform &inf)
Definition: Inform.cpp:42