spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Error compiling a custom container for boost spirit


I'd simplify this by /just/ not treating things like a container and not-a-container at the same time. So for this particular situation I might deviate from my usual mantra (avoid semantic actions) and use them┬╣:

Live On Coliru

template <typename It, typename
Skipper = qi::blank_type>
struct grammar : qi::grammar<It, MyContainer(),
Skipper> {
    grammar() : grammar::base_type(start) {
        update_number = '=' > qi::double_ [
qi::_r1 = qi::_1 ];
        map_entry     = qi::int_ > ';' >
qi::int_;

        auto number =
phx::bind(&MyContainer::number, qi::_val);
        auto data   =
phx::bind(&MyContainer::data, qi::_val);

        start         = *(
            (   update_number(number) 
              | map_entry [ phx::insert(data,
phx::end(data), qi::_1) ]
            )
            >> qi::eol);
    }

  private:
    qi::rule<It, void(double&),      
Skipper> update_number;
    qi::rule<It, MyContainer::Pair(),
Skipper> map_entry;
    qi::rule<It, MyContainer(),      
Skipper> start;
};

If you can afford a (0;0) entry in your map, you can even dispense with the grammar:

Live On Coliru

std::map<int, int> data;
double number;

bool ok = qi::phrase_parse(f, l, 
       *(
            (qi::omit['=' > qi::double_
[phx::ref(number)=qi::_1]] 
          | (qi::int_ > ';' > qi::int_)
        ) >> qi::eol)
        , qi::blank, data);

I can try to make your "advanced spirit" approach work too, but it might take a while :)


┬╣ I use auto for readability, but of course you don't need to use that; just repeat the subexpressions inline or use BOOST_AUTO. Note that this is not generically good advice for stateful parser expressions (see BOOST_SPIRIT_AUTO)


Categories : C++

Related to : Error compiling a custom container for boost spirit
Writing a parser for a matrix-like input with Boost Spirit
You need to break down your expressions to something like this: rows: DOUBLE | rows ',' DOUBLE columns: rows | rows ';' rows matrix: IDENTIFIER '.' '{' IDENTIFIER '}' '=' '[' columns ']' Now you can have a vector<double> for your rows. A vector< vector<double> > for your columns, and save the result in your matrix. Of course, when you get a columns in your matrix, you shoul

Categories : C++
Compiling custom Bootstrap css in yii2 from less
I am using the basic app. To change some Bootstrap properties (field height for example) I did the following: Create a new css-file with changed properties: webcssootstrap-modified.css Add this file to assetsAppAssets.php: public $css = [ 'css/site.css', 'css/bootstrap-modified.css' ];

Categories : Twitter
Custom validator for boost program_options doesn't work with GCC, works with MSVC
On a preliminary hunch, consider using BOOST_STRONG_TYPEDEF(unsigned int, Unsigned); It seems like a bad idea to customize behaviour just on built-in types. Solution: It has to do with partial ordering. If you move your overload outside the boost::program_options namespace it will start working (as it no longer competes with the base template). Live On Coliru #include <iostream> #i

Categories : C++
Error when compiling PHP with openssl: recompile with -fPIC
If your system is 64bit, when you compile openssl, '-m64' would be added to the compile flag, just open Makefile of openssl, remove all '-m64', then make & make install and then go back to php source dir, make would be ok!

Categories : PHP
Undefined Reference Error When Compiling Wont go Away?
Assuming you are using GNU make. You didn't specify any link rule in your makefile, and the implicit link rule is: $(CC) $(LDFLAGS) n.o $(LOADLIBES) $(LDLIBS) where n.o is your object files. Further; the GNU linker requres that library names come after the object files that are supposed to link against those libraries, so if you change your LDFLAGS to LDLIBS then it may fix your problem. It'

Categories : C
Recently Add
VS2013 - Error with multiple includes of same header
Multiplying two large integers stored as integer vectors
How Do I Create a max Functor?
Eigen sparse matrix multiplications seem to compute full matrix
zlib compress() produces awful compression rate
How to delete a window?
passing variable without a name to function
OMNeT++ disassembling received messages
How do I ignore certain file types with cppcheck?
Posting a message to UI from business logic
STL algorithm/functional
su -c replacement using c++
How to use a sdk (non-ros header/lib/binaries) in ros package?
using std::chrono::high_resolution_clock to write a frame 30 times per second
Extracting ints and shorts from a struct using AVX?
Finding Bridges in a graph C++ (BOOST)?
Qt Creator cannot find library with custom cmake step
running visual studio release build .exe file in different machines
class oop realions cpp
Declare interface and Implement the interface using multi-inheritance in C++
How to access all elements of boost::multi_index::multi_index_container<> by their indices?
Understanding what a double pointer to a reference does C++
ld: symbol(s) not found for architecture x86_64 when compiling c++
Disconnected node during Graph traversal
Const behavior in operator >>
Structuring C++ Application (directory and folders)
Sendkey Function Enter Key Issue
Why the memory do not release after funciton call?
Passing C++ functions as arguments without function pointer/inlined?
How to create multiple objects inside of for loop with different names?
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.