Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Compiler errors when using Boost::Spirit
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Evan Driscoll  
View profile  
 More options Aug 7 2012, 11:47 am
From: Evan Driscoll <drisc...@cs.wisc.edu>
Date: Tue, 07 Aug 2012 10:47:08 -0500
Local: Tues, Aug 7 2012 11:47 am
Subject: [Boost-users] Compiler errors when using Boost::Spirit
Hey all,

I'm new to Spirit and trying to put a parser together for a very simple
language of S expressions. [Note: while I'm new to Spirit, I'm not new
to parsers or parser combinators.]

This is sort of an obnoxious email because it's basically "here, solve
my problem for me even though I haven't read the docs as well as I
could", but I figured I'd ask anyway; so if you take a look, I'm much
appreciative.

I define some tokens
   template <typename Lexer>
   struct tokens : lex::lexer<Lexer> {
     tokens()  {
         this->self.add
             ("(",         Tokens::L_Paren)
             (")",         Tokens::R_Paren)
             ("\"...\"",   Tokens::String_Literal)
            ("[0-9]+",    Tokens::Integer_Literal)
             ("[a-zA-Z]+", Tokens::Symbol)
             ;
       }
   };

Then a grammar:
   template <typename Iterator>
   struct sexp_grammar
     : qi::grammar<Iterator, SExp::Ptr(), space_type>
   {
     qi::rule<Iterator, SExp::Ptr(), space_type> sexp;
     qi::rule<Iterator, vector<SExp::Ptr>(), space_type> sexp_list;

     sexp_grammar()
        : sexp_grammar::base_type(sexp)
     {
        using qi::token;
        using namespace Tokens;

        sexp_list = *sexp;

        sexp = token(String_Literal)
            |  token(Integer_Literal)
            |  token(Symbol)
            | (token(L_Paren)
               >> sexp_list
               >> token(R_Paren)
               );
     }
   };

(SExp is a class, and SExp::Ptr is a typedef to shared_ptr<SExp>.)

If I change the  also tried removing the template parameters other than
Iterator in the rules, and that let it compile (albeit with a warning).

I get oodles of errors (compiling with GCC 4.6 with
    g++ -o src/parser.os -c -std=c++0x -g -Wall -Wextra
        -Wnon-virtual-dtor -fPIC -Iinclude src/parser.cc)
which I'm not even going to try to paste into this email and you can
look at pastebin instead:
    http://pastebin.com/R5Hk9gJ0

The full code can be seen at
   https://github.com/EvanED/simple_sexp/blob/master/src/parser.cc

Evan
_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.