package b

import "github.com/alecthomas/chroma/lexers/b"

Index

Variables

var Ballerina = internal.Register(MustNewLexer(
	&Config{
		Name:      "Ballerina",
		Aliases:   []string{"ballerina"},
		Filenames: []string{"*.bal"},
		MimeTypes: []string{"text/x-ballerina"},
		DotAll:    true,
	},
	Rules{
		"root": {
			{`[^\S\n]+`, Text, nil},
			{`//.*?\n`, CommentSingle, nil},
			{`/\*.*?\*/`, CommentMultiline, nil},
			{`(break|catch|continue|done|else|finally|foreach|forever|fork|if|lock|match|return|throw|transaction|try|while)\b`, Keyword, nil},
			{`((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)((?:[^\W\d]|\$)[\w$]*)(\s*)(\()`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil},
			{`@[^\W\d][\w.]*`, NameDecorator, nil},
			{`(annotation|bind|but|endpoint|error|function|object|private|public|returns|service|type|var|with|worker)\b`, KeywordDeclaration, nil},
			{`(boolean|byte|decimal|float|int|json|map|nil|record|string|table|xml)\b`, KeywordType, nil},
			{`(true|false|null)\b`, KeywordConstant, nil},
			{`(import)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
			{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
			{`'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'`, LiteralStringChar, nil},
			{`(\.)((?:[^\W\d]|\$)[\w$]*)`, ByGroups(Operator, NameAttribute), nil},
			{`^\s*([^\W\d]|\$)[\w$]*:`, NameLabel, nil},
			{`([^\W\d]|\$)[\w$]*`, Name, nil},
			{"" /* 270 byte string literal not displayed */, LiteralNumberFloat, nil},
			{`0[xX][0-9a-fA-F][0-9a-fA-F_]*[lL]?`, LiteralNumberHex, nil},
			{`0[bB][01][01_]*[lL]?`, LiteralNumberBin, nil},
			{`0[0-7_]+[lL]?`, LiteralNumberOct, nil},
			{`0|[1-9][0-9_]*[lL]?`, LiteralNumberInteger, nil},
			{`[~^*!%&\[\](){}<>|+=:;,./?-]`, Operator, nil},
			{`\n`, Text, nil},
		},
		"import": {
			{`[\w.]+`, NameNamespace, Pop(1)},
		},
	},
))

Ballerina lexer.

var Bash = internal.Register(MustNewLexer(
	&Config{
		Name:      "Bash",
		Aliases:   []string{"bash", "sh", "ksh", "zsh", "shell"},
		Filenames: []string{"*.sh", "*.ksh", "*.bash", "*.ebuild", "*.eclass", "*.exheres-0", "*.exlib", "*.zsh", "*.zshrc", ".bashrc", "bashrc", ".bash_*", "bash_*", "zshrc", ".zshrc", "PKGBUILD"},
		MimeTypes: []string{"application/x-sh", "application/x-shellscript"},
	},
	Rules{
		"root": {
			Include("basic"),
			{"`", LiteralStringBacktick, Push("backticks")},
			Include("data"),
			Include("interp"),
		},
		"interp": {
			{`\$\(\(`, Keyword, Push("math")},
			{`\$\(`, Keyword, Push("paren")},
			{`\$\{#?`, LiteralStringInterpol, Push("curly")},
			{`\$[a-zA-Z_]\w*`, NameVariable, nil},
			{`\$(?:\d+|[#$?!_*@-])`, NameVariable, nil},
			{`\$`, Text, nil},
		},
		"basic": {
			{`\b(if|fi|else|while|do|done|for|then|return|function|case|select|continue|until|esac|elif)(\s*)\b`, ByGroups(Keyword, Text), nil},
			{"" /* 337 byte string literal not displayed */, NameBuiltin, nil},
			{`\A#!.+\n`, CommentPreproc, nil},
			{`#.*\S`, CommentSingle, nil},
			{`\\[\w\W]`, LiteralStringEscape, nil},
			{`(\b\w+)(\s*)(\+?=)`, ByGroups(NameVariable, Text, Operator), nil},
			{`[\[\]{}()=]`, Operator, nil},
			{`<<<`, Operator, nil},
			{`<<-?\s*(\'?)\\?(\w+)[\w\W]+?\2`, LiteralString, nil},
			{`&&|\|\|`, Operator, nil},
		},
		"data": {
			{`(?s)\$?"(\\\\|\\[0-7]+|\\.|[^"\\$])*"`, LiteralStringDouble, nil},
			{`"`, LiteralStringDouble, Push("string")},
			{`(?s)\$'(\\\\|\\[0-7]+|\\.|[^'\\])*'`, LiteralStringSingle, nil},
			{`(?s)'.*?'`, LiteralStringSingle, nil},
			{`;`, Punctuation, nil},
			{`&`, Punctuation, nil},
			{`\|`, Punctuation, nil},
			{`\s+`, Text, nil},
			{`\d+(?= |$)`, LiteralNumber, nil},
			{"[^=\\s\\[\\]{}()$\"\\'`\\\\<&|;]+", Text, nil},
			{`<`, Text, nil},
		},
		"string": {
			{`"`, LiteralStringDouble, Pop(1)},
			{`(?s)(\\\\|\\[0-7]+|\\.|[^"\\$])+`, LiteralStringDouble, nil},
			Include("interp"),
		},
		"curly": {
			{`\}`, LiteralStringInterpol, Pop(1)},
			{`:-`, Keyword, nil},
			{`\w+`, NameVariable, nil},
			{"[^}:\"\\'`$\\\\]+", Punctuation, nil},
			{`:`, Punctuation, nil},
			Include("root"),
		},
		"paren": {
			{`\)`, Keyword, Pop(1)},
			Include("root"),
		},
		"math": {
			{`\)\)`, Keyword, Pop(1)},
			{`[-+*/%^|&]|\*\*|\|\|`, Operator, nil},
			{`\d+#\d+`, LiteralNumber, nil},
			{`\d+#(?! )`, LiteralNumber, nil},
			{`\d+`, LiteralNumber, nil},
			Include("root"),
		},
		"backticks": {
			{"`", LiteralStringBacktick, Pop(1)},
			Include("root"),
		},
	},
).SetAnalyser(func(text string) float32 {
	if bashAnalyserRe.FindString(text) != "" {
		return 1.0
	}
	return 0.0
}))

Bash lexer.

var Batchfile = internal.Register(MustNewLexer(
	&Config{
		Name:            "Batchfile",
		Aliases:         []string{"bat", "batch", "dosbatch", "winbatch"},
		Filenames:       []string{"*.bat", "*.cmd"},
		MimeTypes:       []string{"application/x-dos-batch"},
		CaseInsensitive: true,
	},
	Rules{
		"root": {
			{`\)((?=\()|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))(?:(?:[^\n\x1a^]|\^[\n\x1a]?[\w\W])*)`, CommentSingle, nil},
			{`(?=((?:(?<=^[^:])|^[^:]?)[\t\v\f\r ,;=\xa0]*)(:))`, Text, Push("follow")},
			{`(?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)`, UsingSelf("text"), nil},
			Include("redirect"),
			{`[\n\x1a]+`, Text, nil},
			{`\(`, Punctuation, Push("root/compound")},
			{`@+`, Punctuation, nil},
			{"" /* 246 byte string literal not displayed */, ByGroups(Keyword, UsingSelf("text")), Push("follow")},
			{"" /* 814 byte string literal not displayed */, ByGroups(Keyword, UsingSelf("text")), Push("follow")},
			{Words(``, `(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(])`, `assoc`, `break`, `cd`, `chdir`, `cls`, `color`, `copy`, `date`, `del`, `dir`, `dpath`, `echo`, `endlocal`, `erase`, `exit`, `ftype`, `keys`, `md`, `mkdir`, `mklink`, `move`, `path`, `pause`, `popd`, `prompt`, `pushd`, `rd`, `ren`, `rename`, `rmdir`, `setlocal`, `shift`, `start`, `time`, `title`, `type`, `ver`, `verify`, `vol`), Keyword, Push("follow")},
			{`(call)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)(:)`, ByGroups(Keyword, UsingSelf("text"), Punctuation), Push("call")},
			{`call(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(])`, Keyword, nil},
			{"" /* 137 byte string literal not displayed */, ByGroups(Keyword, UsingSelf("text"), Keyword), Push("for/f", "for")},
			{"" /* 137 byte string literal not displayed */, ByGroups(Keyword, UsingSelf("text"), Keyword), Push("for/l", "for")},
			{`for(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])(?!\^)`, Keyword, Push("for2", "for")},
			{`(goto(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(]))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)(:?)`, ByGroups(Keyword, UsingSelf("text"), Punctuation), Push("label")},
			{"" /* 291 byte string literal not displayed */, ByGroups(Keyword, UsingSelf("text"), Keyword, UsingSelf("text"), Keyword, UsingSelf("text")), Push("(?", "if")},
			{"" /* 605 byte string literal not displayed */, CommentSingle, Push("follow")},
			{`(set(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(]))((?:(?:\^[\n\x1a]?)?[^\S\n])*)(/a)`, ByGroups(Keyword, UsingSelf("text"), Keyword), Push("arithmetic")},
			{"" /* 222 byte string literal not displayed */, ByGroups(Keyword, UsingSelf("text"), Keyword, UsingSelf("text"), UsingSelf("variable"), Punctuation), Push("follow")},
			Default(Push("follow")),
		},
		"follow": {
			{"" /* 133 byte string literal not displayed */, ByGroups(Text, Punctuation, Text, NameLabel, CommentSingle), nil},
			Include("redirect"),
			{`(?=[\n\x1a])`, Text, Pop(1)},
			{`\|\|?|&&?`, Punctuation, Pop(1)},
			Include("text"),
		},
		"arithmetic": {
			{`0[0-7]+`, LiteralNumberOct, nil},
			{`0x[\da-f]+`, LiteralNumberHex, nil},
			{`\d+`, LiteralNumberInteger, nil},
			{`[(),]+`, Punctuation, nil},
			{`([=+\-*/!~]|%|\^\^)+`, Operator, nil},
			{"" /* 429 byte string literal not displayed */, UsingSelf("variable"), nil},
			{`(?=[\x00|&])`, Text, Pop(1)},
			Include("follow"),
		},
		"call": {
			{`(:?)((?:(?:[^\n\x1a&<>|\t\v\f\r ,;=\xa0+:^]|\^[\n\x1a]?[\w\W])*))`, ByGroups(Punctuation, NameLabel), Pop(1)},
		},
		"label": {
			{"" /* 439 byte string literal not displayed */, ByGroups(NameLabel, CommentSingle), Pop(1)},
		},
		"redirect": {
			{`((?:(?<=[\n\x1a\t\v\f\r ,;=\xa0])\d)?)(>>?&|<&)([\n\x1a\t\v\f\r ,;=\xa0]*)(\d)`, ByGroups(LiteralNumberInteger, Punctuation, Text, LiteralNumberInteger), nil},
			{"" /* 513 byte string literal not displayed */, ByGroups(LiteralNumberInteger, Punctuation, UsingSelf("text")), nil},
		},
		"root/compound": {
			{`\)`, Punctuation, Pop(1)},
			{`(?=((?:(?<=^[^:])|^[^:]?)[\t\v\f\r ,;=\xa0]*)(:))`, Text, Push("follow/compound")},
			{`(?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)`, UsingSelf("text"), nil},
			Include("redirect/compound"),
			{`[\n\x1a]+`, Text, nil},
			{`\(`, Punctuation, Push("root/compound")},
			{`@+`, Punctuation, nil},
			{"" /* 258 byte string literal not displayed */, ByGroups(Keyword, UsingSelf("text")), Push("follow/compound")},
			{"" /* 827 byte string literal not displayed */, ByGroups(Keyword, UsingSelf("text")), Push("follow/compound")},
			{Words(``, `(?:(?=\))|(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(]))`, `assoc`, `break`, `cd`, `chdir`, `cls`, `color`, `copy`, `date`, `del`, `dir`, `dpath`, `echo`, `endlocal`, `erase`, `exit`, `ftype`, `keys`, `md`, `mkdir`, `mklink`, `move`, `path`, `pause`, `popd`, `prompt`, `pushd`, `rd`, `ren`, `rename`, `rmdir`, `setlocal`, `shift`, `start`, `time`, `title`, `type`, `ver`, `verify`, `vol`), Keyword, Push("follow/compound")},
			{`(call)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)(:)`, ByGroups(Keyword, UsingSelf("text"), Punctuation), Push("call/compound")},
			{`call(?:(?=\))|(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(]))`, Keyword, nil},
			{"" /* 159 byte string literal not displayed */, ByGroups(Keyword, UsingSelf("text"), Keyword), Push("for/f", "for")},
			{"" /* 159 byte string literal not displayed */, ByGroups(Keyword, UsingSelf("text"), Keyword), Push("for/l", "for")},
			{`for(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))(?!\^)`, Keyword, Push("for2", "for")},
			{"" /* 129 byte string literal not displayed */, ByGroups(Keyword, UsingSelf("text"), Punctuation), Push("label/compound")},
			{"" /* 324 byte string literal not displayed */, ByGroups(Keyword, UsingSelf("text"), Keyword, UsingSelf("text"), Keyword, UsingSelf("text")), Push("(?", "if")},
			{"" /* 626 byte string literal not displayed */, CommentSingle, Push("follow/compound")},
			{`(set(?:(?=\))|(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(])))((?:(?:\^[\n\x1a]?)?[^\S\n])*)(/a)`, ByGroups(Keyword, UsingSelf("text"), Keyword), Push("arithmetic/compound")},
			{"" /* 234 byte string literal not displayed */, ByGroups(Keyword, UsingSelf("text"), Keyword, UsingSelf("text"), UsingSelf("variable"), Punctuation), Push("follow/compound")},
			Default(Push("follow/compound")),
		},
		"follow/compound": {
			{`(?=\))`, Text, Pop(1)},
			{"" /* 132 byte string literal not displayed */, ByGroups(Text, Punctuation, Text, NameLabel, CommentSingle), nil},
			Include("redirect/compound"),
			{`(?=[\n\x1a])`, Text, Pop(1)},
			{`\|\|?|&&?`, Punctuation, Pop(1)},
			Include("text"),
		},
		"arithmetic/compound": {
			{`(?=\))`, Text, Pop(1)},
			{`0[0-7]+`, LiteralNumberOct, nil},
			{`0x[\da-f]+`, LiteralNumberHex, nil},
			{`\d+`, LiteralNumberInteger, nil},
			{`[(),]+`, Punctuation, nil},
			{`([=+\-*/!~]|%|\^\^)+`, Operator, nil},
			{"" /* 427 byte string literal not displayed */, UsingSelf("variable"), nil},
			{`(?=[\x00|&])`, Text, Pop(1)},
			Include("follow"),
		},
		"call/compound": {
			{`(?=\))`, Text, Pop(1)},
			{`(:?)((?:(?:[^\n\x1a&<>|\t\v\f\r ,;=\xa0+:^)]|\^[\n\x1a]?[^)])*))`, ByGroups(Punctuation, NameLabel), Pop(1)},
		},
		"label/compound": {
			{`(?=\))`, Text, Pop(1)},
			{"" /* 437 byte string literal not displayed */, ByGroups(NameLabel, CommentSingle), Pop(1)},
		},
		"redirect/compound": {
			{`((?:(?<=[\n\x1a\t\v\f\r ,;=\xa0])\d)?)(>>?&|<&)([\n\x1a\t\v\f\r ,;=\xa0]*)(\d)`, ByGroups(LiteralNumberInteger, Punctuation, Text, LiteralNumberInteger), nil},
			{"" /* 514 byte string literal not displayed */, ByGroups(LiteralNumberInteger, Punctuation, UsingSelf("text")), nil},
		},
		"variable-or-escape": {
			{"" /* 300 byte string literal not displayed */, NameVariable, nil},
			{`%%|\^[\n\x1a]?(\^!|[\w\W])`, LiteralStringEscape, nil},
		},
		"string": {
			{`"`, LiteralStringDouble, Pop(1)},
			{"" /* 300 byte string literal not displayed */, NameVariable, nil},
			{`\^!|%%`, LiteralStringEscape, nil},
			{`[^"%^\n\x1a]+|[%^]`, LiteralStringDouble, nil},
			Default(Pop(1)),
		},
		"sqstring": {
			Include("variable-or-escape"),
			{`[^%]+|%`, LiteralStringSingle, nil},
		},
		"bqstring": {
			Include("variable-or-escape"),
			{`[^%]+|%`, LiteralStringBacktick, nil},
		},
		"text": {
			{`"`, LiteralStringDouble, Push("string")},
			Include("variable-or-escape"),
			{`[^"%^\n\x1a&<>|\t\v\f\r ,;=\xa0\d)]+|.`, Text, nil},
		},
		"variable": {
			{`"`, LiteralStringDouble, Push("string")},
			Include("variable-or-escape"),
			{`[^"%^\n\x1a]+|.`, NameVariable, nil},
		},
		"for": {
			{`((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(in)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(\()`, ByGroups(UsingSelf("text"), Keyword, UsingSelf("text"), Punctuation), Pop(1)},
			Include("follow"),
		},
		"for2": {
			{`\)`, Punctuation, nil},
			{`((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(do(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))`, ByGroups(UsingSelf("text"), Keyword), Pop(1)},
			{`[\n\x1a]+`, Text, nil},
			Include("follow"),
		},
		"for/f": {
			{"" /* 348 byte string literal not displayed */, ByGroups(LiteralStringDouble, UsingSelf("string"), Text, Punctuation), nil},
			{`"`, LiteralStringDouble, Push("#pop", "for2", "string")},
			{"" /* 351 byte string literal not displayed */, ByGroups(UsingSelf("sqstring"), Text, Punctuation), nil},
			{"" /* 398 byte string literal not displayed */, ByGroups(UsingSelf("bqstring"), Text, Punctuation), nil},
			Include("for2"),
		},
		"for/l": {
			{`-?\d+`, LiteralNumberInteger, nil},
			Include("for2"),
		},
		"if": {
			{`((?:cmdextversion|errorlevel)(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(\d+)`, ByGroups(Keyword, UsingSelf("text"), LiteralNumberInteger), Pop(1)},
			{"" /* 501 byte string literal not displayed */, ByGroups(Keyword, UsingSelf("text"), UsingSelf("variable")), Pop(1)},
			{"" /* 497 byte string literal not displayed */, ByGroups(Keyword, UsingSelf("text")), Pop(1)},
			{"" /* 259 byte string literal not displayed */, ByGroups(UsingSelf("arithmetic"), OperatorWord, UsingSelf("arithmetic")), Pop(1)},
			{"" /* 408 byte string literal not displayed */, UsingSelf("text"), Push("#pop", "if2")},
		},
		"if2": {
			{"" /* 502 byte string literal not displayed */, ByGroups(UsingSelf("text"), Operator, UsingSelf("text")), Pop(1)},
			{"" /* 525 byte string literal not displayed */, ByGroups(UsingSelf("text"), OperatorWord, UsingSelf("text")), Pop(1)},
		},
		"(?": {
			{`(?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)`, UsingSelf("text"), nil},
			{`\(`, Punctuation, Push("#pop", "else?", "root/compound")},
			Default(Pop(1)),
		},
		"else?": {
			{`(?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)`, UsingSelf("text"), nil},
			{`else(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])`, Keyword, Pop(1)},
			Default(Pop(1)),
		},
	},
))

Batchfile lexer.

var Bibtex = internal.Register(MustNewLexer(
	&Config{
		Name:            "BibTeX",
		Aliases:         []string{"bib", "bibtex"},
		Filenames:       []string{"*.bib"},
		MimeTypes:       []string{"text/x-bibtex"},
		NotMultiline:    true,
		CaseInsensitive: true,
	},
	Rules{
		"root": {
			Include("whitespace"),
			{`@comment`, Comment, nil},
			{`@preamble`, NameClass, Push("closing-brace", "value", "opening-brace")},
			{`@string`, NameClass, Push("closing-brace", "field", "opening-brace")},
			{"@[a-z_@!$&*+\\-./:;<>?\\[\\\\\\]^`|~][\\w@!$&*+\\-./:;<>?\\[\\\\\\]^`|~]*", NameClass, Push("closing-brace", "command-body", "opening-brace")},
			{`.+`, Comment, nil},
		},
		"opening-brace": {
			Include("whitespace"),
			{`[{(]`, Punctuation, Pop(1)},
		},
		"closing-brace": {
			Include("whitespace"),
			{`[})]`, Punctuation, Pop(1)},
		},
		"command-body": {
			Include("whitespace"),
			{`[^\s\,\}]+`, NameLabel, Push("#pop", "fields")},
		},
		"fields": {
			Include("whitespace"),
			{`,`, Punctuation, Push("field")},
			Default(Pop(1)),
		},
		"field": {
			Include("whitespace"),
			{"[a-z_@!$&*+\\-./:;<>?\\[\\\\\\]^`|~][\\w@!$&*+\\-./:;<>?\\[\\\\\\]^`|~]*", NameAttribute, Push("value", "=")},
			Default(Pop(1)),
		},
		"=": {
			Include("whitespace"),
			{`=`, Punctuation, Pop(1)},
		},
		"value": {
			Include("whitespace"),
			{"[a-z_@!$&*+\\-./:;<>?\\[\\\\\\]^`|~][\\w@!$&*+\\-./:;<>?\\[\\\\\\]^`|~]*", NameVariable, nil},
			{`"`, LiteralString, Push("quoted-string")},
			{`\{`, LiteralString, Push("braced-string")},
			{`[\d]+`, LiteralNumber, nil},
			{`#`, Punctuation, nil},
			Default(Pop(1)),
		},
		"quoted-string": {
			{`\{`, LiteralString, Push("braced-string")},
			{`"`, LiteralString, Pop(1)},
			{`[^\{\"]+`, LiteralString, nil},
		},
		"braced-string": {
			{`\{`, LiteralString, Push()},
			{`\}`, LiteralString, Pop(1)},
			{`[^\{\}]+`, LiteralString, nil},
		},
		"whitespace": {
			{`\s+`, Text, nil},
		},
	},
))

Bibtex lexer.

var Blitzbasic = internal.Register(MustNewLexer(
	&Config{
		Name:            "BlitzBasic",
		Aliases:         []string{"blitzbasic", "b3d", "bplus"},
		Filenames:       []string{"*.bb", "*.decls"},
		MimeTypes:       []string{"text/x-bb"},
		CaseInsensitive: true,
	},
	Rules{
		"root": {
			{`[ \t]+`, Text, nil},
			{`;.*?\n`, CommentSingle, nil},
			{`"`, LiteralStringDouble, Push("string")},
			{`[0-9]+\.[0-9]*(?!\.)`, LiteralNumberFloat, nil},
			{`\.[0-9]+(?!\.)`, LiteralNumberFloat, nil},
			{`[0-9]+`, LiteralNumberInteger, nil},
			{`\$[0-9a-f]+`, LiteralNumberHex, nil},
			{`\%[10]+`, LiteralNumberBin, nil},
			{Words(`\b`, `\b`, `Shl`, `Shr`, `Sar`, `Mod`, `Or`, `And`, `Not`, `Abs`, `Sgn`, `Handle`, `Int`, `Float`, `Str`, `First`, `Last`, `Before`, `After`), Operator, nil},
			{`([+\-*/~=<>^])`, Operator, nil},
			{`[(),:\[\]\\]`, Punctuation, nil},
			{`\.([ \t]*)([a-z]\w*)`, NameLabel, nil},
			{`\b(New)\b([ \t]+)([a-z]\w*)`, ByGroups(KeywordReserved, Text, NameClass), nil},
			{`\b(Gosub|Goto)\b([ \t]+)([a-z]\w*)`, ByGroups(KeywordReserved, Text, NameLabel), nil},
			{`\b(Object)\b([ \t]*)([.])([ \t]*)([a-z]\w*)\b`, ByGroups(Operator, Text, Punctuation, Text, NameClass), nil},
			{`\b([a-z]\w*)(?:([ \t]*)(@{1,2}|[#$%])|([ \t]*)([.])([ \t]*)(?:([a-z]\w*)))?\b([ \t]*)(\()`, ByGroups(NameFunction, Text, KeywordType, Text, Punctuation, Text, NameClass, Text, Punctuation), nil},
			{`\b(Function)\b([ \t]+)([a-z]\w*)(?:([ \t]*)(@{1,2}|[#$%])|([ \t]*)([.])([ \t]*)(?:([a-z]\w*)))?`, ByGroups(KeywordReserved, Text, NameFunction, Text, KeywordType, Text, Punctuation, Text, NameClass), nil},
			{`\b(Type)([ \t]+)([a-z]\w*)`, ByGroups(KeywordReserved, Text, NameClass), nil},
			{`\b(Pi|True|False|Null)\b`, KeywordConstant, nil},
			{`\b(Local|Global|Const|Field|Dim)\b`, KeywordDeclaration, nil},
			{Words(`\b`, `\b`, `End`, `Return`, `Exit`, `Chr`, `Len`, `Asc`, `New`, `Delete`, `Insert`, `Include`, `Function`, `Type`, `If`, `Then`, `Else`, `ElseIf`, `EndIf`, `For`, `To`, `Next`, `Step`, `Each`, `While`, `Wend`, `Repeat`, `Until`, `Forever`, `Select`, `Case`, `Default`, `Goto`, `Gosub`, `Data`, `Read`, `Restore`), KeywordReserved, nil},
			{`([a-z]\w*)(?:([ \t]*)(@{1,2}|[#$%])|([ \t]*)([.])([ \t]*)(?:([a-z]\w*)))?`, ByGroups(NameVariable, Text, KeywordType, Text, Punctuation, Text, NameClass), nil},
		},
		"string": {
			{`""`, LiteralStringDouble, nil},
			{`"C?`, LiteralStringDouble, Pop(1)},
			{`[^"]+`, LiteralStringDouble, nil},
		},
	},
))

Blitzbasic lexer.

var Bnf = internal.Register(MustNewLexer(
	&Config{
		Name:      "BNF",
		Aliases:   []string{"bnf"},
		Filenames: []string{"*.bnf"},
		MimeTypes: []string{"text/x-bnf"},
	},
	Rules{
		"root": {
			{`(<)([ -;=?-~]+)(>)`, ByGroups(Punctuation, NameClass, Punctuation), nil},
			{`::=`, Operator, nil},
			{`[^<>:]+`, Text, nil},
			{`.`, Text, nil},
		},
	},
))

Bnf lexer.

var Brainfuck = internal.Register(MustNewLexer(
	&Config{
		Name:      "Brainfuck",
		Aliases:   []string{"brainfuck", "bf"},
		Filenames: []string{"*.bf", "*.b"},
		MimeTypes: []string{"application/x-brainfuck"},
	},
	Rules{
		"common": {
			{`[.,]+`, NameTag, nil},
			{`[+-]+`, NameBuiltin, nil},
			{`[<>]+`, NameVariable, nil},
			{`[^.,+\-<>\[\]]+`, Comment, nil},
		},
		"root": {
			{`\[`, Keyword, Push("loop")},
			{`\]`, Error, nil},
			Include("common"),
		},
		"loop": {
			{`\[`, Keyword, Push()},
			{`\]`, Keyword, Pop(1)},
			Include("common"),
		},
	},
))

Brainfuck lexer.

Source Files

ballerina.go bash.go batch.go bibtex.go blitz.go bnf.go brainfuck.go

Version
v0.7.1
Published
Jan 2, 2020
Platform
js/wasm
Imports
3 packages
Last checked
4 minutes ago

Tools for package owners.