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

@@ -2,11 +2,11 @@ package highlight
func DetectFiletype(defs []*Def, filename string, firstLine []byte) *Def {
for _, d := range defs {
if d.ftdetect[0].Match([]byte(filename)) {
if isMatch, _ := d.ftdetect[0].MatchString(filename); isMatch {
return d
}
if len(d.ftdetect) > 1 {
if d.ftdetect[1].Match(firstLine) {
if isMatch, _ := d.ftdetect[1].MatchString(string(firstLine)); isMatch {
return d
}
}

View File

@@ -3,6 +3,8 @@ package highlight
import (
"regexp"
"strings"
"github.com/dlclark/regexp2"
)
func combineLineMatch(src, dst LineMatch) LineMatch {
@@ -46,7 +48,7 @@ func NewHighlighter(def *Def) *Highlighter {
// color's group (represented as one byte)
type LineMatch map[int]uint8
func findIndex(regex *regexp.Regexp, str []byte, canMatchStart, canMatchEnd bool) []int {
func findIndex(regex *regexp2.Regexp, str []byte, canMatchStart, canMatchEnd bool) []int {
regexStr := regex.String()
if strings.Contains(regexStr, "^") {
if !canMatchStart {
@@ -58,7 +60,11 @@ func findIndex(regex *regexp.Regexp, str []byte, canMatchStart, canMatchEnd bool
return nil
}
}
return regex.FindIndex(str)
match, _ := regex.FindStringMatch(string(str))
if match == nil {
return nil
}
return []int{match.Index, match.Index + match.Length}
}
func findAllIndex(regex *regexp.Regexp, str []byte, canMatchStart, canMatchEnd bool) [][]int {
@@ -77,7 +83,7 @@ func findAllIndex(regex *regexp.Regexp, str []byte, canMatchStart, canMatchEnd b
}
func (h *Highlighter) highlightRegion(start int, canMatchEnd bool, lineNum int, line []byte, region *Region) LineMatch {
fullHighlights := make([]uint8, len(line))
fullHighlights := make([]uint8, len([]rune(string(line))))
for i := 0; i < len(fullHighlights); i++ {
fullHighlights[i] = region.group
}
@@ -90,6 +96,7 @@ func (h *Highlighter) highlightRegion(start int, canMatchEnd bool, lineNum int,
loc := findIndex(region.end, line, start == 0, canMatchEnd)
if loc != nil {
highlights[start+loc[1]-1] = region.group
if region.parent == nil {
highlights[start+loc[1]] = 0
return combineLineMatch(highlights,

View File

@@ -4,14 +4,16 @@ import (
"fmt"
"regexp"
"github.com/dlclark/regexp2"
"gopkg.in/yaml.v2"
)
var groups map[string]uint8
var Groups map[string]uint8
var numGroups uint8
func GetGroup(n uint8) string {
for k, v := range groups {
for k, v := range Groups {
if v == n {
return k
}
@@ -25,7 +27,7 @@ func GetGroup(n uint8) string {
// Then it has the rules which define how to highlight the file
type Def struct {
FileType string
ftdetect []*regexp.Regexp
ftdetect []*regexp2.Regexp
rules *Rules
}
@@ -53,13 +55,13 @@ type Rules struct {
type Region struct {
group uint8
parent *Region
start *regexp.Regexp
end *regexp.Regexp
start *regexp2.Regexp
end *regexp2.Regexp
rules *Rules
}
func init() {
groups = make(map[string]uint8)
Groups = make(map[string]uint8)
}
// ParseDef parses an input syntax file into a highlight Def
@@ -86,7 +88,7 @@ func ParseDef(input []byte) (s *Def, err error) {
} else if k == "detect" {
ftdetect := v.(map[interface{}]interface{})
if len(ftdetect) >= 1 {
syntax, err := regexp.Compile(ftdetect["filename"].(string))
syntax, err := regexp2.Compile(ftdetect["filename"].(string), 0)
if err != nil {
return nil, err
}
@@ -94,7 +96,7 @@ func ParseDef(input []byte) (s *Def, err error) {
s.ftdetect = append(s.ftdetect, syntax)
}
if len(ftdetect) >= 2 {
header, err := regexp.Compile(ftdetect["header"].(string))
header, err := regexp2.Compile(ftdetect["header"].(string), 0)
if err != nil {
return nil, err
}
@@ -172,11 +174,11 @@ func parseRules(input []interface{}, curRegion *Region) (*Rules, error) {
}
groupStr := group.(string)
if _, ok := groups[groupStr]; !ok {
if _, ok := Groups[groupStr]; !ok {
numGroups++
groups[groupStr] = numGroups
Groups[groupStr] = numGroups
}
groupNum := groups[groupStr]
groupNum := Groups[groupStr]
rules.patterns = append(rules.patterns, &Pattern{groupNum, r})
}
case map[interface{}]interface{}:
@@ -199,21 +201,21 @@ func parseRegion(group string, regionInfo map[interface{}]interface{}, prevRegio
var err error
region := new(Region)
if _, ok := groups[group]; !ok {
if _, ok := Groups[group]; !ok {
numGroups++
groups[group] = numGroups
Groups[group] = numGroups
}
groupNum := groups[group]
groupNum := Groups[group]
region.group = groupNum
region.parent = prevRegion
region.start, err = regexp.Compile(regionInfo["start"].(string))
region.start, err = regexp2.Compile(regionInfo["start"].(string), 0)
if err != nil {
return nil, err
}
region.end, err = regexp.Compile(regionInfo["end"].(string))
region.end, err = regexp2.Compile(regionInfo["end"].(string), 0)
if err != nil {
return nil, err

File diff suppressed because one or more lines are too long

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: []