package v

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

Index

Variables

var VBNet = internal.Register(MustNewLexer(
	&Config{
		Name:            "VB.net",
		Aliases:         []string{"vb.net", "vbnet"},
		Filenames:       []string{"*.vb", "*.bas"},
		MimeTypes:       []string{"text/x-vbnet", "text/x-vba"},
		CaseInsensitive: true,
	},
	Rules{
		"root": {
			{`^\s*<.*?>`, NameAttribute, nil},
			{`\s+`, Text, nil},
			{`\n`, Text, nil},
			{`rem\b.*?\n`, Comment, nil},
			{`'.*?\n`, Comment, nil},
			{"" /* 146 byte string literal not displayed */, CommentPreproc, nil},
			{`[(){}!#,.:]`, Punctuation, nil},
			{`Option\s+(Strict|Explicit|Compare)\s+(On|Off|Binary|Text)`, KeywordDeclaration, nil},
			{Words(`(?<!\.)`, `\b`, `AddHandler`, `Alias`, `ByRef`, `ByVal`, `Call`, `Case`, `Catch`, `CBool`, `CByte`, `CChar`, `CDate`, `CDec`, `CDbl`, `CInt`, `CLng`, `CObj`, `Continue`, `CSByte`, `CShort`, `CSng`, `CStr`, `CType`, `CUInt`, `CULng`, `CUShort`, `Declare`, `Default`, `Delegate`, `DirectCast`, `Do`, `Each`, `Else`, `ElseIf`, `EndIf`, `Erase`, `Error`, `Event`, `Exit`, `False`, `Finally`, `For`, `Friend`, `Get`, `Global`, `GoSub`, `GoTo`, `Handles`, `If`, `Implements`, `Inherits`, `Interface`, `Let`, `Lib`, `Loop`, `Me`, `MustInherit`, `MustOverride`, `MyBase`, `MyClass`, `Narrowing`, `New`, `Next`, `Not`, `Nothing`, `NotInheritable`, `NotOverridable`, `Of`, `On`, `Operator`, `Option`, `Optional`, `Overloads`, `Overridable`, `Overrides`, `ParamArray`, `Partial`, `Private`, `Protected`, `Public`, `RaiseEvent`, `ReadOnly`, `ReDim`, `RemoveHandler`, `Resume`, `Return`, `Select`, `Set`, `Shadows`, `Shared`, `Single`, `Static`, `Step`, `Stop`, `SyncLock`, `Then`, `Throw`, `To`, `True`, `Try`, `TryCast`, `Wend`, `Using`, `When`, `While`, `Widening`, `With`, `WithEvents`, `WriteOnly`), Keyword, nil},
			{`(?<!\.)End\b`, Keyword, Push("end")},
			{`(?<!\.)(Dim|Const)\b`, Keyword, Push("dim")},
			{`(?<!\.)(Function|Sub|Property)(\s+)`, ByGroups(Keyword, Text), Push("funcname")},
			{`(?<!\.)(Class|Structure|Enum)(\s+)`, ByGroups(Keyword, Text), Push("classname")},
			{`(?<!\.)(Module|Namespace|Imports)(\s+)`, ByGroups(Keyword, Text), Push("namespace")},
			{`(?<!\.)(Boolean|Byte|Char|Date|Decimal|Double|Integer|Long|Object|SByte|Short|Single|String|Variant|UInteger|ULong|UShort)\b`, KeywordType, nil},
			{`(?<!\.)(AddressOf|And|AndAlso|As|GetType|In|Is|IsNot|Like|Mod|Or|OrElse|TypeOf|Xor)\b`, OperatorWord, nil},
			{`&=|[*]=|/=|\\=|\^=|\+=|-=|<<=|>>=|<<|>>|:=|<=|>=|<>|[-&*/\\^+=<>\[\]]`, Operator, nil},
			{`"`, LiteralString, Push("string")},
			{`_\n`, Text, nil},
			{vbName, Name, nil},
			{`#.*?#`, LiteralDate, nil},
			{`(\d+\.\d*|\d*\.\d+)(F[+-]?[0-9]+)?`, LiteralNumberFloat, nil},
			{`\d+([SILDFR]|US|UI|UL)?`, LiteralNumberInteger, nil},
			{`&H[0-9a-f]+([SILDFR]|US|UI|UL)?`, LiteralNumberInteger, nil},
			{`&O[0-7]+([SILDFR]|US|UI|UL)?`, LiteralNumberInteger, nil},
		},
		"string": {
			{`""`, LiteralString, nil},
			{`"C?`, LiteralString, Pop(1)},
			{`[^"]+`, LiteralString, nil},
		},
		"dim": {
			{vbName, NameVariable, Pop(1)},
			Default(Pop(1)),
		},
		"funcname": {
			{vbName, NameFunction, Pop(1)},
		},
		"classname": {
			{vbName, NameClass, Pop(1)},
		},
		"namespace": {
			{vbName, NameNamespace, nil},
			{`\.`, NameNamespace, nil},
			Default(Pop(1)),
		},
		"end": {
			{`\s+`, Text, nil},
			{`(Function|Sub|Property|Class|Structure|Enum|Module|Namespace)\b`, Keyword, Pop(1)},
			Default(Pop(1)),
		},
	},
))

