Re: Domain name label length

Michael Powell <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <CAMEoF_EykNTaHVnHPn7PbRaLP+WvEd2FhwbZ_tDR_4A5saUNTw@mail.gmail.com>
On Thu, Dec 28, 2017 at 12:27 AM, Joel de Guzman <[email protected]> wrote:
> On 26/12/2017 11:38 AM, Michael Powell wrote:
>>
>> Hello,
>>
>> So, a domain name label looks something like this, in general, right?
>>
>> _label = _let >> *(_let | _dig | _hyp) >> (_let | _dig);
>>
>> However, another stipulation is that its length must be <=63 according
>> to the RFC:
>>
>> https://tools.ietf.org/html/rfc1034#section-3.5
>>
>> So... Is there a way to constrain that using Qi?
>
>
> Yes, but if I were you, I'd probably avoid having too much smarts in
> the parser and have those checks post-hoc.

Yes, of course. The rule thus far is pretty straightforward, to do
with length and length only. It would be inappropriate to embed
anything that was so application specific.

template<typename Iterator>
struct MyParser : qi::grammar<Iterator, Ast::Address()> {

    struct validate_label_length {
        template<typename Context>
        void operator()(std::string& l, Context&, bool& pass) {
            pass = l.length() <= 63;
        }
    };

    // ...

    ... _label = raw[_let >> -(*(_let | _dig | _hyp) >> (_let |
_dig))][validate_label_length()];
    ... _address = _label % dot_;

    ... _start = _address >> eoi;
};

But this is yielding compiler errors. I'm not sure I need to include
something Fusion related?

#include <boost/spirit/home/qi.hpp>
#include "ast/domain_name.hpp"

The structure is nested, defined in the scope of my template Parser.

Severity Code Description Project File Line Suppression State
Error C2893 Failed to specialize function template
'action_dispatch<Subject>::fwd_storage<unknown-type,boost::spirit::traits::action_dispatch<Subject>::fwd_none>::type
boost::spirit::traits::action_dispatch<Subject>::do_call(F &&,...)'
Rfc3986_Uri_RegexSyntaxVerification
G:\Source\Boost.Installs\boost_1_65_1\boost\spirit\home\support\action_dispatch.hpp
142
Error C2672 'boost::spirit::traits::action_dispatch<Subject>::do_call':
no matching overloaded function found
Rfc3986_Uri_RegexSyntaxVerification
G:\Source\Boost.Installs\boost_1_65_1\boost\spirit\home\support\action_dispatch.hpp
142
Error C2893 Failed to specialize function template
'action_dispatch<Subject>::fwd_storage<unknown-type,boost::spirit::traits::action_dispatch<Subject>::fwd_attrib_context_pass>::type
boost::spirit::traits::action_dispatch<Subject>::do_call(F
&&,boost::spirit::traits::action_dispatch<Subject>::fwd_tag<A>,boost::spirit::traits::action_dispatch<Subject>::fwd_tag<B>,boost::spirit::traits::action_dispatch<Subject>::fwd_tag<C>,...)'
Rfc3986_Uri_RegexSyntaxVerification
G:\Source\Boost.Installs\boost_1_65_1\boost\spirit\home\support\action_dispatch.hpp
142
Error C2893 Failed to specialize function template
'action_dispatch<Subject>::fwd_storage<unknown-type,boost::spirit::traits::action_dispatch<Subject>::fwd_attrib_context>::type
boost::spirit::traits::action_dispatch<Subject>::do_call(F
&&,boost::spirit::traits::action_dispatch<Subject>::fwd_tag<A>,boost::spirit::traits::action_dispatch<Subject>::fwd_tag<B>,...)'
Rfc3986_Uri_RegexSyntaxVerification
G:\Source\Boost.Installs\boost_1_65_1\boost\spirit\home\support\action_dispatch.hpp
142
Error C2893 Failed to specialize function template
'action_dispatch<Subject>::fwd_storage<unknown-type,boost::spirit::traits::action_dispatch<Subject>::fwd_attrib>::type
boost::spirit::traits::action_dispatch<Subject>::do_call(F
&&,boost::spirit::traits::action_dispatch<Subject>::fwd_tag<A>,...)'
Rfc3986_Uri_RegexSyntaxVerification
G:\Source\Boost.Installs\boost_1_65_1\boost\spirit\home\support\action_dispatch.hpp
142

> Regards,
> --
> Joel de Guzman
> http://www.ciere.com
> http://boost-spirit.com
> http://www.cycfi.com/
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Spirit-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/spirit-general

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.