Skip to content
Discussion options

You must be logged in to vote

Sorry for the delay.

The problem is that you can't "AND" branch conditions.

auto stop  = level.is_zero() >> dsl::peek(close) >> dsl::break_;

This is equivalent to

auto stop = level.is_zero() >> dsl::peek(close) + dsl::break_;

because the second >> isn't used in a branching context. Therefore, you expect } immediately after the level is zero (and it is initially zero, so that fails). I could special case the context counter somehow, but an easier way is to restructure the code:

// Stop when the next char is '}' *and* we are back to level 0.
auto stop  = dsl::if_(level.is_zero() >> dsl::break_);

// Consume a character, adjusting the level if it is a brace.
auto chunk = open >> level.inc() …

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@SC5Shout
Comment options

@foonathan
Comment options

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