mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-14 22:59:29 +01:00
86e2789960
* 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>
105 lines
4.2 KiB
Go
Vendored
105 lines
4.2 KiB
Go
Vendored
package a
|
|
|
|
import (
|
|
. "github.com/alecthomas/chroma" // nolint
|
|
"github.com/alecthomas/chroma/lexers/internal"
|
|
)
|
|
|
|
// ANTLR lexer.
|
|
var ANTLR = internal.Register(MustNewLazyLexer(
|
|
&Config{
|
|
Name: "ANTLR",
|
|
Aliases: []string{"antlr"},
|
|
Filenames: []string{},
|
|
MimeTypes: []string{},
|
|
},
|
|
antlrRules,
|
|
))
|
|
|
|
func antlrRules() Rules {
|
|
return Rules{
|
|
"whitespace": {
|
|
{`\s+`, TextWhitespace, nil},
|
|
},
|
|
"comments": {
|
|
{`//.*$`, Comment, nil},
|
|
{`/\*(.|\n)*?\*/`, Comment, nil},
|
|
},
|
|
"root": {
|
|
Include("whitespace"),
|
|
Include("comments"),
|
|
{`(lexer|parser|tree)?(\s*)(grammar\b)(\s*)([A-Za-z]\w*)(;)`, ByGroups(Keyword, TextWhitespace, Keyword, TextWhitespace, NameClass, Punctuation), nil},
|
|
{`options\b`, Keyword, Push("options")},
|
|
{`tokens\b`, Keyword, Push("tokens")},
|
|
{`(scope)(\s*)([A-Za-z]\w*)(\s*)(\{)`, ByGroups(Keyword, TextWhitespace, NameVariable, TextWhitespace, Punctuation), Push("action")},
|
|
{`(catch|finally)\b`, Keyword, Push("exception")},
|
|
{`(@[A-Za-z]\w*)(\s*)(::)?(\s*)([A-Za-z]\w*)(\s*)(\{)`, ByGroups(NameLabel, TextWhitespace, Punctuation, TextWhitespace, NameLabel, TextWhitespace, Punctuation), Push("action")},
|
|
{`((?:protected|private|public|fragment)\b)?(\s*)([A-Za-z]\w*)(!)?`, ByGroups(Keyword, TextWhitespace, NameLabel, Punctuation), Push("rule-alts", "rule-prelims")},
|
|
},
|
|
"exception": {
|
|
{`\n`, TextWhitespace, Pop(1)},
|
|
{`\s`, TextWhitespace, nil},
|
|
Include("comments"),
|
|
{`\[`, Punctuation, Push("nested-arg-action")},
|
|
{`\{`, Punctuation, Push("action")},
|
|
},
|
|
"rule-prelims": {
|
|
Include("whitespace"),
|
|
Include("comments"),
|
|
{`returns\b`, Keyword, nil},
|
|
{`\[`, Punctuation, Push("nested-arg-action")},
|
|
{`\{`, Punctuation, Push("action")},
|
|
{`(throws)(\s+)([A-Za-z]\w*)`, ByGroups(Keyword, TextWhitespace, NameLabel), nil},
|
|
{`(,)(\s*)([A-Za-z]\w*)`, ByGroups(Punctuation, TextWhitespace, NameLabel), nil},
|
|
{`options\b`, Keyword, Push("options")},
|
|
{`(scope)(\s+)(\{)`, ByGroups(Keyword, TextWhitespace, Punctuation), Push("action")},
|
|
{`(scope)(\s+)([A-Za-z]\w*)(\s*)(;)`, ByGroups(Keyword, TextWhitespace, NameLabel, TextWhitespace, Punctuation), nil},
|
|
{`(@[A-Za-z]\w*)(\s*)(\{)`, ByGroups(NameLabel, TextWhitespace, Punctuation), Push("action")},
|
|
{`:`, Punctuation, Pop(1)},
|
|
},
|
|
"rule-alts": {
|
|
Include("whitespace"),
|
|
Include("comments"),
|
|
{`options\b`, Keyword, Push("options")},
|
|
{`:`, Punctuation, nil},
|
|
{`'(\\\\|\\'|[^'])*'`, LiteralString, nil},
|
|
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
|
|
{`<<([^>]|>[^>])>>`, LiteralString, nil},
|
|
{`\$?[A-Z_]\w*`, NameConstant, nil},
|
|
{`\$?[a-z_]\w*`, NameVariable, nil},
|
|
{`(\+|\||->|=>|=|\(|\)|\.\.|\.|\?|\*|\^|!|\#|~)`, Operator, nil},
|
|
{`,`, Punctuation, nil},
|
|
{`\[`, Punctuation, Push("nested-arg-action")},
|
|
{`\{`, Punctuation, Push("action")},
|
|
{`;`, Punctuation, Pop(1)},
|
|
},
|
|
"tokens": {
|
|
Include("whitespace"),
|
|
Include("comments"),
|
|
{`\{`, Punctuation, nil},
|
|
{`([A-Z]\w*)(\s*)(=)?(\s*)(\'(?:\\\\|\\\'|[^\']*)\')?(\s*)(;)`, ByGroups(NameLabel, TextWhitespace, Punctuation, TextWhitespace, LiteralString, TextWhitespace, Punctuation), nil},
|
|
{`\}`, Punctuation, Pop(1)},
|
|
},
|
|
"options": {
|
|
Include("whitespace"),
|
|
Include("comments"),
|
|
{`\{`, Punctuation, nil},
|
|
{`([A-Za-z]\w*)(\s*)(=)(\s*)([A-Za-z]\w*|\'(?:\\\\|\\\'|[^\']*)\'|[0-9]+|\*)(\s*)(;)`, ByGroups(NameVariable, TextWhitespace, Punctuation, TextWhitespace, Text, TextWhitespace, Punctuation), nil},
|
|
{`\}`, Punctuation, Pop(1)},
|
|
},
|
|
"action": {
|
|
{`([^${}\'"/\\]+|"(\\\\|\\"|[^"])*"|'(\\\\|\\'|[^'])*'|//.*$\n?|/\*(.|\n)*?\*/|/(?!\*)(\\\\|\\/|[^/])*/|\\(?!%)|/)+`, Other, nil},
|
|
{`(\\)(%)`, ByGroups(Punctuation, Other), nil},
|
|
{`(\$[a-zA-Z]+)(\.?)(text|value)?`, ByGroups(NameVariable, Punctuation, NameProperty), nil},
|
|
{`\{`, Punctuation, Push()},
|
|
{`\}`, Punctuation, Pop(1)},
|
|
},
|
|
"nested-arg-action": {
|
|
{`([^$\[\]\'"/]+|"(\\\\|\\"|[^"])*"|'(\\\\|\\'|[^'])*'|//.*$\n?|/\*(.|\n)*?\*/|/(?!\*)(\\\\|\\/|[^/])*/|/)+`, Other, nil},
|
|
{`\[`, Punctuation, Push()},
|
|
{`\]`, Punctuation, Pop(1)},
|
|
{`(\$[a-zA-Z]+)(\.?)(text|value)?`, ByGroups(NameVariable, Punctuation, NameProperty), nil},
|
|
{`(\\\\|\\\]|\\\[|[^\[\]])+`, Other, nil},
|
|
},
|
|
}
|
|
}
|