this is my small sample .. i have a language and on parsing i have something like
foo()
nextfoo() <-- here an error appears because of the keyword "next"
so the grammer
typedef boost::proto::result_of::deep_copy<BOOST_TYPEOF(ascii::no_caseqi::lit(std::wstring())])>::type nocaselit_return_type;
nocaselit_return_type nocaselit(const std::wstring& keyword)
{
return boost::proto::deep_copy(ascii::no_case[qi::lit(keyword)]);
}
keywords = nocaselit(L"next")
| nocaselit(L"else")
| nocaselit(L"if")
| nocaselit(L"then")
| nocaselit(L"for")
| nocaselit(L"to")
| nocaselit(L"dim")
| nocaselit(L"true")
| nocaselit(L"false")
| nocaselit(L"as")
| nocaselit(L"class")
| nocaselit(L"end")
| nocaselit(L"function")
| nocaselit(L"new")
| nocaselit(L"sub");
name_valid = !keywords>> lexeme[+(boost::spirit::standard_wide::alpha | '_') >> *(boost::spirit::standard_wide::alnum | '_')];
i learned from docu and goolge that i have to write something like this one to make the parser work correct with keywords
name_valid = distinct(Keywords)[ lexeme[+(boost::spirit::standard_wide::alpha | '_') >> *(boost::spirit::standard_wide::alnum | '_')] ];
but this don´t work .. can sombody explain me why ?
Special question .. as Long as i use the Syntax above i get an template compiler error the work sample must be written as the following (the Keywords list is inline instead a rule). I assume that this has someting to do with the type spec of the rule .. but what is the correct one ?
name_valid = distinct(nocaselit(L"next")| nocaselit(L"else") | ... )
[ lexeme[+(boost::spirit::standard_wide::alpha | '_') >> *(boost
thank you