Add support for lookbehind in region regexes

Use the 'regexp2' library for lookahead and lookbehind in region
start and end regular expressions to support things like closing quotes
that aren't preceded by backslashes.
This commit is contained in:
Zachary Yedidia
2017-03-22 19:03:06 -04:00
parent bea1c5dc28
commit 87f54be13a
53 changed files with 209 additions and 157 deletions

View File

@@ -46,7 +46,7 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
@@ -55,3 +55,4 @@ rules:
end: "$"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -74,13 +74,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- preproc: "..+"
- constant.specialChar: "\\\\."
@@ -96,3 +96,4 @@ rules:
end: "\\*/"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -90,13 +90,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
@@ -105,3 +105,4 @@ rules:
end: "$"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -24,13 +24,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
@@ -39,3 +39,4 @@ rules:
end: "$"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -27,13 +27,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- preproc: "..+"
- constant.specialChar: "\\\\."
@@ -49,3 +49,4 @@ rules:
end: "\\*/"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -10,7 +10,7 @@ rules:
- constant.specialChar: "^\\s*}$"
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
@@ -19,3 +19,4 @@ rules:
start: "#"
end: "$"
rules: []

View File

@@ -24,7 +24,7 @@ rules:
# String highlighting
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "(\\\\u[0-9A-fa-f]{4,4}|\\\\newline|\\\\space|\\\\tab|\\\\formfeed|\\\\backspace|\\\\return|\\\\.)"
@@ -34,3 +34,4 @@ rules:
end: "$"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -15,13 +15,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
@@ -37,3 +37,4 @@ rules:
end: "$"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -16,7 +16,7 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
@@ -25,3 +25,4 @@ rules:
end: "$"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -6,10 +6,11 @@ detect:
rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules: []
- comment:
start: "#"
end: "$"
rules: []

View File

@@ -28,13 +28,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- preproc: "..+"
- constant.specialChar: "\\\\."
@@ -50,3 +50,4 @@ rules:
end: "\\*/"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -32,14 +32,14 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialchar: "\\\\."
- special: "#\\{[^}]*\\}"
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules: []
- comment:
@@ -58,3 +58,4 @@ rules:
start: "<<-?'?EOT'?"
end: "^EOT"
rules: []

View File

