Merge pull request #3458 from JoeKar/feature/empty-rules

Remove empty rules in regions
This commit is contained in:
Jöran Karl 2024-09-09 18:48:21 +02:00 committed by GitHub
commit 8c52d2426d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
73 changed files with 11 additions and 145 deletions

View File

@ -258,7 +258,7 @@ func ParseDef(f *File, header *Header) (s *Def, err error) {
if s.rules == nil {
// allow empty rules
s.rules = new(rules)
s.rules = &rules{}
}
return s, err
@ -476,10 +476,17 @@ func parseRegion(group string, regionInfo map[interface{}]interface{}, prevRegio
r.limitGroup = r.group
}
r.rules, err = parseRules(regionInfo["rules"].([]interface{}), r)
// rules are optional
if rules, ok := regionInfo["rules"]; ok {
r.rules, err = parseRules(rules.([]interface{}), r)
if err != nil {
return nil, err
}
}
if err != nil {
return nil, err
if r.rules == nil {
// allow empty rules
r.rules = &rules{}
}
return r, nil

View File

@ -371,7 +371,6 @@ highlighted. For example:
start: "\""
end: "\""
skip: "\\."
rules: []
```
#### Includes

View File

@ -47,7 +47,6 @@ function onBufferOpen(buf)
syntaxFile = syntaxFile .. " - special:\n"
syntaxFile = syntaxFile .. " start: \"@\\\\{\"\n"
syntaxFile = syntaxFile .. " end: \"\\\\}\"\n"
syntaxFile = syntaxFile .. " rules: []\n"
syntaxFile = syntaxFile .. " - include: " .. codetype .. "\n"
config.AddRuntimeFileFromMemory(config.RTSyntax, "literate.yaml", syntaxFile)

View File

@ -19,5 +19,4 @@ rules:
- comment:
start: "#"
end: "$"
rules: []

View File

@ -30,7 +30,6 @@ rules:
- preproc:
start: "\\$(\\{|ENV\\{)"
end: "\\}"
rules: []
- identifier.macro: "\\b(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\\b"

View File

@ -27,12 +27,10 @@ rules:
- constant.string:
start: "`"
end: "`"
rules: []
- constant.string:
start: "%x\\{"
end: "\\}"
rules: []
- constant.string:
start: "\""
@ -68,5 +66,4 @@ rules:
- constant:
start: "<<-?'?EOT'?"
end: "^EOT"
rules: []

File diff suppressed because one or more lines are too long

View File

@ -109,13 +109,10 @@ rules:
- comment:
start: "//"
end: "$"
rules: []
- comment:
start: "/\\*"
end: "\\*/"
rules: []
- comment:
start: "/\\+"
end: "\\+/"
rules: []

View File

@ -19,7 +19,6 @@ rules:
- default:
start: "<%"
end: "%>"
rules: []
- preproc: "<%|%>"
- red: "&[^;[[:space:]]]*;"
@ -37,6 +36,5 @@ rules:
- identifier.macro:
start: "<<-?'?EOT'?"
end: "^EOT"
rules: []
- todo: "(XXX|TODO|FIXME|\\?\\?\\?)"

View File

@ -22,7 +22,6 @@ rules:
start: "'"
end: "'"
skip: "\\\\."
rules: []
# - constant.specialChar: "%."
# - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
# - constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
@ -42,4 +41,3 @@ rules:
- comment:
start: "%"
end: "$"
rules: []

View File

@ -38,7 +38,6 @@ rules:
start: "'"
end: "'"
skip: "\\\\."
rules: []
- comment:
start: "#"

View File

@ -19,7 +19,6 @@ rules:
- constant.string:
start: "\\b([Ss.]\" )"
end: "\""
rules: []
- comment:
start: "\\("

View File

@ -45,4 +45,3 @@ rules:
- comment:
start: "\\(\\*"
end: "\\*\\)"
rules: []

View File

@ -10,7 +10,6 @@ rules:
- special:
start: "^```"
end: "^```"
rules: []
# heading lines
- special: "^#{1,3}.*"
# unordered list items

View File

@ -20,4 +20,3 @@ rules:
- comment:
start: "#"
end: "$"
rules: []

View File

@ -22,7 +22,6 @@ rules:
- comment.line:
start: "^#"
end: "$"
rules: []
# Diffs (i.e. git commit --verbose)
- default:

View File

@ -11,4 +11,3 @@ rules:
- comment:
start: "#"
end: "$"
rules: []

View File

@ -16,4 +16,3 @@ rules:
- comment.line:
start: "^#"
end: "$"
rules: []

View File

@ -47,7 +47,6 @@ rules:
- constant.string:
start: "`"
end: "`"
rules: []
- comment:
start: "//"

View File

@ -44,4 +44,3 @@ rules:
- comment:
start: "#"
end: "$"
rules: []

View File

@ -11,7 +11,6 @@ rules:
- constant:
start: "(\\\\|\\\\\\\\)n\\["
end: "]"
rules: []
- type: "^\\.[[:space:]]*[^[[:space:]]]*"
- comment: "^\\.\\\\\".*$"
@ -19,12 +18,10 @@ rules:
- constant.string:
start: "(\\\\|\\\\\\\\)\\*\\["
end: "]"
rules: []
- constant.specialChar: "\\\\\\(.."
- constant.specialChar:
start: "\\\\\\["
end: "]"
rules: []
- identifier.macro: "\\\\\\\\\\$[1-9]"

View File

@ -75,7 +75,6 @@ rules:
- identifier:
start: "[$][{]"
end: "[}]"
rules: []
# Triple-single-quoted strings
- constant.string:
@ -90,7 +89,6 @@ rules:
- constant.string:
start: "[$]/"
end: "/[$]"
rules: []
# Single-line comments
- comment:
@ -110,4 +108,3 @@ rules:
- comment:
start: "/[*][*]@?"
end: "[*]/"
rules: []

View File

@ -17,7 +17,6 @@ rules:
- default:
start: ">"
end: "<"
rules: []
- symbol.tag: "<|>"
- constant.string.url: "(ftp(s)?|http(s)?|git|chrome)://[^ ]+"

View File

@ -17,7 +17,6 @@ rules:
- default:
start: ">"
end: "<"
rules: []
- symbol.tag: "<|>"
- constant.string.url: "(ftp(s)?|http(s)?|git|chrome)://[^ ]+"

View File

@ -28,10 +28,8 @@ rules:
- comment:
start: "//"
end: "$"
rules: []
- comment:
start: "/\\*"
end: "\\*/"
rules: []

View File

@ -16,4 +16,3 @@ rules:
- comment:
start: "{#"
end: "#}"
rules: []

View File

@ -75,7 +75,6 @@ rules:
start: "\\|\\|\\| *$"
end: "^ *\\|\\|\\|"
rules: []
# multi-line comment
- comment:

View File

@ -30,7 +30,6 @@ rules:
- constant.string:
start: "\"\"\""
end: "\"\"\""
rules: []
- constant.string:
start: "\""
@ -44,14 +43,11 @@ rules:
- constant.string:
start: "'\""
end: "'"
rules: []
- comment:
start: "#="
end: "=#"
rules: []
- comment:
start: "#"
end: "$"
rules: []

View File

@ -37,4 +37,3 @@ rules:
- comment:
start: "#"
end: "$"
rules: []

View File

@ -23,5 +23,4 @@ rules:
- comment:
start: "^!"
end: "$"
rules: []

View File

@ -54,14 +54,11 @@ rules:
start: "\""
end: "(\"|$)"
skip: "\\\\."
rules: []
- constant.string:
start: "'"
end: "('|$)"
skip: "\\\\."
rules: []
- comment:
start: "#"
end: "$"
rules: []

View File

@ -18,9 +18,7 @@ rules:
- comment:
start: "%\\{"
end: "%\\}"
rules: []
- comment:
start: "%"
end: "$"
rules: []

View File

@ -83,7 +83,6 @@ rules:
- constant.string.url:
start: "https?://"
end: "\\s"
rules: []
# path
# - constant.string.url: "\\b(.+)/([^/]+)\\b" # linux

View File

@ -45,7 +45,6 @@ rules:
- constant.string:
start: "\\[\\["
end: "\\]\\]"
rules: []
# support first few lengths of "long brackets" explicitly
# brackets longer than that will give false positives
@ -53,22 +52,18 @@ rules:
- constant.string:
start: "\\[=\\["
end: "\\]=\\]"
rules: []
- constant.string:
start: "\\[==\\["
end: "\\]==\\]"
rules: []
- constant.string:
start: "\\[===\\["
end: "\\]===\\]"
rules: []
- constant.string:
start: "\\[====+\\["
end: "\\]====+\\]"
rules: []
- comment.block:
start: "\\-\\-\\[\\["

View File

@ -18,8 +18,6 @@ rules:
- default:
start: "^\\n\\n"
end: ".*"
rules: []
- comment:
start: "^>.*"
end: "$"
rules: []

View File

@ -34,5 +34,4 @@ rules:
- comment:
start: "#"
end: "$"
rules: []

View File

@ -46,4 +46,3 @@ rules:
- special:
start: "`"
end: "`"
rules: []

View File

@ -11,13 +11,10 @@ rules:
- comment:
start: "#"
end: "$"
rules: []
- comment:
start: "dnl"
end: "$"
rules: []
- constant.string:
start: "`"
end: "'"
rules: []

View File

@ -15,7 +15,6 @@ rules:
- constant.string:
start: "'$"
end: "';$"
rules: []
- comment: "(^|[[:space:]])#([^{].*)?$"
- indent-char.whitespace: "[[:space:]]+$"

View File

@ -22,6 +22,5 @@ rules:
- comment:
start: "\\#\\["
end: "\\]\\#"
rules: []
- todo: "(TODO|FIXME|XXX):?"

View File

@ -14,19 +14,15 @@ rules:
- constant.string:
start: "\""
end: "\""
rules: []
- constant.string:
start: "''"
end: "''"
rules: []
- comment:
start: "#"
end: "$"
rules: []
- comment:
start: "/\\*"
end: "\\*/"
rules: []

View File

@ -94,7 +94,6 @@ rules:
- comment:
start: "#"
end: "$"
rules: []
- comment:
start: "/\\*"
end: "\\*/"

View File

@ -40,4 +40,3 @@ rules:
- comment:
start: "\\(\\*"
end: "\\*\\)"
rules: []

View File

@ -49,7 +49,6 @@ rules:
- constant.string:
start: "`"
end: "`"
rules: []
- comment:
start: "//"

View File

@ -12,7 +12,6 @@ rules:
- special:
start: "asm"
end: "end"
rules: []
- constant.number: "\\$[0-9A-Fa-f]+"
- constant.number: "\\b[+-]?[0-9]+([.]?[0-9]+)?(?i:e[+-]?[0-9]+)?"
- constant.string:
@ -29,17 +28,13 @@ rules:
- preproc:
start: "{\\$"
end: "}"
rules: []
- comment:
start: "//"
end: "$"
rules: []
- comment:
start: "\\(\\*"
end: "\\*\\)"
rules: []
- comment:
start: "({)(?:[^$])"
end: "}"
rules: []

View File

@ -28,12 +28,10 @@ rules:
start: "'"
end: "'"
skip: "\\\\'"
rules: []
- comment:
start: "#"
end: "$"
rules: []
- constant.string: "\"\\(.*\\)\"|qq?\\|.*\\||qq?\\{.*\\}|qq?\\/.*\\/"
- constant.number: "\\b([0-9]*[.])?[0-9]+"
@ -45,14 +43,11 @@ rules:
- preproc:
start: "(^use| = new)"
end: ";"
rules: []
- comment:
start: "^="
end: "^=cut"
rules: []
- identifier.macro:
start: "<< 'STOP'"
end: "STOP"
rules: []

View File

@ -40,11 +40,9 @@ rules:
- comment:
start: "(^|[[:space:]])*(//|#)"
end: "$"
rules: []
- comment:
start: "/\\*"
end: "\\*/"
rules: []
- constant.string:
start: "\""

View File

@ -26,12 +26,10 @@ rules:
- comment:
start: "\"\"\"[^\"]*"
end: "\"\"\""
rules: []
- comment: "(^|[[:space:]])//.*"
- comment:
start: "/\\*"
end: "\\*/"
rules: []
- todo: "TODO:?"

View File

@ -17,5 +17,4 @@ rules:
- comment:
start: "/\\*"
end: "\\*/"
rules: []

View File

@ -32,12 +32,10 @@ rules:
- constant.string:
start: "\"\"\""
end: "\"\"\""
rules: []
- constant.string:
start: "'''"
end: "'''"
rules: []
- constant.string:
start: "\""
@ -56,5 +54,4 @@ rules:
- comment:
start: "#"
end: "$"
rules: []

View File

@ -34,12 +34,10 @@ rules:
- constant.string:
start: "\"\"\""
end: "\"\"\""
rules: []
- constant.string:
start: "'''"
end: "'''"
rules: []
- constant.string:
start: "\""

View File

@ -29,14 +29,11 @@ rules:
- preproc:
start: "(^use| = new)"
end: ";"
rules: []
- identifier.macro:
start: "<<EOSQL"
end: "EOSQL"
rules: []
- comment:
start: "#"
end: "$"
rules: []

View File

@ -14,7 +14,6 @@ rules:
- preproc:
start: "^(Source|Patch)"
end: ":"
rules: []
- preproc: "(i386|i486|i586|i686|athlon|ia64|alpha|alphaev5|alphaev56|alphapca56|alphaev6|alphaev67|sparc|sparcv9|sparc64armv3l|armv4b|armv4lm|ips|mipsel|ppc|ppc|iseries|ppcpseries|ppc64|m68k|m68kmint|Sgi|rs6000|i370|s390x|s390|noarch)"
- preproc: "(ifarch|ifnarch|ifos|ifnos)"
@ -24,12 +23,10 @@ rules:
- statement:
start: "%\\{"
end: "\\}"
rules: []
- statement:
start: "%\\{__"
end: "\\}"
rules: []
- statement: "\\$(RPM_BUILD_ROOT)\\>"
- special: "^%(build$|changelog|check$|clean$|description)"

View File

@ -30,7 +30,6 @@ rules:
start: "'"
end: "'"
skip: "\\\\."
rules: []
- constant.string:
start: "\""
@ -63,6 +62,5 @@ rules:
- constant.macro:
start: "<<-?'?EOT'?"
end: "^EOT"
rules: []
- preproc.shebang: "^#!.+?( |$)"

View File

@ -31,22 +31,18 @@ rules:
- constant.string:
start: "[bc]?r#\""
end: "\"#"
rules: []
- constant.string:
start: "[bc]?r##\""
end: "\"##"
rules: []
- constant.string:
start: "[bc]?r###\""
end: "\"###"
rules: []
- constant.string:
start: "[bc]?r####+\""
end: "\"####+"
rules: []
# Character literals
# NOTE: This is an ugly hack to work around the fact that rust uses
@ -58,7 +54,6 @@ rules:
- constant.string:
start: "'\""
end: "'"
rules: []
- comment:
start: "//"
@ -75,4 +70,3 @@ rules:
- special:
start: "#!\\["
end: "\\]"
rules: []

View File

@ -32,12 +32,10 @@ rules:
- comment:
start: "\"\"\""
end: "\"\"\""
rules: []
- comment:
start: "'''"
end: "'''"
rules: []
- constant.string:
start: "\""
@ -56,5 +54,4 @@ rules:
- comment:
start: "#"
end: "$"
rules: []

View File

@ -28,7 +28,6 @@ rules:
- preproc:
start: "^ *(use|include) <"
end: ">;?"
rules: []
- constant.number: "\\b[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?|PI|inf|nan\\b"
- constant.bool: "\\b(true|false)\\b"

View File

@ -10,7 +10,6 @@ rules:
- constant.string:
start: "\"\"\""
end: "\"\"\""
rules: []
- constant.string:
start: "\""
end: "\""
@ -21,13 +20,10 @@ rules:
- comment:
start: "//"
end: "$"
rules: []
- comment:
start: "/\\*"
end: "\\*/"
rules: []
- comment:
start: "/\\*\\*"
end: "\\*/"
rules: []

View File

@ -48,19 +48,16 @@ rules:
start: "\""
end: "\""
skip: "\\\\."
rules: []
- constant.string:
start: "'"
end: "'"
skip: "\\\\."
rules: []
- constant.string:
start: "<<[^\\s]+[-~.]*[A-Za-z0-9]+$"
end: "^[^\\s]+[A-Za-z0-9]+$"
skip: "\\\\."
rules: []
- comment:
start: "(^|\\s)#"

View File

@ -18,7 +18,6 @@ rules:
start: "'"
end: "'"
skip: "\\\\."
rules: []
- constant.string:
start: "\""
@ -50,6 +49,5 @@ rules:
- constant.macro:
start: "<<-?'?EOT'?"
end: "^EOT"
rules: []
- preproc.shebang: "^#!.+?( |$)"

View File

@ -20,11 +20,9 @@ rules:
- comment:
start: "//"
end: "$"
rules: []
- comment:
start: "/\\*"
end: "\\*/"
rules: []
- todo: "TODO:?"
- constant.string:
start: "\""

View File

@ -11,7 +11,6 @@ rules:
- identifier.macro:
start: "`"
end: "'"
rules: []
- identifier.macro: "\\$\\w+"
- constant.specialChar: "\\\\."
@ -22,7 +21,6 @@ rules:
- identifier.macro:
start: "`"
end: "'"
rules: []
- identifier.macro: "\\$\\w+"
- constant.specialChar: "\\\\."
@ -46,7 +44,6 @@ rules:
- identifier.macro:
start: "`"
end: "'"
rules: []
- comment:
start: "///?"

View File

@ -149,7 +149,6 @@ func generateFile(filetype, syntax, header string, rules []interface{}) string {
output += fmt.Sprintf(" - %s:\n", rule.color)
output += fmt.Sprintf(" start: \"%s\"\n", strings.Replace(strings.Replace(rule.start, "\\", "\\\\", -1), "\"", "\\\"", -1))
output += fmt.Sprintf(" end: \"%s\"\n", strings.Replace(strings.Replace(rule.end, "\\", "\\\\", -1), "\"", "\\\"", -1))
output += fmt.Sprintf(" rules: []\n\n")
}
}

View File

@ -8,11 +8,9 @@ rules:
- identifier:
start: "\\{"
end: "\\}"
rules: []
- identifier:
start: "\\["
end: "\\]"
rules: []
# numbers
- constant.number: "\\b[0-9]+(\\.[0-9]+)?([[:space:]](pt|mm|cm|in|ex|em|bp|pc|dd|cc|nd|nc|sp))?\\b"
# let brackets have the default color again
@ -25,8 +23,6 @@ rules:
- comment:
start: "[^\\\\]%|^%"
end: "$"
rules: []
- comment:
start: "\\\\begin\\{comment\\}"
end: "\\\\end\\{comment\\}"
rules: []

View File

@ -27,11 +27,9 @@ rules:
- constant.string:
start: "'''"
end: "'{3,5}"
rules: []
- constant.string:
start: "'"
end: "'"
rules: []
# Integer
- constant.number: '[+-]?(\d+_)*\d+\b'
- constant.number: '(0x([[:xdigit:]]+_)*[[:xdigit:]]+|0o([0-7]_)*[0-7]+|0b([01]+_)*[01]+)'

View File

@ -52,4 +52,3 @@ rules:
- comment:
start: "\\{#"
end: "#\\}"
rules: []

View File

@ -23,7 +23,6 @@ rules:
- comment:
start: "//"
end: "$"
rules: []
- comment:
start: "/\\*"
end: "\\*/"

View File

@ -65,7 +65,6 @@ rules:
- constant.string:
start: "`"
end: "`"
rules: []
- comment:
start: "//"

View File

@ -19,7 +19,6 @@ rules:
- comment:
start: "/\\*"
end: "\\*/"
rules: []
- todo: "TODO:?"
- indent-char.whitespace: "[[:space:]]+$"

View File

@ -14,7 +14,6 @@ rules:
- comment:
start: "(^\"|[ \t]+\" |[ \t]+\"$)"
end: "$"
rules: []
- constant.string:
start: "\""

View File

@ -27,7 +27,6 @@ rules:
- comment.block:
start: "<!\\-\\-"
end: "\\-\\->"
rules: []
# Bootstrap
- symbol.tag.extended: "(?i)<[/]?(b-alert|b-aspect|b-avatar|b-badge|b-icon|b-breadcrumb|b-button-group|b-button-toolbar|b-button|b-calendar|b-card-text|b-card-input|b-card|b-carousel-slide|b-carousel|b-collapse|b-dropdown|b-dropdown-item|b-dropdown-divider|b-embed|b-form-checkbox-group|b-form-checkbox|b-form-datepicker|b-form-file|b-form-group|b-form-input|b-form-radio|b-form-rating|b-form-select|b-form-spinbutton|b-form-tags|b-form-textarea|b-form|b-form-timepicker|b-img-lazy|b-img|b-input-group|b-jumbotron|b-input|b-container|b-row|b-col|b-link|b-list-group|b-list-group-item|b-media|b-modal|b-nav|b-nav-item|b-nav-item-dropdown|b-nav-text|b-nav-form|b-navbar|b-navbar-brand|b-navbar-toggle|b-navbar-nav|b-overlay|b-pagination|b-pagination-nav|b-popover|b-progress|b-progress-bar|b-sidebar|b-skeleton-wrapper|b-skeleton|b-spinner|b-table|b-table-lite|b-table-simple|b-tabs|b-tab|b-time|b-toast|b-tooltip)\\b"

View File

@ -8,12 +8,10 @@ rules:
- preproc:
start: "<!DOCTYPE"
end: "[/]?>"
rules: []
- comment:
start: "<!--"
end: "-->"
rules: []
- symbol.tag:
start: "<\\??"
@ -22,7 +20,6 @@ rules:
- identifier:
start: " "
end: "="
rules: []
- constant.string:
start: "\""
end: "\""

View File

@ -43,10 +43,8 @@ rules:
- constant.string:
start: "'"
end: "'"
rules: []
- comment:
start: "(^|\\s)#"
end: "$"
rules: []