foonathan / lexy

C++ parsing DSL
https://lexy.foonathan.net
Boost Software License 1.0
991 stars 66 forks source link

Wrong callback for `dsl::curly_bracketed.opt` #141

Closed rkaminsk closed 1 year ago

rkaminsk commented 1 year ago

The following production fails to compile:

struct bracketed {
    static constexpr auto rule = []() {
        return dsl::curly_bracketed.opt(dsl::identifier(dsl::ascii::lower));
    }();
    static constexpr auto value = lexy::callback<std::string>(
        //[]() {  
        //    return "empty";                         
        //},
        [](lexy::nullopt) {
            return "null";
        },
        [](lexeme name) {
            return lexy::as_string<std::string>(name);
        }
    );
};

The error is

error: static assertion failed due to requirement '_detail::error<bracketed>': missing value callback overload for production

The error disappears adding the uncommented overload.

foonathan commented 1 year ago

That isn't a bug. The empty callback is invoked during error recovery of an input like {NOTLOWERCASE}. I'll add a note to the docs.

rkaminsk commented 1 year ago

I see. Thanks.