Skip to content
Discussion options

You must be logged in to vote

Not a bug, it's two things in id. The characters between the quotes become one merged token node whose kind comes from the char class you gave quoted, and -dsl::unicode::control has none, so thats lexy::unknown_token_kind (token in lexy::visualize), not any_token_kind. The rule inside tnode then has to consume that token's whole lexeme (value, no quotes), but your char class only eats one charachter. This works on v2025.05.0:

struct id {
    static constexpr auto rule = dsl::opt(dsl::tnode<lexy::unknown_token_kind>(dsl::capture(dsl::any)));
    static constexpr auto value = lexy::as_string<std::string>;
};

"value" = 123 gives value. The opt covers "", which has no content node at all. If …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Spartan322
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