I saw several posts related to the nuances of using keywords / identifiers in qi grammars, but I can’t understand how the approach demonstrated in the enhancement examples should work ...
Keyword Declaration:
qi::symbols<char> keywords;
An example of a set of keywords:
keywords.add ("foo") ("bar") ;
ID rule declaration:
qi::rule<std::string::const_iterator, std::string(), ascii::space_type> identifier;
Here, as a rule, the identifier is defined in the qi calc and compiler examples:
identifier = !keywords >> qi::raw[ qi::lexeme[ ( qi::alpha | '_' ) >> *( qi::alnum | '_' ) ] ];
I may not read the qi syntax correctly, but it seems to me that this will not accept any literal that matches or starts with a keyword. Rejecting full keyword match is the desired behavior. But I want to accept "food" as an identifier, although it starts with the keyword "foo". This seems like a pretty standard use case, but the problem is finding documentation that really fixes this.
Can someone suggest an identifier rule that rejects only exact keyword matches?
Thanks!
source share