Re: Trying to sort out AST vs grammar mapped attributes
Michael Powell <[email protected]>
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <CAMEoF_GOAjtTC+br9U+de43-iqPKdCsJeng_fCNEPX-1R2FJdw@mail.gmail.com> |
On Wed, Dec 20, 2017 at 5:26 PM, Michael Powell <[email protected]> wrote: > On Wed, Dec 20, 2017 at 4:58 PM, Michael Powell <[email protected]> wrote: >> On Wed, Dec 20, 2017 at 4:32 PM, Michael Powell <[email protected]> wrote: >>> Hello, >>> >>> I've got a parser/AST composed something like this: >>> >>> https://wandbox.org/permlink/P4227jXxu9DvQThF >> >> I sorted it out. It seems to be a matter of having the appropriate >> intermediate structs/attributed-rules to capture the octets, >> addresses, etc. >> >> https://wandbox.org/permlink/HEz4qn3XQLmpWUAx >> >> Now just a matter of rinsing and repeating for additional IPv4 mapped >> alternatives. > > The parser is failing. The IPv4 mapped address bytes appear to be > parsed correctly, but the IPv6 base address does not. > > https://wandbox.org/permlink/Mpi0dhIqe1kW6N34 > > Thoughts? Ah, I'm starting to see. Love attributes! https://wandbox.org/permlink/Qq6rBvGM6Kh769ld >> Cheers! >> >>> I am having difficulty mapping the attributes correctly. I'm not quite >>> sure why, perhaps that structure inheritance is not quite right? I >>> don't know exactly. >>> >>> Note this is handling the IPv4-mapped IPv6 addresses, the first phrase only: >>> >>> IPv6address = 6(h16 ":") ls32 // Don't care about the other >>> alternatives at the moment. >>> ls32 = IPv4address // Don't care about the natural IPv6 alternative >>> IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet >>> dec-octet = int(0, 255) >>> >>> http://www.ietf.org/rfc/rfc5954.txt >>> >>> Getting similar errors across platforms, i.e. Microsoft Visual Studio 2015. >>> >>> The most obvious answer is that I "flatten" the AST mapping, but I'd >>> really like to leverage what I've already got in my IPv4 grammars >>> mapping into IPv6. >>> >>> Thoughts? >>> >>> Best, >>> >>> Michael Powell >>> >>> The errors: >>> >>> In file included from >>> /opt/wandbox/boost-1.65.1/gcc-head/include/boost/spirit/home/qi/auxiliary/attr.hpp:18, >>> from >>> /opt/wandbox/boost-1.65.1/gcc-head/include/boost/spirit/home/qi/auxiliary.hpp:19, >>> from >>> /opt/wandbox/boost-1.65.1/gcc-head/include/boost/spirit/home/qi.hpp:16, >>> from prog.cc:3: >>> /opt/wandbox/boost-1.65.1/gcc-head/include/boost/spirit/home/qi/detail/assign_to.hpp: >>> In instantiation of 'static void >>> boost::spirit::traits::assign_to_attribute_from_value<Attribute, T, >>> Enable>::call(const T_&, Attribute&, mpl_::false_) [with T_ = >>> std::__cxx11::basic_string<char>; Attribute = >>> client::ast::ipv4_mapped_address; T = >>> std::__cxx11::basic_string<char>; Enable = void; mpl_::false_ = >>> mpl_::bool_<false>]': >>> /opt/wandbox/boost-1.65.1/gcc-head/include/boost/spirit/home/qi/detail/assign_to.hpp:171:17: >>> required from 'static void >>> boost::spirit::traits::assign_to_attribute_from_value<Attribute, T, >>> Enable>::call(const T&, Attribute&) [with Attribute = >>> client::ast::ipv4_mapped_address; T = >>> std::__cxx11::basic_string<char>; Enable = void]' >>> /opt/wandbox/boost-1.65.1/gcc-head/include/boost/spirit/home/qi/detail/assign_to.hpp:370:63: >>> required from 'void boost::spirit::traits::detail::assign_to(const >>> T&, Attribute&, mpl_::false_) [with T = >>> std::__cxx11::basic_string<char>; Attribute = >>> client::ast::ipv4_mapped_address; mpl_::false_ = mpl_::bool_<false>]' >>> /opt/wandbox/boost-1.65.1/gcc-head/include/boost/spirit/home/qi/detail/assign_to.hpp:393:26: >>> required from 'void boost::spirit::traits::assign_to(const T&, >>> Attribute&) [with T = std::__cxx11::basic_string<char>; Attribute = >>> client::ast::ipv4_mapped_address]' >>> /opt/wandbox/boost-1.65.1/gcc-head/include/boost/spirit/home/qi/detail/attributes.hpp:27:30: >>> required from 'static void >>> boost::spirit::qi::default_transform_attribute<Exposed, >>> Transformed>::post(Exposed&, const Transformed&) [with Exposed = >>> client::ast::ipv4_mapped_address; Transformed = >>> std::__cxx11::basic_string<char>]' >>> /opt/wandbox/boost-1.65.1/gcc-head/include/boost/spirit/home/qi/detail/attributes.hpp:165:75: >>> required from 'void boost::spirit::traits::post_transform(Exposed&, >>> const Transformed&) [with Exposed = client::ast::ipv4_mapped_address; >>> Transformed = std::__cxx11::basic_string<char>]' >>> /opt/wandbox/boost-1.65.1/gcc-head/include/boost/spirit/home/qi/nonterminal/rule.hpp:308:43: >>> [ skipping 12 instantiation contexts, use >>> -ftemplate-backtrace-limit=0 to disable ] >>> /opt/wandbox/boost-1.65.1/gcc-head/include/boost/function/function_template.hpp:1061:16: >>> required from 'boost::function<R(T0, T1, T2, T3)>::function(Functor, >>> typename boost::enable_if_c<(! boost::is_integral<Functor>::value), >>> int>::type) [with Functor = >>> boost::spirit::qi::detail::parser_binder<boost::spirit::qi::sequence<boost::fusion::cons<boost::spirit::qi::reference<const >>> boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, >>> std::__cxx11::basic_string<char> >, >>> std::__cxx11::basic_string<char>(), boost::spirit::unused_type, >>> boost::spirit::unused_type, boost::spirit::unused_type> >, >>> boost::fusion::cons<boost::spirit::qi::reference<const >>> boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, >>> std::__cxx11::basic_string<char> >, boost::spirit::unused_type, >>> boost::spirit::unused_type, boost::spirit::unused_type, >>> boost::spirit::unused_type> >, >>> boost::fusion::cons<boost::spirit::qi::eoi_parser, >>> boost::fusion::nil_> > > >, mpl_::bool_<false> >; R = bool; T0 = >>> __gnu_cxx::__normal_iterator<const char*, >>> std::__cxx11::basic_string<char> >&; T1 = const >>> __gnu_cxx::__normal_iterator<const char*, >>> std::__cxx11::basic_string<char> >&; T2 = >>> boost::spirit::context<boost::fusion::cons<client::ast::ipv4_mapped_address&, >>> boost::fusion::nil_>, boost::fusion::vector<> >&; T3 = const >>> boost::spirit::unused_type&; typename boost::enable_if_c<(! >>> boost::is_integral<Functor>::value), int>::type = int]' >>> /opt/wandbox/boost-1.65.1/gcc-head/include/boost/function/function_template.hpp:1114:5: >>> required from 'typename boost::enable_if_c<(! >>> boost::is_integral<Functor>::value), boost::function<R(T0, T1, T2, >>> T3)>&>::type boost::function<R(T0, T1, T2, T3)>::operator=(Functor) >>> [with Functor = >>> boost::spirit::qi::detail::parser_binder<boost::spirit::qi::sequence<boost::fusion::cons<boost::spirit::qi::reference<const >>> boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, >>> std::__cxx11::basic_string<char> >, >>> std::__cxx11::basic_string<char>(), boost::spirit::unused_type, >>> boost::spirit::unused_type, boost::spirit::unused_type> >, >>> boost::fusion::cons<boost::spirit::qi::reference<const >>> boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, >>> std::__cxx11::basic_string<char> >, boost::spirit::unused_type, >>> boost::spirit::unused_type, boost::spirit::unused_type, >>> boost::spirit::unused_type> >, >>> boost::fusion::cons<boost::spirit::qi::eoi_parser, >>> boost::fusion::nil_> > > >, mpl_::bool_<false> >; R = bool; T0 = >>> __gnu_cxx::__normal_iterator<const char*, >>> std::__cxx11::basic_string<char> >&; T1 = const >>> __gnu_cxx::__normal_iterator<const char*, >>> std::__cxx11::basic_string<char> >&; T2 = >>> boost::spirit::context<boost::fusion::cons<client::ast::ipv4_mapped_address&, >>> boost::fusion::nil_>, boost::fusion::vector<> >&; T3 = const >>> boost::spirit::unused_type&; typename boost::enable_if_c<(! >>> boost::is_integral<Functor>::value), boost::function<R(T0, T1, T2, >>> T3)>&>::type = boost::function<bool(__gnu_cxx::__normal_iterator<const >>> char*, std::__cxx11::basic_string<char> >&, const >>> __gnu_cxx::__normal_iterator<const char*, >>> std::__cxx11::basic_string<char> >&, >>> boost::spirit::context<boost::fusion::cons<client::ast::ipv4_mapped_address&, >>> boost::fusion::nil_>, boost::fusion::vector<> >&, const >>> boost::spirit::unused_type&)>&]' >>> /opt/wandbox/boost-1.65.1/gcc-head/include/boost/spirit/home/qi/nonterminal/rule.hpp:183:19: >>> required from 'static void boost::spirit::qi::rule<Iterator, T1, T2, >>> T3, T4>::define(boost::spirit::qi::rule<Iterator, T1, T2, T3, T4>&, >>> const Expr&, mpl_::true_) [with Auto = mpl_::bool_<false>; Expr = >>> boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_right, >>> boost::proto::argsns_::list2<const >>> boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_right, >>> boost::proto::argsns_::list2<boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const >>> char*, std::__cxx11::basic_string<char> >, >>> std::__cxx11::basic_string<char>(), boost::spirit::unused_type, >>> boost::spirit::unused_type, boost::spirit::unused_type>&, >>> boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, >>> std::__cxx11::basic_string<char> >, boost::spirit::unused_type, >>> boost::spirit::unused_type, boost::spirit::unused_type, >>> boost::spirit::unused_type>&>, 2>&, const >>> boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, >>> boost::proto::argsns_::term<boost::spirit::tag::eoi>, 0>&>, 2>; >>> Iterator = __gnu_cxx::__normal_iterator<const char*, >>> std::__cxx11::basic_string<char> >; T1 = >>> client::ast::ipv4_mapped_address(); T2 = boost::spirit::unused_type; >>> T3 = boost::spirit::unused_type; T4 = boost::spirit::unused_type; >>> mpl_::true_ = mpl_::bool_<true>]' >>> /opt/wandbox/boost-1.65.1/gcc-head/include/boost/spirit/home/qi/nonterminal/rule.hpp:221:32: >>> required from 'boost::spirit::qi::rule<Iterator, T1, T2, T3, T4>& >>> boost::spirit::qi::rule<Iterator, T1, T2, T3, T4>::operator=(const >>> Expr&) [with Expr = >>> boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_right, >>> boost::proto::argsns_::list2<const >>> boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_right, >>> boost::proto::argsns_::list2<boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const >>> char*, std::__cxx11::basic_string<char> >, >>> std::__cxx11::basic_string<char>(), boost::spirit::unused_type, >>> boost::spirit::unused_type, boost::spirit::unused_type>&, >>> boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, >>> std::__cxx11::basic_string<char> >, boost::spirit::unused_type, >>> boost::spirit::unused_type, boost::spirit::unused_type, >>> boost::spirit::unused_type>&>, 2>&, const >>> boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal, >>> boost::proto::argsns_::term<boost::spirit::tag::eoi>, 0>&>, 2>; >>> Iterator = __gnu_cxx::__normal_iterator<const char*, >>> std::__cxx11::basic_string<char> >; T1 = >>> client::ast::ipv4_mapped_address(); T2 = boost::spirit::unused_type; >>> T3 = boost::spirit::unused_type; T4 = boost::spirit::unused_type]' >>> prog.cc:79:20: required from >>> 'client::my_grammar<Iterator>::my_grammar() [with Iterator = >>> __gnu_cxx::__normal_iterator<const char*, >>> std::__cxx11::basic_string<char> >]' >>> prog.cc:123:20: required from here >>> /opt/wandbox/boost-1.65.1/gcc-head/include/boost/spirit/home/qi/detail/assign_to.hpp:153:20: >>> error: no matching function for call to >>> 'client::ast::ipv4_mapped_address::ipv4_mapped_address(const >>> std::__cxx11::basic_string<char>&)' >>> attr = static_cast<Attribute>(val); >>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> prog.cc:38:9: note: candidate: >>> 'client::ast::ipv4_mapped_address::ipv4_mapped_address(const string&, >>> uint8_t, uint8_t, uint8_t, uint8_t)' >>> ipv4_mapped_address(std::string const& addr >>> ^~~~~~~~~~~~~~~~~~~ >>> prog.cc:38:9: note: candidate expects 5 arguments, 1 provided >>> prog.cc:36:9: note: candidate: >>> 'client::ast::ipv4_mapped_address::ipv4_mapped_address()' >>> ipv4_mapped_address() : ipv4_address(), _addr() {} >>> ^~~~~~~~~~~~~~~~~~~ >>> prog.cc:36:9: note: candidate expects 0 arguments, 1 provided >>> prog.cc:32:12: note: candidate: >>> 'client::ast::ipv4_mapped_address::ipv4_mapped_address(const >>> client::ast::ipv4_mapped_address&)' >>> struct ipv4_mapped_address : ipv4_address { >>> ^~~~~~~~~~~~~~~~~~~ >>> prog.cc:32:12: note: no known conversion for argument 1 from 'const >>> std::__cxx11::basic_string<char>' to 'const >>> client::ast::ipv4_mapped_address&' >>> prog.cc:32:12: note: candidate: >>> 'client::ast::ipv4_mapped_address::ipv4_mapped_address(client::ast::ipv4_mapped_address&&)' >>> prog.cc:32:12: note: no known conversion for argument 1 from 'const >>> std::__cxx11::basic_string<char>' to >>> 'client::ast::ipv4_mapped_address&&' ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot