|
Boost Users : |
From: Ç®ÏþÃ÷ (kyleqian_at_[hidden])
Date: 2008-04-11 12:54:39
I want to use spirit parsing some text file. The very basic element in those
files is string, float and int. For example:
123L
"hello"
987.4343
I wrote my grammar class:
struct pm_parser : public grammar<pm_parser>
{
template <typename ScannerT>
struct definition
{
definition(pm_parser const& self)
{
factor =
int_p[show_int()]>>"L"
| '"'>> *((~ch_p('"'))[show_char()]) >>'"'
| real_p[show_double()]
;
}
rule<ScannerT> factor;
rule<ScannerT> const& start() const { return factor; }
};
};
show_int, show_char, show_double are structs used to show int, char and
double value. When I parse 1L, it works. But when I parse 1, it is parsed
twice(int_p and real_p are all works).
How can I define grammar struct to parse text above without errors?
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