mirror of
https://github.com/go-gitea/gitea.git
synced 2024-08-25 21:57:29 +02:00
* update github.com/PuerkitoBio/goquery * update github.com/alecthomas/chroma * update github.com/blevesearch/bleve/v2 * update github.com/caddyserver/certmagic * update github.com/go-enry/go-enry/v2 * update github.com/go-git/go-billy/v5 * update github.com/go-git/go-git/v5 * update github.com/go-redis/redis/v8 * update github.com/go-testfixtures/testfixtures/v3 * update github.com/jaytaylor/html2text * update github.com/json-iterator/go * update github.com/klauspost/compress * update github.com/markbates/goth * update github.com/mattn/go-isatty * update github.com/mholt/archiver/v3 * update github.com/microcosm-cc/bluemonday * update github.com/minio/minio-go/v7 * update github.com/prometheus/client_golang * update github.com/unrolled/render * update github.com/xanzy/go-gitlab * update github.com/yuin/goldmark * update github.com/yuin/goldmark-highlighting Co-authored-by: techknowlogick <techknowlogick@gitea.io>
78 lines
3.6 KiB
Go
Vendored
78 lines
3.6 KiB
Go
Vendored
package t
|
|
|
|
import (
|
|
. "github.com/alecthomas/chroma" // nolint
|
|
"github.com/alecthomas/chroma/lexers/internal"
|
|
)
|
|
|
|
// Thrift lexer.
|
|
var Thrift = internal.Register(MustNewLazyLexer(
|
|
&Config{
|
|
Name: "Thrift",
|
|
Aliases: []string{"thrift"},
|
|
Filenames: []string{"*.thrift"},
|
|
MimeTypes: []string{"application/x-thrift"},
|
|
},
|
|
thriftRules,
|
|
))
|
|
|
|
func thriftRules() Rules {
|
|
return Rules{
|
|
"root": {
|
|
Include("whitespace"),
|
|
Include("comments"),
|
|
{`"`, LiteralStringDouble, Combined("stringescape", "dqs")},
|
|
{`\'`, LiteralStringSingle, Combined("stringescape", "sqs")},
|
|
{`(namespace)(\s+)`, ByGroups(KeywordNamespace, TextWhitespace), Push("namespace")},
|
|
{`(enum|union|struct|service|exception)(\s+)`, ByGroups(KeywordDeclaration, TextWhitespace), Push("class")},
|
|
{`((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)((?:[^\W\d]|\$)[\w$]*)(\s*)(\()`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil},
|
|
Include("keywords"),
|
|
Include("numbers"),
|
|
{`[&=]`, Operator, nil},
|
|
{`[:;,{}()<>\[\]]`, Punctuation, nil},
|
|
{`[a-zA-Z_](\.\w|\w)*`, Name, nil},
|
|
},
|
|
"whitespace": {
|
|
{`\n`, TextWhitespace, nil},
|
|
{`\s+`, TextWhitespace, nil},
|
|
},
|
|
"comments": {
|
|
{`#.*$`, Comment, nil},
|
|
{`//.*?\n`, Comment, nil},
|
|
{`/\*[\w\W]*?\*/`, CommentMultiline, nil},
|
|
},
|
|
"stringescape": {
|
|
{`\\([\\nrt"\'])`, LiteralStringEscape, nil},
|
|
},
|
|
"dqs": {
|
|
{`"`, LiteralStringDouble, Pop(1)},
|
|
{`[^\\"\n]+`, LiteralStringDouble, nil},
|
|
},
|
|
"sqs": {
|
|
{`'`, LiteralStringSingle, Pop(1)},
|
|
{`[^\\\'\n]+`, LiteralStringSingle, nil},
|
|
},
|
|
"namespace": {
|
|
{`[a-z*](\.\w|\w)*`, NameNamespace, Pop(1)},
|
|
Default(Pop(1)),
|
|
},
|
|
"class": {
|
|
{`[a-zA-Z_]\w*`, NameClass, Pop(1)},
|
|
Default(Pop(1)),
|
|
},
|
|
"keywords": {
|
|
{`(async|oneway|extends|throws|required|optional)\b`, Keyword, nil},
|
|
{`(true|false)\b`, KeywordConstant, nil},
|
|
{`(const|typedef)\b`, KeywordDeclaration, nil},
|
|
{Words(``, `\b`, `cpp_namespace`, `cpp_include`, `cpp_type`, `java_package`, `cocoa_prefix`, `csharp_namespace`, `delphi_namespace`, `php_namespace`, `py_module`, `perl_package`, `ruby_namespace`, `smalltalk_category`, `smalltalk_prefix`, `xsd_all`, `xsd_optional`, `xsd_nillable`, `xsd_namespace`, `xsd_attrs`, `include`), KeywordNamespace, nil},
|
|
{Words(``, `\b`, `void`, `bool`, `byte`, `i16`, `i32`, `i64`, `double`, `string`, `binary`, `map`, `list`, `set`, `slist`, `senum`), KeywordType, nil},
|
|
{Words(`\b`, `\b`, `BEGIN`, `END`, `__CLASS__`, `__DIR__`, `__FILE__`, `__FUNCTION__`, `__LINE__`, `__METHOD__`, `__NAMESPACE__`, `abstract`, `alias`, `and`, `args`, `as`, `assert`, `begin`, `break`, `case`, `catch`, `class`, `clone`, `continue`, `declare`, `def`, `default`, `del`, `delete`, `do`, `dynamic`, `elif`, `else`, `elseif`, `elsif`, `end`, `enddeclare`, `endfor`, `endforeach`, `endif`, `endswitch`, `endwhile`, `ensure`, `except`, `exec`, `finally`, `float`, `for`, `foreach`, `function`, `global`, `goto`, `if`, `implements`, `import`, `in`, `inline`, `instanceof`, `interface`, `is`, `lambda`, `module`, `native`, `new`, `next`, `nil`, `not`, `or`, `pass`, `public`, `print`, `private`, `protected`, `raise`, `redo`, `rescue`, `retry`, `register`, `return`, `self`, `sizeof`, `static`, `super`, `switch`, `synchronized`, `then`, `this`, `throw`, `transient`, `try`, `undef`, `unless`, `unsigned`, `until`, `use`, `var`, `virtual`, `volatile`, `when`, `while`, `with`, `xor`, `yield`), KeywordReserved, nil},
|
|
},
|
|
"numbers": {
|
|
{`[+-]?(\d+\.\d+([eE][+-]?\d+)?|\.?\d+[eE][+-]?\d+)`, LiteralNumberFloat, nil},
|
|
{`[+-]?0x[0-9A-Fa-f]+`, LiteralNumberHex, nil},
|
|
{`[+-]?[0-9]+`, LiteralNumberInteger, nil},
|
|
},
|
|
}
|
|
}
|