atom-language icon indicating copy to clipboard operation
atom-language copied to clipboard

Regexes in S/// s/// operators not highlighted

Open zoffixznet opened this issue 8 years ago • 5 comments

I'm on v1.11.2

The regexes in S/// and s/// operators seem to be not highlighted, or (like the <before>) highlighted differently.

Note that these operators can take adverbs (like S:g///) and there are some other forms for them (I always forms for them (like say S{foo} = {} given "foobar"; or say S ♥foo♥bar♥ with "foobar")

Example Code


 /<before \s+>/;
S/<before \s+>//;
s/<before \s+>//;

 /\s+\s+\s+\s+/;
S/\s+\s+\s+\s+//;
s/\s+\s+\s+\s+//;

Picture [optional]

z

Leave this in. For internal use.

  • [x] Fixed in Master
  • [ ] Has Tests
  • [ ] Passes Tests

zoffixznet avatar Dec 19 '16 15:12 zoffixznet

So there take the same unmatched delimiters for the arbitrary Q/q/qq quoting then?

At least for say S ♥foo♥bar♥ it seems like it?

Does this one only work with brackets or are there other forms? say S{foo} = {} given "foobar";

samcv avatar Dec 19 '16 18:12 samcv

This works `say S[foo] = [] given "foobar";'

So does this say S«foo» = «» given "foobar"

But with say S<foo> = <> given "foobar" I get: Unsupported use of <>; in Perl 6 please use lines() to read input, ('') to represent a null string or () to represent an empty list

Is that last one a bug or a specific case where that's not allowed as a delimiter?

samcv avatar Dec 19 '16 18:12 samcv

I see this bug here: https://github.com/MadcapJake/language-perl6fe/issues/14

But I can definitely fix this, will just require doing some nested captures and grammar rules.

samcv avatar Dec 19 '16 18:12 samcv

So there take the same unmatched delimiters for the arbitrary Q/q/qq quoting then?

I'd expect them to take the same quoters as Q/q/qq forms, since they're just a multi of the quote token in the grammar.

Is that last one a bug or a specific case where that's not allowed as a delimiter?

I think in the form with the = in it the RHS is parsed as normal code:

$ perl6 -e 'say S[foo] = [zof] given "foobar"'
===SORRY!=== Error while compiling -e
Undeclared routine:
    zof used at line 1


$ ./perl6 -e 'say S⟬zof⟭ = ⟬zof⟭ given "foobar"'
===SORRY!=== Error while compiling -e
Assignment operator missing its expression
at -e:1
------> say S⟬zof⟭ =⏏ ⟬zof⟭ given "foobar"
    expecting any of:
        prefix
        term

$ ./perl6 -e 'say S ⟬zof⟭ = q⟬zof⟭ given "foobar"'
foobar

$ ./perl6 -e 'say S⟬zof⟭ = "zof" given "foobar"'
foobar

So the <> is not delimiters for S///, but just regular angle-bracket quoter; and it cries when it's empty.

zoffixznet avatar Dec 19 '16 18:12 zoffixznet

For now I am having it highlight s// and S// as if it were m// or rx// in v1.11.4 i just released. So hopefully that should make it much less likely to break highlighting further down the page, though eventually I will make it capture the replacement term.

samcv avatar Dec 19 '16 19:12 samcv