m

package
Version: v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2022 License: MIT Imports: 6 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MCFunction = internal.Register(MustNewLazyLexer(
	&Config{
		Name:         "mcfunction",
		Aliases:      []string{"mcfunction"},
		Filenames:    []string{"*.mcfunction"},
		MimeTypes:    []string{},
		NotMultiline: true,
		DotAll:       true,
	},
	func() Rules {
		return Rules{
			"simplevalue": {
				{`(true|false)`, KeywordConstant, nil},
				{`[01]b`, LiteralNumber, nil},
				{`-?(0|[1-9]\d*)(\.\d+[eE](\+|-)?\d+|[eE](\+|-)?\d+|\.\d+)`, LiteralNumberFloat, nil},
				{`(-?\d+)(\.\.)(-?\d+)`, ByGroups(LiteralNumberInteger, Punctuation, LiteralNumberInteger), nil},
				{`-?(0|[1-9]\d*)`, LiteralNumberInteger, nil},
				{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
				{`'[^']+'`, LiteralStringSingle, nil},
				{`([!#]?)(\w+)`, ByGroups(Punctuation, Text), nil},
			},
			"nbtobjectattribute": {
				Include("nbtvalue"),
				{`:`, Punctuation, nil},
				{`,`, Punctuation, Pop(1)},
				{`\}`, Punctuation, Pop(2)},
			},
			"nbtobjectvalue": {
				{`("(\\\\|\\"|[^"])*"|[a-zA-Z0-9_]+)`, NameTag, Push("nbtobjectattribute")},
				{`\}`, Punctuation, Pop(1)},
			},
			"nbtarrayvalue": {
				Include("nbtvalue"),
				{`,`, Punctuation, nil},
				{`\]`, Punctuation, Pop(1)},
			},
			"nbtvalue": {
				Include("simplevalue"),
				{`\{`, Punctuation, Push("nbtobjectvalue")},
				{`\[`, Punctuation, Push("nbtarrayvalue")},
			},
			"argumentvalue": {
				Include("simplevalue"),
				{`,`, Punctuation, Pop(1)},
				{`[}\]]`, Punctuation, Pop(2)},
			},
			"argumentlist": {
				{`(nbt)(={)`, ByGroups(NameAttribute, Punctuation), Push("nbtobjectvalue")},
				{`([A-Za-z0-9/_!]+)(={)`, ByGroups(NameAttribute, Punctuation), Push("argumentlist")},
				{`([A-Za-z0-9/_!]+)(=)`, ByGroups(NameAttribute, Punctuation), Push("argumentvalue")},
				Include("simplevalue"),
				{`,`, Punctuation, nil},
				{`[}\]]`, Punctuation, Pop(1)},
			},
			"root": {
				{`#.*?\n`, CommentSingle, nil},
				{Words(`/?`, `\b`, `ability`, `attributes`, `advancement`,
					`ban`, `ban-ip`, `banlist`, `bossbar`,
					`camerashake`, `classroommode`, `clear`,
					`clearspawnpoint`, `clone`, `code`, `collect`,
					`createagent`, `data`, `datapack`, `debug`,
					`defaultgamemode`, `deop`, `destroy`, `detect`,
					`detectredstone`, `difficulty`, `dropall`,
					`effect`, `enchant`, `event`, `execute`,
					`experience`, `fill`, `flog`, `forceload`,
					`function`, `gamemode`, `gamerule`,
					`geteduclientinfo`, `give`, `help`, `item`,
					`immutableworld`, `kick`, `kill`, `list`,
					`locate`, `locatebiome`, `loot`, `me`, `mixer`,
					`mobevent`, `move`, `msg`, `music`, `op`,
					`pardon`, `particle`, `playanimation`,
					`playsound`, `position`, `publish`,
					`raytracefog`, `recipe`, `reload`, `remove`,
					`replaceitem`, `ride`, `save`, `save-all`,
					`save-off`, `save-on`, `say`, `schedule`,
					`scoreboard`, `seed`, `setblock`,
					`setidletimeout`, `setmaxplayers`,
					`setworldspawn`, `spawnpoint`, `spectate`,
					`spreadplayers`, `stop`, `stopsound`,
					`structure`, `summon`, `tag`, `team`, `teammsg`,
					`teleport`, `tell`, `tellraw`, `testfor`,
					`testforblock`, `testforblocks`, `tickingarea`,
					`time`, `title`, `toggledownfall`, `tp`,
					`tpagent`, `transfer`, `transferserver`,
					`trigger`, `turn`, `w`, `weather`, `whitelist`,
					`worldborder`, `worldbuilder`, `wsserver`, `xp`,
				), KeywordReserved, nil},
				{Words(``, ``, `@p`, `@r`, `@a`, `@e`, `@s`, `@c`, `@v`),
					KeywordConstant, nil},
				{`\[`, Punctuation, Push("argumentlist")},
				{`{`, Punctuation, Push("nbtobjectvalue")},
				{`~`, NameBuiltin, nil},
				{`([a-zA-Z_]+:)?[a-zA-Z_]+\b`, Text, nil},
				{`([a-z]+)(\.)([0-9]+)\b`, ByGroups(Text, Punctuation, LiteralNumber), nil},
				{`([<>=]|<=|>=)`, Punctuation, nil},
				Include("simplevalue"),
				{`\s+`, TextWhitespace, nil},
			},
		}
	},
))

mcfunction lexer.

View Source
var MZN = internal.Register(MustNewLazyLexer(
	&Config{
		Name:      "MiniZinc",
		Aliases:   []string{"minizinc", "MZN", "mzn"},
		Filenames: []string{"*.mzn", "*.dzn", "*.fzn"},
		MimeTypes: []string{"text/minizinc"},
	},
	mznRules,
))

MiniZinc lexer.

View Source
var Makefile = internal.Register(MustNewLazyLexer(
	&Config{
		Name:      "Base Makefile",
		Aliases:   []string{"make", "makefile", "mf", "bsdmake"},
		Filenames: []string{"*.mak", "*.mk", "Makefile", "makefile", "Makefile.*", "GNUmakefile"},
		MimeTypes: []string{"text/x-makefile"},
		EnsureNL:  true,
	},
	makefileRules,
))

Makefile lexer.

View Source
var Mako = internal.Register(MustNewLazyLexer(
	&Config{
		Name:      "Mako",
		Aliases:   []string{"mako"},
		Filenames: []string{"*.mao"},
		MimeTypes: []string{"application/x-mako"},
	},
	makoRules,
))

Mako lexer.

View Source
var Markdown = internal.Register(DelegatingLexer(h.HTML, MustNewLazyLexer(
	&Config{
		Name:      "markdown",
		Aliases:   []string{"md", "mkd"},
		Filenames: []string{"*.md", "*.mkd", "*.markdown"},
		MimeTypes: []string{"text/x-markdown"},
	},
	markdownRules,
)))

Markdown lexer.

View Source
var Mason = internal.Register(MustNewLazyLexer(
	&Config{
		Name:      "Mason",
		Aliases:   []string{"mason"},
		Filenames: []string{"*.m", "*.mhtml", "*.mc", "*.mi", "autohandler", "dhandler"},
		MimeTypes: []string{"application/x-mason"},
		Priority:  0.1,
	},
	masonRules,
))

Mason lexer.

View Source
var Mathematica = internal.Register(MustNewLazyLexer(
	&Config{
		Name:      "Mathematica",
		Aliases:   []string{"mathematica", "mma", "nb"},
		Filenames: []string{"*.nb", "*.cdf", "*.nbp", "*.ma"},
		MimeTypes: []string{"application/mathematica", "application/vnd.wolfram.mathematica", "application/vnd.wolfram.mathematica.package", "application/vnd.wolfram.cdf"},
	},
	mathematicaRules,
))

Mathematica lexer.

View Source
var Matlab = internal.Register(MustNewLazyLexer(
	&Config{
		Name:      "Matlab",
		Aliases:   []string{"matlab"},
		Filenames: []string{"*.m"},
		MimeTypes: []string{"text/matlab"},
	},
	matlabRules,
))

Matlab lexer.

View Source
var Meson = internal.Register(MustNewLazyLexer(
	&Config{
		Name:      "Meson",
		Aliases:   []string{"meson", "meson.build"},
		Filenames: []string{"meson.build", "meson_options.txt"},
		MimeTypes: []string{"text/x-meson"},
	},
	func() Rules {
		return Rules{
			"root": {
				{`#.*?$`, Comment, nil},
				{`'''.*'''`, LiteralStringSingle, nil},
				{`[1-9][0-9]*`, LiteralNumberInteger, nil},
				{`0o[0-7]+`, LiteralNumberOct, nil},
				{`0x[a-fA-F0-9]+`, LiteralNumberHex, nil},
				Include("string"),
				Include("keywords"),
				Include("expr"),
				{`[a-zA-Z_][a-zA-Z_0-9]*`, Name, nil},
				{`\s+`, TextWhitespace, nil},
			},
			"string": {
				{`[']{3}([']{0,2}([^\\']|\\(.|\n)))*[']{3}`, LiteralString, nil},
				{`'.*?(?<!\\)(\\\\)*?'`, LiteralString, nil},
			},
			"keywords": {
				{Words(``, `\b`, `if`, `elif`, `else`, `endif`, `foreach`, `endforeach`, `break`, `continue`), Keyword, nil},
			},
			"expr": {
				{`(in|and|or|not)\b`, OperatorWord, nil},
				{`(\*=|/=|%=|\+]=|-=|==|!=|\+|-|=)`, Operator, nil},
				{`[\[\]{}:().,?]`, Punctuation, nil},
				{Words(``, `\b`, `true`, `false`), KeywordConstant, nil},
				Include("builtins"),
				{Words(``, `\b`, `meson`, `build_machine`, `host_machine`, `target_machine`), NameVariableMagic, nil},
			},
			"builtins": {
				{Words(`(?<!\.)`, `\b`, `add_global_arguments`, `add_global_link_arguments`, `add_languages`, `add_project_arguments`, `add_project_link_arguments`, `add_test_setup`, `assert`, `benchmark`, `both_libraries`, `build_target`, `configuration_data`, `configure_file`, `custom_target`, `declare_dependency`, `dependency`, `disabler`, `environment`, `error`, `executable`, `files`, `find_library`, `find_program`, `generator`, `get_option`, `get_variable`, `include_directories`, `install_data`, `install_headers`, `install_man`, `install_subdir`, `is_disabler`, `is_variable`, `jar`, `join_paths`, `library`, `message`, `project`, `range`, `run_command`, `set_variable`, `shared_library`, `shared_module`, `static_library`, `subdir`, `subdir_done`, `subproject`, `summary`, `test`, `vcs_tag`, `warning`), NameBuiltin, nil},
				{`(?<!\.)import\b`, NameNamespace, nil},
			},
		}
	},
))

Meson lexer.

View Source
var Metal = internal.Register(MustNewLazyLexer(
	&Config{
		Name:      "Metal",
		Aliases:   []string{"metal"},
		Filenames: []string{"*.metal"},
		MimeTypes: []string{"text/x-metal"},
		EnsureNL:  true,
	},
	metalRules,
))

Metal lexer.

View Source
var Mlir = internal.Register(MustNewLazyLexer(
	&Config{
		Name:      "MLIR",
		Aliases:   []string{"mlir"},
		Filenames: []string{"*.mlir"},
		MimeTypes: []string{"text/x-mlir"},
	},
	mlirRules,
))

MLIR lexer.

View Source
var Modula2 = internal.Register(MustNewLazyLexer(
	&Config{
		Name:      "Modula-2",
		Aliases:   []string{"modula2", "m2"},
		Filenames: []string{"*.def", "*.mod"},
		MimeTypes: []string{"text/x-modula2"},
		DotAll:    true,
	},
	modula2Rules,
))

Modula-2 lexer.

View Source
var MonkeyC = internal.Register(MustNewLazyLexer(
	&Config{
		Name:      "MonkeyC",
		Aliases:   []string{"monkeyc"},
		Filenames: []string{"*.mc"},
		MimeTypes: []string{"text/x-monkeyc"},
	},
	monkeyCRules,
))
View Source
var MorrowindScript = internal.Register(MustNewLazyLexer(
	&Config{
		Name:      "MorrowindScript",
		Aliases:   []string{"morrowind", "mwscript"},
		Filenames: []string{},
		MimeTypes: []string{},
	},
	morrowindScriptRules,
))

MorrowindScript lexer.

View Source
var MySQL = internal.Register(MustNewLazyLexer(
	&Config{
		Name:            "MySQL",
		Aliases:         []string{"mysql"},
		Filenames:       []string{"*.sql"},
		MimeTypes:       []string{"text/x-mysql"},
		NotMultiline:    true,
		CaseInsensitive: true,
	},
	mySQLRules,
).SetAnalyser(func(text string) float32 {
	nameBetweenBacktickCount := len(mysqlAnalyserNameBetweenBacktickRe.FindAllString(text, -1))
	nameBetweenBracketCount := len(mysqlAnalyserNameBetweenBracketRe.FindAllString(text, -1))

	var result float32

	dialectNameCount := nameBetweenBacktickCount + nameBetweenBracketCount
	if dialectNameCount >= 1 && nameBetweenBacktickCount >= (2*nameBetweenBracketCount) {

		result += 0.5
	} else if nameBetweenBacktickCount > nameBetweenBracketCount {
		result += 0.2
	} else if nameBetweenBacktickCount > 0 {
		result += 0.1
	}

	return result
}))

MySQL lexer.

View Source
var Myghty = internal.Register(MustNewLazyLexer(
	&Config{
		Name:      "Myghty",
		Aliases:   []string{"myghty"},
		Filenames: []string{"*.myt", "autodelegate"},
		MimeTypes: []string{"application/x-myghty"},
	},
	myghtyRules,
))

Myghty 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