d

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2018 License: MIT Imports: 3 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Dart = internal.Register(MustNewLexer(
	&Config{
		Name:      "Dart",
		Aliases:   []string{"dart"},
		Filenames: []string{"*.dart"},
		MimeTypes: []string{"text/x-dart"},
		DotAll:    true,
	},
	Rules{
		"root": {
			Include("string_literal"),
			{`#!(.*?)$`, CommentPreproc, nil},
			{`\b(import|export)\b`, Keyword, Push("import_decl")},
			{`\b(library|source|part of|part)\b`, Keyword, nil},
			{`[^\S\n]+`, Text, nil},
			{`//.*?\n`, CommentSingle, nil},
			{`/\*.*?\*/`, CommentMultiline, nil},
			{`\b(class)\b(\s+)`, ByGroups(KeywordDeclaration, Text), Push("class")},
			{`\b(assert|break|case|catch|continue|default|do|else|finally|for|if|in|is|new|return|super|switch|this|throw|try|while)\b`, Keyword, nil},
			{`\b(abstract|async|await|const|extends|factory|final|get|implements|native|operator|set|static|sync|typedef|var|with|yield)\b`, KeywordDeclaration, nil},
			{`\b(bool|double|dynamic|int|num|Object|String|void)\b`, KeywordType, nil},
			{`\b(false|null|true)\b`, KeywordConstant, nil},
			{`[~!%^&*+=|?:<>/-]|as\b`, Operator, nil},
			{`[a-zA-Z_$]\w*:`, NameLabel, nil},
			{`[a-zA-Z_$]\w*`, Name, nil},
			{`[(){}\[\],.;]`, Punctuation, nil},
			{`0[xX][0-9a-fA-F]+`, LiteralNumberHex, nil},
			{`\d+(\.\d*)?([eE][+-]?\d+)?`, LiteralNumber, nil},
			{`\.\d+([eE][+-]?\d+)?`, LiteralNumber, nil},
			{`\n`, Text, nil},
		},
		"class": {
			{`[a-zA-Z_$]\w*`, NameClass, Pop(1)},
		},
		"import_decl": {
			Include("string_literal"),
			{`\s+`, Text, nil},
			{`\b(as|show|hide)\b`, Keyword, nil},
			{`[a-zA-Z_$]\w*`, Name, nil},
			{`\,`, Punctuation, nil},
			{`\;`, Punctuation, Pop(1)},
		},
		"string_literal": {
			{`r"""([\w\W]*?)"""`, LiteralStringDouble, nil},
			{`r'''([\w\W]*?)'''`, LiteralStringSingle, nil},
			{`r"(.*?)"`, LiteralStringDouble, nil},
			{`r'(.*?)'`, LiteralStringSingle, nil},
			{`"""`, LiteralStringDouble, Push("string_double_multiline")},
			{`'''`, LiteralStringSingle, Push("string_single_multiline")},
			{`"`, LiteralStringDouble, Push("string_double")},
			{`'`, LiteralStringSingle, Push("string_single")},
		},
		"string_common": {
			{`\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\{[0-9A-Fa-f]*\}|[a-z'\"$\\])`, LiteralStringEscape, nil},
			{`(\$)([a-zA-Z_]\w*)`, ByGroups(LiteralStringInterpol, Name), nil},
			{`(\$\{)(.*?)(\})`, ByGroups(LiteralStringInterpol, UsingSelf("root"), LiteralStringInterpol), nil},
		},
		"string_double": {
			{`"`, LiteralStringDouble, Pop(1)},
			{`[^"$\\\n]+`, LiteralStringDouble, nil},
			Include("string_common"),
			{`\$+`, LiteralStringDouble, nil},
		},
		"string_double_multiline": {
			{`"""`, LiteralStringDouble, Pop(1)},
			{`[^"$\\]+`, LiteralStringDouble, nil},
			Include("string_common"),
			{`(\$|\")+`, LiteralStringDouble, nil},
		},
		"string_single": {
			{`'`, LiteralStringSingle, Pop(1)},
			{`[^'$\\\n]+`, LiteralStringSingle, nil},
			Include("string_common"),
			{`\$+`, LiteralStringSingle, nil},
		},
		"string_single_multiline": {
			{`'''`, LiteralStringSingle, Pop(1)},
			{`[^\'$\\]+`, LiteralStringSingle, nil},
			Include("string_common"),
			{`(\$|\')+`, LiteralStringSingle, nil},
		},
	},
))

