Fields of type lex::char_

Ryan Molden <[email protected]> Mon, 7 Nov 2011 09:03:56 -0800
Newsgroups gmane.comp.parsers.spirit.devel
Message-ID <CAKCJ3t4tgQbynnUP0JEKpMgU+iRVz-A2AF4EA5zwOCwvO67GXg@mail.gmail.com>
--===============8998915470832687004==
Content-Type: multipart/alternative; boundary=f46d04426dd04b9d9d04b1280aa6

--f46d04426dd04b9d9d04b1280aa6
Content-Type: text/plain; charset=ISO-8859-1

Sorry if this is duplicated, I originally sent it two days ago but I never
saw it appear back in my inbox as a list message (I actually haven't seen
*any* messages to this list yet...is it still active?), nor have I seen any
follow-up, so I thought I would send it again in case I hadn't been
properly registered as one allowed to send mail when I sent it the first
time.

I am having some problems having fields on my lexer of type lex::char_,
specifically I get the following errors in Visual Studio 2010 SP1 with
Boost 1.47

C2146: syntax error : missing ';' before identifier 'simple'
C2886: 'boost::spirit::standard::char_' : symbol cannot be used in a member
using-declaration
C4430: missing type specifier - int assumed. Note: C++ does not support
default-int
C2146: syntax error : missing ';' before identifier 'simple'
C2886: 'boost::spirit::standard::char_' : symbol cannot be used in a member
using-declaration
C4430: missing type specifier - int assumed. Note: C++ does not support
default-int

This is with the following simplified repro

#include <boost/spirit/include/lex_lexertl.hpp>

namespace lex = boost::spirit::lex;

template <typename Lexer>
struct lexer : lex::lexer<Lexer>
{
    lexer()
    {
        simple = lex::char_('.');
        this->self += simple;

        //This works, but I need/want to store the char_ object so I can
later reference its token ID from the parser level:
        //this->self += lex::char_('.');
        //
        //as does this (though in my real lexer I have LOTS of token_defs
and as I add more the compile time gets worse and worse):
        //
        //this->self += lex::token_def<>('.');
    }
    lex::char_ simple;
};

struct token_processor
{
    template <typename Token>
    bool operator()(Token const& t) const
    {
        return true;
    }
};

int main(int argc, char**argv[])
{
    std::string str (".");
    char const* first = str.c_str();
    char const* last = &first[str.size()];

     lexer<lex::lexertl::actor_lexer<> > l;
    bool r = lex::tokenize(first, last, l, token_processor());

    return 0;
}

Is this a Visual Studio 'issue' or something I am doing wrong?

Ryan

--f46d04426dd04b9d9d04b1280aa6
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div><div><div>Sorry if this is duplicated, I originally sent it two days a=
go but I never saw it appear back in my inbox as a list message (I actually=
 haven&#39;t seen *any* messages to this list yet...is it still active?), n=
or have I seen any follow-up, so I thought I would send it again in case I =
hadn&#39;t been properly registered as one allowed to send mail when I sent=
 it the first time.<br>
<br>
I am having some problems
 having fields on my lexer of type lex::char_, specifically I get the=20
following errors in Visual Studio 2010 SP1 with Boost 1.47</div><div>=A0</d=
iv><div>C2146: syntax error : missing &#39;;&#39; before identifier &#39;si=
mple&#39;</div>
<div>C2886: &#39;boost::spirit::standard::char_&#39; : symbol cannot be use=
d in a member using-declaration<br>C4430: missing type specifier - int assu=
med. Note: C++ does not support default-int</div><div>C2146: syntax error :=
 missing &#39;;&#39; before identifier &#39;simple&#39;</div>


<div>C2886: &#39;boost::spirit::standard::char_&#39; : symbol cannot be use=
d in a member using-declaration<br>C4430: missing type specifier - int assu=
med. Note: C++ does not support default-int</div><div>=A0</div><div>This is=
 with the following simplified repro</div>


<div>=A0</div><div>#include &lt;boost/spirit/include/lex_lexertl.hpp&gt;</d=
iv><div>=A0</div><div>namespace lex =3D boost::spirit::lex;</div><div>=A0</=
div><div>template &lt;typename Lexer&gt;<br>struct lexer : lex::lexer&lt;Le=
xer&gt;<br>


{<br>=A0=A0=A0 lexer()<br>=A0=A0=A0 {<br>=A0=A0=A0=A0=A0=A0=A0 simple =3D l=
ex::char_(&#39;.&#39;);<br>=A0=A0=A0=A0=A0=A0=A0 this-&gt;self +=3D simple;=
</div><div>=A0</div><div>=A0=A0=A0=A0=A0=A0=A0 //This works, but I need/wan=
t to store the char_ object so I can later reference its token ID from the =
parser level:<br>


=A0=A0=A0=A0=A0=A0=A0 //this-&gt;self +=3D lex::char_(&#39;.&#39;);<br>=A0=
=A0=A0=A0=A0=A0=A0 //<br>=A0=A0=A0=A0=A0=A0=A0=20
//as does this (though in my real lexer I have LOTS of token_defs and as
 I add more the compile time gets worse and worse):<br>=A0=A0=A0=A0=A0=A0=
=A0 //<br>=A0=A0=A0=A0=A0=A0=A0 //this-&gt;self +=3D lex::token_def&lt;&gt;=
(&#39;.&#39;);<br>
=A0=A0=A0 }</div><div>=A0=A0=A0 lex::char_ simple;<br>};</div><div>=A0</div=
><div>struct token_processor<br>{<br>=A0=A0=A0 template &lt;typename Token&=
gt;<br>=A0=A0=A0 bool operator()(Token const&amp; t) const<br>=A0=A0=A0 {<b=
r>=A0=A0=A0=A0=A0=A0=A0 return true;<br>=A0=A0=A0 }<br>


};</div><div>=A0</div><div>int main(int argc, char**argv[])<br>{<br>=A0=A0=
=A0 std::string str (&quot;.&quot;);</div><div>=A0=A0=A0 char const* first =
=3D str.c_str();<br>=A0=A0=A0 char const* last =3D &amp;first[str.size()];<=
/div><div>=A0</div><div>


<div>   =A0=A0=A0 lexer&lt;lex::lexertl::actor_lexer&lt;&gt; &gt; l;</div><=
/div><div>=A0=A0=A0 bool r =3D lex::tokenize(first, last, l, token_processo=
r());</div><div>=A0=A0=A0=A0</div><div>=A0=A0=A0 return 0;<br>}</div><div>=
=A0</div><div>Is this a Visual Studio &#39;issue&#39; or something I am doi=
ng wrong?</div>


<div>=A0</div><font color=3D"#888888"><div>Ryan</div>
</font></div></div>

--f46d04426dd04b9d9d04b1280aa6--


--===============8998915470832687004==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
--===============8998915470832687004==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Spirit-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

--===============8998915470832687004==--