perlop(3):
The "=>" operator is a synonym for the comma, but forces any word (con- sisting entirely of word characters) to its left to be interpreted as a string (as of 5.001). This includes words that might otherwise be con- sidered a constant or function call.
For example:
{ format => 'html', server => 'localhost', }
Currently, 'format' has a scope of support.function.perl, while 'server' is source.perl.
\b\w+\s*=> would match, but would should the scope be? string.quoted.other? And how to give it higher precedence than support.function.perl?
On 23. Nov 2006, at 21:26, Grant Hollingworth wrote:
[...] { format => 'html', server => 'localhost', }
Currently, 'format' has a scope of support.function.perl, while 'server' is source.perl.
\b\w+\s*=> would match, but would should the scope be? string.quoted.other?
In property lists we scope it constant.other.key[.plist] -- here format is to be considered a key in the key/value data structure.
And how to give it higher precedence than support.function.perl?
Place the rule which matches \b\w+\s*=> above the one which matches the support function name.
* Allan Odgaard throw-away-1@macromates.com [2006-11-23 13:49]:
In property lists we scope it constant.other.key[.plist] -- here format is to be considered a key in the key/value data structure.
Okay. I was going to use string.quoted because the key is turned into a string (e.g., {'this' => 'that'} and {this => 'that'} are identical structures) but it looks wrong to see them as strings. Perl can think of them as strings, but to us they're keys.
I added the related case of bareword subscripts. For example, in
{ format => 'html' }->{ format }
the first format is constant.other.key.perl, and the second is constant.other.bareword.perl. Maybe constant.other.subscript is better?
I used (?<={)\s*\w+\s*(?=}) for the match, so the spaces around the second format are in the same scope. Is that a problem?