Boost logo

Boost Users :

Subject: [Boost-users] [xpressive] Using placeholder in semantic actions
From: Symons, Greg - SSD (Greg.Symons_at_[hidden])
Date: 2008-09-04 11:13:36


Hi!

I'm trying to use xpressive with semantic actions that use a placeholder, but I
can't quite see the right way to do it. Here's my code:

namespace grammar
{
   using namespace boost::xpressive;

   struct ParsedUri
   {
      std::string hostname;
      std::string modelPath;
      std::string diagramPath;
   };

   static placeholder<ParsedUri> result;

   static const mark_tag model(1), diagram(2), host(1);
   static const char pathSep = '/';

   static sregex unreserved =
                                 set
                                 [
                                    alpha |
                                    digit |
                                    '-' |
                                    '.' |
                                    '_' |
                                    '~' |
                                    ' ' |
                                    ':' |
                                    '$'
                                 ];
   static sregex pctEncoded =
                                 as_xpr('%') >> xdigit >> xdigit;
   static sregex pathElem =
                                 *(unreserved | pctEncoded);
   static sregex path =
                                 pathElem |
                                 *(pathElem >> pathSep >> by_ref(path));
   static sregex drive =
                                 alpha >> ':';
   static sregex quad =
                                 repeat<1,3>(digit)
                                 [ check(as<int>(_) >= 1 && as<int>(_) <= 255) ];
   static sregex ipv4 =
                                 repeat<3>(quad >> '.') >> quad;
   static sregex hostname = !(ipv4 | pathElem);
   static sregex pathNoHost =
                                 pathSep >> drive >> pathSep >> path;
   static sregex pathHost =
                                 (host= hostname) >> pathSep >> path
                                 [ result.hostname = host ];
   static sregex modelPath = pathNoHost | pathHost
   static sregex uri =
                                 "rosert://" >> (model= modelPath) >> '?' >> (diagram= path)
                                 [ result.modelPath = model, result.diagramPath = diagram ];
}

What happens is that when I compile the code, I get a compile error for the
lines accessing the placeholder saying that the various members of the structure
are not members of placeholder<T>, which looking at regex_actions.hpp seems to
make sense to me. But in the example using placeholder<T> in the docs, it looks
like you can use it in the semantic action as if it were a T. Somewhere I'm
misunderstanding something, and I don't know what. Can anyone help me here?

--
Gregory Symons
Software Engineer
ITT Space Systems Division
greg.symons_at_[hidden]
(260) 451-6402
This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

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