I found a tilde in this grammar (Grammar) of the Raku Config::INI module :
token header { ^^ \h* '[' ~ ']' $<text>=<-[ \] \n ]>+ \h* <.eol>+ }
I don't have any tildes in the text that this pattern matches. I know it '[' ~ ']'
's important because if I remove any (or two or all) of these three symbols, the pattern no longer matches the text.
I changed the expression like this and it works:
token header { ^^ \h* '[' $<text>=<-[ \] \n ]>+ ']' \h* <.eol>+ }
It seems to me that it '[' ~ ']'
means that what follows will be inside a pair of [
and ]
.
I know that in normal Raku syntax, the tilde is used ~
for concatenation, but this example is inside a grammar ('Grammar'). (In Raku, the grammar can be used to extract structured data from text.) I searched the documentation for grammars and regular expressions for just one ~
, but didn't find any within a grammar or within a regular expression either.
Taken (and translated) from the Apocalypse 5 documentation (syntax for regexes) in the "New Metacharacters" section:
In that explanation there is also the link to the corresponding tests in the Perl6 test suite (roast) repository.