meta
meta copied to clipboard
Read pattern as string
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)
One idea: Allow meta data on sequence and select rules.
// sequence
[a b c]:"foo"
// select
{a b c}:"foo"
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"
Another idea is to pass it to another rule.