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 { func DetectFiletype(defs []*Def, filename string, firstLine []byte) *Def {
for _, d := range defs { for _, d := range defs {
if d.ftdetect[0].Match([]byte(filename)) { if isMatch, _ := d.ftdetect[0].MatchString(filename); isMatch {
return d return d
} }
if len(d.ftdetect) > 1 { if len(d.ftdetect) > 1 {
if d.ftdetect[1].Match(firstLine) { if isMatch, _ := d.ftdetect[1].MatchString(string(firstLine)); isMatch {
return d return d
} }
} }

View File

@@ -3,6 +3,8 @@ package highlight
import ( import (
"regexp" "regexp"
"strings" "strings"
"github.com/dlclark/regexp2"
) )
func combineLineMatch(src, dst LineMatch) LineMatch { func combineLineMatch(src, dst LineMatch) LineMatch {
@@ -46,7 +48,7 @@ func NewHighlighter(def *Def) *Highlighter {
// color's group (represented as one byte) // color's group (represented as one byte)
type LineMatch map[int]uint8 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() regexStr := regex.String()
if strings.Contains(regexStr, "^") { if strings.Contains(regexStr, "^") {
if !canMatchStart { if !canMatchStart {
@@ -58,7 +60,11 @@ func findIndex(regex *regexp.Regexp, str []byte, canMatchStart, canMatchEnd bool
return nil 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 { 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 { 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++ { for i := 0; i < len(fullHighlights); i++ {
fullHighlights[i] = region.group 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) loc := findIndex(region.end, line, start == 0, canMatchEnd)
if loc != nil { if loc != nil {
highlights[start+loc[1]-1] = region.group
if region.parent == nil { if region.parent == nil {
highlights[start+loc[1]] = 0 highlights[start+loc[1]] = 0
return combineLineMatch(highlights, return combineLineMatch(highlights,

View File

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

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -19,7 +19,7 @@ rules:
- constant.string: - constant.string:
start: "\"" start: "\""
end: "\"" end: "(?<!\\\\)\""
rules: rules:
- constant.specialChar: "\\\\." - constant.specialChar: "\\\\."
@@ -44,3 +44,4 @@ rules:
start: "#!\\[" start: "#!\\["
end: "\\]" end: "\\]"
rules: [] 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" - 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: - constant.string:
start: "\"" start: "\""
end: "\"" end: "(?<!\\\\)\""
rules: rules:
- constant.specialChar: "\\\\." - constant.specialChar: "\\\\."
- constant: "\\b(true|false|null)\\b" - constant: "\\b(true|false|null)\\b"
@@ -25,3 +25,4 @@ rules:
start: "/\\*\\*" start: "/\\*\\*"
end: "\\*/" end: "\\*/"
rules: [] rules: []

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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