1
0
Fork 0
forked from forgejo/forgejo

Server-side syntax highlighting for all code (#12047)

* Server-side syntax hilighting for all code

This PR does a few things:

* Remove all traces of highlight.js
* Use chroma library to provide fast syntax hilighting directly on the server
* Provide syntax hilighting for diffs
* Re-style both unified and split diffs views
* Add custom syntax hilighting styling for both regular and arc-green

Fixes #7729
Fixes #10157
Fixes #11825
Fixes #7728
Fixes #3872
Fixes #3682

And perhaps gets closer to #9553

* fix line marker

* fix repo search

* Fix single line select

* properly load settings

* npm uninstall highlight.js

* review suggestion

* code review

* forgot to call function

* fix test

* Apply suggestions from code review

suggestions from @silverwind thanks

Co-authored-by: silverwind <me@silverwind.io>

* code review

* copy/paste error

* Use const for highlight size limit

* Update web_src/less/_repository.less

Co-authored-by: Lauris BH <lauris@nix.lv>

* update size limit to 1MB and other styling tweaks

* fix highlighting for certain diff sections

* fix test

* add worker back as suggested

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
mrsdizzie 2020-06-30 17:34:03 -04:00 committed by GitHub
parent ce5f2b9845
commit af7ffaa279
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
336 changed files with 37293 additions and 769 deletions

94
vendor/github.com/alecthomas/chroma/lexers/s/sas.go generated vendored Normal file
View file

@ -0,0 +1,94 @@
package s
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Sas lexer.
var Sas = internal.Register(MustNewLexer(
&Config{
Name: "SAS",
Aliases: []string{"sas"},
Filenames: []string{"*.SAS", "*.sas"},
MimeTypes: []string{"text/x-sas", "text/sas", "application/x-sas"},
CaseInsensitive: true,
},
Rules{
"root": {
Include("comments"),
Include("proc-data"),
Include("cards-datalines"),
Include("logs"),
Include("general"),
{`.`, Text, nil},
{`\\\n`, Text, nil},
{`\n`, Text, nil},
},
"comments": {
{`^\s*\*.*?;`, Comment, nil},
{`/\*.*?\*/`, Comment, nil},
{`^\s*\*(.|\n)*?;`, CommentMultiline, nil},
{`/[*](.|\n)*?[*]/`, CommentMultiline, nil},
},
"proc-data": {
{`(^|;)\s*(proc \w+|data|run|quit)[\s;]`, KeywordReserved, nil},
},
"cards-datalines": {
{`^\s*(datalines|cards)\s*;\s*$`, Keyword, Push("data")},
},
"data": {
{`(.|\n)*^\s*;\s*$`, Other, Pop(1)},
},
"logs": {
{`\n?^\s*%?put `, Keyword, Push("log-messages")},
},
"log-messages": {
{`NOTE(:|-).*`, Generic, Pop(1)},
{`WARNING(:|-).*`, GenericEmph, Pop(1)},
{`ERROR(:|-).*`, GenericError, Pop(1)},
Include("general"),
},
"general": {
Include("keywords"),
Include("vars-strings"),
Include("special"),
Include("numbers"),
},
"keywords": {
{Words(`\b`, `\b`, `abort`, `array`, `attrib`, `by`, `call`, `cards`, `cards4`, `catname`, `continue`, `datalines`, `datalines4`, `delete`, `delim`, `delimiter`, `display`, `dm`, `drop`, `endsas`, `error`, `file`, `filename`, `footnote`, `format`, `goto`, `in`, `infile`, `informat`, `input`, `keep`, `label`, `leave`, `length`, `libname`, `link`, `list`, `lostcard`, `merge`, `missing`, `modify`, `options`, `output`, `out`, `page`, `put`, `redirect`, `remove`, `rename`, `replace`, `retain`, `return`, `select`, `set`, `skip`, `startsas`, `stop`, `title`, `update`, `waitsas`, `where`, `window`, `x`, `systask`), Keyword, nil},
{Words(`\b`, `\b`, `add`, `and`, `alter`, `as`, `cascade`, `check`, `create`, `delete`, `describe`, `distinct`, `drop`, `foreign`, `from`, `group`, `having`, `index`, `insert`, `into`, `in`, `key`, `like`, `message`, `modify`, `msgtype`, `not`, `null`, `on`, `or`, `order`, `primary`, `references`, `reset`, `restrict`, `select`, `set`, `table`, `unique`, `update`, `validate`, `view`, `where`), Keyword, nil},
{Words(`\b`, `\b`, `do`, `if`, `then`, `else`, `end`, `until`, `while`), Keyword, nil},
{Words(`%`, `\b`, `bquote`, `nrbquote`, `cmpres`, `qcmpres`, `compstor`, `datatyp`, `display`, `do`, `else`, `end`, `eval`, `global`, `goto`, `if`, `index`, `input`, `keydef`, `label`, `left`, `length`, `let`, `local`, `lowcase`, `macro`, `mend`, `nrquote`, `nrstr`, `put`, `qleft`, `qlowcase`, `qscan`, `qsubstr`, `qsysfunc`, `qtrim`, `quote`, `qupcase`, `scan`, `str`, `substr`, `superq`, `syscall`, `sysevalf`, `sysexec`, `sysfunc`, `sysget`, `syslput`, `sysprod`, `sysrc`, `sysrput`, `then`, `to`, `trim`, `unquote`, `until`, `upcase`, `verify`, `while`, `window`), NameBuiltin, nil},
{Words(`\b`, `\(`, `abs`, `addr`, `airy`, `arcos`, `arsin`, `atan`, `attrc`, `attrn`, `band`, `betainv`, `blshift`, `bnot`, `bor`, `brshift`, `bxor`, `byte`, `cdf`, `ceil`, `cexist`, `cinv`, `close`, `cnonct`, `collate`, `compbl`, `compound`, `compress`, `cos`, `cosh`, `css`, `curobs`, `cv`, `daccdb`, `daccdbsl`, `daccsl`, `daccsyd`, `dacctab`, `dairy`, `date`, `datejul`, `datepart`, `datetime`, `day`, `dclose`, `depdb`, `depdbsl`, `depsl`, `depsyd`, `deptab`, `dequote`, `dhms`, `dif`, `digamma`, `dim`, `dinfo`, `dnum`, `dopen`, `doptname`, `doptnum`, `dread`, `dropnote`, `dsname`, `erf`, `erfc`, `exist`, `exp`, `fappend`, `fclose`, `fcol`, `fdelete`, `fetch`, `fetchobs`, `fexist`, `fget`, `fileexist`, `filename`, `fileref`, `finfo`, `finv`, `fipname`, `fipnamel`, `fipstate`, `floor`, `fnonct`, `fnote`, `fopen`, `foptname`, `foptnum`, `fpoint`, `fpos`, `fput`, `fread`, `frewind`, `frlen`, `fsep`, `fuzz`, `fwrite`, `gaminv`, `gamma`, `getoption`, `getvarc`, `getvarn`, `hbound`, `hms`, `hosthelp`, `hour`, `ibessel`, `index`, `indexc`, `indexw`, `input`, `inputc`, `inputn`, `int`, `intck`, `intnx`, `intrr`, `irr`, `jbessel`, `juldate`, `kurtosis`, `lag`, `lbound`, `left`, `length`, `lgamma`, `libname`, `libref`, `log`, `log10`, `log2`, `logpdf`, `logpmf`, `logsdf`, `lowcase`, `max`, `mdy`, `mean`, `min`, `minute`, `mod`, `month`, `mopen`, `mort`, `n`, `netpv`, `nmiss`, `normal`, `note`, `npv`, `open`, `ordinal`, `pathname`, `pdf`, `peek`, `peekc`, `pmf`, `point`, `poisson`, `poke`, `probbeta`, `probbnml`, `probchi`, `probf`, `probgam`, `probhypr`, `probit`, `probnegb`, `probnorm`, `probt`, `put`, `putc`, `putn`, `qtr`, `quote`, `ranbin`, `rancau`, `ranexp`, `rangam`, `range`, `rank`, `rannor`, `ranpoi`, `rantbl`, `rantri`, `ranuni`, `repeat`, `resolve`, `reverse`, `rewind`, `right`, `round`, `saving`, `scan`, `sdf`, `second`, `sign`, `sin`, `sinh`, `skewness`, `soundex`, `spedis`, `sqrt`, `std`, `stderr`, `stfips`, `stname`, `stnamel`, `substr`, `sum`, `symget`, `sysget`, `sysmsg`, `sysprod`, `sysrc`, `system`, `tan`, `tanh`, `time`, `timepart`, `tinv`, `tnonct`, `today`, `translate`, `tranwrd`, `trigamma`, `trim`, `trimn`, `trunc`, `uniform`, `upcase`, `uss`, `var`, `varfmt`, `varinfmt`, `varlabel`, `varlen`, `varname`, `varnum`, `varray`, `varrayx`, `vartype`, `verify`, `vformat`, `vformatd`, `vformatdx`, `vformatn`, `vformatnx`, `vformatw`, `vformatwx`, `vformatx`, `vinarray`, `vinarrayx`, `vinformat`, `vinformatd`, `vinformatdx`, `vinformatn`, `vinformatnx`, `vinformatw`, `vinformatwx`, `vinformatx`, `vlabel`, `vlabelx`, `vlength`, `vlengthx`, `vname`, `vnamex`, `vtype`, `vtypex`, `weekday`, `year`, `yyq`, `zipfips`, `zipname`, `zipnamel`, `zipstate`), NameBuiltin, nil},
},
"vars-strings": {
{`&[a-z_]\w{0,31}\.?`, NameVariable, nil},
{`%[a-z_]\w{0,31}`, NameFunction, nil},
{`\'`, LiteralString, Push("string_squote")},
{`"`, LiteralString, Push("string_dquote")},
},
"string_squote": {
{`'`, LiteralString, Pop(1)},
{`\\\\|\\"|\\\n`, LiteralStringEscape, nil},
{`[^$\'\\]+`, LiteralString, nil},
{`[$\'\\]`, LiteralString, nil},
},
"string_dquote": {
{`"`, LiteralString, Pop(1)},
{`\\\\|\\"|\\\n`, LiteralStringEscape, nil},
{`&`, NameVariable, Push("validvar")},
{`[^$&"\\]+`, LiteralString, nil},
{`[$"\\]`, LiteralString, nil},
},
"validvar": {
{`[a-z_]\w{0,31}\.?`, NameVariable, Pop(1)},
},
"numbers": {
{`\b[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+|\.)(E[+-]?[0-9]+)?i?\b`, LiteralNumber, nil},
},
"special": {
{`(null|missing|_all_|_automatic_|_character_|_n_|_infile_|_name_|_null_|_numeric_|_user_|_webout_)`, KeywordConstant, nil},
},
},
))

144
vendor/github.com/alecthomas/chroma/lexers/s/sass.go generated vendored Normal file

File diff suppressed because one or more lines are too long

112
vendor/github.com/alecthomas/chroma/lexers/s/scala.go generated vendored Normal file
View file

@ -0,0 +1,112 @@
package s
import (
"fmt"
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
var (
scalaOp = "[-~\\^\\*!%&\\\\<>\\|+=:/?@\xa6-\xa7\xa9\xac\xae\xb0-\xb1\xb6\xd7\xf7\u03f6\u0482\u0606-\u0608\u060e-\u060f\u06e9\u06fd-\u06fe\u07f6\u09fa\u0b70\u0bf3-\u0bf8\u0bfa\u0c7f\u0cf1-\u0cf2\u0d79\u0f01-\u0f03\u0f13-\u0f17\u0f1a-\u0f1f\u0f34\u0f36\u0f38\u0fbe-\u0fc5\u0fc7-\u0fcf\u109e-\u109f\u1360\u1390-\u1399\u1940\u19e0-\u19ff\u1b61-\u1b6a\u1b74-\u1b7c\u2044\u2052\u207a-\u207c\u208a-\u208c\u2100-\u2101\u2103-\u2106\u2108-\u2109\u2114\u2116-\u2118\u211e-\u2123\u2125\u2127\u2129\u212e\u213a-\u213b\u2140-\u2144\u214a-\u214d\u214f\u2190-\u2328\u232b-\u244a\u249c-\u24e9\u2500-\u2767\u2794-\u27c4\u27c7-\u27e5\u27f0-\u2982\u2999-\u29d7\u29dc-\u29fb\u29fe-\u2b54\u2ce5-\u2cea\u2e80-\u2ffb\u3004\u3012-\u3013\u3020\u3036-\u3037\u303e-\u303f\u3190-\u3191\u3196-\u319f\u31c0-\u31e3\u3200-\u321e\u322a-\u3250\u3260-\u327f\u328a-\u32b0\u32c0-\u33ff\u4dc0-\u4dff\ua490-\ua4c6\ua828-\ua82b\ufb29\ufdfd\ufe62\ufe64-\ufe66\uff0b\uff1c-\uff1e\uff5c\uff5e\uffe2\uffe4\uffe8-\uffee\ufffc-\ufffd]+"
scalaUpper = "[A-Z\\$_\xc0-\xd6\xd8-\xde\u0100\u0102\u0104\u0106\u0108\u010a\u010c\u010e\u0110\u0112\u0114\u0116\u0118\u011a\u011c\u011e\u0120\u0122\u0124\u0126\u0128\u012a\u012c\u012e\u0130\u0132\u0134\u0136\u0139\u013b\u013d\u013f\u0141\u0143\u0145\u0147\u014a\u014c\u014e\u0150\u0152\u0154\u0156\u0158\u015a\u015c\u015e\u0160\u0162\u0164\u0166\u0168\u016a\u016c\u016e\u0170\u0172\u0174\u0176\u0178-\u0179\u017b\u017d\u0181-\u0182\u0184\u0186-\u0187\u0189-\u018b\u018e-\u0191\u0193-\u0194\u0196-\u0198\u019c-\u019d\u019f-\u01a0\u01a2\u01a4\u01a6-\u01a7\u01a9\u01ac\u01ae-\u01af\u01b1-\u01b3\u01b5\u01b7-\u01b8\u01bc\u01c4\u01c7\u01ca\u01cd\u01cf\u01d1\u01d3\u01d5\u01d7\u01d9\u01db\u01de\u01e0\u01e2\u01e4\u01e6\u01e8\u01ea\u01ec\u01ee\u01f1\u01f4\u01f6-\u01f8\u01fa\u01fc\u01fe\u0200\u0202\u0204\u0206\u0208\u020a\u020c\u020e\u0210\u0212\u0214\u0216\u0218\u021a\u021c\u021e\u0220\u0222\u0224\u0226\u0228\u022a\u022c\u022e\u0230\u0232\u023a-\u023b\u023d-\u023e\u0241\u0243-\u0246\u0248\u024a\u024c\u024e\u0370\u0372\u0376\u0386\u0388-\u038f\u0391-\u03ab\u03cf\u03d2-\u03d4\u03d8\u03da\u03dc\u03de\u03e0\u03e2\u03e4\u03e6\u03e8\u03ea\u03ec\u03ee\u03f4\u03f7\u03f9-\u03fa\u03fd-\u042f\u0460\u0462\u0464\u0466\u0468\u046a\u046c\u046e\u0470\u0472\u0474\u0476\u0478\u047a\u047c\u047e\u0480\u048a\u048c\u048e\u0490\u0492\u0494\u0496\u0498\u049a\u049c\u049e\u04a0\u04a2\u04a4\u04a6\u04a8\u04aa\u04ac\u04ae\u04b0\u04b2\u04b4\u04b6\u04b8\u04ba\u04bc\u04be\u04c0-\u04c1\u04c3\u04c5\u04c7\u04c9\u04cb\u04cd\u04d0\u04d2\u04d4\u04d6\u04d8\u04da\u04dc\u04de\u04e0\u04e2\u04e4\u04e6\u04e8\u04ea\u04ec\u04ee\u04f0\u04f2\u04f4\u04f6\u04f8\u04fa\u04fc\u04fe\u0500\u0502\u0504\u0506\u0508\u050a\u050c\u050e\u0510\u0512\u0514\u0516\u0518\u051a\u051c\u051e\u0520\u0522\u0531-\u0556\u10a0-\u10c5\u1e00\u1e02\u1e04\u1e06\u1e08\u1e0a\u1e0c\u1e0e\u1e10\u1e12\u1e14\u1e16\u1e18\u1e1a\u1e1c\u1e1e\u1e20\u1e22\u1e24\u1e26\u1e28\u1e2a\u1e2c\u1e2e\u1e30\u1e32\u1e34\u1e36\u1e38\u1e3a\u1e3c\u1e3e\u1e40\u1e42\u1e44\u1e46\u1e48\u1e4a\u1e4c\u1e4e\u1e50\u1e52\u1e54\u1e56\u1e58\u1e5a\u1e5c\u1e5e\u1e60\u1e62\u1e64\u1e66\u1e68\u1e6a\u1e6c\u1e6e\u1e70\u1e72\u1e74\u1e76\u1e78\u1e7a\u1e7c\u1e7e\u1e80\u1e82\u1e84\u1e86\u1e88\u1e8a\u1e8c\u1e8e\u1e90\u1e92\u1e94\u1e9e\u1ea0\u1ea2\u1ea4\u1ea6\u1ea8\u1eaa\u1eac\u1eae\u1eb0\u1eb2\u1eb4\u1eb6\u1eb8\u1eba\u1ebc\u1ebe\u1ec0\u1ec2\u1ec4\u1ec6\u1ec8\u1eca\u1ecc\u1ece\u1ed0\u1ed2\u1ed4\u1ed6\u1ed8\u1eda\u1edc\u1ede\u1ee0\u1ee2\u1ee4\u1ee6\u1ee8\u1eea\u1eec\u1eee\u1ef0\u1ef2\u1ef4\u1ef6\u1ef8\u1efa\u1efc\u1efe\u1f08-\u1f0f\u1f18-\u1f1d\u1f28-\u1f2f\u1f38-\u1f3f\u1f48-\u1f4d\u1f59-\u1f5f\u1f68-\u1f6f\u1fb8-\u1fbb\u1fc8-\u1fcb\u1fd8-\u1fdb\u1fe8-\u1fec\u1ff8-\u1ffb\u2102\u2107\u210b-\u210d\u2110-\u2112\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u2130-\u2133\u213e-\u213f\u2145\u2183\u2c00-\u2c2e\u2c60\u2c62-\u2c64\u2c67\u2c69\u2c6b\u2c6d-\u2c6f\u2c72\u2c75\u2c80\u2c82\u2c84\u2c86\u2c88\u2c8a\u2c8c\u2c8e\u2c90\u2c92\u2c94\u2c96\u2c98\u2c9a\u2c9c\u2c9e\u2ca0\u2ca2\u2ca4\u2ca6\u2ca8\u2caa\u2cac\u2cae\u2cb0\u2cb2\u2cb4\u2cb6\u2cb8\u2cba\u2cbc\u2cbe\u2cc0\u2cc2\u2cc4\u2cc6\u2cc8\u2cca\u2ccc\u2cce\u2cd0\u2cd2\u2cd4\u2cd6\u2cd8\u2cda\u2cdc\u2cde\u2ce0\u2ce2\ua640\ua642\ua644\ua646\ua648\ua64a\ua64c\ua64e\ua650\ua652\ua654\ua656\ua658\ua65a\ua65c\ua65e\ua662\ua664\ua666\ua668\ua66a\ua66c\ua680\ua682\ua684\ua686\ua688\ua68a\ua68c\ua68e\ua690\ua692\ua694\ua696\ua722\ua724\ua726\ua728\ua72a\ua72c\ua72e\ua732\ua734\ua736\ua738\ua73a\ua73c\ua73e\ua740\ua742\ua744\ua746\ua748\ua74a\ua74c\ua74e\ua750\ua752\ua754\ua756\ua758\ua75a\ua75c\ua75e\ua760\ua762\ua764\ua766\ua768\ua76a\ua76c\ua76e\ua779\ua77b\ua77d-\ua77e\ua780\ua782\ua784\ua786\ua78b\uff21-\uff3a]"
scalaLetter = `[a-zA-Z\\$_ªµºÀ-ÖØ-öø-ʯͰ-ͳͶ-ͷͻ-ͽΆΈ-ϵϷ-ҁҊ-Ֆա-ևא-ײء-ؿف-يٮ-ٯٱ-ۓەۮ-ۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪऄ-हऽॐक़-ॡॲ-ॿঅ-হঽৎড়-ৡৰ-ৱਅ-ਹਖ਼-ਫ਼ੲ-ੴઅ-હઽૐ-ૡଅ-ହଽଡ଼-ୡୱஃ-ஹௐఅ-ఽౘ-ౡಅ-ಹಽೞ-ೡഅ-ഽൠ-ൡൺ-ൿඅ-ෆก-ะา-ำเ-ๅກ-ະາ-ຳຽ-ໄໜ-ༀཀ-ཬྈ-ྋက-ဪဿၐ-ၕၚ-ၝၡၥ-ၦၮ-ၰၵ-ႁႎႠ-ჺᄀ-ፚᎀ-ᎏᎠ-ᙬᙯ-ᙶᚁ-ᚚᚠ-ᛪᛮ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝰក-ឳៜᠠ-ᡂᡄ-ᢨᢪ-ᤜᥐ-ᦩᧁ-ᧇᨀ-ᨖᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮ-ᮯᰀ-ᰣᱍ-ᱏᱚ-ᱷᴀ-ᴫᵢ-ᵷᵹ-ᶚḀ-ᾼιῂ-ῌῐ-Ίῠ-Ῥῲ-ῼⁱⁿℂℇℊ--ℝℤΩℨK--ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⱼⲀ-ⳤⴀ-ⵥⶀ-ⷞ〆-〇〡-〩〸-〺〼ぁ-ゖゟァ-ヺヿ-ㆎㆠ-ㆷㇰ-ㇿ㐀-䶵一-ꀔꀖ-ꒌꔀ-ꘋꘐ-ꘟꘪ-ꙮꚀ-ꚗꜢ-ꝯꝱ-ꞇꞋ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꤊ-ꤥꤰ-ꥆꨀ-ꨨꩀ-ꩂꩄ-ꩋ가-힣豈-יִײַ-ﬨשׁ-ﴽﵐ-ﷻﹰ-ﻼA--zヲ-ッア-ンᅠ-ᅵ]`
scalaIDRest = fmt.Sprintf(`%s(?:%s|[0-9])*(?:(?<=_)%s)?`, scalaLetter, scalaLetter, scalaOp)
)
// Scala lexer.
var Scala = internal.Register(MustNewLexer(
&Config{
Name: "Scala",
Aliases: []string{"scala"},
Filenames: []string{"*.scala"},
MimeTypes: []string{"text/x-scala"},
DotAll: true,
},
Rules{
"root": {
{`(class|trait|object)(\s+)`, ByGroups(Keyword, Text), Push("class")},
{`[^\S\n]+`, Text, nil},
{`//.*?\n`, CommentSingle, nil},
{`/\*`, CommentMultiline, Push("comment")},
{`@` + scalaIDRest, NameDecorator, nil},
{`(abstract|ca(?:se|tch)|d(?:ef|o)|e(?:lse|xtends)|f(?:inal(?:ly)?|or(?:Some)?)|i(?:f|mplicit)|lazy|match|new|override|pr(?:ivate|otected)|re(?:quires|turn)|s(?:ealed|uper)|t(?:h(?:is|row)|ry)|va[lr]|w(?:hile|ith)|yield)\b|(<[%:-]|=>|>:|[#=@_⇒←])(\b|(?=\s)|$)`, Keyword, nil},
{`:(?!` + scalaOp + `%s)`, Keyword, Push("type")},
{fmt.Sprintf("%s%s\\b", scalaUpper, scalaIDRest), NameClass, nil},
{`(true|false|null)\b`, KeywordConstant, nil},
{`(import|package)(\s+)`, ByGroups(Keyword, Text), Push("import")},
{`(type)(\s+)`, ByGroups(Keyword, Text), Push("type")},
{`""".*?"""(?!")`, LiteralString, nil},
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
{`'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'`, LiteralStringChar, nil},
{"'" + scalaIDRest, TextSymbol, nil},
{`[fs]"""`, LiteralString, Push("interptriplestring")},
{`[fs]"`, LiteralString, Push("interpstring")},
{`raw"(\\\\|\\"|[^"])*"`, LiteralString, nil},
{scalaIDRest, Name, nil},
{"`[^`]+`", Name, nil},
{`\[`, Operator, Push("typeparam")},
{`[(){};,.#]`, Operator, nil},
{scalaOp, Operator, nil},
{`([0-9][0-9]*\.[0-9]*|\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?`, LiteralNumberFloat, nil},
{`0x[0-9a-fA-F]+`, LiteralNumberHex, nil},
{`[0-9]+L?`, LiteralNumberInteger, nil},
{`\n`, Text, nil},
},
"class": {
{fmt.Sprintf("(%s|%s|`[^`]+`)(\\s*)(\\[)", scalaIDRest, scalaOp), ByGroups(NameClass, Text, Operator), Push("typeparam")},
{`\s+`, Text, nil},
{`\{`, Operator, Pop(1)},
{`\(`, Operator, Pop(1)},
{`//.*?\n`, CommentSingle, Pop(1)},
{fmt.Sprintf("%s|%s|`[^`]+`", scalaIDRest, scalaOp), NameClass, Pop(1)},
},
"type": {
{`\s+`, Text, nil},
{`<[%:]|>:|[#_]|forSome|type`, Keyword, nil},
{`([,);}]|=>|=|⇒)(\s*)`, ByGroups(Operator, Text), Pop(1)},
{`[({]`, Operator, Push()},
{fmt.Sprintf("((?:%s|%s|`[^`]+`)(?:\\.(?:%s|%s|`[^`]+`))*)(\\s*)(\\[)", scalaIDRest, scalaOp, scalaIDRest, scalaOp), ByGroups(KeywordType, Text, Operator), Push("#pop", "typeparam")},
{fmt.Sprintf("((?:%s|%s|`[^`]+`)(?:\\.(?:%s|%s|`[^`]+`))*)(\\s*)$", scalaIDRest, scalaOp, scalaIDRest, scalaOp), ByGroups(KeywordType, Text), Pop(1)},
{`//.*?\n`, CommentSingle, Pop(1)},
{fmt.Sprintf("\\.|%s|%s|`[^`]+`", scalaIDRest, scalaOp), KeywordType, nil},
},
"typeparam": {
{`[\s,]+`, Text, nil},
{`<[%:]|=>|>:|[#_⇒]|forSome|type`, Keyword, nil},
{`([\])}])`, Operator, Pop(1)},
{`[(\[{]`, Operator, Push()},
{fmt.Sprintf("\\.|%s|%s|`[^`]+`", scalaIDRest, scalaOp), KeywordType, nil},
},
"comment": {
{`[^/*]+`, CommentMultiline, nil},
{`/\*`, CommentMultiline, Push()},
{`\*/`, CommentMultiline, Pop(1)},
{`[*/]`, CommentMultiline, nil},
},
"import": {
{fmt.Sprintf("(%s|\\.)+", scalaIDRest), NameNamespace, Pop(1)},
},
"interpstringcommon": {
{`[^"$\\]+`, LiteralString, nil},
{`\$\$`, LiteralString, nil},
{`\$` + scalaLetter + `(?:` + scalaLetter + `|\d)*`, LiteralStringInterpol, nil},
{`\$\{`, LiteralStringInterpol, Push("interpbrace")},
{`\\.`, LiteralString, nil},
},
"interptriplestring": {
{`"""(?!")`, LiteralString, Pop(1)},
{`"`, LiteralString, nil},
Include("interpstringcommon"),
},
"interpstring": {
{`"`, LiteralString, Pop(1)},
Include("interpstringcommon"),
},
"interpbrace": {
{`\}`, LiteralStringInterpol, Pop(1)},
{`\{`, LiteralStringInterpol, Push()},
Include("root"),
},
},
))

53
vendor/github.com/alecthomas/chroma/lexers/s/scheme.go generated vendored Normal file
View file

@ -0,0 +1,53 @@
package s
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// nolint
// Scheme lexer.
var SchemeLang = internal.Register(MustNewLexer(
&Config{
Name: "Scheme",
Aliases: []string{"scheme", "scm"},
Filenames: []string{"*.scm", "*.ss"},
MimeTypes: []string{"text/x-scheme", "application/x-scheme"},
},
Rules{
"root": {
{`;.*$`, CommentSingle, nil},
{`#\|`, CommentMultiline, Push("multiline-comment")},
{`#;\s*\(`, Comment, Push("commented-form")},
{`#!r6rs`, Comment, nil},
{`\s+`, Text, nil},
{`-?\d+\.\d+`, LiteralNumberFloat, nil},
{`-?\d+`, LiteralNumberInteger, nil},
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
{`'[\w!$%&*+,/:<=>?@^~|-]+`, LiteralStringSymbol, nil},
{`#\\([()/'\"._!§$%& ?=+-]|[a-zA-Z0-9]+)`, LiteralStringChar, nil},
{`(#t|#f)`, NameConstant, nil},
{"('|#|`|,@|,|\\.)", Operator, nil},
{`(lambda |define |if |else |cond |and |or |case |let |let\* |letrec |begin |do |delay |set\! |\=\> |quote |quasiquote |unquote |unquote\-splicing |define\-syntax |let\-syntax |letrec\-syntax |syntax\-rules )`, Keyword, nil},
{`(?<='\()[\w!$%&*+,/:<=>?@^~|-]+`, NameVariable, nil},
{`(?<=#\()[\w!$%&*+,/:<=>?@^~|-]+`, NameVariable, nil},
{`(?<=\()(\* |\+ |\- |\/ |\< |\<\= |\= |\> |\>\= |abs |acos |angle |append |apply |asin |assoc |assq |assv |atan |boolean\? |caaaar |caaadr |caaar |caadar |caaddr |caadr |caar |cadaar |cadadr |cadar |caddar |cadddr |caddr |cadr |call\-with\-current\-continuation |call\-with\-input\-file |call\-with\-output\-file |call\-with\-values |call\/cc |car |cdaaar |cdaadr |cdaar |cdadar |cdaddr |cdadr |cdar |cddaar |cddadr |cddar |cdddar |cddddr |cdddr |cddr |cdr |ceiling |char\-\>integer |char\-alphabetic\? |char\-ci\<\=\? |char\-ci\<\? |char\-ci\=\? |char\-ci\>\=\? |char\-ci\>\? |char\-downcase |char\-lower\-case\? |char\-numeric\? |char\-ready\? |char\-upcase |char\-upper\-case\? |char\-whitespace\? |char\<\=\? |char\<\? |char\=\? |char\>\=\? |char\>\? |char\? |close\-input\-port |close\-output\-port |complex\? |cons |cos |current\-input\-port |current\-output\-port |denominator |display |dynamic\-wind |eof\-object\? |eq\? |equal\? |eqv\? |eval |even\? |exact\-\>inexact |exact\? |exp |expt |floor |for\-each |force |gcd |imag\-part |inexact\-\>exact |inexact\? |input\-port\? |integer\-\>char |integer\? |interaction\-environment |lcm |length |list |list\-\>string |list\-\>vector |list\-ref |list\-tail |list\? |load |log |magnitude |make\-polar |make\-rectangular |make\-string |make\-vector |map |max |member |memq |memv |min |modulo |negative\? |newline |not |null\-environment |null\? |number\-\>string |number\? |numerator |odd\? |open\-input\-file |open\-output\-file |output\-port\? |pair\? |peek\-char |port\? |positive\? |procedure\? |quotient |rational\? |rationalize |read |read\-char |real\-part |real\? |remainder |reverse |round |scheme\-report\-environment |set\-car\! |set\-cdr\! |sin |sqrt |string |string\-\>list |string\-\>number |string\-\>symbol |string\-append |string\-ci\<\=\? |string\-ci\<\? |string\-ci\=\? |string\-ci\>\=\? |string\-ci\>\? |string\-copy |string\-fill\! |string\-length |string\-ref |string\-set\! |string\<\=\? |string\<\? |string\=\? |string\>\=\? |string\>\? |string\? |substring |symbol\-\>string |symbol\? |tan |transcript\-off |transcript\-on |truncate |values |vector |vector\-\>list |vector\-fill\! |vector\-length |vector\-ref |vector\-set\! |vector\? |with\-input\-from\-file |with\-output\-to\-file |write |write\-char |zero\? )`, NameBuiltin, nil},
{`(?<=\()[\w!$%&*+,/:<=>?@^~|-]+`, NameFunction, nil},
{`[\w!$%&*+,/:<=>?@^~|-]+`, NameVariable, nil},
{`(\(|\))`, Punctuation, nil},
{`(\[|\])`, Punctuation, nil},
},
"multiline-comment": {
{`#\|`, CommentMultiline, Push()},
{`\|#`, CommentMultiline, Pop(1)},
{`[^|#]+`, CommentMultiline, nil},
{`[|#]`, CommentMultiline, nil},
},
"commented-form": {
{`\(`, Comment, Push()},
{`\)`, Comment, Pop(1)},
{`[^()]+`, Comment, nil},
},
},
))

44
vendor/github.com/alecthomas/chroma/lexers/s/scilab.go generated vendored Normal file

File diff suppressed because one or more lines are too long

124
vendor/github.com/alecthomas/chroma/lexers/s/scss.go generated vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,99 @@
package s
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Smalltalk lexer.
var Smalltalk = internal.Register(MustNewLexer(
&Config{
Name: "Smalltalk",
Aliases: []string{"smalltalk", "squeak", "st"},
Filenames: []string{"*.st"},
MimeTypes: []string{"text/x-smalltalk"},
},
Rules{
"root": {
{`(<)(\w+:)(.*?)(>)`, ByGroups(Text, Keyword, Text, Text), nil},
Include("squeak fileout"),
Include("whitespaces"),
Include("method definition"),
{`(\|)([\w\s]*)(\|)`, ByGroups(Operator, NameVariable, Operator), nil},
Include("objects"),
{`\^|:=|_`, Operator, nil},
{`[\]({}.;!]`, Text, nil},
},
"method definition": {
{`([a-zA-Z]+\w*:)(\s*)(\w+)`, ByGroups(NameFunction, Text, NameVariable), nil},
{`^(\b[a-zA-Z]+\w*\b)(\s*)$`, ByGroups(NameFunction, Text), nil},
{`^([-+*/\\~<>=|&!?,@%]+)(\s*)(\w+)(\s*)$`, ByGroups(NameFunction, Text, NameVariable, Text), nil},
},
"blockvariables": {
Include("whitespaces"),
{`(:)(\s*)(\w+)`, ByGroups(Operator, Text, NameVariable), nil},
{`\|`, Operator, Pop(1)},
Default(Pop(1)),
},
"literals": {
{`'(''|[^'])*'`, LiteralString, Push("afterobject")},
{`\$.`, LiteralStringChar, Push("afterobject")},
{`#\(`, LiteralStringSymbol, Push("parenth")},
{`\)`, Text, Push("afterobject")},
{`(\d+r)?-?\d+(\.\d+)?(e-?\d+)?`, LiteralNumber, Push("afterobject")},
},
"_parenth_helper": {
Include("whitespaces"),
{`(\d+r)?-?\d+(\.\d+)?(e-?\d+)?`, LiteralNumber, nil},
{`[-+*/\\~<>=|&#!?,@%\w:]+`, LiteralStringSymbol, nil},
{`'(''|[^'])*'`, LiteralString, nil},
{`\$.`, LiteralStringChar, nil},
{`#*\(`, LiteralStringSymbol, Push("inner_parenth")},
},
"parenth": {
{`\)`, LiteralStringSymbol, Push("root", "afterobject")},
Include("_parenth_helper"),
},
"inner_parenth": {
{`\)`, LiteralStringSymbol, Pop(1)},
Include("_parenth_helper"),
},
"whitespaces": {
{`\s+`, Text, nil},
{`"(""|[^"])*"`, Comment, nil},
},
"objects": {
{`\[`, Text, Push("blockvariables")},
{`\]`, Text, Push("afterobject")},
{`\b(self|super|true|false|nil|thisContext)\b`, NameBuiltinPseudo, Push("afterobject")},
{`\b[A-Z]\w*(?!:)\b`, NameClass, Push("afterobject")},
{`\b[a-z]\w*(?!:)\b`, NameVariable, Push("afterobject")},
{`#("(""|[^"])*"|[-+*/\\~<>=|&!?,@%]+|[\w:]+)`, LiteralStringSymbol, Push("afterobject")},
Include("literals"),
},
"afterobject": {
{`! !$`, Keyword, Pop(1)},
Include("whitespaces"),
{`\b(ifTrue:|ifFalse:|whileTrue:|whileFalse:|timesRepeat:)`, NameBuiltin, Pop(1)},
{`\b(new\b(?!:))`, NameBuiltin, nil},
{`:=|_`, Operator, Pop(1)},
{`\b[a-zA-Z]+\w*:`, NameFunction, Pop(1)},
{`\b[a-zA-Z]+\w*`, NameFunction, nil},
{`\w+:?|[-+*/\\~<>=|&!?,@%]+`, NameFunction, Pop(1)},
{`\.`, Punctuation, Pop(1)},
{`;`, Punctuation, nil},
{`[\])}]`, Text, nil},
{`[\[({]`, Text, Pop(1)},
},
"squeak fileout": {
{`^"(""|[^"])*"!`, Keyword, nil},
{`^'(''|[^'])*'!`, Keyword, nil},
{`^(!)(\w+)( commentStamp: )(.*?)( prior: .*?!\n)(.*?)(!)`, ByGroups(Keyword, NameClass, Keyword, LiteralString, Keyword, Text, Keyword), nil},
{`^(!)(\w+(?: class)?)( methodsFor: )('(?:''|[^'])*')(.*?!)`, ByGroups(Keyword, NameClass, Keyword, LiteralString, Keyword), nil},
{`^(\w+)( subclass: )(#\w+)(\s+instanceVariableNames: )(.*?)(\s+classVariableNames: )(.*?)(\s+poolDictionaries: )(.*?)(\s+category: )(.*?)(!)`, ByGroups(NameClass, Keyword, LiteralStringSymbol, Keyword, LiteralString, Keyword, LiteralString, Keyword, LiteralString, Keyword, LiteralString, Keyword), nil},
{`^(\w+(?: class)?)(\s+instanceVariableNames: )(.*?)(!)`, ByGroups(NameClass, Keyword, LiteralString, Keyword), nil},
{`(!\n)(\].*)(! !)$`, ByGroups(Keyword, Text, Keyword), nil},
{`! !$`, Keyword, nil},
},
},
))

40
vendor/github.com/alecthomas/chroma/lexers/s/smarty.go generated vendored Normal file
View file

@ -0,0 +1,40 @@
package s
import (
. "github.com/alecthomas/chroma" // nolint
. "github.com/alecthomas/chroma/lexers/circular" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Smarty lexer.
var Smarty = internal.Register(MustNewLexer(
&Config{
Name: "Smarty",
Aliases: []string{"smarty"},
Filenames: []string{"*.tpl"},
MimeTypes: []string{"application/x-smarty"},
DotAll: true,
},
Rules{
"root": {
{`[^{]+`, Other, nil},
{`(\{)(\*.*?\*)(\})`, ByGroups(CommentPreproc, Comment, CommentPreproc), nil},
{`(\{php\})(.*?)(\{/php\})`, ByGroups(CommentPreproc, Using(PHP), CommentPreproc), nil},
{`(\{)(/?[a-zA-Z_]\w*)(\s*)`, ByGroups(CommentPreproc, NameFunction, Text), Push("smarty")},
{`\{`, CommentPreproc, Push("smarty")},
},
"smarty": {
{`\s+`, Text, nil},
{`\{`, CommentPreproc, Push()},
{`\}`, CommentPreproc, Pop(1)},
{`#[a-zA-Z_]\w*#`, NameVariable, nil},
{`\$[a-zA-Z_]\w*(\.\w+)*`, NameVariable, nil},
{`[~!%^&*()+=|\[\]:;,.<>/?@-]`, Operator, nil},
{`(true|false|null)\b`, KeywordConstant, nil},
{`[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?`, LiteralNumber, nil},
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
{`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
{`[a-zA-Z_]\w*`, NameAttribute, nil},
},
},
))

200
vendor/github.com/alecthomas/chroma/lexers/s/sml.go generated vendored Normal file
View file

@ -0,0 +1,200 @@
package s
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Standard ML lexer.
var StandardML = internal.Register(MustNewLexer(
&Config{
Name: "Standard ML",
Aliases: []string{"sml"},
Filenames: []string{"*.sml", "*.sig", "*.fun"},
MimeTypes: []string{"text/x-standardml", "application/x-standardml"},
},
Rules{
"whitespace": {
{`\s+`, Text, nil},
{`\(\*`, CommentMultiline, Push("comment")},
},
"delimiters": {
{`\(|\[|\{`, Punctuation, Push("main")},
{`\)|\]|\}`, Punctuation, Pop(1)},
{`\b(let|if|local)\b(?!\')`, KeywordReserved, Push("main", "main")},
{`\b(struct|sig|while)\b(?!\')`, KeywordReserved, Push("main")},
{`\b(do|else|end|in|then)\b(?!\')`, KeywordReserved, Pop(1)},
},
"core": {
{`(_|\}|\{|\)|;|,|\[|\(|\]|\.\.\.)`, Punctuation, nil},
{`#"`, LiteralStringChar, Push("char")},
{`"`, LiteralStringDouble, Push("string")},
{`~?0x[0-9a-fA-F]+`, LiteralNumberHex, nil},
{`0wx[0-9a-fA-F]+`, LiteralNumberHex, nil},
{`0w\d+`, LiteralNumberInteger, nil},
{`~?\d+\.\d+[eE]~?\d+`, LiteralNumberFloat, nil},
{`~?\d+\.\d+`, LiteralNumberFloat, nil},
{`~?\d+[eE]~?\d+`, LiteralNumberFloat, nil},
{`~?\d+`, LiteralNumberInteger, nil},
{`#\s*[1-9][0-9]*`, NameLabel, nil},
{`#\s*([a-zA-Z][\w']*)`, NameLabel, nil},
{"#\\s+([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameLabel, nil},
{`\b(datatype|abstype)\b(?!\')`, KeywordReserved, Push("dname")},
{`(?=\b(exception)\b(?!\'))`, Text, Push("ename")},
{`\b(functor|include|open|signature|structure)\b(?!\')`, KeywordReserved, Push("sname")},
{`\b(type|eqtype)\b(?!\')`, KeywordReserved, Push("tname")},
{`\'[\w\']*`, NameDecorator, nil},
{`([a-zA-Z][\w']*)(\.)`, NameNamespace, Push("dotted")},
{`\b(abstype|and|andalso|as|case|datatype|do|else|end|exception|fn|fun|handle|if|in|infix|infixr|let|local|nonfix|of|op|open|orelse|raise|rec|then|type|val|with|withtype|while|eqtype|functor|include|sharing|sig|signature|struct|structure|where)\b`, KeywordReserved, nil},
{`([a-zA-Z][\w']*)`, Name, nil},
{`\b(:|\|,=|=>|->|#|:>)\b`, KeywordReserved, nil},
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Name, nil},
},
"dotted": {
{`([a-zA-Z][\w']*)(\.)`, NameNamespace, nil},
// ignoring reserved words
{`([a-zA-Z][\w']*)`, Name, Pop(1)},
// ignoring reserved words
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Name, Pop(1)},
{`\s+`, Error, nil},
{`\S+`, Error, nil},
},
"root": {
Default(Push("main")),
},
"main": {
Include("whitespace"),
{`\b(val|and)\b(?!\')`, KeywordReserved, Push("vname")},
{`\b(fun)\b(?!\')`, KeywordReserved, Push("#pop", "main-fun", "fname")},
Include("delimiters"),
Include("core"),
{`\S+`, Error, nil},
},
"main-fun": {
Include("whitespace"),
{`\s`, Text, nil},
{`\(\*`, CommentMultiline, Push("comment")},
{`\b(fun|and)\b(?!\')`, KeywordReserved, Push("fname")},
{`\b(val)\b(?!\')`, KeywordReserved, Push("#pop", "main", "vname")},
{`\|`, Punctuation, Push("fname")},
{`\b(case|handle)\b(?!\')`, KeywordReserved, Push("#pop", "main")},
Include("delimiters"),
Include("core"),
{`\S+`, Error, nil},
},
"char": {
{`[^"\\]`, LiteralStringChar, nil},
{`\\[\\"abtnvfr]`, LiteralStringEscape, nil},
{`\\\^[\x40-\x5e]`, LiteralStringEscape, nil},
{`\\[0-9]{3}`, LiteralStringEscape, nil},
{`\\u[0-9a-fA-F]{4}`, LiteralStringEscape, nil},
{`\\\s+\\`, LiteralStringInterpol, nil},
{`"`, LiteralStringChar, Pop(1)},
},
"string": {
{`[^"\\]`, LiteralStringDouble, nil},
{`\\[\\"abtnvfr]`, LiteralStringEscape, nil},
{`\\\^[\x40-\x5e]`, LiteralStringEscape, nil},
{`\\[0-9]{3}`, LiteralStringEscape, nil},
{`\\u[0-9a-fA-F]{4}`, LiteralStringEscape, nil},
{`\\\s+\\`, LiteralStringInterpol, nil},
{`"`, LiteralStringDouble, Pop(1)},
},
"breakout": {
{`(?=\b(where|do|handle|if|sig|op|while|case|as|else|signature|andalso|struct|infixr|functor|in|structure|then|local|rec|end|fun|of|orelse|val|include|fn|with|exception|let|and|infix|sharing|datatype|type|abstype|withtype|eqtype|nonfix|raise|open)\b(?!\'))`, Text, Pop(1)},
},
"sname": {
Include("whitespace"),
Include("breakout"),
{`([a-zA-Z][\w']*)`, NameNamespace, nil},
Default(Pop(1)),
},
"fname": {
Include("whitespace"),
{`\'[\w\']*`, NameDecorator, nil},
{`\(`, Punctuation, Push("tyvarseq")},
{`([a-zA-Z][\w']*)`, NameFunction, Pop(1)},
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameFunction, Pop(1)},
Default(Pop(1)),
},
"vname": {
Include("whitespace"),
{`\'[\w\']*`, NameDecorator, nil},
{`\(`, Punctuation, Push("tyvarseq")},
{"([a-zA-Z][\\w']*)(\\s*)(=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+))", ByGroups(NameVariable, Text, Punctuation), Pop(1)},
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)(\\s*)(=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+))", ByGroups(NameVariable, Text, Punctuation), Pop(1)},
{`([a-zA-Z][\w']*)`, NameVariable, Pop(1)},
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameVariable, Pop(1)},
Default(Pop(1)),
},
"tname": {
Include("whitespace"),
Include("breakout"),
{`\'[\w\']*`, NameDecorator, nil},
{`\(`, Punctuation, Push("tyvarseq")},
{"=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Punctuation, Push("#pop", "typbind")},
{`([a-zA-Z][\w']*)`, KeywordType, nil},
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", KeywordType, nil},
{`\S+`, Error, Pop(1)},
},
"typbind": {
Include("whitespace"),
{`\b(and)\b(?!\')`, KeywordReserved, Push("#pop", "tname")},
Include("breakout"),
Include("core"),
{`\S+`, Error, Pop(1)},
},
"dname": {
Include("whitespace"),
Include("breakout"),
{`\'[\w\']*`, NameDecorator, nil},
{`\(`, Punctuation, Push("tyvarseq")},
{`(=)(\s*)(datatype)`, ByGroups(Punctuation, Text, KeywordReserved), Pop(1)},
{"=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Punctuation, Push("#pop", "datbind", "datcon")},
{`([a-zA-Z][\w']*)`, KeywordType, nil},
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", KeywordType, nil},
{`\S+`, Error, Pop(1)},
},
"datbind": {
Include("whitespace"),
{`\b(and)\b(?!\')`, KeywordReserved, Push("#pop", "dname")},
{`\b(withtype)\b(?!\')`, KeywordReserved, Push("#pop", "tname")},
{`\b(of)\b(?!\')`, KeywordReserved, nil},
{`(\|)(\s*)([a-zA-Z][\w']*)`, ByGroups(Punctuation, Text, NameClass), nil},
{"(\\|)(\\s+)([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", ByGroups(Punctuation, Text, NameClass), nil},
Include("breakout"),
Include("core"),
{`\S+`, Error, nil},
},
"ename": {
Include("whitespace"),
{`(exception|and)\b(\s+)([a-zA-Z][\w']*)`, ByGroups(KeywordReserved, Text, NameClass), nil},
{"(exception|and)\\b(\\s*)([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", ByGroups(KeywordReserved, Text, NameClass), nil},
{`\b(of)\b(?!\')`, KeywordReserved, nil},
Include("breakout"),
Include("core"),
{`\S+`, Error, nil},
},
"datcon": {
Include("whitespace"),
{`([a-zA-Z][\w']*)`, NameClass, Pop(1)},
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameClass, Pop(1)},
{`\S+`, Error, Pop(1)},
},
"tyvarseq": {
{`\s`, Text, nil},
{`\(\*`, CommentMultiline, Push("comment")},
{`\'[\w\']*`, NameDecorator, nil},
{`[a-zA-Z][\w']*`, Name, nil},
{`,`, Punctuation, nil},
{`\)`, Punctuation, Pop(1)},
{"[!%&$#+\\-/:<=>?@\\\\~`^|*]+", Name, nil},
},
"comment": {
{`[^(*)]`, CommentMultiline, nil},
{`\(\*`, CommentMultiline, Push()},
{`\*\)`, CommentMultiline, Pop(1)},
{`[(*)]`, CommentMultiline, nil},
},
},
))

48
vendor/github.com/alecthomas/chroma/lexers/s/snobol.go generated vendored Normal file
View file

@ -0,0 +1,48 @@
package s
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Snobol lexer.
var Snobol = internal.Register(MustNewLexer(
&Config{
Name: "Snobol",
Aliases: []string{"snobol"},
Filenames: []string{"*.snobol"},
MimeTypes: []string{"text/x-snobol"},
},
Rules{
"root": {
{`\*.*\n`, Comment, nil},
{`[+.] `, Punctuation, Push("statement")},
{`-.*\n`, Comment, nil},
{`END\s*\n`, NameLabel, Push("heredoc")},
{`[A-Za-z$][\w$]*`, NameLabel, Push("statement")},
{`\s+`, Text, Push("statement")},
},
"statement": {
{`\s*\n`, Text, Pop(1)},
{`\s+`, Text, nil},
{`(?<=[^\w.])(LT|LE|EQ|NE|GE|GT|INTEGER|IDENT|DIFFER|LGT|SIZE|REPLACE|TRIM|DUPL|REMDR|DATE|TIME|EVAL|APPLY|OPSYN|LOAD|UNLOAD|LEN|SPAN|BREAK|ANY|NOTANY|TAB|RTAB|REM|POS|RPOS|FAIL|FENCE|ABORT|ARB|ARBNO|BAL|SUCCEED|INPUT|OUTPUT|TERMINAL)(?=[^\w.])`, NameBuiltin, nil},
{`[A-Za-z][\w.]*`, Name, nil},
{`\*\*|[?$.!%*/#+\-@|&\\=]`, Operator, nil},
{`"[^"]*"`, LiteralString, nil},
{`'[^']*'`, LiteralString, nil},
{`[0-9]+(?=[^.EeDd])`, LiteralNumberInteger, nil},
{`[0-9]+(\.[0-9]*)?([EDed][-+]?[0-9]+)?`, LiteralNumberFloat, nil},
{`:`, Punctuation, Push("goto")},
{`[()<>,;]`, Punctuation, nil},
},
"goto": {
{`\s*\n`, Text, Pop(2)},
{`\s+`, Text, nil},
{`F|S`, Keyword, nil},
{`(\()([A-Za-z][\w.]*)(\))`, ByGroups(Punctuation, NameLabel, Punctuation), nil},
},
"heredoc": {
{`.*\n`, LiteralStringHeredoc, nil},
},
},
))

File diff suppressed because one or more lines are too long

69
vendor/github.com/alecthomas/chroma/lexers/s/sparql.go generated vendored Normal file
View file

@ -0,0 +1,69 @@
package s
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Sparql lexer.
var Sparql = internal.Register(MustNewLexer(
&Config{
Name: "SPARQL",
Aliases: []string{"sparql"},
Filenames: []string{"*.rq", "*.sparql"},
MimeTypes: []string{"application/sparql-query"},
},
Rules{
"root": {
{`\s+`, Text, nil},
{`((?i)select|construct|describe|ask|where|filter|group\s+by|minus|distinct|reduced|from\s+named|from|order\s+by|desc|asc|limit|offset|bindings|load|clear|drop|create|add|move|copy|insert\s+data|delete\s+data|delete\s+where|delete|insert|using\s+named|using|graph|default|named|all|optional|service|silent|bind|union|not\s+in|in|as|having|to|prefix|base)\b`, Keyword, nil},
{`(a)\b`, Keyword, nil},
{"(<(?:[^<>\"{}|^`\\\\\\x00-\\x20])*>)", NameLabel, nil},
{`(_:[0-9a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_](?:[a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_\-0-9·̀-ͯ‿-⁀.]*[a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_\-0-9·̀-ͯ‿-⁀])?)`, NameLabel, nil},
{`[?$][0-9a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_][a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_0-9·̀-ͯ‿-⁀]*`, NameVariable, nil},
{`([a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>](?:[a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_\-0-9·̀-ͯ‿-⁀.]*[a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_\-0-9·̀-ͯ‿-⁀])?)?(\:)((?:[a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_:0-9]|(?:%[0-9A-Fa-f][0-9A-Fa-f])|(?:\\[ _~.\-!$&"()*+,;=/?#@%]))(?:(?:[a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_\-0-9·̀-ͯ‿-⁀.:]|(?:%[0-9A-Fa-f][0-9A-Fa-f])|(?:\\[ _~.\-!$&"()*+,;=/?#@%]))*(?:[a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_\-0-9·̀-ͯ‿-⁀:]|(?:%[0-9A-Fa-f][0-9A-Fa-f])|(?:\\[ _~.\-!$&"()*+,;=/?#@%])))?)?`, ByGroups(NameNamespace, Punctuation, NameTag), nil},
{`((?i)str|lang|langmatches|datatype|bound|iri|uri|bnode|rand|abs|ceil|floor|round|concat|strlen|ucase|lcase|encode_for_uri|contains|strstarts|strends|strbefore|strafter|year|month|day|hours|minutes|seconds|timezone|tz|now|md5|sha1|sha256|sha384|sha512|coalesce|if|strlang|strdt|sameterm|isiri|isuri|isblank|isliteral|isnumeric|regex|substr|replace|exists|not\s+exists|count|sum|min|max|avg|sample|group_concat|separator)\b`, NameFunction, nil},
{`(true|false)`, KeywordConstant, nil},
{`[+\-]?(\d+\.\d*[eE][+-]?\d+|\.?\d+[eE][+-]?\d+)`, LiteralNumberFloat, nil},
{`[+\-]?(\d+\.\d*|\.\d+)`, LiteralNumberFloat, nil},
{`[+\-]?\d+`, LiteralNumberInteger, nil},
{`(\|\||&&|=|\*|\-|\+|/|!=|<=|>=|!|<|>)`, Operator, nil},
{`[(){}.;,:^\[\]]`, Punctuation, nil},
{`#[^\n]*`, Comment, nil},
{`"""`, LiteralString, Push("triple-double-quoted-string")},
{`"`, LiteralString, Push("single-double-quoted-string")},
{`'''`, LiteralString, Push("triple-single-quoted-string")},
{`'`, LiteralString, Push("single-single-quoted-string")},
},
"triple-double-quoted-string": {
{`"""`, LiteralString, Push("end-of-string")},
{`[^\\]+`, LiteralString, nil},
{`\\`, LiteralString, Push("string-escape")},
},
"single-double-quoted-string": {
{`"`, LiteralString, Push("end-of-string")},
{`[^"\\\n]+`, LiteralString, nil},
{`\\`, LiteralString, Push("string-escape")},
},
"triple-single-quoted-string": {
{`'''`, LiteralString, Push("end-of-string")},
{`[^\\]+`, LiteralString, nil},
{`\\`, LiteralStringEscape, Push("string-escape")},
},
"single-single-quoted-string": {
{`'`, LiteralString, Push("end-of-string")},
{`[^'\\\n]+`, LiteralString, nil},
{`\\`, LiteralString, Push("string-escape")},
},
"string-escape": {
{`u[0-9A-Fa-f]{4}`, LiteralStringEscape, Pop(1)},
{`U[0-9A-Fa-f]{8}`, LiteralStringEscape, Pop(1)},
{`.`, LiteralStringEscape, Pop(1)},
},
"end-of-string": {
{`(@)([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)`, ByGroups(Operator, NameFunction), Pop(2)},
{`\^\^`, Operator, Pop(2)},
Default(Pop(2)),
},
},
))

49
vendor/github.com/alecthomas/chroma/lexers/s/sql.go generated vendored Normal file

File diff suppressed because one or more lines are too long

38
vendor/github.com/alecthomas/chroma/lexers/s/squid.go generated vendored Normal file
View file

@ -0,0 +1,38 @@
package s
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Squidconf lexer.
var Squidconf = internal.Register(MustNewLexer(
&Config{
Name: "SquidConf",
Aliases: []string{"squidconf", "squid.conf", "squid"},
Filenames: []string{"squid.conf"},
MimeTypes: []string{"text/x-squidconf"},
NotMultiline: true,
CaseInsensitive: true,
},
Rules{
"root": {
{`\s+`, TextWhitespace, nil},
{`#`, Comment, Push("comment")},
{Words(`\b`, `\b`, `access_log`, `acl`, `always_direct`, `announce_host`, `announce_period`, `announce_port`, `announce_to`, `anonymize_headers`, `append_domain`, `as_whois_server`, `auth_param_basic`, `authenticate_children`, `authenticate_program`, `authenticate_ttl`, `broken_posts`, `buffered_logs`, `cache_access_log`, `cache_announce`, `cache_dir`, `cache_dns_program`, `cache_effective_group`, `cache_effective_user`, `cache_host`, `cache_host_acl`, `cache_host_domain`, `cache_log`, `cache_mem`, `cache_mem_high`, `cache_mem_low`, `cache_mgr`, `cachemgr_passwd`, `cache_peer`, `cache_peer_access`, `cahce_replacement_policy`, `cache_stoplist`, `cache_stoplist_pattern`, `cache_store_log`, `cache_swap`, `cache_swap_high`, `cache_swap_log`, `cache_swap_low`, `client_db`, `client_lifetime`, `client_netmask`, `connect_timeout`, `coredump_dir`, `dead_peer_timeout`, `debug_options`, `delay_access`, `delay_class`, `delay_initial_bucket_level`, `delay_parameters`, `delay_pools`, `deny_info`, `dns_children`, `dns_defnames`, `dns_nameservers`, `dns_testnames`, `emulate_httpd_log`, `err_html_text`, `fake_user_agent`, `firewall_ip`, `forwarded_for`, `forward_snmpd_port`, `fqdncache_size`, `ftpget_options`, `ftpget_program`, `ftp_list_width`, `ftp_passive`, `ftp_user`, `half_closed_clients`, `header_access`, `header_replace`, `hierarchy_stoplist`, `high_response_time_warning`, `high_page_fault_warning`, `hosts_file`, `htcp_port`, `http_access`, `http_anonymizer`, `httpd_accel`, `httpd_accel_host`, `httpd_accel_port`, `httpd_accel_uses_host_header`, `httpd_accel_with_proxy`, `http_port`, `http_reply_access`, `icp_access`, `icp_hit_stale`, `icp_port`, `icp_query_timeout`, `ident_lookup`, `ident_lookup_access`, `ident_timeout`, `incoming_http_average`, `incoming_icp_average`, `inside_firewall`, `ipcache_high`, `ipcache_low`, `ipcache_size`, `local_domain`, `local_ip`, `logfile_rotate`, `log_fqdn`, `log_icp_queries`, `log_mime_hdrs`, `maximum_object_size`, `maximum_single_addr_tries`, `mcast_groups`, `mcast_icp_query_timeout`, `mcast_miss_addr`, `mcast_miss_encode_key`, `mcast_miss_port`, `memory_pools`, `memory_pools_limit`, `memory_replacement_policy`, `mime_table`, `min_http_poll_cnt`, `min_icp_poll_cnt`, `minimum_direct_hops`, `minimum_object_size`, `minimum_retry_timeout`, `miss_access`, `negative_dns_ttl`, `negative_ttl`, `neighbor_timeout`, `neighbor_type_domain`, `netdb_high`, `netdb_low`, `netdb_ping_period`, `netdb_ping_rate`, `never_direct`, `no_cache`, `passthrough_proxy`, `pconn_timeout`, `pid_filename`, `pinger_program`, `positive_dns_ttl`, `prefer_direct`, `proxy_auth`, `proxy_auth_realm`, `query_icmp`, `quick_abort`, `quick_abort_max`, `quick_abort_min`, `quick_abort_pct`, `range_offset_limit`, `read_timeout`, `redirect_children`, `redirect_program`, `redirect_rewrites_host_header`, `reference_age`, `refresh_pattern`, `reload_into_ims`, `request_body_max_size`, `request_size`, `request_timeout`, `shutdown_lifetime`, `single_parent_bypass`, `siteselect_timeout`, `snmp_access`, `snmp_incoming_address`, `snmp_port`, `source_ping`, `ssl_proxy`, `store_avg_object_size`, `store_objects_per_bucket`, `strip_query_terms`, `swap_level1_dirs`, `swap_level2_dirs`, `tcp_incoming_address`, `tcp_outgoing_address`, `tcp_recv_bufsize`, `test_reachability`, `udp_hit_obj`, `udp_hit_obj_size`, `udp_incoming_address`, `udp_outgoing_address`, `unique_hostname`, `unlinkd_program`, `uri_whitespace`, `useragent_log`, `visible_hostname`, `wais_relay`, `wais_relay_host`, `wais_relay_port`), Keyword, nil},
{Words(`\b`, `\b`, `proxy-only`, `weight`, `ttl`, `no-query`, `default`, `round-robin`, `multicast-responder`, `on`, `off`, `all`, `deny`, `allow`, `via`, `parent`, `no-digest`, `heap`, `lru`, `realm`, `children`, `q1`, `q2`, `credentialsttl`, `none`, `disable`, `offline_toggle`, `diskd`), NameConstant, nil},
{Words(`\b`, `\b`, `shutdown`, `info`, `parameter`, `server_list`, `client_list`, `squid.conf`), LiteralString, nil},
{Words(`stats/`, `\b`, `objects`, `vm_objects`, `utilization`, `ipcache`, `fqdncache`, `dns`, `redirector`, `io`, `reply_headers`, `filedescriptors`, `netdb`), LiteralString, nil},
{Words(`log/`, `=`, `status`, `enable`, `disable`, `clear`), LiteralString, nil},
{Words(`\b`, `\b`, `url_regex`, `urlpath_regex`, `referer_regex`, `port`, `proto`, `req_mime_type`, `rep_mime_type`, `method`, `browser`, `user`, `src`, `dst`, `time`, `dstdomain`, `ident`, `snmp_community`), Keyword, nil},
{`(?:(?:(?:[3-9]\d?|2(?:5[0-5]|[0-4]?\d)?|1\d{0,2}|0x0*[0-9a-f]{1,2}|0+[1-3]?[0-7]{0,2})(?:\.(?:[3-9]\d?|2(?:5[0-5]|[0-4]?\d)?|1\d{0,2}|0x0*[0-9a-f]{1,2}|0+[1-3]?[0-7]{0,2})){3})|(?!.*::.*::)(?:(?!:)|:(?=:))(?:[0-9a-f]{0,4}(?:(?<=::)|(?<!::):)){6}(?:[0-9a-f]{0,4}(?:(?<=::)|(?<!::):)[0-9a-f]{0,4}(?:(?<=::)|(?<!:)|(?<=:)(?<!::):)|(?:25[0-4]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-4]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))(?:/(?:(?:(?:(?:[3-9]\d?|2(?:5[0-5]|[0-4]?\d)?|1\d{0,2}|0x0*[0-9a-f]{1,2}|0+[1-3]?[0-7]{0,2})(?:\.(?:[3-9]\d?|2(?:5[0-5]|[0-4]?\d)?|1\d{0,2}|0x0*[0-9a-f]{1,2}|0+[1-3]?[0-7]{0,2})){3})|(?!.*::.*::)(?:(?!:)|:(?=:))(?:[0-9a-f]{0,4}(?:(?<=::)|(?<!::):)){6}(?:[0-9a-f]{0,4}(?:(?<=::)|(?<!::):)[0-9a-f]{0,4}(?:(?<=::)|(?<!:)|(?<=:)(?<!::):)|(?:25[0-4]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-4]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|\b\d+\b))?`, LiteralNumberFloat, nil},
{`(?:\b\d+\b(?:-\b\d+|%)?)`, LiteralNumber, nil},
{`\S+`, Text, nil},
},
"comment": {
{`\s*TAG:.*`, LiteralStringEscape, Pop(1)},
{`.+`, Comment, Pop(1)},
Default(Pop(1)),
},
},
))

87
vendor/github.com/alecthomas/chroma/lexers/s/swift.go generated vendored Normal file
View file

@ -0,0 +1,87 @@
package s
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Swift lexer.
var Swift = internal.Register(MustNewLexer(
&Config{
Name: "Swift",
Aliases: []string{"swift"},
Filenames: []string{"*.swift"},
MimeTypes: []string{"text/x-swift"},
},
Rules{
"root": {
{`\n`, Text, nil},
{`\s+`, Text, nil},
{`//`, CommentSingle, Push("comment-single")},
{`/\*`, CommentMultiline, Push("comment-multi")},
{`#(if|elseif|else|endif|available)\b`, CommentPreproc, Push("preproc")},
Include("keywords"),
{Words(``, `\b`, `Array`, `AutoreleasingUnsafeMutablePointer`, `BidirectionalReverseView`, `Bit`, `Bool`, `CFunctionPointer`, `COpaquePointer`, `CVaListPointer`, `Character`, `ClosedInterval`, `CollectionOfOne`, `ContiguousArray`, `Dictionary`, `DictionaryGenerator`, `DictionaryIndex`, `Double`, `EmptyCollection`, `EmptyGenerator`, `EnumerateGenerator`, `EnumerateSequence`, `FilterCollectionView`, `FilterCollectionViewIndex`, `FilterGenerator`, `FilterSequenceView`, `Float`, `Float80`, `FloatingPointClassification`, `GeneratorOf`, `GeneratorOfOne`, `GeneratorSequence`, `HalfOpenInterval`, `HeapBuffer`, `HeapBufferStorage`, `ImplicitlyUnwrappedOptional`, `IndexingGenerator`, `Int`, `Int16`, `Int32`, `Int64`, `Int8`, `LazyBidirectionalCollection`, `LazyForwardCollection`, `LazyRandomAccessCollection`, `LazySequence`, `MapCollectionView`, `MapSequenceGenerator`, `MapSequenceView`, `MirrorDisposition`, `ObjectIdentifier`, `OnHeap`, `Optional`, `PermutationGenerator`, `QuickLookObject`, `RandomAccessReverseView`, `Range`, `RangeGenerator`, `RawByte`, `Repeat`, `ReverseBidirectionalIndex`, `ReverseRandomAccessIndex`, `SequenceOf`, `SinkOf`, `Slice`, `StaticString`, `StrideThrough`, `StrideThroughGenerator`, `StrideTo`, `StrideToGenerator`, `String`, `UInt`, `UInt16`, `UInt32`, `UInt64`, `UInt8`, `UTF16`, `UTF32`, `UTF8`, `UnicodeDecodingResult`, `UnicodeScalar`, `Unmanaged`, `UnsafeBufferPointer`, `UnsafeBufferPointerGenerator`, `UnsafeMutableBufferPointer`, `UnsafeMutablePointer`, `UnsafePointer`, `Zip2`, `ZipGenerator2`, `AbsoluteValuable`, `AnyObject`, `ArrayLiteralConvertible`, `BidirectionalIndexType`, `BitwiseOperationsType`, `BooleanLiteralConvertible`, `BooleanType`, `CVarArgType`, `CollectionType`, `Comparable`, `DebugPrintable`, `DictionaryLiteralConvertible`, `Equatable`, `ExtendedGraphemeClusterLiteralConvertible`, `ExtensibleCollectionType`, `FloatLiteralConvertible`, `FloatingPointType`, `ForwardIndexType`, `GeneratorType`, `Hashable`, `IntegerArithmeticType`, `IntegerLiteralConvertible`, `IntegerType`, `IntervalType`, `MirrorType`, `MutableCollectionType`, `MutableSliceable`, `NilLiteralConvertible`, `OutputStreamType`, `Printable`, `RandomAccessIndexType`, `RangeReplaceableCollectionType`, `RawOptionSetType`, `RawRepresentable`, `Reflectable`, `SequenceType`, `SignedIntegerType`, `SignedNumberType`, `SinkType`, `Sliceable`, `Streamable`, `Strideable`, `StringInterpolationConvertible`, `StringLiteralConvertible`, `UnicodeCodecType`, `UnicodeScalarLiteralConvertible`, `UnsignedIntegerType`, `_ArrayBufferType`, `_BidirectionalIndexType`, `_CocoaStringType`, `_CollectionType`, `_Comparable`, `_ExtensibleCollectionType`, `_ForwardIndexType`, `_Incrementable`, `_IntegerArithmeticType`, `_IntegerType`, `_ObjectiveCBridgeable`, `_RandomAccessIndexType`, `_RawOptionSetType`, `_SequenceType`, `_Sequence_Type`, `_SignedIntegerType`, `_SignedNumberType`, `_Sliceable`, `_Strideable`, `_SwiftNSArrayRequiredOverridesType`, `_SwiftNSArrayType`, `_SwiftNSCopyingType`, `_SwiftNSDictionaryRequiredOverridesType`, `_SwiftNSDictionaryType`, `_SwiftNSEnumeratorType`, `_SwiftNSFastEnumerationType`, `_SwiftNSStringRequiredOverridesType`, `_SwiftNSStringType`, `_UnsignedIntegerType`, `C_ARGC`, `C_ARGV`, `Process`, `Any`, `AnyClass`, `BooleanLiteralType`, `CBool`, `CChar`, `CChar16`, `CChar32`, `CDouble`, `CFloat`, `CInt`, `CLong`, `CLongLong`, `CShort`, `CSignedChar`, `CUnsignedInt`, `CUnsignedLong`, `CUnsignedShort`, `CWideChar`, `ExtendedGraphemeClusterType`, `Float32`, `Float64`, `FloatLiteralType`, `IntMax`, `IntegerLiteralType`, `StringLiteralType`, `UIntMax`, `UWord`, `UnicodeScalarType`, `Void`, `Word`, `NSErrorPointer`, `NSObjectProtocol`, `Selector`), NameBuiltin, nil},
{Words(``, `\b`, `abs`, `advance`, `alignof`, `alignofValue`, `assert`, `assertionFailure`, `contains`, `count`, `countElements`, `debugPrint`, `debugPrintln`, `distance`, `dropFirst`, `dropLast`, `dump`, `enumerate`, `equal`, `extend`, `fatalError`, `filter`, `find`, `first`, `getVaList`, `indices`, `insert`, `isEmpty`, `join`, `last`, `lazy`, `lexicographicalCompare`, `map`, `max`, `maxElement`, `min`, `minElement`, `numericCast`, `overlaps`, `partition`, `precondition`, `preconditionFailure`, `prefix`, `print`, `println`, `reduce`, `reflect`, `removeAll`, `removeAtIndex`, `removeLast`, `removeRange`, `reverse`, `sizeof`, `sizeofValue`, `sort`, `sorted`, `splice`, `split`, `startsWith`, `stride`, `strideof`, `strideofValue`, `suffix`, `swap`, `toDebugString`, `toString`, `transcode`, `underestimateCount`, `unsafeAddressOf`, `unsafeBitCast`, `unsafeDowncast`, `withExtendedLifetime`, `withUnsafeMutablePointer`, `withUnsafeMutablePointers`, `withUnsafePointer`, `withUnsafePointers`, `withVaList`), NameBuiltinPseudo, nil},
{`\$\d+`, NameVariable, nil},
{`0b[01_]+`, LiteralNumberBin, nil},
{`0o[0-7_]+`, LiteralNumberOct, nil},
{`0x[0-9a-fA-F_]+`, LiteralNumberHex, nil},
{`[0-9][0-9_]*(\.[0-9_]+[eE][+\-]?[0-9_]+|\.[0-9_]*|[eE][+\-]?[0-9_]+)`, LiteralNumberFloat, nil},
{`[0-9][0-9_]*`, LiteralNumberInteger, nil},
{`"`, LiteralString, Push("string")},
{"[(){}\\[\\].,:;=@#`?]|->|[<&?](?=\\w)|(?<=\\w)[>!?]", Punctuation, nil},
{`[/=\-+!*%<>&|^?~]+`, Operator, nil},
{`[a-zA-Z_]\w*`, Name, nil},
},
"keywords": {
{Words(``, `\b`, `as`, `break`, `case`, `catch`, `continue`, `default`, `defer`, `do`, `else`, `fallthrough`, `for`, `guard`, `if`, `in`, `is`, `repeat`, `return`, `#selector`, `switch`, `throw`, `try`, `where`, `while`), Keyword, nil},
{`@availability\([^)]+\)`, KeywordReserved, nil},
{Words(``, `\b`, `associativity`, `convenience`, `dynamic`, `didSet`, `final`, `get`, `indirect`, `infix`, `inout`, `lazy`, `left`, `mutating`, `none`, `nonmutating`, `optional`, `override`, `postfix`, `precedence`, `prefix`, `Protocol`, `required`, `rethrows`, `right`, `set`, `throws`, `Type`, `unowned`, `weak`, `willSet`, `@availability`, `@autoclosure`, `@noreturn`, `@NSApplicationMain`, `@NSCopying`, `@NSManaged`, `@objc`, `@UIApplicationMain`, `@IBAction`, `@IBDesignable`, `@IBInspectable`, `@IBOutlet`), KeywordReserved, nil},
{`(as|dynamicType|false|is|nil|self|Self|super|true|__COLUMN__|__FILE__|__FUNCTION__|__LINE__|_|#(?:file|line|column|function))\b`, KeywordConstant, nil},
{`import\b`, KeywordDeclaration, Push("module")},
{`(class|enum|extension|struct|protocol)(\s+)([a-zA-Z_]\w*)`, ByGroups(KeywordDeclaration, Text, NameClass), nil},
{`(func)(\s+)([a-zA-Z_]\w*)`, ByGroups(KeywordDeclaration, Text, NameFunction), nil},
{`(var|let)(\s+)([a-zA-Z_]\w*)`, ByGroups(KeywordDeclaration, Text, NameVariable), nil},
{Words(``, `\b`, `class`, `deinit`, `enum`, `extension`, `func`, `import`, `init`, `internal`, `let`, `operator`, `private`, `protocol`, `public`, `static`, `struct`, `subscript`, `typealias`, `var`), KeywordDeclaration, nil},
},
"comment": {
{`:param: [a-zA-Z_]\w*|:returns?:|(FIXME|MARK|TODO):`, CommentSpecial, nil},
},
"comment-single": {
{`\n`, Text, Pop(1)},
Include("comment"),
{`[^\n]`, CommentSingle, nil},
},
"comment-multi": {
Include("comment"),
{`[^*/]`, CommentMultiline, nil},
{`/\*`, CommentMultiline, Push()},
{`\*/`, CommentMultiline, Pop(1)},
{`[*/]`, CommentMultiline, nil},
},
"module": {
{`\n`, Text, Pop(1)},
{`[a-zA-Z_]\w*`, NameClass, nil},
Include("root"),
},
"preproc": {
{`\n`, Text, Pop(1)},
Include("keywords"),
{`[A-Za-z]\w*`, CommentPreproc, nil},
Include("root"),
},
"string": {
{`\\\(`, LiteralStringInterpol, Push("string-intp")},
{`"`, LiteralString, Pop(1)},
{`\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}`, LiteralStringEscape, nil},
{`[^\\"]+`, LiteralString, nil},
{`\\`, LiteralString, nil},
},
"string-intp": {
{`\(`, LiteralStringInterpol, Push()},
{`\)`, LiteralStringInterpol, Pop(1)},
Include("root"),
},
},
))

View file

@ -0,0 +1,28 @@
package s
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
var SYSTEMD = internal.Register(MustNewLexer(
&Config{
Name: "SYSTEMD",
Aliases: []string{"systemd"},
Filenames: []string{"*.service"},
MimeTypes: []string{"text/plain"},
},
Rules{
"root": {
{`\s+`, Text, nil},
{`[;#].*`, Comment, nil},
{`\[.*?\]$`, Keyword, nil},
{`(.*?)(=)(.*)(\\\n)`, ByGroups(NameAttribute, Operator, LiteralString, Text), Push("continuation")},
{`(.*?)(=)(.*)`, ByGroups(NameAttribute, Operator, LiteralString), nil},
},
"continuation": {
{`(.*?)(\\\n)`, ByGroups(LiteralString, Text), nil},
{`(.*)`, LiteralString, Pop(1)},
},
},
))

View file

@ -0,0 +1,73 @@
package s
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Systemverilog lexer.
var Systemverilog = internal.Register(MustNewLexer(
&Config{
Name: "systemverilog",
Aliases: []string{"systemverilog", "sv"},
Filenames: []string{"*.sv", "*.svh"},
MimeTypes: []string{"text/x-systemverilog"},
EnsureNL: true,
},
Rules{
"root": {
{"^\\s*`define", CommentPreproc, Push("macro")},
{`^(\s*)(package)(\s+)`, ByGroups(Text, KeywordNamespace, Text), nil},
{`^(\s*)(import)(\s+)("DPI(?:-C)?")(\s+)`, ByGroups(Text, KeywordNamespace, Text, LiteralString, Text), nil},
{`^(\s*)(import)(\s+)`, ByGroups(Text, KeywordNamespace, Text), Push("import")},
{`\n`, Text, nil},
{`\s+`, Text, nil},
{`\\\n`, Text, nil},
{`/(\\\n)?/(\n|(.|\n)*?[^\\]\n)`, CommentSingle, nil},
{`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil},
{`[{}#@]`, Punctuation, nil},
{`L?"`, LiteralString, Push("string")},
{`L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'`, LiteralStringChar, nil},
{`(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?`, LiteralNumberFloat, nil},
{`(\d+\.\d*|\.\d+|\d+[fF])[fF]?`, LiteralNumberFloat, nil},
{`([0-9]+)|(\'h)[0-9a-fA-F]+`, LiteralNumberHex, nil},
{`([0-9]+)|(\'b)[01]+`, LiteralNumberBin, nil},
{`([0-9]+)|(\'d)[0-9]+`, LiteralNumberInteger, nil},
{`([0-9]+)|(\'o)[0-7]+`, LiteralNumberOct, nil},
{`\'[01xz]`, LiteralNumber, nil},
{`\d+[Ll]?`, LiteralNumberInteger, nil},
{`\*/`, Error, nil},
{`[~!%^&*+=|?:<>/-]`, Operator, nil},
{`[()\[\],.;\']`, Punctuation, nil},
{"`[a-zA-Z_]\\w*", NameConstant, nil},
{Words(``, `\b`, `accept_on`, `alias`, `always`, `always_comb`, `always_ff`, `always_latch`, `and`, `assert`, `assign`, `assume`, `automatic`, `before`, `begin`, `bind`, `bins`, `binsof`, `bit`, `break`, `buf`, `bufif0`, `bufif1`, `byte`, `case`, `casex`, `casez`, `cell`, `chandle`, `checker`, `class`, `clocking`, `cmos`, `config`, `const`, `constraint`, `context`, `continue`, `cover`, `covergroup`, `coverpoint`, `cross`, `deassign`, `default`, `defparam`, `design`, `disable`, `dist`, `do`, `edge`, `else`, `end`, `endcase`, `endchecker`, `endclass`, `endclocking`, `endconfig`, `endfunction`, `endgenerate`, `endgroup`, `endinterface`, `endmodule`, `endpackage`, `endprimitive`, `endprogram`, `endproperty`, `endsequence`, `endspecify`, `endtable`, `endtask`, `enum`, `event`, `eventually`, `expect`, `export`, `extends`, `extern`, `final`, `first_match`, `for`, `force`, `foreach`, `forever`, `fork`, `forkjoin`, `function`, `generate`, `genvar`, `global`, `highz0`, `highz1`, `if`, `iff`, `ifnone`, `ignore_bins`, `illegal_bins`, `implies`, `import`, `incdir`, `include`, `initial`, `inout`, `input`, `inside`, `instance`, `int`, `integer`, `interface`, `intersect`, `join`, `join_any`, `join_none`, `large`, `let`, `liblist`, `library`, `local`, `localparam`, `logic`, `longint`, `macromodule`, `matches`, `medium`, `modport`, `module`, `nand`, `negedge`, `new`, `nexttime`, `nmos`, `nor`, `noshowcancelled`, `not`, `notif0`, `notif1`, `null`, `or`, `output`, `package`, `packed`, `parameter`, `pmos`, `posedge`, `primitive`, `priority`, `program`, `property`, `protected`, `pull0`, `pull1`, `pulldown`, `pullup`, `pulsestyle_ondetect`, `pulsestyle_onevent`, `pure`, `rand`, `randc`, `randcase`, `randsequence`, `rcmos`, `real`, `realtime`, `ref`, `reg`, `reject_on`, `release`, `repeat`, `restrict`, `return`, `rnmos`, `rpmos`, `rtran`, `rtranif0`, `rtranif1`, `s_always`, `s_eventually`, `s_nexttime`, `s_until`, `s_until_with`, `scalared`, `sequence`, `shortint`, `shortreal`, `showcancelled`, `signed`, `small`, `solve`, `specify`, `specparam`, `static`, `string`, `strong`, `strong0`, `strong1`, `struct`, `super`, `supply0`, `supply1`, `sync_accept_on`, `sync_reject_on`, `table`, `tagged`, `task`, `this`, `throughout`, `time`, `timeprecision`, `timeunit`, `tran`, `tranif0`, `tranif1`, `tri`, `tri0`, `tri1`, `triand`, `trior`, `trireg`, `type`, `typedef`, `union`, `unique`, `unique0`, `unsigned`, `until`, `until_with`, `untyped`, `use`, `uwire`, `var`, `vectored`, `virtual`, `void`, `wait`, `wait_order`, `wand`, `weak`, `weak0`, `weak1`, `while`, `wildcard`, `wire`, `with`, `within`, `wor`, `xnor`, `xor`), Keyword, nil},
{Words(``, `\b`, "`__FILE__", "`__LINE__", "`begin_keywords", "`celldefine", "`default_nettype", "`define", "`else", "`elsif", "`end_keywords", "`endcelldefine", "`endif", "`ifdef", "`ifndef", "`include", "`line", "`nounconnected_drive", "`pragma", "`resetall", "`timescale", "`unconnected_drive", "`undef", "`undefineall"), CommentPreproc, nil},
{Words(``, `\b`, `$display`, `$displayb`, `$displayh`, `$displayo`, `$dumpall`, `$dumpfile`, `$dumpflush`, `$dumplimit`, `$dumpoff`, `$dumpon`, `$dumpports`, `$dumpportsall`, `$dumpportsflush`, `$dumpportslimit`, `$dumpportsoff`, `$dumpportson`, `$dumpvars`, `$fclose`, `$fdisplay`, `$fdisplayb`, `$fdisplayh`, `$fdisplayo`, `$feof`, `$ferror`, `$fflush`, `$fgetc`, `$fgets`, `$finish`, `$fmonitor`, `$fmonitorb`, `$fmonitorh`, `$fmonitoro`, `$fopen`, `$fread`, `$fscanf`, `$fseek`, `$fstrobe`, `$fstrobeb`, `$fstrobeh`, `$fstrobeo`, `$ftell`, `$fwrite`, `$fwriteb`, `$fwriteh`, `$fwriteo`, `$monitor`, `$monitorb`, `$monitorh`, `$monitoro`, `$monitoroff`, `$monitoron`, `$plusargs`, `$random`, `$readmemb`, `$readmemh`, `$rewind`, `$sformat`, `$sformatf`, `$sscanf`, `$strobe`, `$strobeb`, `$strobeh`, `$strobeo`, `$swrite`, `$swriteb`, `$swriteh`, `$swriteo`, `$test`, `$ungetc`, `$value$plusargs`, `$write`, `$writeb`, `$writeh`, `$writememb`, `$writememh`, `$writeo`), NameBuiltin, nil},
{`(class)(\s+)`, ByGroups(Keyword, Text), Push("classname")},
{Words(``, `\b`, `byte`, `shortint`, `int`, `longint`, `integer`, `time`, `bit`, `logic`, `reg`, `supply0`, `supply1`, `tri`, `triand`, `trior`, `tri0`, `tri1`, `trireg`, `uwire`, `wire`, `wand`, `woshortreal`, `real`, `realtime`), KeywordType, nil},
{`[a-zA-Z_]\w*:(?!:)`, NameLabel, nil},
{`\$?[a-zA-Z_]\w*`, Name, nil},
},
"classname": {
{`[a-zA-Z_]\w*`, NameClass, Pop(1)},
},
"string": {
{`"`, LiteralString, Pop(1)},
{`\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})`, LiteralStringEscape, nil},
{`[^\\"\n]+`, LiteralString, nil},
{`\\\n`, LiteralString, nil},
{`\\`, LiteralString, nil},
},
"macro": {
{`[^/\n]+`, CommentPreproc, nil},
{`/[*](.|\n)*?[*]/`, CommentMultiline, nil},
{`//.*?\n`, CommentSingle, Pop(1)},
{`/`, CommentPreproc, nil},
{`(?<=\\)\n`, CommentPreproc, nil},
{`\n`, CommentPreproc, Pop(1)},
},
"import": {
{`[\w:]+\*?`, NameNamespace, Pop(1)},
},
},
))