1
0
mirror of https://gitea.com/gitea/tea.git synced 2024-12-04 14:46:40 -05:00
tea/vendor/github.com/alecthomas/chroma/lexers/r/ragel.go
6543 89e93d90b3 Use glamour and termev to render/colorize content (#181)
Merge branch 'master' into use-glamour

select Glamour Theme based on BackgroundColor

Merge branch 'master' into use-glamour

Merge branch 'master' into use-glamour

update termev

update go.mod

label color colorate

use glamour for issue content

Vendor: Add glamour

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/181
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-19 16:00:50 +00:00

77 lines
2.1 KiB
Go

package r
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Ragel lexer.
var Ragel = internal.Register(MustNewLexer(
&Config{
Name: "Ragel",
Aliases: []string{"ragel"},
Filenames: []string{},
MimeTypes: []string{},
},
Rules{
"whitespace": {
{`\s+`, TextWhitespace, nil},
},
"comments": {
{`\#.*$`, Comment, nil},
},
"keywords": {
{`(access|action|alphtype)\b`, Keyword, nil},
{`(getkey|write|machine|include)\b`, Keyword, nil},
{`(any|ascii|extend|alpha|digit|alnum|lower|upper)\b`, Keyword, nil},
{`(xdigit|cntrl|graph|print|punct|space|zlen|empty)\b`, Keyword, nil},
},
"numbers": {
{`0x[0-9A-Fa-f]+`, LiteralNumberHex, nil},
{`[+-]?[0-9]+`, LiteralNumberInteger, nil},
},
"literals": {
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
{`'(\\\\|\\'|[^'])*'`, LiteralString, nil},
{`\[(\\\\|\\\]|[^\]])*\]`, LiteralString, nil},
{`/(?!\*)(\\\\|\\/|[^/])*/`, LiteralStringRegex, nil},
},
"identifiers": {
{`[a-zA-Z_]\w*`, NameVariable, nil},
},
"operators": {
{`,`, Operator, nil},
{`\||&|--?`, Operator, nil},
{`\.|<:|:>>?`, Operator, nil},
{`:`, Operator, nil},
{`->`, Operator, nil},
{`(>|\$|%|<|@|<>)(/|eof\b)`, Operator, nil},
{`(>|\$|%|<|@|<>)(!|err\b)`, Operator, nil},
{`(>|\$|%|<|@|<>)(\^|lerr\b)`, Operator, nil},
{`(>|\$|%|<|@|<>)(~|to\b)`, Operator, nil},
{`(>|\$|%|<|@|<>)(\*|from\b)`, Operator, nil},
{`>|@|\$|%`, Operator, nil},
{`\*|\?|\+|\{[0-9]*,[0-9]*\}`, Operator, nil},
{`!|\^`, Operator, nil},
{`\(|\)`, Operator, nil},
},
"root": {
Include("literals"),
Include("whitespace"),
Include("comments"),
Include("keywords"),
Include("numbers"),
Include("identifiers"),
Include("operators"),
{`\{`, Punctuation, Push("host")},
{`=`, Operator, nil},
{`;`, Punctuation, nil},
},
"host": {
{`([^{}\'"/#]+|[^\\]\\[{}]|"(\\\\|\\"|[^"])*"|'(\\\\|\\'|[^'])*'|//.*$\n?|/\*(.|\n)*?\*/|\#.*$\n?|/(?!\*)(\\\\|\\/|[^/])*/|/)+`, Other, nil},
{`\{`, Punctuation, Push()},
{`\}`, Punctuation, Pop(1)},
},
},
))