I mainly do an expression parser. Since I need the highest possible performance, and according to the documentation, building a grammar can be quite slow, I would like to reuse the grammar and attach the symbol table just before parsing. Since the grammar client is likely to have a character table that would be built and maintained ahead of the parsing, I would ideally want to avoid copying the actual table, which leads me to the following code (simplified) to translate the terms:
qi::symbols< char, double >* m_Symbols;
qi::rule< Iterator, double(), ascii::space_type > m_Val;
m_Val = qi::int_[ _val = boost::phoenix::static_cast_< double >( boost::spirit::_1 ) ] | qi::double_ | m_Symbols;
The problem here is in m_Symbols. I would like m_Val to hold m_Symbols by reference, since when we bind a character table, I naturally change the pointer, which I suppose can be somehow solved using boost :: phoenix :: ref? But the big problem is that I cannot use a pointer to parsers when building a new parser. Using dereferencing in m_Symbols difference expressions immediately, which is undesirable, I want to defer dereferencing to analyze time.
source
share