mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-15 05:58:16 +00: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>
108 lines
3.8 KiB
Go
Vendored
108 lines
3.8 KiB
Go
Vendored
package m
|
|
|
|
import (
|
|
. "github.com/alecthomas/chroma" // nolint
|
|
"github.com/alecthomas/chroma/lexers/internal"
|
|
)
|
|
|
|
// mcfunction lexer.
|
|
var MCFunction = internal.Register(MustNewLexer(
|
|
&Config{
|
|
Name: "mcfunction",
|
|
Aliases: []string{"mcfunction"},
|
|
Filenames: []string{"*.mcfunction"},
|
|
MimeTypes: []string{},
|
|
NotMultiline: true,
|
|
DotAll: true,
|
|
},
|
|
Rules{
|
|
"simplevalue": {
|
|
{`(true|false)`, KeywordConstant, nil},
|
|
{`[01]b`, LiteralNumber, nil},
|
|
{`-?(0|[1-9]\d*)(\.\d+[eE](\+|-)?\d+|[eE](\+|-)?\d+|\.\d+)`, LiteralNumberFloat, nil},
|
|
{`(-?\d+)(\.\.)(-?\d+)`, ByGroups(LiteralNumberInteger, Punctuation, LiteralNumberInteger), nil},
|
|
{`-?(0|[1-9]\d*)`, LiteralNumberInteger, nil},
|
|
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
|
|
{`'[^']+'`, LiteralStringSingle, nil},
|
|
{`([!#]?)(\w+)`, ByGroups(Punctuation, Text), nil},
|
|
},
|
|
"nbtobjectattribute": {
|
|
Include("nbtvalue"),
|
|
{`:`, Punctuation, nil},
|
|
{`,`, Punctuation, Pop(1)},
|
|
{`\}`, Punctuation, Pop(2)},
|
|
},
|
|
"nbtobjectvalue": {
|
|
{`("(\\\\|\\"|[^"])*"|[a-zA-Z0-9_]+)`, NameTag, Push("nbtobjectattribute")},
|
|
{`\}`, Punctuation, Pop(1)},
|
|
},
|
|
"nbtarrayvalue": {
|
|
Include("nbtvalue"),
|
|
{`,`, Punctuation, nil},
|
|
{`\]`, Punctuation, Pop(1)},
|
|
},
|
|
"nbtvalue": {
|
|
Include("simplevalue"),
|
|
{`\{`, Punctuation, Push("nbtobjectvalue")},
|
|
{`\[`, Punctuation, Push("nbtarrayvalue")},
|
|
},
|
|
"argumentvalue": {
|
|
Include("simplevalue"),
|
|
{`,`, Punctuation, Pop(1)},
|
|
{`[}\]]`, Punctuation, Pop(2)},
|
|
},
|
|
"argumentlist": {
|
|
{`(nbt)(={)`, ByGroups(NameAttribute, Punctuation), Push("nbtobjectvalue")},
|
|
{`([A-Za-z0-9/_!]+)(={)`, ByGroups(NameAttribute, Punctuation), Push("argumentlist")},
|
|
{`([A-Za-z0-9/_!]+)(=)`, ByGroups(NameAttribute, Punctuation), Push("argumentvalue")},
|
|
Include("simplevalue"),
|
|
{`,`, Punctuation, nil},
|
|
{`[}\]]`, Punctuation, Pop(1)},
|
|
},
|
|
"root": {
|
|
{`#.*?\n`, CommentSingle, nil},
|
|
{Words(`/?`, `\b`, `ability`, `attributes`, `advancement`,
|
|
`ban`, `ban-ip`, `banlist`, `bossbar`,
|
|
`camerashake`, `classroommode`, `clear`,
|
|
`clearspawnpoint`, `clone`, `code`, `collect`,
|
|
`createagent`, `data`, `datapack`, `debug`,
|
|
`defaultgamemode`, `deop`, `destroy`, `detect`,
|
|
`detectredstone`, `difficulty`, `dropall`,
|
|
`effect`, `enchant`, `event`, `execute`,
|
|
`experience`, `fill`, `flog`, `forceload`,
|
|
`function`, `gamemode`, `gamerule`,
|
|
`geteduclientinfo`, `give`, `help`, `item`,
|
|
`immutableworld`, `kick`, `kill`, `list`,
|
|
`locate`, `locatebiome`, `loot`, `me`, `mixer`,
|
|
`mobevent`, `move`, `msg`, `music`, `op`,
|
|
`pardon`, `particle`, `playanimation`,
|
|
`playsound`, `position`, `publish`,
|
|
`raytracefog`, `recipe`, `reload`, `remove`,
|
|
`replaceitem`, `ride`, `save`, `save-all`,
|
|
`save-off`, `save-on`, `say`, `schedule`,
|
|
`scoreboard`, `seed`, `setblock`,
|
|
`setidletimeout`, `setmaxplayers`,
|
|
`setworldspawn`, `spawnpoint`, `spectate`,
|
|
`spreadplayers`, `stop`, `stopsound`,
|
|
`structure`, `summon`, `tag`, `team`, `teammsg`,
|
|
`teleport`, `tell`, `tellraw`, `testfor`,
|
|
`testforblock`, `testforblocks`, `tickingarea`,
|
|
`time`, `title`, `toggledownfall`, `tp`,
|
|
`tpagent`, `transfer`, `transferserver`,
|
|
`trigger`, `turn`, `w`, `weather`, `whitelist`,
|
|
`worldborder`, `worldbuilder`, `wsserver`, `xp`,
|
|
), KeywordReserved, nil},
|
|
{Words(``, ``, `@p`, `@r`, `@a`, `@e`, `@s`, `@c`, `@v`),
|
|
KeywordConstant, nil},
|
|
{`\[`, Punctuation, Push("argumentlist")},
|
|
{`{`, Punctuation, Push("nbtobjectvalue")},
|
|
{`~`, NameBuiltin, nil},
|
|
{`([a-zA-Z_]+:)?[a-zA-Z_]+\b`, Text, nil},
|
|
{`([a-z]+)(\.)([0-9]+)\b`, ByGroups(Text, Punctuation, LiteralNumber), nil},
|
|
{`([<>=]|<=|>=)`, Punctuation, nil},
|
|
Include("simplevalue"),
|
|
{`\s+`, TextWhitespace, nil},
|
|
},
|
|
},
|
|
))
|