VB.Net lexer.

var VHDL = internal.Register(MustNewLexer(
	&Config{
		Name:            "VHDL",
		Aliases:         []string{"vhdl"},
		Filenames:       []string{"*.vhdl", "*.vhd"},
		MimeTypes:       []string{"text/x-vhdl"},
		CaseInsensitive: true,
	},
	Rules{
		"root": {
			{`\n`, Text, nil},
			{`\s+`, Text, nil},
			{`\\\n`, Text, nil},
			{`--.*?$`, CommentSingle, nil},
			{`'(U|X|0|1|Z|W|L|H|-)'`, LiteralStringChar, nil},
			{`[~!%^&*+=|?:<>/-]`, Operator, nil},
			{`'[a-z_]\w*`, NameAttribute, nil},
			{`[()\[\],.;\']`, Punctuation, nil},
			{`"[^\n\\"]*"`, LiteralString, nil},
			{`(library)(\s+)([a-z_]\w*)`, ByGroups(Keyword, Text, NameNamespace), nil},
			{`(use)(\s+)(entity)`, ByGroups(Keyword, Text, Keyword), nil},
			{`(use)(\s+)([a-z_][\w.]*\.)(all)`, ByGroups(Keyword, Text, NameNamespace, Keyword), nil},
			{`(use)(\s+)([a-z_][\w.]*)`, ByGroups(Keyword, Text, NameNamespace), nil},
			{`(std|ieee)(\.[a-z_]\w*)`, ByGroups(NameNamespace, NameNamespace), nil},
			{Words(``, `\b`, `std`, `ieee`, `work`), NameNamespace, nil},
			{`(entity|component)(\s+)([a-z_]\w*)`, ByGroups(Keyword, Text, NameClass), nil},
			{`(architecture|configuration)(\s+)([a-z_]\w*)(\s+)(of)(\s+)([a-z_]\w*)(\s+)(is)`, ByGroups(Keyword, Text, NameClass, Text, Keyword, Text, NameClass, Text, Keyword), nil},
			{`([a-z_]\w*)(:)(\s+)(process|for)`, ByGroups(NameClass, Operator, Text, Keyword), nil},

			{`(end)(\s+)`, ByGroups(Keyword, Text), Push("endblock")},
			Include("types"),
			Include("keywords"),
			Include("numbers"),
			{`[a-z_]\w*`, Name, nil},
		},
		"endblock": {
			Include("keywords"),
			{`[a-z_]\w*`, NameClass, nil},
			{`(\s+)`, Text, nil},
			{`;`, Punctuation, Pop(1)},
		},
		"types": {
			{Words(``, `\b`, `boolean`, `bit`, `character`, `severity_level`, `integer`, `time`, `delay_length`, `natural`, `positive`, `string`, `bit_vector`, `file_open_kind`, `file_open_status`, `std_ulogic`, `std_ulogic_vector`, `std_logic`, `std_logic_vector`, `signed`, `unsigned`), KeywordType, nil},
		},
		"keywords": {
			{Words(``, `\b`, `abs`, `access`, `after`, `alias`, `all`, `and`, `architecture`, `array`, `assert`, `attribute`, `begin`, `block`, `body`, `buffer`, `bus`, `case`, `component`, `configuration`, `constant`, `disconnect`, `downto`, `else`, `elsif`, `end`, `entity`, `exit`, `file`, `for`, `function`, `generate`, `generic`, `group`, `guarded`, `if`, `impure`, `in`, `inertial`, `inout`, `is`, `label`, `library`, `linkage`, `literal`, `loop`, `map`, `mod`, `nand`, `new`, `next`, `nor`, `not`, `null`, `of`, `on`, `open`, `or`, `others`, `out`, `package`, `port`, `postponed`, `procedure`, `process`, `pure`, `range`, `record`, `register`, `reject`, `rem`, `return`, `rol`, `ror`, `select`, `severity`, `signal`, `shared`, `sla`, `sll`, `sra`, `srl`, `subtype`, `then`, `to`, `transport`, `type`, `units`, `until`, `use`, `variable`, `wait`, `when`, `while`, `with`, `xnor`, `xor`), Keyword, nil},
		},
		"numbers": {
			{`\d{1,2}#[0-9a-f_]+#?`, LiteralNumberInteger, nil},
			{`\d+`, LiteralNumberInteger, nil},
			{`(\d+\.\d*|\.\d+|\d+)E[+-]?\d+`, LiteralNumberFloat, nil},
			{`X"[0-9a-f_]+"`, LiteralNumberHex, nil},
			{`O"[0-7_]+"`, LiteralNumberOct, nil},
			{`B"[01_]+"`, LiteralNumberBin, nil},
		},
	},
))

