Boost logo

Boost Users :

Subject: [Boost-users] [Spirit] How to prohibit reserved names from matching
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2018-12-06 15:02:50


Let's say I have some Qi rules:

qi::rule<It, char()> mych;
qi::rule<It, std::string()> myname;

struct reserved_names_t : qi::symbols<path_t, path_t> {
    reserved_names_t() {
        this->add("CON", "CON")
            ("PRN", "PRN")
            ("AUX", "AUX")
            ("NUL", "NUL")
            ("COM1", "COM1")
            ("COM2", "COM2")
            ("COM3", "COM3")
            ("COM4", "COM4")
            ("COM5", "COM5")
            ("COM6", "COM6")
            ("COM7", "COM7")
            ("COM8", "COM8")
            ("COM9", "COM9")
            ("LPT1", "LPT1")
            ("LPT2", "LPT2")
            ("LPT3", "LPT3")
            ("LPT4", "LPT4")
            ("LPT5", "LPT5")
            ("LPT6", "LPT6")
            ("LPT7", "LPT7")
            ("LPT8", "LPT8")
            ("LPT9", "LPT9")
} reserved_names;

Assuming I've defined mych accordingly, the simple approach would be:

myname %= +myname;

This gets me the name in the character set. Now, I want to prohibit
the reserved names from matching.

myname %= ~qi::no_case[reserved_names] | +myname;

However, this does not seem to work. I suppose it is one thing ruling
out invalid characters, but what about prohibiting whole strings?

Thanks in advance for any insights...

Michael Powell

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at