Moved basic parsers to new header file spirit.h
parent
19ea0436db
commit
4d1225cda7
|
@ -23,7 +23,7 @@
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
|
|
||||||
//#define BOOST_SPIRIT_DEBUG
|
//#define BOOST_SPIRIT_DEBUG
|
||||||
#include "spirit_actors.h"
|
#include "spirit.h"
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
|
|
|
@ -18,14 +18,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/spirit/include/classic_core.hpp>
|
#include <wrap/spirit.h>
|
||||||
#include <boost/spirit/include/classic_push_back_actor.hpp>
|
|
||||||
#include <boost/spirit/include/classic_clear_actor.hpp>
|
|
||||||
#include <boost/spirit/include/classic_assign_actor.hpp>
|
|
||||||
#include <boost/spirit/include/classic_confix.hpp>
|
|
||||||
|
|
||||||
namespace classic = BOOST_SPIRIT_CLASSIC_NS;
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -161,41 +154,6 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ************************************************************************* */
|
|
||||||
/// Som basic rules used by all parsers
|
|
||||||
template<typename ScannerT>
|
|
||||||
struct basic_rules {
|
|
||||||
|
|
||||||
typedef classic::rule<ScannerT> Rule;
|
|
||||||
|
|
||||||
Rule comments_p, basisType_p, eigenType_p, keywords_p, stlType_p, name_p,
|
|
||||||
className_p, namespace_p;
|
|
||||||
|
|
||||||
basic_rules() {
|
|
||||||
|
|
||||||
using namespace classic;
|
|
||||||
|
|
||||||
comments_p = comment_p("/*", "*/") | comment_p("//", eol_p);
|
|
||||||
|
|
||||||
basisType_p = (str_p("string") | "bool" | "size_t" | "int" | "double"
|
|
||||||
| "char" | "unsigned char");
|
|
||||||
|
|
||||||
eigenType_p = (str_p("Vector") | "Matrix");
|
|
||||||
|
|
||||||
keywords_p =
|
|
||||||
(str_p("const") | "static" | "namespace" | "void" | basisType_p);
|
|
||||||
|
|
||||||
stlType_p = (str_p("vector") | "list");
|
|
||||||
|
|
||||||
name_p = lexeme_d[alpha_p >> *(alnum_p | '_')];
|
|
||||||
|
|
||||||
className_p = (lexeme_d[upper_p >> *(alnum_p | '_')] - eigenType_p
|
|
||||||
- keywords_p) | stlType_p;
|
|
||||||
|
|
||||||
namespace_p = lexeme_d[lower_p >> *(alnum_p | '_')] - keywords_p;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
// http://boost-spirit.com/distrib/spirit_1_8_2/libs/spirit/doc/grammar.html
|
// http://boost-spirit.com/distrib/spirit_1_8_2/libs/spirit/doc/grammar.html
|
||||||
class TypeGrammar: public classic::grammar<TypeGrammar> {
|
class TypeGrammar: public classic::grammar<TypeGrammar> {
|
||||||
|
@ -284,7 +242,7 @@ struct TypeListGrammar: public classic::grammar<TypeListGrammar> {
|
||||||
definition(TypeListGrammar const& self) {
|
definition(TypeListGrammar const& self) {
|
||||||
using namespace classic;
|
using namespace classic;
|
||||||
type_p = self.type_g //
|
type_p = self.type_g //
|
||||||
[classic::push_back_a(self.result_, self.type)] //
|
[push_back_a(self.result_, self.type)] //
|
||||||
[clear_a(self.type)];
|
[clear_a(self.type)];
|
||||||
typeList_p = '{' >> !type_p >> *(',' >> type_p) >> '}';
|
typeList_p = '{' >> !type_p >> *(',' >> type_p) >> '}';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
/**
|
/**
|
||||||
* @file spirit_actors.h
|
* @file spirit_actors.h
|
||||||
*
|
*
|
||||||
* @brief Additional actors for the wrap parser
|
* @brief Additional utilities and actors for the wrap parser
|
||||||
*
|
*
|
||||||
* @date Dec 8, 2011
|
* @date Dec 8, 2011
|
||||||
* @author Alex Cunningham
|
* @author Alex Cunningham
|
||||||
|
* @author Frank Dellaert
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/spirit/include/classic_core.hpp>
|
#include <boost/spirit/include/classic_core.hpp>
|
||||||
#include <boost/spirit/include/classic_ref_actor.hpp>
|
#include <boost/spirit/include/classic_push_back_actor.hpp>
|
||||||
|
#include <boost/spirit/include/classic_clear_actor.hpp>
|
||||||
|
#include <boost/spirit/include/classic_assign_actor.hpp>
|
||||||
|
#include <boost/spirit/include/classic_confix.hpp>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace spirit {
|
namespace spirit {
|
||||||
|
@ -121,3 +125,40 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_END
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace classic = BOOST_SPIRIT_CLASSIC_NS;
|
||||||
|
|
||||||
|
/// Some basic rules used by all parsers
|
||||||
|
template<typename ScannerT>
|
||||||
|
struct basic_rules {
|
||||||
|
|
||||||
|
typedef BOOST_SPIRIT_CLASSIC_NS::rule<ScannerT> Rule;
|
||||||
|
|
||||||
|
Rule comments_p, basisType_p, eigenType_p, keywords_p, stlType_p, name_p,
|
||||||
|
className_p, namespace_p;
|
||||||
|
|
||||||
|
basic_rules() {
|
||||||
|
|
||||||
|
using namespace BOOST_SPIRIT_CLASSIC_NS;
|
||||||
|
|
||||||
|
comments_p = comment_p("/*", "*/") | comment_p("//", eol_p);
|
||||||
|
|
||||||
|
basisType_p = (str_p("string") | "bool" | "size_t" | "int" | "double"
|
||||||
|
| "char" | "unsigned char");
|
||||||
|
|
||||||
|
eigenType_p = (str_p("Vector") | "Matrix");
|
||||||
|
|
||||||
|
keywords_p =
|
||||||
|
(str_p("const") | "static" | "namespace" | "void" | basisType_p);
|
||||||
|
|
||||||
|
stlType_p = (str_p("vector") | "list");
|
||||||
|
|
||||||
|
name_p = lexeme_d[alpha_p >> *(alnum_p | '_')];
|
||||||
|
|
||||||
|
className_p = (lexeme_d[upper_p >> *(alnum_p | '_')] - eigenType_p
|
||||||
|
- keywords_p) | stlType_p;
|
||||||
|
|
||||||
|
namespace_p = lexeme_d[lower_p >> *(alnum_p | '_')] - keywords_p;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue