meta icon indicating copy to clipboard operation
meta copied to clipboard

Read pattern as string

Open bvssvni opened this issue 9 years ago • 3 comments

Sometimes you want to match over a pattern of rules and use it as a string.

Examples of usage:

  • Code generation (part of the syntax rules describe a pattern for another language)
  • Doc comments (follows a pattern but is not processed at the first stage of parsing)

bvssvni avatar May 21 '16 11:05 bvssvni

One idea: Allow meta data on sequence and select rules.

// sequence
[a b c]:"foo"
// select
{a b c}:"foo"

bvssvni avatar Dec 02 '16 21:12 bvssvni

In the case of comments, this text includes the special characters, so their meaning becomes application specific:

// includes `//` and `/* ... */` in "text".
1 comment = {multi_line_comment ["//" ..."\n"?]}:"text"

bvssvni avatar Dec 02 '16 21:12 bvssvni

Another idea is to pass it to another rule.

bvssvni avatar Jan 06 '17 02:01 bvssvni