Spirit X3 employee.cpp compile error

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Spirit X3 employee.cpp compile error

Vincent Virgilio
Visual Studio 2015 Professional
Boost 1.61, Windows binary install
Spirit X3 example 'employee.cpp' (http://ciere.com/example/x3/employee.cpp)

Unless I add a third template argument of 'true' to the declaration of the employee rule, compilation fails with the below message. It's tripping on an ambiguous overload.

Vince




1>------ Build started: Project: employee, Configuration: Release Win32 ------

1> employee.cpp

1>C:\local\boost_1_61_0\boost/spirit/home/x3/nonterminal/rule.hpp(116): error C2668: 'client::parser::parse_rule': ambiguous call to overloaded function

1> ..\..\x3\example\employee.cpp(86): note: could be 'bool client::parser::parse_rule<Iterator,Context,Attribute_>(const boost::spirit::x3::rule<client::parser::employee,client::ast::employee,false>,Iterator &,const Iterator &,const Context &,Attribute &)' [found using argument-dependent lookup]

1> with

1> [

1> Iterator=std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>,

1> Context=boost::spirit::x3::context<boost::spirit::x3::skipper_tag,const boost::spirit::x3::ascii::space_type,boost::spirit::x3::unused_type>,

1> Attribute_=client::ast::employee,

1> Attribute=client::ast::employee

1> ]

1> C:\local\boost_1_61_0\boost/spirit/home/x3/nonterminal/rule.hpp(30): note: or 'boost::spirit::x3::detail::default_parse_rule_result boost::spirit::x3::parse_rule<client::parser::employee,client::ast::employee,Iterator,Context,Attribute_>(boost::spirit::x3::rule<client::parser::employee,client::ast::employee,false>,Iterator &,const Iterator &,const Context &,ActualAttribute &)'

1> with

1> [

1> Iterator=std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>,

1> Context=boost::spirit::x3::context<boost::spirit::x3::skipper_tag,const boost::spirit::x3::ascii::space_type,boost::spirit::x3::unused_type>,

1> Attribute_=client::ast::employee,

1> ActualAttribute=client::ast::employee

1> ]

1> C:\local\boost_1_61_0\boost/spirit/home/x3/nonterminal/rule.hpp(116): note: while trying to match the argument list '(const boost::spirit::x3::rule<client::parser::employee,client::ast::employee,false>, std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>, const std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>, const boost::spirit::x3::context<boost::spirit::x3::skipper_tag,const Derived,boost::spirit::x3::unused_type>, client::ast::employee)'

1> with

1> [

1> Derived=boost::spirit::x3::ascii::space_type

1> ]

1> C:\local\boost_1_61_0\boost/spirit/home/x3/core/parse.hpp(117): note: see reference to function template instantiation 'bool boost::spirit::x3::rule<client::parser::employee,client::ast::employee,false>::parse<Iterator,boost::spirit::x3::context<boost::spirit::x3::skipper_tag,const Derived,boost::spirit::x3::unused_type>,Attribute>(Iterator &,const Iterator &,const Context &,boost::spirit::x3::unused_type,Attribute_ &) const' being compiled

1> with

1> [

1> Iterator=std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>,

1> Derived=boost::spirit::x3::ascii::space_type,

1> Attribute=client::ast::employee,

1> Context=boost::spirit::x3::context<boost::spirit::x3::skipper_tag,const boost::spirit::x3::ascii::space_type,boost::spirit::x3::unused_type>,

1> Attribute_=client::ast::employee

1> ]

1> C:\local\boost_1_61_0\boost/spirit/home/x3/core/parse.hpp(117): note: see reference to function template instantiation 'bool boost::spirit::x3::rule<client::parser::employee,client::ast::employee,false>::parse<Iterator,boost::spirit::x3::context<boost::spirit::x3::skipper_tag,const Derived,boost::spirit::x3::unused_type>,Attribute>(Iterator &,const Iterator &,const Context &,boost::spirit::x3::unused_type,Attribute_ &) const' being compiled

1> with

1> [

1> Iterator=std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>,

1> Derived=boost::spirit::x3::ascii::space_type,

1> Attribute=client::ast::employee,

1> Context=boost::spirit::x3::context<boost::spirit::x3::skipper_tag,const boost::spirit::x3::ascii::space_type,boost::spirit::x3::unused_type>,

1> Attribute_=client::ast::employee

1> ]

1> C:\local\boost_1_61_0\boost/spirit/home/x3/core/parse.hpp(134): note: see reference to function template instantiation 'bool boost::spirit::x3::phrase_parse_main<Iterator,Parser,Skipper,Attribute>(Iterator &,Iterator,const Parser &,const Skipper &,Attribute &,boost::spirit::x3::skip_flag)' being compiled

1> with

1> [

1> Iterator=std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>,

1> Parser=boost::spirit::x3::rule<client::parser::employee,client::ast::employee,false>,

1> Skipper=boost::spirit::x3::ascii::space_type,

1> Attribute=client::ast::employee

1> ]

1> ..\..\x3\example\employee.cpp(118): note: see reference to function template instantiation 'bool boost::spirit::x3::phrase_parse<std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>,boost::spirit::x3::rule<client::parser::employee,client::ast::employee,false>,boost::spirit::x3::ascii::space_type,client::ast::employee>(Iterator &,Iterator,const Parser &,const Skipper &,Attribute &,boost::spirit::x3::skip_flag)' being compiled

1> with

1> [

1> Iterator=std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>,

1> Parser=boost::spirit::x3::rule<client::parser::employee,client::ast::employee,false>,

1> Skipper=boost::spirit::x3::ascii::space_type,

1> Attribute=client::ast::employee

1> ]

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

Joel de Guzman
On 11/08/2016 12:12 PM, Vincent Virgilio wrote:
> Visual Studio 2015 Professional
> Boost 1.61, Windows binary install
> Spirit X3 example 'employee.cpp' (http://ciere.com/example/x3/employee.cpp)
>
> Unless I add a third template argument of 'true' to the declaration of the employee rule,
> compilation fails with the below message. It's tripping on an ambiguous overload.

X3 does not (officially) support VS.

regards,
--
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

Vincent Virgilio
In reply to this post by Vincent Virgilio
Thank you for the response. I should've looked more closely.

I did move onto another small Spirit project, with some partial success. Here it is at coliru:


I think the compilation fails when it reaches phrase_parse. Container_traits tries to query a std::pair<> in my rules for 'value_type'. There's a specialization for pair<> in container_traits (just above line 77) that seems to be missed.

/usr/local/include/boost/spirit/home/x3/support/traits/container_traits.hpp:69:12: error: no type named 'value_type' in 'struct std::pair<int, std::vector<std::__cxx11::basic_string<char> > >'

I'm very new to Spirit, so likely it's due to a simple mis-use.

Thanks again,

Vince


On Aug 12, 2016, at 12:10 AM, Joel de Guzman <[hidden email]> wrote:

On 11/08/2016 12:12 PM, Vincent Virgilio wrote:
Visual Studio 2015 Professional
Boost 1.61, Windows binary install
Spirit X3 example 'employee.cpp' (http://ciere.com/example/x3/employee.cpp)

Unless I add a third template argument of 'true' to the declaration of the employee rule,
compilation fails with the below message. It's tripping on an ambiguous overload.

X3 does not (officially) support VS.

regards,
--
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

cppljevans
In reply to this post by Vincent Virgilio
On 08/10/2016 11:12 PM, Vincent Virgilio wrote:

> Visual Studio 2015 Professional
> Boost 1.61, Windows binary install
> Spirit X3 example 'employee.cpp' (http://ciere.com/example/x3/employee.cpp)
>
> Unless I add a third template argument of 'true' to the declaration of
> the employee rule, compilation fails with the below message. It's
> tripping on an ambiguous overload.
>
> Vince
>
[snip]
Hi Vince.

FWIW, the code here:

https://github.com/boostorg/spirit/blob/develop/include/boost/spirit/home/x3/nonterminal/rule.hpp#L75

does require a 3ird bool template argument.

However, the documentation here:

http://ciere.com/cppnow15/x3_docs/spirit/quick_reference/non_terminals.html

does not.

Maybe the ciere.com employee.cpp is based on a different library,
one where rule only has 2 template arguments.  I've tried, without
success, to find where on ciere.com that library might be available :(
When I pointed my browser to:

http://ciere.com/cppnow15/

it showed the link:

   X3 Documentation

pointing to:

   http://ciere.com/cppnow15/x3_docs/

but it also showed:

--{--cut here--
Spirit X3 Source

GitHub: [hidden email]:boostorg/spirit.git

Use the develop branch.
--}--cut here--

and following the GitHub link:

https://github.com/boostorg/spirit/

lead to, eventually:

https://github.com/boostorg/spirit/blob/develop/include/boost/spirit/home/x3/nonterminal/rule.hpp#L75

which is where rule has 3 template arguments :(

So, I gave up at that point trying to find the 2 template argument rule
code :(

-regards,
Larry




------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

cppljevans
On 08/12/2016 06:33 AM, Larry Evans wrote:

> On 08/10/2016 11:12 PM, Vincent Virgilio wrote:
>> Visual Studio 2015 Professional
>> Boost 1.61, Windows binary install
>> Spirit X3 example 'employee.cpp' (http://ciere.com/example/x3/employee.cpp)
>>
>> Unless I add a third template argument of 'true' to the declaration of
>> the employee rule, compilation fails with the below message. It's
>> tripping on an ambiguous overload.
>>
>> Vince
>>
> [snip]
> Hi Vince.
>
> FWIW, the code here:
>
> https://github.com/boostorg/spirit/blob/develop/include/boost/spirit/home/x3/nonterminal/rule.hpp#L75
>
> does require a 3ird bool template argument.
>
[snip]

> GitHub: [hidden email]:boostorg/spirit.git
>
> Use the develop branch.
> --}--cut here--
>
The 2 template arg rule code is actually in the x3-devel branch instead
of the develop branch:

https://github.com/boostorg/spirit/blob/x3-devel/include/boost/spirit/home/x3/nonterminal/rule.hpp#L80

I shouldn't have given up so easily ;(

-regards,
Larry




------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

cppljevans
On 08/12/2016 06:40 AM, Larry Evans wrote:
[snip]

>
>> GitHub: [hidden email]:boostorg/spirit.git
>>
>> Use the develop branch.
>> --}--cut here--
>>
> The 2 template arg rule code is actually in the x3-devel branch instead
> of the develop branch:
>
> https://github.com/boostorg/spirit/blob/x3-devel/include/boost/spirit/home/x3/nonterminal/rule.hpp#L80
>
[snip]
However, if you decide to use x3-devel, then the employee.cpp code
referenced in your OP needs to be modified so that the arguments
to BOOST_SPIRIT_DEFINE contain assignments instead of just
rule names.  For example, see:

https://github.com/boostorg/spirit/blob/x3-devel/example/x3/calc4.cpp#L218

HTH.

-regards,
Larry






------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

Vincent Virgilio


On Aug 12, 2016, at 08:27 AM, Larry Evans <[hidden email]> wrote:

On 08/12/2016 06:40 AM, Larry Evans wrote:
[snip]

GitHub: [hidden email]:boostorg/spirit.git

Use the develop branch.
--}--cut here--

The 2 template arg rule code is actually in the x3-devel branch instead
of the develop branch:

https://github.com/boostorg/spirit/blob/x3-devel/include/boost/spirit/home/x3/nonterminal/rule.hpp#L80

[snip]
However, if you decide to use x3-devel, then the employee.cpp code
referenced in your OP needs to be modified so that the arguments
to BOOST_SPIRIT_DEFINE contain assignments instead of just
rule names. For example, see:

https://github.com/boostorg/spirit/blob/x3-devel/example/x3/calc4.cpp#L218

HTH.

-regards,
Larry

Hi Larry,

Thanks for all the help so far.

Why is BOOST_SPIRIT_DEFINE required if the rule declarations and definitions are already associated via assignment? In another small project, I was able to parse with an X3 grammar without that macro. In that case, very schematically, I had "auto const rule_name = rule<...>() = rule_def;"

I'm limiting myself mostly to the version of X3 included in the latest Boost release (1.61 as of now). I won't be using x3-devel, except for some experiments.

Again, thank you.

Vince

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

cppljevans
On 08/12/2016 07:53 AM, Vincent Virgilio wrote:

>
>
> On Aug 12, 2016, at 08:27 AM, Larry Evans <[hidden email]> wrote:
>
>> On 08/12/2016 06:40 AM, Larry Evans wrote:
>> [snip]
>>>
>>>> GitHub: [hidden email] <mailto:[hidden email]>:boostorg/spirit.git
>>>>
>>>> Use the develop branch.
>>>> --}--cut here--
>>>>
>>> The 2 template arg rule code is actually in the x3-devel branch instead
>>> of the develop branch:
>>>
>>> https://github.com/boostorg/spirit/blob/x3-devel/include/boost/spirit/home/x3/nonterminal/rule.hpp#L80
>>>
>> [snip]
>> However, if you decide to use x3-devel, then the employee.cpp code
>> referenced in your OP needs to be modified so that the arguments
>> to BOOST_SPIRIT_DEFINE contain assignments instead of just
>> rule names. For example, see:
>>
>> https://github.com/boostorg/spirit/blob/x3-devel/example/x3/calc4.cpp#L218
>>
>> HTH.
>>
>> -regards,
>> Larry
>
> Hi Larry,
>
> Thanks for all the help so far.
>
> Why is BOOST_SPIRIT_DEFINE required if the rule declarations and
> definitions are already associated via assignment? In another small
> project, I was able to parse with an X3 grammar without that macro. In
> that case, very schematically, I had "auto const rule_name = rule<...>()
> = rule_def;"
>
[snip]
Hi Vincent,

I can only guess that the grammar in this small project had no
recursive rules like the calc4.cpp grammar I mentioned above.

That's only a guess; however, I *think* the whole purpose of
BOOST_SPIRIT_DEFINE is to allow mutually recursive rules, such as
that in calc4.cpp, *and* to avoid massive template names.
At least that's the conclusion I reach after reading
[hidden email] reply to me here:

https://sourceforge.net/p/spirit/mailman/message/35271675/

HTH.

-regards,
Larry




------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

Vincent Virgilio


> On Aug 12, 2016, at 9:29 AM, Larry Evans <[hidden email]> wrote:
>
>> On 08/12/2016 07:53 AM, Vincent Virgilio wrote:
>>
>>
>>> On Aug 12, 2016, at 08:27 AM, Larry Evans <[hidden email]> wrote:
>>>
>>>> On 08/12/2016 06:40 AM, Larry Evans wrote:
>>>> [snip]
>>>>
>>>>> GitHub: [hidden email] <mailto:[hidden email]>:boostorg/spirit.git
>>>>>
>>>>> Use the develop branch.
>>>>> --}--cut here--
>>>> The 2 template arg rule code is actually in the x3-devel branch instead
>>>> of the develop branch:
>>>>
>>>> https://github.com/boostorg/spirit/blob/x3-devel/include/boost/spirit/home/x3/nonterminal/rule.hpp#L80
>>> [snip]
>>> However, if you decide to use x3-devel, then the employee.cpp code
>>> referenced in your OP needs to be modified so that the arguments
>>> to BOOST_SPIRIT_DEFINE contain assignments instead of just
>>> rule names. For example, see:
>>>
>>> https://github.com/boostorg/spirit/blob/x3-devel/example/x3/calc4.cpp#L218
>>>
>>> HTH.
>>>
>>> -regards,
>>> Larry
>>
>> Hi Larry,
>>
>> Thanks for all the help so far.
>>
>> Why is BOOST_SPIRIT_DEFINE required if the rule declarations and
>> definitions are already associated via assignment? In another small
>> project, I was able to parse with an X3 grammar without that macro. In
>> that case, very schematically, I had "auto const rule_name = rule<...>()
>> = rule_def;"
> [snip]
> Hi Vincent,
>
> I can only guess that the grammar in this small project had no
> recursive rules like the calc4.cpp grammar I mentioned above.
>
> That's only a guess; however, I *think* the whole purpose of
> BOOST_SPIRIT_DEFINE is to allow mutually recursive rules, such as
> that in calc4.cpp, *and* to avoid massive template names.
> At least that's the conclusion I reach after reading
> [hidden email] reply to me here:
>
> https://sourceforge.net/p/spirit/mailman/message/35271675/
>
> HTH.
>
> -regards,
> Larry

Yes, the grammar was tiny.

I think I see what you're saying.
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

Mike Gresens
In reply to this post by Vincent Virgilio
Try to add

#include <boost/fusion/adapted/std_pair.hpp>

Best regards,
Mike...
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

Vincent Virgilio


> On Aug 12, 2016, at 1:04 PM, Mike Gresens <[hidden email]> wrote:
>
> Try to add
>
> #include <boost/fusion/adapted/std_pair.hpp>
>
> Best regards,
> Mike...
>

That did it.

I thought Spirit would handle such an include behind-the-scenes. For example, I didn't have to include anything Fusion for std::map.

Thanks Mike.
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

Vincent Virgilio


On Aug 12, 2016, at 01:14 PM, Vincent Virgilio <[hidden email]> wrote:



On Aug 12, 2016, at 1:04 PM, Mike Gresens <[hidden email]> wrote:

Try to add

#include <boost/fusion/adapted/std_pair.hpp>

Best regards,
Mike...


That did it.

I thought Spirit would handle such an include behind-the-scenes. For example, I didn't have to include anything Fusion for std::map.

Thanks Mike.

Should've linked to the code . . .

Here's the fix at coliru:


which also compiles and runs in VS2015 Update 3. 

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

cppljevans
In reply to this post by Vincent Virgilio
On 08/12/2016 09:19 AM, Vincent Virgilio wrote:

>
>
>> On Aug 12, 2016, at 9:29 AM, Larry Evans <[hidden email]> wrote:
>>
>>> On 08/12/2016 07:53 AM, Vincent Virgilio wrote:
>>>
>>>
>>>> On Aug 12, 2016, at 08:27 AM, Larry Evans <[hidden email]> wrote:
>>>>
>>>>> On 08/12/2016 06:40 AM, Larry Evans wrote:
>>>>> [snip]
>>>>>
>>>>>> GitHub: [hidden email] <mailto:[hidden email]>:boostorg/spirit.git
>>>>>>
>>>>>> Use the develop branch.
>>>>>> --}--cut here--
>>>>> The 2 template arg rule code is actually in the x3-devel branch instead
>>>>> of the develop branch:
>>>>>
>>>>> https://github.com/boostorg/spirit/blob/x3-devel/include/boost/spirit/home/x3/nonterminal/rule.hpp#L80
>>>> [snip]
>>>> However, if you decide to use x3-devel, then the employee.cpp code
>>>> referenced in your OP needs to be modified so that the arguments
>>>> to BOOST_SPIRIT_DEFINE contain assignments instead of just
>>>> rule names. For example, see:
>>>>
>>>> https://github.com/boostorg/spirit/blob/x3-devel/example/x3/calc4.cpp#L218
>>>>
>>>> HTH.
>>>>
>>>> -regards,
>>>> Larry
>>>
>>> Hi Larry,
>>>
>>> Thanks for all the help so far.
>>>
>>> Why is BOOST_SPIRIT_DEFINE required if the rule declarations and
>>> definitions are already associated via assignment? In another small
>>> project, I was able to parse with an X3 grammar without that macro. In
>>> that case, very schematically, I had "auto const rule_name = rule<...>()
>>> = rule_def;"
>> [snip]
>> Hi Vincent,
>>
>> I can only guess that the grammar in this small project had no
>> recursive rules like the calc4.cpp grammar I mentioned above.
>>
>> That's only a guess; however, I *think* the whole purpose of
>> BOOST_SPIRIT_DEFINE is to allow mutually recursive rules, such as
>> that in calc4.cpp, *and* to avoid massive template names.
>> At least that's the conclusion I reach after reading
>> [hidden email] reply to me here:
>>
>> https://sourceforge.net/p/spirit/mailman/message/35271675/
>>
>> HTH.
>>
>> -regards,
>> Larry
>
> Yes, the grammar was tiny.
>
> I think I see what you're saying.

Great!

The following gist:

https://gist.github.com/cppljevans/3d3bec54be8f3d0c4d8b94af84a6e529

hopefully will make things more clear.
It shows a grammar without recursion and one with.
There's also a macro, USE_DEFINE, which, if !defined(USE_DEFINE),
causes a compile error something like:

define.o
toy_why_define.cpp:132:9: error: static_assert failed
"BOOST_SPIRIT_DEFINE undefined for this rule."
 
static_assert(!boost::is_same<get_type,undefined>::value,"BOOST_SPIRIT_DEFINE
undefined for this rule.");
         ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

OTOH, when defined(USE_DEFINE), it runs without error.
The comments above the #define USE_SPIRIT_DEFINE try to explain
how it works.

HTH.

-regards,
Larry




------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

cppljevans
In reply to this post by cppljevans
On 08/12/2016 08:29 AM, Larry Evans wrote:

> On 08/12/2016 07:53 AM, Vincent Virgilio wrote:
>>
>>
>> On Aug 12, 2016, at 08:27 AM, Larry Evans <[hidden email]> wrote:
>>
>>> On 08/12/2016 06:40 AM, Larry Evans wrote:
>>> [snip]
>>>>
>>>>> GitHub: [hidden email] <mailto:[hidden email]>:boostorg/spirit.git
>>>>>
>>>>> Use the develop branch.
>>>>> --}--cut here--
>>>>>
>>>> The 2 template arg rule code is actually in the x3-devel branch instead
>>>> of the develop branch:
>>>>
>>>> https://github.com/boostorg/spirit/blob/x3-devel/include/boost/spirit/home/x3/nonterminal/rule.hpp#L80
>>>>
>>> [snip]
>>> However, if you decide to use x3-devel, then the employee.cpp code
>>> referenced in your OP needs to be modified so that the arguments
>>> to BOOST_SPIRIT_DEFINE contain assignments instead of just
>>> rule names. For example, see:
>>>
>>> https://github.com/boostorg/spirit/blob/x3-devel/example/x3/calc4.cpp#L218
>>>
>>> HTH.
>>>
>>> -regards,
>>> Larry
>>
>> Hi Larry,
>>
>> Thanks for all the help so far.
>>
>> Why is BOOST_SPIRIT_DEFINE required if the rule declarations and
>> definitions are already associated via assignment? In another small
>> project, I was able to parse with an X3 grammar without that macro. In
>> that case, very schematically, I had "auto const rule_name = rule<...>()
>> = rule_def;"
>>
> [snip]
> Hi Vincent,
>
> I can only guess that the grammar in this small project had no
> recursive rules like the calc4.cpp grammar I mentioned above.
>
> That's only a guess; however, I *think* the whole purpose of
> BOOST_SPIRIT_DEFINE is to allow mutually recursive rules,

Apparently that conclusion is wrong because here:

https://github.com/boostorg/spirit/blob/master/test/x3/rule1.cpp#L48

there's a single recursive rule and there's no BOOST_SPIRIT_DEFINE.

Sorry for misleading you.  I'm still trying to learn how the code
works :(


> such as
> that in calc4.cpp, *and* to avoid massive template names.
> At least that's the conclusion I reach after reading
> [hidden email] reply to me here:
>
> https://sourceforge.net/p/spirit/mailman/message/35271675/
>
> HTH.
>
> -regards,
> Larry
>
>
>
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. http://sdm.link/zohodev2dev
>



------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

cppljevans
On 08/20/2016 05:20 AM, Larry Evans wrote:

> On 08/12/2016 08:29 AM, Larry Evans wrote:
>> On 08/12/2016 07:53 AM, Vincent Virgilio wrote:
>>>
>>>
>>> On Aug 12, 2016, at 08:27 AM, Larry Evans <[hidden email]> wrote:
>>>
>>>> On 08/12/2016 06:40 AM, Larry Evans wrote:
>>>> [snip]
>>>>>
>>>>>> GitHub: [hidden email] <mailto:[hidden email]>:boostorg/spirit.git
>>>>>>
>>>>>> Use the develop branch.
>>>>>> --}--cut here--
>>>>>>
>>>>> The 2 template arg rule code is actually in the x3-devel branch instead
>>>>> of the develop branch:
>>>>>
>>>>> https://github.com/boostorg/spirit/blob/x3-devel/include/boost/spirit/home/x3/nonterminal/rule.hpp#L80
>>>>>
>>>> [snip]
>>>> However, if you decide to use x3-devel, then the employee.cpp code
>>>> referenced in your OP needs to be modified so that the arguments
>>>> to BOOST_SPIRIT_DEFINE contain assignments instead of just
>>>> rule names. For example, see:
>>>>
>>>> https://github.com/boostorg/spirit/blob/x3-devel/example/x3/calc4.cpp#L218
>>>>
>>>> HTH.
>>>>
>>>> -regards,
>>>> Larry
>>>
>>> Hi Larry,
>>>
>>> Thanks for all the help so far.
>>>
>>> Why is BOOST_SPIRIT_DEFINE required if the rule declarations and
>>> definitions are already associated via assignment? In another small
>>> project, I was able to parse with an X3 grammar without that macro. In
>>> that case, very schematically, I had "auto const rule_name = rule<...>()
>>> = rule_def;"
>>>
>> [snip]
>> Hi Vincent,
>>
>> I can only guess that the grammar in this small project had no
>> recursive rules like the calc4.cpp grammar I mentioned above.
>>
>> That's only a guess; however, I *think* the whole purpose of
>> BOOST_SPIRIT_DEFINE is to allow mutually recursive rules,
>
> Apparently that conclusion is wrong because here:
>
> https://github.com/boostorg/spirit/blob/master/test/x3/rule1.cpp#L48
>
> there's a single recursive rule and there's no BOOST_SPIRIT_DEFINE.
>
> Sorry for misleading you.  I'm still trying to learn how the code
> works :(
>

OOPS.  I should have re-looked at:

https://github.com/boostorg/spirit/blob/develop/workbench/x3/toy/toy.cpp#L134

which shows the rule_definition<>::parse function stores the
rule definition in the context dictionary.  Then, even
when BOOST_SPIRIT_DEFINE is not used, the rule rhs is looked up
by the rule<...>::parse function:

https://github.com/boostorg/spirit/blob/develop/workbench/x3/toy/toy.cpp#L154

The process is a little more complicated in the actual code.
There, rule_defintion<...>::parse:

https://github.com/boostorg/spirit/blob/master/include/boost/spirit/home/x3/nonterminal/rule.hpp#L64

*maybe* does something similar by putting the definition in the
context dictionary where the key is the rule ID.  Then, in subsequent
calls to rule<...>::parse:

https://github.com/boostorg/spirit/blob/master/include/boost/spirit/home/x3/nonterminal/rule.hpp#L113

the rule_parse<...> function looks up the definition in the context,
if it can:

https://github.com/boostorg/spirit/blob/master/include/boost/spirit/home/x3/nonterminal/rule.hpp#L37

Of course, I maybe missing something.  It's happened before :(

-regards,
Larry






------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

cppljevans
On 08/20/2016 08:30 AM, Larry Evans wrote:
[snip]

> OOPS.  I should have re-looked at:
>
> https://github.com/boostorg/spirit/blob/develop/workbench/x3/toy/toy.cpp#L134
>
> which shows the rule_definition<>::parse function stores the
> rule definition in the context dictionary.  Then, even
> when BOOST_SPIRIT_DEFINE is not used, the rule rhs is looked up
> by the rule<...>::parse function:
>
> https://github.com/boostorg/spirit/blob/develop/workbench/x3/toy/toy.cpp#L154
>
> The process is a little more complicated in the actual code.
> There, rule_defintion<...>::parse:
>
> https://github.com/boostorg/spirit/blob/master/include/boost/spirit/home/x3/nonterminal/rule.hpp#L64
>
> *maybe* does something similar by putting the definition in the
> context dictionary where the key is the rule ID.
Yep, it's done here:

https://github.com/boostorg/spirit/blob/master/include/boost/spirit/home/x3/nonterminal/detail/rule.hpp#L209

in the expression:

   make_rule_context<ID>(rhs, context, is_default_parse_rule())

which, in case BOOST_SPIRIT_DEFINE is not used to define the rule,
and the rule definition is not already in the context, calls:

https://github.com/boostorg/spirit/blob/master/include/boost/spirit/home/x3/support/context.hpp#L89

However, this only happens if rule_definition's on on the RHS of rules,
as done here:

http://coliru.stacked-crooked.com/a/41425cb30e49bc8a

in lines 29-39 where process, node, and node_map are all rule_definition's.

However, this use of rule_definitions on the RHS or rules suffers the
same "crazy long mangled names" problem mentioned by Tongari here:

http://boost.2283326.n4.nabble.com/compare-of-2-existing-methods-to-implement-grammar-recursion-tt4687574.html#a4687690

So why wouldn't the simpler rule_map solution be preferred?  With
rule_map, there's no need to put rule_definitions on RHS, there's
only the need to create the rule_map once and pass that as part
of the context.

-regards,
Larry



------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Spirit X3 employee.cpp compile error

cppljevans
On 08/31/2016 12:31 AM, Larry Evans wrote:

> On 08/20/2016 08:30 AM, Larry Evans wrote:
> [snip]
>
>> OOPS.  I should have re-looked at:
>>
>> https://github.com/boostorg/spirit/blob/develop/workbench/x3/toy/toy.cpp#L134
>>
>> which shows the rule_definition<>::parse function stores the
>> rule definition in the context dictionary.  Then, even
>> when BOOST_SPIRIT_DEFINE is not used, the rule rhs is looked up
>> by the rule<...>::parse function:
>>
>> https://github.com/boostorg/spirit/blob/develop/workbench/x3/toy/toy.cpp#L154
>>
>> The process is a little more complicated in the actual code.
>> There, rule_defintion<...>::parse:
>>
>> https://github.com/boostorg/spirit/blob/master/include/boost/spirit/home/x3/nonterminal/rule.hpp#L64
>>
>> *maybe* does something similar by putting the definition in the
>> context dictionary where the key is the rule ID.
> Yep, it's done here:
>
> https://github.com/boostorg/spirit/blob/master/include/boost/spirit/home/x3/nonterminal/detail/rule.hpp#L209
>
> in the expression:
>
>    make_rule_context<ID>(rhs, context, is_default_parse_rule())
>
> which, in case BOOST_SPIRIT_DEFINE is not used to define the rule,
> and the rule definition is not already in the context, calls:
>
> https://github.com/boostorg/spirit/blob/master/include/boost/spirit/home/x3/support/context.hpp#L89
>
> However, this only happens if rule_definition's on on the RHS of rules,
> as done here:
>
> http://coliru.stacked-crooked.com/a/41425cb30e49bc8a
>
> in lines 29-39 where process, node, and node_map are all rule_definition's.
>
> However, this use of rule_definitions on the RHS or rules suffers the
> same "crazy long mangled names" problem mentioned by Tongari here:
>
> http://boost.2283326.n4.nabble.com/compare-of-2-existing-methods-to-implement-grammar-recursion-tt4687574.html#a4687690


Another problem with this method is that mutually recursive rules
cannot be done for reasons mentioned in the //Result: comment of:

https://github.com/cppljevans/spirit/blob/trace-design/x3-design/employee_calc1_context_DEFINE.cpp

[snip]


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