|
| 1 | +package m |
| 2 | + |
| 3 | +import ( |
| 4 | + . "github.com/alecthomas/chroma" // nolint |
| 5 | + "github.com/alecthomas/chroma/lexers/internal" |
| 6 | +) |
| 7 | + |
| 8 | +// mcfunction lexer. |
| 9 | +var MCFunction = internal.Register(MustNewLexer( |
| 10 | + &Config{ |
| 11 | + Name: "mcfunction", |
| 12 | + Aliases: []string{"mcfunction"}, |
| 13 | + Filenames: []string{"*.mcfunction"}, |
| 14 | + MimeTypes: []string{}, |
| 15 | + NotMultiline: true, |
| 16 | + DotAll: true, |
| 17 | + }, |
| 18 | + Rules{ |
| 19 | + "simplevalue": { |
| 20 | + {`(true|false)`, KeywordConstant, nil}, |
| 21 | + {`[01]b`, LiteralNumber, nil}, |
| 22 | + {`-?(0|[1-9]\d*)(\.\d+[eE](\+|-)?\d+|[eE](\+|-)?\d+|\.\d+)`, LiteralNumberFloat, nil}, |
| 23 | + {`(-?\d+)(\.\.)(-?\d+)`, ByGroups(LiteralNumberInteger, Punctuation, LiteralNumberInteger), nil}, |
| 24 | + {`-?(0|[1-9]\d*)`, LiteralNumberInteger, nil}, |
| 25 | + {`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil}, |
| 26 | + {`'[^']+'`, LiteralStringSingle, nil}, |
| 27 | + {`([!#]?)(\w+)`, ByGroups(Punctuation, Text), nil}, |
| 28 | + }, |
| 29 | + "nbtobjectattribute": { |
| 30 | + Include("nbtvalue"), |
| 31 | + {`:`, Punctuation, nil}, |
| 32 | + {`,`, Punctuation, Pop(1)}, |
| 33 | + {`\}`, Punctuation, Pop(2)}, |
| 34 | + }, |
| 35 | + "nbtobjectvalue": { |
| 36 | + {`("(\\\\|\\"|[^"])*"|[a-zA-Z0-9_]+)`, NameTag, Push("nbtobjectattribute")}, |
| 37 | + {`\}`, Punctuation, Pop(1)}, |
| 38 | + }, |
| 39 | + "nbtarrayvalue": { |
| 40 | + Include("nbtvalue"), |
| 41 | + {`,`, Punctuation, nil}, |
| 42 | + {`\]`, Punctuation, Pop(1)}, |
| 43 | + }, |
| 44 | + "nbtvalue": { |
| 45 | + Include("simplevalue"), |
| 46 | + {`\{`, Punctuation, Push("nbtobjectvalue")}, |
| 47 | + {`\[`, Punctuation, Push("nbtarrayvalue")}, |
| 48 | + }, |
| 49 | + "argumentvalue": { |
| 50 | + Include("simplevalue"), |
| 51 | + {`,`, Punctuation, Pop(1)}, |
| 52 | + {`[}\]]`, Punctuation, Pop(2)}, |
| 53 | + }, |
| 54 | + "argumentlist": { |
| 55 | + {`(nbt)(={)`, ByGroups(NameAttribute, Punctuation), Push("nbtobjectvalue")}, |
| 56 | + {`([A-Za-z0-9/_!]+)(={)`, ByGroups(NameAttribute, Punctuation), Push("argumentlist")}, |
| 57 | + {`([A-Za-z0-9/_!]+)(=)`, ByGroups(NameAttribute, Punctuation), Push("argumentvalue")}, |
| 58 | + Include("simplevalue"), |
| 59 | + {`,`, Punctuation, nil}, |
| 60 | + {`[}\]]`, Punctuation, Pop(1)}, |
| 61 | + }, |
| 62 | + "root": { |
| 63 | + {`#.*?\n`, CommentSingle, nil}, |
| 64 | + {Words(`/?`, `\b`, `ability`, `attributes`, `advancement`, |
| 65 | + `ban`, `ban-ip`, `banlist`, `bossbar`, |
| 66 | + `camerashake`, `classroommode`, `clear`, |
| 67 | + `clearspawnpoint`, `clone`, `code`, `collect`, |
| 68 | + `createagent`, `data`, `datapack`, `debug`, |
| 69 | + `defaultgamemode`, `deop`, `destroy`, `detect`, |
| 70 | + `detectredstone`, `difficulty`, `dropall`, |
| 71 | + `effect`, `enchant`, `event`, `execute`, |
| 72 | + `experience`, `fill`, `flog`, `forceload`, |
| 73 | + `function`, `gamemode`, `gamerule`, |
| 74 | + `geteduclientinfo`, `give`, `help`, `item`, |
| 75 | + `immutableworld`, `kick`, `kill`, `list`, |
| 76 | + `locate`, `locatebiome`, `loot`, `me`, `mixer`, |
| 77 | + `mobevent`, `move`, `msg`, `music`, `op`, |
| 78 | + `pardon`, `particle`, `playanimation`, |
| 79 | + `playsound`, `position`, `publish`, |
| 80 | + `raytracefog`, `recipe`, `reload`, `remove`, |
| 81 | + `replaceitem`, `ride`, `save`, `save-all`, |
| 82 | + `save-off`, `save-on`, `say`, `schedule`, |
| 83 | + `scoreboard`, `seed`, `setblock`, |
| 84 | + `setidletimeout`, `setmaxplayers`, |
| 85 | + `setworldspawn`, `spawnpoint`, `spectate`, |
| 86 | + `spreadplayers`, `stop`, `stopsound`, |
| 87 | + `structure`, `summon`, `tag`, `team`, `teammsg`, |
| 88 | + `teleport`, `tell`, `tellraw`, `testfor`, |
| 89 | + `testforblock`, `testforblocks`, `tickingarea`, |
| 90 | + `time`, `title`, `toggledownfall`, `tp`, |
| 91 | + `tpagent`, `transfer`, `transferserver`, |
| 92 | + `trigger`, `turn`, `w`, `weather`, `whitelist`, |
| 93 | + `worldborder`, `worldbuilder`, `wsserver`, `xp`, |
| 94 | + ), KeywordReserved, nil}, |
| 95 | + {Words(``, ``, `@p`, `@r`, `@a`, `@e`, `@s`, `@c`, `@v`), |
| 96 | + KeywordConstant, nil}, |
| 97 | + {`\[`, Punctuation, Push("argumentlist")}, |
| 98 | + {`{`, Punctuation, Push("nbtobjectvalue")}, |
| 99 | + {`~`, NameBuiltin, nil}, |
| 100 | + {`([a-zA-Z_]+:)?[a-zA-Z_]+\b`, Text, nil}, |
| 101 | + {`([a-z]+)(\.)([0-9]+)\b`, ByGroups(Text, Punctuation, LiteralNumber), nil}, |
| 102 | + {`([<>=]|<=|>=)`, Punctuation, nil}, |
| 103 | + Include("simplevalue"), |
| 104 | + {`\s+`, TextWhitespace, nil}, |
| 105 | + }, |
| 106 | + }, |
| 107 | +)) |
0 commit comments