y

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2020 License: MIT Imports: 2 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

View Source
var YAML = internal.Register(MustNewLexer(
	&Config{
		Name:      "YAML",
		Aliases:   []string{"yaml"},
		Filenames: []string{"*.yaml", "*.yml"},
		MimeTypes: []string{"text/x-yaml"},
	},
	Rules{
		"root": {
			Include("whitespace"),
			{`^---`, NameNamespace, nil},
			{`^\.\.\.`, NameNamespace, nil},
			{`[\n?]?\s*- `, Text, nil},
			{`#.*$`, Comment, nil},
			{`!![^\s]+`, CommentPreproc, nil},
			{`&[^\s]+`, CommentPreproc, nil},
			{`\*[^\s]+`, CommentPreproc, nil},
			{`^%include\s+[^\n\r]+`, CommentPreproc, nil},
			{`[>|](?:[+-])?\s(?:^(?:[ \n]{1})+.*\n?)*$`, StringDoc, nil},
			Include("key"),
			Include("value"),
			{`[?:,\[\]]`, Punctuation, nil},
			{`.`, Text, nil},
		},
		"value": {
			{Words(``, `\b`, "true", "True", "TRUE", "false", "False", "FALSE", "null",
				"y", "Y", "yes", "Yes", "YES", "n", "N", "no", "No", "NO",
				"on", "On", "ON", "off", "Off", "OFF"), KeywordConstant, nil},
			{`"(?:\\.|[^"])*"`, StringDouble, nil},
			{`'(?:\\.|[^'])*'`, StringSingle, nil},
			{`\d\d\d\d-\d\d-\d\d([T ]\d\d:\d\d:\d\d(\.\d+)?(Z|\s+[-+]\d+)?)?`, LiteralDate, nil},
			{`\b[+\-]?(0x[\da-f]+|0o[0-7]+|(\d+\.?\d*|\.?\d+)(e[\+\-]?\d+)?|\.inf|\.nan)\b`, Number, nil},
			{`[^\{\}\[\]\?,\:\!\-\*&\@].*`, Literal, nil},
		},
		"key": {
			{`"[^"\n].*": `, NameTag, nil},
			{`(-)( )([^"\n{]*)(:)( )`, ByGroups(Punctuation, Whitespace, NameTag, Punctuation, Whitespace), nil},
			{`([^"\n{]*)(:)( )`, ByGroups(NameTag, Punctuation, Whitespace), nil},
			{`([^"\n{]*)(:)(\n)`, ByGroups(NameTag, Punctuation, Whitespace), nil},
		},
		"whitespace": {
			{`\s+`, Whitespace, nil},
			{`\n+`, Whitespace, nil},
		},
	},
))
View Source
var YANG = internal.Register(MustNewLexer(
	&Config{
		Name:      "YANG",
		Aliases:   []string{"yang"},
		Filenames: []string{"*.yang"},
		MimeTypes: []string{"application/yang"},
	},
	Rules{
		"root": {
			{`\s+`, Whitespace, nil},
			{`[\{\}\;]+`, Punctuation, nil},
			{`(?<![\-\w])(and|or|not|\+|\.)(?![\-\w])`, Operator, nil},

			{`"(?:\\"|[^"])*?"`, StringDouble, nil},
			{`'(?:\\'|[^'])*?'`, StringSingle, nil},

			{`/\*`, CommentMultiline, Push("comments")},
			{`//.*?$`, CommentSingle, nil},

			{`(?:^|(?<=[\s{};]))([\w.-]+)(:)([\w.-]+)(?=[\s{};])`, ByGroups(KeywordNamespace, Punctuation, Text), nil},

			{`([0-9]{4}\-[0-9]{2}\-[0-9]{2})(?=[\s\{\}\;])`, LiteralDate, nil},
			{`([0-9]+\.[0-9]+)(?=[\s\{\}\;])`, NumberFloat, nil},
			{`([0-9]+)(?=[\s\{\}\;])`, NumberInteger, nil},

			{Words(``, `(?=[^\w\-\:])`, `module`, `submodule`), Keyword, nil},

			{Words(``, `(?=[^\w\-\:])`, `belongs-to`, `namespace`, `prefix`, `yang-version`), Keyword, nil},

			{Words(``, `(?=[^\w\-\:])`, `contact`, `description`, `organization`, `reference`, `revision`), Keyword, nil},

			{Words(``, `(?=[^\w\-\:])`, `import`, `include`, `revision-date`), Keyword, nil},

			{Words(``, `(?=[^\w\-\:])`, `action`, `argument`, `augment`, `deviation`, `extension`, `feature`, `grouping`, `identity`, `if-feature`, `input`, `notification`, `output`, `rpc`, `typedef`), Keyword, nil},

			{Words(``, `(?=[^\w\-\:])`, `anydata`, `anyxml`, `case`, `choice`, `config`, `container`, `deviate`, `leaf`, `leaf-list`, `list`, `must`, `presence`, `refine`, `uses`, `when`), Keyword, nil},

			{Words(``, `(?=[^\w\-\:])`, `base`, `bit`, `default`, `enum`, `error-app-tag`, `error-message`, `fraction-digits`, `length`, `max-elements`, `min-elements`, `modifier`, `ordered-by`, `path`, `pattern`, `position`, `range`, `require-instance`, `status`, `type`, `units`, `value`, `yin-element`), Keyword, nil},

			{Words(``, `(?=[^\w\-\:])`, `key`, `mandatory`, `unique`), Keyword, nil},

			{Words(``, `(?=[^\w\-\:])`, `add`, `current`, `delete`, `deprecated`, `false`, `invert-match`, `max`, `min`, `not-supported`, `obsolete`, `replace`, `true`, `unbounded`, `user`), NameClass, nil},

			{Words(``, `(?=[^\w\-\:])`, `binary`, `bits`, `boolean`, `decimal64`, `empty`, `enumeration`, `identityref`, `instance-identifier`, `int16`, `int32`, `int64`, `int8`, `leafref`, `string`, `uint16`, `uint32`, `uint64`, `uint8`, `union`), NameClass, nil},

			{`[^;{}\s\'\"]+`, Text, nil},
		},
		"comments": {
			{`[^*/]`, CommentMultiline, nil},
			{`/\*`, CommentMultiline, Push("comment")},
			{`\*/`, CommentMultiline, Pop(1)},
			{`[*/]`, CommentMultiline, nil},
		},
	},
))

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