@@ -23,14 +23,14 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\([btnfr]|'|\\\"|\\\\)"
- constant.specialChar: "\\\\u[A-Fa-f0-9]{4}"
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\([btnfr]|'|\\\"|\\\\)"
- constant.specialChar: "\\\\u[A-Fa-f0-9]{4}"
@@ -46,3 +46,4 @@ rules:
end: "\\*/"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -24,12 +24,12 @@ rules:
# Strings
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
- special: "\"|'"

View File

@@ -20,13 +20,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
@@ -47,3 +47,4 @@ rules:
end: "$"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -26,7 +26,7 @@ rules:
# Character literals
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
# Keywords
@@ -52,13 +52,13 @@ rules:
# DoubleQuotedString
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
# WysiwygString
- constant.string:
start: "r\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
@@ -69,7 +69,7 @@ rules:
# HexString
- constant.string:
start: "x\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
# DelimitedString
@@ -116,3 +116,4 @@ rules:
start: "/\\+"
end: "\\+/"
rules: []

View File

@@ -32,12 +32,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."

View File

@@ -22,12 +22,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."

View File

@@ -10,7 +10,7 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
@@ -25,3 +25,4 @@ rules:
end: "\\*/"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -29,13 +29,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules: []
- comment:
@@ -43,3 +43,4 @@ rules:
end: "$"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -43,13 +43,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
@@ -58,3 +58,4 @@ rules:
end: "$"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -34,13 +34,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
@@ -66,3 +66,4 @@ rules:
end: "'''"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -28,13 +28,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
@@ -43,3 +43,4 @@ rules:
end: "$"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -29,7 +29,7 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "%."
- constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
@@ -37,7 +37,7 @@ rules:
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- error: "..+"
- constant.specialChar: "%."

View File

@@ -47,13 +47,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
@@ -68,3 +68,4 @@ rules:
end: "----"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -29,7 +29,7 @@ rules:
# Strings
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."

View File

@@ -10,7 +10,7 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules: []
- default:
@@ -24,3 +24,4 @@ rules:
end: "</style.*?>"
rules:
- include: "css"

View File

@@ -12,13 +12,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- preproc: "..+"
- constant.specialChar: "\\\\."
@@ -32,3 +32,4 @@ rules:
start: "/\\*"
end: "\\*/"
rules: []

View File

@@ -21,13 +21,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
@@ -40,3 +40,4 @@ rules:
start: "/\\*"
end: "\\*/"
rules: []

View File

@@ -12,12 +12,12 @@ rules:
- constant: "\\b(true|false)\\b"
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
- statement: "\\\"(\\\\\"|[^\"])*\\\"[[:space:]]*:\" \"'(\\'|[^'])*'[[:space:]]*:"

View File

@@ -10,15 +10,16 @@ rules:
- special: "="
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
- comment:
start: "^!"
end: "$"
rules: []

View File

@@ -11,7 +11,7 @@ rules:
- special: "[(){}<>]|\\[|\\]"
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- comment:
@@ -22,3 +22,4 @@ rules:
start: "%"
end: "$"
rules: []

View File

@@ -26,13 +26,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
@@ -58,3 +58,4 @@ rules:
start: "\\-\\-\\[\\["
end: "\\]\\]"
rules: []

View File

@@ -23,7 +23,7 @@ rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
- identifier: "\\$+(\\{[^} ]+\\}|\\([^) ]+\\))"
@@ -33,3 +33,4 @@ rules:
start: "#"
end: "$"
rules: []

View File

@@ -15,8 +15,8 @@ rules:
rules: []
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.number: "#[0-9 A-F a-f]+"

View File

@@ -34,13 +34,13 @@ rules:
- constant.string:
start: "@\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
@@ -55,3 +55,4 @@ rules:
end: "\\*/"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -22,7 +22,7 @@ rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
- preproc:
@@ -41,3 +41,4 @@ rules:
start: "({)(?:[^$])"
end: "}"
rules: []

View File

@@ -31,13 +31,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
@@ -55,3 +55,4 @@ rules:
start: "'''"
end: "'''"
rules: []

View File

@@ -30,13 +30,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
@@ -54,3 +54,4 @@ rules:
start: "'''"
end: "'''"
rules: []

View File

@@ -19,7 +19,7 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
@@ -44,3 +44,4 @@ rules:
start: "#!\\["
end: "\\]"
rules: []

View File

@@ -9,7 +9,7 @@ rules:
- statement: "\\b(def|object|case|trait|lazy|implicit|abstract|class|extends|final|implements|import|instanceof|interface|native|package|private|protected|public|static|strictfp|super|synchronized|throws|volatile|sealed)\\b"
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant: "\\b(true|false|null)\\b"
@@ -25,3 +25,4 @@ rules:
start: "/\\*\\*"
end: "\\*/"
rules: []

View File

@@ -25,13 +25,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules: []
- comment:
@@ -39,3 +39,4 @@ rules:
end: "$"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -28,11 +28,12 @@ rules:
- todo: "TODO:?"
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."

View File

@@ -26,7 +26,7 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
@@ -47,3 +47,4 @@ rules:
end: "\\*/"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -16,13 +16,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
@@ -37,3 +37,4 @@ rules:
end: "$"
rules:
- todo: "(TODO|XXX|FIXME):?"

View File

@@ -31,12 +31,12 @@ rules:
- todo: "TODO:?"
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."

View File

@@ -12,13 +12,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
@@ -27,3 +27,4 @@ rules:
end: "$"
rules: []

View File

@@ -15,13 +15,13 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules:
- constant.specialChar: "\\\\."
@@ -30,3 +30,4 @@ rules:
end: "$"
rules: []

View File

@@ -35,16 +35,17 @@ rules:
- constant.string:
start: "\""
end: "\""
end: "(?<!\\\\)\""
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
end: "(?<!\\\\)'"
rules: []
- comment:
start: "#"
end: "$"
rules: []