File: io.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 (44 lines) | stat: -rw-r--r-- 1,273 bytes parent folder | download | duplicates (2)
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
package i

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

// Io lexer.
var Io = internal.Register(MustNewLazyLexer(
	&Config{
		Name:      "Io",
		Aliases:   []string{"io"},
		Filenames: []string{"*.io"},
		MimeTypes: []string{"text/x-iosrc"},
	},
	ioRules,
))

func ioRules() Rules {
	return Rules{
		"root": {
			{`\n`, Text, nil},
			{`\s+`, Text, nil},
			{`//(.*?)\n`, CommentSingle, nil},
			{`#(.*?)\n`, CommentSingle, nil},
			{`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil},
			{`/\+`, CommentMultiline, Push("nestedcomment")},
			{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
			{`::=|:=|=|\(|\)|;|,|\*|-|\+|>|<|@|!|/|\||\^|\.|%|&|\[|\]|\{|\}`, Operator, nil},
			{`(clone|do|doFile|doString|method|for|if|else|elseif|then)\b`, Keyword, nil},
			{`(nil|false|true)\b`, NameConstant, nil},
			{`(Object|list|List|Map|args|Sequence|Coroutine|File)\b`, NameBuiltin, nil},
			{`[a-zA-Z_]\w*`, Name, nil},
			{`(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?`, LiteralNumberFloat, nil},
			{`\d+`, LiteralNumberInteger, nil},
		},
		"nestedcomment": {
			{`[^+/]+`, CommentMultiline, nil},
			{`/\+`, CommentMultiline, Push()},
			{`\+/`, CommentMultiline, Pop(1)},
			{`[+/]`, CommentMultiline, nil},
		},
	}
}