VHDL lexer.

var Verilog = internal.Register(MustNewLexer(
	&Config{
		Name:      "verilog",
		Aliases:   []string{"verilog", "v"},
		Filenames: []string{"*.v"},
		MimeTypes: []string{"text/x-verilog"},
		EnsureNL:  true,
	},
	Rules{
		"root": {
			{"^\\s*`define", CommentPreproc, Push("macro")},
			{`\n`, Text, nil},
			{`\s+`, Text, nil},
			{`\\\n`, Text, nil},
			{`/(\\\n)?/(\n|(.|\n)*?[^\\]\n)`, CommentSingle, nil},
			{`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil},
			{`[{}#@]`, Punctuation, nil},
			{`L?"`, LiteralString, Push("string")},
			{`L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'`, LiteralStringChar, nil},
			{`(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?`, LiteralNumberFloat, nil},
			{`(\d+\.\d*|\.\d+|\d+[fF])[fF]?`, LiteralNumberFloat, nil},
			{`([0-9]+)|(\'h)[0-9a-fA-F]+`, LiteralNumberHex, nil},
			{`([0-9]+)|(\'b)[01]+`, LiteralNumberBin, nil},
			{`([0-9]+)|(\'d)[0-9]+`, LiteralNumberInteger, nil},
			{`([0-9]+)|(\'o)[0-7]+`, LiteralNumberOct, nil},
			{`\'[01xz]`, LiteralNumber, nil},
			{`\d+[Ll]?`, LiteralNumberInteger, nil},
			{`\*/`, Error, nil},
			{`[~!%^&*+=|?:<>/-]`, Operator, nil},
			{`[()\[\],.;\']`, Punctuation, nil},
			{"`[a-zA-Z_]\\w*", NameConstant, nil},
			{`^(\s*)(package)(\s+)`, ByGroups(Text, KeywordNamespace, Text), nil},
			{`^(\s*)(import)(\s+)`, ByGroups(Text, KeywordNamespace, Text), Push("import")},
			{Words(``, `\b`, `always`, `always_comb`, `always_ff`, `always_latch`, `and`, `assign`, `automatic`, `begin`, `break`, `buf`, `bufif0`, `bufif1`, `case`, `casex`, `casez`, `cmos`, `const`, `continue`, `deassign`, `default`, `defparam`, `disable`, `do`, `edge`, `else`, `end`, `endcase`, `endfunction`, `endgenerate`, `endmodule`, `endpackage`, `endprimitive`, `endspecify`, `endtable`, `endtask`, `enum`, `event`, `final`, `for`, `force`, `forever`, `fork`, `function`, `generate`, `genvar`, `highz0`, `highz1`, `if`, `initial`, `inout`, `input`, `integer`, `join`, `large`, `localparam`, `macromodule`, `medium`, `module`, `nand`, `negedge`, `nmos`, `nor`, `not`, `notif0`, `notif1`, `or`, `output`, `packed`, `parameter`, `pmos`, `posedge`, `primitive`, `pull0`, `pull1`, `pulldown`, `pullup`, `rcmos`, `ref`, `release`, `repeat`, `return`, `rnmos`, `rpmos`, `rtran`, `rtranif0`, `rtranif1`, `scalared`, `signed`, `small`, `specify`, `specparam`, `strength`, `string`, `strong0`, `strong1`, `struct`, `table`, `task`, `tran`, `tranif0`, `tranif1`, `type`, `typedef`, `unsigned`, `var`, `vectored`, `void`, `wait`, `weak0`, `weak1`, `while`, `xnor`, `xor`), Keyword, nil},
			{Words("`", `\b`, `accelerate`, `autoexpand_vectornets`, `celldefine`, `default_nettype`, `else`, `elsif`, `endcelldefine`, `endif`, `endprotect`, `endprotected`, `expand_vectornets`, `ifdef`, `ifndef`, `include`, `noaccelerate`, `noexpand_vectornets`, `noremove_gatenames`, `noremove_netnames`, `nounconnected_drive`, `protect`, `protected`, `remove_gatenames`, `remove_netnames`, `resetall`, `timescale`, `unconnected_drive`, `undef`), CommentPreproc, nil},
			{Words(`\$`, `\b`, `bits`, `bitstoreal`, `bitstoshortreal`, `countdrivers`, `display`, `fclose`, `fdisplay`, `finish`, `floor`, `fmonitor`, `fopen`, `fstrobe`, `fwrite`, `getpattern`, `history`, `incsave`, `input`, `itor`, `key`, `list`, `log`, `monitor`, `monitoroff`, `monitoron`, `nokey`, `nolog`, `printtimescale`, `random`, `readmemb`, `readmemh`, `realtime`, `realtobits`, `reset`, `reset_count`, `reset_value`, `restart`, `rtoi`, `save`, `scale`, `scope`, `shortrealtobits`, `showscopes`, `showvariables`, `showvars`, `sreadmemb`, `sreadmemh`, `stime`, `stop`, `strobe`, `time`, `timeformat`, `write`), NameBuiltin, nil},
			{Words(``, `\b`, `byte`, `shortint`, `int`, `longint`, `integer`, `time`, `bit`, `logic`, `reg`, `supply0`, `supply1`, `tri`, `triand`, `trior`, `tri0`, `tri1`, `trireg`, `uwire`, `wire`, `wand`, `woshortreal`, `real`, `realtime`), KeywordType, nil},
			{`[a-zA-Z_]\w*:(?!:)`, NameLabel, nil},
			{`\$?[a-zA-Z_]\w*`, Name, nil},
		},
		"string": {
			{`"`, LiteralString, Pop(1)},
			{`\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})`, LiteralStringEscape, nil},
			{`[^\\"\n]+`, LiteralString, nil},
			{`\\\n`, LiteralString, nil},
			{`\\`, LiteralString, nil},
		},
		"macro": {
			{`[^/\n]+`, CommentPreproc, nil},
			{`/[*](.|\n)*?[*]/`, CommentMultiline, nil},
			{`//.*?\n`, CommentSingle, Pop(1)},
			{`/`, CommentPreproc, nil},
			{`(?<=\\)\n`, CommentPreproc, nil},
			{`\n`, CommentPreproc, Pop(1)},
		},
		"import": {
			{`[\w:]+\*?`, NameNamespace, Pop(1)},
		},
	},
))

Verilog lexer.

var Viml = internal.Register(MustNewLexer(
	&Config{
		Name:      "VimL",
		Aliases:   []string{"vim"},
		Filenames: []string{"*.vim", ".vimrc", ".exrc", ".gvimrc", "_vimrc", "_exrc", "_gvimrc", "vimrc", "gvimrc"},
		MimeTypes: []string{"text/x-vim"},
	},
	Rules{
		"root": {
			{`^([ \t:]*)(py(?:t(?:h(?:o(?:n)?)?)?)?)([ \t]*)(<<)([ \t]*)(.*)((?:\n|.)*)(\6)`, ByGroups(UsingSelf("root"), Keyword, Text, Operator, Text, Text, Using(Python), Text), nil},
			{`^([ \t:]*)(py(?:t(?:h(?:o(?:n)?)?)?)?)([ \t])(.*)`, ByGroups(UsingSelf("root"), Keyword, Text, Using(Python)), nil},
			{`^\s*".*`, Comment, nil},
			{`[ \t]+`, Text, nil},
			{`/(\\\\|\\/|[^\n/])*/`, LiteralStringRegex, nil},
			{`"(\\\\|\\"|[^\n"])*"`, LiteralStringDouble, nil},
			{`'(''|[^\n'])*'`, LiteralStringSingle, nil},
			{`(?<=\s)"[^\-:.%#=*].*`, Comment, nil},
			{`-?\d+`, LiteralNumber, nil},
			{`#[0-9a-f]{6}`, LiteralNumberHex, nil},
			{`^:`, Punctuation, nil},
			{`[()<>+=!|,~-]`, Punctuation, nil},
			{`\b(let|if|else|endif|elseif|fun|function|endfunction)\b`, Keyword, nil},
			{`\b(NONE|bold|italic|underline|dark|light)\b`, NameBuiltin, nil},
			{`\b\w+\b`, NameOther, nil},
			{`.`, Text, nil},
		},
	},
))

Viml lexer.

var Vue = internal.Register(MustNewLexer(
	&Config{
		Name:      "vue",
		Aliases:   []string{"vue", "vuejs"},
		Filenames: []string{"*.vue"},
		MimeTypes: []string{"text/x-vue", "application/x-vue"},
		DotAll:    true,
	},
	Rules{
		"commentsandwhitespace": {
			{`\s+`, Text, nil},
			{`<!--`, Comment, nil},
			{`//.*?\n`, CommentSingle, nil},
			{`/\*.*?\*/`, CommentMultiline, nil},
		},
		"slashstartsregex": {
			Include("commentsandwhitespace"),
			{`/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/([gimuy]+\b|\B)`, LiteralStringRegex, Pop(1)},
			{`(?=/)`, Text, Push("#pop", "badregex")},
			Default(Pop(1)),
		},
		"badregex": {
			{`\n`, Text, Pop(1)},
		},
		"root": {
			Include("vue"),
			{`\A#! ?/.*?\n`, CommentHashbang, nil},
			{`^(?=\s|/|<!--)`, Text, Push("slashstartsregex")},
			Include("commentsandwhitespace"),
			{`(\.\d+|[0-9]+\.[0-9]*)([eE][-+]?[0-9]+)?`, LiteralNumberFloat, nil},
			{`0[bB][01]+`, LiteralNumberBin, nil},
			{`0[oO][0-7]+`, LiteralNumberOct, nil},
			{`0[xX][0-9a-fA-F]+`, LiteralNumberHex, nil},
			{`[0-9]+`, LiteralNumberInteger, nil},
			{`\.\.\.|=>`, Punctuation, nil},
			{`\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?`, Operator, Push("slashstartsregex")},
			{`[{(\[;,]`, Punctuation, Push("slashstartsregex")},
			{`[})\].]`, Punctuation, nil},
			{"" /* 143 byte string literal not displayed */, Keyword, Push("slashstartsregex")},
			{`(var|let|with|function)\b`, KeywordDeclaration, Push("slashstartsregex")},
			{"" /* 232 byte string literal not displayed */, KeywordReserved, nil},
			{`(true|false|null|NaN|Infinity|undefined)\b`, KeywordConstant, nil},
			{"" /* 247 byte string literal not displayed */, NameBuiltin, nil},
			{"" /* 18803 byte string literal not displayed */, NameOther, nil},
			{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
			{`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
			{"`", LiteralStringBacktick, Push("interp")},
		},
		"interp": {
			{"`", LiteralStringBacktick, Pop(1)},
			{`\\\\`, LiteralStringBacktick, nil},
			{"\\\\`", LiteralStringBacktick, nil},
			{`\$\{`, LiteralStringInterpol, Push("interp-inside")},
			{`\$`, LiteralStringBacktick, nil},
			{"[^`\\\\$]+", LiteralStringBacktick, nil},
		},
		"interp-inside": {
			{`\}`, LiteralStringInterpol, Pop(1)},
			Include("root"),
		},
		"vue": {
			{`(<)([\w]+)`, ByGroups(Punctuation, NameTag), Push("tag")},
			{`(<)(/)([\w]+)(>)`, ByGroups(Punctuation, Punctuation, NameTag, Punctuation), nil},
		},
		"tag": {
			{`\s+`, Text, nil},
			{`(-)([\w]+)`, NameTag, nil},
			{`(@[\w]+)(="[\S]+")(>)`, ByGroups(NameTag, LiteralString, Punctuation), nil},
			{`(@[\w]+)(="[\S]+")`, ByGroups(NameTag, LiteralString), nil},
			{`(@[\S]+)(="[\S]+")`, ByGroups(NameTag, LiteralString), nil},
			{`(:[\S]+)(="[\S]+")`, ByGroups(NameTag, LiteralString), nil},
			{`(:)`, Operator, nil},
			{`(v-b-[\S]+)`, NameTag, nil},
			{`(v-[\w]+)(=".+)([:][\w]+)(="[\w]+")(>)`, ByGroups(NameTag, LiteralString, NameTag, LiteralString, Punctuation), nil},
			{`(v-[\w]+)(="[\S]+")(>)`, ByGroups(NameTag, LiteralString, Punctuation), nil},
			{`(v-[\w]+)(>)`, ByGroups(NameTag, Punctuation), nil},
			{`(v-[\w]+)(=".+")(>)`, ByGroups(NameTag, LiteralString, Punctuation), nil},
			{`(<)([\w]+)`, ByGroups(Punctuation, NameTag), nil},
			{`(<)(/)([\w]+)(>)`, ByGroups(Punctuation, Punctuation, NameTag, Punctuation), nil},
			{`([\w]+\s*)(=)(\s*)`, ByGroups(NameAttribute, Operator, Text), Push("attr")},
			{`[{}]+`, Punctuation, nil},
			{`[\w\.]+`, NameAttribute, nil},
			{`(/?)(\s*)(>)`, ByGroups(Punctuation, Text, Punctuation), Pop(1)},
		},
		"attr": {
			{`{`, Punctuation, Push("expression")},
			{`".*?"`, LiteralString, Pop(1)},
			{`'.*?'`, LiteralString, Pop(1)},
			Default(Pop(1)),
		},
		"expression": {
			{`{`, Punctuation, Push()},
			{`}`, Punctuation, Pop(1)},
			Include("root"),
		},
	},
))

Vue lexer.

This was generated from https://github.com/testdrivenio/vue-lexer

Source Files

vb.go verilog.go vhdl.go vim.go vue.go

Version
v0.6.6
Published
Jul 20, 2019
Platform
js/wasm
Imports
3 packages
Last checked
32 minutes ago

Tools for package owners.