File: jungle.go

package info (click to toggle)
golang-github-alecthomas-chroma 0.10.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 6,652 kB
  • sloc: python: 426; javascript: 79; makefile: 34; sh: 32
file content (54 lines) | stat: -rw-r--r-- 1,492 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package j

import (
	. "github.com/alecthomas/chroma" // nolint
	"github.com/alecthomas/chroma/lexers/internal"
)

var Jungle = internal.Register(MustNewLazyLexer(
	&Config{
		Name:      "Jungle",
		Aliases:   []string{"jungle"},
		Filenames: []string{"*.jungle"},
		MimeTypes: []string{"text/x-jungle"},
	},
	jungleRules,
))

func jungleRules() Rules {
	return Rules{
		"root": {
			{`[^\S\n]+`, Text, nil},
			{`\n`, Text, nil},
			{`#(\n|[\w\W]*?[^#]\n)`, CommentSingle, nil},
			{`^(?=\S)`, None, Push("instruction")},
			{`[\.;\[\]\(\)\$]`, Punctuation, nil},
			{`[a-zA-Z_]\w*`, Name, nil},
		},
		"instruction": {
			{`[^\S\n]+`, Text, nil},
			{`=`, Operator, Push("value")},
			{`(?=\S)`, None, Push("var")},
			Default(Pop(1)),
		},
		"value": {
			{`[^\S\n]+`, Text, nil},
			{`\$\(`, Punctuation, Push("var")},
			{`[;\[\]\(\)\$]`, Punctuation, nil},
			{`#(\n|[\w\W]*?[^#]\n)`, CommentSingle, nil},
			{`[\w_\-\.\/\\]+`, Text, nil},
			Default(Pop(1)),
		},
		"var": {
			{`[^\S\n]+`, Text, nil},
			{`\b(((re)?source|barrel)Path|excludeAnnotations|annotations|lang)\b`, NameBuiltin, nil},
			{`\bbase\b`, NameConstant, nil},
			{`\b(ind|zsm|hrv|ces|dan|dut|eng|fin|fre|deu|gre|hun|ita|nob|po[lr]|rus|sl[ov]|spa|swe|ara|heb|zh[st]|jpn|kor|tha|vie|bul|tur)`, NameConstant, nil},
			{`\b((semi)?round|rectangle)(-\d+x\d+)?\b`, NameConstant, nil},
			{`[\.;\[\]\(\$]`, Punctuation, nil},
			{`\)`, Punctuation, Pop(1)},
			{`[a-zA-Z_]\w*`, Name, nil},
			Default(Pop(1)),
		},
	}
}