|
Boost Users : |
From: K M (krbyxtrm_at_[hidden])
Date: 2006-04-04 21:17:44
Hi,
I have this parser that parses string that represents a function, (a
c++ function prototype to say)
CONSIDER:
bool
parse_info<> x_parser4(char const* str, FunctionSpec& spec)
{
// some rules...
rettype
= lexeme_d[
(alpha_p)
>> *(alnum_p | space_p | ch_p('*'))
][list_actor(spec)];
// assign function name when match...
function
= lexeme_d[
(alpha_p | ch_p('_'))
>> *(alnum_p | ch_p('_'))
][assign_a(spec.m_Name)];
// other rules....
....
return parse(str,top);
}
// Here's what my struct looks like:
struct FunctionSpec {
std::string m_Name;
enum eVarType {
VAR_VOID, VAR_BOOL, VAR_INT...
}
eVarType m_RetType;
};
In the function rule what i did was just to assign the name to the
m_Name of spec
In the rettype tule what i did there was to pass the match string
along with the struct (spec) to a class (list_actor) using the
operator()...
Problem is that i can't jsut assign m_RetType to the 'matched string'
delivered to list_actor's operator() since this one is an enumerated
type;
In the code i attached, there is a function that 'maps' a string to
eVarType, but i can't call this function within the list_actor's
operator() body?
i.e.
template <typename ActionIterT>
operator(...,...)
{
// can't do here?
// tried to bind the function but it didn't work as well...
}
In summary what i need to do is to assign value for m_RetType and
other members of FunctionSpec using the strings i get from parsing,
e.g.
when i get the string "void" for a match in the rettype rule,
m_RetType will be assigned to VAR_VOID. etc.
-----
krby
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net