[Spirit] Equivalent of limit_d in spirit 2.x

Hi, Spirit 1.8 has a directive called limit_d which allowed to set the value range. Is there an equivalent for this in Spirit 2.x? Thanks and regards, Roland

Spirit 1.8 has a directive called limit_d which allowed to set the value range. Is there an equivalent for this in Spirit 2.x?
There is not anything like this, but you can achieve the same with a semantic action: limit_d(min, max)[uint_p] is equivalent to (when using qi::uint_, qi::_pass, and qi::_1): uint_[_pass = (min <= _1 && _1 <= max)] Regards Hartmut --------------- Meet me at BoostCon www.boostcon.com

Hartmut Kaiser wrote:
Spirit 1.8 has a directive called limit_d which allowed to set the value range. Is there an equivalent for this in Spirit 2.x?
There is not anything like this, but you can achieve the same with a semantic action:
limit_d(min, max)[uint_p]
is equivalent to (when using qi::uint_, qi::_pass, and qi::_1):
uint_[_pass = (min <= _1 && _1 <= max)]
Regards Hartmut
Thanks for the quick reply! Just out of curiosity: Where can I find this in the documentation? I missed the _pass somehow. Regards, Roland

Spirit 1.8 has a directive called limit_d which allowed to set the value range. Is there an equivalent for this in Spirit 2.x?
There is not anything like this, but you can achieve the same with a semantic action:
limit_d(min, max)[uint_p]
is equivalent to (when using qi::uint_, qi::_pass, and qi::_1):
uint_[_pass = (min <= _1 && _1 <= max)]
Regards Hartmut
Thanks for the quick reply!
Just out of curiosity: Where can I find this in the documentation? I missed the _pass somehow.
http://www.boost.org/doc/libs/1_43_0/libs/spirit/doc/html/spirit/qi/quick_re ference/phoenix.html Regards Hartmut --------------- Meet me at BoostCon www.boostcon.com

Hartmut Kaiser wrote:
Spirit 1.8 has a directive called limit_d which allowed to set the value range. Is there an equivalent for this in Spirit 2.x?
There is not anything like this, but you can achieve the same with a semantic action:
limit_d(min, max)[uint_p]
is equivalent to (when using qi::uint_, qi::_pass, and qi::_1):
uint_[_pass = (min <= _1 && _1 <= max)]
Regards Hartmut
Thanks for the quick reply!
Just out of curiosity: Where can I find this in the documentation? I missed the _pass somehow.
http://www.boost.org/doc/libs/1_43_0/libs/spirit/doc/html/spirit/qi/quick_re ference/phoenix.html
Regards Hartmut
Thanks again! I'd like to make two suggestions for the documentation: a) It would be cool to have something like this in the tutorial: uint_[_pass = (min <= _1 && _1 <= max)][ref(year) = _1] It shows an example usage of _pass and spirit's ability to handle multiple semantic actions. b) The links from the spirit documentation into the phoenix documentation could be more targeted (currently they link to the index page). In the given example, I have some trouble in finding more information about _pass in the phoenix documentation. Regards, Roland

On 7/19/10 12:21 PM, Roland Bock wrote:
I'd like to make two suggestions for the documentation:
a) It would be cool to have something like this in the tutorial:
uint_[_pass = (min<= _1&& _1<= max)][ref(year) = _1]
It shows an example usage of _pass and spirit's ability to handle multiple semantic actions.
b) The links from the spirit documentation into the phoenix documentation could be more targeted (currently they link to the index page). In the given example, I have some trouble in finding more information about _pass in the phoenix documentation.
Well, contributions welcome, ahem ahem :-P Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net

Joel de Guzman wrote:
On 7/19/10 12:21 PM, Roland Bock wrote:
I'd like to make two suggestions for the documentation:
a) It would be cool to have something like this in the tutorial:
uint_[_pass = (min<= _1&& _1<= max)][ref(year) = _1]
It shows an example usage of _pass and spirit's ability to handle multiple semantic actions.
b) The links from the spirit documentation into the phoenix documentation could be more targeted (currently they link to the index page). In the given example, I have some trouble in finding more information about _pass in the phoenix documentation.
Well, contributions welcome, ahem ahem :-P
OK, I'll try to come up with a section for the tutorial in the next few days :-) Where should I send it? As for the links into phoenix, well, I did not find the _pass anywhere in the phoenix documentation. Otherwise I would have been more precise... Regards, Roland

