Skip to content

fmt format #217

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

You must be logged in to vote

Logically, you have a list of segments, where each segment is either a unicode code point, or a {...} sequence:

dsl::list(dsl::curly_bracketed(format_syntax) | dsl::else_ >> dsl::code_point)

(use dsl::bracekts(dsl::not_followed_by(...), ...) as appropriate)

Alternatively, you can merge adjacent unescaped code points, you can use dsl::until, which will consume the {, but this just means you don't have to handle it specially. I think you could just treat it as a list of segments, with { serving as list separator:

dsl::list(dsl::until(param_start).or_eof(), dsl::sep(param_start >> grammar_parameter + dsl::lit_c<'}'>))

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