Skip to content
Discussion options

You must be logged in to vote

Okay, using dsl::peek I got it working; let me know if you think there's a better way to do it.

https://lexy.foonathan.net/playground/?id=f5x5xY58T&mode=tree

The modified lines are shown like this // <--- using peek

#include <lexy/callback.hpp>

struct StepRange {
    int first{};
    int last{};
    int step{};
};

struct simplestep { // "6"
    static constexpr auto rule = dsl::integer<int>;
    static constexpr auto value = lexy::construct<StepRange>;
};

struct simplerange { // "1..10"
    static constexpr auto rule = dsl::peek(dsl::while_one(dsl::digit<>) >> dsl::twice(dsl::period)) // <--- using peek
        >> dsl::integer<int16_t>
        >> dsl::twice(dsl::period)
        + dsl::…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@foonathan
Comment options

Answer selected by totalgee
Comment options

You must be logged in to vote
4 replies
@totalgee
Comment options

@totalgee
Comment options

@foonathan
Comment options

@totalgee
Comment options

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