|
Boost Users : |
From: Mihalicza, Jozsef (JMihalicza_at_[hidden])
Date: 2005-09-09 20:40:47
Hello,
I've built a spirit grammer to process the token sequence of wave.
1. Scope missing in macros.
The first problem arose when I tried to write the wave token equivalent of chlit:
struct token_lit : public boost::spirit::char_parser<token_lit>
{
token_lit(boost::wave::token_id id_) : id(id_) {}
template <typename T>
bool test(T id_) const
{
return BASE_TOKEN(id_) == BASE_TOKEN(id);
}
boost::wave::token_id id;
};
The code above doesn't compile, because BASE_TOKEN uses constants from boost::wave without explicit scope. Lines to fix: token_ids.hpp(37-40,305,309).
2. Newline token reports bad position.
For debug purposes I reported the match positions in the grammer actions using the file_position interface of the wave token type. The results were quite strange, sometimes pointing into the middle of a keyword, so I decided to take a smaller step and modified the wave example (the one in the documentation) just to see what happens, as follows:
while (first != last) {
std::cout << "value: \"" << (*first).get_value() << "\" pos: " <<
(*first).get_position ().get_file () << "(" << (*first).get_position ().get_line () << ") @" <<
(*first).get_position ().get_column () << std::endl;
++first;
}
Attached you can find some very small inputs and their corresponding outputs.
2.1. A file containing only whites and comments produced no tokens at all
2.2. Position of the enter token reports the new line number but the old column
2.3. The #line directive affects the position in a very strange way
Please clarify if some of these are not errors.
Oops, I almost forgot, I am using a fresh verison from the CVS repository already containing the fix for the SF bug #1274584.
Best regards,
József Mihalicza
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