|
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
(gentoo).
g++ -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\"
-DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"cs507_EC\"
-DVERSION=\"0.1.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
-DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1
-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
char*,
RE_Parser&, const boost::spirit::space_parser&)'
make[2]: *** [RE_Parser.o] Error 1
The code is:
--------------------
Parser
--------------------
#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[&RE_Parser::process_Kleene]
| (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
('0');
}
rule<ScannerT> r_rule, s_rule;
rule<ScannerT> const&
start() const { return r_rule;}
};
};
class RE_Parser {
public:
void process_Kleene (char const*, char const*){ cout << "Kleene star" <<
endl;};
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_ */
----------
Main
----------
#include "Parser.hpp"
#include <string>
#include <iostream>
#include <fstream>
using namespace re_parser;
int
main ()
{
RE_Parser reg_rdr;
string input_str;
ifstream reg_file;
reg_file.open("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;
}
else
{
cout << "Parsing failed. Stopped at: " << info.stop << endl;
}
}
}
Stephen
-- Stephen Torri GPG Key: http://www.cs.wustl.edu/~storri/storri.asc
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk