package h

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

Index

Variables

var HCL = internal.Register(MustNewLexer(
	&Config{
		Name:      "HCL",
		Aliases:   []string{"hcl"},
		Filenames: []string{"*.hcl"},
		MimeTypes: []string{"application/x-hcl"},
	},
	Rules{
		"root": {
			Include("string"),
			Include("punctuation"),
			Include("curly"),
			Include("basic"),
			Include("whitespace"),
			{`[0-9]+`, LiteralNumber, nil},
		},
		"basic": {
			{Words(`\b`, `\b`, `true`, `false`), KeywordType, nil},
			{`\s*/\*`, CommentMultiline, Push("comment")},
			{`\s*#.*\n`, CommentSingle, nil},
			{`(.*?)(\s*)(=)`, ByGroups(Name, Text, Operator), nil},
			{`\d+`, Number, nil},
			{`\b\w+\b`, Keyword, nil},
			{`\$\{`, LiteralStringInterpol, Push("var_builtin")},
		},
		"function": {
			{`(\s+)(".*")(\s+)`, ByGroups(Text, LiteralString, Text), nil},
			Include("punctuation"),
			Include("curly"),
		},
		"var_builtin": {
			{`\$\{`, LiteralStringInterpol, Push()},
			{Words(`\b`, `\b`, `concat`, `file`, `join`, `lookup`, `element`), NameBuiltin, nil},
			Include("string"),
			Include("punctuation"),
			{`\s+`, Text, nil},
			{`\}`, LiteralStringInterpol, Pop(1)},
		},
		"string": {
			{`(".*")`, ByGroups(LiteralStringDouble), nil},
		},
		"punctuation": {
			{`[\[\](),.]`, Punctuation, nil},
		},
		"curly": {
			{`\{`, TextPunctuation, nil},
			{`\}`, TextPunctuation, nil},
		},
		"comment": {
			{`[^*/]`, CommentMultiline, nil},
			{`/\*`, CommentMultiline, Push()},
			{`\*/`, CommentMultiline, Pop(1)},
			{`[*/]`, CommentMultiline, nil},
		},
		"whitespace": {
			{`\n`, Text, nil},
			{`\s+`, Text, nil},
			{`\\\n`, Text, nil},
		},
	},
))

HCL lexer.

var HTML = internal.Register(MustNewLexer(
	&Config{
		Name:            "HTML",
		Aliases:         []string{"html"},
		Filenames:       []string{"*.html", "*.htm", "*.xhtml", "*.xslt"},
		MimeTypes:       []string{"text/html", "application/xhtml+xml"},
		NotMultiline:    true,
		DotAll:          true,
		CaseInsensitive: true,
	},
	Rules{
		"root": {
			{`[^<&]+`, Text, nil},
			{`&\S*?;`, NameEntity, nil},
			{`\<\!\[CDATA\[.*?\]\]\>`, CommentPreproc, nil},
			{`<!--`, Comment, Push("comment")},
			{`<\?.*?\?>`, CommentPreproc, nil},
			{`<![^>]*>`, CommentPreproc, nil},
			{`(<)(\s*)(script)(\s*)`, ByGroups(Punctuation, Text, NameTag, Text), Push("script-content", "tag")},
			{`(<)(\s*)(style)(\s*)`, ByGroups(Punctuation, Text, NameTag, Text), Push("style-content", "tag")},
			{`(<)(\s*)([\w:.-]+)`, ByGroups(Punctuation, Text, NameTag), Push("tag")},
			{`(<)(\s*)(/)(\s*)([\w:.-]+)(\s*)(>)`, ByGroups(Punctuation, Text, Punctuation, Text, NameTag, Text, Punctuation), nil},
		},
		"comment": {
			{`[^-]+`, Comment, nil},
			{`-->`, Comment, Pop(1)},
			{`-`, Comment, nil},
		},
		"tag": {
			{`\s+`, Text, nil},
			{`([\w:-]+\s*)(=)(\s*)`, ByGroups(NameAttribute, Operator, Text), Push("attr")},
			{`[\w:-]+`, NameAttribute, nil},
			{`(/?)(\s*)(>)`, ByGroups(Punctuation, Text, Punctuation), Pop(1)},
		},
		"script-content": {
			{`(<)(\s*)(/)(\s*)(script)(\s*)(>)`, ByGroups(Punctuation, Text, Punctuation, Text, NameTag, Text, Punctuation), Pop(1)},
			{`.+?(?=<\s*/\s*script\s*>)`, Using(Javascript), nil},
		},
		"style-content": {
			{`(<)(\s*)(/)(\s*)(style)(\s*)(>)`, ByGroups(Punctuation, Text, Punctuation, Text, NameTag, Text, Punctuation), Pop(1)},
			{`.+?(?=<\s*/\s*style\s*>)`, Using(CSS), nil},
		},
		"attr": {
			{`".*?"`, LiteralString, Pop(1)},
			{`'.*?'`, LiteralString, Pop(1)},
			{`[^\s>]+`, LiteralString, Pop(1)},
		},
	},
))

HTML lexer.

var HTTP = internal.Register(httpBodyContentTypeLexer(MustNewLexer(
	&Config{
		Name:         "HTTP",
		Aliases:      []string{"http"},
		Filenames:    []string{},
		MimeTypes:    []string{},
		NotMultiline: true,
		DotAll:       true,
	},
	Rules{
		"root": {
			{`(GET|POST|PUT|DELETE|HEAD|OPTIONS|TRACE|PATCH|CONNECT)( +)([^ ]+)( +)(HTTP)(/)(1\.[01])(\r?\n|\Z)`, ByGroups(NameFunction, Text, NameNamespace, Text, KeywordReserved, Operator, LiteralNumber, Text), Push("headers")},
			{`(HTTP)(/)(1\.[01])( +)(\d{3})( +)([^\r\n]+)(\r?\n|\Z)`, ByGroups(KeywordReserved, Operator, LiteralNumber, Text, LiteralNumber, Text, NameException, Text), Push("headers")},
		},
		"headers": {
			{`([^\s:]+)( *)(:)( *)([^\r\n]+)(\r?\n|\Z)`, EmitterFunc(httpHeaderBlock), nil},
			{`([\t ]+)([^\r\n]+)(\r?\n|\Z)`, EmitterFunc(httpContinuousHeaderBlock), nil},
			{`\r?\n`, Text, Push("content")},
		},
		"content": {
			{`.+`, EmitterFunc(httpContentBlock), nil},
		},
	},
)))

HTTP lexer.