On Mon, Jul 19, 2010 at 10:33 AM, Roland Bock
Joel de Guzman wrote:
On 7/19/10 12:21 PM, Roland Bock wrote:
I'd like to make two suggestions for the documentation:
a) It would be cool to have something like this in the tutorial:
uint_[_pass = (min<= _1&& _1<= max)][ref(year) = _1]
It shows an example usage of _pass and spirit's ability to handle multiple semantic actions.
b) The links from the spirit documentation into the phoenix documentation could be more targeted (currently they link to the index page). In the given example, I have some trouble in finding more information about _pass in the phoenix documentation.
Well, contributions welcome, ahem ahem :-P
OK, I'll try to come up with a section for the tutorial in the next few days :-) Where should I send it?
As for the links into phoenix, well, I did not find the _pass anywhere in the phoenix documentation. Otherwise I would have been more precise...
_pass does not really belong into the phoenix docs, as it is spirit specific :) Anyway, it is just a placeholder for semantic actions where you can specify wether the rule was parsed correctly or not.

Joel de Guzman wrote:
On 7/19/10 12:21 PM, Roland Bock wrote:
I'd like to make two suggestions for the documentation:
a) It would be cool to have something like this in the tutorial:
uint_[_pass = (min<= _1&& _1<= max)][ref(year) = _1]
It shows an example usage of _pass and spirit's ability to handle multiple semantic actions.
b) The links from the spirit documentation into the phoenix documentation could be more targeted (currently they link to the index page). In the given example, I have some trouble in finding more information about _pass in the phoenix documentation.
Well, contributions welcome, ahem ahem :-P
OK, I'll try to come up with a section for the tutorial in the next few days :-) Where should I send it?
The best would be a patch wrt the existing *qbk files. Feel free to send it either to the Spirit ML or directly to me or Joel (best both).
As for the links into phoenix, well, I did not find the _pass anywhere in the phoenix documentation. Otherwise I would have been more precise...
_pass is nothing Phoenix related, except it being a placeholder built on top of Phoenix facilities (as almost all of the other Spirit placeholders, btw). Regards Hartmut --------------- Meet me at BoostCon www.boostcon.com

Hartmut Kaiser wrote:
Joel de Guzman wrote:
On 7/19/10 12:21 PM, Roland Bock wrote:
I'd like to make two suggestions for the documentation:
a) It would be cool to have something like this in the tutorial:
uint_[_pass = (min<= _1&& _1<= max)][ref(year) = _1]
It shows an example usage of _pass and spirit's ability to handle multiple semantic actions.
b) The links from the spirit documentation into the phoenix documentation could be more targeted (currently they link to the index page). In the given example, I have some trouble in finding more information about _pass in the phoenix documentation. Well, contributions welcome, ahem ahem :-P OK, I'll try to come up with a section for the tutorial in the next few days :-) Where should I send it?
The best would be a patch wrt the existing *qbk files. Feel free to send it either to the Spirit ML or directly to me or Joel (best both).
OK, I'll try to come up with something that would have sped up things for our team here.
As for the links into phoenix, well, I did not find the _pass anywhere in the phoenix documentation. Otherwise I would have been more precise...
_pass is nothing Phoenix related, except it being a placeholder built on top of Phoenix facilities (as almost all of the other Spirit placeholders, btw).
Got it. I admit that a sentence like this would have spared me some time :-) Regards, Roland

Roland Bock wrote:
As for the links into phoenix, well, I did not find the _pass anywhere in the phoenix documentation. Otherwise I would have been more precise...
Hi Roland - The Phoenix compatible placeholders used in Qi are defined here: http://www.boost.org/doc/libs/1_43_0/libs/spirit/doc/html/spirit/qi/quick_re... hth michael -- ---------------------------------- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com
participants (5)
-
Hartmut Kaiser
-
Joel de Guzman
-
Michael Caisse
-
Roland Bock
-
Thomas Heller