1 #ifndef GGL_RULE_GML_GRAMMAR_HH_
2 #define GGL_RULE_GML_GRAMMAR_HH_
8 #if HAVE_UNORDERED_MAP > 0
9 #include <unordered_map>
10 #elif HAVE_TR1_UNORDERED_MAP > 0
11 #include <tr1/unordered_map>
12 #elif HAVE_GNU_HASH_MAP > 0
13 #include <ext/hash_map>
19 #if !defined(BOOST_SPIRIT_CLOSURE_LIMIT)
20 #define BOOST_SPIRIT_CLOSURE_LIMIT 5
21 #elif BOOST_SPIRIT_CLOSURE_LIMIT < 5
22 #error "GGL_RULE_GML_GRAMMAR : BOOST_SPIRIT_CLOSURE_LIMIT too low, has to be at least 5"
26 #if !defined(PHOENIX_LIMIT)
27 #define PHOENIX_LIMIT 5
28 #elif PHOENIX_LIMIT < 5
29 #error "GGL_RULE_GML_GRAMMAR : PHOENIX_LIMIT too low, has to be at least 5"
32 #include <boost/version.hpp>
33 #if BOOST_VERSION >= 103800
34 #include <boost/spirit/include/classic.hpp>
35 #include <boost/spirit/include/phoenix1.hpp>
36 #define NS_BOOSTSPIRIT boost::spirit::classic
38 #include <boost/spirit.hpp>
39 #include <boost/spirit/phoenix.hpp>
40 #define NS_BOOSTSPIRIT boost::spirit
118 :
public NS_BOOSTSPIRIT::grammar< Rule_GML_grammar >
136 typedef boost::tuple<int,int,std::string,std::string>
edge_t;
137 typedef boost::tuple<int,std::string,std::string>
node_t;
138 #if HAVE_UNORDERED_MAP > 0
139 typedef std::unordered_map<std::string, kv_values_t>
keys_map_t;
140 #elif HAVE_TR1_UNORDERED_MAP > 0
141 typedef std::tr1::unordered_map<std::string, kv_values_t>
keys_map_t;
142 #elif HAVE_GNU_HASH_MAP > 0
143 typedef __gnu_cxx::hash_map<std::string, kv_values_t, sgm::hash_string>
keys_map_t;
148 struct lt_edge :
public std::binary_function<edge_t, edge_t, bool> {
150 if (a.get<0>() != b.get<0>())
return ( a.get<0>() < b.get<0>() );
151 if (a.get<1>() != b.get<1>())
return ( a.get<1>() < b.get<1>() );
152 if (a.get<2>() != b.get<2>())
return ( a.get<2>() < b.get<2>() );
153 if (a.get<3>() != b.get<3>())
return ( a.get<3>() < b.get<3>() );
159 struct lt_node :
public std::binary_function<node_t, node_t, bool> {
161 if (a.get<0>() != b.get<0>())
return ( a.get<0>() < b.get<0>() );
162 if (a.get<1>() != b.get<1>())
return ( a.get<1>() < b.get<1>() );
163 if (a.get<2>() != b.get<2>())
return ( a.get<2>() < b.get<2>() );
170 std::string, std::string, int, double>
217 keys_map_t::iterator pos =
_keys.find(k);
219 if (pos !=
_keys.end())
return (pos->second);
224 keys_map_t::iterator pos =
_keys.find(
"_"+k);
300 , std::vector< sgm::Pattern_Interface::Match_Constraint* > &
ruleConstraints
312 std::pair< Rule, int >
317 template <
typename ScannerT>
326 NS_BOOSTSPIRIT::rule<ScannerT>
const&
334 typedef NS_BOOSTSPIRIT::rule<ScannerT
345 typedef std::multiset<edge_t,lt_edge>
edges_t;
416 void dumpKeyValues(std::string k, std::string s,
int i,
double d);
419 void set_node_data(std::string k, std::string s,
int i,
double d);
422 void set_edge_data(std::string k, std::string s,
int i,
double d);
455 void keyValueAction(std::string k, std::string s,
int i,
double d);
506 #include "ggl/Rule_GML_grammar.icc"