[Spirit] How to prohibit reserved names from matching

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Spirit] How to prohibit reserved names from matching

Boost - Users mailing list
Hello,

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 mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users