24 #define BOOST_SPIRIT_DEBUG 29 #include <boost/spirit/include/classic_core.hpp> 30 #include <boost/spirit/include/classic_multi_pass.hpp> 40 typedef std::input_iterator_tag iterator_category;
41 typedef char value_type;
42 typedef ptrdiff_t difference_type;
43 typedef char* pointer;
44 typedef char& reference;
46 friend bool operator==(MY_ITERATOR
const& a, MY_ITERATOR
const& b) {
return false; }
47 friend bool operator!=(MY_ITERATOR
const& a, MY_ITERATOR
const& b) {
return true; }
48 value_type& operator*(
void) {
return M_dummy; }
49 value_type
const& operator*(
void)
const {
return M_dummy; }
50 MY_ITERATOR& operator++(
void) {
return*
this; }
52 MY_ITERATOR(
void) : M_dummy(
'?') { }
53 MY_ITERATOR(MY_ITERATOR
const& iter) : M_dummy(iter.M_dummy) { }
54 MY_ITERATOR& operator=(MY_ITERATOR
const& iter) { M_dummy = iter.M_dummy; }
60 typedef MY_ITERATOR iterator_t;
62 typedef boost::spirit::classic::skip_parser_iteration_policy<boost::spirit::classic::space_parser> iter_policy_t;
63 typedef boost::spirit::classic::scanner_policies<iter_policy_t> scanner_policies_t;
64 typedef boost::spirit::classic::scanner<iterator_t, scanner_policies_t> scanner_t;
66 iter_policy_t iter_policy(boost::spirit::classic::space_p);
67 scanner_policies_t policies(iter_policy);
71 int main(
int argc,
char* argv[])
73 Debug(NAMESPACE_DEBUG::init());
75 for (
int i = 1; i < argc; ++i)
77 if (std::string(argv[i]) ==
"/home/carlo/chess/freechess.ladder/0018.pgn")
79 std::cout <<
"Trying to parse file \"" << argv[i] <<
"\"." << std::endl;
80 std::ifstream in(argv[i]);
85 boost::spirit::classic::parse_info<iterator_t> info = boost::spirit::classic::parse(first, last, g);
88 std::cout <<
"Failure to parse anything." << std::endl;
92 std::cout << info.length <<
" characters have been parsed successfully." << std::endl;
This file contains the declaration of class PgnGrammar.