You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How to write a delimited-dsl closing delimiter that is the same as an escape leader?
suppose for sake of illustration that in the object language to be parsed, strings were delimited by %
Then I would want to match delimited strings as follows:
"%one two%" --> "one two"
"%one %% two%" --> "one % two"
In Pascal, for instance, the basic syntax of a string is delimited with single quotes.
If you want to escape a single quote inside such a string, you type it twice.
What is the recommended way to handle this?
here is a snippet that did not work
struct pct_quoted {
static constexpr auto quote_sym = lexy::symbol_table<char>.map<'%'>('%');
static constexpr auto rule = [] {
auto delim = dsl::percent_sign;
auto escape = dsl::escape(delim).symbol<quote_sym>();
auto pct_q = dsl::delimited(delim, delim);
return pct_q(dsl::ascii::character,escape);
}();
};
void test_pct_quot() {
auto input = lexy::zstring_input("%one%%two%");
lexy::trace<pct_quoted>(stdout,input);
};
How to write a delimited-dsl closing delimiter that is the same as an escape leader?
suppose for sake of illustration that in the object language to be parsed, strings were delimited by
%
Then I would want to match delimited strings as follows:
"%one two%" --> "one two"
"%one %% two%" --> "one % two"
In Pascal, for instance, the basic syntax of a string is delimited with single quotes.
If you want to escape a single quote inside such a string, you type it twice.
What is the recommended way to handle this?
here is a snippet that did not work
Thank you for this nice library.
The text was updated successfully, but these errors were encountered: