Skip to content
Snippets Groups Projects
Commit 978fb992 authored by Matthias Schoepfer's avatar Matthias Schoepfer
Browse files

noting big

parent 1639e6d6
Branches
Tags
No related merge requests found
#include <boost/spirit/include/qi.hpp>
#include <iostream>
#include <string>
namespace qi = boost::spirit::qi;
namespace px = boost::phoenix;
namespace ascii = boost::spirit::ascii;
typedef qi::rule<std::string::const_iterator,std::string(),qi::ascii::space_type> RuleType;
typedef RuleType* RuleTypePtr;
template <typename Iterator>
struct dynamicParser : qi::grammar<Iterator,std::string(), boost::spirit::ascii::space_type> {
dynamicParser (std::vector<qi::rule<Iterator,std::string(), qi::ascii::space_type>* > rules) : dynamicParser::base_type(startRule) {
rulestack = rules;
startRule = *(rulestack.at(0));
}
std::vector<qi::rule<Iterator,std::string(),qi::ascii::space_type>* > rulestack;
qi::rule<Iterator,std::string(), qi::ascii::space_type> startRule;
};
int
main (int argc, char** argv) {
std::vector<RuleTypePtr> myRuleVector;
myRuleVector.push_back (new RuleType(qi::eps));//This rule is going to get replaced
myRuleVector.push_back (new RuleType(qi::string("Hello")));
myRuleVector.push_back (new RuleType(qi::string("Hi")));
myRuleVector.push_back (new RuleType(qi::string("Whats up")));
//Now magically compose a rule *with arbitrary vectorsize*
//I have no clue how to do this
//But it should result in:
myRuleVector.at(0) = new RuleType ((*myRuleVector.at(1)) | (*myRuleVector.at(2)) | ((*myRuleVector.at(3))));
dynamicParser<std::string::const_iterator> myDynamicParser(myRuleVector);
std::string s ("Hi");
std::string attr;
if (qi::phrase_parse ((std::string::const_iterator)s.begin(),(std::string::const_iterator)s.end(),myDynamicParser,ascii::space,attr))
std::cout << "Parse success" << std::endl;
else
std::cout << "Parse failed" << std::endl;
return 0;
}
......@@ -92,7 +92,7 @@
<buildCommandWorkingDir>.</buildCommandWorkingDir>
<buildCommand>${MAKE} -f Makefile</buildCommand>
<cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
<executablePath></executablePath>
<executablePath>src/pocketsphinxAdapter</executablePath>
</makeTool>
</makefileType>
<item path="build/CMakeFiles/2.8.10.2/CompilerIdC/CMakeCCompilerId.c"
......
......@@ -25,43 +25,7 @@
<in>moc_measureDb.cxx</in>
</df>
</df>
<df name="cmake">
<df name="Modules">
</df>
</df>
<df name="CMakeFiles">
<df name="2.8.10.2">
<df name="CompilerIdC">
<in>CMakeCCompilerId.c</in>
</df>
<df name="CompilerIdCXX">
<in>CMakeCXXCompilerId.cpp</in>
</df>
</df>
<df name="CMakeTmp">
</df>
<df name="CompilerIdC">
<in>CMakeCCompilerId.c</in>
</df>
<df name="CompilerIdCXX">
<in>CMakeCXXCompilerId.cpp</in>
</df>
</df>
<df name="src">
<df name="CMakeFiles">
<df name="jsgfParser.dir">
</df>
<df name="jsgfParserTest.dir">
</df>
<df name="measureAlsaDb.dir">
</df>
<df name="measureDb.dir">
</df>
<df name="parserToyExample.dir">
</df>
<df name="pocketsphinxAdapter.dir">
</df>
</df>
<in>AlsaMicGrabber.cpp</in>
<in>AlsaMicGrabber.h</in>
<in>EqualizerColorWidget.cpp</in>
......@@ -97,7 +61,6 @@
<in>moc_SimpleDoubleThresholdSegmenter.cxx</in>
<in>moc_SimpleTextAddField.cxx</in>
<in>moc_measureDb.cxx</in>
<in>moc_pocketsphinxAdapter.cxx</in>
</df>
<in>pocketsphinxAdapterConfig.h</in>
</df>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment