diff --git a/grammars/php.cson b/grammars/php.cson index 014484a5..c3b53dd2 100644 --- a/grammars/php.cson +++ b/grammars/php.cson @@ -2207,20 +2207,10 @@ ] '2': 'name': 'keyword.other.array.phpdoc.php' - 'regex-double-quoted': - 'begin': '"/(?=(\\\\.|[^"/])++/[imsxeADSUXu]*")' - 'beginCaptures': - '0': - 'name': 'punctuation.definition.string.begin.php' - 'end': '(/)([imsxeADSUXu]*)(")' - 'endCaptures': - '0': - 'name': 'punctuation.definition.string.end.php' - 'name': 'string.regexp.double-quoted.php' + 'regex-double-quoted-interior': 'patterns': [ { - # Escaped from the regexp – there can also be 2 backslashes (since 1 will escape the first) - 'match': '(\\\\){1,2}[.$^\\[\\]{}]' + 'match': '\\\\[.$^\\[\\]{}*+()?|]' 'name': 'constant.character.escape.regex.php' } { @@ -2236,23 +2226,119 @@ 'name': 'string.regexp.arbitrary-repetition.php' } { - 'begin': '\\[(?:\\^?\\])?' + 'begin': '\\[\\^?\\]?' 'captures': '0': 'name': 'punctuation.definition.character-class.php' 'end': '\\]' 'name': 'string.regexp.character-class.php' 'patterns': [ + { + 'match': '\\\\]' + } { 'include': '#interpolation' } ] } { - 'match': '[$^+*]' + 'match': '[$^+*|?.]' 'name': 'keyword.operator.regexp.php' } ] + 'regex-double-quoted': + 'patterns': [ + { + 'match': '''(?x) + (") + [ \\t]* + ([!"#$%&')*+,./:;=>?@\\]^_`|}~-]) + (?! + (?: + \\\\[$"] + | + [^.$^\\[{*+(?|] + )+ + \\2 + [ \\t]* + [imsxeADSUXu]* + [ \\t]* + " + ) + ( + (?: + \\\\(?:"|\\2) + | + (?!"|\\2). + )++ + ) + \\2 + [ \\t]* + [imsxeADSUXu]* + [ \\t]* + (") + ''' + 'captures': + '1': + 'name': 'punctuation.definition.string.begin.php' + '4': + 'name': 'punctuation.definition.string.end.php' + '3': + 'patterns': [ + { + 'include': '#regex-double-quoted-interior' + } + ] + 'name': 'string.regexp.double-quoted.php' + } + { + 'match': '''(?x) + (") + [ \\t]* + < + (?! + (?: + \\\\[$"] + | + [^|^$*+{\\[(".] + )+ + > + [ \\t]* + [imsxeADSUXu]* + [ \\t]* + " + ) + ( + ( + < + \\g<3>* + > + | + \\\\["<>] + | + [^"<>] + )++ + ) + > + [ \\t]* + [imsxeADSUXu]* + [ \\t]* + (") + ''' + 'captures': + '1': + 'name': 'punctuation.definition.string.begin.php' + '4': + 'name': 'punctuation.definition.string.end.php' + '2': + 'patterns': [ + { + 'include': '#regex-double-quoted-interior' + } + ] + 'name': 'string.regexp.double-quoted.php' + } + ] 'regex-single-quoted': 'begin': '\'/(?=(\\\\(?:\\\\(?:\\\\[\\\\\']?|[^\'])|.)|[^\'/])++/[imsxeADSUXu]*\')' 'beginCaptures':