taocpp / PEGTL

Parsing Expression Grammar Template Library
Boost Software License 1.0
1.94k stars 228 forks source link

Incorrect memory_input parameters in string_input.hpp #82

Closed chybz closed 6 years ago

chybz commented 6 years ago

Hi ! First and foremost, it's a real pleasure to use PEGTL, thank you !

When using string_input like:

std::string s{ "something to parse" }; tao::pegtl::string_input<> in(s);

a compiler error occurs.

Obviously in string_input.hpp:42 the second parameter to memory_input is not what is expected.

Changing it to data.data() + data.size() fixes the problem.

Hope this helps.

Best.

d-frey commented 6 years ago

The error message is a bit rubbish, but the problem is that you forgot to provide a source for your data. Try:

tao::pegtl::string_input<> in( s, "std::string" );

(I might look into ways to improve the error message, but it would probably end up with a lot of code duplication that I'd like to avoid)