Update chroma (#18033)
Update chroma to 0.9.4 Signed-off-by: Andrew Thornton <art27@cantab.net>tokarchuk/v1.17
parent
fb5f7791ef
commit
25677cdc5b
@ -1,34 +1,14 @@ |
||||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U= |
||||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI= |
||||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo= |
||||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0= |
||||
github.com/alecthomas/kong v0.2.4 h1:Y0ZBCHAvHhTHw7FFJ2FzCAAG4pkbTgA45nc7BpMhDNk= |
||||
github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE= |
||||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY= |
||||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ= |
||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ= |
||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk= |
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= |
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
||||
github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E= |
||||
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= |
||||
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= |
||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= |
||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= |
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= |
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= |
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= |
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= |
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= |
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
||||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= |
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= |
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= |
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= |
||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= |
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= |
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 h1:opSr2sbRXk5X5/givKrrKj9HXxFpW2sdCiP8MJSKLQY= |
||||
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= |
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= |
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= |
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= |
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
||||
|
@ -0,0 +1,72 @@ |
||||
package a |
||||
|
||||
import ( |
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal" |
||||
) |
||||
|
||||
var ArmAsm = internal.Register(MustNewLazyLexer( |
||||
&Config{ |
||||
Name: "ArmAsm", |
||||
Aliases: []string{"armasm"}, |
||||
EnsureNL: true, |
||||
Filenames: []string{"*.s", "*.S"}, |
||||
MimeTypes: []string{"text/x-armasm", "text/x-asm"}, |
||||
}, |
||||
armasmRules, |
||||
)) |
||||
|
||||
func armasmRules() Rules { |
||||
return Rules{ |
||||
"commentsandwhitespace": { |
||||
{`\s+`, Text, nil}, |
||||
{`[@;].*?\n`, CommentSingle, nil}, |
||||
{`/\*.*?\*/`, CommentMultiline, nil}, |
||||
}, |
||||
"literal": { |
||||
// Binary
|
||||
{`0b[01]+`, NumberBin, Pop(1)}, |
||||
// Hex
|
||||
{`0x\w{1,8}`, NumberHex, Pop(1)}, |
||||
// Octal
|
||||
{`0\d+`, NumberOct, Pop(1)}, |
||||
// Float
|
||||
{`\d+?\.\d+?`, NumberFloat, Pop(1)}, |
||||
// Integer
|
||||
{`\d+`, NumberInteger, Pop(1)}, |
||||
// String
|
||||
{`(")(.+)(")`, ByGroups(Punctuation, StringDouble, Punctuation), Pop(1)}, |
||||
// Char
|
||||
{`(')(.{1}|\\.{1})(')`, ByGroups(Punctuation, StringChar, Punctuation), Pop(1)}, |
||||
}, |
||||
"opcode": { |
||||
// Escape at line end
|
||||
{`\n`, Text, Pop(1)}, |
||||
// Comment
|
||||
{`(@|;).*\n`, CommentSingle, Pop(1)}, |
||||
// Whitespace
|
||||
{`(\s+|,)`, Text, nil}, |
||||
// Register by number
|
||||
{`[rapcfxwbhsdqv]\d{1,2}`, NameClass, nil}, |
||||
// Address by hex
|
||||
{`=0x\w+`, ByGroups(Text, NameLabel), nil}, |
||||
// Pseudo address by label
|
||||
{`(=)(\w+)`, ByGroups(Text, NameLabel), nil}, |
||||
// Immediate
|
||||
{`#`, Text, Push("literal")}, |
||||
}, |
||||
"root": { |
||||
Include("commentsandwhitespace"), |
||||
// Directive with optional param
|
||||
{`(\.\w+)([ \t]+\w+\s+?)?`, ByGroups(KeywordNamespace, NameLabel), nil}, |
||||
// Label with data
|
||||
{`(\w+)(:)(\s+\.\w+\s+)`, ByGroups(NameLabel, Punctuation, KeywordNamespace), Push("literal")}, |
||||
// Label
|
||||
{`(\w+)(:)`, ByGroups(NameLabel, Punctuation), nil}, |
||||
// Syscall Op
|
||||
{`svc\s+\w+`, NameNamespace, nil}, |
||||
// Opcode
|
||||
{`[a-zA-Z]+`, Text, Push("opcode")}, |
||||
}, |
||||
} |
||||
} |
@ -0,0 +1,27 @@ |
||||
package b |
||||
|
||||
import ( |
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal" |
||||
) |
||||
|
||||
// BashSession lexer.
|
||||
var BashSession = internal.Register(MustNewLazyLexer( |
||||
&Config{ |
||||
Name: "BashSession", |
||||
Aliases: []string{"bash-session", "console", "shell-session"}, |
||||
Filenames: []string{".sh-session"}, |
||||
MimeTypes: []string{"text/x-sh"}, |
||||
EnsureNL: true, |
||||
}, |
||||
bashsessionRules, |
||||
)) |
||||
|
||||
func bashsessionRules() Rules { |
||||
return Rules{ |
||||
"root": { |
||||
{`(^[#$%>]\s*)(.*\n?)`, ByGroups(GenericPrompt, Using(Bash)), nil}, |
||||
{`^.+\n?`, GenericOutput, nil}, |
||||
}, |
||||
} |
||||
} |
@ -0,0 +1,66 @@ |
||||
package f |
||||
|
||||
import ( |
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal" |
||||
) |
||||
|
||||
// Fennel lexer.
|
||||
var Fennel = internal.Register(MustNewLazyLexer( |
||||
&Config{ |
||||
Name: "Fennel", |
||||
Aliases: []string{"fennel", "fnl"}, |
||||
Filenames: []string{"*.fennel"}, |
||||
MimeTypes: []string{"text/x-fennel", "application/x-fennel"}, |
||||
}, |
||||
fennelRules, |
||||
)) |
||||
|
||||
// Here's some Fennel code used to generate the lists of keywords:
|
||||
// (local fennel (require :fennel))
|
||||
//
|
||||
// (fn member? [t x] (each [_ y (ipairs t)] (when (= y x) (lua "return true"))))
|
||||
//
|
||||
// (local declarations [:fn :lambda :λ :local :var :global :macro :macros])
|
||||
// (local keywords [])
|
||||
// (local globals [])
|
||||
//
|
||||
// (each [name data (pairs (fennel.syntax))]
|
||||
// (if (member? declarations name) nil ; already populated
|
||||
// data.special? (table.insert keywords name)
|
||||
// data.macro? (table.insert keywords name)
|
||||
// data.global? (table.insert globals name)))
|
||||
//
|
||||
// (fn quoted [tbl]
|
||||
// (table.sort tbl)
|
||||
// (table.concat (icollect [_ k (ipairs tbl)]
|
||||
// (string.format "`%s`" k)) ", "))
|
||||
//
|
||||
// (print :Keyword (quoted keywords))
|
||||
// (print :KeywordDeclaration (quoted declarations))
|
||||
// (print :NameBuiltin (quoted globals))
|
||||
|
||||
func fennelRules() Rules { |
||||
return Rules{ |
||||
"root": { |
||||
{`;.*$`, CommentSingle, nil}, |
||||
{`\s+`, Whitespace, nil}, |
||||
{`-?\d+\.\d+`, LiteralNumberFloat, nil}, |
||||
{`-?\d+`, LiteralNumberInteger, nil}, |
||||
{`0x-?[abcdef\d]+`, LiteralNumberHex, nil}, |
||||
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil}, |
||||
{`'(?!#)[\w!$%*+<=>?/.#-]+`, LiteralStringSymbol, nil}, |
||||
{`\\(.|[a-z]+)`, LiteralStringChar, nil}, |
||||
{`::?#?(?!#)[\w!$%*+<=>?/.#-]+`, LiteralStringSymbol, nil}, |
||||
{"~@|[`\\'#^~&@]", Operator, nil}, |
||||
{Words(``, ` `, `#`, `%`, `*`, `+`, `-`, `->`, `->>`, `-?>`, `-?>>`, `.`, `..`, `/`, `//`, `:`, `<`, `<=`, `=`, `>`, `>=`, `?.`, `^`, `accumulate`, `and`, `band`, `bnot`, `bor`, `bxor`, `collect`, `comment`, `do`, `doc`, `doto`, `each`, `eval-compiler`, `for`, `hashfn`, `icollect`, `if`, `import-macros`, `include`, `length`, `let`, `lshift`, `lua`, `macrodebug`, `match`, `not`, `not=`, `or`, `partial`, `pick-args`, `pick-values`, `quote`, `require-macros`, `rshift`, `set`, `set-forcibly!`, `tset`, `values`, `when`, `while`, `with-open`, `~=`), Keyword, nil}, |
||||
{Words(``, ` `, `fn`, `global`, `lambda`, `local`, `macro`, `macros`, `var`, `λ`), KeywordDeclaration, nil}, |
||||
{Words(``, ` `, `_G`, `arg`, `assert`, `bit32`, `bit32.arshift`, `bit32.band`, `bit32.bnot`, `bit32.bor`, `bit32.btest`, `bit32.bxor`, `bit32.extract`, `bit32.lrotate`, `bit32.lshift`, `bit32.replace`, `bit32.rrotate`, `bit32.rshift`, `collectgarbage`, `coroutine`, `coroutine.create`, `coroutine.resume`, `coroutine.running`, `coroutine.status`, `coroutine.wrap`, `coroutine.yield`, `debug`, `debug.debug`, `debug.gethook`, `debug.getinfo`, `debug.getlocal`, `debug.getmetatable`, `debug.getregistry`, `debug.getupvalue`, `debug.getuservalue`, `debug.sethook`, `debug.setlocal`, `debug.setmetatable`, `debug.setupvalue`, `debug.setuservalue`, `debug.traceback`, `debug.upvalueid`, `debug.upvaluejoin`, `dofile`, `error`, `getmetatable`, `io`, `io.close`, `io.flush`, `io.input`, `io.lines`, `io.open`, `io.output`, `io.popen`, `io.read`, `io.tmpfile`, `io.type`, `io.write`, `ipairs`, `load`, `loadfile`, `loadstring`, `math`, `math.abs`, `math.acos`, `math.asin`, `math.atan`, `math.atan2`, `math.ceil`, `math.cos`, `math.cosh`, `math.deg`, `math.exp`, `math.floor`, `math.fmod`, `math.frexp`, `math.ldexp`, `math.log`, `math.log10`, `math.max`, `math.min`, `math.modf`, `math.pow`, `math.rad`, `math.random`, `math.randomseed`, `math.sin`, `math.sinh`, `math.sqrt`, `math.tan`, `math.tanh`, `module`, `next`, `os`, `os.clock`, `os.date`, `os.difftime`, `os.execute`, `os.exit`, `os.getenv`, `os.remove`, `os.rename`, `os.setlocale`, `os.time`, `os.tmpname`, `package`, `package.loadlib`, `package.searchpath`, `package.seeall`, `pairs`, `pcall`, `print`, `rawequal`, `rawget`, `rawlen`, `rawset`, `require`, `select`, `setmetatable`, `string`, `string.byte`, `string.char`, `string.dump`, `string.find`, `string.format`, `string.gmatch`, `string.gsub`, `string.len`, `string.lower`, `string.match`, `string.rep`, `string.reverse`, `string.sub`, `string.upper`, `table`, `table.concat`, `table.insert`, `table.maxn`, `table.pack`, `table.remove`, `table.sort`, `table.unpack`, `tonumber`, `tostring`, `type`, `unpack`, `xpcall`), NameBuiltin, nil}, |
||||
{`(?<=\()(?!#)[\w!$%*+<=>?/.#-]+`, NameFunction, nil}, |
||||
{`(?!#)[\w!$%*+<=>?/.#-]+`, NameVariable, nil}, |
||||
{`(\[|\])`, Punctuation, nil}, |
||||
{`(\{|\})`, Punctuation, nil}, |
||||
{`(\(|\))`, Punctuation, nil}, |
||||
}, |
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,51 @@ |
||||
package m |
||||
|
||||
import ( |
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal" |
||||
) |
||||
|
||||
// Meson lexer.
|
||||
var Meson = internal.Register(MustNewLazyLexer( |
||||
&Config{ |
||||
Name: "Meson", |
||||
Aliases: []string{"meson", "meson.build"}, |
||||
Filenames: []string{"meson.build", "meson_options.txt"}, |
||||
MimeTypes: []string{"text/x-meson"}, |
||||
}, |
||||
func() Rules { |
||||
return Rules{ |
||||
"root": { |
||||
{`#.*?$`, Comment, nil}, |
||||
{`'''.*'''`, LiteralStringSingle, nil}, |
||||
{`[1-9][0-9]*`, LiteralNumberInteger, nil}, |
||||
{`0o[0-7]+`, LiteralNumberOct, nil}, |
||||
{`0x[a-fA-F0-9]+`, LiteralNumberHex, nil}, |
||||
Include("string"), |
||||
Include("keywords"), |
||||
Include("expr"), |
||||
{`[a-zA-Z_][a-zA-Z_0-9]*`, Name, nil}, |
||||
{`\s+`, TextWhitespace, nil}, |
||||
}, |
||||
"string": { |
||||
{`[']{3}([']{0,2}([^\\']|\\(.|\n)))*[']{3}`, LiteralString, nil}, |
||||
{`'.*?(?<!\\)(\\\\)*?'`, LiteralString, nil}, |
||||
}, |
||||
"keywords": { |
||||
{Words(``, `\b`, `if`, `elif`, `else`, `endif`, `foreach`, `endforeach`, `break`, `continue`), Keyword, nil}, |
||||
}, |
||||
"expr": { |
||||
{`(in|and|or|not)\b`, OperatorWord, nil}, |
||||
{`(\*=|/=|%=|\+]=|-=|==|!=|\+|-|=)`, Operator, nil}, |
||||
{`[\[\]{}:().,?]`, Punctuation, nil}, |
||||
{Words(``, `\b`, `true`, `false`), KeywordConstant, nil}, |
||||
Include("builtins"), |
||||
{Words(``, `\b`, `meson`, `build_machine`, `host_machine`, `target_machine`), NameVariableMagic, nil}, |
||||
}, |
||||
"builtins": { |
||||
{Words(`(?<!\.)`, `\b`, `add_global_arguments`, `add_global_link_arguments`, `add_languages`, `add_project_arguments`, `add_project_link_arguments`, `add_test_setup`, `assert`, `benchmark`, `both_libraries`, `build_target`, `configuration_data`, `configure_file`, `custom_target`, `declare_dependency`, `dependency`, `disabler`, `environment`, `error`, `executable`, `files`, `find_library`, `find_program`, `generator`, `get_option`, `get_variable`, `include_directories`, `install_data`, `install_headers`, `install_man`, `install_subdir`, `is_disabler`, `is_variable`, `jar`, `join_paths`, `library`, `message`, `project`, `range`, `run_command`, `set_variable`, `shared_library`, `shared_module`, `static_library`, `subdir`, `subdir_done`, `subproject`, `summary`, `test`, `vcs_tag`, `warning`), NameBuiltin, nil}, |
||||
{`(?<!\.)import\b`, NameNamespace, nil}, |
||||
}, |
||||
} |
||||
}, |
||||
)) |
@ -0,0 +1,50 @@ |
||||
package o |
||||
|
||||
import ( |
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal" |
||||
) |
||||
|
||||
// 1S:Enterprise lexer.
|
||||
var OnesEnterprise = internal.Register(MustNewLazyLexer( |
||||
&Config{ |
||||
Name: "OnesEnterprise", |
||||
Aliases: []string{"ones", "onesenterprise", "1S", "1S:Enterprise"}, |
||||
Filenames: []string{"*.EPF", "*.epf", "*.ERF", "*.erf"}, |
||||
MimeTypes: []string{"application/octet-stream"}, |
||||
CaseInsensitive: true, |
||||
}, |
||||
onesRules, |
||||
)) |
||||
|
||||
func onesRules() Rules { |
||||
return Rules{ |
||||
"root": { |
||||
{`\n`, Text, nil}, |
||||
{`\s+`, Text, nil}, |
||||
{`\\\n`, Text, nil}, |
||||
{`[^\S\n]+`, Text, nil}, |
||||
{`//(.*?)\n`, Comment, nil}, |
||||
{`(#область|#region|#конецобласти|#endregion|#если|#if|#иначе|#else|#конецесли|#endif).*`, CommentPreproc, nil}, |
||||
{`(&наклиенте|&atclient|&насервере|&atserver|&насерверебезконтекста|&atservernocontext|&наклиентенасерверебезконтекста|&atclientatservernocontext).*`, CommentPreproc, nil}, |
||||
{`(>=|<=|<>|\+|-|=|>|<|\*|/|%)`, Operator, nil}, |
||||
{`(;|,|\)|\(|\.)`, Punctuation, nil}, |
||||
{Words(``, `\b`, `истина`, `true`, `ложь`, `false`, `и`, `and`, `или`, `or`, `не`, `not`), Operator, nil}, |
||||
{Words(``, `\b`, `если`, `if`, `тогда`, `then`, `иначе`, `else`, `иначеесли`, `elsif`, `конецесли`, `endif`), Operator, nil}, |
||||
{Words(``, `\b`, `для`, `for`, `каждого`, `each`, `из`, `in`, `цикл`, `do`, `пока`, `while`, `конеццикла`, `enddo`, `по`, `to`), Operator, nil}, |
||||
{Words(``, `\b`, `прервать`, `break`, `продолжить`, `continue`, `возврат`, `return`, `перейти`, `goto`), Operator, nil}, |
||||
{Words(``, `\b`, `процедура`, `procedure`, `конецпроцедуры`, `endprocedure`, `функция`, `function`, `конецфункции`, `endfunction`), Keyword, nil}, |
||||
{Words(``, `\b`, `новый`, `new`, `знач`, `val`, `экспорт`, `export`, `перем`, `var`), Keyword, nil}, |
||||
{Words(``, `\b`, `попытка`, `try`, `исключение`, `except`, `вызватьисключение`, `raise`, `конецпопытки`, `endtry`), Keyword, nil}, |
||||
{Words(``, `\b`, `выполнить`, `execute`, `вычислить`, `eval`), Keyword, nil}, |
||||
{`"`, LiteralString, Push("string")}, |
||||
{`[_а-яА-Я0-9][а-яА-Я0-9]*`, Name, nil}, |
||||
{`[_\w][\w]*`, Name, nil}, |
||||
}, |
||||
"string": { |
||||
{`""`, LiteralString, nil}, |
||||
{`"C?`, LiteralString, Pop(1)}, |
||||
{`[^"]+`, LiteralString, nil}, |
||||
}, |
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,37 @@ |
||||
package s |
||||
|
||||
import ( |
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal" |
||||
) |
||||
|
||||
// Sieve lexer.
|
||||
var Sieve = internal.Register(MustNewLazyLexer( |
||||
&Config{ |
||||
Name: "Sieve", |
||||
Aliases: []string{"sieve"}, |
||||
Filenames: []string{"*.siv", "*.sieve"}, |
||||
MimeTypes: []string{}, |
||||
}, |
||||
func() Rules { |
||||
return Rules{ |
||||
"root": { |
||||
{`\s+`, Text, nil}, |
||||
{`[();,{}\[\]]`, Punctuation, nil}, |
||||
{`(?i)require`, KeywordNamespace, nil}, |
||||
{`(?i)(:)(addresses|all|contains|content|create|copy|comparator|count|days|detail|domain|fcc|flags|from|handle|importance|is|localpart|length|lowerfirst|lower|matches|message|mime|options|over|percent|quotewildcard|raw|regex|specialuse|subject|text|under|upperfirst|upper|value)`, ByGroups(NameTag, NameTag), nil}, |
||||
{`(?i)(address|addflag|allof|anyof|body|discard|elsif|else|envelope|ereject|exists|false|fileinto|if|hasflag|header|keep|notify_method_capability|notify|not|redirect|reject|removeflag|setflag|size|spamtest|stop|string|true|vacation|virustest)`, NameBuiltin, nil}, |
||||
{`(?i)set`, KeywordDeclaration, nil}, |
||||
{`([0-9.]+)([kmgKMG])?`, ByGroups(LiteralNumber, LiteralNumber), nil}, |
||||
{`#.*$`, CommentSingle, nil}, |
||||
{`/\*.*\*/`, CommentMultiline, nil}, |
||||
{`"[^"]*?"`, LiteralString, nil}, |
||||
{`text:`, NameTag, Push("text")}, |
||||
}, |
||||
"text": { |
||||
{`[^.].*?\n`, LiteralString, nil}, |
||||
{`^\.`, Punctuation, Pop(1)}, |
||||
}, |
||||
} |
||||
}, |
||||
)) |
File diff suppressed because one or more lines are too long
@ -0,0 +1,17 @@ |
||||
package styles |
||||
|
||||
import ( |
||||
"github.com/alecthomas/chroma" |
||||
) |
||||
|
||||
// 1S:Designer color palette
|
||||
var OnesEnterprise = Register(chroma.MustNewStyle("onesenterprise", chroma.StyleEntries{ |
||||
chroma.Text: "#000000", |
||||
chroma.Comment: "#008000", |
||||
chroma.CommentPreproc: "#963200", |
||||
chroma.Operator: "#FF0000", |
||||
chroma.Keyword: "#FF0000", |
||||
chroma.Punctuation: "#FF0000", |
||||
chroma.LiteralString: "#000000", |
||||
chroma.Name: "#0000FF", |
||||
})) |
@ -1,24 +0,0 @@ |
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects) |
||||
*.o |
||||
*.a |
||||
*.so |
||||
|
||||
# Folders |
||||
_obj |
||||
_test |
||||
|
||||
# Architecture specific extensions/prefixes |
||||
*.[568vq] |
||||
[568vq].out |
||||
|
||||
*.cgo1.go |
||||
*.cgo2.c |
||||
_cgo_defun.c |
||||
_cgo_gotypes.go |
||||
_cgo_export.* |
||||
|
||||
_testmain.go |
||||
|
||||
*.exe |
||||
*.test |
||||
*.prof |
@ -1,23 +0,0 @@ |
||||
Copyright (c) 2016, Daniel Wakefield |
||||
All rights reserved. |
||||
|
||||
Redistribution and use in source and binary forms, with or without |
||||
modification, are permitted provided that the following conditions are met: |
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this |
||||
list of conditions and the following disclaimer. |
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, |
||||
this list of conditions and the following disclaimer in the documentation |
||||
and/or other materials provided with the distribution. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
@ -1,4 +0,0 @@ |
||||
# fnmatch |
||||
Updated clone of kballards golang fnmatch gist (https://gist.github.com/kballard/272720) |
||||
|
||||
|
@ -1,219 +0,0 @@ |
||||
// Provide string-matching based on fnmatch.3
|
||||
package fnmatch |
||||
|
||||
// There are a few issues that I believe to be bugs, but this implementation is
|
||||
// based as closely as possible on BSD fnmatch. These bugs are present in the
|
||||
// source of BSD fnmatch, and so are replicated here. The issues are as follows:
|
||||
//
|
||||
// * FNM_PERIOD is no longer observed after the first * in a pattern
|
||||
// This only applies to matches done with FNM_PATHNAME as well
|
||||
// * FNM_PERIOD doesn't apply to ranges. According to the documentation,
|
||||
// a period must be matched explicitly, but a range will match it too
|
||||
|
||||
import ( |
||||
"unicode" |
||||
"unicode/utf8" |
||||
) |
||||
|
||||
const ( |
||||
FNM_NOESCAPE = (1 << iota) |
||||
FNM_PATHNAME |
||||
FNM_PERIOD |
||||
|
||||
FNM_LEADING_DIR |
||||
FNM_CASEFOLD |
||||
|
||||
FNM_IGNORECASE = FNM_CASEFOLD |
||||
FNM_FILE_NAME = FNM_PATHNAME |
||||
) |
||||
|
||||
func unpackRune(str *string) rune { |
||||
rune, size := utf8.DecodeRuneInString(*str) |
||||
*str = (*str)[size:] |
||||
return rune |
||||
} |
||||
|
||||
// Matches the pattern against the string, with the given flags,
|
||||
// and returns true if the match is successful.
|
||||
// This function should match fnmatch.3 as closely as possible.
|
||||
func Match(pattern, s string, flags int) bool { |
||||
// The implementation for this function was patterned after the BSD fnmatch.c
|
||||
// source found at http://src.gnu-darwin.org/src/contrib/csup/fnmatch.c.html
|
||||
noescape := (flags&FNM_NOESCAPE != 0) |
||||
pathname := (flags&FNM_PATHNAME != 0) |
||||
period := (flags&FNM_PERIOD != 0) |
||||
leadingdir := (flags&FNM_LEADING_DIR != 0) |
||||
casefold := (flags&FNM_CASEFOLD != 0) |
||||
// the following is some bookkeeping that the original fnmatch.c implementation did not do
|
||||
// We are forced to do this because we're not keeping indexes into C strings but rather
|
||||
// processing utf8-encoded strings. Use a custom unpacker to maintain our state for us
|
||||
sAtStart := true |
||||
sLastAtStart := true |
||||
sLastSlash := false |
||||
sLastUnpacked := rune(0) |
||||
unpackS := func() rune { |
||||
sLastSlash = (sLastUnpacked == '/') |
||||
sLastUnpacked = unpackRune(&s) |
||||
sLastAtStart = sAtStart |
||||
sAtStart = false |
||||
return sLastUnpacked |
||||
} |
||||
for len(pattern) > 0 { |
||||
c := unpackRune(&pattern) |
||||
switch c { |
||||
case '?': |
||||
if len(s) == 0 { |
||||
return false |
||||
} |
||||
sc := unpackS() |
||||
if pathname && sc == '/' { |
||||
return false |
||||
} |
||||
if period && sc == '.' && (sLastAtStart || (pathname && sLastSlash)) { |
||||
return false |
||||
} |
||||
case '*': |
||||
// collapse multiple *'s
|
||||
// don't use unpackRune here, the only char we care to detect is ASCII
|
||||
for len(pattern) > 0 && pattern[0] == '*' { |
||||
pattern = pattern[1:] |
||||
} |
||||
if period && s[0] == '.' && (sAtStart || (pathname && sLastUnpacked == '/')) { |
||||
return false |
||||
} |
||||
// optimize for patterns with * at end or before /
|
||||
if len(pattern) == 0 { |
||||
if pathname { |
||||
return leadingdir || (strchr(s, '/') == -1) |
||||
} else { |
||||
return true |
||||
} |
||||
return !(pathname && strchr(s, '/') >= 0) |
||||
} else if pathname && pattern[0] == '/' { |
||||
offset := strchr(s, '/') |
||||
if offset == -1 { |
||||
return false |
||||
} else { |
||||
// we already know our pattern and string have a /, skip past it
|
||||
s = s[offset:] // use unpackS here to maintain our bookkeeping state
|
||||
unpackS() |
||||
pattern = pattern[1:] // we know / is one byte long
|
||||
break |
||||
} |
||||
} |
||||
// general case, recurse
|
||||
for test := s; len(test) > 0; unpackRune(&test) { |
||||
// I believe the (flags &^ FNM_PERIOD) is a bug when FNM_PATHNAME is specified
|
||||
// but this follows exactly from how fnmatch.c implements it
|
||||
if Match(pattern, test, (flags &^ FNM_PERIOD)) { |
||||
return true |
||||
} else if pathname && test[0] == '/' { |
||||
break |
||||
} |
||||
} |
||||
return false |
||||
case '[': |
||||
if len(s) == 0 { |
||||
return false |
||||
} |
||||
if pathname && s[0] == '/' { |
||||
return false |
||||
} |
||||
sc := unpackS() |
||||
if !rangematch(&pattern, sc, flags) { |
||||
return false |
||||
} |
||||
case '\\': |
||||
if !noescape { |
||||
if len(pattern) > 0 { |
||||
c = unpackRune(&pattern) |
||||
} |
||||
} |
||||
fallthrough |
||||
default: |
||||
if len(s) == 0 { |
||||
return false |
||||
} |
||||
sc := unpackS() |
||||
switch { |
||||
case sc == c: |
||||
case casefold && unicode.ToLower(sc) == unicode.ToLower(c): |
||||
default: |
||||
return false |
||||
} |
||||
} |
||||
} |
||||
return len(s) == 0 || (leadingdir && s[0] == '/') |
||||
} |
||||
|
||||
func rangematch(pattern *string, test rune, flags int) bool { |
||||
if len(*pattern) == 0 { |
||||
return false |
||||
} |
||||
casefold := (flags&FNM_CASEFOLD != 0) |
||||
noescape := (flags&FNM_NOESCAPE != 0) |
||||
if casefold { |
||||
test = unicode.ToLower(test) |
||||
} |
||||
var negate, matched bool |
||||
if (*pattern)[0] == '^' || (*pattern)[0] == '!' { |
||||
negate = true |
||||
(*pattern) = (*pattern)[1:] |
||||
} |
||||
for !matched && len(*pattern) > 1 && (*pattern)[0] != ']' { |
||||
c := unpackRune(pattern) |
||||
if !noescape && c == '\\' { |
||||
if len(*pattern) > 1 { |
||||
c = unpackRune(pattern) |
||||
} else { |
||||
return false |
||||
} |
||||
} |
||||
if casefold { |
||||
c = unicode.ToLower(c) |
||||
} |
||||
if (*pattern)[0] == '-' && len(*pattern) > 1 && (*pattern)[1] != ']' { |
||||
unpackRune(pattern) // skip the -
|
||||
c2 := unpackRune(pattern) |
||||
if !noescape && c2 == '\\' { |
||||
if len(*pattern) > 0 { |
||||
c2 = unpackRune(pattern) |
||||
} else { |
||||
return false |
||||
} |
||||
} |
||||
if casefold { |
||||
c2 = unicode.ToLower(c2) |
||||
} |
||||
// this really should be more intelligent, but it looks like
|
||||
// fnmatch.c does simple int comparisons, therefore we will as well
|
||||
if c <= test && test <= c2 { |
||||
matched = true |
||||
} |
||||
} else if c == test { |
||||
matched = true |
||||
} |
||||
} |
||||
// skip past the rest of the pattern
|
||||
ok := false |
||||
for !ok && len(*pattern) > 0 { |
||||
c := unpackRune(pattern) |
||||
if c == '\\' && len(*pattern) > 0 { |
||||
unpackRune(pattern) |
||||
} else if c == ']' { |
||||
ok = true |
||||
} |
||||
} |
||||
return ok && matched != negate |
||||
} |
||||
|
||||
// define strchr because strings.Index() seems a bit overkill
|
||||
// returns the index of c in s, or -1 if there is no match
|
||||
func strchr(s string, c rune) int { |
||||
for i, sc := range s { |
||||
if sc == c { |
||||
return i |
||||
} |
||||
} |
||||
return -1 |
||||
} |
Loading…
Reference in new issue