var Handlebars = internal.Register(MustNewLexer(
	&Config{
		Name:      "Handlebars",
		Aliases:   []string{"handlebars"},
		Filenames: []string{"*.handlebars"},
		MimeTypes: []string{},
	},
	Rules{
		"root": {
			{`[^{]+`, Other, nil},
			{`\{\{!.*\}\}`, Comment, nil},
			{`(\{\{\{)(\s*)`, ByGroups(CommentSpecial, Text), Push("tag")},
			{`(\{\{)(\s*)`, ByGroups(CommentPreproc, Text), Push("tag")},
		},
		"tag": {
			{`\s+`, Text, nil},
			{`\}\}\}`, CommentSpecial, Pop(1)},
			{`\}\}`, CommentPreproc, Pop(1)},
			{`([#/]*)(each|if|unless|else|with|log|in(?:line)?)`, ByGroups(Keyword, Keyword), nil},
			{`#\*inline`, Keyword, nil},
			{`([#/])([\w-]+)`, ByGroups(NameFunction, NameFunction), nil},
			{`([\w-]+)(=)`, ByGroups(NameAttribute, Operator), nil},
			{`(>)(\s*)(@partial-block)`, ByGroups(Keyword, Text, Keyword), nil},
			{`(#?>)(\s*)([\w-]+)`, ByGroups(Keyword, Text, NameVariable), nil},
			{`(>)(\s*)(\()`, ByGroups(Keyword, Text, Punctuation), Push("dynamic-partial")},
			Include("generic"),
		},
		"dynamic-partial": {
			{`\s+`, Text, nil},
			{`\)`, Punctuation, Pop(1)},
			{`(lookup)(\s+)(\.|this)(\s+)`, ByGroups(Keyword, Text, NameVariable, Text), nil},
			{`(lookup)(\s+)(\S+)`, ByGroups(Keyword, Text, UsingSelf("variable")), nil},
			{`[\w-]+`, NameFunction, nil},
			Include("generic"),
		},
		"variable": {
			{`[a-zA-Z][\w-]*`, NameVariable, nil},
			{`\.[\w-]+`, NameVariable, nil},
			{`(this\/|\.\/|(\.\.\/)+)[\w-]+`, NameVariable, nil},
		},
		"generic": {
			Include("variable"),
			{`:?"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
			{`:?'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
			{`[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?`, LiteralNumber, nil},
		},
	},
))

Handlebars lexer.

var Haskell = internal.Register(MustNewLexer(
	&Config{
		Name:      "Haskell",
		Aliases:   []string{"haskell", "hs"},
		Filenames: []string{"*.hs"},
		MimeTypes: []string{"text/x-haskell"},
	},
	Rules{
		"root": {
			{`\s+`, Text, nil},
			{`--(?![!#$%&*+./<=>?@^|_~:\\]).*?$`, CommentSingle, nil},
			{`\{-`, CommentMultiline, Push("comment")},
			{`\bimport\b`, KeywordReserved, Push("import")},
			{`\bmodule\b`, KeywordReserved, Push("module")},
			{`\berror\b`, NameException, nil},
			{`\b(case|class|data|default|deriving|do|else|family|if|in|infix[lr]?|instance|let|newtype|of|then|type|where|_)(?!\')\b`, KeywordReserved, nil},
			{`'[^\\]'`, LiteralStringChar, nil},
			{"" /* 1972 byte string literal not displayed */, NameFunction, nil},
			{"" /* 1972 byte string literal not displayed */, Name, nil},
			{"" /* 1926 byte string literal not displayed */, KeywordType, nil},
			{"" /* 1924 byte string literal not displayed */, KeywordType, nil},
			{`(')\[[^\]]*\]`, KeywordType, nil},
			{`(')\([^)]*\)`, KeywordType, nil},
			{`\\(?![:!#$%&*+.\\/<=>?@^|~-]+)`, NameFunction, nil},
			{`(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)`, OperatorWord, nil},
			{`:[:!#$%&*+.\\/<=>?@^|~-]*`, KeywordType, nil},
			{`[:!#$%&*+.\\/<=>?@^|~-]+`, Operator, nil},
			{`\d+[eE][+-]?\d+`, LiteralNumberFloat, nil},
			{`\d+\.\d+([eE][+-]?\d+)?`, LiteralNumberFloat, nil},
			{`0[oO][0-7]+`, LiteralNumberOct, nil},
			{`0[xX][\da-fA-F]+`, LiteralNumberHex, nil},
			{`\d+`, LiteralNumberInteger, nil},
			{`'`, LiteralStringChar, Push("character")},
			{`"`, LiteralString, Push("string")},
			{`\[\]`, KeywordType, nil},
			{`\(\)`, NameBuiltin, nil},
			{"[][(),;`{}]", Punctuation, nil},
		},
		"import": {
			{`\s+`, Text, nil},
			{`"`, LiteralString, Push("string")},
			{`\)`, Punctuation, Pop(1)},
			{`qualified\b`, Keyword, nil},
			{"" /* 3856 byte string literal not displayed */, ByGroups(NameNamespace, Text, Keyword, Text, Name), Pop(1)},
			{"" /* 1944 byte string literal not displayed */, ByGroups(NameNamespace, Text, Keyword, Text, Punctuation), Push("funclist")},
			{"" /* 1931 byte string literal not displayed */, ByGroups(NameNamespace, Text, Punctuation), Push("funclist")},
			{`[\w.]+`, NameNamespace, Pop(1)},
		},
		"module": {
			{`\s+`, Text, nil},
			{"" /* 1931 byte string literal not displayed */, ByGroups(NameNamespace, Text, Punctuation), Push("funclist")},
			{"" /* 1920 byte string literal not displayed */, NameNamespace, Pop(1)},
		},
		"funclist": {
			{`\s+`, Text, nil},
			{"" /* 1917 byte string literal not displayed */, KeywordType, nil},
			{"" /* 1981 byte string literal not displayed */, NameFunction, nil},
			{`--(?![!#$%&*+./<=>?@^|_~:\\]).*?$`, CommentSingle, nil},
			{`\{-`, CommentMultiline, Push("comment")},
			{`,`, Punctuation, nil},
			{`[:!#$%&*+.\\/<=>?@^|~-]+`, Operator, nil},
			{`\(`, Punctuation, Push("funclist", "funclist")},
			{`\)`, Punctuation, Pop(2)},
		},
		"comment": {
			{`[^-{}]+`, CommentMultiline, nil},
			{`\{-`, CommentMultiline, Push()},
			{`-\}`, CommentMultiline, Pop(1)},
			{`[-{}]`, CommentMultiline, nil},
		},
		"character": {
			{`[^\\']'`, LiteralStringChar, Pop(1)},
			{`\\`, LiteralStringEscape, Push("escape")},
			{`'`, LiteralStringChar, Pop(1)},
		},
		"string": {
			{`[^\\"]+`, LiteralString, nil},
			{`\\`, LiteralStringEscape, Push("escape")},
			{`"`, LiteralString, Pop(1)},
		},
		"escape": {
			{`[abfnrtv"\'&\\]`, LiteralStringEscape, Pop(1)},
			{"" /* 1921 byte string literal not displayed */, LiteralStringEscape, Pop(1)},
			{`NUL|SOH|[SE]TX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|S[OI]|DLE|DC[1-4]|NAK|SYN|ETB|CAN|EM|SUB|ESC|[FGRU]S|SP|DEL`, LiteralStringEscape, Pop(1)},
			{`o[0-7]+`, LiteralStringEscape, Pop(1)},
			{`x[\da-fA-F]+`, LiteralStringEscape, Pop(1)},
			{`\d+`, LiteralStringEscape, Pop(1)},
			{`\s+\\`, LiteralStringEscape, Pop(1)},
		},
	},
))

Haskell lexer.

var Haxe = internal.Register(MustNewLexer(
	&Config{
		Name:      "Haxe",
		Aliases:   []string{"hx", "haxe", "hxsl"},
		Filenames: []string{"*.hx", "*.hxsl"},
		MimeTypes: []string{"text/haxe", "text/x-haxe", "text/x-hx"},
		DotAll:    true,
	},
	Rules{ /* 105 elements not displayed */

	},
))

Haxe lexer.

var Hexdump = internal.Register(MustNewLexer(
	&Config{
		Name:      "Hexdump",
		Aliases:   []string{"hexdump"},
		Filenames: []string{},
		MimeTypes: []string{},
	},
	Rules{
		"root": {
			{`\n`, Text, nil},
			Include("offset"),
			{`([0-9A-Ha-h]{2})(\-)([0-9A-Ha-h]{2})`, ByGroups(LiteralNumberHex, Punctuation, LiteralNumberHex), nil},
			{`[0-9A-Ha-h]{2}`, LiteralNumberHex, nil},
			{`(\s{2,3})(\>)(.{16})(\<)$`, ByGroups(Text, Punctuation, LiteralString, Punctuation), Push("bracket-strings")},
			{`(\s{2,3})(\|)(.{16})(\|)$`, ByGroups(Text, Punctuation, LiteralString, Punctuation), Push("piped-strings")},
			{`(\s{2,3})(\>)(.{1,15})(\<)$`, ByGroups(Text, Punctuation, LiteralString, Punctuation), nil},
			{`(\s{2,3})(\|)(.{1,15})(\|)$`, ByGroups(Text, Punctuation, LiteralString, Punctuation), nil},
			{`(\s{2,3})(.{1,15})$`, ByGroups(Text, LiteralString), nil},
			{`(\s{2,3})(.{16}|.{20})$`, ByGroups(Text, LiteralString), Push("nonpiped-strings")},
			{`\s`, Text, nil},
			{`^\*`, Punctuation, nil},
		},
		"offset": {
			{`^([0-9A-Ha-h]+)(:)`, ByGroups(NameLabel, Punctuation), Push("offset-mode")},
			{`^[0-9A-Ha-h]+`, NameLabel, nil},
		},
		"offset-mode": {
			{`\s`, Text, Pop(1)},
			{`[0-9A-Ha-h]+`, NameLabel, nil},
			{`:`, Punctuation, nil},
		},
		"piped-strings": {
			{`\n`, Text, nil},
			Include("offset"),
			{`[0-9A-Ha-h]{2}`, LiteralNumberHex, nil},
			{`(\s{2,3})(\|)(.{1,16})(\|)$`, ByGroups(Text, Punctuation, LiteralString, Punctuation), nil},
			{`\s`, Text, nil},
			{`^\*`, Punctuation, nil},
		},
		"bracket-strings": {
			{`\n`, Text, nil},
			Include("offset"),
			{`[0-9A-Ha-h]{2}`, LiteralNumberHex, nil},
			{`(\s{2,3})(\>)(.{1,16})(\<)$`, ByGroups(Text, Punctuation, LiteralString, Punctuation), nil},
			{`\s`, Text, nil},
			{`^\*`, Punctuation, nil},
		},
		"nonpiped-strings": {
			{`\n`, Text, nil},
			Include("offset"),
			{`([0-9A-Ha-h]{2})(\-)([0-9A-Ha-h]{2})`, ByGroups(LiteralNumberHex, Punctuation, LiteralNumberHex), nil},
			{`[0-9A-Ha-h]{2}`, LiteralNumberHex, nil},
			{`(\s{19,})(.{1,20}?)$`, ByGroups(Text, LiteralString), nil},
			{`(\s{2,3})(.{1,20})$`, ByGroups(Text, LiteralString), nil},
			{`\s`, Text, nil},
			{`^\*`, Punctuation, nil},
		},
	},
))

Hexdump lexer.

var Hy = internal.Register(MustNewLexer(
	&Config{
		Name:      "Hy",
		Aliases:   []string{"hylang"},
		Filenames: []string{"*.hy"},
		MimeTypes: []string{"text/x-hy", "application/x-hy"},
	},
	Rules{
		"root": {
			{`;.*$`, CommentSingle, nil},
			{`[,\s]+`, Text, nil},
			{`-?\d+\.\d+`, LiteralNumberFloat, nil},
			{`-?\d+`, LiteralNumberInteger, nil},
			{`0[0-7]+j?`, LiteralNumberOct, nil},
			{`0[xX][a-fA-F0-9]+`, LiteralNumberHex, nil},
			{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
			{`'(?!#)[\w!$%*+<=>?/.#-]+`, LiteralStringSymbol, nil},
			{`\\(.|[a-z]+)`, LiteralStringChar, nil},
			{`^(\s*)([rRuU]{,2}"""(?:.|\n)*?""")`, ByGroups(Text, LiteralStringDoc), nil},
			{`^(\s*)([rRuU]{,2}'''(?:.|\n)*?''')`, ByGroups(Text, LiteralStringDoc), nil},
			{`::?(?!#)[\w!$%*+<=>?/.#-]+`, LiteralStringSymbol, nil},
			{"~@|[`\\'#^~&@]", Operator, nil},
			Include("py-keywords"),
			Include("py-builtins"),
			{Words(``, ` `, `cond`, `for`, `->`, `->>`, `car`, `cdr`, `first`, `rest`, `let`, `when`, `unless`, `import`, `do`, `progn`, `get`, `slice`, `assoc`, `with-decorator`, `,`, `list_comp`, `kwapply`, `~`, `is`, `in`, `is-not`, `not-in`, `quasiquote`, `unquote`, `unquote-splice`, `quote`, `|`, `<<=`, `>>=`, `foreach`, `while`, `eval-and-compile`, `eval-when-compile`), Keyword, nil},
			{Words(``, ` `, `def`, `defn`, `defun`, `defmacro`, `defclass`, `lambda`, `fn`, `setv`), KeywordDeclaration, nil},
			{Words(``, ` `, `cycle`, `dec`, `distinct`, `drop`, `even?`, `filter`, `inc`, `instance?`, `iterable?`, `iterate`, `iterator?`, `neg?`, `none?`, `nth`, `numeric?`, `odd?`, `pos?`, `remove`, `repeat`, `repeatedly`, `take`, `take_nth`, `take_while`, `zero?`), NameBuiltin, nil},
			{`(?<=\()(?!#)[\w!$%*+<=>?/.#-]+`, NameFunction, nil},
			{`(?!#)[\w!$%*+<=>?/.#-]+`, NameVariable, nil},
			{`(\[|\])`, Punctuation, nil},
			{`(\{|\})`, Punctuation, nil},
			{`(\(|\))`, Punctuation, nil},
		},
		"py-keywords": {
			{Words(``, `\b`, `assert`, `break`, `continue`, `del`, `elif`, `else`, `except`, `exec`, `finally`, `for`, `global`, `if`, `lambda`, `pass`, `print`, `raise`, `return`, `try`, `while`, `yield`, `yield from`, `as`, `with`), Keyword, nil},
		},
		"py-builtins": {
			{Words(`(?<!\.)`, `\b`, `__import__`, `abs`, `all`, `any`, `apply`, `basestring`, `bin`, `bool`, `buffer`, `bytearray`, `bytes`, `callable`, `chr`, `classmethod`, `cmp`, `coerce`, `compile`, `complex`, `delattr`, `dict`, `dir`, `divmod`, `enumerate`, `eval`, `execfile`, `exit`, `file`, `filter`, `float`, `frozenset`, `getattr`, `globals`, `hasattr`, `hash`, `hex`, `id`, `input`, `int`, `intern`, `isinstance`, `issubclass`, `iter`, `len`, `list`, `locals`, `long`, `map`, `max`, `min`, `next`, `object`, `oct`, `open`, `ord`, `pow`, `property`, `range`, `raw_input`, `reduce`, `reload`, `repr`, `reversed`, `round`, `set`, `setattr`, `slice`, `sorted`, `staticmethod`, `str`, `sum`, `super`, `tuple`, `type`, `unichr`, `unicode`, `vars`, `xrange`, `zip`), NameBuiltin, nil},
			{`(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|cls)\b`, NameBuiltinPseudo, nil},
			{Words(`(?<!\.)`, `\b`, `ArithmeticError`, `AssertionError`, `AttributeError`, `BaseException`, `DeprecationWarning`, `EOFError`, `EnvironmentError`, `Exception`, `FloatingPointError`, `FutureWarning`, `GeneratorExit`, `IOError`, `ImportError`, `ImportWarning`, `IndentationError`, `IndexError`, `KeyError`, `KeyboardInterrupt`, `LookupError`, `MemoryError`, `NameError`, `NotImplemented`, `NotImplementedError`, `OSError`, `OverflowError`, `OverflowWarning`, `PendingDeprecationWarning`, `ReferenceError`, `RuntimeError`, `RuntimeWarning`, `StandardError`, `StopIteration`, `SyntaxError`, `SyntaxWarning`, `SystemError`, `SystemExit`, `TabError`, `TypeError`, `UnboundLocalError`, `UnicodeDecodeError`, `UnicodeEncodeError`, `UnicodeError`, `UnicodeTranslateError`, `UnicodeWarning`, `UserWarning`, `ValueError`, `VMSError`, `Warning`, `WindowsError`, `ZeroDivisionError`), NameException, nil},
		},
	},
))

Hy lexer.

Source Files

handlebars.go haskell.go haxe.go hcl.go hexdump.go html.go http.go hy.go

Version
v0.6.4
Published
Jun 17, 2019
Platform
js/wasm
Imports
5 packages
Last checked
4 minutes ago

Tools for package owners.