Skip to content

parse without a file #41

Answered by foonathan
haasdo95 asked this question in Q&A
Discussion options

You must be logged in to vote

The lexy::parse function accepts an arbitrary Input. The buffer returned by lexy::read_file is one, but there are multiple others: https://lexy.foonathan.net/reference/#input

You want the lexy::string_input: https://lexy.foonathan.net/reference/input/string_input/

std::string str = ...;
auto result = lexy::parse<production>(lexy::string_input(str), …);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by foonathan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #21 on December 10, 2021 07:51.