Dart lexer.

View Source
var Diff = internal.Register(MustNewLexer(
	&Config{
		Name:      "Diff",
		Aliases:   []string{"diff", "udiff"},
		EnsureNL:  true,
		Filenames: []string{"*.diff", "*.patch"},
		MimeTypes: []string{"text/x-diff", "text/x-patch"},
	},
	Rules{
		"root": {
			{` .*\n`, Text, nil},
			{`\+.*\n`, GenericInserted, nil},
			{`-.*\n`, GenericDeleted, nil},
			{`!.*\n`, GenericStrong, nil},
			{`@.*\n`, GenericSubheading, nil},
			{`([Ii]ndex|diff).*\n`, GenericHeading, nil},
			{`=.*\n`, GenericHeading, nil},
			{`.*\n`, Text, nil},
		},
	},
))

Diff lexer.

View Source
var DjangoJinja = internal.Register(MustNewLexer(
	&Config{
		Name:      "Django/Jinja",
		Aliases:   []string{"django", "jinja"},
		Filenames: []string{},
		MimeTypes: []string{"application/x-django-templating", "application/x-jinja"},
		DotAll:    true,
	},
	Rules{
		"root": {
			{`[^{]+`, Other, nil},
			{`\{\{`, CommentPreproc, Push("var")},
			{`\{[*#].*?[*#]\}`, Comment, nil},
			{`(\{%)(-?\s*)(comment)(\s*-?)(%\})(.*?)(\{%)(-?\s*)(endcomment)(\s*-?)(%\})`, ByGroups(CommentPreproc, Text, Keyword, Text, CommentPreproc, Comment, CommentPreproc, Text, Keyword, Text, CommentPreproc), nil},
			{`(\{%)(-?\s*)(raw)(\s*-?)(%\})(.*?)(\{%)(-?\s*)(endraw)(\s*-?)(%\})`, ByGroups(CommentPreproc, Text, Keyword, Text, CommentPreproc, Text, CommentPreproc, Text, Keyword, Text, CommentPreproc), nil},
			{`(\{%)(-?\s*)(filter)(\s+)([a-zA-Z_]\w*)`, ByGroups(CommentPreproc, Text, Keyword, Text, NameFunction), Push("block")},
			{`(\{%)(-?\s*)([a-zA-Z_]\w*)`, ByGroups(CommentPreproc, Text, Keyword), Push("block")},
			{`\{`, Other, nil},
		},
		"varnames": {
			{`(\|)(\s*)([a-zA-Z_]\w*)`, ByGroups(Operator, Text, NameFunction), nil},
			{`(is)(\s+)(not)?(\s+)?([a-zA-Z_]\w*)`, ByGroups(Keyword, Text, Keyword, Text, NameFunction), nil},
			{`(_|true|false|none|True|False|None)\b`, KeywordPseudo, nil},
			{`(in|as|reversed|recursive|not|and|or|is|if|else|import|with(?:(?:out)?\s*context)?|scoped|ignore\s+missing)\b`, Keyword, nil},
			{`(loop|block|super|forloop)\b`, NameBuiltin, nil},
			{`[a-zA-Z_][\w-]*`, NameVariable, nil},
			{`\.\w+`, NameVariable, nil},
			{`:?"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
			{`:?'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
			{`([{}()\[\]+\-*/,:~]|[><=]=?)`, Operator, nil},
			{`[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?`, LiteralNumber, nil},
		},
		"var": {
			{`\s+`, Text, nil},
			{`(-?)(\}\})`, ByGroups(Text, CommentPreproc), Pop(1)},
			Include("varnames"),
		},
		"block": {
			{`\s+`, Text, nil},
			{`(-?)(%\})`, ByGroups(Text, CommentPreproc), Pop(1)},
			Include("varnames"),
			{`.`, Punctuation, nil},
		},
	},
))

Django/Jinja lexer.

View Source
var Docker = internal.Register(MustNewLexer(
	&Config{
		Name:            "Docker",
		Aliases:         []string{"docker", "dockerfile"},
		Filenames:       []string{"Dockerfile", "*.docker"},
		MimeTypes:       []string{"text/x-dockerfile-config"},
		CaseInsensitive: true,
	},
	Rules{
		"root": {
			{`^(ONBUILD)(\s+)((?:FROM|MAINTAINER|CMD|EXPOSE|ENV|ADD|ENTRYPOINT|VOLUME|WORKDIR))\b`, ByGroups(NameKeyword, TextWhitespace, Keyword), nil},
			{`^((?:FROM|MAINTAINER|CMD|EXPOSE|ENV|ADD|ENTRYPOINT|VOLUME|WORKDIR))\b(.*)`, ByGroups(Keyword, LiteralString), nil},
			{`#.*`, Comment, nil},
			{`RUN`, Keyword, nil},
			{`(.*\\\n)*.+`, Using(Bash), nil},
		},
	},
))

Docker lexer.

View Source
var Dtd = internal.Register(MustNewLexer(
	&Config{
		Name:      "DTD",
		Aliases:   []string{"dtd"},
		Filenames: []string{"*.dtd"},
		MimeTypes: []string{"application/xml-dtd"},
		DotAll:    true,
	},
	Rules{
		"root": {
			Include("common"),
			{`(<!ELEMENT)(\s+)(\S+)`, ByGroups(Keyword, Text, NameTag), Push("element")},
			{`(<!ATTLIST)(\s+)(\S+)`, ByGroups(Keyword, Text, NameTag), Push("attlist")},
			{`(<!ENTITY)(\s+)(\S+)`, ByGroups(Keyword, Text, NameEntity), Push("entity")},
			{`(<!NOTATION)(\s+)(\S+)`, ByGroups(Keyword, Text, NameTag), Push("notation")},
			{`(<!\[)([^\[\s]+)(\s*)(\[)`, ByGroups(Keyword, NameEntity, Text, Keyword), nil},
			{`(<!DOCTYPE)(\s+)([^>\s]+)`, ByGroups(Keyword, Text, NameTag), nil},
			{`PUBLIC|SYSTEM`, KeywordConstant, nil},
			{`[\[\]>]`, Keyword, nil},
		},
		"common": {
			{`\s+`, Text, nil},
			{`(%|&)[^;]*;`, NameEntity, nil},
			{`<!--`, Comment, Push("comment")},
			{`[(|)*,?+]`, Operator, nil},
			{`"[^"]*"`, LiteralStringDouble, nil},
			{`\'[^\']*\'`, LiteralStringSingle, nil},
		},
		"comment": {
			{`[^-]+`, Comment, nil},
			{`-->`, Comment, Pop(1)},
			{`-`, Comment, nil},
		},
		"element": {
			Include("common"),
			{`EMPTY|ANY|#PCDATA`, KeywordConstant, nil},
			{`[^>\s|()?+*,]+`, NameTag, nil},
			{`>`, Keyword, Pop(1)},
		},
		"attlist": {
			Include("common"),
			{`CDATA|IDREFS|IDREF|ID|NMTOKENS|NMTOKEN|ENTITIES|ENTITY|NOTATION`, KeywordConstant, nil},
			{`#REQUIRED|#IMPLIED|#FIXED`, KeywordConstant, nil},
			{`xml:space|xml:lang`, KeywordReserved, nil},
			{`[^>\s|()?+*,]+`, NameAttribute, nil},
			{`>`, Keyword, Pop(1)},
		},
		"entity": {
			Include("common"),
			{`SYSTEM|PUBLIC|NDATA`, KeywordConstant, nil},
			{`[^>\s|()?+*,]+`, NameEntity, nil},
			{`>`, Keyword, Pop(1)},
		},
		"notation": {
			Include("common"),
			{`SYSTEM|PUBLIC`, KeywordConstant, nil},
			{`[^>\s|()?+*,]+`, NameAttribute, nil},
			{`>`, Keyword, Pop(1)},
		},
	},
))

Dtd lexer.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL