package a

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

Index

Variables

var ANTLR = internal.Register(MustNewLexer(
	&Config{
		Name:      "ANTLR",
		Aliases:   []string{"antlr"},
		Filenames: []string{},
		MimeTypes: []string{},
	},
	Rules{
		"whitespace": {
			{`\s+`, TextWhitespace, nil},
		},
		"comments": {
			{`//.*$`, Comment, nil},
			{`/\*(.|\n)*?\*/`, Comment, nil},
		},
		"root": {
			Include("whitespace"),
			Include("comments"),
			{`(lexer|parser|tree)?(\s*)(grammar\b)(\s*)([A-Za-z]\w*)(;)`, ByGroups(Keyword, TextWhitespace, Keyword, TextWhitespace, NameClass, Punctuation), nil},
			{`options\b`, Keyword, Push("options")},
			{`tokens\b`, Keyword, Push("tokens")},
			{`(scope)(\s*)([A-Za-z]\w*)(\s*)(\{)`, ByGroups(Keyword, TextWhitespace, NameVariable, TextWhitespace, Punctuation), Push("action")},
			{`(catch|finally)\b`, Keyword, Push("exception")},
			{`(@[A-Za-z]\w*)(\s*)(::)?(\s*)([A-Za-z]\w*)(\s*)(\{)`, ByGroups(NameLabel, TextWhitespace, Punctuation, TextWhitespace, NameLabel, TextWhitespace, Punctuation), Push("action")},
			{`((?:protected|private|public|fragment)\b)?(\s*)([A-Za-z]\w*)(!)?`, ByGroups(Keyword, TextWhitespace, NameLabel, Punctuation), Push("rule-alts", "rule-prelims")},
		},
		"exception": {
			{`\n`, TextWhitespace, Pop(1)},
			{`\s`, TextWhitespace, nil},
			Include("comments"),
			{`\[`, Punctuation, Push("nested-arg-action")},
			{`\{`, Punctuation, Push("action")},
		},
		"rule-prelims": {
			Include("whitespace"),
			Include("comments"),
			{`returns\b`, Keyword, nil},
			{`\[`, Punctuation, Push("nested-arg-action")},
			{`\{`, Punctuation, Push("action")},
			{`(throws)(\s+)([A-Za-z]\w*)`, ByGroups(Keyword, TextWhitespace, NameLabel), nil},
			{`(,)(\s*)([A-Za-z]\w*)`, ByGroups(Punctuation, TextWhitespace, NameLabel), nil},
			{`options\b`, Keyword, Push("options")},
			{`(scope)(\s+)(\{)`, ByGroups(Keyword, TextWhitespace, Punctuation), Push("action")},
			{`(scope)(\s+)([A-Za-z]\w*)(\s*)(;)`, ByGroups(Keyword, TextWhitespace, NameLabel, TextWhitespace, Punctuation), nil},
			{`(@[A-Za-z]\w*)(\s*)(\{)`, ByGroups(NameLabel, TextWhitespace, Punctuation), Push("action")},
			{`:`, Punctuation, Pop(1)},
		},
		"rule-alts": {
			Include("whitespace"),
			Include("comments"),
			{`options\b`, Keyword, Push("options")},
			{`:`, Punctuation, nil},
			{`'(\\\\|\\'|[^'])*'`, LiteralString, nil},
			{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
			{`<<([^>]|>[^>])>>`, LiteralString, nil},
			{`\$?[A-Z_]\w*`, NameConstant, nil},
			{`\$?[a-z_]\w*`, NameVariable, nil},
			{`(\+|\||->|=>|=|\(|\)|\.\.|\.|\?|\*|\^|!|\#|~)`, Operator, nil},
			{`,`, Punctuation, nil},
			{`\[`, Punctuation, Push("nested-arg-action")},
			{`\{`, Punctuation, Push("action")},
			{`;`, Punctuation, Pop(1)},
		},
		"tokens": {
			Include("whitespace"),
			Include("comments"),
			{`\{`, Punctuation, nil},
			{`([A-Z]\w*)(\s*)(=)?(\s*)(\'(?:\\\\|\\\'|[^\']*)\')?(\s*)(;)`, ByGroups(NameLabel, TextWhitespace, Punctuation, TextWhitespace, LiteralString, TextWhitespace, Punctuation), nil},
			{`\}`, Punctuation, Pop(1)},
		},
		"options": {
			Include("whitespace"),
			Include("comments"),
			{`\{`, Punctuation, nil},
			{`([A-Za-z]\w*)(\s*)(=)(\s*)([A-Za-z]\w*|\'(?:\\\\|\\\'|[^\']*)\'|[0-9]+|\*)(\s*)(;)`, ByGroups(NameVariable, TextWhitespace, Punctuation, TextWhitespace, Text, TextWhitespace, Punctuation), nil},
			{`\}`, Punctuation, Pop(1)},
		},
		"action": {
			{`([^${}\'"/\\]+|"(\\\\|\\"|[^"])*"|'(\\\\|\\'|[^'])*'|//.*$\n?|/\*(.|\n)*?\*/|/(?!\*)(\\\\|\\/|[^/])*/|\\(?!%)|/)+`, Other, nil},
			{`(\\)(%)`, ByGroups(Punctuation, Other), nil},
			{`(\$[a-zA-Z]+)(\.?)(text|value)?`, ByGroups(NameVariable, Punctuation, NameProperty), nil},
			{`\{`, Punctuation, Push()},
			{`\}`, Punctuation, Pop(1)},
		},
		"nested-arg-action": {
			{`([^$\[\]\'"/]+|"(\\\\|\\"|[^"])*"|'(\\\\|\\'|[^'])*'|//.*$\n?|/\*(.|\n)*?\*/|/(?!\*)(\\\\|\\/|[^/])*/|/)+`, Other, nil},
			{`\[`, Punctuation, Push()},
			{`\]`, Punctuation, Pop(1)},
			{`(\$[a-zA-Z]+)(\.?)(text|value)?`, ByGroups(NameVariable, Punctuation, NameProperty), nil},
			{`(\\\\|\\\]|\\\[|[^\[\]])+`, Other, nil},
		},
	},
))

ANTLR lexer.

var Abap = internal.Register(MustNewLexer(
	&Config{
		Name:            "ABAP",
		Aliases:         []string{"abap"},
		Filenames:       []string{"*.abap", "*.ABAP"},
		MimeTypes:       []string{"text/x-abap"},
		CaseInsensitive: true,
	},
	Rules{
		"common": {
			{`\s+`, Text, nil},
			{`^\*.*$`, CommentSingle, nil},
			{`\".*?\n`, CommentSingle, nil},
			{`##\w+`, CommentSpecial, nil},
		},
		"variable-names": {
			{`<\S+>`, NameVariable, nil},
			{`\w[\w~]*(?:(\[\])|->\*)?`, NameVariable, nil},
		},
		"root": {
			Include("common"),
			{`CALL\s+(?:BADI|CUSTOMER-FUNCTION|FUNCTION)`, Keyword, nil},
			{`(CALL\s+(?:DIALOG|SCREEN|SUBSCREEN|SELECTION-SCREEN|TRANSACTION|TRANSFORMATION))\b`, Keyword, nil},
			{`(FORM|PERFORM)(\s+)(\w+)`, ByGroups(Keyword, Text, NameFunction), nil},
			{`(PERFORM)(\s+)(\()(\w+)(\))`, ByGroups(Keyword, Text, Punctuation, NameVariable, Punctuation), nil},
			{`(MODULE)(\s+)(\S+)(\s+)(INPUT|OUTPUT)`, ByGroups(Keyword, Text, NameFunction, Text, Keyword), nil},
			{`(METHOD)(\s+)([\w~]+)`, ByGroups(Keyword, Text, NameFunction), nil},
			{`(\s+)([\w\-]+)([=\-]>)([\w\-~]+)`, ByGroups(Text, NameVariable, Operator, NameFunction), nil},
			{`(?<=(=|-)>)([\w\-~]+)(?=\()`, NameFunction, nil},
			{`(TEXT)(-)(\d{3})`, ByGroups(Keyword, Punctuation, LiteralNumberInteger), nil},
			{`(TEXT)(-)(\w{3})`, ByGroups(Keyword, Punctuation, NameVariable), nil},
			{"" /* 528 byte string literal not displayed */, Keyword, nil},
			{"" /* 2326 byte string literal not displayed */, Keyword, nil},
			{"" /* 1516 byte string literal not displayed */, Keyword, nil},
			{"" /* 570 byte string literal not displayed */, ByGroups(NameBuiltin, Punctuation), nil},
			{`&[0-9]`, Name, nil},
			{`[0-9]+`, LiteralNumberInteger, nil},
			{"" /* 166 byte string literal not displayed */, OperatorWord, nil},
			Include("variable-names"),
			{`[?*<>=\-+&]`, Operator, nil},
			{`'(''|[^'])*'`, LiteralStringSingle, nil},
			{"`([^`])*`", LiteralStringSingle, nil},
			{`([|}])([^{}|]*?)([|{])`, ByGroups(Punctuation, LiteralStringSingle, Punctuation), nil},
			{`[/;:()\[\],.]`, Punctuation, nil},
			{`(!)(\w+)`, ByGroups(Operator, Name), nil},
		},
	},
))

ABAP lexer.

var Abnf = internal.Register(MustNewLexer(
	&Config{
		Name:      "ABNF",
		Aliases:   []string{"abnf"},
		Filenames: []string{"*.abnf"},
		MimeTypes: []string{"text/x-abnf"},
	},
	Rules{
		"root": {
			{`;.*$`, CommentSingle, nil},
			{`(%[si])?"[^"]*"`, Literal, nil},
			{`%b[01]+\-[01]+\b`, Literal, nil},
			{`%b[01]+(\.[01]+)*\b`, Literal, nil},
			{`%d[0-9]+\-[0-9]+\b`, Literal, nil},
			{`%d[0-9]+(\.[0-9]+)*\b`, Literal, nil},
			{`%x[0-9a-fA-F]+\-[0-9a-fA-F]+\b`, Literal, nil},
			{`%x[0-9a-fA-F]+(\.[0-9a-fA-F]+)*\b`, Literal, nil},
			{`\b[0-9]+\*[0-9]+`, Operator, nil},
			{`\b[0-9]+\*`, Operator, nil},
			{`\b[0-9]+`, Operator, nil},
			{`\*`, Operator, nil},
			{Words(``, `\b`, `ALPHA`, `BIT`, `CHAR`, `CR`, `CRLF`, `CTL`, `DIGIT`, `DQUOTE`, `HEXDIG`, `HTAB`, `LF`, `LWSP`, `OCTET`, `SP`, `VCHAR`, `WSP`), Keyword, nil},
			{`[a-zA-Z][a-zA-Z0-9-]+\b`, NameClass, nil},
			{`(=/|=|/)`, Operator, nil},
			{`[\[\]()]`, Punctuation, nil},
			{`\s+`, Text, nil},
			{`.`, Text, nil},
		},
	},
))

Abnf lexer.

var Actionscript = internal.Register(MustNewLexer(
	&Config{
		Name:         "ActionScript",
		Aliases:      []string{"as", "actionscript"},
		Filenames:    []string{"*.as"},
		MimeTypes:    []string{"application/x-actionscript", "text/x-actionscript", "text/actionscript"},
		NotMultiline: true,
		DotAll:       true,
	},
	Rules{
		"root": {
			{`\s+`, Text, nil},
			{`//.*?\n`, CommentSingle, nil},
			{`/\*.*?\*/`, CommentMultiline, nil},
			{`/(\\\\|\\/|[^/\n])*/[gim]*`, LiteralStringRegex, nil},
			{`[~^*!%&<>|+=:;,/?\\-]+`, Operator, nil},
			{`[{}\[\]();.]+`, Punctuation, nil},
			{Words(``, `\b`, `case`, `default`, `for`, `each`, `in`, `while`, `do`, `break`, `return`, `continue`, `if`, `else`, `throw`, `try`, `catch`, `var`, `with`, `new`, `typeof`, `arguments`, `instanceof`, `this`, `switch`), Keyword, nil},
			{Words(``, `\b`, `class`, `public`, `final`, `internal`, `native`, `override`, `private`, `protected`, `static`, `import`, `extends`, `implements`, `interface`, `intrinsic`, `return`, `super`, `dynamic`, `function`, `const`, `get`, `namespace`, `package`, `set`), KeywordDeclaration, nil},
			{`(true|false|null|NaN|Infinity|-Infinity|undefined|Void)\b`, KeywordConstant, nil},
			{Words(``, `\b`, `Accessibility`, `AccessibilityProperties`, `ActionScriptVersion`, `ActivityEvent`, `AntiAliasType`, `ApplicationDomain`, `AsBroadcaster`, `Array`, `AsyncErrorEvent`, `AVM1Movie`, `BevelFilter`, `Bitmap`, `BitmapData`, `BitmapDataChannel`, `BitmapFilter`, `BitmapFilterQuality`, `BitmapFilterType`, `BlendMode`, `BlurFilter`, `Boolean`, `ByteArray`, `Camera`, `Capabilities`, `CapsStyle`, `Class`, `Color`, `ColorMatrixFilter`, `ColorTransform`, `ContextMenu`, `ContextMenuBuiltInItems`, `ContextMenuEvent`, `ContextMenuItem`, `ConvultionFilter`, `CSMSettings`, `DataEvent`, `Date`, `DefinitionError`, `DeleteObjectSample`, `Dictionary`, `DisplacmentMapFilter`, `DisplayObject`, `DisplacmentMapFilterMode`, `DisplayObjectContainer`, `DropShadowFilter`, `Endian`, `EOFError`, `Error`, `ErrorEvent`, `EvalError`, `Event`, `EventDispatcher`, `EventPhase`, `ExternalInterface`, `FileFilter`, `FileReference`, `FileReferenceList`, `FocusDirection`, `FocusEvent`, `Font`, `FontStyle`, `FontType`, `FrameLabel`, `FullScreenEvent`, `Function`, `GlowFilter`, `GradientBevelFilter`, `GradientGlowFilter`, `GradientType`, `Graphics`, `GridFitType`, `HTTPStatusEvent`, `IBitmapDrawable`, `ID3Info`, `IDataInput`, `IDataOutput`, `IDynamicPropertyOutputIDynamicPropertyWriter`, `IEventDispatcher`, `IExternalizable`, `IllegalOperationError`, `IME`, `IMEConversionMode`, `IMEEvent`, `int`, `InteractiveObject`, `InterpolationMethod`, `InvalidSWFError`, `InvokeEvent`, `IOError`, `IOErrorEvent`, `JointStyle`, `Key`, `Keyboard`, `KeyboardEvent`, `KeyLocation`, `LineScaleMode`, `Loader`, `LoaderContext`, `LoaderInfo`, `LoadVars`, `LocalConnection`, `Locale`, `Math`, `Matrix`, `MemoryError`, `Microphone`, `MorphShape`, `Mouse`, `MouseEvent`, `MovieClip`, `MovieClipLoader`, `Namespace`, `NetConnection`, `NetStatusEvent`, `NetStream`, `NewObjectSample`, `Number`, `Object`, `ObjectEncoding`, `PixelSnapping`, `Point`, `PrintJob`, `PrintJobOptions`, `PrintJobOrientation`, `ProgressEvent`, `Proxy`, `QName`, `RangeError`, `Rectangle`, `ReferenceError`, `RegExp`, `Responder`, `Sample`, `Scene`, `ScriptTimeoutError`, `Security`, `SecurityDomain`, `SecurityError`, `SecurityErrorEvent`, `SecurityPanel`, `Selection`, `Shape`, `SharedObject`, `SharedObjectFlushStatus`, `SimpleButton`, `Socket`, `Sound`, `SoundChannel`, `SoundLoaderContext`, `SoundMixer`, `SoundTransform`, `SpreadMethod`, `Sprite`, `StackFrame`, `StackOverflowError`, `Stage`, `StageAlign`, `StageDisplayState`, `StageQuality`, `StageScaleMode`, `StaticText`, `StatusEvent`, `String`, `StyleSheet`, `SWFVersion`, `SyncEvent`, `SyntaxError`, `System`, `TextColorType`, `TextField`, `TextFieldAutoSize`, `TextFieldType`, `TextFormat`, `TextFormatAlign`, `TextLineMetrics`, `TextRenderer`, `TextSnapshot`, `Timer`, `TimerEvent`, `Transform`, `TypeError`, `uint`, `URIError`, `URLLoader`, `URLLoaderDataFormat`, `URLRequest`, `URLRequestHeader`, `URLRequestMethod`, `URLStream`, `URLVariabeles`, `VerifyError`, `Video`, `XML`, `XMLDocument`, `XMLList`, `XMLNode`, `XMLNodeType`, `XMLSocket`, `XMLUI`), NameBuiltin, nil},
			{Words(``, `\b`, `decodeURI`, `decodeURIComponent`, `encodeURI`, `escape`, `eval`, `isFinite`, `isNaN`, `isXMLName`, `clearInterval`, `fscommand`, `getTimer`, `getURL`, `getVersion`, `parseFloat`, `parseInt`, `setInterval`, `trace`, `updateAfterEvent`, `unescape`), NameFunction, nil},
			{`[$a-zA-Z_]\w*`, NameOther, nil},
			{`[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?`, LiteralNumberFloat, nil},
			{`0x[0-9a-f]+`, LiteralNumberHex, nil},
			{`[0-9]+`, LiteralNumberInteger, nil},
			{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
			{`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
		},
	},
))

Actionscript lexer.

var Actionscript3 = internal.Register(MustNewLexer(
	&Config{
		Name:      "ActionScript 3",
		Aliases:   []string{"as3", "actionscript3"},
		Filenames: []string{"*.as"},
		MimeTypes: []string{"application/x-actionscript3", "text/x-actionscript3", "text/actionscript3"},
		DotAll:    true,
	},
	Rules{
		"root": {
			{`\s+`, Text, nil},
			{`(function\s+)([$a-zA-Z_]\w*)(\s*)(\()`, ByGroups(KeywordDeclaration, NameFunction, Text, Operator), Push("funcparams")},
			{`(var|const)(\s+)([$a-zA-Z_]\w*)(\s*)(:)(\s*)([$a-zA-Z_]\w*(?:\.<\w+>)?)`, ByGroups(KeywordDeclaration, Text, Name, Text, Punctuation, Text, KeywordType), nil},
			{`(import|package)(\s+)((?:[$a-zA-Z_]\w*|\.)+)(\s*)`, ByGroups(Keyword, Text, NameNamespace, Text), nil},
			{`(new)(\s+)([$a-zA-Z_]\w*(?:\.<\w+>)?)(\s*)(\()`, ByGroups(Keyword, Text, KeywordType, Text, Operator), nil},
			{`//.*?\n`, CommentSingle, nil},
			{`/\*.*?\*/`, CommentMultiline, nil},
			{`/(\\\\|\\/|[^\n])*/[gisx]*`, LiteralStringRegex, nil},
			{`(\.)([$a-zA-Z_]\w*)`, ByGroups(Operator, NameAttribute), nil},
			{"" /* 155 byte string literal not displayed */, Keyword, nil},
			{"" /* 182 byte string literal not displayed */, KeywordDeclaration, nil},
			{`(true|false|null|NaN|Infinity|-Infinity|undefined|void)\b`, KeywordConstant, nil},
			{"" /* 205 byte string literal not displayed */, NameFunction, nil},
			{`[$a-zA-Z_]\w*`, Name, nil},
			{`[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?`, LiteralNumberFloat, nil},
			{`0x[0-9a-f]+`, LiteralNumberHex, nil},
			{`[0-9]+`, LiteralNumberInteger, nil},
			{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
			{`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
			{`[~^*!%&<>|+=:;,/?\\{}\[\]().-]+`, Operator, nil},
		},
		"funcparams": {
			{`\s+`, Text, nil},
			{`(\s*)(\.\.\.)?([$a-zA-Z_]\w*)(\s*)(:)(\s*)([$a-zA-Z_]\w*(?:\.<\w+>)?|\*)(\s*)`, ByGroups(Text, Punctuation, Name, Text, Operator, Text, KeywordType, Text), Push("defval")},
			{`\)`, Operator, Push("type")},
		},
		"type": {
			{`(\s*)(:)(\s*)([$a-zA-Z_]\w*(?:\.<\w+>)?|\*)`, ByGroups(Text, Operator, Text, KeywordType), Pop(2)},
			{`\s+`, Text, Pop(2)},
			Default(Pop(2)),
		},
		"defval": {
			{`(=)(\s*)([^(),]+)(\s*)(,?)`, ByGroups(Operator, Text, UsingSelf("root"), Text, Operator), Pop(1)},
			{`,`, Operator, Pop(1)},
			Default(Pop(1)),
		},
	},
))

Actionscript 3 lexer.

var Ada = internal.Register(MustNewLexer(
	&Config{
		Name:            "Ada",
		Aliases:         []string{"ada", "ada95", "ada2005"},
		Filenames:       []string{"*.adb", "*.ads", "*.ada"},
		MimeTypes:       []string{"text/x-ada"},
		CaseInsensitive: true,
	},
	Rules{
		"root": {
			{`[^\S\n]+`, Text, nil},
			{`--.*?\n`, CommentSingle, nil},
			{`[^\S\n]+`, Text, nil},
			{`function|procedure|entry`, KeywordDeclaration, Push("subprogram")},
			{`(subtype|type)(\s+)(\w+)`, ByGroups(KeywordDeclaration, Text, KeywordType), Push("type_def")},
			{`task|protected`, KeywordDeclaration, nil},
			{`(subtype)(\s+)`, ByGroups(KeywordDeclaration, Text), nil},
			{`(end)(\s+)`, ByGroups(KeywordReserved, Text), Push("end")},
			{`(pragma)(\s+)(\w+)`, ByGroups(KeywordReserved, Text, CommentPreproc), nil},
			{`(true|false|null)\b`, KeywordConstant, nil},
			{Words(``, `\b`, `Address`, `Byte`, `Boolean`, `Character`, `Controlled`, `Count`, `Cursor`, `Duration`, `File_Mode`, `File_Type`, `Float`, `Generator`, `Integer`, `Long_Float`, `Long_Integer`, `Long_Long_Float`, `Long_Long_Integer`, `Natural`, `Positive`, `Reference_Type`, `Short_Float`, `Short_Integer`, `Short_Short_Float`, `Short_Short_Integer`, `String`, `Wide_Character`, `Wide_String`), KeywordType, nil},
			{`(and(\s+then)?|in|mod|not|or(\s+else)|rem)\b`, OperatorWord, nil},
			{`generic|private`, KeywordDeclaration, nil},
			{`package`, KeywordDeclaration, Push("package")},
			{`array\b`, KeywordReserved, Push("array_def")},
			{`(with|use)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
			{`(\w+)(\s*)(:)(\s*)(constant)`, ByGroups(NameConstant, Text, Punctuation, Text, KeywordReserved), nil},
			{`<<\w+>>`, NameLabel, nil},
			{`(\w+)(\s*)(:)(\s*)(declare|begin|loop|for|while)`, ByGroups(NameLabel, Text, Punctuation, Text, KeywordReserved), nil},
			{Words(`\b`, `\b`, `abort`, `abs`, `abstract`, `accept`, `access`, `aliased`, `all`, `array`, `at`, `begin`, `body`, `case`, `constant`, `declare`, `delay`, `delta`, `digits`, `do`, `else`, `elsif`, `end`, `entry`, `exception`, `exit`, `interface`, `for`, `goto`, `if`, `is`, `limited`, `loop`, `new`, `null`, `of`, `or`, `others`, `out`, `overriding`, `pragma`, `protected`, `raise`, `range`, `record`, `renames`, `requeue`, `return`, `reverse`, `select`, `separate`, `subtype`, `synchronized`, `task`, `tagged`, `terminate`, `then`, `type`, `until`, `when`, `while`, `xor`), KeywordReserved, nil},
			{`"[^"]*"`, LiteralString, nil},
			Include("attribute"),
			Include("numbers"),
			{`'[^']'`, LiteralStringChar, nil},
			{`(\w+)(\s*|[(,])`, ByGroups(Name, UsingSelf("root")), nil},
			{`(<>|=>|:=|[()|:;,.'])`, Punctuation, nil},
			{`[*<>+=/&-]`, Operator, nil},
			{`\n+`, Text, nil},
		},
		"numbers": {
			{`[0-9_]+#[0-9a-f]+#`, LiteralNumberHex, nil},
			{`[0-9_]+\.[0-9_]*`, LiteralNumberFloat, nil},
			{`[0-9_]+`, LiteralNumberInteger, nil},
		},
		"attribute": {
			{`(')(\w+)`, ByGroups(Punctuation, NameAttribute), nil},
		},
		"subprogram": {
			{`\(`, Punctuation, Push("#pop", "formal_part")},
			{`;`, Punctuation, Pop(1)},
			{`is\b`, KeywordReserved, Pop(1)},
			{`"[^"]+"|\w+`, NameFunction, nil},
			Include("root"),
		},
		"end": {
			{`(if|case|record|loop|select)`, KeywordReserved, nil},
			{`"[^"]+"|[\w.]+`, NameFunction, nil},
			{`\s+`, Text, nil},
			{`;`, Punctuation, Pop(1)},
		},
		"type_def": {
			{`;`, Punctuation, Pop(1)},
			{`\(`, Punctuation, Push("formal_part")},
			{`with|and|use`, KeywordReserved, nil},
			{`array\b`, KeywordReserved, Push("#pop", "array_def")},
			{`record\b`, KeywordReserved, Push("record_def")},
			{`(null record)(;)`, ByGroups(KeywordReserved, Punctuation), Pop(1)},
			Include("root"),
		},
		"array_def": {
			{`;`, Punctuation, Pop(1)},
			{`(\w+)(\s+)(range)`, ByGroups(KeywordType, Text, KeywordReserved), nil},
			Include("root"),
		},
		"record_def": {
			{`end record`, KeywordReserved, Pop(1)},
			Include("root"),
		},
		"import": {
			{`[\w.]+`, NameNamespace, Pop(1)},
			Default(Pop(1)),
		},
		"formal_part": {
			{`\)`, Punctuation, Pop(1)},
			{`\w+`, NameVariable, nil},
			{`,|:[^=]`, Punctuation, nil},
			{`(in|not|null|out|access)\b`, KeywordReserved, nil},
			Include("root"),
		},
		"package": {
			{`body`, KeywordDeclaration, nil},
			{`is\s+new|renames`, KeywordReserved, nil},
			{`is`, KeywordReserved, Pop(1)},
			{`;`, Punctuation, Pop(1)},
			{`\(`, Punctuation, Push("package_instantiation")},
			{`([\w.]+)`, NameClass, nil},
			Include("root"),
		},
		"package_instantiation": {
			{`("[^"]+"|\w+)(\s+)(=>)`, ByGroups(NameVariable, Text, Punctuation), nil},
			{`[\w.\'"]`, Text, nil},
			{`\)`, Punctuation, Pop(1)},
			Include("root"),
		},
	},
))

Ada lexer.

var Angular2 = internal.Register(MustNewLexer(
	&Config{
		Name:      "Angular2",
		Aliases:   []string{"ng2"},
		Filenames: []string{},
		MimeTypes: []string{},
	},
	Rules{
		"root": {
			{`[^{([*#]+`, Other, nil},
			{`(\{\{)(\s*)`, ByGroups(CommentPreproc, Text), Push("ngExpression")},
			{`([([]+)([\w:.-]+)([\])]+)(\s*)(=)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation, Text, Operator, Text), Push("attr")},
			{`([([]+)([\w:.-]+)([\])]+)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation, Text), nil},
			{`([*#])([\w:.-]+)(\s*)(=)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation, Operator), Push("attr")},
			{`([*#])([\w:.-]+)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation), nil},
		},
		"ngExpression": {
			{`\s+(\|\s+)?`, Text, nil},
			{`\}\}`, CommentPreproc, Pop(1)},
			{`:?(true|false)`, LiteralStringBoolean, nil},
			{`:?"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
			{`:?'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
			{`[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?`, LiteralNumber, nil},
			{`[a-zA-Z][\w-]*(\(.*\))?`, NameVariable, nil},
			{`\.[\w-]+(\(.*\))?`, NameVariable, nil},
			{`(\?)(\s*)([^}\s]+)(\s*)(:)(\s*)([^}\s]+)(\s*)`, ByGroups(Operator, Text, LiteralString, Text, Operator, Text, LiteralString, Text), nil},
		},
		"attr": {
			{`".*?"`, LiteralString, Pop(1)},
			{`'.*?'`, LiteralString, Pop(1)},
			{`[^\s>]+`, LiteralString, Pop(1)},
		},
	},
))

Angular2 lexer.

var Apacheconf = internal.Register(MustNewLexer(
	&Config{
		Name:            "ApacheConf",
		Aliases:         []string{"apacheconf", "aconf", "apache"},
		Filenames:       []string{".htaccess", "apache.conf", "apache2.conf"},
		MimeTypes:       []string{"text/x-apacheconf"},
		CaseInsensitive: true,
	},
	Rules{
		"root": {
			{`\s+`, Text, nil},
			{`(#.*?)$`, Comment, nil},
			{`(<[^\s>]+)(?:(\s+)(.*?))?(>)`, ByGroups(NameTag, Text, LiteralString, NameTag), nil},
			{`([a-z]\w*)(\s+)`, ByGroups(NameBuiltin, Text), Push("value")},
			{`\.+`, Text, nil},
		},
		"value": {
			{`\\\n`, Text, nil},
			{`$`, Text, Pop(1)},
			{`\\`, Text, nil},
			{`[^\S\n]+`, Text, nil},
			{`\d+\.\d+\.\d+\.\d+(?:/\d+)?`, LiteralNumber, nil},
			{`\d+`, LiteralNumber, nil},
			{`/([a-z0-9][\w./-]+)`, LiteralStringOther, nil},
			{"" /* 164 byte string literal not displayed */, Keyword, nil},
			{`"([^"\\]*(?:\\.[^"\\]*)*)"`, LiteralStringDouble, nil},
			{`[^\s"\\]+`, Text, nil},
		},
	},
))

Apacheconf lexer.

var Apl = internal.Register(MustNewLexer(
	&Config{
		Name:      "APL",
		Aliases:   []string{"apl"},
		Filenames: []string{"*.apl"},
		MimeTypes: []string{},
	},
	Rules{
		"root": {
			{`\s+`, Text, nil},
			{`[⍝#].*$`, CommentSingle, nil},
			{`\'((\'\')|[^\'])*\'`, LiteralStringSingle, nil},
			{`"(("")|[^"])*"`, LiteralStringDouble, nil},
			{`[⋄◇()]`, Punctuation, nil},
			{`[\[\];]`, LiteralStringRegex, nil},
			{`⎕[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*`, NameFunction, nil},
			{`[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*`, NameVariable, nil},
			{"" /* 137 byte string literal not displayed */, LiteralNumber, nil},
			{`[\.\\/⌿⍀¨⍣⍨⍠⍤∘]`, NameAttribute, nil},
			{"" /* 152 byte string literal not displayed */, Operator, nil},
			{`⍬`, NameConstant, nil},
			{`[⎕⍞]`, NameVariableGlobal, nil},
			{`[←→]`, KeywordDeclaration, nil},
			{`[⍺⍵⍶⍹∇:]`, NameBuiltinPseudo, nil},
			{`[{}]`, KeywordType, nil},
		},
	},
))

Apl lexer.

var Applescript = internal.Register(MustNewLexer(
	&Config{
		Name:      "AppleScript",
		Aliases:   []string{"applescript"},
		Filenames: []string{"*.applescript"},
		MimeTypes: []string{},
		DotAll:    true,
	},
	Rules{
		"root": {
			{`\s+`, Text, nil},
			{`¬\n`, LiteralStringEscape, nil},
			{`'s\s+`, Text, nil},
			{`(--|#).*?$`, Comment, nil},
			{`\(\*`, CommentMultiline, Push("comment")},
			{`[(){}!,.:]`, Punctuation, nil},
			{`(«)([^»]+)(»)`, ByGroups(Text, NameBuiltin, Text), nil},
			{`\b((?:considering|ignoring)\s*)(application responses|case|diacriticals|hyphens|numeric strings|punctuation|white space)`, ByGroups(Keyword, NameBuiltin), nil},
			{`(-|\*|\+|&|≠|>=?|<=?|=|≥|≤|/|÷|\^)`, Operator, nil},
			{"" /* 736 byte string literal not displayed */, OperatorWord, nil},
			{"" /* 1846 byte string literal not displayed */, ByGroups(Keyword, NameFunction), nil},
			{`^(\s*)(in|on|script|to)(\s+)`, ByGroups(Text, Keyword, Text), nil},
			{"" /* 191 byte string literal not displayed */, ByGroups(Keyword, NameClass), nil},
			{"" /* 135 byte string literal not displayed */, NameConstant, nil},
			{"" /* 642 byte string literal not displayed */, NameBuiltin, nil},
			{"" /* 196 byte string literal not displayed */, Keyword, nil},
			{`\b(global|local|prop(erty)?|set|get)\b`, Keyword, nil},
			{`\b(but|put|returning|the)\b`, NameBuiltin, nil},
			{`\b(attachment|attribute run|character|day|month|paragraph|word|year)s?\b`, NameBuiltin, nil},
			{"" /* 135 byte string literal not displayed */, NameBuiltin, nil},
			{"" /* 4937 byte string literal not displayed */, NameAttribute, nil},
			{"" /* 637 byte string literal not displayed */, NameBuiltin, nil},
			{"" /* 406 byte string literal not displayed */, NameBuiltin, nil},
			{"" /* 211 byte string literal not displayed */, NameBuiltin, nil},
			{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
			{`\b([a-zA-Z]\w*)\b`, NameVariable, nil},
			{`[-+]?(\d+\.\d*|\d*\.\d+)(E[-+][0-9]+)?`, LiteralNumberFloat, nil},
			{`[-+]?\d+`, LiteralNumberInteger, nil},
		},
		"comment": {
			{`\(\*`, CommentMultiline, Push()},
			{`\*\)`, CommentMultiline, Pop(1)},
			{`[^*(]+`, CommentMultiline, nil},
			{`[*(]`, CommentMultiline, nil},
		},
	},
))

Applescript lexer.

var Arduino = internal.Register(MustNewLexer(
	&Config{
		Name:      "Arduino",
		Aliases:   []string{"arduino"},
		Filenames: []string{"*.ino"},
		MimeTypes: []string{"text/x-arduino"},
		EnsureNL:  true,
	},
	Rules{
		"statements": {
			{Words(``, `\b`, `catch`, `const_cast`, `delete`, `dynamic_cast`, `explicit`, `export`, `friend`, `mutable`, `namespace`, `new`, `operator`, `private`, `protected`, `public`, `reinterpret_cast`, `restrict`, `static_cast`, `template`, `this`, `throw`, `throws`, `try`, `typeid`, `typename`, `using`, `virtual`, `constexpr`, `nullptr`, `decltype`, `thread_local`, `alignas`, `alignof`, `static_assert`, `noexcept`, `override`, `final`), Keyword, nil},
			{`char(16_t|32_t)\b`, KeywordType, nil},
			{`(class)\b`, ByGroups(Keyword, Text), Push("classname")},
			{`(R)(")([^\\()\s]{,16})(\()((?:.|\n)*?)(\)\3)(")`, ByGroups(LiteralStringAffix, LiteralString, LiteralStringDelimiter, LiteralStringDelimiter, LiteralString, LiteralStringDelimiter, LiteralString), nil},
			{`(u8|u|U)(")`, ByGroups(LiteralStringAffix, LiteralString), Push("string")},
			{`(L?)(")`, ByGroups(LiteralStringAffix, LiteralString), Push("string")},
			{`(L?)(')(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])(')`, ByGroups(LiteralStringAffix, LiteralStringChar, LiteralStringChar, LiteralStringChar), nil},
			{`(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*`, LiteralNumberFloat, nil},
			{`(\d+\.\d*|\.\d+|\d+[fF])[fF]?`, LiteralNumberFloat, nil},
			{`0x[0-9a-fA-F]+[LlUu]*`, LiteralNumberHex, nil},
			{`0[0-7]+[LlUu]*`, LiteralNumberOct, nil},
			{`\d+[LlUu]*`, LiteralNumberInteger, nil},
			{`\*/`, Error, nil},
			{`[~!%^&*+=|?:<>/-]`, Operator, nil},
			{`[()\[\],.]`, Punctuation, nil},
			{Words(``, `\b`, `asm`, `auto`, `break`, `case`, `const`, `continue`, `default`, `do`, `else`, `enum`, `extern`, `for`, `goto`, `if`, `register`, `restricted`, `return`, `sizeof`, `static`, `struct`, `switch`, `typedef`, `union`, `volatile`, `while`), Keyword, nil},
			{"" /* 663 byte string literal not displayed */, KeywordType, nil},

			{`(and|final|If|Loop|loop|not|or|override|setup|Setup|throw|try|xor)\b`, Keyword, nil},
			{"" /* 345 byte string literal not displayed */, KeywordConstant, nil},
			{`(boolean|const|byte|word|string|String|array)\b`, NameVariable, nil},
			{"" /* 500 byte string literal not displayed */, NameClass, nil},
			{"" /* 4203 byte string literal not displayed */, NameFunction, nil},

			{Words(``, `\b`, `inline`, `_inline`, `__inline`, `naked`, `restrict`, `thread`, `typename`), KeywordReserved, nil},
			{`(__m(128i|128d|128|64))\b`, KeywordReserved, nil},
			{Words(`__`, `\b`, `asm`, `int8`, `based`, `except`, `int16`, `stdcall`, `cdecl`, `fastcall`, `int32`, `declspec`, `finally`, `int64`, `try`, `leave`, `wchar_t`, `w64`, `unaligned`, `raise`, `noop`, `identifier`, `forceinline`, `assume`), KeywordReserved, nil},
			{`(true|false|NULL)\b`, NameBuiltin, nil},
			{`([a-zA-Z_]\w*)(\s*)(:)(?!:)`, ByGroups(NameLabel, Text, Punctuation), nil},
			{`[a-zA-Z_]\w*`, Name, nil},
		},
		"root": {
			Include("whitespace"),
			{`((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;{]*)(\{)`, ByGroups(UsingSelf("root"), NameFunction, UsingSelf("root"), UsingSelf("root"), Punctuation), Push("function")},
			{`((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;]*)(;)`, ByGroups(UsingSelf("root"), NameFunction, UsingSelf("root"), UsingSelf("root"), Punctuation), nil},
			Default(Push("statement")),
			{Words(`__`, `\b`, `virtual_inheritance`, `uuidof`, `super`, `single_inheritance`, `multiple_inheritance`, `interface`, `event`), KeywordReserved, nil},
			{`__(offload|blockingoffload|outer)\b`, KeywordPseudo, nil},
		},
		"classname": {
			{`[a-zA-Z_]\w*`, NameClass, Pop(1)},
			{`\s*(?=>)`, Text, Pop(1)},
		},
		"whitespace": {
			{`^#if\s+0`, CommentPreproc, Push("if0")},
			{`^#`, CommentPreproc, Push("macro")},
			{`^(\s*(?:/[*].*?[*]/\s*)?)(#if\s+0)`, ByGroups(UsingSelf("root"), CommentPreproc), Push("if0")},
			{`^(\s*(?:/[*].*?[*]/\s*)?)(#)`, ByGroups(UsingSelf("root"), CommentPreproc), Push("macro")},
			{`\n`, Text, nil},
			{`\s+`, Text, nil},
			{`\\\n`, Text, nil},
			{`//(\n|[\w\W]*?[^\\]\n)`, CommentSingle, nil},
			{`/(\\\n)?[*][\w\W]*?[*](\\\n)?/`, CommentMultiline, nil},
			{`/(\\\n)?[*][\w\W]*`, CommentMultiline, nil},
		},
		"statement": {
			Include("whitespace"),
			Include("statements"),
			{`[{}]`, Punctuation, nil},
			{`;`, Punctuation, Pop(1)},
		},
		"function": {
			Include("whitespace"),
			Include("statements"),
			{`;`, Punctuation, nil},
			{`\{`, Punctuation, Push()},
			{`\}`, Punctuation, Pop(1)},
		},
		"string": {
			{`"`, LiteralString, Pop(1)},
			{`\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})`, LiteralStringEscape, nil},
			{`[^\\"\n]+`, LiteralString, nil},
			{`\\\n`, LiteralString, nil},
			{`\\`, LiteralString, nil},
		},
		"macro": {
			{`(include)(\s*(?:/[*].*?[*]/\s*)?)([^\n]+)`, ByGroups(CommentPreproc, Text, CommentPreprocFile), nil},
			{`[^/\n]+`, CommentPreproc, nil},
			{`/[*](.|\n)*?[*]/`, CommentMultiline, nil},
			{`//.*?\n`, CommentSingle, Pop(1)},
			{`/`, CommentPreproc, nil},
			{`(?<=\\)\n`, CommentPreproc, nil},
			{`\n`, CommentPreproc, Pop(1)},
		},
		"if0": {
			{`^\s*#if.*?(?<!\\)\n`, CommentPreproc, Push()},
			{`^\s*#el(?:se|if).*\n`, CommentPreproc, Pop(1)},
			{`^\s*#endif.*?(?<!\\)\n`, CommentPreproc, Pop(1)},
			{`.*?\n`, Comment, nil},
		},
	},
))

Arduino lexer.

var Awk = internal.Register(MustNewLexer(
	&Config{
		Name:      "Awk",
		Aliases:   []string{"awk", "gawk", "mawk", "nawk"},
		Filenames: []string{"*.awk"},
		MimeTypes: []string{"application/x-awk"},
	},
	Rules{
		"commentsandwhitespace": {
			{`\s+`, Text, nil},
			{`#.*$`, CommentSingle, nil},
		},
		"slashstartsregex": {
			Include("commentsandwhitespace"),
			{`/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/\B`, LiteralStringRegex, Pop(1)},
			{`(?=/)`, Text, Push("#pop", "badregex")},
			Default(Pop(1)),
		},
		"badregex": {
			{`\n`, Text, Pop(1)},
		},
		"root": {
			{`^(?=\s|/)`, Text, Push("slashstartsregex")},
			Include("commentsandwhitespace"),
			{`\+\+|--|\|\||&&|in\b|\$|!?~|(\*\*|[-<>+*%\^/!=|])=?`, Operator, Push("slashstartsregex")},
			{`[{(\[;,]`, Punctuation, Push("slashstartsregex")},
			{`[})\].]`, Punctuation, nil},
			{`(break|continue|do|while|exit|for|if|else|return)\b`, Keyword, Push("slashstartsregex")},
			{`function\b`, KeywordDeclaration, Push("slashstartsregex")},
			{"" /* 198 byte string literal not displayed */, KeywordReserved, nil},
			{"" /* 141 byte string literal not displayed */, NameBuiltin, nil},
			{`[$a-zA-Z_]\w*`, NameOther, nil},
			{`[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?`, LiteralNumberFloat, nil},
			{`0x[0-9a-fA-F]+`, LiteralNumberHex, nil},
			{`[0-9]+`, LiteralNumberInteger, nil},
			{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
			{`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
		},
	},
))

Awk lexer.

Source Files

abap.go abnf.go actionscript.go actionscript3.go ada.go angular2.go antlr.go apache.go apl.go applescript.go arduino.go awk.go

Version
v0.6.7
Published
Sep 22, 2019
Platform
js/wasm
Imports
2 packages
Last checked
8 minutes ago

Tools for package owners.