Successfully used TypeListGrammar
parent
4d1225cda7
commit
9a77072654
|
@ -114,35 +114,25 @@ void Module::parseMarkup(const std::string& data) {
|
|||
// TODO, do we really need cls here? Non-local
|
||||
Class cls0(verbose),cls(verbose);
|
||||
|
||||
// parse "gtsam::Pose2" and add to templateArgValues
|
||||
Qualified templateArgValue;
|
||||
vector<Qualified> templateArgValues;
|
||||
TypeGrammar templateArgValue_g(templateArgValue);
|
||||
Rule templateArgValue_p = templateArgValue_g
|
||||
[push_back_a(templateArgValues, templateArgValue)]
|
||||
[clear_a(templateArgValue)];
|
||||
|
||||
// template<CALIBRATION = {gtsam::Cal3DS2}>
|
||||
string templateArgName;
|
||||
vector<Qualified> templateArgValues;
|
||||
TypeListGrammar<'{','}'> templateArgValues_g(templateArgValues);
|
||||
Rule templateArgValues_p =
|
||||
(str_p("template") >>
|
||||
'<' >> basic.name_p[assign_a(templateArgName)] >> '=' >>
|
||||
'{' >> !(templateArgValue_p >> *(',' >> templateArgValue_p)) >> '}' >>
|
||||
'>');
|
||||
templateArgValues_g >> '>');
|
||||
|
||||
// parse "gtsam::Pose2" and add to singleInstantiation.typeList
|
||||
TemplateInstantiationTypedef singleInstantiation, singleInstantiation0;
|
||||
Rule templateSingleInstantiationArg_p = templateArgValue_g
|
||||
[push_back_a(singleInstantiation.typeList, templateArgValue)]
|
||||
[clear_a(templateArgValue)];
|
||||
TypeListGrammar<'<','>'> typelist_g(singleInstantiation.typeList);
|
||||
|
||||
// typedef gtsam::RangeFactor<gtsam::Pose2, gtsam::Point2> RangeFactorPosePoint2;
|
||||
vector<string> namespaces; // current namespace tag
|
||||
TypeGrammar instantiationClass_g(singleInstantiation.class_);
|
||||
Rule templateSingleInstantiation_p =
|
||||
(str_p("typedef") >> instantiationClass_g >>
|
||||
'<' >> templateSingleInstantiationArg_p >> *(',' >> templateSingleInstantiationArg_p) >>
|
||||
'>' >>
|
||||
typelist_g >>
|
||||
basic.className_p[assign_a(singleInstantiation.name_)] >>
|
||||
';')
|
||||
[assign_a(singleInstantiation.namespaces_, namespaces)]
|
||||
|
|
|
@ -218,7 +218,8 @@ public:
|
|||
|
||||
/* ************************************************************************* */
|
||||
// http://boost-spirit.com/distrib/spirit_1_8_2/libs/spirit/doc/grammar.html
|
||||
struct TypeListGrammar: public classic::grammar<TypeListGrammar> {
|
||||
template <char OPEN, char CLOSE>
|
||||
struct TypeListGrammar: public classic::grammar<TypeListGrammar<OPEN,CLOSE> > {
|
||||
|
||||
typedef std::vector<wrap::Qualified> TypeList;
|
||||
TypeList& result_; ///< successful parse will be placed in here
|
||||
|
@ -244,7 +245,7 @@ struct TypeListGrammar: public classic::grammar<TypeListGrammar> {
|
|||
type_p = self.type_g //
|
||||
[push_back_a(self.result_, self.type)] //
|
||||
[clear_a(self.type)];
|
||||
typeList_p = '{' >> !type_p >> *(',' >> type_p) >> '}';
|
||||
typeList_p = OPEN >> !type_p >> *(',' >> type_p) >> CLOSE;
|
||||
}
|
||||
|
||||
Rule const& start() const {
|
||||
|
|
|
@ -90,7 +90,7 @@ TEST( TypeList, grammar ) {
|
|||
|
||||
// Create type grammar that will place result in actual
|
||||
vector<Qualified> actual;
|
||||
TypeListGrammar g(actual);
|
||||
TypeListGrammar<'{','}'> g(actual);
|
||||
|
||||
EXPECT(parse("{gtsam::Point2}", g, space_p).full);
|
||||
EXPECT_LONGS_EQUAL(1, actual.size());
|
||||
|
|
Loading…
Reference in New Issue