Boost logo

Boost :

From: Stephen Torri (storri_at_[hidden])
Date: 2004-03-29 21:54:17

I am having problems with compiling a simple parsing example that I created.
I have read over half of the spirit guide and took one of the examples a
guide for creating my program. Here is the full error message that I hinted
above. What is wrong with my code? I am using boot-1.31.0 with gcc-3.3.2

-DHAVE_DLFCN_H=1 -I. -I. -I../../src -O2 -c -o RE_Parser.o `test -f
RE_Parser.cpp || echo './'`RE_Parser.cpp
RE_Parser.cpp: In function `int main()':
RE_Parser.cpp:18: error: no matching function for call to `parse(const
   RE_Parser&, const boost::spirit::space_parser&)'
make[2]: *** [RE_Parser.o] Error 1

The code is:

#ifndef RE_PARSER_H_
#define RE_PARSER_H_

#include <string>
#include "FileException.hpp"
#include <boost/spirit.hpp>
#include <iostream>

using namespace std;
using namespace boost::spirit;

//namespace re_parser {

class RE_Parser;

struct RE_Grammar : public grammar<RE_Grammar>

  template <typename ScannerT>
  struct definition
    definition (RE_Grammar const& self)
      r_rule =
        | (r_rule >> s_rule)[&RE_Parser::process_Concat]
        | (r_rule >> ch_p('+') >> s_rule)[&RE_Parser::process_Or]
        | s_rule[&RE_Parser::process_Char];

      s_rule = ch_p('a') | ch_p ('b') | ch_p ('c') | ch_p ('^') | ch_p

    rule<ScannerT> r_rule, s_rule;

    rule<ScannerT> const&
    start() const { return r_rule;}

  class RE_Parser {
    void process_Kleene (char const*, char const*){ cout << "Kleene star" <<
    void process_Concat (char const*, char const*){ cout << "Concatenate" <<
endl; };
    void process_Or (char const*, char const*, char* const*){ cout << "Or"
<< endl;};
    void process_Char (char const*){ cout << "Char" << endl;};


//} /* namespace re_parser */

#endif /* RE_PARSER_H_ */

#include "Parser.hpp"
#include <string>
#include <iostream>
#include <fstream>

using namespace re_parser;

main ()
  RE_Parser reg_rdr;
  string input_str;
  ifstream reg_file;"reg_expr.txt");
  while (getline(reg_file,input_str))
      parse_info<> info = parse(input_str.c_str(), reg_rdr, space_p);

      if (info.full)
          cout << "Parsing succeeded." << endl;
          cout << "Parsing failed. Stopped at: " << info.stop << endl;


Stephen Torri
GPG Key:

Boost list run by bdawes at, gregod at, cpdaniel at, john at