mirror of
				https://github.com/alecthomas/chroma.git
				synced 2025-10-30 23:57:49 +02:00 
			
		
		
		
	Switch to github.com/dlclark/regexp2.
This makes translating Pygments lexers much much simpler (and possible).
This commit is contained in:
		
							
								
								
									
										19
									
								
								COPYING
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								COPYING
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| Copyright (C) 2017 Alec Thomas | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy of | ||||
| this software and associated documentation files (the "Software"), to deal in | ||||
| the Software without restriction, including without limitation the rights to | ||||
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||||
| of the Software, and to permit persons to whom the Software is furnished to do | ||||
| so, subject to the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be included in all | ||||
| copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| SOFTWARE. | ||||
| @@ -1,9 +1,10 @@ | ||||
| import re | ||||
| import os | ||||
| import functools | ||||
| import importlib | ||||
| import json | ||||
| import os | ||||
| import re | ||||
| import sys | ||||
| import types | ||||
| import json | ||||
|  | ||||
| import pystache | ||||
| from pygments import lexer as pygments_lexer | ||||
| @@ -47,13 +48,11 @@ var {{upper_name}} = Register(MustNewLexer( | ||||
| ''' | ||||
|  | ||||
|  | ||||
| def go_regex(s): | ||||
|     return go_string(s) | ||||
|  | ||||
|  | ||||
| def go_string(s): | ||||
|     # TODO: Search for substring ranges and convert them to character classes. | ||||
|     # | ||||
|     # This seems to commonly occur with Unicode character classes, which presumably | ||||
|     # aren't supported by Python's regex engine. | ||||
|     if '(?<' in s: | ||||
|         warning('perl regex found in %r' % s) | ||||
|     if '`' not in s: | ||||
|         return '`' + s + '`' | ||||
|     return json.dumps(s) | ||||
| @@ -105,6 +104,8 @@ def resolve_emitter(emitter): | ||||
|  | ||||
|  | ||||
| def process_state_action(action): | ||||
|     if isinstance(action, tuple): | ||||
|         return functools.reduce(lambda a, b: a + b, (process_state_action(a) for a in action)) | ||||
|     if action.startswith('#'): | ||||
|         action = action[1:] | ||||
|         if action== 'pop': | ||||
| @@ -119,7 +120,7 @@ def process_state_action(action): | ||||
|             raise ValueError('unsupported action %r' % (action,)) | ||||
|     else: | ||||
|         action = 'Push("%s")' % action | ||||
|     return action | ||||
|     return (action,) | ||||
|  | ||||
|  | ||||
| def translate_rules(rules): | ||||
| @@ -128,16 +129,18 @@ def translate_rules(rules): | ||||
|         if isinstance(rule, tuple): | ||||
|             regex = rule[0] | ||||
|             if isinstance(regex, str): | ||||
|                 regex = go_string(regex) | ||||
|                 regex = go_regex(regex) | ||||
|             elif isinstance(regex, pygments_lexer.words): | ||||
|                 regex = go_string('`%s(?:%s)%s`' % (regex.prefix, '|'.join(regex.words), regex.suffix)) | ||||
|                 regex = 'Words(%s, %s, %s)' % (go_string(regex.prefix), | ||||
|                                                go_string(regex.suffix), | ||||
|                                                ', '.join(go_string(w) for w in regex.words)) | ||||
|             else: | ||||
|                 raise ValueError('expected regex string but got %r' % regex) | ||||
|             emitter = resolve_emitter(rule[1]) | ||||
|             if len(rule) == 2: | ||||
|                 modifier = 'nil' | ||||
|             elif type(rule[2]) is str: | ||||
|                 modifier = process_state_action(rule[2]) | ||||
|                 modifier = process_state_action(rule[2])[0] | ||||
|             elif isinstance(rule[2], pygments_lexer.combined): | ||||
|                 modifier = 'Combined("%s")' % '", "'.join(rule[2]) | ||||
|             elif type(rule[2]) is tuple: | ||||
| @@ -148,7 +151,7 @@ def translate_rules(rules): | ||||
|         elif isinstance(rule, pygments_lexer.include): | ||||
|             out.append('Include("{}")'.format(rule)) | ||||
|         elif isinstance(rule, pygments_lexer.default): | ||||
|             out.append('Default({})'.format(process_state_action(rule.state))) | ||||
|             out.append('Default({})'.format(', '.join(process_state_action(rule.state)))) | ||||
|         else: | ||||
|             raise ValueError('unsupported rule %r' % (rule,)) | ||||
|     return out | ||||
|   | ||||
| @@ -1,7 +1,6 @@ | ||||
| package main | ||||
|  | ||||
| import ( | ||||
| 	"bufio" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"io/ioutil" | ||||
| @@ -54,8 +53,9 @@ func main() { | ||||
| 		}() | ||||
| 		defer pprof.StopCPUProfile() | ||||
| 	} | ||||
| 	w := bufio.NewWriterSize(os.Stdout, 16384) | ||||
| 	defer w.Flush() | ||||
| 	// w := bufio.NewWriterSize(os.Stdout, 16384) | ||||
| 	w := os.Stdout | ||||
| 	// defer w.Flush() | ||||
| 	if *formatterFlag == "html" { | ||||
| 		options := []html.Option{} | ||||
| 		if *htmlPrefixFlag != "" { | ||||
|   | ||||
							
								
								
									
										72
									
								
								lexer.go
									
									
									
									
									
								
							
							
						
						
									
										72
									
								
								lexer.go
									
									
									
									
									
								
							| @@ -4,6 +4,7 @@ import ( | ||||
| 	"fmt" | ||||
| 	"regexp" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
|  | ||||
| 	"github.com/dlclark/regexp2" | ||||
| ) | ||||
| @@ -54,6 +55,9 @@ type Config struct { | ||||
|  | ||||
| 	// If given and greater than 0, expand tabs in the input. | ||||
| 	// TabSize int | ||||
|  | ||||
| 	// Whether to track how long rules take to process. | ||||
| 	TimeRules bool | ||||
| } | ||||
|  | ||||
| // Token output to formatter. | ||||
| @@ -153,11 +157,11 @@ func UsingSelf(state string) Emitter { | ||||
| } | ||||
|  | ||||
| // Words creates a regex that matches any of the given literal words. | ||||
| func Words(words ...string) string { | ||||
| func Words(prefix, suffix string, words ...string) string { | ||||
| 	for i, word := range words { | ||||
| 		words[i] = regexp.QuoteMeta(word) | ||||
| 	} | ||||
| 	return `\b(?:` + strings.Join(words, `|`) + `)\b` | ||||
| 	return prefix + `(` + strings.Join(words, `|`) + `)` + suffix | ||||
| } | ||||
|  | ||||
| // Rules maps from state to a sequence of Rules. | ||||
| @@ -186,7 +190,6 @@ func NewLexer(config *Config, rules Rules) (*RegexLexer, error) { | ||||
| 	compiledRules := map[string][]CompiledRule{} | ||||
| 	for state, rules := range rules { | ||||
| 		for _, rule := range rules { | ||||
| 			crule := CompiledRule{Rule: rule} | ||||
| 			flags := "" | ||||
| 			if !config.NotMultiline { | ||||
| 				flags += "m" | ||||
| @@ -197,12 +200,7 @@ func NewLexer(config *Config, rules Rules) (*RegexLexer, error) { | ||||
| 			if config.DotAll { | ||||
| 				flags += "s" | ||||
| 			} | ||||
| 			re, err := regexp2.Compile("^(?"+flags+")(?:"+rule.Pattern+")", 0) | ||||
| 			if err != nil { | ||||
| 				return nil, fmt.Errorf("invalid regex %q for state %q: %s", rule.Pattern, state, err) | ||||
| 			} | ||||
| 			crule.Regexp = re | ||||
| 			compiledRules[state] = append(compiledRules[state], crule) | ||||
| 			compiledRules[state] = append(compiledRules[state], CompiledRule{Rule: rule, flags: flags}) | ||||
| 		} | ||||
| 	} | ||||
| 	return &RegexLexer{ | ||||
| @@ -215,12 +213,13 @@ func NewLexer(config *Config, rules Rules) (*RegexLexer, error) { | ||||
| type CompiledRule struct { | ||||
| 	Rule | ||||
| 	Regexp *regexp2.Regexp | ||||
| 	flags  string | ||||
| } | ||||
|  | ||||
| type CompiledRules map[string][]CompiledRule | ||||
|  | ||||
| type LexerState struct { | ||||
| 	Text  string | ||||
| 	Text  []rune | ||||
| 	Pos   int | ||||
| 	Rules map[string][]CompiledRule | ||||
| 	Stack []string | ||||
| @@ -228,12 +227,25 @@ type LexerState struct { | ||||
| 	Rule  int | ||||
| 	// Group matches. | ||||
| 	Groups []string | ||||
| 	// Custum context for mutators. | ||||
| 	MutatorContext map[interface{}]interface{} | ||||
| } | ||||
|  | ||||
| func (l *LexerState) Set(key interface{}, value interface{}) { | ||||
| 	l.MutatorContext[key] = value | ||||
| } | ||||
|  | ||||
| func (l *LexerState) Get(key interface{}) interface{} { | ||||
| 	return l.MutatorContext[key] | ||||
| } | ||||
|  | ||||
| type RegexLexer struct { | ||||
| 	config   *Config | ||||
| 	rules    map[string][]CompiledRule | ||||
| 	analyser func(text string) float32 | ||||
|  | ||||
| 	mu       sync.Mutex | ||||
| 	compiled bool | ||||
| 	rules    map[string][]CompiledRule | ||||
| } | ||||
|  | ||||
| // SetAnalyser sets the analyser function used to perform content inspection. | ||||
| @@ -253,21 +265,45 @@ func (r *RegexLexer) Config() *Config { | ||||
| 	return r.config | ||||
| } | ||||
|  | ||||
| // Regex compilation is deferred until the lexer is used. This is to avoid significant init() time costs. | ||||
| func (r *RegexLexer) maybeCompile() (err error) { | ||||
| 	r.mu.Lock() | ||||
| 	defer r.mu.Unlock() | ||||
| 	if r.compiled { | ||||
| 		return nil | ||||
| 	} | ||||
| 	for _, rules := range r.rules { | ||||
| 		for i, rule := range rules { | ||||
| 			if rule.Regexp == nil { | ||||
| 				rule.Regexp, err = regexp2.Compile("^(?"+rule.flags+")(?:"+rule.Pattern+")", 0) | ||||
| 				if err != nil { | ||||
| 					return err | ||||
| 				} | ||||
| 			} | ||||
| 			rules[i] = rule | ||||
| 		} | ||||
| 	} | ||||
| 	r.compiled = true | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (r *RegexLexer) Tokenise(options *TokeniseOptions, text string, out func(*Token)) error { | ||||
| 	r.maybeCompile() | ||||
| 	if options == nil { | ||||
| 		options = defaultOptions | ||||
| 	} | ||||
| 	state := &LexerState{ | ||||
| 		Text:  text, | ||||
| 		Stack: []string{options.State}, | ||||
| 		Rules: r.rules, | ||||
| 		Text:           []rune(text), | ||||
| 		Stack:          []string{options.State}, | ||||
| 		Rules:          r.rules, | ||||
| 		MutatorContext: map[interface{}]interface{}{}, | ||||
| 	} | ||||
| 	for state.Pos < len(text) && len(state.Stack) > 0 { | ||||
| 	for state.Pos < len(state.Text) && len(state.Stack) > 0 { | ||||
| 		state.State = state.Stack[len(state.Stack)-1] | ||||
| 		ruleIndex, rule, groups := matchRules(state.Text[state.Pos:], state.Rules[state.State]) | ||||
| 		// No match. | ||||
| 		if groups == nil { | ||||
| 			out(&Token{Error, state.Text[state.Pos : state.Pos+1]}) | ||||
| 			out(&Token{Error, string(state.Text[state.Pos : state.Pos+1])}) | ||||
| 			state.Pos++ | ||||
| 			continue | ||||
| 		} | ||||
| @@ -294,9 +330,9 @@ func Tokenise(lexer Lexer, options *TokeniseOptions, text string) ([]*Token, err | ||||
| 	return out, lexer.Tokenise(options, text, func(token *Token) { out = append(out, token) }) | ||||
| } | ||||
|  | ||||
| func matchRules(text string, rules []CompiledRule) (int, CompiledRule, []string) { | ||||
| func matchRules(text []rune, rules []CompiledRule) (int, CompiledRule, []string) { | ||||
| 	for i, rule := range rules { | ||||
| 		match, err := rule.Regexp.FindStringMatch(text) | ||||
| 		match, err := rule.Regexp.FindRunesMatch(text) | ||||
| 		if match != nil && err == nil { | ||||
| 			groups := []string{} | ||||
| 			for _, g := range match.Groups() { | ||||
|   | ||||
							
								
								
									
										37
									
								
								lexers/abnf.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								lexers/abnf.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Abnf lexer. | ||||
| var Abnf = 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}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										38
									
								
								lexers/actionscript.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								lexers/actionscript.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Actionscript lexer. | ||||
| var Actionscript = 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}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										55
									
								
								lexers/actionscript3.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								lexers/actionscript3.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,55 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Actionscript 3 lexer. | ||||
| var Actionscript3 = 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}, | ||||
| 			{`(case|default|for|each|in|while|do|break|return|continue|if|else|throw|try|catch|with|new|typeof|arguments|instanceof|this|switch|import|include|as|is)\b`, Keyword, nil}, | ||||
| 			{`(class|public|final|internal|native|override|private|protected|static|import|extends|implements|interface|intrinsic|return|super|dynamic|function|const|get|namespace|package|set)\b`, KeywordDeclaration, nil}, | ||||
| 			{`(true|false|null|NaN|Infinity|-Infinity|undefined|void)\b`, KeywordConstant, nil}, | ||||
| 			{`(decodeURI|decodeURIComponent|encodeURI|escape|eval|isFinite|isNaN|isXMLName|clearInterval|fscommand|getTimer|getURL|getVersion|isFinite|parseFloat|parseInt|setInterval|trace|updateAfterEvent|unescape)\b`, 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)), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										113
									
								
								lexers/ada.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								lexers/ada.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,113 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Ada lexer. | ||||
| var Ada = 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"), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										41
									
								
								lexers/angular2.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								lexers/angular2.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Angular2 lexer. | ||||
| var Angular2 = 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)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										100
									
								
								lexers/antlr.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										100
									
								
								lexers/antlr.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,100 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Antlr lexer. | ||||
| var Antlr = 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}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										37
									
								
								lexers/apache.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								lexers/apache.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Apacheconf lexer. | ||||
| var Apacheconf = 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}, | ||||
| 			{`(on|off|none|any|all|double|email|dns|min|minimal|os|productonly|full|emerg|alert|crit|error|warn|notice|info|debug|registry|script|inetd|standalone|user|group)\b`, Keyword, nil}, | ||||
| 			{`"([^"\\]*(?:\\.[^"\\]*)*)"`, LiteralStringDouble, nil}, | ||||
| 			{`[^\s"\\]+`, Text, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										35
									
								
								lexers/apl.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								lexers/apl.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Apl lexer. | ||||
| var Apl = 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}, | ||||
| 			{`¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞)([Jj]¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞))?`, LiteralNumber, nil}, | ||||
| 			{`[\.\\/⌿⍀¨⍣⍨⍠⍤∘]`, NameAttribute, nil}, | ||||
| 			{`[+\-×÷⌈⌊∣|⍳?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⌸⍯↗]`, Operator, nil}, | ||||
| 			{`⍬`, NameConstant, nil}, | ||||
| 			{`[⎕⍞]`, NameVariableGlobal, nil}, | ||||
| 			{`[←→]`, KeywordDeclaration, nil}, | ||||
| 			{`[⍺⍵⍶⍹∇:]`, NameBuiltinPseudo, nil}, | ||||
| 			{`[{}]`, KeywordType, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										54
									
								
								lexers/applescript.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								lexers/applescript.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,54 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Applescript lexer. | ||||
| var Applescript = 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}, | ||||
| 			{`\b(and|or|is equal|equals|(is )?equal to|is not|isn't|isn't equal( to)?|is not equal( to)?|doesn't equal|does not equal|(is )?greater than|comes after|is not less than or equal( to)?|isn't less than or equal( to)?|(is )?less than|comes before|is not greater than or equal( to)?|isn't greater than or equal( to)?|(is  )?greater than or equal( to)?|is not less than|isn't less than|does not come before|doesn't come before|(is )?less than or equal( to)?|is not greater than|isn't greater than|does not come after|doesn't come after|starts? with|begins? with|ends? with|contains?|does not contain|doesn't contain|is in|is contained by|is not in|is not contained by|isn't contained by|div|mod|not|(a  )?(ref( to)?|reference to)|is|does)\b`, OperatorWord, nil}, | ||||
| 			{`^(\s*(?:on|end)\s+)(zoomed|write to file|will zoom|will show|will select tab view item|will resize( sub views)?|will resign active|will quit|will pop up|will open|will move|will miniaturize|will hide|will finish launching|will display outline cell|will display item cell|will display cell|will display browser cell|will dismiss|will close|will become active|was miniaturized|was hidden|update toolbar item|update parameters|update menu item|shown|should zoom|should selection change|should select tab view item|should select row|should select item|should select column|should quit( after last window closed)?|should open( untitled)?|should expand item|should end editing|should collapse item|should close|should begin editing|selection changing|selection changed|selected tab view item|scroll wheel|rows changed|right mouse up|right mouse dragged|right mouse down|resized( sub views)?|resigned main|resigned key|resigned active|read from file|prepare table drop|prepare table drag|prepare outline drop|prepare outline drag|prepare drop|plugin loaded|parameters updated|panel ended|opened|open untitled|number of rows|number of items|number of browser rows|moved|mouse up|mouse moved|mouse exited|mouse entered|mouse dragged|mouse down|miniaturized|load data representation|launched|keyboard up|keyboard down|items changed|item value changed|item value|item expandable|idle|exposed|end editing|drop|drag( (entered|exited|updated))?|double clicked|document nib name|dialog ended|deminiaturized|data representation|conclude drop|column resized|column moved|column clicked|closed|clicked toolbar item|clicked|choose menu item|child of item|changed|change item value|change cell value|cell value changed|cell value|bounds changed|begin editing|became main|became key|awake from nib|alert ended|activated|action|accept table drop|accept outline drop)`, ByGroups(Keyword, NameFunction), nil}, | ||||
| 			{`^(\s*)(in|on|script|to)(\s+)`, ByGroups(Text, Keyword, Text), nil}, | ||||
| 			{`\b(as )(alias |application |boolean |class |constant |date |file |integer |list |number |POSIX file |real |record |reference |RGB color |script |text |unit types|(?:Unicode )?text|string)\b`, ByGroups(Keyword, NameClass), nil}, | ||||
| 			{`\b(AppleScript|current application|false|linefeed|missing value|pi|quote|result|return|space|tab|text item delimiters|true|version)\b`, NameConstant, nil}, | ||||
| 			{`\b(ASCII (character|number)|activate|beep|choose URL|choose application|choose color|choose file( name)?|choose folder|choose from list|choose remote application|clipboard info|close( access)?|copy|count|current date|delay|delete|display (alert|dialog)|do shell script|duplicate|exists|get eof|get volume settings|info for|launch|list (disks|folder)|load script|log|make|mount volume|new|offset|open( (for access|location))?|path to|print|quit|random number|read|round|run( script)?|say|scripting components|set (eof|the clipboard to|volume)|store script|summarize|system attribute|system info|the clipboard|time to GMT|write|quoted form)\b`, NameBuiltin, nil}, | ||||
| 			{`\b(considering|else|error|exit|from|if|ignoring|in|repeat|tell|then|times|to|try|until|using terms from|while|whith|with timeout( of)?|with transaction|by|continue|end|its?|me|my|return|of|as)\b`, 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}, | ||||
| 			{`\b(about|above|against|apart from|around|aside from|at|below|beneath|beside|between|for|given|instead of|on|onto|out of|over|since)\b`, NameBuiltin, nil}, | ||||
| 			{`\b(accepts arrow key|action method|active|alignment|allowed identifiers|allows branch selection|allows column reordering|allows column resizing|allows column selection|allows customization|allows editing text attributes|allows empty selection|allows mixed state|allows multiple selection|allows reordering|allows undo|alpha( value)?|alternate image|alternate increment value|alternate title|animation delay|associated file name|associated object|auto completes|auto display|auto enables items|auto repeat|auto resizes( outline column)?|auto save expanded items|auto save name|auto save table columns|auto saves configuration|auto scroll|auto sizes all columns to fit|auto sizes cells|background color|bezel state|bezel style|bezeled|border rect|border type|bordered|bounds( rotation)?|box type|button returned|button type|can choose directories|can choose files|can draw|can hide|cell( (background color|size|type))?|characters|class|click count|clicked( data)? column|clicked data item|clicked( data)? row|closeable|collating|color( (mode|panel))|command key down|configuration|content(s| (size|view( margins)?))?|context|continuous|control key down|control size|control tint|control view|controller visible|coordinate system|copies( on scroll)?|corner view|current cell|current column|current( field)?  editor|current( menu)? item|current row|current tab view item|data source|default identifiers|delta (x|y|z)|destination window|directory|display mode|displayed cell|document( (edited|rect|view))?|double value|dragged column|dragged distance|dragged items|draws( cell)? background|draws grid|dynamically scrolls|echos bullets|edge|editable|edited( data)? column|edited data item|edited( data)? row|enabled|enclosing scroll view|ending page|error handling|event number|event type|excluded from windows menu|executable path|expanded|fax number|field editor|file kind|file name|file type|first responder|first visible column|flipped|floating|font( panel)?|formatter|frameworks path|frontmost|gave up|grid color|has data items|has horizontal ruler|has horizontal scroller|has parent data item|has resize indicator|has shadow|has sub menu|has vertical ruler|has vertical scroller|header cell|header view|hidden|hides when deactivated|highlights by|horizontal line scroll|horizontal page scroll|horizontal ruler view|horizontally resizable|icon image|id|identifier|ignores multiple clicks|image( (alignment|dims when disabled|frame style|scaling))?|imports graphics|increment value|indentation per level|indeterminate|index|integer value|intercell spacing|item height|key( (code|equivalent( modifier)?|window))?|knob thickness|label|last( visible)? column|leading offset|leaf|level|line scroll|loaded|localized sort|location|loop mode|main( (bunde|menu|window))?|marker follows cell|matrix mode|maximum( content)? size|maximum visible columns|menu( form representation)?|miniaturizable|miniaturized|minimized image|minimized title|minimum column width|minimum( content)? size|modal|modified|mouse down state|movie( (controller|file|rect))?|muted|name|needs display|next state|next text|number of tick marks|only tick mark values|opaque|open panel|option key down|outline table column|page scroll|pages across|pages down|palette label|pane splitter|parent data item|parent window|pasteboard|path( (names|separator))?|playing|plays every frame|plays selection only|position|preferred edge|preferred type|pressure|previous text|prompt|properties|prototype cell|pulls down|rate|released when closed|repeated|requested print time|required file type|resizable|resized column|resource path|returns records|reuses columns|rich text|roll over|row height|rulers visible|save panel|scripts path|scrollable|selectable( identifiers)?|selected cell|selected( data)? columns?|selected data items?|selected( data)? rows?|selected item identifier|selection by rect|send action on arrow key|sends action when done editing|separates columns|separator item|sequence number|services menu|shared frameworks path|shared support path|sheet|shift key down|shows alpha|shows state by|size( mode)?|smart insert delete enabled|sort case sensitivity|sort column|sort order|sort type|sorted( data rows)?|sound|source( mask)?|spell checking enabled|starting page|state|string value|sub menu|super menu|super view|tab key traverses cells|tab state|tab type|tab view|table view|tag|target( printer)?|text color|text container insert|text container origin|text returned|tick mark position|time stamp|title(d| (cell|font|height|position|rect))?|tool tip|toolbar|trailing offset|transparent|treat packages as directories|truncated labels|types|unmodified characters|update views|use sort indicator|user defaults|uses data source|uses ruler|uses threaded animation|uses title from previous column|value wraps|version|vertical( (line scroll|page scroll|ruler view))?|vertically resizable|view|visible( document rect)?|volume|width|window|windows menu|wraps|zoomable|zoomed)\b`, NameAttribute, nil}, | ||||
| 			{`\b(action cell|alert reply|application|box|browser( cell)?|bundle|button( cell)?|cell|clip view|color well|color-panel|combo box( item)?|control|data( (cell|column|item|row|source))?|default entry|dialog reply|document|drag info|drawer|event|font(-panel)?|formatter|image( (cell|view))?|matrix|menu( item)?|item|movie( view)?|open-panel|outline view|panel|pasteboard|plugin|popup button|progress indicator|responder|save-panel|scroll view|secure text field( cell)?|slider|sound|split view|stepper|tab view( item)?|table( (column|header cell|header view|view))|text( (field( cell)?|view))?|toolbar( item)?|user-defaults|view|window)s?\b`, NameBuiltin, nil}, | ||||
| 			{`\b(animate|append|call method|center|close drawer|close panel|display|display alert|display dialog|display panel|go|hide|highlight|increment|item for|load image|load movie|load nib|load panel|load sound|localized string|lock focus|log|open drawer|path for|pause|perform action|play|register|resume|scroll|select( all)?|show|size to fit|start|step back|step forward|stop|synchronize|unlock focus|update)\b`, NameBuiltin, nil}, | ||||
| 			{`\b((in )?back of|(in )?front of|[0-9]+(st|nd|rd|th)|first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|after|back|before|behind|every|front|index|last|middle|some|that|through|thru|where|whose)\b`, 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}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										47
									
								
								lexers/awk.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								lexers/awk.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Awk lexer. | ||||
| var Awk = 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")}, | ||||
| 			{`(atan2|cos|exp|int|log|rand|sin|sqrt|srand|gensub|gsub|index|length|match|split|sprintf|sub|substr|tolower|toupper|close|fflush|getline|next|nextfile|print|printf|strftime|systime|delete|system)\b`, KeywordReserved, nil}, | ||||
| 			{`(ARGC|ARGIND|ARGV|BEGIN|CONVFMT|ENVIRON|END|ERRNO|FIELDWIDTHS|FILENAME|FNR|FS|IGNORECASE|NF|NR|OFMT|OFS|ORFS|RLENGTH|RS|RSTART|RT|SUBSEP)\b`, 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}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										168
									
								
								lexers/bash.go
									
									
									
									
									
								
							
							
						
						
									
										168
									
								
								lexers/bash.go
									
									
									
									
									
								
							| @@ -1,97 +1,85 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
|     "strings" | ||||
|  | ||||
|     . "github.com/alecthomas/chroma" // nolint | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Bash lexer. | ||||
| var Bash = Register(MustNewLexer( | ||||
|     &Config{ | ||||
|         Name:    "Bash", | ||||
|         Aliases: []string{"bash", "sh", "ksh", "zsh", "shell"}, | ||||
|         Filenames: []string{ | ||||
|             "*.sh", "*.ksh", "*.bash", "*.ebuild", "*.eclass", "*.exheres-0", "*.exlib", | ||||
|             "*.zsh", ".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}, | ||||
|             {`\b(alias|bg|bind|break|builtin|caller|cd|command|compgen|complete|declare|dirs|disown|echo|enable|eval|exec|exit|export|false|fc|fg|getopts|hash|help|history|jobs|kill|let|local|logout|popd|printf|pushd|pwd|read|readonly|set|shift|shopt|source|suspend|test|time|times|trap|true|type|typeset|ulimit|umask|unalias|unset|wait)(\s*)\b`, NameBuiltin, nil}, | ||||
|             {`\A#!.+\n`, CommentHashbang, nil}, | ||||
|             {`#.*\n`, 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+\b`, 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(content string) float32 { | ||||
|     if strings.HasPrefix(content, "#!/bin/sh") || | ||||
|         strings.HasPrefix(content, "#!/bin/bash") || | ||||
|         strings.HasPrefix(content, "#!/bin/zsh") { | ||||
|         return 1.0 | ||||
|     } | ||||
|     return 0.0 | ||||
| })) | ||||
| 	&Config{ | ||||
| 		Name:      "Bash", | ||||
| 		Aliases:   []string{"bash", "sh", "ksh", "zsh", "shell"}, | ||||
| 		Filenames: []string{"*.sh", "*.ksh", "*.bash", "*.ebuild", "*.eclass", "*.exheres-0", "*.exlib", "*.zsh", ".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}, | ||||
| 			{"\\b(alias|bg|bind|break|builtin|caller|cd|command|compgen|complete|declare|dirs|disown|echo|enable|eval|exec|exit|export|false|fc|fg|getopts|hash|help|history|jobs|kill|let|local|logout|popd|printf|pushd|pwd|read|readonly|set|shift|shopt|source|suspend|test|time|times|trap|true|type|typeset|ulimit|umask|unalias|unset|wait)(?=[\\s)`])", NameBuiltin, nil}, | ||||
| 			{`\A#!.+\n`, CommentHashbang, nil}, | ||||
| 			{`#.*\n`, 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+\b`, 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"), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
|   | ||||
							
								
								
									
										193
									
								
								lexers/batch.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										193
									
								
								lexers/batch.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,193 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Batchfile lexer. | ||||
| var Batchfile = 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}, | ||||
| 			{`((?:for|if|rem)(?:(?=(?:\^[\n\x1a]?)?/)|(?:(?!\^)|(?<=m))(?:(?=\()|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+)?(?:\^[\n\x1a]?)?/(?:\^[\n\x1a]?)?\?)`, ByGroups(Keyword, UsingSelf("text")), Push("follow")}, | ||||
| 			{`(goto(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(]))((?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|[^"%\n\x1a&<>|])*(?:\^[\n\x1a]?)?/(?:\^[\n\x1a]?)?\?(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|[^"%\n\x1a&<>|])*)`, 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}, | ||||
| 			{`(for(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])(?!\^))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(/f(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))`, ByGroups(Keyword, UsingSelf("text"), Keyword), Push("for/f", "for")}, | ||||
| 			{`(for(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])(?!\^))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(/l(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))`, 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")}, | ||||
| 			{`(if(?:(?=\()|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))(?!\^))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)((?:/i(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))?)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)((?:not(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))?)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)`, ByGroups(Keyword, UsingSelf("text"), Keyword, UsingSelf("text"), Keyword, UsingSelf("text")), Push("(?", "if")}, | ||||
| 			{`rem(((?=\()|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))(?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+)?.*|(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(])(?:(?:[^\n\x1a^]|\^[\n\x1a]?[\w\W])*))`, 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")}, | ||||
| 			{`(set(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(]))((?:(?:\^[\n\x1a]?)?[^\S\n])*)((?:/p)?)((?:(?:\^[\n\x1a]?)?[^\S\n])*)((?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|^=]|\^[\n\x1a]?[^"=])+)?)((?:(?:\^[\n\x1a]?)?=)?)`, ByGroups(Keyword, UsingSelf("text"), Keyword, UsingSelf("text"), UsingSelf("variable"), Punctuation), Push("follow")}, | ||||
| 			Default(Push("follow")), | ||||
| 		}, | ||||
| 		"follow": { | ||||
| 			{`((?:(?<=^[^:])|^[^:]?)[\t\v\f\r ,;=\xa0]*)(:)([\t\v\f\r ,;=\xa0]*)((?:(?:[^\n\x1a&<>|\t\v\f\r ,;=\xa0+:^]|\^[\n\x1a]?[\w\W])*))(.*)`, 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}, | ||||
| 			{`((?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(\^[\n\x1a]?)?[^()=+\-*/!~%^"\n\x1a&<>|\t\v\f\r ,;=\xa0]|\^[\n\x1a\t\v\f\r ,;=\xa0]?[\w\W])+`, 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": { | ||||
| 			{`((?:(?:[^\n\x1a&<>|\t\v\f\r ,;=\xa0+:^]|\^[\n\x1a]?[\w\W])*)?)((?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|\^[\n\x1a]?[\w\W]|[^"%^\n\x1a&<>|])*)`, 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}, | ||||
| 			{`((?:(?<=[\n\x1a\t\v\f\r ,;=\xa0])(?<!\^[\n\x1a])\d)?)(>>?|<)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+))`, 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}, | ||||
| 			{`((?:for|if|rem)(?:(?=(?:\^[\n\x1a]?)?/)|(?:(?!\^)|(?<=m))(?:(?=\()|(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0)])+)?(?:\^[\n\x1a]?)?/(?:\^[\n\x1a]?)?\?)`, ByGroups(Keyword, UsingSelf("text")), Push("follow/compound")}, | ||||
| 			{`(goto(?:(?=\))|(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(])))((?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|[^"%\n\x1a&<>|)])*(?:\^[\n\x1a]?)?/(?:\^[\n\x1a]?)?\?(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|[^"%\n\x1a&<>|)])*)`, 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}, | ||||
| 			{`(for(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))(?!\^))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(/f(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))`, ByGroups(Keyword, UsingSelf("text"), Keyword), Push("for/f", "for")}, | ||||
| 			{`(for(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))(?!\^))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))(/l(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))`, 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/compound")}, | ||||
| 			{`(if(?:(?=\()|(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))(?!\^))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)((?:/i(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))?)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)((?:not(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))?)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)`, ByGroups(Keyword, UsingSelf("text"), Keyword, UsingSelf("text"), Keyword, UsingSelf("text")), Push("(?", "if")}, | ||||
| 			{`rem(((?=\()|(?:(?=\))|(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))(?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+)?.*|(?:(?=\))|(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(]))(?:(?:[^\n\x1a^)]|\^[\n\x1a]?[^)])*))`, 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")}, | ||||
| 			{`(set(?:(?=\))|(?=(?:\^[\n\x1a]?)?[\t\v\f\r ,;=\xa0+./:[\\\]]|[\n\x1a&<>|(])))((?:(?:\^[\n\x1a]?)?[^\S\n])*)((?:/p)?)((?:(?:\^[\n\x1a]?)?[^\S\n])*)((?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|^=)]|\^[\n\x1a]?[^"=])+)?)((?:(?:\^[\n\x1a]?)?=)?)`, ByGroups(Keyword, UsingSelf("text"), Keyword, UsingSelf("text"), UsingSelf("variable"), Punctuation), Push("follow/compound")}, | ||||
| 			Default(Push("follow/compound")), | ||||
| 		}, | ||||
| 		"follow/compound": { | ||||
| 			{`(?=\))`, Text, Pop(1)}, | ||||
| 			{`((?:(?<=^[^:])|^[^:]?)[\t\v\f\r ,;=\xa0]*)(:)([\t\v\f\r ,;=\xa0]*)((?:(?:[^\n\x1a&<>|\t\v\f\r ,;=\xa0+:^)]|\^[\n\x1a]?[^)])*))(.*)`, 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}, | ||||
| 			{`((?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(\^[\n\x1a]?)?[^()=+\-*/!~%^"\n\x1a&<>|\t\v\f\r ,;=\xa0]|\^[\n\x1a\t\v\f\r ,;=\xa0]?[^)])+`, 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)}, | ||||
| 			{`((?:(?:[^\n\x1a&<>|\t\v\f\r ,;=\xa0+:^)]|\^[\n\x1a]?[^)])*)?)((?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|\^[\n\x1a]?[^)]|[^"%^\n\x1a&<>|)])*)`, 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}, | ||||
| 			{`((?:(?<=[\n\x1a\t\v\f\r ,;=\xa0])(?<!\^[\n\x1a])\d)?)(>>?|<)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0)])+))+))`, ByGroups(LiteralNumberInteger, Punctuation, UsingSelf("text")), nil}, | ||||
| 		}, | ||||
| 		"variable-or-escape": { | ||||
| 			{`(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))`, NameVariable, nil}, | ||||
| 			{`%%|\^[\n\x1a]?(\^!|[\w\W])`, LiteralStringEscape, nil}, | ||||
| 		}, | ||||
| 		"string": { | ||||
| 			{`"`, LiteralStringDouble, Pop(1)}, | ||||
| 			{`(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))`, 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": { | ||||
| 			{`(")((?:(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|[^"])*?")([\n\x1a\t\v\f\r ,;=\xa0]*)(\))`, ByGroups(LiteralStringDouble, UsingSelf("string"), Text, Punctuation), nil}, | ||||
| 			{`"`, LiteralStringDouble, Push("#pop", "for2", "string")}, | ||||
| 			{`('(?:%%|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|[\w\W])*?')([\n\x1a\t\v\f\r ,;=\xa0]*)(\))`, ByGroups(UsingSelf("sqstring"), Text, Punctuation), nil}, | ||||
| 			{"(`(?:%%|(?:(?:%(?:\\*|(?:~[a-z]*(?:\\$[^:]+:)?)?\\d|[^%:\\n\\x1a]+(?::(?:~(?:-?\\d+)?(?:,(?:-?\\d+)?)?|(?:[^%\\n\\x1a^]|\\^[^%\\n\\x1a])[^=\\n\\x1a]*=(?:[^%\\n\\x1a^]|\\^[^%\\n\\x1a])*)?)?%))|(?:\\^?![^!:\\n\\x1a]+(?::(?:~(?:-?\\d+)?(?:,(?:-?\\d+)?)?|(?:[^!\\n\\x1a^]|\\^[^!\\n\\x1a])[^=\\n\\x1a]*=(?:[^!\\n\\x1a^]|\\^[^!\\n\\x1a])*)?)?\\^?!))|[\\w\\W])*?`)([\\n\\x1a\\t\\v\\f\\r ,;=\\xa0]*)(\\))", 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)}, | ||||
| 			{`(defined(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))((?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+))`, ByGroups(Keyword, UsingSelf("text"), UsingSelf("variable")), Pop(1)}, | ||||
| 			{`(exist(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+))`, ByGroups(Keyword, UsingSelf("text")), Pop(1)}, | ||||
| 			{`((?:-?(?:0[0-7]+|0x[\da-f]+|\d+)(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a]))(?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))((?:equ|geq|gtr|leq|lss|neq))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)(?:-?(?:0[0-7]+|0x[\da-f]+|\d+)(?=\^?[\t\v\f\r ,;=\xa0]|[&<>|\n\x1a])))`, ByGroups(UsingSelf("arithmetic"), OperatorWord, UsingSelf("arithmetic")), Pop(1)}, | ||||
| 			{`(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+)`, UsingSelf("text"), Push("#pop", "if2")}, | ||||
| 		}, | ||||
| 		"if2": { | ||||
| 			{`((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?)(==)((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)?(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+))`, ByGroups(UsingSelf("text"), Operator, UsingSelf("text")), Pop(1)}, | ||||
| 			{`((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+))((?:equ|geq|gtr|leq|lss|neq))((?:(?:(?:\^[\n\x1a])?[\t\v\f\r ,;=\xa0])+)(?:[&<>|]+|(?:(?:"[^\n\x1a"]*(?:"|(?=[\n\x1a])))|(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|[^%:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%\n\x1a^]|\^[^%\n\x1a])[^=\n\x1a]*=(?:[^%\n\x1a^]|\^[^%\n\x1a])*)?)?%))|(?:\^?![^!:\n\x1a]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^!\n\x1a^]|\^[^!\n\x1a])[^=\n\x1a]*=(?:[^!\n\x1a^]|\^[^!\n\x1a])*)?)?\^?!))|(?:(?:(?:\^[\n\x1a]?)?[^"\n\x1a&<>|\t\v\f\r ,;=\xa0])+))+))`, 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)), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										47
									
								
								lexers/blitz.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								lexers/blitz.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Blitzbasic lexer. | ||||
| var Blitzbasic = 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}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										23
									
								
								lexers/bnf.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								lexers/bnf.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Bnf lexer. | ||||
| var Bnf = 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}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										33
									
								
								lexers/brainfuck.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								lexers/brainfuck.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Brainfuck lexer. | ||||
| var Brainfuck = 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"), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										164
									
								
								lexers/c.go
									
									
									
									
									
								
							
							
						
						
									
										164
									
								
								lexers/c.go
									
									
									
									
									
								
							| @@ -1,90 +1,90 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
|     . "github.com/alecthomas/chroma" // nolint | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // C lexer. | ||||
| var C = Register(MustNewLexer( | ||||
|     &Config{ | ||||
|         Name:      "C", | ||||
|         Aliases:   []string{"c"}, | ||||
|         Filenames: []string{"*.c", "*.h", "*.idc"}, | ||||
|         MimeTypes: []string{"text/x-chdr", "text/x-csrc"}, | ||||
|     }, | ||||
|     Rules{ | ||||
|         "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}, | ||||
|         }, | ||||
|         "statements": { | ||||
|             {`(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}, | ||||
|             {`(?: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)\b`, Keyword, nil}, | ||||
|             {`(bool|int|long|float|short|double|char|unsigned|signed|void)\b`, KeywordType, nil}, | ||||
|             {`(?:inline|_inline|__inline|naked|restrict|thread|typename)\b`, KeywordReserved, nil}, | ||||
|             {`(__m(128i|128d|128|64))\b`, KeywordReserved, nil}, | ||||
|             {`__(?:asm|int8|based|except|int16|stdcall|cdecl|fastcall|int32|declspec|finally|int64|try|leave|wchar_t|w64|unaligned|raise|noop|identifier|forceinline|assume)\b`, 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")), | ||||
|         }, | ||||
|         "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}, | ||||
|         }, | ||||
|     }, | ||||
| 	&Config{ | ||||
| 		Name:      "C", | ||||
| 		Aliases:   []string{"c"}, | ||||
| 		Filenames: []string{"*.c", "*.h", "*.idc"}, | ||||
| 		MimeTypes: []string{"text/x-chdr", "text/x-csrc"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"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}, | ||||
| 		}, | ||||
| 		"statements": { | ||||
| 			{`(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}, | ||||
| 			{`(bool|int|long|float|short|double|char|unsigned|signed|void)\b`, KeywordType, 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")), | ||||
| 		}, | ||||
| 		"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}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
|   | ||||
							
								
								
									
										60
									
								
								lexers/capnproto.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								lexers/capnproto.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,60 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Cap'N'Proto Proto lexer. | ||||
| var CapNProto = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Cap'n Proto", | ||||
| 		Aliases:   []string{"capnp"}, | ||||
| 		Filenames: []string{"*.capnp"}, | ||||
| 		MimeTypes: []string{}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`#.*?$`, CommentSingle, nil}, | ||||
| 			{`@[0-9a-zA-Z]*`, NameDecorator, nil}, | ||||
| 			{`=`, Literal, Push("expression")}, | ||||
| 			{`:`, NameClass, Push("type")}, | ||||
| 			{`\$`, NameAttribute, Push("annotation")}, | ||||
| 			{`(struct|enum|interface|union|import|using|const|annotation|extends|in|of|on|as|with|from|fixed)\b`, Keyword, nil}, | ||||
| 			{`[\w.]+`, Name, nil}, | ||||
| 			{`[^#@=:$\w]+`, Text, nil}, | ||||
| 		}, | ||||
| 		"type": { | ||||
| 			{`[^][=;,(){}$]+`, NameClass, nil}, | ||||
| 			{`[[(]`, NameClass, Push("parentype")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"parentype": { | ||||
| 			{`[^][;()]+`, NameClass, nil}, | ||||
| 			{`[[(]`, NameClass, Push()}, | ||||
| 			{`[])]`, NameClass, Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"expression": { | ||||
| 			{`[^][;,(){}$]+`, Literal, nil}, | ||||
| 			{`[[(]`, Literal, Push("parenexp")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"parenexp": { | ||||
| 			{`[^][;()]+`, Literal, nil}, | ||||
| 			{`[[(]`, Literal, Push()}, | ||||
| 			{`[])]`, Literal, Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"annotation": { | ||||
| 			{`[^][;,(){}=:]+`, NameAttribute, nil}, | ||||
| 			{`[[(]`, NameAttribute, Push("annexp")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"annexp": { | ||||
| 			{`[^][;()]+`, NameAttribute, nil}, | ||||
| 			{`[[(]`, NameAttribute, Push()}, | ||||
| 			{`[])]`, NameAttribute, Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										62
									
								
								lexers/ceylon.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								lexers/ceylon.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,62 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Ceylon lexer. | ||||
| var Ceylon = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Ceylon", | ||||
| 		Aliases:   []string{"ceylon"}, | ||||
| 		Filenames: []string{"*.ceylon"}, | ||||
| 		MimeTypes: []string{"text/x-ceylon"}, | ||||
| 		DotAll:    true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)([a-zA-Z_]\w*)(\s*)(\()`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil}, | ||||
| 			{`[^\S\n]+`, Text, nil}, | ||||
| 			{`//.*?\n`, CommentSingle, nil}, | ||||
| 			{`/\*`, CommentMultiline, Push("comment")}, | ||||
| 			{`(shared|abstract|formal|default|actual|variable|deprecated|small|late|literal|doc|by|see|throws|optional|license|tagged|final|native|annotation|sealed)\b`, NameDecorator, nil}, | ||||
| 			{`(break|case|catch|continue|else|finally|for|in|if|return|switch|this|throw|try|while|is|exists|dynamic|nonempty|then|outer|assert|let)\b`, Keyword, nil}, | ||||
| 			{`(abstracts|extends|satisfies|super|given|of|out|assign)\b`, KeywordDeclaration, nil}, | ||||
| 			{`(function|value|void|new)\b`, KeywordType, nil}, | ||||
| 			{`(assembly|module|package)(\s+)`, ByGroups(KeywordNamespace, Text), nil}, | ||||
| 			{`(true|false|null)\b`, KeywordConstant, nil}, | ||||
| 			{`(class|interface|object|alias)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("class")}, | ||||
| 			{`(import)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")}, | ||||
| 			{`"(\\\\|\\"|[^"])*"`, LiteralString, nil}, | ||||
| 			{`'\\.'|'[^\\]'|'\\\{#[0-9a-fA-F]{4}\}'`, LiteralStringChar, nil}, | ||||
| 			{"\".*``.*``.*\"", LiteralStringInterpol, nil}, | ||||
| 			{`(\.)([a-z_]\w*)`, ByGroups(Operator, NameAttribute), nil}, | ||||
| 			{`[a-zA-Z_]\w*:`, NameLabel, nil}, | ||||
| 			{`[a-zA-Z_]\w*`, Name, nil}, | ||||
| 			{`[~^*!%&\[\](){}<>|+=:;,./?-]`, Operator, nil}, | ||||
| 			{`\d{1,3}(_\d{3})+\.\d{1,3}(_\d{3})+[kMGTPmunpf]?`, LiteralNumberFloat, nil}, | ||||
| 			{`\d{1,3}(_\d{3})+\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?`, LiteralNumberFloat, nil}, | ||||
| 			{`[0-9][0-9]*\.\d{1,3}(_\d{3})+[kMGTPmunpf]?`, LiteralNumberFloat, nil}, | ||||
| 			{`[0-9][0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?`, LiteralNumberFloat, nil}, | ||||
| 			{`#([0-9a-fA-F]{4})(_[0-9a-fA-F]{4})+`, LiteralNumberHex, nil}, | ||||
| 			{`#[0-9a-fA-F]+`, LiteralNumberHex, nil}, | ||||
| 			{`\$([01]{4})(_[01]{4})+`, LiteralNumberBin, nil}, | ||||
| 			{`\$[01]+`, LiteralNumberBin, nil}, | ||||
| 			{`\d{1,3}(_\d{3})+[kMGTP]?`, LiteralNumberInteger, nil}, | ||||
| 			{`[0-9]+[kMGTP]?`, LiteralNumberInteger, nil}, | ||||
| 			{`\n`, Text, nil}, | ||||
| 		}, | ||||
| 		"class": { | ||||
| 			{`[A-Za-z_]\w*`, NameClass, Pop(1)}, | ||||
| 		}, | ||||
| 		"import": { | ||||
| 			{`[a-z][\w.]*`, NameNamespace, Pop(1)}, | ||||
| 		}, | ||||
| 		"comment": { | ||||
| 			{`[^*/]`, CommentMultiline, nil}, | ||||
| 			{`/\*`, CommentMultiline, Push()}, | ||||
| 			{`\*/`, CommentMultiline, Pop(1)}, | ||||
| 			{`[*/]`, CommentMultiline, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										55
									
								
								lexers/cfengine3.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								lexers/cfengine3.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,55 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Cfengine3 lexer. | ||||
| var Cfengine3 = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "CFEngine3", | ||||
| 		Aliases:   []string{"cfengine3", "cf3"}, | ||||
| 		Filenames: []string{"*.cf"}, | ||||
| 		MimeTypes: []string{}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`#.*?\n`, Comment, nil}, | ||||
| 			{`(body)(\s+)(\S+)(\s+)(control)`, ByGroups(Keyword, Text, Keyword, Text, Keyword), nil}, | ||||
| 			{`(body|bundle)(\s+)(\S+)(\s+)(\w+)(\()`, ByGroups(Keyword, Text, Keyword, Text, NameFunction, Punctuation), Push("arglist")}, | ||||
| 			{`(body|bundle)(\s+)(\S+)(\s+)(\w+)`, ByGroups(Keyword, Text, Keyword, Text, NameFunction), nil}, | ||||
| 			{`(")([^"]+)(")(\s+)(string|slist|int|real)(\s*)(=>)(\s*)`, ByGroups(Punctuation, NameVariable, Punctuation, Text, KeywordType, Text, Operator, Text), nil}, | ||||
| 			{`(\S+)(\s*)(=>)(\s*)`, ByGroups(KeywordReserved, Text, Operator, Text), nil}, | ||||
| 			{`"`, LiteralString, Push("string")}, | ||||
| 			{`(\w+)(\()`, ByGroups(NameFunction, Punctuation), nil}, | ||||
| 			{`([\w.!&|()]+)(::)`, ByGroups(NameClass, Punctuation), nil}, | ||||
| 			{`(\w+)(:)`, ByGroups(KeywordDeclaration, Punctuation), nil}, | ||||
| 			{`@[{(][^)}]+[})]`, NameVariable, nil}, | ||||
| 			{`[(){},;]`, Punctuation, nil}, | ||||
| 			{`=>`, Operator, nil}, | ||||
| 			{`->`, Operator, nil}, | ||||
| 			{`\d+\.\d+`, LiteralNumberFloat, nil}, | ||||
| 			{`\d+`, LiteralNumberInteger, nil}, | ||||
| 			{`\w+`, NameFunction, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 		}, | ||||
| 		"string": { | ||||
| 			{`\$[{(]`, LiteralStringInterpol, Push("interpol")}, | ||||
| 			{`\\.`, LiteralStringEscape, nil}, | ||||
| 			{`"`, LiteralString, Pop(1)}, | ||||
| 			{`\n`, LiteralString, nil}, | ||||
| 			{`.`, LiteralString, nil}, | ||||
| 		}, | ||||
| 		"interpol": { | ||||
| 			{`\$[{(]`, LiteralStringInterpol, Push()}, | ||||
| 			{`[})]`, LiteralStringInterpol, Pop(1)}, | ||||
| 			{`[^${()}]+`, LiteralStringInterpol, nil}, | ||||
| 		}, | ||||
| 		"arglist": { | ||||
| 			{`\)`, Punctuation, Pop(1)}, | ||||
| 			{`,`, Punctuation, nil}, | ||||
| 			{`\w+`, NameVariable, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										62
									
								
								lexers/chaiscript.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								lexers/chaiscript.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,62 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Chaiscript lexer. | ||||
| var Chaiscript = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "ChaiScript", | ||||
| 		Aliases:   []string{"chai", "chaiscript"}, | ||||
| 		Filenames: []string{"*.chai"}, | ||||
| 		MimeTypes: []string{"text/x-chaiscript", "application/x-chaiscript"}, | ||||
| 		DotAll:    true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"commentsandwhitespace": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`//.*?\n`, CommentSingle, nil}, | ||||
| 			{`/\*.*?\*/`, CommentMultiline, nil}, | ||||
| 			{`^\#.*?\n`, CommentSingle, nil}, | ||||
| 		}, | ||||
| 		"slashstartsregex": { | ||||
| 			Include("commentsandwhitespace"), | ||||
| 			{`/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/([gim]+\b|\B)`, LiteralStringRegex, Pop(1)}, | ||||
| 			{`(?=/)`, Text, Push("#pop", "badregex")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"badregex": { | ||||
| 			{`\n`, Text, Pop(1)}, | ||||
| 		}, | ||||
| 		"root": { | ||||
| 			Include("commentsandwhitespace"), | ||||
| 			{`\n`, Text, nil}, | ||||
| 			{`[^\S\n]+`, Text, nil}, | ||||
| 			{`\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|\.\.(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?`, Operator, Push("slashstartsregex")}, | ||||
| 			{`[{(\[;,]`, Punctuation, Push("slashstartsregex")}, | ||||
| 			{`[})\].]`, Punctuation, nil}, | ||||
| 			{`[=+\-*/]`, Operator, nil}, | ||||
| 			{`(for|in|while|do|break|return|continue|if|else|throw|try|catch)\b`, Keyword, Push("slashstartsregex")}, | ||||
| 			{`(var)\b`, KeywordDeclaration, Push("slashstartsregex")}, | ||||
| 			{`(attr|def|fun)\b`, KeywordReserved, nil}, | ||||
| 			{`(true|false)\b`, KeywordConstant, nil}, | ||||
| 			{`(eval|throw)\b`, NameBuiltin, nil}, | ||||
| 			{"`\\S+`", 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, Push("dqstring")}, | ||||
| 			{`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil}, | ||||
| 		}, | ||||
| 		"dqstring": { | ||||
| 			{`\$\{[^"}]+?\}`, LiteralStringInterpol, nil}, | ||||
| 			{`\$`, LiteralStringDouble, nil}, | ||||
| 			{`\\\\`, LiteralStringDouble, nil}, | ||||
| 			{`\\"`, LiteralStringDouble, nil}, | ||||
| 			{`[^\\"$]+`, LiteralStringDouble, nil}, | ||||
| 			{`"`, LiteralStringDouble, Pop(1)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										35
									
								
								lexers/cheetah.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								lexers/cheetah.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Cheetah lexer. | ||||
| var Cheetah = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Cheetah", | ||||
| 		Aliases:   []string{"cheetah", "spitfire"}, | ||||
| 		Filenames: []string{"*.tmpl", "*.spt"}, | ||||
| 		MimeTypes: []string{"application/x-cheetah", "application/x-spitfire"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`(##[^\n]*)$`, ByGroups(Comment), nil}, | ||||
| 			{`#[*](.|\n)*?[*]#`, Comment, nil}, | ||||
| 			{`#end[^#\n]*(?:#|$)`, CommentPreproc, nil}, | ||||
| 			{`#slurp$`, CommentPreproc, nil}, | ||||
| 			{`(#[a-zA-Z]+)([^#\n]*)(#|$)`, ByGroups(CommentPreproc, Using(Python, nil), CommentPreproc), nil}, | ||||
| 			{`(\$)([a-zA-Z_][\w.]*\w)`, ByGroups(CommentPreproc, Using(Python, nil)), nil}, | ||||
| 			{`(\$\{!?)(.*?)(\})(?s)`, ByGroups(CommentPreproc, Using(Python, nil), CommentPreproc), nil}, | ||||
| 			{`(?sx) | ||||
|                 (.+?)               # anything, followed by: | ||||
|                 (?: | ||||
|                  (?=\#[#a-zA-Z]*) | # an eval comment | ||||
|                  (?=\$[a-zA-Z_{]) | # a substitution | ||||
|                  \Z                 # end of string | ||||
|                 ) | ||||
|             `, Other, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										73
									
								
								lexers/cl.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								lexers/cl.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Common Lisp lexer. | ||||
| var CommonLisp = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:            "Common Lisp", | ||||
| 		Aliases:         []string{"common-lisp", "cl", "lisp"}, | ||||
| 		Filenames:       []string{"*.cl", "*.lisp"}, | ||||
| 		MimeTypes:       []string{"text/x-common-lisp"}, | ||||
| 		CaseInsensitive: true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			Default(Push("body")), | ||||
| 		}, | ||||
| 		"multiline-comment": { | ||||
| 			{`#\|`, CommentMultiline, Push()}, | ||||
| 			{`\|#`, CommentMultiline, Pop(1)}, | ||||
| 			{`[^|#]+`, CommentMultiline, nil}, | ||||
| 			{`[|#]`, CommentMultiline, nil}, | ||||
| 		}, | ||||
| 		"commented-form": { | ||||
| 			{`\(`, CommentPreproc, Push()}, | ||||
| 			{`\)`, CommentPreproc, Pop(1)}, | ||||
| 			{`[^()]+`, CommentPreproc, nil}, | ||||
| 		}, | ||||
| 		"body": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`;.*$`, CommentSingle, nil}, | ||||
| 			{`#\|`, CommentMultiline, Push("multiline-comment")}, | ||||
| 			{`#\d*Y.*$`, CommentSpecial, nil}, | ||||
| 			{`"(\\.|\\\n|[^"\\])*"`, LiteralString, nil}, | ||||
| 			{`:(\|[^|]+\||(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~])(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~]|[#.:])*)`, LiteralStringSymbol, nil}, | ||||
| 			{`::(\|[^|]+\||(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~])(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~]|[#.:])*)`, LiteralStringSymbol, nil}, | ||||
| 			{`:#(\|[^|]+\||(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~])(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~]|[#.:])*)`, LiteralStringSymbol, nil}, | ||||
| 			{`'(\|[^|]+\||(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~])(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~]|[#.:])*)`, LiteralStringSymbol, nil}, | ||||
| 			{`'`, Operator, nil}, | ||||
| 			{"`", Operator, nil}, | ||||
| 			{"[-+]?\\d+\\.?(?=[ \"()\\'\\n,;`])", LiteralNumberInteger, nil}, | ||||
| 			{"[-+]?\\d+/\\d+(?=[ \"()\\'\\n,;`])", LiteralNumber, nil}, | ||||
| 			{"[-+]?(\\d*\\.\\d+([defls][-+]?\\d+)?|\\d+(\\.\\d*)?[defls][-+]?\\d+)(?=[ \"()\\'\\n,;`])", LiteralNumberFloat, nil}, | ||||
| 			{"#\\\\.(?=[ \"()\\'\\n,;`])", LiteralStringChar, nil}, | ||||
| 			{`#\\(\|[^|]+\||(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~])(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~]|[#.:])*)`, LiteralStringChar, nil}, | ||||
| 			{`#\(`, Operator, Push("body")}, | ||||
| 			{`#\d*\*[01]*`, LiteralOther, nil}, | ||||
| 			{`#:(\|[^|]+\||(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~])(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~]|[#.:])*)`, LiteralStringSymbol, nil}, | ||||
| 			{`#[.,]`, Operator, nil}, | ||||
| 			{`#\'`, NameFunction, nil}, | ||||
| 			{`#b[+-]?[01]+(/[01]+)?`, LiteralNumberBin, nil}, | ||||
| 			{`#o[+-]?[0-7]+(/[0-7]+)?`, LiteralNumberOct, nil}, | ||||
| 			{`#x[+-]?[0-9a-f]+(/[0-9a-f]+)?`, LiteralNumberHex, nil}, | ||||
| 			{`#\d+r[+-]?[0-9a-z]+(/[0-9a-z]+)?`, LiteralNumber, nil}, | ||||
| 			{`(#c)(\()`, ByGroups(LiteralNumber, Punctuation), Push("body")}, | ||||
| 			{`(#\d+a)(\()`, ByGroups(LiteralOther, Punctuation), Push("body")}, | ||||
| 			{`(#s)(\()`, ByGroups(LiteralOther, Punctuation), Push("body")}, | ||||
| 			{`#p?"(\\.|[^"])*"`, LiteralOther, nil}, | ||||
| 			{`#\d+=`, Operator, nil}, | ||||
| 			{`#\d+#`, Operator, nil}, | ||||
| 			{"#+nil(?=[ \"()\\'\\n,;`])\\s*\\(", CommentPreproc, Push("commented-form")}, | ||||
| 			{`#[+-]`, Operator, nil}, | ||||
| 			{`(,@|,|\.)`, Operator, nil}, | ||||
| 			{"(t|nil)(?=[ \"()\\'\\n,;`])", NameConstant, nil}, | ||||
| 			{`\*(\|[^|]+\||(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~])(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~]|[#.:])*)\*`, NameVariableGlobal, nil}, | ||||
| 			{`(\|[^|]+\||(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~])(?:\\.|[\w!$%&*+-/<=>?@\[\]^{}~]|[#.:])*)`, NameVariable, nil}, | ||||
| 			{`\(`, Punctuation, Push("body")}, | ||||
| 			{`\)`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										37
									
								
								lexers/clojure.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								lexers/clojure.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Clojure lexer. | ||||
| var Clojure = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Clojure", | ||||
| 		Aliases:   []string{"clojure", "clj"}, | ||||
| 		Filenames: []string{"*.clj"}, | ||||
| 		MimeTypes: []string{"text/x-clojure", "application/x-clojure"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`;.*$`, CommentSingle, nil}, | ||||
| 			{`[,\s]+`, Text, nil}, | ||||
| 			{`-?\d+\.\d+`, LiteralNumberFloat, nil}, | ||||
| 			{`-?\d+`, LiteralNumberInteger, nil}, | ||||
| 			{`0x-?[abcdef\d]+`, LiteralNumberHex, nil}, | ||||
| 			{`"(\\\\|\\"|[^"])*"`, LiteralString, nil}, | ||||
| 			{`'(?!#)[\w!$%*+<=>?/.#-]+`, LiteralStringSymbol, nil}, | ||||
| 			{`\\(.|[a-z]+)`, LiteralStringChar, nil}, | ||||
| 			{`::?#?(?!#)[\w!$%*+<=>?/.#-]+`, LiteralStringSymbol, nil}, | ||||
| 			{"~@|[`\\'#^~&@]", Operator, nil}, | ||||
| 			{Words(``, ` `, `.`, `def`, `do`, `fn`, `if`, `let`, `new`, `quote`, `var`, `loop`), Keyword, nil}, | ||||
| 			{Words(``, ` `, `def-`, `defn`, `defn-`, `defmacro`, `defmulti`, `defmethod`, `defstruct`, `defonce`, `declare`, `definline`, `definterface`, `defprotocol`, `defrecord`, `deftype`, `defproject`, `ns`), KeywordDeclaration, nil}, | ||||
| 			{Words(``, ` `, `*`, `+`, `-`, `->`, `/`, `<`, `<=`, `=`, `==`, `>`, `>=`, `..`, `accessor`, `agent`, `agent-errors`, `aget`, `alength`, `all-ns`, `alter`, `and`, `append-child`, `apply`, `array-map`, `aset`, `aset-boolean`, `aset-byte`, `aset-char`, `aset-double`, `aset-float`, `aset-int`, `aset-long`, `aset-short`, `assert`, `assoc`, `await`, `await-for`, `bean`, `binding`, `bit-and`, `bit-not`, `bit-or`, `bit-shift-left`, `bit-shift-right`, `bit-xor`, `boolean`, `branch?`, `butlast`, `byte`, `cast`, `char`, `children`, `class`, `clear-agent-errors`, `comment`, `commute`, `comp`, `comparator`, `complement`, `concat`, `conj`, `cons`, `constantly`, `cond`, `if-not`, `construct-proxy`, `contains?`, `count`, `create-ns`, `create-struct`, `cycle`, `dec`, `deref`, `difference`, `disj`, `dissoc`, `distinct`, `doall`, `doc`, `dorun`, `doseq`, `dosync`, `dotimes`, `doto`, `double`, `down`, `drop`, `drop-while`, `edit`, `end?`, `ensure`, `eval`, `every?`, `false?`, `ffirst`, `file-seq`, `filter`, `find`, `find-doc`, `find-ns`, `find-var`, `first`, `float`, `flush`, `for`, `fnseq`, `frest`, `gensym`, `get-proxy-class`, `get`, `hash-map`, `hash-set`, `identical?`, `identity`, `if-let`, `import`, `in-ns`, `inc`, `index`, `insert-child`, `insert-left`, `insert-right`, `inspect-table`, `inspect-tree`, `instance?`, `int`, `interleave`, `intersection`, `into`, `into-array`, `iterate`, `join`, `key`, `keys`, `keyword`, `keyword?`, `last`, `lazy-cat`, `lazy-cons`, `left`, `lefts`, `line-seq`, `list*`, `list`, `load`, `load-file`, `locking`, `long`, `loop`, `macroexpand`, `macroexpand-1`, `make-array`, `make-node`, `map`, `map-invert`, `map?`, `mapcat`, `max`, `max-key`, `memfn`, `merge`, `merge-with`, `meta`, `min`, `min-key`, `name`, `namespace`, `neg?`, `new`, `newline`, `next`, `nil?`, `node`, `not`, `not-any?`, `not-every?`, `not=`, `ns-imports`, `ns-interns`, `ns-map`, `ns-name`, `ns-publics`, `ns-refers`, `ns-resolve`, `ns-unmap`, `nth`, `nthrest`, `or`, `parse`, `partial`, `path`, `peek`, `pop`, `pos?`, `pr`, `pr-str`, `print`, `print-str`, `println`, `println-str`, `prn`, `prn-str`, `project`, `proxy`, `proxy-mappings`, `quot`, `rand`, `rand-int`, `range`, `re-find`, `re-groups`, `re-matcher`, `re-matches`, `re-pattern`, `re-seq`, `read`, `read-line`, `reduce`, `ref`, `ref-set`, `refer`, `rem`, `remove`, `remove-method`, `remove-ns`, `rename`, `rename-keys`, `repeat`, `replace`, `replicate`, `resolve`, `rest`, `resultset-seq`, `reverse`, `rfirst`, `right`, `rights`, `root`, `rrest`, `rseq`, `second`, `select`, `select-keys`, `send`, `send-off`, `seq`, `seq-zip`, `seq?`, `set`, `short`, `slurp`, `some`, `sort`, `sort-by`, `sorted-map`, `sorted-map-by`, `sorted-set`, `special-symbol?`, `split-at`, `split-with`, `str`, `string?`, `struct`, `struct-map`, `subs`, `subvec`, `symbol`, `symbol?`, `sync`, `take`, `take-nth`, `take-while`, `test`, `time`, `to-array`, `to-array-2d`, `tree-seq`, `true?`, `union`, `up`, `update-proxy`, `val`, `vals`, `var-get`, `var-set`, `var?`, `vector`, `vector-zip`, `vector?`, `when`, `when-first`, `when-let`, `when-not`, `with-local-vars`, `with-meta`, `with-open`, `with-out-str`, `xml-seq`, `xml-zip`, `zero?`, `zipmap`, `zipper`), NameBuiltin, nil}, | ||||
| 			{`(?<=\()(?!#)[\w!$%*+<=>?/.#-]+`, NameFunction, nil}, | ||||
| 			{`(?!#)[\w!$%*+<=>?/.#-]+`, NameVariable, nil}, | ||||
| 			{`(\[|\])`, Punctuation, nil}, | ||||
| 			{`(\{|\})`, Punctuation, nil}, | ||||
| 			{`(\(|\))`, Punctuation, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										50
									
								
								lexers/cobol.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								lexers/cobol.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Cobol lexer. | ||||
| var Cobol = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:            "COBOL", | ||||
| 		Aliases:         []string{"cobol"}, | ||||
| 		Filenames:       []string{"*.cob", "*.COB", "*.cpy", "*.CPY"}, | ||||
| 		MimeTypes:       []string{"text/x-cobol"}, | ||||
| 		CaseInsensitive: true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			Include("comment"), | ||||
| 			Include("strings"), | ||||
| 			Include("core"), | ||||
| 			Include("nums"), | ||||
| 			{`[a-z0-9]([\w\-]*[a-z0-9]+)?`, NameVariable, nil}, | ||||
| 			{`[ \t]+`, Text, nil}, | ||||
| 		}, | ||||
| 		"comment": { | ||||
| 			{`(^.{6}[*/].*\n|^.{6}|\*>.*\n)`, Comment, nil}, | ||||
| 		}, | ||||
| 		"core": { | ||||
| 			{`(^|(?<=[^\w\-]))(ALL\s+)?((ZEROES)|(HIGH-VALUE|LOW-VALUE|QUOTE|SPACE|ZERO)(S)?)\s*($|(?=[^\w\-]))`, NameConstant, nil}, | ||||
| 			{Words(`(^|(?<=[^\w\-]))`, `\s*($|(?=[^\w\-]))`, `ACCEPT`, `ADD`, `ALLOCATE`, `CALL`, `CANCEL`, `CLOSE`, `COMPUTE`, `CONFIGURATION`, `CONTINUE`, `DATA`, `DELETE`, `DISPLAY`, `DIVIDE`, `DIVISION`, `ELSE`, `END`, `END-ACCEPT`, `END-ADD`, `END-CALL`, `END-COMPUTE`, `END-DELETE`, `END-DISPLAY`, `END-DIVIDE`, `END-EVALUATE`, `END-IF`, `END-MULTIPLY`, `END-OF-PAGE`, `END-PERFORM`, `END-READ`, `END-RETURN`, `END-REWRITE`, `END-SEARCH`, `END-START`, `END-STRING`, `END-SUBTRACT`, `END-UNSTRING`, `END-WRITE`, `ENVIRONMENT`, `EVALUATE`, `EXIT`, `FD`, `FILE`, `FILE-CONTROL`, `FOREVER`, `FREE`, `GENERATE`, `GO`, `GOBACK`, `IDENTIFICATION`, `IF`, `INITIALIZE`, `INITIATE`, `INPUT-OUTPUT`, `INSPECT`, `INVOKE`, `I-O-CONTROL`, `LINKAGE`, `LOCAL-STORAGE`, `MERGE`, `MOVE`, `MULTIPLY`, `OPEN`, `PERFORM`, `PROCEDURE`, `PROGRAM-ID`, `RAISE`, `READ`, `RELEASE`, `RESUME`, `RETURN`, `REWRITE`, `SCREEN`, `SD`, `SEARCH`, `SECTION`, `SET`, `SORT`, `START`, `STOP`, `STRING`, `SUBTRACT`, `SUPPRESS`, `TERMINATE`, `THEN`, `UNLOCK`, `UNSTRING`, `USE`, `VALIDATE`, `WORKING-STORAGE`, `WRITE`), KeywordReserved, nil}, | ||||
| 			{Words(`(^|(?<=[^\w\-]))`, `\s*($|(?=[^\w\-]))`, `ACCESS`, `ADDRESS`, `ADVANCING`, `AFTER`, `ALL`, `ALPHABET`, `ALPHABETIC`, `ALPHABETIC-LOWER`, `ALPHABETIC-UPPER`, `ALPHANUMERIC`, `ALPHANUMERIC-EDITED`, `ALSO`, `ALTER`, `ALTERNATEANY`, `ARE`, `AREA`, `AREAS`, `ARGUMENT-NUMBER`, `ARGUMENT-VALUE`, `AS`, `ASCENDING`, `ASSIGN`, `AT`, `AUTO`, `AUTO-SKIP`, `AUTOMATIC`, `AUTOTERMINATE`, `BACKGROUND-COLOR`, `BASED`, `BEEP`, `BEFORE`, `BELL`, `BLANK`, `BLINK`, `BLOCK`, `BOTTOM`, `BY`, `BYTE-LENGTH`, `CHAINING`, `CHARACTER`, `CHARACTERS`, `CLASS`, `CODE`, `CODE-SET`, `COL`, `COLLATING`, `COLS`, `COLUMN`, `COLUMNS`, `COMMA`, `COMMAND-LINE`, `COMMIT`, `COMMON`, `CONSTANT`, `CONTAINS`, `CONTENT`, `CONTROL`, `CONTROLS`, `CONVERTING`, `COPY`, `CORR`, `CORRESPONDING`, `COUNT`, `CRT`, `CURRENCY`, `CURSOR`, `CYCLE`, `DATE`, `DAY`, `DAY-OF-WEEK`, `DE`, `DEBUGGING`, `DECIMAL-POINT`, `DECLARATIVES`, `DEFAULT`, `DELIMITED`, `DELIMITER`, `DEPENDING`, `DESCENDING`, `DETAIL`, `DISK`, `DOWN`, `DUPLICATES`, `DYNAMIC`, `EBCDIC`, `ENTRY`, `ENVIRONMENT-NAME`, `ENVIRONMENT-VALUE`, `EOL`, `EOP`, `EOS`, `ERASE`, `ERROR`, `ESCAPE`, `EXCEPTION`, `EXCLUSIVE`, `EXTEND`, `EXTERNAL`, `FILE-ID`, `FILLER`, `FINAL`, `FIRST`, `FIXED`, `FLOAT-LONG`, `FLOAT-SHORT`, `FOOTING`, `FOR`, `FOREGROUND-COLOR`, `FORMAT`, `FROM`, `FULL`, `FUNCTION`, `FUNCTION-ID`, `GIVING`, `GLOBAL`, `GROUP`, `HEADING`, `HIGHLIGHT`, `I-O`, `ID`, `IGNORE`, `IGNORING`, `IN`, `INDEX`, `INDEXED`, `INDICATE`, `INITIAL`, `INITIALIZED`, `INPUT`, `INTO`, `INTRINSIC`, `INVALID`, `IS`, `JUST`, `JUSTIFIED`, `KEY`, `LABEL`, `LAST`, `LEADING`, `LEFT`, `LENGTH`, `LIMIT`, `LIMITS`, `LINAGE`, `LINAGE-COUNTER`, `LINE`, `LINES`, `LOCALE`, `LOCK`, `LOWLIGHT`, `MANUAL`, `MEMORY`, `MINUS`, `MODE`, `MULTIPLE`, `NATIONAL`, `NATIONAL-EDITED`, `NATIVE`, `NEGATIVE`, `NEXT`, `NO`, `NULL`, `NULLS`, `NUMBER`, `NUMBERS`, `NUMERIC`, `NUMERIC-EDITED`, `OBJECT-COMPUTER`, `OCCURS`, `OF`, `OFF`, `OMITTED`, `ON`, `ONLY`, `OPTIONAL`, `ORDER`, `ORGANIZATION`, `OTHER`, `OUTPUT`, `OVERFLOW`, `OVERLINE`, `PACKED-DECIMAL`, `PADDING`, `PAGE`, `PARAGRAPH`, `PLUS`, `POINTER`, `POSITION`, `POSITIVE`, `PRESENT`, `PREVIOUS`, `PRINTER`, `PRINTING`, `PROCEDURE-POINTER`, `PROCEDURES`, `PROCEED`, `PROGRAM`, `PROGRAM-POINTER`, `PROMPT`, `QUOTE`, `QUOTES`, `RANDOM`, `RD`, `RECORD`, `RECORDING`, `RECORDS`, `RECURSIVE`, `REDEFINES`, `REEL`, `REFERENCE`, `RELATIVE`, `REMAINDER`, `REMOVAL`, `RENAMES`, `REPLACING`, `REPORT`, `REPORTING`, `REPORTS`, `REPOSITORY`, `REQUIRED`, `RESERVE`, `RETURNING`, `REVERSE-VIDEO`, `REWIND`, `RIGHT`, `ROLLBACK`, `ROUNDED`, `RUN`, `SAME`, `SCROLL`, `SECURE`, `SEGMENT-LIMIT`, `SELECT`, `SENTENCE`, `SEPARATE`, `SEQUENCE`, `SEQUENTIAL`, `SHARING`, `SIGN`, `SIGNED`, `SIGNED-INT`, `SIGNED-LONG`, `SIGNED-SHORT`, `SIZE`, `SORT-MERGE`, `SOURCE`, `SOURCE-COMPUTER`, `SPECIAL-NAMES`, `STANDARD`, `STANDARD-1`, `STANDARD-2`, `STATUS`, `SUM`, `SYMBOLIC`, `SYNC`, `SYNCHRONIZED`, `TALLYING`, `TAPE`, `TEST`, `THROUGH`, `THRU`, `TIME`, `TIMES`, `TO`, `TOP`, `TRAILING`, `TRANSFORM`, `TYPE`, `UNDERLINE`, `UNIT`, `UNSIGNED`, `UNSIGNED-INT`, `UNSIGNED-LONG`, `UNSIGNED-SHORT`, `UNTIL`, `UP`, `UPDATE`, `UPON`, `USAGE`, `USING`, `VALUE`, `VALUES`, `VARYING`, `WAIT`, `WHEN`, `WITH`, `WORDS`, `YYYYDDD`, `YYYYMMDD`), KeywordPseudo, nil}, | ||||
| 			{Words(`(^|(?<=[^\w\-]))`, `\s*($|(?=[^\w\-]))`, `ACTIVE-CLASS`, `ALIGNED`, `ANYCASE`, `ARITHMETIC`, `ATTRIBUTE`, `B-AND`, `B-NOT`, `B-OR`, `B-XOR`, `BIT`, `BOOLEAN`, `CD`, `CENTER`, `CF`, `CH`, `CHAIN`, `CLASS-ID`, `CLASSIFICATION`, `COMMUNICATION`, `CONDITION`, `DATA-POINTER`, `DESTINATION`, `DISABLE`, `EC`, `EGI`, `EMI`, `ENABLE`, `END-RECEIVE`, `ENTRY-CONVENTION`, `EO`, `ESI`, `EXCEPTION-OBJECT`, `EXPANDS`, `FACTORY`, `FLOAT-BINARY-16`, `FLOAT-BINARY-34`, `FLOAT-BINARY-7`, `FLOAT-DECIMAL-16`, `FLOAT-DECIMAL-34`, `FLOAT-EXTENDED`, `FORMAT`, `FUNCTION-POINTER`, `GET`, `GROUP-USAGE`, `IMPLEMENTS`, `INFINITY`, `INHERITS`, `INTERFACE`, `INTERFACE-ID`, `INVOKE`, `LC_ALL`, `LC_COLLATE`, `LC_CTYPE`, `LC_MESSAGES`, `LC_MONETARY`, `LC_NUMERIC`, `LC_TIME`, `LINE-COUNTER`, `MESSAGE`, `METHOD`, `METHOD-ID`, `NESTED`, `NONE`, `NORMAL`, `OBJECT`, `OBJECT-REFERENCE`, `OPTIONS`, `OVERRIDE`, `PAGE-COUNTER`, `PF`, `PH`, `PROPERTY`, `PROTOTYPE`, `PURGE`, `QUEUE`, `RAISE`, `RAISING`, `RECEIVE`, `RELATION`, `REPLACE`, `REPRESENTS-NOT-A-NUMBER`, `RESET`, `RESUME`, `RETRY`, `RF`, `RH`, `SECONDS`, `SEGMENT`, `SELF`, `SEND`, `SOURCES`, `STATEMENT`, `STEP`, `STRONG`, `SUB-QUEUE-1`, `SUB-QUEUE-2`, `SUB-QUEUE-3`, `SUPER`, `SYMBOL`, `SYSTEM-DEFAULT`, `TABLE`, `TERMINAL`, `TEXT`, `TYPEDEF`, `UCS-4`, `UNIVERSAL`, `USER-DEFAULT`, `UTF-16`, `UTF-8`, `VAL-STATUS`, `VALID`, `VALIDATE`, `VALIDATE-STATUS`), Error, nil}, | ||||
| 			{`(^|(?<=[^\w\-]))(PIC\s+.+?(?=(\s|\.\s))|PICTURE\s+.+?(?=(\s|\.\s))|(COMPUTATIONAL)(-[1-5X])?|(COMP)(-[1-5X])?|BINARY-C-LONG|BINARY-CHAR|BINARY-DOUBLE|BINARY-LONG|BINARY-SHORT|BINARY)\s*($|(?=[^\w\-]))`, KeywordType, nil}, | ||||
| 			{`(\*\*|\*|\+|-|/|<=|>=|<|>|==|/=|=)`, Operator, nil}, | ||||
| 			{`([(),;:&%.])`, Punctuation, nil}, | ||||
| 			{`(^|(?<=[^\w\-]))(ABS|ACOS|ANNUITY|ASIN|ATAN|BYTE-LENGTH|CHAR|COMBINED-DATETIME|CONCATENATE|COS|CURRENT-DATE|DATE-OF-INTEGER|DATE-TO-YYYYMMDD|DAY-OF-INTEGER|DAY-TO-YYYYDDD|EXCEPTION-(?:FILE|LOCATION|STATEMENT|STATUS)|EXP10|EXP|E|FACTORIAL|FRACTION-PART|INTEGER-OF-(?:DATE|DAY|PART)|INTEGER|LENGTH|LOCALE-(?:DATE|TIME(?:-FROM-SECONDS)?)|LOG(?:10)?|LOWER-CASE|MAX|MEAN|MEDIAN|MIDRANGE|MIN|MOD|NUMVAL(?:-C)?|ORD(?:-MAX|-MIN)?|PI|PRESENT-VALUE|RANDOM|RANGE|REM|REVERSE|SECONDS-FROM-FORMATTED-TIME|SECONDS-PAST-MIDNIGHT|SIGN|SIN|SQRT|STANDARD-DEVIATION|STORED-CHAR-LENGTH|SUBSTITUTE(?:-CASE)?|SUM|TAN|TEST-DATE-YYYYMMDD|TEST-DAY-YYYYDDD|TRIM|UPPER-CASE|VARIANCE|WHEN-COMPILED|YEAR-TO-YYYY)\s*($|(?=[^\w\-]))`, NameFunction, nil}, | ||||
| 			{`(^|(?<=[^\w\-]))(true|false)\s*($|(?=[^\w\-]))`, NameBuiltin, nil}, | ||||
| 			{`(^|(?<=[^\w\-]))(equal|equals|ne|lt|le|gt|ge|greater|less|than|not|and|or)\s*($|(?=[^\w\-]))`, OperatorWord, nil}, | ||||
| 		}, | ||||
| 		"strings": { | ||||
| 			{`"[^"\n]*("|\n)`, LiteralStringDouble, nil}, | ||||
| 			{`'[^'\n]*('|\n)`, LiteralStringSingle, nil}, | ||||
| 		}, | ||||
| 		"nums": { | ||||
| 			{`\d+(\s*|\.$|$)`, LiteralNumberInteger, nil}, | ||||
| 			{`[+-]?\d*\.\d+(E[-+]?\d+)?`, LiteralNumberFloat, nil}, | ||||
| 			{`[+-]?\d+\.\d*(E[-+]?\d+)?`, LiteralNumberFloat, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										90
									
								
								lexers/coffee.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								lexers/coffee.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,90 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Coffeescript lexer. | ||||
| var Coffeescript = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:         "CoffeeScript", | ||||
| 		Aliases:      []string{"coffee-script", "coffeescript", "coffee"}, | ||||
| 		Filenames:    []string{"*.coffee"}, | ||||
| 		MimeTypes:    []string{"text/coffeescript"}, | ||||
| 		NotMultiline: true, | ||||
| 		DotAll:       true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"commentsandwhitespace": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`###[^#].*?###`, CommentMultiline, nil}, | ||||
| 			{`#(?!##[^#]).*?\n`, CommentSingle, nil}, | ||||
| 		}, | ||||
| 		"multilineregex": { | ||||
| 			{`[^/#]+`, LiteralStringRegex, nil}, | ||||
| 			{`///([gim]+\b|\B)`, LiteralStringRegex, Pop(1)}, | ||||
| 			{`#\{`, LiteralStringInterpol, Push("interpoling_string")}, | ||||
| 			{`[/#]`, LiteralStringRegex, nil}, | ||||
| 		}, | ||||
| 		"slashstartsregex": { | ||||
| 			Include("commentsandwhitespace"), | ||||
| 			{`///`, LiteralStringRegex, Push("#pop", "multilineregex")}, | ||||
| 			{`/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/([gim]+\b|\B)`, LiteralStringRegex, Pop(1)}, | ||||
| 			{`/`, Operator, nil}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"root": { | ||||
| 			Include("commentsandwhitespace"), | ||||
| 			{`^(?=\s|/)`, Text, Push("slashstartsregex")}, | ||||
| 			{"\\+\\+|~|&&|\\band\\b|\\bor\\b|\\bis\\b|\\bisnt\\b|\\bnot\\b|\\?|:|\\|\\||\\\\(?=\\n)|(<<|>>>?|==?(?!>)|!=?|=(?!>)|-(?!>)|[<>+*`%&\\|\\^/])=?", Operator, Push("slashstartsregex")}, | ||||
| 			{`(?:\([^()]*\))?\s*[=-]>`, NameFunction, Push("slashstartsregex")}, | ||||
| 			{`[{(\[;,]`, Punctuation, Push("slashstartsregex")}, | ||||
| 			{`[})\].]`, Punctuation, nil}, | ||||
| 			{`(?<![.$])(for|own|in|of|while|until|loop|break|return|continue|switch|when|then|if|unless|else|throw|try|catch|finally|new|delete|typeof|instanceof|super|extends|this|class|by)\b`, Keyword, Push("slashstartsregex")}, | ||||
| 			{`(?<![.$])(true|false|yes|no|on|off|null|NaN|Infinity|undefined)\b`, KeywordConstant, nil}, | ||||
| 			{`(Array|Boolean|Date|Error|Function|Math|netscape|Number|Object|Packages|RegExp|String|sun|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|isNaN|parseFloat|parseInt|document|window)\b`, NameBuiltin, nil}, | ||||
| 			{`[$a-zA-Z_][\w.:$]*\s*[:=]\s`, NameVariable, Push("slashstartsregex")}, | ||||
| 			{`@[$a-zA-Z_][\w.:$]*\s*[:=]\s`, NameVariableInstance, Push("slashstartsregex")}, | ||||
| 			{`@`, NameOther, Push("slashstartsregex")}, | ||||
| 			{`@?[$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}, | ||||
| 			{`"""`, LiteralString, Push("tdqs")}, | ||||
| 			{`'''`, LiteralString, Push("tsqs")}, | ||||
| 			{`"`, LiteralString, Push("dqs")}, | ||||
| 			{`'`, LiteralString, Push("sqs")}, | ||||
| 		}, | ||||
| 		"strings": { | ||||
| 			{`[^#\\\'"]+`, LiteralString, nil}, | ||||
| 		}, | ||||
| 		"interpoling_string": { | ||||
| 			{`\}`, LiteralStringInterpol, Pop(1)}, | ||||
| 			Include("root"), | ||||
| 		}, | ||||
| 		"dqs": { | ||||
| 			{`"`, LiteralString, Pop(1)}, | ||||
| 			{`\\.|\'`, LiteralString, nil}, | ||||
| 			{`#\{`, LiteralStringInterpol, Push("interpoling_string")}, | ||||
| 			{`#`, LiteralString, nil}, | ||||
| 			Include("strings"), | ||||
| 		}, | ||||
| 		"sqs": { | ||||
| 			{`'`, LiteralString, Pop(1)}, | ||||
| 			{`#|\\.|"`, LiteralString, nil}, | ||||
| 			Include("strings"), | ||||
| 		}, | ||||
| 		"tdqs": { | ||||
| 			{`"""`, LiteralString, Pop(1)}, | ||||
| 			{`\\.|\'|"`, LiteralString, nil}, | ||||
| 			{`#\{`, LiteralStringInterpol, Push("interpoling_string")}, | ||||
| 			{`#`, LiteralString, nil}, | ||||
| 			Include("strings"), | ||||
| 		}, | ||||
| 		"tsqs": { | ||||
| 			{`'''`, LiteralString, Pop(1)}, | ||||
| 			{`#|\\.|\'|"`, LiteralString, nil}, | ||||
| 			Include("strings"), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										47
									
								
								lexers/coldfusion.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								lexers/coldfusion.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Cfstatement lexer. | ||||
| var Cfstatement = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:            "cfstatement", | ||||
| 		Aliases:         []string{"cfs"}, | ||||
| 		Filenames:       []string{}, | ||||
| 		MimeTypes:       []string{}, | ||||
| 		NotMultiline:    true, | ||||
| 		CaseInsensitive: true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`//.*?\n`, CommentSingle, nil}, | ||||
| 			{`/\*(?:.|\n)*?\*/`, CommentMultiline, nil}, | ||||
| 			{`\+\+|--`, Operator, nil}, | ||||
| 			{`[-+*/^&=!]`, Operator, nil}, | ||||
| 			{`<=|>=|<|>|==`, Operator, nil}, | ||||
| 			{`mod\b`, Operator, nil}, | ||||
| 			{`(eq|lt|gt|lte|gte|not|is|and|or)\b`, Operator, nil}, | ||||
| 			{`\|\||&&`, Operator, nil}, | ||||
| 			{`\?`, Operator, nil}, | ||||
| 			{`"`, LiteralStringDouble, Push("string")}, | ||||
| 			{`'.*?'`, LiteralStringSingle, nil}, | ||||
| 			{`\d+`, LiteralNumber, nil}, | ||||
| 			{`(if|else|len|var|xml|default|break|switch|component|property|function|do|try|catch|in|continue|for|return|while|required|any|array|binary|boolean|component|date|guid|numeric|query|string|struct|uuid|case)\b`, Keyword, nil}, | ||||
| 			{`(true|false|null)\b`, KeywordConstant, nil}, | ||||
| 			{`(application|session|client|cookie|super|this|variables|arguments)\b`, NameConstant, nil}, | ||||
| 			{`([a-z_$][\w.]*)(\s*)(\()`, ByGroups(NameFunction, Text, Punctuation), nil}, | ||||
| 			{`[a-z_$][\w.]*`, NameVariable, nil}, | ||||
| 			{`[()\[\]{};:,.\\]`, Punctuation, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 		}, | ||||
| 		"string": { | ||||
| 			{`""`, LiteralStringDouble, nil}, | ||||
| 			{`#.+?#`, LiteralStringInterpol, nil}, | ||||
| 			{`[^"#]+`, LiteralStringDouble, nil}, | ||||
| 			{`#`, LiteralStringDouble, nil}, | ||||
| 			{`"`, LiteralStringDouble, Pop(1)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										62
									
								
								lexers/coq.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								lexers/coq.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,62 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Coq lexer. | ||||
| var Coq = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Coq", | ||||
| 		Aliases:   []string{"coq"}, | ||||
| 		Filenames: []string{"*.v"}, | ||||
| 		MimeTypes: []string{"text/x-coq"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`false|true|\(\)|\[\]`, NameBuiltinPseudo, nil}, | ||||
| 			{`\(\*`, Comment, Push("comment")}, | ||||
| 			{Words(`\b`, `\b`, `Section`, `Module`, `End`, `Require`, `Import`, `Export`, `Variable`, `Variables`, `Parameter`, `Parameters`, `Axiom`, `Hypothesis`, `Hypotheses`, `Notation`, `Local`, `Tactic`, `Reserved`, `Scope`, `Open`, `Close`, `Bind`, `Delimit`, `Definition`, `Let`, `Ltac`, `Fixpoint`, `CoFixpoint`, `Morphism`, `Relation`, `Implicit`, `Arguments`, `Set`, `Unset`, `Contextual`, `Strict`, `Prenex`, `Implicits`, `Inductive`, `CoInductive`, `Record`, `Structure`, `Canonical`, `Coercion`, `Theorem`, `Lemma`, `Corollary`, `Proposition`, `Fact`, `Remark`, `Example`, `Proof`, `Goal`, `Save`, `Qed`, `Defined`, `Hint`, `Resolve`, `Rewrite`, `View`, `Search`, `Show`, `Print`, `Printing`, `All`, `Graph`, `Projections`, `inside`, `outside`, `Check`, `Global`, `Instance`, `Class`, `Existing`, `Universe`, `Polymorphic`, `Monomorphic`, `Context`), KeywordNamespace, nil}, | ||||
| 			{Words(`\b`, `\b`, `forall`, `exists`, `exists2`, `fun`, `fix`, `cofix`, `struct`, `match`, `end`, `in`, `return`, `let`, `if`, `is`, `then`, `else`, `for`, `of`, `nosimpl`, `with`, `as`), Keyword, nil}, | ||||
| 			{Words(`\b`, `\b`, `Type`, `Prop`), KeywordType, nil}, | ||||
| 			{Words(`\b`, `\b`, `pose`, `set`, `move`, `case`, `elim`, `apply`, `clear`, `hnf`, `intro`, `intros`, `generalize`, `rename`, `pattern`, `after`, `destruct`, `induction`, `using`, `refine`, `inversion`, `injection`, `rewrite`, `congr`, `unlock`, `compute`, `ring`, `field`, `replace`, `fold`, `unfold`, `change`, `cutrewrite`, `simpl`, `have`, `suff`, `wlog`, `suffices`, `without`, `loss`, `nat_norm`, `assert`, `cut`, `trivial`, `revert`, `bool_congr`, `nat_congr`, `symmetry`, `transitivity`, `auto`, `split`, `left`, `right`, `autorewrite`, `tauto`, `setoid_rewrite`, `intuition`, `eauto`, `eapply`, `econstructor`, `etransitivity`, `constructor`, `erewrite`, `red`, `cbv`, `lazy`, `vm_compute`, `native_compute`, `subst`), Keyword, nil}, | ||||
| 			{Words(`\b`, `\b`, `by`, `done`, `exact`, `reflexivity`, `tauto`, `romega`, `omega`, `assumption`, `solve`, `contradiction`, `discriminate`, `congruence`), KeywordPseudo, nil}, | ||||
| 			{Words(`\b`, `\b`, `do`, `last`, `first`, `try`, `idtac`, `repeat`), KeywordReserved, nil}, | ||||
| 			{`\b([A-Z][\w\']*)`, Name, nil}, | ||||
| 			{"(\u03bb|\u03a0|\\|\\}|\\{\\||\\\\/|/\\\\|=>|~|\\}|\\|]|\\||\\{<|\\{|`|_|]|\\[\\||\\[>|\\[<|\\[|\\?\\?|\\?|>\\}|>]|>|=|<->|<-|<|;;|;|:>|:=|::|:|\\.\\.|\\.|->|-\\.|-|,|\\+|\\*|\\)|\\(|&&|&|#|!=)", Operator, nil}, | ||||
| 			{`([=<>@^|&+\*/$%-]|[!?~])?[!$%&*+\./:<=>?@^|~-]`, Operator, nil}, | ||||
| 			{`\b(unit|nat|bool|string|ascii|list)\b`, KeywordType, nil}, | ||||
| 			{`[^\W\d][\w']*`, Name, nil}, | ||||
| 			{`\d[\d_]*`, LiteralNumberInteger, nil}, | ||||
| 			{`0[xX][\da-fA-F][\da-fA-F_]*`, LiteralNumberHex, nil}, | ||||
| 			{`0[oO][0-7][0-7_]*`, LiteralNumberOct, nil}, | ||||
| 			{`0[bB][01][01_]*`, LiteralNumberBin, nil}, | ||||
| 			{`-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)`, LiteralNumberFloat, nil}, | ||||
| 			{`'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'`, LiteralStringChar, nil}, | ||||
| 			{`'.'`, LiteralStringChar, nil}, | ||||
| 			{`'`, Keyword, nil}, | ||||
| 			{`"`, LiteralStringDouble, Push("string")}, | ||||
| 			{`[~?][a-z][\w\']*:`, Name, nil}, | ||||
| 		}, | ||||
| 		"comment": { | ||||
| 			{`[^(*)]+`, Comment, nil}, | ||||
| 			{`\(\*`, Comment, Push()}, | ||||
| 			{`\*\)`, Comment, Pop(1)}, | ||||
| 			{`[(*)]`, Comment, nil}, | ||||
| 		}, | ||||
| 		"string": { | ||||
| 			{`[^"]+`, LiteralStringDouble, nil}, | ||||
| 			{`""`, LiteralStringDouble, nil}, | ||||
| 			{`"`, LiteralStringDouble, Pop(1)}, | ||||
| 		}, | ||||
| 		"dotted": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`\.`, Punctuation, nil}, | ||||
| 			{`[A-Z][\w\']*(?=\s*\.)`, NameNamespace, nil}, | ||||
| 			{`[A-Z][\w\']*`, NameClass, Pop(1)}, | ||||
| 			{`[a-z][a-z0-9_\']*`, Name, Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										190
									
								
								lexers/cpp.go
									
									
									
									
									
								
							
							
						
						
									
										190
									
								
								lexers/cpp.go
									
									
									
									
									
								
							| @@ -1,103 +1,101 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
|     . "github.com/alecthomas/chroma" // nolint | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // CPP is a C++ lexer. | ||||
| // CPP lexer. | ||||
| var CPP = Register(MustNewLexer( | ||||
|     &Config{ | ||||
|         Name:      "C++", | ||||
|         Aliases:   []string{"cpp", "c++"}, | ||||
|         Filenames: []string{"*.cpp", "*.hpp", "*.c++", "*.h++", "*.cc", "*.hh", "*.cxx", "*.hxx", "*.C", "*.H", "*.cp", "*.CPP"}, | ||||
|         MimeTypes: []string{"text/x-c++hdr", "text/x-c++src"}, | ||||
|     }, | ||||
|     Rules{ | ||||
|         "statements": { | ||||
|             {`(?: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)\b`, Keyword, nil}, | ||||
|             {`char(16_t|32_t)\b`, KeywordType, nil}, | ||||
|             {`(class)(\s+)`, ByGroups(Keyword, Text), Push("classname")}, | ||||
|             // TODO: Fix backref. | ||||
|             // {`(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}, | ||||
|             {`(?: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)\b`, Keyword, nil}, | ||||
|             {`(bool|int|long|float|short|double|char|unsigned|signed|void)\b`, KeywordType, nil}, | ||||
|             {`(?:inline|_inline|__inline|naked|restrict|thread|typename)\b`, KeywordReserved, nil}, | ||||
|             {`(__m(128i|128d|128|64))\b`, KeywordReserved, nil}, | ||||
|             {`__(?:asm|int8|based|except|int16|stdcall|cdecl|fastcall|int32|declspec|finally|int64|try|leave|wchar_t|w64|unaligned|raise|noop|identifier|forceinline|assume)\b`, 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")), | ||||
|             {`__(?:virtual_inheritance|uuidof|super|single_inheritance|multiple_inheritance|interface|event)\b`, 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}, | ||||
|             // TODO: Fix? | ||||
|             // {`(?<=\\)\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}, | ||||
|         }, | ||||
|     }, | ||||
| 	&Config{ | ||||
| 		Name:      "C++", | ||||
| 		Aliases:   []string{"cpp", "c++"}, | ||||
| 		Filenames: []string{"*.cpp", "*.hpp", "*.c++", "*.h++", "*.cc", "*.hh", "*.cxx", "*.hxx", "*.C", "*.H", "*.cp", "*.CPP"}, | ||||
| 		MimeTypes: []string{"text/x-c++hdr", "text/x-c++src"}, | ||||
| 	}, | ||||
| 	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)(\s+)`, 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}, | ||||
| 			{`(bool|int|long|float|short|double|char|unsigned|signed|void)\b`, KeywordType, 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}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
|   | ||||
							
								
								
									
										261
									
								
								lexers/crystal.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										261
									
								
								lexers/crystal.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,261 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Crystal lexer. | ||||
| var Crystal = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Crystal", | ||||
| 		Aliases:   []string{"cr", "crystal"}, | ||||
| 		Filenames: []string{"*.cr"}, | ||||
| 		MimeTypes: []string{"text/x-crystal"}, | ||||
| 		DotAll:    true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`#.*?$`, CommentSingle, nil}, | ||||
| 			{Words(``, `\b`, `abstract`, `asm`, `as`, `begin`, `break`, `case`, `do`, `else`, `elsif`, `end`, `ensure`, `extend`, `ifdef`, `if`, `include`, `instance_sizeof`, `next`, `of`, `pointerof`, `private`, `protected`, `rescue`, `return`, `require`, `sizeof`, `super`, `then`, `typeof`, `unless`, `until`, `when`, `while`, `with`, `yield`), Keyword, nil}, | ||||
| 			{Words(``, `\b`, `true`, `false`, `nil`), KeywordConstant, nil}, | ||||
| 			{`(module|lib)(\s+)([a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*)`, ByGroups(Keyword, Text, NameNamespace), nil}, | ||||
| 			{`(def|fun|macro)(\s+)((?:[a-zA-Z_]\w*::)*)`, ByGroups(Keyword, Text, NameNamespace), Push("funcname")}, | ||||
| 			{"def(?=[*%&^`~+-/\\[<>=])", Keyword, Push("funcname")}, | ||||
| 			{`(class|struct|union|type|alias|enum)(\s+)((?:[a-zA-Z_]\w*::)*)`, ByGroups(Keyword, Text, NameNamespace), Push("classname")}, | ||||
| 			{`(self|out|uninitialized)\b|(is_a|responds_to)\?`, KeywordPseudo, nil}, | ||||
| 			{Words(``, `\b`, `debugger`, `record`, `pp`, `assert_responds_to`, `spawn`, `parallel`, `getter`, `setter`, `property`, `delegate`, `def_hash`, `def_equals`, `def_equals_and_hash`, `forward_missing_to`), NameBuiltinPseudo, nil}, | ||||
| 			{`getter[!?]|property[!?]|__(DIR|FILE|LINE)__\b`, NameBuiltinPseudo, nil}, | ||||
| 			{Words(`(?<!\.)`, `\b`, `Object`, `Value`, `Struct`, `Reference`, `Proc`, `Class`, `Nil`, `Symbol`, `Enum`, `Void`, `Bool`, `Number`, `Int`, `Int8`, `Int16`, `Int32`, `Int64`, `UInt8`, `UInt16`, `UInt32`, `UInt64`, `Float`, `Float32`, `Float64`, `Char`, `String`, `Pointer`, `Slice`, `Range`, `Exception`, `Regex`, `Mutex`, `StaticArray`, `Array`, `Hash`, `Set`, `Tuple`, `Deque`, `Box`, `Process`, `File`, `Dir`, `Time`, `Channel`, `Concurrent`, `Scheduler`, `abort`, `at_exit`, `caller`, `delay`, `exit`, `fork`, `future`, `get_stack_top`, `gets`, `lazy`, `loop`, `main`, `p`, `print`, `printf`, `puts`, `raise`, `rand`, `read_line`, `sleep`, `sprintf`, `system`, `with_color`), NameBuiltin, nil}, | ||||
| 			{"(?<!\\w)(<<-?)([\"`\\']?)([a-zA-Z_]\\w*)(\\2)(.*?\\n)", StringHeredoc, nil}, | ||||
| 			{`(<<-?)("|\')()(\2)(.*?\n)`, StringHeredoc, nil}, | ||||
| 			{`__END__`, CommentPreproc, Push("end-part")}, | ||||
| 			{`(?:^|(?<=[=<>~!:])|(?<=(?:\s|;)when\s)|(?<=(?:\s|;)or\s)|(?<=(?:\s|;)and\s)|(?<=\.index\s)|(?<=\.scan\s)|(?<=\.sub\s)|(?<=\.sub!\s)|(?<=\.gsub\s)|(?<=\.gsub!\s)|(?<=\.match\s)|(?<=(?:\s|;)if\s)|(?<=(?:\s|;)elsif\s)|(?<=^when\s)|(?<=^index\s)|(?<=^scan\s)|(?<=^sub\s)|(?<=^gsub\s)|(?<=^sub!\s)|(?<=^gsub!\s)|(?<=^match\s)|(?<=^if\s)|(?<=^elsif\s))(\s*)(/)`, ByGroups(Text, LiteralStringRegex), Push("multiline-regex")}, | ||||
| 			{`(?<=\(|,|\[)/`, LiteralStringRegex, Push("multiline-regex")}, | ||||
| 			{`(\s+)(/)(?![\s=])`, ByGroups(Text, LiteralStringRegex), Push("multiline-regex")}, | ||||
| 			{`(0o[0-7]+(?:_[0-7]+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?`, ByGroups(LiteralNumberOct, Text, Operator), nil}, | ||||
| 			{`(0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?`, ByGroups(LiteralNumberHex, Text, Operator), nil}, | ||||
| 			{`(0b[01]+(?:_[01]+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?`, ByGroups(LiteralNumberBin, Text, Operator), nil}, | ||||
| 			{`((?:0(?![0-9])|[1-9][\d_]*)(?:\.\d[\d_]*)(?:e[+-]?[0-9]+)?(?:_?f[0-9]+)?)(\s*)([/?])?`, ByGroups(LiteralNumberFloat, Text, Operator), nil}, | ||||
| 			{`((?:0(?![0-9])|[1-9][\d_]*)(?:\.\d[\d_]*)?(?:e[+-]?[0-9]+)(?:_?f[0-9]+)?)(\s*)([/?])?`, ByGroups(LiteralNumberFloat, Text, Operator), nil}, | ||||
| 			{`((?:0(?![0-9])|[1-9][\d_]*)(?:\.\d[\d_]*)?(?:e[+-]?[0-9]+)?(?:_?f[0-9]+))(\s*)([/?])?`, ByGroups(LiteralNumberFloat, Text, Operator), nil}, | ||||
| 			{`(0\b|[1-9][\d]*(?:_\d+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?`, ByGroups(LiteralNumberInteger, Text, Operator), nil}, | ||||
| 			{`@@[a-zA-Z_]\w*`, NameVariableClass, nil}, | ||||
| 			{`@[a-zA-Z_]\w*`, NameVariableInstance, nil}, | ||||
| 			{`\$\w+`, NameVariableGlobal, nil}, | ||||
| 			{"\\$[!@&`\\'+~=/\\\\,;.<>_*$?:\"^-]", NameVariableGlobal, nil}, | ||||
| 			{`\$-[0adFiIlpvw]`, NameVariableGlobal, nil}, | ||||
| 			{`::`, Operator, nil}, | ||||
| 			Include("strings"), | ||||
| 			{`\?(\\[MC]-)*(\\([\\befnrtv#"\']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})|\S)(?!\w)`, LiteralStringChar, nil}, | ||||
| 			{`[A-Z][A-Z_]+\b`, NameConstant, nil}, | ||||
| 			{`\{%`, LiteralStringInterpol, Push("in-macro-control")}, | ||||
| 			{`\{\{`, LiteralStringInterpol, Push("in-macro-expr")}, | ||||
| 			{`(@\[)(\s*)([A-Z]\w*)`, ByGroups(Operator, Text, NameDecorator), Push("in-attr")}, | ||||
| 			{Words(`(\.|::)`, ``, `!=`, `!~`, `!`, `%`, `&&`, `&`, `**`, `*`, `+`, `-`, `/`, `<=>`, `<<`, `<=`, `<`, `===`, `==`, `=~`, `=`, `>=`, `>>`, `>`, `[]=`, `[]?`, `[]`, `^`, `||`, `|`, `~`), ByGroups(Operator, NameOperator), nil}, | ||||
| 			{"(\\.|::)([a-zA-Z_]\\w*[!?]?|[*%&^`~+\\-/\\[<>=])", ByGroups(Operator, Name), nil}, | ||||
| 			{`[a-zA-Z_]\w*(?:[!?](?!=))?`, Name, nil}, | ||||
| 			{`(\[|\]\??|\*\*|<=>?|>=|<<?|>>?|=~|===|!~|&&?|\|\||\.{1,3})`, Operator, nil}, | ||||
| 			{`[-+/*%=<>&!^|~]=?`, Operator, nil}, | ||||
| 			{`[(){};,/?:\\]`, Punctuation, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 		}, | ||||
| 		"funcname": { | ||||
| 			{"(?:([a-zA-Z_]\\w*)(\\.))?([a-zA-Z_]\\w*[!?]?|\\*\\*?|[-+]@?|[/%&|^`~]|\\[\\]=?|<<|>>|<=?>|>=?|===?)", ByGroups(NameClass, Operator, NameFunction), Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"classname": { | ||||
| 			{`[A-Z_]\w*`, NameClass, nil}, | ||||
| 			{`(\()(\s*)([A-Z_]\w*)(\s*)(\))`, ByGroups(Punctuation, Text, NameClass, Text, Punctuation), nil}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"in-intp": { | ||||
| 			{`\{`, LiteralStringInterpol, Push()}, | ||||
| 			{`\}`, LiteralStringInterpol, Pop(1)}, | ||||
| 			Include("root"), | ||||
| 		}, | ||||
| 		"string-intp": { | ||||
| 			{`#\{`, LiteralStringInterpol, Push("in-intp")}, | ||||
| 		}, | ||||
| 		"string-escaped": { | ||||
| 			{`\\([\\befnstv#"\']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})`, LiteralStringEscape, nil}, | ||||
| 		}, | ||||
| 		"string-intp-escaped": { | ||||
| 			Include("string-intp"), | ||||
| 			Include("string-escaped"), | ||||
| 		}, | ||||
| 		"interpolated-regex": { | ||||
| 			Include("string-intp"), | ||||
| 			{`[\\#]`, LiteralStringRegex, nil}, | ||||
| 			{`[^\\#]+`, LiteralStringRegex, nil}, | ||||
| 		}, | ||||
| 		"interpolated-string": { | ||||
| 			Include("string-intp"), | ||||
| 			{`[\\#]`, LiteralStringOther, nil}, | ||||
| 			{`[^\\#]+`, LiteralStringOther, nil}, | ||||
| 		}, | ||||
| 		"multiline-regex": { | ||||
| 			Include("string-intp"), | ||||
| 			{`\\\\`, LiteralStringRegex, nil}, | ||||
| 			{`\\/`, LiteralStringRegex, nil}, | ||||
| 			{`[\\#]`, LiteralStringRegex, nil}, | ||||
| 			{`[^\\/#]+`, LiteralStringRegex, nil}, | ||||
| 			{`/[imsx]*`, LiteralStringRegex, Pop(1)}, | ||||
| 		}, | ||||
| 		"end-part": { | ||||
| 			{`.+`, CommentPreproc, Pop(1)}, | ||||
| 		}, | ||||
| 		"in-macro-control": { | ||||
| 			{`\{%`, LiteralStringInterpol, Push()}, | ||||
| 			{`%\}`, LiteralStringInterpol, Pop(1)}, | ||||
| 			{`for\b|in\b`, Keyword, nil}, | ||||
| 			Include("root"), | ||||
| 		}, | ||||
| 		"in-macro-expr": { | ||||
| 			{`\{\{`, LiteralStringInterpol, Push()}, | ||||
| 			{`\}\}`, LiteralStringInterpol, Pop(1)}, | ||||
| 			Include("root"), | ||||
| 		}, | ||||
| 		"in-attr": { | ||||
| 			{`\[`, Operator, Push()}, | ||||
| 			{`\]`, Operator, Pop(1)}, | ||||
| 			Include("root"), | ||||
| 		}, | ||||
| 		"strings": { | ||||
| 			{`\:@{0,2}[a-zA-Z_]\w*[!?]?`, LiteralStringSymbol, nil}, | ||||
| 			{Words(`\:@{0,2}`, ``, `!=`, `!~`, `!`, `%`, `&&`, `&`, `**`, `*`, `+`, `-`, `/`, `<=>`, `<<`, `<=`, `<`, `===`, `==`, `=~`, `=`, `>=`, `>>`, `>`, `[]=`, `[]?`, `[]`, `^`, `||`, `|`, `~`), LiteralStringSymbol, nil}, | ||||
| 			{`:'(\\\\|\\'|[^'])*'`, LiteralStringSymbol, nil}, | ||||
| 			{`'(\\\\|\\'|[^']|\\[^'\\]+)'`, LiteralStringChar, nil}, | ||||
| 			{`:"`, LiteralStringSymbol, Push("simple-sym")}, | ||||
| 			{`([a-zA-Z_]\w*)(:)(?!:)`, ByGroups(LiteralStringSymbol, Punctuation), nil}, | ||||
| 			{`"`, LiteralStringDouble, Push("simple-string")}, | ||||
| 			{"(?<!\\.)`", LiteralStringBacktick, Push("simple-backtick")}, | ||||
| 			{`%\{`, LiteralStringOther, Push("cb-intp-string")}, | ||||
| 			{`%[wi]\{`, LiteralStringOther, Push("cb-string")}, | ||||
| 			{`%r\{`, LiteralStringRegex, Push("cb-regex")}, | ||||
| 			{`%\[`, LiteralStringOther, Push("sb-intp-string")}, | ||||
| 			{`%[wi]\[`, LiteralStringOther, Push("sb-string")}, | ||||
| 			{`%r\[`, LiteralStringRegex, Push("sb-regex")}, | ||||
| 			{`%\(`, LiteralStringOther, Push("pa-intp-string")}, | ||||
| 			{`%[wi]\(`, LiteralStringOther, Push("pa-string")}, | ||||
| 			{`%r\(`, LiteralStringRegex, Push("pa-regex")}, | ||||
| 			{`%<`, LiteralStringOther, Push("ab-intp-string")}, | ||||
| 			{`%[wi]<`, LiteralStringOther, Push("ab-string")}, | ||||
| 			{`%r<`, LiteralStringRegex, Push("ab-regex")}, | ||||
| 			{`(%r([\W_]))((?:\\\2|(?!\2).)*)(\2[imsx]*)`, String, nil}, | ||||
| 			{`(%[wi]([\W_]))((?:\\\2|(?!\2).)*)(\2)`, String, nil}, | ||||
| 			{`(?<=[-+/*%=<>&!^|~,(])(\s*)(%([\t ])(?:(?:\\\3|(?!\3).)*)\3)`, ByGroups(Text, LiteralStringOther, None), nil}, | ||||
| 			{`^(\s*)(%([\t ])(?:(?:\\\3|(?!\3).)*)\3)`, ByGroups(Text, LiteralStringOther, None), nil}, | ||||
| 			{`(%([\[{(<]))((?:\\\2|(?!\2).)*)(\2)`, String, nil}, | ||||
| 		}, | ||||
| 		"simple-string": { | ||||
| 			Include("string-intp-escaped"), | ||||
| 			{`[^\\"#]+`, LiteralStringDouble, nil}, | ||||
| 			{`[\\#]`, LiteralStringDouble, nil}, | ||||
| 			{`"`, LiteralStringDouble, Pop(1)}, | ||||
| 		}, | ||||
| 		"simple-sym": { | ||||
| 			Include("string-escaped"), | ||||
| 			{`[^\\"#]+`, LiteralStringSymbol, nil}, | ||||
| 			{`[\\#]`, LiteralStringSymbol, nil}, | ||||
| 			{`"`, LiteralStringSymbol, Pop(1)}, | ||||
| 		}, | ||||
| 		"simple-backtick": { | ||||
| 			Include("string-intp-escaped"), | ||||
| 			{"[^\\\\`#]+", LiteralStringBacktick, nil}, | ||||
| 			{`[\\#]`, LiteralStringBacktick, nil}, | ||||
| 			{"`", LiteralStringBacktick, Pop(1)}, | ||||
| 		}, | ||||
| 		"cb-intp-string": { | ||||
| 			{`\\[\{]`, LiteralStringOther, nil}, | ||||
| 			{`\{`, LiteralStringOther, Push()}, | ||||
| 			{`\}`, LiteralStringOther, Pop(1)}, | ||||
| 			Include("string-intp-escaped"), | ||||
| 			{`[\\#{}]`, LiteralStringOther, nil}, | ||||
| 			{`[^\\#{}]+`, LiteralStringOther, nil}, | ||||
| 		}, | ||||
| 		"cb-string": { | ||||
| 			{`\\[\\{}]`, LiteralStringOther, nil}, | ||||
| 			{`\{`, LiteralStringOther, Push()}, | ||||
| 			{`\}`, LiteralStringOther, Pop(1)}, | ||||
| 			{`[\\#{}]`, LiteralStringOther, nil}, | ||||
| 			{`[^\\#{}]+`, LiteralStringOther, nil}, | ||||
| 		}, | ||||
| 		"cb-regex": { | ||||
| 			{`\\[\\{}]`, LiteralStringRegex, nil}, | ||||
| 			{`\{`, LiteralStringRegex, Push()}, | ||||
| 			{`\}[imsx]*`, LiteralStringRegex, Pop(1)}, | ||||
| 			Include("string-intp"), | ||||
| 			{`[\\#{}]`, LiteralStringRegex, nil}, | ||||
| 			{`[^\\#{}]+`, LiteralStringRegex, nil}, | ||||
| 		}, | ||||
| 		"sb-intp-string": { | ||||
| 			{`\\[\[]`, LiteralStringOther, nil}, | ||||
| 			{`\[`, LiteralStringOther, Push()}, | ||||
| 			{`\]`, LiteralStringOther, Pop(1)}, | ||||
| 			Include("string-intp-escaped"), | ||||
| 			{`[\\#\[\]]`, LiteralStringOther, nil}, | ||||
| 			{`[^\\#\[\]]+`, LiteralStringOther, nil}, | ||||
| 		}, | ||||
| 		"sb-string": { | ||||
| 			{`\\[\\\[\]]`, LiteralStringOther, nil}, | ||||
| 			{`\[`, LiteralStringOther, Push()}, | ||||
| 			{`\]`, LiteralStringOther, Pop(1)}, | ||||
| 			{`[\\#\[\]]`, LiteralStringOther, nil}, | ||||
| 			{`[^\\#\[\]]+`, LiteralStringOther, nil}, | ||||
| 		}, | ||||
| 		"sb-regex": { | ||||
| 			{`\\[\\\[\]]`, LiteralStringRegex, nil}, | ||||
| 			{`\[`, LiteralStringRegex, Push()}, | ||||
| 			{`\][imsx]*`, LiteralStringRegex, Pop(1)}, | ||||
| 			Include("string-intp"), | ||||
| 			{`[\\#\[\]]`, LiteralStringRegex, nil}, | ||||
| 			{`[^\\#\[\]]+`, LiteralStringRegex, nil}, | ||||
| 		}, | ||||
| 		"pa-intp-string": { | ||||
| 			{`\\[\(]`, LiteralStringOther, nil}, | ||||
| 			{`\(`, LiteralStringOther, Push()}, | ||||
| 			{`\)`, LiteralStringOther, Pop(1)}, | ||||
| 			Include("string-intp-escaped"), | ||||
| 			{`[\\#()]`, LiteralStringOther, nil}, | ||||
| 			{`[^\\#()]+`, LiteralStringOther, nil}, | ||||
| 		}, | ||||
| 		"pa-string": { | ||||
| 			{`\\[\\()]`, LiteralStringOther, nil}, | ||||
| 			{`\(`, LiteralStringOther, Push()}, | ||||
| 			{`\)`, LiteralStringOther, Pop(1)}, | ||||
| 			{`[\\#()]`, LiteralStringOther, nil}, | ||||
| 			{`[^\\#()]+`, LiteralStringOther, nil}, | ||||
| 		}, | ||||
| 		"pa-regex": { | ||||
| 			{`\\[\\()]`, LiteralStringRegex, nil}, | ||||
| 			{`\(`, LiteralStringRegex, Push()}, | ||||
| 			{`\)[imsx]*`, LiteralStringRegex, Pop(1)}, | ||||
| 			Include("string-intp"), | ||||
| 			{`[\\#()]`, LiteralStringRegex, nil}, | ||||
| 			{`[^\\#()]+`, LiteralStringRegex, nil}, | ||||
| 		}, | ||||
| 		"ab-intp-string": { | ||||
| 			{`\\[<]`, LiteralStringOther, nil}, | ||||
| 			{`<`, LiteralStringOther, Push()}, | ||||
| 			{`>`, LiteralStringOther, Pop(1)}, | ||||
| 			Include("string-intp-escaped"), | ||||
| 			{`[\\#<>]`, LiteralStringOther, nil}, | ||||
| 			{`[^\\#<>]+`, LiteralStringOther, nil}, | ||||
| 		}, | ||||
| 		"ab-string": { | ||||
| 			{`\\[\\<>]`, LiteralStringOther, nil}, | ||||
| 			{`<`, LiteralStringOther, Push()}, | ||||
| 			{`>`, LiteralStringOther, Pop(1)}, | ||||
| 			{`[\\#<>]`, LiteralStringOther, nil}, | ||||
| 			{`[^\\#<>]+`, LiteralStringOther, nil}, | ||||
| 		}, | ||||
| 		"ab-regex": { | ||||
| 			{`\\[\\<>]`, LiteralStringRegex, nil}, | ||||
| 			{`<`, LiteralStringRegex, Push()}, | ||||
| 			{`>[imsx]*`, LiteralStringRegex, Pop(1)}, | ||||
| 			Include("string-intp"), | ||||
| 			{`[\\#<>]`, LiteralStringRegex, nil}, | ||||
| 			{`[^\\#<>]+`, LiteralStringRegex, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										134
									
								
								lexers/cython.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								lexers/cython.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,134 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Cython lexer. | ||||
| var Cython = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Cython", | ||||
| 		Aliases:   []string{"cython", "pyx", "pyrex"}, | ||||
| 		Filenames: []string{"*.pyx", "*.pxd", "*.pxi"}, | ||||
| 		MimeTypes: []string{"text/x-cython", "application/x-cython"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\n`, Text, nil}, | ||||
| 			{`^(\s*)("""(?:.|\n)*?""")`, ByGroups(Text, LiteralStringDoc), nil}, | ||||
| 			{`^(\s*)('''(?:.|\n)*?''')`, ByGroups(Text, LiteralStringDoc), nil}, | ||||
| 			{`[^\S\n]+`, Text, nil}, | ||||
| 			{`#.*$`, Comment, nil}, | ||||
| 			{`[]{}:(),;[]`, Punctuation, nil}, | ||||
| 			{`\\\n`, Text, nil}, | ||||
| 			{`\\`, Text, nil}, | ||||
| 			{`(in|is|and|or|not)\b`, OperatorWord, nil}, | ||||
| 			{`(<)([a-zA-Z0-9.?]+)(>)`, ByGroups(Punctuation, KeywordType, Punctuation), nil}, | ||||
| 			{`!=|==|<<|>>|[-~+/*%=<>&^|.?]`, Operator, nil}, | ||||
| 			{`(from)(\d+)(<=)(\s+)(<)(\d+)(:)`, ByGroups(Keyword, LiteralNumberInteger, Operator, Name, Operator, Name, Punctuation), nil}, | ||||
| 			Include("keywords"), | ||||
| 			{`(def|property)(\s+)`, ByGroups(Keyword, Text), Push("funcname")}, | ||||
| 			{`(cp?def)(\s+)`, ByGroups(Keyword, Text), Push("cdef")}, | ||||
| 			{`(cdef)(:)`, ByGroups(Keyword, Punctuation), nil}, | ||||
| 			{`(class|struct)(\s+)`, ByGroups(Keyword, Text), Push("classname")}, | ||||
| 			{`(from)(\s+)`, ByGroups(Keyword, Text), Push("fromimport")}, | ||||
| 			{`(c?import)(\s+)`, ByGroups(Keyword, Text), Push("import")}, | ||||
| 			Include("builtins"), | ||||
| 			Include("backtick"), | ||||
| 			{`(?:[rR]|[uU][rR]|[rR][uU])"""`, LiteralString, Push("tdqs")}, | ||||
| 			{`(?:[rR]|[uU][rR]|[rR][uU])'''`, LiteralString, Push("tsqs")}, | ||||
| 			{`(?:[rR]|[uU][rR]|[rR][uU])"`, LiteralString, Push("dqs")}, | ||||
| 			{`(?:[rR]|[uU][rR]|[rR][uU])'`, LiteralString, Push("sqs")}, | ||||
| 			{`[uU]?"""`, LiteralString, Combined("stringescape", "tdqs")}, | ||||
| 			{`[uU]?'''`, LiteralString, Combined("stringescape", "tsqs")}, | ||||
| 			{`[uU]?"`, LiteralString, Combined("stringescape", "dqs")}, | ||||
| 			{`[uU]?'`, LiteralString, Combined("stringescape", "sqs")}, | ||||
| 			Include("name"), | ||||
| 			Include("numbers"), | ||||
| 		}, | ||||
| 		"keywords": { | ||||
| 			{Words(``, `\b`, `assert`, `break`, `by`, `continue`, `ctypedef`, `del`, `elif`, `else`, `except`, `except?`, `exec`, `finally`, `for`, `fused`, `gil`, `global`, `if`, `include`, `lambda`, `nogil`, `pass`, `print`, `raise`, `return`, `try`, `while`, `yield`, `as`, `with`), Keyword, nil}, | ||||
| 			{`(DEF|IF|ELIF|ELSE)\b`, CommentPreproc, nil}, | ||||
| 		}, | ||||
| 		"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`, `unsigned`, `vars`, `xrange`, `zip`), NameBuiltin, nil}, | ||||
| 			{`(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|NULL)\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`, `Warning`, `ZeroDivisionError`), NameException, nil}, | ||||
| 		}, | ||||
| 		"numbers": { | ||||
| 			{`(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?`, LiteralNumberFloat, nil}, | ||||
| 			{`0\d+`, LiteralNumberOct, nil}, | ||||
| 			{`0[xX][a-fA-F0-9]+`, LiteralNumberHex, nil}, | ||||
| 			{`\d+L`, LiteralNumberIntegerLong, nil}, | ||||
| 			{`\d+`, LiteralNumberInteger, nil}, | ||||
| 		}, | ||||
| 		"backtick": { | ||||
| 			{"`.*?`", LiteralStringBacktick, nil}, | ||||
| 		}, | ||||
| 		"name": { | ||||
| 			{`@\w+`, NameDecorator, nil}, | ||||
| 			{`[a-zA-Z_]\w*`, Name, nil}, | ||||
| 		}, | ||||
| 		"funcname": { | ||||
| 			{`[a-zA-Z_]\w*`, NameFunction, Pop(1)}, | ||||
| 		}, | ||||
| 		"cdef": { | ||||
| 			{`(public|readonly|extern|api|inline)\b`, KeywordReserved, nil}, | ||||
| 			{`(struct|enum|union|class)\b`, Keyword, nil}, | ||||
| 			{`([a-zA-Z_]\w*)(\s*)(?=[(:#=]|$)`, ByGroups(NameFunction, Text), Pop(1)}, | ||||
| 			{`([a-zA-Z_]\w*)(\s*)(,)`, ByGroups(NameFunction, Text, Punctuation), nil}, | ||||
| 			{`from\b`, Keyword, Pop(1)}, | ||||
| 			{`as\b`, Keyword, nil}, | ||||
| 			{`:`, Punctuation, Pop(1)}, | ||||
| 			{`(?=["\'])`, Text, Pop(1)}, | ||||
| 			{`[a-zA-Z_]\w*`, KeywordType, nil}, | ||||
| 			{`.`, Text, nil}, | ||||
| 		}, | ||||
| 		"classname": { | ||||
| 			{`[a-zA-Z_]\w*`, NameClass, Pop(1)}, | ||||
| 		}, | ||||
| 		"import": { | ||||
| 			{`(\s+)(as)(\s+)`, ByGroups(Text, Keyword, Text), nil}, | ||||
| 			{`[a-zA-Z_][\w.]*`, NameNamespace, nil}, | ||||
| 			{`(\s*)(,)(\s*)`, ByGroups(Text, Operator, Text), nil}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"fromimport": { | ||||
| 			{`(\s+)(c?import)\b`, ByGroups(Text, Keyword), Pop(1)}, | ||||
| 			{`[a-zA-Z_.][\w.]*`, NameNamespace, nil}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"stringescape": { | ||||
| 			{`\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})`, LiteralStringEscape, nil}, | ||||
| 		}, | ||||
| 		"strings": { | ||||
| 			{`%(\([a-zA-Z0-9]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]`, LiteralStringInterpol, nil}, | ||||
| 			{`[^\\\'"%\n]+`, LiteralString, nil}, | ||||
| 			{`[\'"\\]`, LiteralString, nil}, | ||||
| 			{`%`, LiteralString, nil}, | ||||
| 		}, | ||||
| 		"nl": { | ||||
| 			{`\n`, LiteralString, nil}, | ||||
| 		}, | ||||
| 		"dqs": { | ||||
| 			{`"`, LiteralString, Pop(1)}, | ||||
| 			{`\\\\|\\"|\\\n`, LiteralStringEscape, nil}, | ||||
| 			Include("strings"), | ||||
| 		}, | ||||
| 		"sqs": { | ||||
| 			{`'`, LiteralString, Pop(1)}, | ||||
| 			{`\\\\|\\'|\\\n`, LiteralStringEscape, nil}, | ||||
| 			Include("strings"), | ||||
| 		}, | ||||
| 		"tdqs": { | ||||
| 			{`"""`, LiteralString, Pop(1)}, | ||||
| 			Include("strings"), | ||||
| 			Include("nl"), | ||||
| 		}, | ||||
| 		"tsqs": { | ||||
| 			{`'''`, LiteralString, Pop(1)}, | ||||
| 			Include("strings"), | ||||
| 			Include("nl"), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										90
									
								
								lexers/dart.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								lexers/dart.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,90 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Dart lexer. | ||||
| var Dart = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Dart", | ||||
| 		Aliases:   []string{"dart"}, | ||||
| 		Filenames: []string{"*.dart"}, | ||||
| 		MimeTypes: []string{"text/x-dart"}, | ||||
| 		DotAll:    true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			Include("string_literal"), | ||||
| 			{`#!(.*?)$`, CommentPreproc, nil}, | ||||
| 			{`\b(import|export)\b`, Keyword, Push("import_decl")}, | ||||
| 			{`\b(library|source|part of|part)\b`, Keyword, nil}, | ||||
| 			{`[^\S\n]+`, Text, nil}, | ||||
| 			{`//.*?\n`, CommentSingle, nil}, | ||||
| 			{`/\*.*?\*/`, CommentMultiline, nil}, | ||||
| 			{`\b(class)\b(\s+)`, ByGroups(KeywordDeclaration, Text), Push("class")}, | ||||
| 			{`\b(assert|break|case|catch|continue|default|do|else|finally|for|if|in|is|new|return|super|switch|this|throw|try|while)\b`, Keyword, nil}, | ||||
| 			{`\b(abstract|async|await|const|extends|factory|final|get|implements|native|operator|set|static|sync|typedef|var|with|yield)\b`, KeywordDeclaration, nil}, | ||||
| 			{`\b(bool|double|dynamic|int|num|Object|String|void)\b`, KeywordType, nil}, | ||||
| 			{`\b(false|null|true)\b`, KeywordConstant, nil}, | ||||
| 			{`[~!%^&*+=|?:<>/-]|as\b`, Operator, nil}, | ||||
| 			{`[a-zA-Z_$]\w*:`, NameLabel, nil}, | ||||
| 			{`[a-zA-Z_$]\w*`, Name, nil}, | ||||
| 			{`[(){}\[\],.;]`, Punctuation, nil}, | ||||
| 			{`0[xX][0-9a-fA-F]+`, LiteralNumberHex, nil}, | ||||
| 			{`\d+(\.\d*)?([eE][+-]?\d+)?`, LiteralNumber, nil}, | ||||
| 			{`\.\d+([eE][+-]?\d+)?`, LiteralNumber, nil}, | ||||
| 			{`\n`, Text, nil}, | ||||
| 		}, | ||||
| 		"class": { | ||||
| 			{`[a-zA-Z_$]\w*`, NameClass, Pop(1)}, | ||||
| 		}, | ||||
| 		"import_decl": { | ||||
| 			Include("string_literal"), | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`\b(as|show|hide)\b`, Keyword, nil}, | ||||
| 			{`[a-zA-Z_$]\w*`, Name, nil}, | ||||
| 			{`\,`, Punctuation, nil}, | ||||
| 			{`\;`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"string_literal": { | ||||
| 			{`r"""([\w\W]*?)"""`, LiteralStringDouble, nil}, | ||||
| 			{`r'''([\w\W]*?)'''`, LiteralStringSingle, nil}, | ||||
| 			{`r"(.*?)"`, LiteralStringDouble, nil}, | ||||
| 			{`r'(.*?)'`, LiteralStringSingle, nil}, | ||||
| 			{`"""`, LiteralStringDouble, Push("string_double_multiline")}, | ||||
| 			{`'''`, LiteralStringSingle, Push("string_single_multiline")}, | ||||
| 			{`"`, LiteralStringDouble, Push("string_double")}, | ||||
| 			{`'`, LiteralStringSingle, Push("string_single")}, | ||||
| 		}, | ||||
| 		"string_common": { | ||||
| 			{`\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\{[0-9A-Fa-f]*\}|[a-z'\"$\\])`, LiteralStringEscape, nil}, | ||||
| 			{`(\$)([a-zA-Z_]\w*)`, ByGroups(LiteralStringInterpol, Name), nil}, | ||||
| 			{`(\$\{)(.*?)(\})`, ByGroups(LiteralStringInterpol, UsingSelf("root"), LiteralStringInterpol), nil}, | ||||
| 		}, | ||||
| 		"string_double": { | ||||
| 			{`"`, LiteralStringDouble, Pop(1)}, | ||||
| 			{`[^"$\\\n]+`, LiteralStringDouble, nil}, | ||||
| 			Include("string_common"), | ||||
| 			{`\$+`, LiteralStringDouble, nil}, | ||||
| 		}, | ||||
| 		"string_double_multiline": { | ||||
| 			{`"""`, LiteralStringDouble, Pop(1)}, | ||||
| 			{`[^"$\\]+`, LiteralStringDouble, nil}, | ||||
| 			Include("string_common"), | ||||
| 			{`(\$|\")+`, LiteralStringDouble, nil}, | ||||
| 		}, | ||||
| 		"string_single": { | ||||
| 			{`'`, LiteralStringSingle, Pop(1)}, | ||||
| 			{`[^'$\\\n]+`, LiteralStringSingle, nil}, | ||||
| 			Include("string_common"), | ||||
| 			{`\$+`, LiteralStringSingle, nil}, | ||||
| 		}, | ||||
| 		"string_single_multiline": { | ||||
| 			{`'''`, LiteralStringSingle, Pop(1)}, | ||||
| 			{`[^\'$\\]+`, LiteralStringSingle, nil}, | ||||
| 			Include("string_common"), | ||||
| 			{`(\$|\')+`, LiteralStringSingle, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										27
									
								
								lexers/diff.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								lexers/diff.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Diff lexer. | ||||
| var Diff = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Diff", | ||||
| 		Aliases:   []string{"diff", "udiff"}, | ||||
| 		Filenames: []string{"*.diff", "*.patch"}, | ||||
| 		MimeTypes: []string{"text/x-diff", "text/x-patch"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{` .*\n`, Text, nil}, | ||||
| 			{`\+.*\n`, GenericInserted, nil}, | ||||
| 			{`-.*\n`, GenericDeleted, nil}, | ||||
| 			{`!.*\n`, GenericStrong, nil}, | ||||
| 			{`@.*\n`, GenericSubheading, nil}, | ||||
| 			{`([Ii]ndex|diff).*\n`, GenericHeading, nil}, | ||||
| 			{`=.*\n`, GenericHeading, nil}, | ||||
| 			{`.*\n`, Text, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										52
									
								
								lexers/django.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								lexers/django.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Django/Jinja lexer. | ||||
| var DjangoJinja = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Django/Jinja", | ||||
| 		Aliases:   []string{"django", "jinja"}, | ||||
| 		Filenames: []string{}, | ||||
| 		MimeTypes: []string{"application/x-django-templating", "application/x-jinja"}, | ||||
| 		DotAll:    true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`[^{]+`, Other, nil}, | ||||
| 			{`\{\{`, CommentPreproc, Push("var")}, | ||||
| 			{`\{[*#].*?[*#]\}`, Comment, nil}, | ||||
| 			{`(\{%)(-?\s*)(comment)(\s*-?)(%\})(.*?)(\{%)(-?\s*)(endcomment)(\s*-?)(%\})`, ByGroups(CommentPreproc, Text, Keyword, Text, CommentPreproc, Comment, CommentPreproc, Text, Keyword, Text, CommentPreproc), nil}, | ||||
| 			{`(\{%)(-?\s*)(raw)(\s*-?)(%\})(.*?)(\{%)(-?\s*)(endraw)(\s*-?)(%\})`, ByGroups(CommentPreproc, Text, Keyword, Text, CommentPreproc, Text, CommentPreproc, Text, Keyword, Text, CommentPreproc), nil}, | ||||
| 			{`(\{%)(-?\s*)(filter)(\s+)([a-zA-Z_]\w*)`, ByGroups(CommentPreproc, Text, Keyword, Text, NameFunction), Push("block")}, | ||||
| 			{`(\{%)(-?\s*)([a-zA-Z_]\w*)`, ByGroups(CommentPreproc, Text, Keyword), Push("block")}, | ||||
| 			{`\{`, Other, nil}, | ||||
| 		}, | ||||
| 		"varnames": { | ||||
| 			{`(\|)(\s*)([a-zA-Z_]\w*)`, ByGroups(Operator, Text, NameFunction), nil}, | ||||
| 			{`(is)(\s+)(not)?(\s+)?([a-zA-Z_]\w*)`, ByGroups(Keyword, Text, Keyword, Text, NameFunction), nil}, | ||||
| 			{`(_|true|false|none|True|False|None)\b`, KeywordPseudo, nil}, | ||||
| 			{`(in|as|reversed|recursive|not|and|or|is|if|else|import|with(?:(?:out)?\s*context)?|scoped|ignore\s+missing)\b`, Keyword, nil}, | ||||
| 			{`(loop|block|super|forloop)\b`, NameBuiltin, nil}, | ||||
| 			{`[a-zA-Z_][\w-]*`, NameVariable, nil}, | ||||
| 			{`\.\w+`, NameVariable, nil}, | ||||
| 			{`:?"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil}, | ||||
| 			{`:?'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil}, | ||||
| 			{`([{}()\[\]+\-*/,:~]|[><=]=?)`, Operator, nil}, | ||||
| 			{`[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?`, LiteralNumber, nil}, | ||||
| 		}, | ||||
| 		"var": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`(-?)(\}\})`, ByGroups(Text, CommentPreproc), Pop(1)}, | ||||
| 			Include("varnames"), | ||||
| 		}, | ||||
| 		"block": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`(-?)(%\})`, ByGroups(Text, CommentPreproc), Pop(1)}, | ||||
| 			Include("varnames"), | ||||
| 			{`.`, Punctuation, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										25
									
								
								lexers/docker.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								lexers/docker.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Docker lexer. | ||||
| var Docker = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:            "Docker", | ||||
| 		Aliases:         []string{"docker", "dockerfile"}, | ||||
| 		Filenames:       []string{"Dockerfile", "*.docker"}, | ||||
| 		MimeTypes:       []string{"text/x-dockerfile-config"}, | ||||
| 		CaseInsensitive: true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`^(ONBUILD)(\s+)((?:FROM|MAINTAINER|CMD|EXPOSE|ENV|ADD|ENTRYPOINT|VOLUME|WORKDIR))\b`, ByGroups(NameKeyword, TextWhitespace, Keyword), nil}, | ||||
| 			{`^((?:FROM|MAINTAINER|CMD|EXPOSE|ENV|ADD|ENTRYPOINT|VOLUME|WORKDIR))\b(.*)`, ByGroups(Keyword, LiteralString), nil}, | ||||
| 			{`#.*`, Comment, nil}, | ||||
| 			{`RUN`, Keyword, nil}, | ||||
| 			{`(.*\\\n)*.+`, Using(Bash, nil), nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										68
									
								
								lexers/dtd.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								lexers/dtd.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,68 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Dtd lexer. | ||||
| var Dtd = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "DTD", | ||||
| 		Aliases:   []string{"dtd"}, | ||||
| 		Filenames: []string{"*.dtd"}, | ||||
| 		MimeTypes: []string{"application/xml-dtd"}, | ||||
| 		DotAll:    true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			Include("common"), | ||||
| 			{`(<!ELEMENT)(\s+)(\S+)`, ByGroups(Keyword, Text, NameTag), Push("element")}, | ||||
| 			{`(<!ATTLIST)(\s+)(\S+)`, ByGroups(Keyword, Text, NameTag), Push("attlist")}, | ||||
| 			{`(<!ENTITY)(\s+)(\S+)`, ByGroups(Keyword, Text, NameEntity), Push("entity")}, | ||||
| 			{`(<!NOTATION)(\s+)(\S+)`, ByGroups(Keyword, Text, NameTag), Push("notation")}, | ||||
| 			{`(<!\[)([^\[\s]+)(\s*)(\[)`, ByGroups(Keyword, NameEntity, Text, Keyword), nil}, | ||||
| 			{`(<!DOCTYPE)(\s+)([^>\s]+)`, ByGroups(Keyword, Text, NameTag), nil}, | ||||
| 			{`PUBLIC|SYSTEM`, KeywordConstant, nil}, | ||||
| 			{`[\[\]>]`, Keyword, nil}, | ||||
| 		}, | ||||
| 		"common": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`(%|&)[^;]*;`, NameEntity, nil}, | ||||
| 			{`<!--`, Comment, Push("comment")}, | ||||
| 			{`[(|)*,?+]`, Operator, nil}, | ||||
| 			{`"[^"]*"`, LiteralStringDouble, nil}, | ||||
| 			{`\'[^\']*\'`, LiteralStringSingle, nil}, | ||||
| 		}, | ||||
| 		"comment": { | ||||
| 			{`[^-]+`, Comment, nil}, | ||||
| 			{`-->`, Comment, Pop(1)}, | ||||
| 			{`-`, Comment, nil}, | ||||
| 		}, | ||||
| 		"element": { | ||||
| 			Include("common"), | ||||
| 			{`EMPTY|ANY|#PCDATA`, KeywordConstant, nil}, | ||||
| 			{`[^>\s|()?+*,]+`, NameTag, nil}, | ||||
| 			{`>`, Keyword, Pop(1)}, | ||||
| 		}, | ||||
| 		"attlist": { | ||||
| 			Include("common"), | ||||
| 			{`CDATA|IDREFS|IDREF|ID|NMTOKENS|NMTOKEN|ENTITIES|ENTITY|NOTATION`, KeywordConstant, nil}, | ||||
| 			{`#REQUIRED|#IMPLIED|#FIXED`, KeywordConstant, nil}, | ||||
| 			{`xml:space|xml:lang`, KeywordReserved, nil}, | ||||
| 			{`[^>\s|()?+*,]+`, NameAttribute, nil}, | ||||
| 			{`>`, Keyword, Pop(1)}, | ||||
| 		}, | ||||
| 		"entity": { | ||||
| 			Include("common"), | ||||
| 			{`SYSTEM|PUBLIC|NDATA`, KeywordConstant, nil}, | ||||
| 			{`[^>\s|()?+*,]+`, NameEntity, nil}, | ||||
| 			{`>`, Keyword, Pop(1)}, | ||||
| 		}, | ||||
| 		"notation": { | ||||
| 			Include("common"), | ||||
| 			{`SYSTEM|PUBLIC`, KeywordConstant, nil}, | ||||
| 			{`[^>\s|()?+*,]+`, NameAttribute, nil}, | ||||
| 			{`>`, Keyword, Pop(1)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										50
									
								
								lexers/ebnf.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								lexers/ebnf.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Ebnf lexer. | ||||
| var Ebnf = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "EBNF", | ||||
| 		Aliases:   []string{"ebnf"}, | ||||
| 		Filenames: []string{"*.ebnf"}, | ||||
| 		MimeTypes: []string{"text/x-ebnf"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			Include("whitespace"), | ||||
| 			Include("comment_start"), | ||||
| 			Include("identifier"), | ||||
| 			{`=`, Operator, Push("production")}, | ||||
| 		}, | ||||
| 		"production": { | ||||
| 			Include("whitespace"), | ||||
| 			Include("comment_start"), | ||||
| 			Include("identifier"), | ||||
| 			{`"[^"]*"`, LiteralStringDouble, nil}, | ||||
| 			{`'[^']*'`, LiteralStringSingle, nil}, | ||||
| 			{`(\?[^?]*\?)`, NameEntity, nil}, | ||||
| 			{`[\[\]{}(),|]`, Punctuation, nil}, | ||||
| 			{`-`, Operator, nil}, | ||||
| 			{`;`, Punctuation, Pop(1)}, | ||||
| 			{`\.`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"whitespace": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 		}, | ||||
| 		"comment_start": { | ||||
| 			{`\(\*`, CommentMultiline, Push("comment")}, | ||||
| 		}, | ||||
| 		"comment": { | ||||
| 			{`[^*)]`, CommentMultiline, nil}, | ||||
| 			Include("comment_start"), | ||||
| 			{`\*\)`, CommentMultiline, Pop(1)}, | ||||
| 			{`[*)]`, CommentMultiline, nil}, | ||||
| 		}, | ||||
| 		"identifier": { | ||||
| 			{`([a-zA-Z][\w \-]*)`, Keyword, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										269
									
								
								lexers/elixir.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										269
									
								
								lexers/elixir.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,269 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Elixir lexer. | ||||
| var Elixir = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Elixir", | ||||
| 		Aliases:   []string{"elixir", "ex", "exs"}, | ||||
| 		Filenames: []string{"*.ex", "*.exs"}, | ||||
| 		MimeTypes: []string{"text/x-elixir"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`#.*$`, CommentSingle, nil}, | ||||
| 			{`(\?)(\\x\{)([\da-fA-F]+)(\})`, ByGroups(LiteralStringChar, LiteralStringEscape, LiteralNumberHex, LiteralStringEscape), nil}, | ||||
| 			{`(\?)(\\x[\da-fA-F]{1,2})`, ByGroups(LiteralStringChar, LiteralStringEscape), nil}, | ||||
| 			{`(\?)(\\[abdefnrstv])`, ByGroups(LiteralStringChar, LiteralStringEscape), nil}, | ||||
| 			{`\?\\?.`, LiteralStringChar, nil}, | ||||
| 			{`:::`, LiteralStringSymbol, nil}, | ||||
| 			{`::`, Operator, nil}, | ||||
| 			{`:(?:\.\.\.|<<>>|%\{\}|%|\{\})`, LiteralStringSymbol, nil}, | ||||
| 			{`:(?:(?:\.\.\.|[a-z_]\w*[!?]?)|[A-Z]\w*(?:\.[A-Z]\w*)*|(?:\<\<\<|\>\>\>|\|\|\||\&\&\&|\^\^\^|\~\~\~|\=\=\=|\!\=\=|\~\>\>|\<\~\>|\|\~\>|\<\|\>|\=\=|\!\=|\<\=|\>\=|\&\&|\|\||\<\>|\+\+|\-\-|\|\>|\=\~|\-\>|\<\-|\||\.|\=|\~\>|\<\~|\<|\>|\+|\-|\*|\/|\!|\^|\&))`, LiteralStringSymbol, nil}, | ||||
| 			{`:"`, LiteralStringSymbol, Push("string_double_atom")}, | ||||
| 			{`:'`, LiteralStringSymbol, Push("string_single_atom")}, | ||||
| 			{`((?:\.\.\.|<<>>|%\{\}|%|\{\})|(?:(?:\.\.\.|[a-z_]\w*[!?]?)|[A-Z]\w*(?:\.[A-Z]\w*)*|(?:\<\<\<|\>\>\>|\|\|\||\&\&\&|\^\^\^|\~\~\~|\=\=\=|\!\=\=|\~\>\>|\<\~\>|\|\~\>|\<\|\>|\=\=|\!\=|\<\=|\>\=|\&\&|\|\||\<\>|\+\+|\-\-|\|\>|\=\~|\-\>|\<\-|\||\.|\=|\~\>|\<\~|\<|\>|\+|\-|\*|\/|\!|\^|\&)))(:)(?=\s|\n)`, ByGroups(LiteralStringSymbol, Punctuation), nil}, | ||||
| 			{`@(?:\.\.\.|[a-z_]\w*[!?]?)`, NameAttribute, nil}, | ||||
| 			{`(?:\.\.\.|[a-z_]\w*[!?]?)`, Name, nil}, | ||||
| 			{`(%?)([A-Z]\w*(?:\.[A-Z]\w*)*)`, ByGroups(Punctuation, NameClass), nil}, | ||||
| 			{`\<\<\<|\>\>\>|\|\|\||\&\&\&|\^\^\^|\~\~\~|\=\=\=|\!\=\=|\~\>\>|\<\~\>|\|\~\>|\<\|\>`, Operator, nil}, | ||||
| 			{`\=\=|\!\=|\<\=|\>\=|\&\&|\|\||\<\>|\+\+|\-\-|\|\>|\=\~|\-\>|\<\-|\||\.|\=|\~\>|\<\~`, Operator, nil}, | ||||
| 			{`\\\\|\<\<|\>\>|\=\>|\(|\)|\:|\;|\,|\[|\]`, Punctuation, nil}, | ||||
| 			{`&\d`, NameEntity, nil}, | ||||
| 			{`\<|\>|\+|\-|\*|\/|\!|\^|\&`, Operator, nil}, | ||||
| 			{`0b[01]+`, LiteralNumberBin, nil}, | ||||
| 			{`0o[0-7]+`, LiteralNumberOct, nil}, | ||||
| 			{`0x[\da-fA-F]+`, LiteralNumberHex, nil}, | ||||
| 			{`\d(_?\d)*\.\d(_?\d)*([eE][-+]?\d(_?\d)*)?`, LiteralNumberFloat, nil}, | ||||
| 			{`\d(_?\d)*`, LiteralNumberInteger, nil}, | ||||
| 			{`"""\s*`, LiteralStringHeredoc, Push("heredoc_double")}, | ||||
| 			{`'''\s*$`, LiteralStringHeredoc, Push("heredoc_single")}, | ||||
| 			{`"`, LiteralStringDouble, Push("string_double")}, | ||||
| 			{`'`, LiteralStringSingle, Push("string_single")}, | ||||
| 			Include("sigils"), | ||||
| 			{`%\{`, Punctuation, Push("map_key")}, | ||||
| 			{`\{`, Punctuation, Push("tuple")}, | ||||
| 		}, | ||||
| 		"heredoc_double": { | ||||
| 			{`^\s*"""`, LiteralStringHeredoc, Pop(1)}, | ||||
| 			Include("heredoc_interpol"), | ||||
| 		}, | ||||
| 		"heredoc_single": { | ||||
| 			{`^\s*'''`, LiteralStringHeredoc, Pop(1)}, | ||||
| 			Include("heredoc_interpol"), | ||||
| 		}, | ||||
| 		"heredoc_interpol": { | ||||
| 			{`[^#\\\n]+`, LiteralStringHeredoc, nil}, | ||||
| 			Include("escapes"), | ||||
| 			{`\\.`, LiteralStringHeredoc, nil}, | ||||
| 			{`\n+`, LiteralStringHeredoc, nil}, | ||||
| 			Include("interpol"), | ||||
| 		}, | ||||
| 		"heredoc_no_interpol": { | ||||
| 			{`[^\\\n]+`, LiteralStringHeredoc, nil}, | ||||
| 			{`\\.`, LiteralStringHeredoc, nil}, | ||||
| 			{`\n+`, LiteralStringHeredoc, nil}, | ||||
| 		}, | ||||
| 		"escapes": { | ||||
| 			{`(\\x\{)([\da-fA-F]+)(\})`, ByGroups(LiteralStringEscape, LiteralNumberHex, LiteralStringEscape), nil}, | ||||
| 			{`(\\x[\da-fA-F]{1,2})`, LiteralStringEscape, nil}, | ||||
| 			{`(\\[abdefnrstv])`, LiteralStringEscape, nil}, | ||||
| 		}, | ||||
| 		"interpol": { | ||||
| 			{`#\{`, LiteralStringInterpol, Push("interpol_string")}, | ||||
| 		}, | ||||
| 		"interpol_string": { | ||||
| 			{`\}`, LiteralStringInterpol, Pop(1)}, | ||||
| 			Include("root"), | ||||
| 		}, | ||||
| 		"map_key": { | ||||
| 			Include("root"), | ||||
| 			{`:`, Punctuation, Push("map_val")}, | ||||
| 			{`=>`, Punctuation, Push("map_val")}, | ||||
| 			{`\}`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"map_val": { | ||||
| 			Include("root"), | ||||
| 			{`,`, Punctuation, Pop(1)}, | ||||
| 			{`(?=\})`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"tuple": { | ||||
| 			Include("root"), | ||||
| 			{`\}`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"string_double": { | ||||
| 			{`[^#"\\]+`, LiteralStringDouble, nil}, | ||||
| 			Include("escapes"), | ||||
| 			{`\\.`, LiteralStringDouble, nil}, | ||||
| 			{`(")`, ByGroups(LiteralStringDouble), Pop(1)}, | ||||
| 			Include("interpol"), | ||||
| 		}, | ||||
| 		"string_single": { | ||||
| 			{`[^#'\\]+`, LiteralStringSingle, nil}, | ||||
| 			Include("escapes"), | ||||
| 			{`\\.`, LiteralStringSingle, nil}, | ||||
| 			{`(')`, ByGroups(LiteralStringSingle), Pop(1)}, | ||||
| 			Include("interpol"), | ||||
| 		}, | ||||
| 		"string_double_atom": { | ||||
| 			{`[^#"\\]+`, LiteralStringSymbol, nil}, | ||||
| 			Include("escapes"), | ||||
| 			{`\\.`, LiteralStringSymbol, nil}, | ||||
| 			{`(")`, ByGroups(LiteralStringSymbol), Pop(1)}, | ||||
| 			Include("interpol"), | ||||
| 		}, | ||||
| 		"string_single_atom": { | ||||
| 			{`[^#'\\]+`, LiteralStringSymbol, nil}, | ||||
| 			Include("escapes"), | ||||
| 			{`\\.`, LiteralStringSymbol, nil}, | ||||
| 			{`(')`, ByGroups(LiteralStringSymbol), Pop(1)}, | ||||
| 			Include("interpol"), | ||||
| 		}, | ||||
| 		"sigils": { | ||||
| 			{`(~[a-z])(""")`, ByGroups(LiteralStringOther, LiteralStringHeredoc), Push("triquot-end", "triquot-intp")}, | ||||
| 			{`(~[A-Z])(""")`, ByGroups(LiteralStringOther, LiteralStringHeredoc), Push("triquot-end", "triquot-no-intp")}, | ||||
| 			{`(~[a-z])(''')`, ByGroups(LiteralStringOther, LiteralStringHeredoc), Push("triapos-end", "triapos-intp")}, | ||||
| 			{`(~[A-Z])(''')`, ByGroups(LiteralStringOther, LiteralStringHeredoc), Push("triapos-end", "triapos-no-intp")}, | ||||
| 			{`~[a-z]\{`, LiteralStringOther, Push("cb-intp")}, | ||||
| 			{`~[A-Z]\{`, LiteralStringOther, Push("cb-no-intp")}, | ||||
| 			{`~[a-z]\[`, LiteralStringOther, Push("sb-intp")}, | ||||
| 			{`~[A-Z]\[`, LiteralStringOther, Push("sb-no-intp")}, | ||||
| 			{`~[a-z]\(`, LiteralStringOther, Push("pa-intp")}, | ||||
| 			{`~[A-Z]\(`, LiteralStringOther, Push("pa-no-intp")}, | ||||
| 			{`~[a-z]<`, LiteralStringOther, Push("ab-intp")}, | ||||
| 			{`~[A-Z]<`, LiteralStringOther, Push("ab-no-intp")}, | ||||
| 			{`~[a-z]/`, LiteralStringOther, Push("slas-intp")}, | ||||
| 			{`~[A-Z]/`, LiteralStringOther, Push("slas-no-intp")}, | ||||
| 			{`~[a-z]\|`, LiteralStringOther, Push("pipe-intp")}, | ||||
| 			{`~[A-Z]\|`, LiteralStringOther, Push("pipe-no-intp")}, | ||||
| 			{`~[a-z]"`, LiteralStringOther, Push("quot-intp")}, | ||||
| 			{`~[A-Z]"`, LiteralStringOther, Push("quot-no-intp")}, | ||||
| 			{`~[a-z]'`, LiteralStringOther, Push("apos-intp")}, | ||||
| 			{`~[A-Z]'`, LiteralStringOther, Push("apos-no-intp")}, | ||||
| 		}, | ||||
| 		"triquot-end": { | ||||
| 			{`[a-zA-Z]+`, LiteralStringOther, Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"triquot-intp": { | ||||
| 			{`^\s*"""`, LiteralStringHeredoc, Pop(1)}, | ||||
| 			Include("heredoc_interpol"), | ||||
| 		}, | ||||
| 		"triquot-no-intp": { | ||||
| 			{`^\s*"""`, LiteralStringHeredoc, Pop(1)}, | ||||
| 			Include("heredoc_no_interpol"), | ||||
| 		}, | ||||
| 		"triapos-end": { | ||||
| 			{`[a-zA-Z]+`, LiteralStringOther, Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"triapos-intp": { | ||||
| 			{`^\s*'''`, LiteralStringHeredoc, Pop(1)}, | ||||
| 			Include("heredoc_interpol"), | ||||
| 		}, | ||||
| 		"triapos-no-intp": { | ||||
| 			{`^\s*'''`, LiteralStringHeredoc, Pop(1)}, | ||||
| 			Include("heredoc_no_interpol"), | ||||
| 		}, | ||||
| 		"cb-intp": { | ||||
| 			{`[^#\}\\]+`, LiteralStringOther, nil}, | ||||
| 			Include("escapes"), | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`\}[a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 			Include("interpol"), | ||||
| 		}, | ||||
| 		"cb-no-intp": { | ||||
| 			{`[^\}\\]+`, LiteralStringOther, nil}, | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`\}[a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 		}, | ||||
| 		"sb-intp": { | ||||
| 			{`[^#\]\\]+`, LiteralStringOther, nil}, | ||||
| 			Include("escapes"), | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`\][a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 			Include("interpol"), | ||||
| 		}, | ||||
| 		"sb-no-intp": { | ||||
| 			{`[^\]\\]+`, LiteralStringOther, nil}, | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`\][a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 		}, | ||||
| 		"pa-intp": { | ||||
| 			{`[^#\)\\]+`, LiteralStringOther, nil}, | ||||
| 			Include("escapes"), | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`\)[a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 			Include("interpol"), | ||||
| 		}, | ||||
| 		"pa-no-intp": { | ||||
| 			{`[^\)\\]+`, LiteralStringOther, nil}, | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`\)[a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 		}, | ||||
| 		"ab-intp": { | ||||
| 			{`[^#>\\]+`, LiteralStringOther, nil}, | ||||
| 			Include("escapes"), | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`>[a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 			Include("interpol"), | ||||
| 		}, | ||||
| 		"ab-no-intp": { | ||||
| 			{`[^>\\]+`, LiteralStringOther, nil}, | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`>[a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 		}, | ||||
| 		"slas-intp": { | ||||
| 			{`[^#/\\]+`, LiteralStringOther, nil}, | ||||
| 			Include("escapes"), | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`/[a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 			Include("interpol"), | ||||
| 		}, | ||||
| 		"slas-no-intp": { | ||||
| 			{`[^/\\]+`, LiteralStringOther, nil}, | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`/[a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 		}, | ||||
| 		"pipe-intp": { | ||||
| 			{`[^#\|\\]+`, LiteralStringOther, nil}, | ||||
| 			Include("escapes"), | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`\|[a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 			Include("interpol"), | ||||
| 		}, | ||||
| 		"pipe-no-intp": { | ||||
| 			{`[^\|\\]+`, LiteralStringOther, nil}, | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`\|[a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 		}, | ||||
| 		"quot-intp": { | ||||
| 			{`[^#"\\]+`, LiteralStringOther, nil}, | ||||
| 			Include("escapes"), | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`"[a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 			Include("interpol"), | ||||
| 		}, | ||||
| 		"quot-no-intp": { | ||||
| 			{`[^"\\]+`, LiteralStringOther, nil}, | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`"[a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 		}, | ||||
| 		"apos-intp": { | ||||
| 			{`[^#'\\]+`, LiteralStringOther, nil}, | ||||
| 			Include("escapes"), | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`'[a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 			Include("interpol"), | ||||
| 		}, | ||||
| 		"apos-no-intp": { | ||||
| 			{`[^'\\]+`, LiteralStringOther, nil}, | ||||
| 			{`\\.`, LiteralStringOther, nil}, | ||||
| 			{`'[a-zA-Z]*`, LiteralStringOther, Pop(1)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										58
									
								
								lexers/elm.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								lexers/elm.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Elm lexer. | ||||
| var Elm = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Elm", | ||||
| 		Aliases:   []string{"elm"}, | ||||
| 		Filenames: []string{"*.elm"}, | ||||
| 		MimeTypes: []string{"text/x-elm"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\{-`, CommentMultiline, Push("comment")}, | ||||
| 			{`--.*`, CommentSingle, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`"`, LiteralString, Push("doublequote")}, | ||||
| 			{`^\s*module\s*`, KeywordNamespace, Push("imports")}, | ||||
| 			{`^\s*import\s*`, KeywordNamespace, Push("imports")}, | ||||
| 			{`\[glsl\|.*`, NameEntity, Push("shader")}, | ||||
| 			{Words(``, `\b`, `alias`, `as`, `case`, `else`, `if`, `import`, `in`, `let`, `module`, `of`, `port`, `then`, `type`, `where`), KeywordReserved, nil}, | ||||
| 			{`[A-Z]\w*`, KeywordType, nil}, | ||||
| 			{`^main `, KeywordReserved, nil}, | ||||
| 			{Words(`\(`, `\)`, `~`, `||`, `|>`, `|`, "`", `^`, `\`, `'`, `>>`, `>=`, `>`, `==`, `=`, `<~`, `<|`, `<=`, `<<`, `<-`, `<`, `::`, `:`, `/=`, `//`, `/`, `..`, `.`, `->`, `-`, `++`, `+`, `*`, `&&`, `%`), NameFunction, nil}, | ||||
| 			{Words(``, ``, `~`, `||`, `|>`, `|`, "`", `^`, `\`, `'`, `>>`, `>=`, `>`, `==`, `=`, `<~`, `<|`, `<=`, `<<`, `<-`, `<`, `::`, `:`, `/=`, `//`, `/`, `..`, `.`, `->`, `-`, `++`, `+`, `*`, `&&`, `%`), NameFunction, nil}, | ||||
| 			Include("numbers"), | ||||
| 			{`[a-z_][a-zA-Z_\']*`, NameVariable, nil}, | ||||
| 			{`[,()\[\]{}]`, Punctuation, nil}, | ||||
| 		}, | ||||
| 		"comment": { | ||||
| 			{`-(?!\})`, CommentMultiline, nil}, | ||||
| 			{`\{-`, CommentMultiline, Push("comment")}, | ||||
| 			{`[^-}]`, CommentMultiline, nil}, | ||||
| 			{`-\}`, CommentMultiline, Pop(1)}, | ||||
| 		}, | ||||
| 		"doublequote": { | ||||
| 			{`\\u[0-9a-fA-F]{4}`, LiteralStringEscape, nil}, | ||||
| 			{`\\[nrfvb\\"]`, LiteralStringEscape, nil}, | ||||
| 			{`[^"]`, LiteralString, nil}, | ||||
| 			{`"`, LiteralString, Pop(1)}, | ||||
| 		}, | ||||
| 		"imports": { | ||||
| 			{`\w+(\.\w+)*`, NameClass, Pop(1)}, | ||||
| 		}, | ||||
| 		"numbers": { | ||||
| 			{`_?\d+\.(?=\d+)`, LiteralNumberFloat, nil}, | ||||
| 			{`_?\d+`, LiteralNumberInteger, nil}, | ||||
| 		}, | ||||
| 		"shader": { | ||||
| 			{`\|(?!\])`, NameEntity, nil}, | ||||
| 			{`\|\]`, NameEntity, Pop(1)}, | ||||
| 			{`.*\n`, NameEntity, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										59
									
								
								lexers/emacs.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								lexers/emacs.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,59 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Emacslisp lexer. | ||||
| var Emacslisp = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "EmacsLisp", | ||||
| 		Aliases:   []string{"emacs", "elisp", "emacs-lisp"}, | ||||
| 		Filenames: []string{"*.el"}, | ||||
| 		MimeTypes: []string{"text/x-elisp", "application/x-elisp"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			Default(Push("body")), | ||||
| 		}, | ||||
| 		"body": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`;.*$`, CommentSingle, nil}, | ||||
| 			{`"`, LiteralString, Push("string")}, | ||||
| 			{`\?([^\\]|\\.)`, LiteralStringChar, nil}, | ||||
| 			{`:((?:\\.|[\w!$%&*+-/<=>?@^{}~|])(?:\\.|[\w!$%&*+-/<=>?@^{}~|]|[#.:])*)`, NameBuiltin, nil}, | ||||
| 			{`::((?:\\.|[\w!$%&*+-/<=>?@^{}~|])(?:\\.|[\w!$%&*+-/<=>?@^{}~|]|[#.:])*)`, LiteralStringSymbol, nil}, | ||||
| 			{`'((?:\\.|[\w!$%&*+-/<=>?@^{}~|])(?:\\.|[\w!$%&*+-/<=>?@^{}~|]|[#.:])*)`, LiteralStringSymbol, nil}, | ||||
| 			{`'`, Operator, nil}, | ||||
| 			{"`", Operator, nil}, | ||||
| 			{"[-+]?\\d+\\.?(?=[ \"()\\]\\'\\n,;`])", LiteralNumberInteger, nil}, | ||||
| 			{"[-+]?\\d+/\\d+(?=[ \"()\\]\\'\\n,;`])", LiteralNumber, nil}, | ||||
| 			{"[-+]?(\\d*\\.\\d+([defls][-+]?\\d+)?|\\d+(\\.\\d*)?[defls][-+]?\\d+)(?=[ \"()\\]\\'\\n,;`])", LiteralNumberFloat, nil}, | ||||
| 			{`\[|\]`, Punctuation, nil}, | ||||
| 			{`#:((?:\\.|[\w!$%&*+-/<=>?@^{}~|])(?:\\.|[\w!$%&*+-/<=>?@^{}~|]|[#.:])*)`, LiteralStringSymbol, nil}, | ||||
| 			{`#\^\^?`, Operator, nil}, | ||||
| 			{`#\'`, NameFunction, nil}, | ||||
| 			{`#[bB][+-]?[01]+(/[01]+)?`, LiteralNumberBin, nil}, | ||||
| 			{`#[oO][+-]?[0-7]+(/[0-7]+)?`, LiteralNumberOct, nil}, | ||||
| 			{`#[xX][+-]?[0-9a-fA-F]+(/[0-9a-fA-F]+)?`, LiteralNumberHex, nil}, | ||||
| 			{`#\d+r[+-]?[0-9a-zA-Z]+(/[0-9a-zA-Z]+)?`, LiteralNumber, nil}, | ||||
| 			{`#\d+=`, Operator, nil}, | ||||
| 			{`#\d+#`, Operator, nil}, | ||||
| 			{`(,@|,|\.|:)`, Operator, nil}, | ||||
| 			{"(t|nil)(?=[ \"()\\]\\'\\n,;`])", NameConstant, nil}, | ||||
| 			{`\*((?:\\.|[\w!$%&*+-/<=>?@^{}~|])(?:\\.|[\w!$%&*+-/<=>?@^{}~|]|[#.:])*)\*`, NameVariableGlobal, nil}, | ||||
| 			{`((?:\\.|[\w!$%&*+-/<=>?@^{}~|])(?:\\.|[\w!$%&*+-/<=>?@^{}~|]|[#.:])*)`, NameVariable, nil}, | ||||
| 			{`#\(`, Operator, Push("body")}, | ||||
| 			{`\(`, Punctuation, Push("body")}, | ||||
| 			{`\)`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"string": { | ||||
| 			{"[^\"\\\\`]+", LiteralString, nil}, | ||||
| 			{"`((?:\\\\.|[\\w!$%&*+-/<=>?@^{}~|])(?:\\\\.|[\\w!$%&*+-/<=>?@^{}~|]|[#.:])*)\\'", LiteralStringSymbol, nil}, | ||||
| 			{"`", LiteralString, nil}, | ||||
| 			{`\\.`, LiteralString, nil}, | ||||
| 			{`\\\n`, LiteralString, nil}, | ||||
| 			{`"`, LiteralString, Pop(1)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										65
									
								
								lexers/erlang.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								lexers/erlang.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,65 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Erlang lexer. | ||||
| var Erlang = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Erlang", | ||||
| 		Aliases:   []string{"erlang"}, | ||||
| 		Filenames: []string{"*.erl", "*.hrl", "*.es", "*.escript"}, | ||||
| 		MimeTypes: []string{"text/x-erlang"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`%.*\n`, Comment, nil}, | ||||
| 			{Words(``, `\b`, `after`, `begin`, `case`, `catch`, `cond`, `end`, `fun`, `if`, `let`, `of`, `query`, `receive`, `try`, `when`), Keyword, nil}, | ||||
| 			{Words(``, `\b`, `abs`, `append_element`, `apply`, `atom_to_list`, `binary_to_list`, `bitstring_to_list`, `binary_to_term`, `bit_size`, `bump_reductions`, `byte_size`, `cancel_timer`, `check_process_code`, `delete_module`, `demonitor`, `disconnect_node`, `display`, `element`, `erase`, `exit`, `float`, `float_to_list`, `fun_info`, `fun_to_list`, `function_exported`, `garbage_collect`, `get`, `get_keys`, `group_leader`, `hash`, `hd`, `integer_to_list`, `iolist_to_binary`, `iolist_size`, `is_atom`, `is_binary`, `is_bitstring`, `is_boolean`, `is_builtin`, `is_float`, `is_function`, `is_integer`, `is_list`, `is_number`, `is_pid`, `is_port`, `is_process_alive`, `is_record`, `is_reference`, `is_tuple`, `length`, `link`, `list_to_atom`, `list_to_binary`, `list_to_bitstring`, `list_to_existing_atom`, `list_to_float`, `list_to_integer`, `list_to_pid`, `list_to_tuple`, `load_module`, `localtime_to_universaltime`, `make_tuple`, `md5`, `md5_final`, `md5_update`, `memory`, `module_loaded`, `monitor`, `monitor_node`, `node`, `nodes`, `open_port`, `phash`, `phash2`, `pid_to_list`, `port_close`, `port_command`, `port_connect`, `port_control`, `port_call`, `port_info`, `port_to_list`, `process_display`, `process_flag`, `process_info`, `purge_module`, `put`, `read_timer`, `ref_to_list`, `register`, `resume_process`, `round`, `send`, `send_after`, `send_nosuspend`, `set_cookie`, `setelement`, `size`, `spawn`, `spawn_link`, `spawn_monitor`, `spawn_opt`, `split_binary`, `start_timer`, `statistics`, `suspend_process`, `system_flag`, `system_info`, `system_monitor`, `system_profile`, `term_to_binary`, `tl`, `trace`, `trace_delivered`, `trace_info`, `trace_pattern`, `trunc`, `tuple_size`, `tuple_to_list`, `universaltime_to_localtime`, `unlink`, `unregister`, `whereis`), NameBuiltin, nil}, | ||||
| 			{Words(``, `\b`, `and`, `andalso`, `band`, `bnot`, `bor`, `bsl`, `bsr`, `bxor`, `div`, `not`, `or`, `orelse`, `rem`, `xor`), OperatorWord, nil}, | ||||
| 			{`^-`, Punctuation, Push("directive")}, | ||||
| 			{`(\+\+?|--?|\*|/|<|>|/=|=:=|=/=|=<|>=|==?|<-|!|\?)`, Operator, nil}, | ||||
| 			{`"`, LiteralString, Push("string")}, | ||||
| 			{`<<`, NameLabel, nil}, | ||||
| 			{`>>`, NameLabel, nil}, | ||||
| 			{`((?:[a-z]\w*|'[^\n']*[^\\]'))(:)`, ByGroups(NameNamespace, Punctuation), nil}, | ||||
| 			{`(?:^|(?<=:))((?:[a-z]\w*|'[^\n']*[^\\]'))(\s*)(\()`, ByGroups(NameFunction, Text, Punctuation), nil}, | ||||
| 			{`[+-]?(?:[2-9]|[12][0-9]|3[0-6])#[0-9a-zA-Z]+`, LiteralNumberInteger, nil}, | ||||
| 			{`[+-]?\d+`, LiteralNumberInteger, nil}, | ||||
| 			{`[+-]?\d+.\d+`, LiteralNumberFloat, nil}, | ||||
| 			{`[]\[:_@\".{}()|;,]`, Punctuation, nil}, | ||||
| 			{`(?:[A-Z_]\w*)`, NameVariable, nil}, | ||||
| 			{`(?:[a-z]\w*|'[^\n']*[^\\]')`, Name, nil}, | ||||
| 			{`\?(?:(?:[A-Z_]\w*)|(?:[a-z]\w*|'[^\n']*[^\\]'))`, NameConstant, nil}, | ||||
| 			{`\$(?:(?:\\(?:[bdefnrstv\'"\\]|[0-7][0-7]?[0-7]?|(?:x[0-9a-fA-F]{2}|x\{[0-9a-fA-F]+\})|\^[a-zA-Z]))|\\[ %]|[^\\])`, LiteralStringChar, nil}, | ||||
| 			{`#(?:[a-z]\w*|'[^\n']*[^\\]')(:?\.(?:[a-z]\w*|'[^\n']*[^\\]'))?`, NameLabel, nil}, | ||||
| 			{`\A#!.+\n`, CommentHashbang, nil}, | ||||
| 			{`#\{`, Punctuation, Push("map_key")}, | ||||
| 		}, | ||||
| 		"string": { | ||||
| 			{`(?:\\(?:[bdefnrstv\'"\\]|[0-7][0-7]?[0-7]?|(?:x[0-9a-fA-F]{2}|x\{[0-9a-fA-F]+\})|\^[a-zA-Z]))`, LiteralStringEscape, nil}, | ||||
| 			{`"`, LiteralString, Pop(1)}, | ||||
| 			{`~[0-9.*]*[~#+BPWXb-ginpswx]`, LiteralStringInterpol, nil}, | ||||
| 			{`[^"\\~]+`, LiteralString, nil}, | ||||
| 			{`~`, LiteralString, nil}, | ||||
| 		}, | ||||
| 		"directive": { | ||||
| 			{`(define)(\s*)(\()((?:(?:[A-Z_]\w*)|(?:[a-z]\w*|'[^\n']*[^\\]')))`, ByGroups(NameEntity, Text, Punctuation, NameConstant), Pop(1)}, | ||||
| 			{`(record)(\s*)(\()((?:(?:[A-Z_]\w*)|(?:[a-z]\w*|'[^\n']*[^\\]')))`, ByGroups(NameEntity, Text, Punctuation, NameLabel), Pop(1)}, | ||||
| 			{`(?:[a-z]\w*|'[^\n']*[^\\]')`, NameEntity, Pop(1)}, | ||||
| 		}, | ||||
| 		"map_key": { | ||||
| 			Include("root"), | ||||
| 			{`=>`, Punctuation, Push("map_val")}, | ||||
| 			{`:=`, Punctuation, Push("map_val")}, | ||||
| 			{`\}`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"map_val": { | ||||
| 			Include("root"), | ||||
| 			{`,`, Punctuation, Pop(1)}, | ||||
| 			{`(?=\})`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										114
									
								
								lexers/factor.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								lexers/factor.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,114 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Factor lexer. | ||||
| var Factor = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Factor", | ||||
| 		Aliases:   []string{"factor"}, | ||||
| 		Filenames: []string{"*.factor"}, | ||||
| 		MimeTypes: []string{"text/x-factor"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`#!.*$`, CommentPreproc, nil}, | ||||
| 			Default(Push("base")), | ||||
| 		}, | ||||
| 		"base": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`((?:MACRO|MEMO|TYPED)?:[:]?)(\s+)(\S+)`, ByGroups(Keyword, Text, NameFunction), nil}, | ||||
| 			{`(M:[:]?)(\s+)(\S+)(\s+)(\S+)`, ByGroups(Keyword, Text, NameClass, Text, NameFunction), nil}, | ||||
| 			{`(C:)(\s+)(\S+)(\s+)(\S+)`, ByGroups(Keyword, Text, NameFunction, Text, NameClass), nil}, | ||||
| 			{`(GENERIC:)(\s+)(\S+)`, ByGroups(Keyword, Text, NameFunction), nil}, | ||||
| 			{`(HOOK:|GENERIC#)(\s+)(\S+)(\s+)(\S+)`, ByGroups(Keyword, Text, NameFunction, Text, NameFunction), nil}, | ||||
| 			{`\(\s`, NameFunction, Push("stackeffect")}, | ||||
| 			{`;\s`, Keyword, nil}, | ||||
| 			{`(USING:)(\s+)`, ByGroups(KeywordNamespace, Text), Push("vocabs")}, | ||||
| 			{`(USE:|UNUSE:|IN:|QUALIFIED:)(\s+)(\S+)`, ByGroups(KeywordNamespace, Text, NameNamespace), nil}, | ||||
| 			{`(QUALIFIED-WITH:)(\s+)(\S+)(\s+)(\S+)`, ByGroups(KeywordNamespace, Text, NameNamespace, Text, NameNamespace), nil}, | ||||
| 			{`(FROM:|EXCLUDE:)(\s+)(\S+)(\s+=>\s)`, ByGroups(KeywordNamespace, Text, NameNamespace, Text), Push("words")}, | ||||
| 			{`(RENAME:)(\s+)(\S+)(\s+)(\S+)(\s+=>\s+)(\S+)`, ByGroups(KeywordNamespace, Text, NameFunction, Text, NameNamespace, Text, NameFunction), nil}, | ||||
| 			{`(ALIAS:|TYPEDEF:)(\s+)(\S+)(\s+)(\S+)`, ByGroups(KeywordNamespace, Text, NameFunction, Text, NameFunction), nil}, | ||||
| 			{`(DEFER:|FORGET:|POSTPONE:)(\s+)(\S+)`, ByGroups(KeywordNamespace, Text, NameFunction), nil}, | ||||
| 			{`(TUPLE:|ERROR:)(\s+)(\S+)(\s+<\s+)(\S+)`, ByGroups(Keyword, Text, NameClass, Text, NameClass), Push("slots")}, | ||||
| 			{`(TUPLE:|ERROR:|BUILTIN:)(\s+)(\S+)`, ByGroups(Keyword, Text, NameClass), Push("slots")}, | ||||
| 			{`(MIXIN:|UNION:|INTERSECTION:)(\s+)(\S+)`, ByGroups(Keyword, Text, NameClass), nil}, | ||||
| 			{`(PREDICATE:)(\s+)(\S+)(\s+<\s+)(\S+)`, ByGroups(Keyword, Text, NameClass, Text, NameClass), nil}, | ||||
| 			{`(C:)(\s+)(\S+)(\s+)(\S+)`, ByGroups(Keyword, Text, NameFunction, Text, NameClass), nil}, | ||||
| 			{`(INSTANCE:)(\s+)(\S+)(\s+)(\S+)`, ByGroups(Keyword, Text, NameClass, Text, NameClass), nil}, | ||||
| 			{`(SLOT:)(\s+)(\S+)`, ByGroups(Keyword, Text, NameFunction), nil}, | ||||
| 			{`(SINGLETON:)(\s+)(\S+)`, ByGroups(Keyword, Text, NameClass), nil}, | ||||
| 			{`SINGLETONS:`, Keyword, Push("classes")}, | ||||
| 			{`(CONSTANT:|SYMBOL:|MAIN:|HELP:)(\s+)(\S+)`, ByGroups(Keyword, Text, NameFunction), nil}, | ||||
| 			{`SYMBOLS:\s`, Keyword, Push("words")}, | ||||
| 			{`SYNTAX:\s`, Keyword, nil}, | ||||
| 			{`ALIEN:\s`, Keyword, nil}, | ||||
| 			{`(STRUCT:)(\s+)(\S+)`, ByGroups(Keyword, Text, NameClass), nil}, | ||||
| 			{`(FUNCTION:)(\s+\S+\s+)(\S+)(\s+\(\s+[^)]+\)\s)`, ByGroups(KeywordNamespace, Text, NameFunction, Text), nil}, | ||||
| 			{`(FUNCTION-ALIAS:)(\s+)(\S+)(\s+\S+\s+)(\S+)(\s+\(\s+[^)]+\)\s)`, ByGroups(KeywordNamespace, Text, NameFunction, Text, NameFunction, Text), nil}, | ||||
| 			{`(?:<PRIVATE|PRIVATE>)\s`, KeywordNamespace, nil}, | ||||
| 			{`"""\s+(?:.|\n)*?\s+"""`, LiteralString, nil}, | ||||
| 			{`"(?:\\\\|\\"|[^"])*"`, LiteralString, nil}, | ||||
| 			{`\S+"\s+(?:\\\\|\\"|[^"])*"`, LiteralString, nil}, | ||||
| 			{`CHAR:\s+(?:\\[\\abfnrstv]|[^\\]\S*)\s`, LiteralStringChar, nil}, | ||||
| 			{`!\s+.*$`, Comment, nil}, | ||||
| 			{`#!\s+.*$`, Comment, nil}, | ||||
| 			{`/\*\s+(?:.|\n)*?\s\*/\s`, Comment, nil}, | ||||
| 			{`[tf]\s`, NameConstant, nil}, | ||||
| 			{`[\\$]\s+\S+`, NameConstant, nil}, | ||||
| 			{`M\\\s+\S+\s+\S+`, NameConstant, nil}, | ||||
| 			{`[+-]?(?:[\d,]*\d)?\.(?:\d([\d,]*\d)?)?(?:[eE][+-]?\d+)?\s`, LiteralNumber, nil}, | ||||
| 			{`[+-]?\d(?:[\d,]*\d)?(?:[eE][+-]?\d+)?\s`, LiteralNumber, nil}, | ||||
| 			{`0x[a-fA-F\d](?:[a-fA-F\d,]*[a-fA-F\d])?(?:p\d([\d,]*\d)?)?\s`, LiteralNumber, nil}, | ||||
| 			{`NAN:\s+[a-fA-F\d](?:[a-fA-F\d,]*[a-fA-F\d])?(?:p\d([\d,]*\d)?)?\s`, LiteralNumber, nil}, | ||||
| 			{`0b[01]+\s`, LiteralNumberBin, nil}, | ||||
| 			{`0o[0-7]+\s`, LiteralNumberOct, nil}, | ||||
| 			{`(?:\d([\d,]*\d)?)?\+\d(?:[\d,]*\d)?/\d(?:[\d,]*\d)?\s`, LiteralNumber, nil}, | ||||
| 			{`(?:\-\d([\d,]*\d)?)?\-\d(?:[\d,]*\d)?/\d(?:[\d,]*\d)?\s`, LiteralNumber, nil}, | ||||
| 			{`(?:deprecated|final|foldable|flushable|inline|recursive)\s`, Keyword, nil}, | ||||
| 			{Words(``, `\s`, `-rot`, `2bi`, `2bi@`, `2bi*`, `2curry`, `2dip`, `2drop`, `2dup`, `2keep`, `2nip`, `2over`, `2tri`, `2tri@`, `2tri*`, `3bi`, `3curry`, `3dip`, `3drop`, `3dup`, `3keep`, `3tri`, `4dip`, `4drop`, `4dup`, `4keep`, `<wrapper>`, `=`, `>boolean`, `clone`, `?`, `?execute`, `?if`, `and`, `assert`, `assert=`, `assert?`, `bi`, `bi-curry`, `bi-curry@`, `bi-curry*`, `bi@`, `bi*`, `boa`, `boolean`, `boolean?`, `both?`, `build`, `call`, `callstack`, `callstack>array`, `callstack?`, `clear`, `(clone)`, `compose`, `compose?`, `curry`, `curry?`, `datastack`, `die`, `dip`, `do`, `drop`, `dup`, `dupd`, `either?`, `eq?`, `equal?`, `execute`, `hashcode`, `hashcode*`, `identity-hashcode`, `identity-tuple`, `identity-tuple?`, `if`, `if*`, `keep`, `loop`, `most`, `new`, `nip`, `not`, `null`, `object`, `or`, `over`, `pick`, `prepose`, `retainstack`, `rot`, `same?`, `swap`, `swapd`, `throw`, `tri`, `tri-curry`, `tri-curry@`, `tri-curry*`, `tri@`, `tri*`, `tuple`, `tuple?`, `unless`, `unless*`, `until`, `when`, `when*`, `while`, `with`, `wrapper`, `wrapper?`, `xor`), NameBuiltin, nil}, | ||||
| 			{Words(``, `\s`, `2cache`, `<enum>`, `>alist`, `?at`, `?of`, `assoc`, `assoc-all?`, `assoc-any?`, `assoc-clone-like`, `assoc-combine`, `assoc-diff`, `assoc-diff!`, `assoc-differ`, `assoc-each`, `assoc-empty?`, `assoc-filter`, `assoc-filter!`, `assoc-filter-as`, `assoc-find`, `assoc-hashcode`, `assoc-intersect`, `assoc-like`, `assoc-map`, `assoc-map-as`, `assoc-partition`, `assoc-refine`, `assoc-size`, `assoc-stack`, `assoc-subset?`, `assoc-union`, `assoc-union!`, `assoc=`, `assoc>map`, `assoc?`, `at`, `at+`, `at*`, `cache`, `change-at`, `clear-assoc`, `delete-at`, `delete-at*`, `enum`, `enum?`, `extract-keys`, `inc-at`, `key?`, `keys`, `map>assoc`, `maybe-set-at`, `new-assoc`, `of`, `push-at`, `rename-at`, `set-at`, `sift-keys`, `sift-values`, `substitute`, `unzip`, `value-at`, `value-at*`, `value?`, `values`, `zip`), NameBuiltin, nil}, | ||||
| 			{Words(``, `\s`, `2cleave`, `2cleave>quot`, `3cleave`, `3cleave>quot`, `4cleave`, `4cleave>quot`, `alist>quot`, `call-effect`, `case`, `case-find`, `case>quot`, `cleave`, `cleave>quot`, `cond`, `cond>quot`, `deep-spread>quot`, `execute-effect`, `linear-case-quot`, `no-case`, `no-case?`, `no-cond`, `no-cond?`, `recursive-hashcode`, `shallow-spread>quot`, `spread`, `to-fixed-point`, `wrong-values`, `wrong-values?`), NameBuiltin, nil}, | ||||
| 			{Words(``, `\s`, `-`, `/`, `/f`, `/i`, `/mod`, `2/`, `2^`, `<`, `<=`, `<fp-nan>`, `>`, `>=`, `>bignum`, `>fixnum`, `>float`, `>integer`, `(all-integers?)`, `(each-integer)`, `(find-integer)`, `*`, `+`, `?1+`, `abs`, `align`, `all-integers?`, `bignum`, `bignum?`, `bit?`, `bitand`, `bitnot`, `bitor`, `bits>double`, `bits>float`, `bitxor`, `complex`, `complex?`, `denominator`, `double>bits`, `each-integer`, `even?`, `find-integer`, `find-last-integer`, `fixnum`, `fixnum?`, `float`, `float>bits`, `float?`, `fp-bitwise=`, `fp-infinity?`, `fp-nan-payload`, `fp-nan?`, `fp-qnan?`, `fp-sign`, `fp-snan?`, `fp-special?`, `if-zero`, `imaginary-part`, `integer`, `integer>fixnum`, `integer>fixnum-strict`, `integer?`, `log2`, `log2-expects-positive`, `log2-expects-positive?`, `mod`, `neg`, `neg?`, `next-float`, `next-power-of-2`, `number`, `number=`, `number?`, `numerator`, `odd?`, `out-of-fixnum-range`, `out-of-fixnum-range?`, `power-of-2?`, `prev-float`, `ratio`, `ratio?`, `rational`, `rational?`, `real`, `real-part`, `real?`, `recip`, `rem`, `sgn`, `shift`, `sq`, `times`, `u<`, `u<=`, `u>`, `u>=`, `unless-zero`, `unordered?`, `when-zero`, `zero?`), NameBuiltin, nil}, | ||||
| 			{Words(``, `\s`, `1sequence`, `2all?`, `2each`, `2map`, `2map-as`, `2map-reduce`, `2reduce`, `2selector`, `2sequence`, `3append`, `3append-as`, `3each`, `3map`, `3map-as`, `3sequence`, `4sequence`, `<repetition>`, `<reversed>`, `<slice>`, `?first`, `?last`, `?nth`, `?second`, `?set-nth`, `accumulate`, `accumulate!`, `accumulate-as`, `all?`, `any?`, `append`, `append!`, `append-as`, `assert-sequence`, `assert-sequence=`, `assert-sequence?`, `binary-reduce`, `bounds-check`, `bounds-check?`, `bounds-error`, `bounds-error?`, `but-last`, `but-last-slice`, `cartesian-each`, `cartesian-map`, `cartesian-product`, `change-nth`, `check-slice`, `check-slice-error`, `clone-like`, `collapse-slice`, `collector`, `collector-for`, `concat`, `concat-as`, `copy`, `count`, `cut`, `cut-slice`, `cut*`, `delete-all`, `delete-slice`, `drop-prefix`, `each`, `each-from`, `each-index`, `empty?`, `exchange`, `filter`, `filter!`, `filter-as`, `find`, `find-from`, `find-index`, `find-index-from`, `find-last`, `find-last-from`, `first`, `first2`, `first3`, `first4`, `flip`, `follow`, `fourth`, `glue`, `halves`, `harvest`, `head`, `head-slice`, `head-slice*`, `head*`, `head?`, `if-empty`, `immutable`, `immutable-sequence`, `immutable-sequence?`, `immutable?`, `index`, `index-from`, `indices`, `infimum`, `infimum-by`, `insert-nth`, `interleave`, `iota`, `iota-tuple`, `iota-tuple?`, `join`, `join-as`, `last`, `last-index`, `last-index-from`, `length`, `lengthen`, `like`, `longer`, `longer?`, `longest`, `map`, `map!`, `map-as`, `map-find`, `map-find-last`, `map-index`, `map-integers`, `map-reduce`, `map-sum`, `max-length`, `member-eq?`, `member?`, `midpoint@`, `min-length`, `mismatch`, `move`, `new-like`, `new-resizable`, `new-sequence`, `non-negative-integer-expected`, `non-negative-integer-expected?`, `nth`, `nths`, `pad-head`, `pad-tail`, `padding`, `partition`, `pop`, `pop*`, `prefix`, `prepend`, `prepend-as`, `produce`, `produce-as`, `product`, `push`, `push-all`, `push-either`, `push-if`, `reduce`, `reduce-index`, `remove`, `remove!`, `remove-eq`, `remove-eq!`, `remove-nth`, `remove-nth!`, `repetition`, `repetition?`, `replace-slice`, `replicate`, `replicate-as`, `rest`, `rest-slice`, `reverse`, `reverse!`, `reversed`, `reversed?`, `second`, `selector`, `selector-for`, `sequence`, `sequence-hashcode`, `sequence=`, `sequence?`, `set-first`, `set-fourth`, `set-last`, `set-length`, `set-nth`, `set-second`, `set-third`, `short`, `shorten`, `shorter`, `shorter?`, `shortest`, `sift`, `slice`, `slice-error`, `slice-error?`, `slice?`, `snip`, `snip-slice`, `start`, `start*`, `subseq`, `subseq?`, `suffix`, `suffix!`, `sum`, `sum-lengths`, `supremum`, `supremum-by`, `surround`, `tail`, `tail-slice`, `tail-slice*`, `tail*`, `tail?`, `third`, `trim`, `trim-head`, `trim-head-slice`, `trim-slice`, `trim-tail`, `trim-tail-slice`, `unclip`, `unclip-last`, `unclip-last-slice`, `unclip-slice`, `unless-empty`, `virtual-exemplar`, `virtual-sequence`, `virtual-sequence?`, `virtual@`, `when-empty`), NameBuiltin, nil}, | ||||
| 			{Words(``, `\s`, `+@`, `change`, `change-global`, `counter`, `dec`, `get`, `get-global`, `global`, `inc`, `init-namespaces`, `initialize`, `is-global`, `make-assoc`, `namespace`, `namestack`, `off`, `on`, `set`, `set-global`, `set-namestack`, `toggle`, `with-global`, `with-scope`, `with-variable`, `with-variables`), NameBuiltin, nil}, | ||||
| 			{Words(``, `\s`, `1array`, `2array`, `3array`, `4array`, `<array>`, `>array`, `array`, `array?`, `pair`, `pair?`, `resize-array`), NameBuiltin, nil}, | ||||
| 			{Words(``, `\s`, `(each-stream-block-slice)`, `(each-stream-block)`, `(stream-contents-by-block)`, `(stream-contents-by-element)`, `(stream-contents-by-length-or-block)`, `(stream-contents-by-length)`, `+byte+`, `+character+`, `bad-seek-type`, `bad-seek-type?`, `bl`, `contents`, `each-block`, `each-block-size`, `each-block-slice`, `each-line`, `each-morsel`, `each-stream-block`, `each-stream-block-slice`, `each-stream-line`, `error-stream`, `flush`, `input-stream`, `input-stream?`, `invalid-read-buffer`, `invalid-read-buffer?`, `lines`, `nl`, `output-stream`, `output-stream?`, `print`, `read`, `read-into`, `read-partial`, `read-partial-into`, `read-until`, `read1`, `readln`, `seek-absolute`, `seek-absolute?`, `seek-end`, `seek-end?`, `seek-input`, `seek-output`, `seek-relative`, `seek-relative?`, `stream-bl`, `stream-contents`, `stream-contents*`, `stream-copy`, `stream-copy*`, `stream-element-type`, `stream-flush`, `stream-length`, `stream-lines`, `stream-nl`, `stream-print`, `stream-read`, `stream-read-into`, `stream-read-partial`, `stream-read-partial-into`, `stream-read-partial-unsafe`, `stream-read-unsafe`, `stream-read-until`, `stream-read1`, `stream-readln`, `stream-seek`, `stream-seekable?`, `stream-tell`, `stream-write`, `stream-write1`, `tell-input`, `tell-output`, `with-error-stream`, `with-error-stream*`, `with-error>output`, `with-input-output+error-streams`, `with-input-output+error-streams*`, `with-input-stream`, `with-input-stream*`, `with-output-stream`, `with-output-stream*`, `with-output>error`, `with-output+error-stream`, `with-output+error-stream*`, `with-streams`, `with-streams*`, `write`, `write1`), NameBuiltin, nil}, | ||||
| 			{Words(``, `\s`, `1string`, `<string>`, `>string`, `resize-string`, `string`, `string?`), NameBuiltin, nil}, | ||||
| 			{Words(``, `\s`, `1vector`, `<vector>`, `>vector`, `?push`, `vector`, `vector?`), NameBuiltin, nil}, | ||||
| 			{Words(``, `\s`, `<condition>`, `<continuation>`, `<restart>`, `attempt-all`, `attempt-all-error`, `attempt-all-error?`, `callback-error-hook`, `callcc0`, `callcc1`, `cleanup`, `compute-restarts`, `condition`, `condition?`, `continuation`, `continuation?`, `continue`, `continue-restart`, `continue-with`, `current-continuation`, `error`, `error-continuation`, `error-in-thread`, `error-thread`, `ifcc`, `ignore-errors`, `in-callback?`, `original-error`, `recover`, `restart`, `restart?`, `restarts`, `rethrow`, `rethrow-restarts`, `return`, `return-continuation`, `thread-error-hook`, `throw-continue`, `throw-restarts`, `with-datastack`, `with-return`), NameBuiltin, nil}, | ||||
| 			{`\S+`, Text, nil}, | ||||
| 		}, | ||||
| 		"stackeffect": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`\(\s+`, NameFunction, Push("stackeffect")}, | ||||
| 			{`\)\s`, NameFunction, Pop(1)}, | ||||
| 			{`--\s`, NameFunction, nil}, | ||||
| 			{`\S+`, NameVariable, nil}, | ||||
| 		}, | ||||
| 		"slots": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`;\s`, Keyword, Pop(1)}, | ||||
| 			{`(\{\s+)(\S+)(\s+[^}]+\s+\}\s)`, ByGroups(Text, NameVariable, Text), nil}, | ||||
| 			{`\S+`, NameVariable, nil}, | ||||
| 		}, | ||||
| 		"vocabs": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`;\s`, Keyword, Pop(1)}, | ||||
| 			{`\S+`, NameNamespace, nil}, | ||||
| 		}, | ||||
| 		"classes": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`;\s`, Keyword, Pop(1)}, | ||||
| 			{`\S+`, NameClass, nil}, | ||||
| 		}, | ||||
| 		"words": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`;\s`, Keyword, Pop(1)}, | ||||
| 			{`\S+`, NameFunction, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										64
									
								
								lexers/fish.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								lexers/fish.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,64 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Fish lexer. | ||||
| var Fish = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Fish", | ||||
| 		Aliases:   []string{"fish", "fishshell"}, | ||||
| 		Filenames: []string{"*.fish", "*.load"}, | ||||
| 		MimeTypes: []string{"application/x-fish"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			Include("basic"), | ||||
| 			Include("data"), | ||||
| 			Include("interp"), | ||||
| 		}, | ||||
| 		"interp": { | ||||
| 			{`\$\(\(`, Keyword, Push("math")}, | ||||
| 			{`\(`, Keyword, Push("paren")}, | ||||
| 			{`\$#?(\w+|.)`, NameVariable, nil}, | ||||
| 		}, | ||||
| 		"basic": { | ||||
| 			{`\b(begin|end|if|else|while|break|for|in|return|function|block|case|continue|switch|not|and|or|set|echo|exit|pwd|true|false|cd|count|test)(\s*)\b`, ByGroups(Keyword, Text), nil}, | ||||
| 			{`\b(alias|bg|bind|breakpoint|builtin|command|commandline|complete|contains|dirh|dirs|emit|eval|exec|fg|fish|fish_config|fish_indent|fish_pager|fish_prompt|fish_right_prompt|fish_update_completions|fishd|funced|funcsave|functions|help|history|isatty|jobs|math|mimedb|nextd|open|popd|prevd|psub|pushd|random|read|set_color|source|status|trap|type|ulimit|umask|vared|fc|getopts|hash|kill|printf|time|wait)\s*\b(?!\.)`, NameBuiltin, nil}, | ||||
| 			{`#.*\n`, Comment, nil}, | ||||
| 			{`\\[\w\W]`, LiteralStringEscape, nil}, | ||||
| 			{`(\b\w+)(\s*)(=)`, ByGroups(NameVariable, Text, Operator), nil}, | ||||
| 			{`[\[\]()=]`, Operator, nil}, | ||||
| 			{`<<-?\s*(\'?)\\?(\w+)[\w\W]+?\2`, LiteralString, nil}, | ||||
| 		}, | ||||
| 		"data": { | ||||
| 			{`(?s)\$?"(\\\\|\\[0-7]+|\\.|[^"\\$])*"`, LiteralStringDouble, nil}, | ||||
| 			{`"`, LiteralStringDouble, Push("string")}, | ||||
| 			{`(?s)\$'(\\\\|\\[0-7]+|\\.|[^'\\])*'`, LiteralStringSingle, nil}, | ||||
| 			{`(?s)'.*?'`, LiteralStringSingle, nil}, | ||||
| 			{`;`, Punctuation, nil}, | ||||
| 			{`&|\||\^|<|>`, Operator, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`\d+(?= |\Z)`, LiteralNumber, nil}, | ||||
| 			{"[^=\\s\\[\\]{}()$\"\\'`\\\\<&|;]+", Text, nil}, | ||||
| 		}, | ||||
| 		"string": { | ||||
| 			{`"`, LiteralStringDouble, Pop(1)}, | ||||
| 			{`(?s)(\\\\|\\[0-7]+|\\.|[^"\\$])+`, LiteralStringDouble, nil}, | ||||
| 			Include("interp"), | ||||
| 		}, | ||||
| 		"paren": { | ||||
| 			{`\)`, Keyword, Pop(1)}, | ||||
| 			Include("root"), | ||||
| 		}, | ||||
| 		"math": { | ||||
| 			{`\)\)`, Keyword, Pop(1)}, | ||||
| 			{`[-+*/%^|&]|\*\*|\|\|`, Operator, nil}, | ||||
| 			{`\d+#\d+`, LiteralNumber, nil}, | ||||
| 			{`\d+#(?! )`, LiteralNumber, nil}, | ||||
| 			{`\d+`, LiteralNumber, nil}, | ||||
| 			Include("root"), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										39
									
								
								lexers/forth.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								lexers/forth.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Forth lexer. | ||||
| var Forth = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:            "Forth", | ||||
| 		Aliases:         []string{"forth"}, | ||||
| 		Filenames:       []string{"*.frt", "*.fs"}, | ||||
| 		MimeTypes:       []string{"application/x-forth"}, | ||||
| 		CaseInsensitive: true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`\\.*?\n`, CommentSingle, nil}, | ||||
| 			{`\([\s].*?\)`, CommentSingle, nil}, | ||||
| 			{`(:|variable|constant|value|buffer:)(\s+)`, ByGroups(KeywordNamespace, Text), Push("worddef")}, | ||||
| 			{`([.sc]")(\s+?)`, ByGroups(LiteralString, Text), Push("stringdef")}, | ||||
| 			{`(blk|block|buffer|evaluate|flush|load|save-buffers|update|empty-buffers|list|refill|scr|thru|\#s|\*\/mod|\+loop|\/mod|0<|0=|1\+|1-|2!|2\*|2\/|2@|2drop|2dup|2over|2swap|>body|>in|>number|>r|\?dup|abort|abort\"|abs|accept|align|aligned|allot|and|base|begin|bl|c!|c,|c@|cell\+|cells|char|char\+|chars|constant|count|cr|create|decimal|depth|do|does>|drop|dup|else|emit|environment\?|evaluate|execute|exit|fill|find|fm\/mod|here|hold|i|if|immediate|invert|j|key|leave|literal|loop|lshift|m\*|max|min|mod|move|negate|or|over|postpone|quit|r>|r@|recurse|repeat|rot|rshift|s\"|s>d|sign|sm\/rem|source|space|spaces|state|swap|then|type|u\.|u\<|um\*|um\/mod|unloop|until|variable|while|word|xor|\[char\]|\[\'\]|@|!|\#|<\#|\#>|:|;|\+|-|\*|\/|,|<|>|\|1\+|1-|\.|\.r|0<>|0>|2>r|2r>|2r@|:noname|\?do|again|c\"|case|compile,|endcase|endof|erase|false|hex|marker|nip|of|pad|parse|pick|refill|restore-input|roll|save-input|source-id|to|true|tuck|u\.r|u>|unused|value|within|\[compile\]|\#tib|convert|expect|query|span|tib|2constant|2literal|2variable|d\+|d-|d\.|d\.r|d0<|d0=|d2\*|d2\/|d<|d=|d>s|dabs|dmax|dmin|dnegate|m\*\/|m\+|2rot|du<|catch|throw|abort|abort\"|at-xy|key\?|page|ekey|ekey>char|ekey\?|emit\?|ms|time&date|BIN|CLOSE-FILE|CREATE-FILE|DELETE-FILE|FILE-POSITION|FILE-SIZE|INCLUDE-FILE|INCLUDED|OPEN-FILE|R\/O|R\/W|READ-FILE|READ-LINE|REPOSITION-FILE|RESIZE-FILE|S\"|SOURCE-ID|W/O|WRITE-FILE|WRITE-LINE|FILE-STATUS|FLUSH-FILE|REFILL|RENAME-FILE|>float|d>f|f!|f\*|f\+|f-|f\/|f0<|f0=|f<|f>d|f@|falign|faligned|fconstant|fdepth|fdrop|fdup|fliteral|float\+|floats|floor|fmax|fmin|fnegate|fover|frot|fround|fswap|fvariable|represent|df!|df@|dfalign|dfaligned|dfloat\+|dfloats|f\*\*|f\.|fabs|facos|facosh|falog|fasin|fasinh|fatan|fatan2|fatanh|fcos|fcosh|fe\.|fexp|fexpm1|fln|flnp1|flog|fs\.|fsin|fsincos|fsinh|fsqrt|ftan|ftanh|f~|precision|set-precision|sf!|sf@|sfalign|sfaligned|sfloat\+|sfloats|\(local\)|to|locals\||allocate|free|resize|definitions|find|forth-wordlist|get-current|get-order|search-wordlist|set-current|set-order|wordlist|also|forth|only|order|previous|-trailing|\/string|blank|cmove|cmove>|compare|search|sliteral|.s|dump|see|words|;code|ahead|assembler|bye|code|cs-pick|cs-roll|editor|state|\[else\]|\[if\]|\[then\]|forget|defer|defer@|defer!|action-of|begin-structure|field:|buffer:|parse-name|buffer:|traverse-wordlist|n>r|nr>|2value|fvalue|name>interpret|name>compile|name>string|cfield:|end-structure)\s`, Keyword, nil}, | ||||
| 			{`(\$[0-9A-F]+)`, LiteralNumberHex, nil}, | ||||
| 			{`(\#|%|&|\-|\+)?[0-9]+`, LiteralNumberInteger, nil}, | ||||
| 			{`(\#|%|&|\-|\+)?[0-9.]+`, KeywordType, nil}, | ||||
| 			{`(@i|!i|@e|!e|pause|noop|turnkey|sleep|itype|icompare|sp@|sp!|rp@|rp!|up@|up!|>a|a>|a@|a!|a@+|a@-|>b|b>|b@|b!|b@+|b@-|find-name|1ms|sp0|rp0|\(evaluate\)|int-trap|int!)\s`, NameConstant, nil}, | ||||
| 			{`(do-recognizer|r:fail|recognizer:|get-recognizers|set-recognizers|r:float|r>comp|r>int|r>post|r:name|r:word|r:dnum|r:num|recognizer|forth-recognizer|rec:num|rec:float|rec:word)\s`, NameDecorator, nil}, | ||||
| 			{`(Evalue|Rvalue|Uvalue|Edefer|Rdefer|Udefer)(\s+)`, ByGroups(KeywordNamespace, Text), Push("worddef")}, | ||||
| 			{`[^\s]+(?=[\s])`, NameFunction, nil}, | ||||
| 		}, | ||||
| 		"worddef": { | ||||
| 			{`\S+`, NameClass, Pop(1)}, | ||||
| 		}, | ||||
| 		"stringdef": { | ||||
| 			{`[^"]+`, LiteralString, Pop(1)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										46
									
								
								lexers/fortran.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								lexers/fortran.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Fortran lexer. | ||||
| var Fortran = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:            "Fortran", | ||||
| 		Aliases:         []string{"fortran"}, | ||||
| 		Filenames:       []string{"*.f03", "*.f90", "*.F03", "*.F90"}, | ||||
| 		MimeTypes:       []string{"text/x-fortran"}, | ||||
| 		CaseInsensitive: true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`^#.*\n`, CommentPreproc, nil}, | ||||
| 			{`!.*\n`, Comment, nil}, | ||||
| 			Include("strings"), | ||||
| 			Include("core"), | ||||
| 			{`[a-z][\w$]*`, Name, nil}, | ||||
| 			Include("nums"), | ||||
| 			{`[\s]+`, Text, nil}, | ||||
| 		}, | ||||
| 		"core": { | ||||
| 			{Words(`\b`, `\s*\b`, `ABSTRACT`, `ACCEPT`, `ALL`, `ALLSTOP`, `ALLOCATABLE`, `ALLOCATE`, `ARRAY`, `ASSIGN`, `ASSOCIATE`, `ASYNCHRONOUS`, `BACKSPACE`, `BIND`, `BLOCK`, `BLOCKDATA`, `BYTE`, `CALL`, `CASE`, `CLASS`, `CLOSE`, `CODIMENSION`, `COMMON`, `CONCURRRENT`, `CONTIGUOUS`, `CONTAINS`, `CONTINUE`, `CRITICAL`, `CYCLE`, `DATA`, `DEALLOCATE`, `DECODE`, `DEFERRED`, `DIMENSION`, `DO`, `ELEMENTAL`, `ELSE`, `ENCODE`, `END`, `ENTRY`, `ENUM`, `ENUMERATOR`, `EQUIVALENCE`, `EXIT`, `EXTENDS`, `EXTERNAL`, `EXTRINSIC`, `FILE`, `FINAL`, `FORALL`, `FORMAT`, `FUNCTION`, `GENERIC`, `GOTO`, `IF`, `IMAGES`, `IMPLICIT`, `IMPORT`, `IMPURE`, `INCLUDE`, `INQUIRE`, `INTENT`, `INTERFACE`, `INTRINSIC`, `IS`, `LOCK`, `MEMORY`, `MODULE`, `NAMELIST`, `NULLIFY`, `NONE`, `NON_INTRINSIC`, `NON_OVERRIDABLE`, `NOPASS`, `OPEN`, `OPTIONAL`, `OPTIONS`, `PARAMETER`, `PASS`, `PAUSE`, `POINTER`, `PRINT`, `PRIVATE`, `PROGRAM`, `PROCEDURE`, `PROTECTED`, `PUBLIC`, `PURE`, `READ`, `RECURSIVE`, `RESULT`, `RETURN`, `REWIND`, `SAVE`, `SELECT`, `SEQUENCE`, `STOP`, `SUBMODULE`, `SUBROUTINE`, `SYNC`, `SYNCALL`, `SYNCIMAGES`, `SYNCMEMORY`, `TARGET`, `THEN`, `TYPE`, `UNLOCK`, `USE`, `VALUE`, `VOLATILE`, `WHERE`, `WRITE`, `WHILE`), Keyword, nil}, | ||||
| 			{Words(`\b`, `\s*\b`, `CHARACTER`, `COMPLEX`, `DOUBLE PRECISION`, `DOUBLE COMPLEX`, `INTEGER`, `LOGICAL`, `REAL`, `C_INT`, `C_SHORT`, `C_LONG`, `C_LONG_LONG`, `C_SIGNED_CHAR`, `C_SIZE_T`, `C_INT8_T`, `C_INT16_T`, `C_INT32_T`, `C_INT64_T`, `C_INT_LEAST8_T`, `C_INT_LEAST16_T`, `C_INT_LEAST32_T`, `C_INT_LEAST64_T`, `C_INT_FAST8_T`, `C_INT_FAST16_T`, `C_INT_FAST32_T`, `C_INT_FAST64_T`, `C_INTMAX_T`, `C_INTPTR_T`, `C_FLOAT`, `C_DOUBLE`, `C_LONG_DOUBLE`, `C_FLOAT_COMPLEX`, `C_DOUBLE_COMPLEX`, `C_LONG_DOUBLE_COMPLEX`, `C_BOOL`, `C_CHAR`, `C_PTR`, `C_FUNPTR`), KeywordType, nil}, | ||||
| 			{`(\*\*|\*|\+|-|\/|<|>|<=|>=|==|\/=|=)`, Operator, nil}, | ||||
| 			{`(::)`, KeywordDeclaration, nil}, | ||||
| 			{`[()\[\],:&%;.]`, Punctuation, nil}, | ||||
| 			{Words(`\b`, `\s*\b`, `Abort`, `Abs`, `Access`, `AChar`, `ACos`, `ACosH`, `AdjustL`, `AdjustR`, `AImag`, `AInt`, `Alarm`, `All`, `Allocated`, `ALog`, `AMax`, `AMin`, `AMod`, `And`, `ANInt`, `Any`, `ASin`, `ASinH`, `Associated`, `ATan`, `ATanH`, `Atomic_Define`, `Atomic_Ref`, `BesJ`, `BesJN`, `Bessel_J0`, `Bessel_J1`, `Bessel_JN`, `Bessel_Y0`, `Bessel_Y1`, `Bessel_YN`, `BesY`, `BesYN`, `BGE`, `BGT`, `BLE`, `BLT`, `Bit_Size`, `BTest`, `CAbs`, `CCos`, `Ceiling`, `CExp`, `Char`, `ChDir`, `ChMod`, `CLog`, `Cmplx`, `Command_Argument_Count`, `Complex`, `Conjg`, `Cos`, `CosH`, `Count`, `CPU_Time`, `CShift`, `CSin`, `CSqRt`, `CTime`, `C_Loc`, `C_Associated`, `C_Null_Ptr`, `C_Null_Funptr`, `C_F_Pointer`, `C_F_ProcPointer`, `C_Null_Char`, `C_Alert`, `C_Backspace`, `C_Form_Feed`, `C_FunLoc`, `C_Sizeof`, `C_New_Line`, `C_Carriage_Return`, `C_Horizontal_Tab`, `C_Vertical_Tab`, `DAbs`, `DACos`, `DASin`, `DATan`, `Date_and_Time`, `DbesJ`, `DbesJN`, `DbesY`, `DbesYN`, `Dble`, `DCos`, `DCosH`, `DDiM`, `DErF`, `DErFC`, `DExp`, `Digits`, `DiM`, `DInt`, `DLog`, `DMax`, `DMin`, `DMod`, `DNInt`, `Dot_Product`, `DProd`, `DSign`, `DSinH`, `DShiftL`, `DShiftR`, `DSin`, `DSqRt`, `DTanH`, `DTan`, `DTime`, `EOShift`, `Epsilon`, `ErF`, `ErFC`, `ErFC_Scaled`, `ETime`, `Execute_Command_Line`, `Exit`, `Exp`, `Exponent`, `Extends_Type_Of`, `FDate`, `FGet`, `FGetC`, `FindLoc`, `Float`, `Floor`, `Flush`, `FNum`, `FPutC`, `FPut`, `Fraction`, `FSeek`, `FStat`, `FTell`, `Gamma`, `GError`, `GetArg`, `Get_Command`, `Get_Command_Argument`, `Get_Environment_Variable`, `GetCWD`, `GetEnv`, `GetGId`, `GetLog`, `GetPId`, `GetUId`, `GMTime`, `HostNm`, `Huge`, `Hypot`, `IAbs`, `IAChar`, `IAll`, `IAnd`, `IAny`, `IArgC`, `IBClr`, `IBits`, `IBSet`, `IChar`, `IDate`, `IDiM`, `IDInt`, `IDNInt`, `IEOr`, `IErrNo`, `IFix`, `Imag`, `ImagPart`, `Image_Index`, `Index`, `Int`, `IOr`, `IParity`, `IRand`, `IsaTty`, `IShft`, `IShftC`, `ISign`, `Iso_C_Binding`, `Is_Contiguous`, `Is_Iostat_End`, `Is_Iostat_Eor`, `ITime`, `Kill`, `Kind`, `LBound`, `LCoBound`, `Len`, `Len_Trim`, `LGe`, `LGt`, `Link`, `LLe`, `LLt`, `LnBlnk`, `Loc`, `Log`, `Log_Gamma`, `Logical`, `Long`, `LShift`, `LStat`, `LTime`, `MaskL`, `MaskR`, `MatMul`, `Max`, `MaxExponent`, `MaxLoc`, `MaxVal`, `MClock`, `Merge`, `Merge_Bits`, `Move_Alloc`, `Min`, `MinExponent`, `MinLoc`, `MinVal`, `Mod`, `Modulo`, `MvBits`, `Nearest`, `New_Line`, `NInt`, `Norm2`, `Not`, `Null`, `Num_Images`, `Or`, `Pack`, `Parity`, `PError`, `Precision`, `Present`, `Product`, `Radix`, `Rand`, `Random_Number`, `Random_Seed`, `Range`, `Real`, `RealPart`, `Rename`, `Repeat`, `Reshape`, `RRSpacing`, `RShift`, `Same_Type_As`, `Scale`, `Scan`, `Second`, `Selected_Char_Kind`, `Selected_Int_Kind`, `Selected_Real_Kind`, `Set_Exponent`, `Shape`, `ShiftA`, `ShiftL`, `ShiftR`, `Short`, `Sign`, `Signal`, `SinH`, `Sin`, `Sleep`, `Sngl`, `Spacing`, `Spread`, `SqRt`, `SRand`, `Stat`, `Storage_Size`, `Sum`, `SymLnk`, `System`, `System_Clock`, `Tan`, `TanH`, `Time`, `This_Image`, `Tiny`, `TrailZ`, `Transfer`, `Transpose`, `Trim`, `TtyNam`, `UBound`, `UCoBound`, `UMask`, `Unlink`, `Unpack`, `Verify`, `XOr`, `ZAbs`, `ZCos`, `ZExp`, `ZLog`, `ZSin`, `ZSqRt`), NameBuiltin, nil}, | ||||
| 			{`\.(true|false)\.`, NameBuiltin, nil}, | ||||
| 			{`\.(eq|ne|lt|le|gt|ge|not|and|or|eqv|neqv)\.`, OperatorWord, nil}, | ||||
| 		}, | ||||
| 		"strings": { | ||||
| 			{`(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"`, LiteralStringDouble, nil}, | ||||
| 			{`(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'`, LiteralStringSingle, nil}, | ||||
| 		}, | ||||
| 		"nums": { | ||||
| 			{`\d+(?![.e])(_[a-z]\w+)?`, LiteralNumberInteger, nil}, | ||||
| 			{`[+-]?\d*\.\d+([ed][-+]?\d+)?(_[a-z]\w+)?`, LiteralNumberFloat, nil}, | ||||
| 			{`[+-]?\d+\.\d*([ed][-+]?\d+)?(_[a-z]\w+)?`, LiteralNumberFloat, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										93
									
								
								lexers/fsharp.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								lexers/fsharp.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,93 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Fsharp lexer. | ||||
| var Fsharp = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "FSharp", | ||||
| 		Aliases:   []string{"fsharp"}, | ||||
| 		Filenames: []string{"*.fs", "*.fsi"}, | ||||
| 		MimeTypes: []string{"text/x-fsharp"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"escape-sequence": { | ||||
| 			{`\\[\\"\'ntbrafv]`, LiteralStringEscape, nil}, | ||||
| 			{`\\[0-9]{3}`, LiteralStringEscape, nil}, | ||||
| 			{`\\u[0-9a-fA-F]{4}`, LiteralStringEscape, nil}, | ||||
| 			{`\\U[0-9a-fA-F]{8}`, LiteralStringEscape, nil}, | ||||
| 		}, | ||||
| 		"root": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`\(\)|\[\]`, NameBuiltinPseudo, nil}, | ||||
| 			{`\b(?<!\.)([A-Z][\w\']*)(?=\s*\.)`, NameNamespace, Push("dotted")}, | ||||
| 			{`\b([A-Z][\w\']*)`, Name, nil}, | ||||
| 			{`///.*?\n`, LiteralStringDoc, nil}, | ||||
| 			{`//.*?\n`, CommentSingle, nil}, | ||||
| 			{`\(\*(?!\))`, Comment, Push("comment")}, | ||||
| 			{`@"`, LiteralString, Push("lstring")}, | ||||
| 			{`"""`, LiteralString, Push("tqs")}, | ||||
| 			{`"`, LiteralString, Push("string")}, | ||||
| 			{`\b(open|module)(\s+)([\w.]+)`, ByGroups(Keyword, Text, NameNamespace), nil}, | ||||
| 			{`\b(let!?)(\s+)(\w+)`, ByGroups(Keyword, Text, NameVariable), nil}, | ||||
| 			{`\b(type)(\s+)(\w+)`, ByGroups(Keyword, Text, NameClass), nil}, | ||||
| 			{`\b(member|override)(\s+)(\w+)(\.)(\w+)`, ByGroups(Keyword, Text, Name, Punctuation, NameFunction), nil}, | ||||
| 			{`\b(abstract|as|assert|base|begin|class|default|delegate|do!|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|function|fun|global|if|inherit|inline|interface|internal|in|lazy|let!|let|match|member|module|mutable|namespace|new|null|of|open|override|private|public|rec|return!|return|select|static|struct|then|to|true|try|type|upcast|use!|use|val|void|when|while|with|yield!|yield|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|include|method|mixin|object|parallel|process|protected|pure|sealed|tailcall|trait|virtual|volatile)\b`, Keyword, nil}, | ||||
| 			{"``([^`\\n\\r\\t]|`[^`\\n\\r\\t])+``", Name, nil}, | ||||
| 			{"(!=|#|&&|&|\\(|\\)|\\*|\\+|,|-\\.|->|-|\\.\\.|\\.|::|:=|:>|:|;;|;|<-|<\\]|<|>\\]|>|\\?\\?|\\?|\\[<|\\[\\||\\[|\\]|_|`|\\{|\\|\\]|\\||\\}|~|<@@|<@|=|@>|@@>)", Operator, nil}, | ||||
| 			{`([=<>@^|&+\*/$%-]|[!?~])?[!$%&*+\./:<=>?@^|~-]`, Operator, nil}, | ||||
| 			{`\b(and|or|not)\b`, OperatorWord, nil}, | ||||
| 			{`\b(sbyte|byte|char|nativeint|unativeint|float32|single|float|double|int8|uint8|int16|uint16|int32|uint32|int64|uint64|decimal|unit|bool|string|list|exn|obj|enum)\b`, KeywordType, nil}, | ||||
| 			{`#[ \t]*(if|endif|else|line|nowarn|light|\d+)\b.*?\n`, CommentPreproc, nil}, | ||||
| 			{`[^\W\d][\w']*`, Name, nil}, | ||||
| 			{`\d[\d_]*[uU]?[yslLnQRZINGmM]?`, LiteralNumberInteger, nil}, | ||||
| 			{`0[xX][\da-fA-F][\da-fA-F_]*[uU]?[yslLn]?[fF]?`, LiteralNumberHex, nil}, | ||||
| 			{`0[oO][0-7][0-7_]*[uU]?[yslLn]?`, LiteralNumberOct, nil}, | ||||
| 			{`0[bB][01][01_]*[uU]?[yslLn]?`, LiteralNumberBin, nil}, | ||||
| 			{`-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)[fFmM]?`, LiteralNumberFloat, nil}, | ||||
| 			{`'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'B?`, LiteralStringChar, nil}, | ||||
| 			{`'.'`, LiteralStringChar, nil}, | ||||
| 			{`'`, Keyword, nil}, | ||||
| 			{`@?"`, LiteralStringDouble, Push("string")}, | ||||
| 			{`[~?][a-z][\w\']*:`, NameVariable, nil}, | ||||
| 		}, | ||||
| 		"dotted": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`\.`, Punctuation, nil}, | ||||
| 			{`[A-Z][\w\']*(?=\s*\.)`, NameNamespace, nil}, | ||||
| 			{`[A-Z][\w\']*`, Name, Pop(1)}, | ||||
| 			{`[a-z_][\w\']*`, Name, Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"comment": { | ||||
| 			{`[^(*)@"]+`, Comment, nil}, | ||||
| 			{`\(\*`, Comment, Push()}, | ||||
| 			{`\*\)`, Comment, Pop(1)}, | ||||
| 			{`@"`, LiteralString, Push("lstring")}, | ||||
| 			{`"""`, LiteralString, Push("tqs")}, | ||||
| 			{`"`, LiteralString, Push("string")}, | ||||
| 			{`[(*)@]`, Comment, nil}, | ||||
| 		}, | ||||
| 		"string": { | ||||
| 			{`[^\\"]+`, LiteralString, nil}, | ||||
| 			Include("escape-sequence"), | ||||
| 			{`\\\n`, LiteralString, nil}, | ||||
| 			{`\n`, LiteralString, nil}, | ||||
| 			{`"B?`, LiteralString, Pop(1)}, | ||||
| 		}, | ||||
| 		"lstring": { | ||||
| 			{`[^"]+`, LiteralString, nil}, | ||||
| 			{`\n`, LiteralString, nil}, | ||||
| 			{`""`, LiteralString, nil}, | ||||
| 			{`"B?`, LiteralString, Pop(1)}, | ||||
| 		}, | ||||
| 		"tqs": { | ||||
| 			{`[^"]+`, LiteralString, nil}, | ||||
| 			{`\n`, LiteralString, nil}, | ||||
| 			{`"""B?`, LiteralString, Pop(1)}, | ||||
| 			{`"`, LiteralString, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										54
									
								
								lexers/gas.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								lexers/gas.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,54 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Gas lexer. | ||||
| var Gas = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "GAS", | ||||
| 		Aliases:   []string{"gas", "asm"}, | ||||
| 		Filenames: []string{"*.s", "*.S"}, | ||||
| 		MimeTypes: []string{"text/x-gas"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			Include("whitespace"), | ||||
| 			{`(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+):`, NameLabel, nil}, | ||||
| 			{`\.(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameAttribute, Push("directive-args")}, | ||||
| 			{`lock|rep(n?z)?|data\d+`, NameAttribute, nil}, | ||||
| 			{`(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameFunction, Push("instruction-args")}, | ||||
| 			{`[\r\n]+`, Text, nil}, | ||||
| 		}, | ||||
| 		"directive-args": { | ||||
| 			{`(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameConstant, nil}, | ||||
| 			{`"(\\"|[^"])*"`, LiteralString, nil}, | ||||
| 			{`@(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameAttribute, nil}, | ||||
| 			{`(?:0[xX][a-zA-Z0-9]+|\d+)`, LiteralNumberInteger, nil}, | ||||
| 			{`[\r\n]+`, Text, Pop(1)}, | ||||
| 			Include("punctuation"), | ||||
| 			Include("whitespace"), | ||||
| 		}, | ||||
| 		"instruction-args": { | ||||
| 			{`([a-z0-9]+)( )(<)((?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+))(>)`, ByGroups(LiteralNumberHex, Text, Punctuation, NameConstant, Punctuation), nil}, | ||||
| 			{`([a-z0-9]+)( )(<)((?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+))([-+])((?:0[xX][a-zA-Z0-9]+|\d+))(>)`, ByGroups(LiteralNumberHex, Text, Punctuation, NameConstant, Punctuation, LiteralNumberInteger, Punctuation), nil}, | ||||
| 			{`(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameConstant, nil}, | ||||
| 			{`(?:0[xX][a-zA-Z0-9]+|\d+)`, LiteralNumberInteger, nil}, | ||||
| 			{`%(?:[a-zA-Z$_][\w$.@-]*|\.[\w$.@-]+)`, NameVariable, nil}, | ||||
| 			{`$(?:0[xX][a-zA-Z0-9]+|\d+)`, LiteralNumberInteger, nil}, | ||||
| 			{`$'(.|\\')'`, LiteralStringChar, nil}, | ||||
| 			{`[\r\n]+`, Text, Pop(1)}, | ||||
| 			Include("punctuation"), | ||||
| 			Include("whitespace"), | ||||
| 		}, | ||||
| 		"whitespace": { | ||||
| 			{`\n`, Text, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`[;#].*?\n`, Comment, nil}, | ||||
| 		}, | ||||
| 		"punctuation": { | ||||
| 			{`[-*,.()\[\]!:]+`, Punctuation, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										35
									
								
								lexers/genshi.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								lexers/genshi.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Genshi Text lexer. | ||||
| var GenshiTemplate = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Genshi Text", | ||||
| 		Aliases:   []string{"genshitext"}, | ||||
| 		Filenames: []string{}, | ||||
| 		MimeTypes: []string{"application/x-genshi-text", "text/x-genshi"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`[^#$\s]+`, Other, nil}, | ||||
| 			{`^(\s*)(##.*)$`, ByGroups(Text, Comment), nil}, | ||||
| 			{`^(\s*)(#)`, ByGroups(Text, CommentPreproc), Push("directive")}, | ||||
| 			Include("variable"), | ||||
| 			{`[#$\s]`, Other, nil}, | ||||
| 		}, | ||||
| 		"directive": { | ||||
| 			{`\n`, Text, Pop(1)}, | ||||
| 			{`(?:def|for|if)\s+.*`, Using(Python, nil), Pop(1)}, | ||||
| 			{`(choose|when|with)([^\S\n]+)(.*)`, ByGroups(Keyword, Text, Using(Python, nil)), Pop(1)}, | ||||
| 			{`(choose|otherwise)\b`, Keyword, Pop(1)}, | ||||
| 			{`(end\w*)([^\S\n]*)(.*)`, ByGroups(Keyword, Text, Comment), Pop(1)}, | ||||
| 		}, | ||||
| 		"variable": { | ||||
| 			{`(?<!\$)(\$\{)(.+?)(\})`, ByGroups(CommentPreproc, Using(Python, nil), CommentPreproc), nil}, | ||||
| 			{`(?<!\$)(\$)([a-zA-Z_][\w.]*)`, NameVariable, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										36
									
								
								lexers/glsl.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								lexers/glsl.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,36 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Glsl lexer. | ||||
| var Glsl = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "GLSL", | ||||
| 		Aliases:   []string{"glsl"}, | ||||
| 		Filenames: []string{"*.vert", "*.frag", "*.geo"}, | ||||
| 		MimeTypes: []string{"text/x-glslsrc"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`^#.*`, CommentPreproc, nil}, | ||||
| 			{`//.*`, CommentSingle, nil}, | ||||
| 			{`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil}, | ||||
| 			{`\+|-|~|!=?|\*|/|%|<<|>>|<=?|>=?|==?|&&?|\^|\|\|?`, Operator, nil}, | ||||
| 			{`[?:]`, Operator, nil}, | ||||
| 			{`\bdefined\b`, Operator, nil}, | ||||
| 			{`[;{}(),\[\]]`, Punctuation, nil}, | ||||
| 			{`[+-]?\d*\.\d+([eE][-+]?\d+)?`, LiteralNumberFloat, nil}, | ||||
| 			{`[+-]?\d+\.\d*([eE][-+]?\d+)?`, LiteralNumberFloat, nil}, | ||||
| 			{`0[xX][0-9a-fA-F]*`, LiteralNumberHex, nil}, | ||||
| 			{`0[0-7]*`, LiteralNumberOct, nil}, | ||||
| 			{`[1-9][0-9]*`, LiteralNumberInteger, nil}, | ||||
| 			{Words(`\b`, `\b`, `attribute`, `const`, `uniform`, `varying`, `centroid`, `break`, `continue`, `do`, `for`, `while`, `if`, `else`, `in`, `out`, `inout`, `float`, `int`, `void`, `bool`, `true`, `false`, `invariant`, `discard`, `return`, `mat2`, `mat3mat4`, `mat2x2`, `mat3x2`, `mat4x2`, `mat2x3`, `mat3x3`, `mat4x3`, `mat2x4`, `mat3x4`, `mat4x4`, `vec2`, `vec3`, `vec4`, `ivec2`, `ivec3`, `ivec4`, `bvec2`, `bvec3`, `bvec4`, `sampler1D`, `sampler2D`, `sampler3DsamplerCube`, `sampler1DShadow`, `sampler2DShadow`, `struct`), Keyword, nil}, | ||||
| 			{Words(`\b`, `\b`, `asm`, `class`, `union`, `enum`, `typedef`, `template`, `this`, `packed`, `goto`, `switch`, `default`, `inline`, `noinline`, `volatile`, `public`, `static`, `extern`, `external`, `interface`, `long`, `short`, `double`, `half`, `fixed`, `unsigned`, `lowp`, `mediump`, `highp`, `precision`, `input`, `output`, `hvec2`, `hvec3`, `hvec4`, `dvec2`, `dvec3`, `dvec4`, `fvec2`, `fvec3`, `fvec4`, `sampler2DRect`, `sampler3DRect`, `sampler2DRectShadow`, `sizeof`, `cast`, `namespace`, `using`), Keyword, nil}, | ||||
| 			{`[a-zA-Z_]\w*`, Name, nil}, | ||||
| 			{`\.`, Punctuation, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										116
									
								
								lexers/gnuplot.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										116
									
								
								lexers/gnuplot.go
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										43
									
								
								lexers/go.go
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								lexers/go.go
									
									
									
									
									
								
							| @@ -3,67 +3,44 @@ package lexers | ||||
| import ( | ||||
| 	"strings" | ||||
|  | ||||
| 	. "github.com/alecthomas/chroma" // nolint: golint | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Go lexer. | ||||
| var Go = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Go", | ||||
| 		Aliases:   []string{"go"}, | ||||
| 		Filenames: []string{"*.go"}, | ||||
| 		Aliases:   []string{"go", "golang"}, | ||||
| 		MimeTypes: []string{"text/x-gosrc"}, | ||||
| 	}, | ||||
| 	// TODO: Convert this Lexer to use text/scanner | ||||
| 	Rules{ | ||||
| 		`root`: []Rule{ | ||||
| 		"root": { | ||||
| 			{`\n`, Text, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`\\\n`, Text, nil}, // line continuations | ||||
| 			{`\\\n`, Text, nil}, | ||||
| 			{`//(.*?)\n`, CommentSingle, nil}, | ||||
| 			{`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil}, | ||||
| 			{`(import|package)\b`, KeywordNamespace, nil}, | ||||
| 			{`(var|func|struct|map|chan|type|interface|const)\b`, | ||||
| 				KeywordDeclaration, nil}, | ||||
| 			{Words(`break`, `default`, `select`, `case`, `defer`, `go`, | ||||
| 				`else`, `goto`, `switch`, `fallthrough`, `if`, `range`, | ||||
| 				`continue`, `for`, `return`), Keyword, nil}, | ||||
| 			{`(var|func|struct|map|chan|type|interface|const)\b`, KeywordDeclaration, nil}, | ||||
| 			{Words(``, `\b`, `break`, `default`, `select`, `case`, `defer`, `go`, `else`, `goto`, `switch`, `fallthrough`, `if`, `range`, `continue`, `for`, `return`), Keyword, nil}, | ||||
| 			{`(true|false|iota|nil)\b`, KeywordConstant, nil}, | ||||
| 			{Words(`uint`, `uint8`, `uint16`, `uint32`, `uint64`, | ||||
| 				`int`, `int8`, `int16`, `int32`, `int64`, | ||||
| 				`float`, `float32`, `float64`, | ||||
| 				`complex64`, `complex128`, `byte`, `rune`, | ||||
| 				`string`, `bool`, `erro`, `uintpt`, | ||||
| 				`print`, `println`, `panic`, `recove`, `close`, `complex`, | ||||
| 				`real`, `imag`, `len`, `cap`, `append`, `copy`, `delete`, | ||||
| 				`new`, `make`), | ||||
| 				KeywordType, nil}, | ||||
| 			// imaginary_lit | ||||
| 			{Words(``, `\b(\()`, `uint`, `uint8`, `uint16`, `uint32`, `uint64`, `int`, `int8`, `int16`, `int32`, `int64`, `float`, `float32`, `float64`, `complex64`, `complex128`, `byte`, `rune`, `string`, `bool`, `error`, `uintptr`, `print`, `println`, `panic`, `recover`, `close`, `complex`, `real`, `imag`, `len`, `cap`, `append`, `copy`, `delete`, `new`, `make`), ByGroups(NameBuiltin, Punctuation), nil}, | ||||
| 			{Words(``, `\b`, `uint`, `uint8`, `uint16`, `uint32`, `uint64`, `int`, `int8`, `int16`, `int32`, `int64`, `float`, `float32`, `float64`, `complex64`, `complex128`, `byte`, `rune`, `string`, `bool`, `error`, `uintptr`), KeywordType, nil}, | ||||
| 			{`\d+i`, LiteralNumber, nil}, | ||||
| 			{`\d+\.\d*([Ee][-+]\d+)?i`, LiteralNumber, nil}, | ||||
| 			{`\.\d+([Ee][-+]\d+)?i`, LiteralNumber, nil}, | ||||
| 			{`\d+[Ee][-+]\d+i`, LiteralNumber, nil}, | ||||
| 			// float_lit | ||||
| 			{`\d+(\.\d+[eE][+\-]?\d+|\.\d*|[eE][+\-]?\d+)`, LiteralNumberFloat, nil}, | ||||
| 			{`\.\d+([eE][+\-]?\d+)?`, LiteralNumberFloat, nil}, | ||||
| 			// int_lit | ||||
| 			// -- octal_lit | ||||
| 			{`0[0-7]+`, LiteralNumberOct, nil}, | ||||
| 			// -- hex_lit | ||||
| 			{`0[xX][0-9a-fA-F]+`, LiteralNumberHex, nil}, | ||||
| 			// -- decimal_lit | ||||
| 			{`(0|[1-9][0-9]*)`, LiteralNumberInteger, nil}, | ||||
| 			// char_lit | ||||
| 			{`'(\\['"\\abfnrtv]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|[^\\])'`, LiteralStringChar, nil}, | ||||
| 			// StringLiteral | ||||
| 			// -- raw_string_lit | ||||
| 			{"`[^`]*`", String, nil}, | ||||
| 			// -- interpreted_string_lit | ||||
| 			{`"(\\\\|\\"|[^"])*"`, String, nil}, | ||||
| 			// Tokens | ||||
| 			{"`[^`]*`", LiteralString, nil}, | ||||
| 			{`"(\\\\|\\"|[^"])*"`, LiteralString, nil}, | ||||
| 			{`(<<=|>>=|<<|>>|<=|>=|&\^=|&\^|\+=|-=|\*=|/=|%=|&=|\|=|&&|\|\||<-|\+\+|--|==|!=|:=|\.\.\.|[+\-*/%&])`, Operator, nil}, | ||||
| 			{`[|^<>=!()\[\]{}.,;:]`, Punctuation, nil}, | ||||
| 			// identifier | ||||
| 			{`[^\W\d]\w*`, NameOther, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
|   | ||||
							
								
								
									
										57
									
								
								lexers/groovy.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								lexers/groovy.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Groovy lexer. | ||||
| var Groovy = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Groovy", | ||||
| 		Aliases:   []string{"groovy"}, | ||||
| 		Filenames: []string{"*.groovy", "*.gradle"}, | ||||
| 		MimeTypes: []string{"text/x-groovy"}, | ||||
| 		DotAll:    true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`#!(.*?)$`, CommentPreproc, Push("base")}, | ||||
| 			Default(Push("base")), | ||||
| 		}, | ||||
| 		"base": { | ||||
| 			{`^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)([a-zA-Z_]\w*)(\s*)(\()`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil}, | ||||
| 			{`[^\S\n]+`, Text, nil}, | ||||
| 			{`//.*?\n`, CommentSingle, nil}, | ||||
| 			{`/\*.*?\*/`, CommentMultiline, nil}, | ||||
| 			{`@[a-zA-Z_][\w.]*`, NameDecorator, nil}, | ||||
| 			{`(assert|break|case|catch|continue|default|do|else|finally|for|if|goto|instanceof|new|return|switch|this|throw|try|while|in|as)\b`, Keyword, nil}, | ||||
| 			{`(abstract|const|enum|extends|final|implements|native|private|protected|public|static|strictfp|super|synchronized|throws|transient|volatile)\b`, KeywordDeclaration, nil}, | ||||
| 			{`(def|boolean|byte|char|double|float|int|long|short|void)\b`, KeywordType, nil}, | ||||
| 			{`(package)(\s+)`, ByGroups(KeywordNamespace, Text), nil}, | ||||
| 			{`(true|false|null)\b`, KeywordConstant, nil}, | ||||
| 			{`(class|interface)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("class")}, | ||||
| 			{`(import)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")}, | ||||
| 			{`""".*?"""`, LiteralStringDouble, nil}, | ||||
| 			{`'''.*?'''`, LiteralStringSingle, nil}, | ||||
| 			{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil}, | ||||
| 			{`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil}, | ||||
| 			{`\$/((?!/\$).)*/\$`, LiteralString, nil}, | ||||
| 			{`/(\\\\|\\"|[^/])*/`, LiteralString, nil}, | ||||
| 			{`'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'`, LiteralStringChar, nil}, | ||||
| 			{`(\.)([a-zA-Z_]\w*)`, ByGroups(Operator, NameAttribute), nil}, | ||||
| 			{`[a-zA-Z_]\w*:`, NameLabel, nil}, | ||||
| 			{`[a-zA-Z_$]\w*`, Name, nil}, | ||||
| 			{`[~^*!%&\[\](){}<>|+=:;,./?-]`, Operator, nil}, | ||||
| 			{`[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?`, LiteralNumberFloat, nil}, | ||||
| 			{`0x[0-9a-fA-F]+`, LiteralNumberHex, nil}, | ||||
| 			{`[0-9]+L?`, LiteralNumberInteger, nil}, | ||||
| 			{`\n`, Text, nil}, | ||||
| 		}, | ||||
| 		"class": { | ||||
| 			{`[a-zA-Z_]\w*`, NameClass, Pop(1)}, | ||||
| 		}, | ||||
| 		"import": { | ||||
| 			{`[\w.]+\*?`, NameNamespace, Pop(1)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										55
									
								
								lexers/handlebars.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								lexers/handlebars.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,55 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Handlebars lexer. | ||||
| var Handlebars = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Handlebars", | ||||
| 		Aliases:   []string{"handlebars"}, | ||||
| 		Filenames: []string{}, | ||||
| 		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}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										98
									
								
								lexers/haskell.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								lexers/haskell.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,98 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Haskell lexer. | ||||
| var Haskell = 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}, | ||||
| 			{`^[_a-zµß-öø-ÿāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıijĵķ-ĸĺļľŀłńņň-ʼnŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷźżž-ƀƃƅƈƌ-ƍƒƕƙ-ƛƞơƣƥƨƪ-ƫƭưƴƶƹ-ƺƽ-ƿdžljnjǎǐǒǔǖǘǚǜ-ǝǟǡǣǥǧǩǫǭǯ-ǰdzǵǹǻǽǿȁȃȅȇȉȋȍȏȑȓȕȗșțȝȟȡȣȥȧȩȫȭȯȱȳ-ȹȼȿ-ɀɂɇɉɋɍɏ-ʓʕ-ʯͱͳͷͻ-ͽΐά-ώϐ-ϑϕ-ϗϙϛϝϟϡϣϥϧϩϫϭϯ-ϳϵϸϻ-ϼа-џѡѣѥѧѩѫѭѯѱѳѵѷѹѻѽѿҁҋҍҏґғҕҗҙқҝҟҡңҥҧҩҫҭүұҳҵҷҹһҽҿӂӄӆӈӊӌӎ-ӏӑӓӕӗәӛӝӟӡӣӥӧөӫӭӯӱӳӵӷӹӻӽӿԁԃԅԇԉԋԍԏԑԓԕԗԙԛԝԟԡԣԥԧա-ևᴀ-ᴫᵫ-ᵷᵹ-ᶚḁḃḅḇḉḋḍḏḑḓḕḗḙḛḝḟḡḣḥḧḩḫḭḯḱḳḵḷḹḻḽḿṁṃṅṇṉṋṍṏṑṓṕṗṙṛṝṟṡṣṥṧṩṫṭṯṱṳṵṷṹṻṽṿẁẃẅẇẉẋẍẏẑẓẕ-ẝẟạảấầẩẫậắằẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹỻỽỿ-ἇἐ-ἕἠ-ἧἰ-ἷὀ-ὅὐ-ὗὠ-ὧὰ-ώᾀ-ᾇᾐ-ᾗᾠ-ᾧᾰ-ᾴᾶ-ᾷιῂ-ῄῆ-ῇῐ-ΐῖ-ῗῠ-ῧῲ-ῴῶ-ῷℊℎ-ℏℓℯℴℹℼ-ℽⅆ-ⅉⅎↄⰰ-ⱞⱡⱥ-ⱦⱨⱪⱬⱱⱳ-ⱴⱶ-ⱻⲁⲃⲅⲇⲉⲋⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⲳⲵⲷⲹⲻⲽⲿⳁⳃⳅⳇⳉⳋⳍⳏⳑⳓⳕⳗⳙⳛⳝⳟⳡⳣ-ⳤⳬⳮⳳⴀ-ⴥⴧⴭꙁꙃꙅꙇꙉꙋꙍꙏꙑꙓꙕꙗꙙꙛꙝꙟꙡꙣꙥꙧꙩꙫꙭꚁꚃꚅꚇꚉꚋꚍꚏꚑꚓꚕꚗꜣꜥꜧꜩꜫꜭꜯ-ꜱꜳꜵꜷꜹꜻꜽꜿꝁꝃꝅꝇꝉꝋꝍꝏꝑꝓꝕꝗꝙꝛꝝꝟꝡꝣꝥꝧꝩꝫꝭꝯꝱ-ꝸꝺꝼꝿꞁꞃꞅꞇꞌꞎꞑꞓꞡꞣꞥꞧꞩꟺff-stﬓ-ﬗa-z𐐨-𐑏𝐚-𝐳𝑎-𝑔𝑖-𝑧𝒂-𝒛𝒶-𝒹𝒻𝒽-𝓃𝓅-𝓏𝓪-𝔃𝔞-𝔷𝕒-𝕫𝖆-𝖟𝖺-𝗓𝗮-𝘇𝘢-𝘻𝙖-𝙯𝚊-𝚥𝛂-𝛚𝛜-𝛡𝛼-𝜔𝜖-𝜛𝜶-𝝎𝝐-𝝕𝝰-𝞈𝞊-𝞏𝞪-𝟂𝟄-𝟉𝟋][\w\']*`, NameFunction, nil}, | ||||
| 			{`'?[_a-zµß-öø-ÿāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıijĵķ-ĸĺļľŀłńņň-ʼnŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷźżž-ƀƃƅƈƌ-ƍƒƕƙ-ƛƞơƣƥƨƪ-ƫƭưƴƶƹ-ƺƽ-ƿdžljnjǎǐǒǔǖǘǚǜ-ǝǟǡǣǥǧǩǫǭǯ-ǰdzǵǹǻǽǿȁȃȅȇȉȋȍȏȑȓȕȗșțȝȟȡȣȥȧȩȫȭȯȱȳ-ȹȼȿ-ɀɂɇɉɋɍɏ-ʓʕ-ʯͱͳͷͻ-ͽΐά-ώϐ-ϑϕ-ϗϙϛϝϟϡϣϥϧϩϫϭϯ-ϳϵϸϻ-ϼа-џѡѣѥѧѩѫѭѯѱѳѵѷѹѻѽѿҁҋҍҏґғҕҗҙқҝҟҡңҥҧҩҫҭүұҳҵҷҹһҽҿӂӄӆӈӊӌӎ-ӏӑӓӕӗәӛӝӟӡӣӥӧөӫӭӯӱӳӵӷӹӻӽӿԁԃԅԇԉԋԍԏԑԓԕԗԙԛԝԟԡԣԥԧա-ևᴀ-ᴫᵫ-ᵷᵹ-ᶚḁḃḅḇḉḋḍḏḑḓḕḗḙḛḝḟḡḣḥḧḩḫḭḯḱḳḵḷḹḻḽḿṁṃṅṇṉṋṍṏṑṓṕṗṙṛṝṟṡṣṥṧṩṫṭṯṱṳṵṷṹṻṽṿẁẃẅẇẉẋẍẏẑẓẕ-ẝẟạảấầẩẫậắằẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹỻỽỿ-ἇἐ-ἕἠ-ἧἰ-ἷὀ-ὅὐ-ὗὠ-ὧὰ-ώᾀ-ᾇᾐ-ᾗᾠ-ᾧᾰ-ᾴᾶ-ᾷιῂ-ῄῆ-ῇῐ-ΐῖ-ῗῠ-ῧῲ-ῴῶ-ῷℊℎ-ℏℓℯℴℹℼ-ℽⅆ-ⅉⅎↄⰰ-ⱞⱡⱥ-ⱦⱨⱪⱬⱱⱳ-ⱴⱶ-ⱻⲁⲃⲅⲇⲉⲋⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⲳⲵⲷⲹⲻⲽⲿⳁⳃⳅⳇⳉⳋⳍⳏⳑⳓⳕⳗⳙⳛⳝⳟⳡⳣ-ⳤⳬⳮⳳⴀ-ⴥⴧⴭꙁꙃꙅꙇꙉꙋꙍꙏꙑꙓꙕꙗꙙꙛꙝꙟꙡꙣꙥꙧꙩꙫꙭꚁꚃꚅꚇꚉꚋꚍꚏꚑꚓꚕꚗꜣꜥꜧꜩꜫꜭꜯ-ꜱꜳꜵꜷꜹꜻꜽꜿꝁꝃꝅꝇꝉꝋꝍꝏꝑꝓꝕꝗꝙꝛꝝꝟꝡꝣꝥꝧꝩꝫꝭꝯꝱ-ꝸꝺꝼꝿꞁꞃꞅꞇꞌꞎꞑꞓꞡꞣꞥꞧꞩꟺff-stﬓ-ﬗa-z𐐨-𐑏𝐚-𝐳𝑎-𝑔𝑖-𝑧𝒂-𝒛𝒶-𝒹𝒻𝒽-𝓃𝓅-𝓏𝓪-𝔃𝔞-𝔷𝕒-𝕫𝖆-𝖟𝖺-𝗓𝗮-𝘇𝘢-𝘻𝙖-𝙯𝚊-𝚥𝛂-𝛚𝛜-𝛡𝛼-𝜔𝜖-𝜛𝜶-𝝎𝝐-𝝕𝝰-𝞈𝞊-𝞏𝞪-𝟂𝟄-𝟉𝟋][\w']*`, Name, nil}, | ||||
| 			{`('')?[A-ZÀ-ÖØ-ÞĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŸ-ŹŻŽƁ-ƂƄƆ-ƇƉ-ƋƎ-ƑƓ-ƔƖ-ƘƜ-ƝƟ-ƠƢƤƦ-ƧƩƬƮ-ƯƱ-ƳƵƷ-ƸƼDŽLJNJǍǏǑǓǕǗǙǛǞǠǢǤǦǨǪǬǮDZǴǶ-ǸǺǼǾȀȂȄȆȈȊȌȎȐȒȔȖȘȚȜȞȠȢȤȦȨȪȬȮȰȲȺ-ȻȽ-ȾɁɃ-ɆɈɊɌɎͰͲͶΆΈ-ΊΌΎ-ΏΑ-ΡΣ-ΫϏϒ-ϔϘϚϜϞϠϢϤϦϨϪϬϮϴϷϹ-ϺϽ-ЯѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӀ-ӁӃӅӇӉӋӍӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӶӸӺӼӾԀԂԄԆԈԊԌԎԐԒԔԖԘԚԜԞԠԢԤԦԱ-ՖႠ-ჅჇჍḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẞẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸỺỼỾἈ-ἏἘ-ἝἨ-ἯἸ-ἿὈ-ὍὙὛὝὟὨ-ὯᾸ-ΆῈ-ΉῘ-ΊῨ-ῬῸ-Ώℂℇℋ-ℍℐ-ℒℕℙ-ℝℤΩℨK-ℭℰ-ℳℾ-ℿⅅↃⰀ-ⰮⱠⱢ-ⱤⱧⱩⱫⱭ-ⱰⱲⱵⱾ-ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢⳫⳭⳲꙀꙂꙄꙆꙈꙊꙌꙎꙐꙒꙔꙖꙘꙚꙜꙞꙠꙢꙤꙦꙨꙪꙬꚀꚂꚄꚆꚈꚊꚌꚎꚐꚒꚔꚖꜢꜤꜦꜨꜪꜬꜮꜲꜴꜶꜸꜺꜼꜾꝀꝂꝄꝆꝈꝊꝌꝎꝐꝒꝔꝖꝘꝚꝜꝞꝠꝢꝤꝦꝨꝪꝬꝮꝹꝻꝽ-ꝾꞀꞂꞄꞆꞋꞍꞐꞒꞠꞢꞤꞦꞨꞪA-Z𐐀-𐐧𝐀-𝐙𝐴-𝑍𝑨-𝒁𝒜𝒞-𝒟𝒢𝒥-𝒦𝒩-𝒬𝒮-𝒵𝓐-𝓩𝔄-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔸-𝔹𝔻-𝔾𝕀-𝕄𝕆𝕊-𝕐𝕬-𝖅𝖠-𝖹𝗔-𝗭𝘈-𝘡𝘼-𝙕𝙰-𝚉𝚨-𝛀𝛢-𝛺𝜜-𝜴𝝖-𝝮𝞐-𝞨𝟊][\w\']*`, KeywordType, nil}, | ||||
| 			{`(')[A-ZÀ-ÖØ-ÞĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŸ-ŹŻŽƁ-ƂƄƆ-ƇƉ-ƋƎ-ƑƓ-ƔƖ-ƘƜ-ƝƟ-ƠƢƤƦ-ƧƩƬƮ-ƯƱ-ƳƵƷ-ƸƼDŽLJNJǍǏǑǓǕǗǙǛǞǠǢǤǦǨǪǬǮDZǴǶ-ǸǺǼǾȀȂȄȆȈȊȌȎȐȒȔȖȘȚȜȞȠȢȤȦȨȪȬȮȰȲȺ-ȻȽ-ȾɁɃ-ɆɈɊɌɎͰͲͶΆΈ-ΊΌΎ-ΏΑ-ΡΣ-ΫϏϒ-ϔϘϚϜϞϠϢϤϦϨϪϬϮϴϷϹ-ϺϽ-ЯѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӀ-ӁӃӅӇӉӋӍӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӶӸӺӼӾԀԂԄԆԈԊԌԎԐԒԔԖԘԚԜԞԠԢԤԦԱ-ՖႠ-ჅჇჍḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẞẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸỺỼỾἈ-ἏἘ-ἝἨ-ἯἸ-ἿὈ-ὍὙὛὝὟὨ-ὯᾸ-ΆῈ-ΉῘ-ΊῨ-ῬῸ-Ώℂℇℋ-ℍℐ-ℒℕℙ-ℝℤΩℨK-ℭℰ-ℳℾ-ℿⅅↃⰀ-ⰮⱠⱢ-ⱤⱧⱩⱫⱭ-ⱰⱲⱵⱾ-ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢⳫⳭⳲꙀꙂꙄꙆꙈꙊꙌꙎꙐꙒꙔꙖꙘꙚꙜꙞꙠꙢꙤꙦꙨꙪꙬꚀꚂꚄꚆꚈꚊꚌꚎꚐꚒꚔꚖꜢꜤꜦꜨꜪꜬꜮꜲꜴꜶꜸꜺꜼꜾꝀꝂꝄꝆꝈꝊꝌꝎꝐꝒꝔꝖꝘꝚꝜꝞꝠꝢꝤꝦꝨꝪꝬꝮꝹꝻꝽ-ꝾꞀꞂꞄꞆꞋꞍꞐꞒꞠꞢꞤꞦꞨꞪA-Z𐐀-𐐧𝐀-𝐙𝐴-𝑍𝑨-𝒁𝒜𝒞-𝒟𝒢𝒥-𝒦𝒩-𝒬𝒮-𝒵𝓐-𝓩𝔄-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔸-𝔹𝔻-𝔾𝕀-𝕄𝕆𝕊-𝕐𝕬-𝖅𝖠-𝖹𝗔-𝗭𝘈-𝘡𝘼-𝙕𝙰-𝚉𝚨-𝛀𝛢-𝛺𝜜-𝜴𝝖-𝝮𝞐-𝞨𝟊][\w\']*`, 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}, | ||||
| 			{`([A-ZÀ-ÖØ-ÞĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŸ-ŹŻŽƁ-ƂƄƆ-ƇƉ-ƋƎ-ƑƓ-ƔƖ-ƘƜ-ƝƟ-ƠƢƤƦ-ƧƩƬƮ-ƯƱ-ƳƵƷ-ƸƼDŽLJNJǍǏǑǓǕǗǙǛǞǠǢǤǦǨǪǬǮDZǴǶ-ǸǺǼǾȀȂȄȆȈȊȌȎȐȒȔȖȘȚȜȞȠȢȤȦȨȪȬȮȰȲȺ-ȻȽ-ȾɁɃ-ɆɈɊɌɎͰͲͶΆΈ-ΊΌΎ-ΏΑ-ΡΣ-ΫϏϒ-ϔϘϚϜϞϠϢϤϦϨϪϬϮϴϷϹ-ϺϽ-ЯѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӀ-ӁӃӅӇӉӋӍӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӶӸӺӼӾԀԂԄԆԈԊԌԎԐԒԔԖԘԚԜԞԠԢԤԦԱ-ՖႠ-ჅჇჍḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẞẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸỺỼỾἈ-ἏἘ-ἝἨ-ἯἸ-ἿὈ-ὍὙὛὝὟὨ-ὯᾸ-ΆῈ-ΉῘ-ΊῨ-ῬῸ-Ώℂℇℋ-ℍℐ-ℒℕℙ-ℝℤΩℨK-ℭℰ-ℳℾ-ℿⅅↃⰀ-ⰮⱠⱢ-ⱤⱧⱩⱫⱭ-ⱰⱲⱵⱾ-ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢⳫⳭⳲꙀꙂꙄꙆꙈꙊꙌꙎꙐꙒꙔꙖꙘꙚꙜꙞꙠꙢꙤꙦꙨꙪꙬꚀꚂꚄꚆꚈꚊꚌꚎꚐꚒꚔꚖꜢꜤꜦꜨꜪꜬꜮꜲꜴꜶꜸꜺꜼꜾꝀꝂꝄꝆꝈꝊꝌꝎꝐꝒꝔꝖꝘꝚꝜꝞꝠꝢꝤꝦꝨꝪꝬꝮꝹꝻꝽ-ꝾꞀꞂꞄꞆꞋꞍꞐꞒꞠꞢꞤꞦꞨꞪA-Z𐐀-𐐧𝐀-𝐙𝐴-𝑍𝑨-𝒁𝒜𝒞-𝒟𝒢𝒥-𝒦𝒩-𝒬𝒮-𝒵𝓐-𝓩𝔄-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔸-𝔹𝔻-𝔾𝕀-𝕄𝕆𝕊-𝕐𝕬-𝖅𝖠-𝖹𝗔-𝗭𝘈-𝘡𝘼-𝙕𝙰-𝚉𝚨-𝛀𝛢-𝛺𝜜-𝜴𝝖-𝝮𝞐-𝞨𝟊][\w.]*)(\s+)(as)(\s+)([A-ZÀ-ÖØ-ÞĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŸ-ŹŻŽƁ-ƂƄƆ-ƇƉ-ƋƎ-ƑƓ-ƔƖ-ƘƜ-ƝƟ-ƠƢƤƦ-ƧƩƬƮ-ƯƱ-ƳƵƷ-ƸƼDŽLJNJǍǏǑǓǕǗǙǛǞǠǢǤǦǨǪǬǮDZǴǶ-ǸǺǼǾȀȂȄȆȈȊȌȎȐȒȔȖȘȚȜȞȠȢȤȦȨȪȬȮȰȲȺ-ȻȽ-ȾɁɃ-ɆɈɊɌɎͰͲͶΆΈ-ΊΌΎ-ΏΑ-ΡΣ-ΫϏϒ-ϔϘϚϜϞϠϢϤϦϨϪϬϮϴϷϹ-ϺϽ-ЯѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӀ-ӁӃӅӇӉӋӍӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӶӸӺӼӾԀԂԄԆԈԊԌԎԐԒԔԖԘԚԜԞԠԢԤԦԱ-ՖႠ-ჅჇჍḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẞẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸỺỼỾἈ-ἏἘ-ἝἨ-ἯἸ-ἿὈ-ὍὙὛὝὟὨ-ὯᾸ-ΆῈ-ΉῘ-ΊῨ-ῬῸ-Ώℂℇℋ-ℍℐ-ℒℕℙ-ℝℤΩℨK-ℭℰ-ℳℾ-ℿⅅↃⰀ-ⰮⱠⱢ-ⱤⱧⱩⱫⱭ-ⱰⱲⱵⱾ-ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢⳫⳭⳲꙀꙂꙄꙆꙈꙊꙌꙎꙐꙒꙔꙖꙘꙚꙜꙞꙠꙢꙤꙦꙨꙪꙬꚀꚂꚄꚆꚈꚊꚌꚎꚐꚒꚔꚖꜢꜤꜦꜨꜪꜬꜮꜲꜴꜶꜸꜺꜼꜾꝀꝂꝄꝆꝈꝊꝌꝎꝐꝒꝔꝖꝘꝚꝜꝞꝠꝢꝤꝦꝨꝪꝬꝮꝹꝻꝽ-ꝾꞀꞂꞄꞆꞋꞍꞐꞒꞠꞢꞤꞦꞨꞪA-Z𐐀-𐐧𝐀-𝐙𝐴-𝑍𝑨-𝒁𝒜𝒞-𝒟𝒢𝒥-𝒦𝒩-𝒬𝒮-𝒵𝓐-𝓩𝔄-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔸-𝔹𝔻-𝔾𝕀-𝕄𝕆𝕊-𝕐𝕬-𝖅𝖠-𝖹𝗔-𝗭𝘈-𝘡𝘼-𝙕𝙰-𝚉𝚨-𝛀𝛢-𝛺𝜜-𝜴𝝖-𝝮𝞐-𝞨𝟊][\w.]*)`, ByGroups(NameNamespace, Text, Keyword, Text, Name), Pop(1)}, | ||||
| 			{`([A-ZÀ-ÖØ-ÞĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŸ-ŹŻŽƁ-ƂƄƆ-ƇƉ-ƋƎ-ƑƓ-ƔƖ-ƘƜ-ƝƟ-ƠƢƤƦ-ƧƩƬƮ-ƯƱ-ƳƵƷ-ƸƼDŽLJNJǍǏǑǓǕǗǙǛǞǠǢǤǦǨǪǬǮDZǴǶ-ǸǺǼǾȀȂȄȆȈȊȌȎȐȒȔȖȘȚȜȞȠȢȤȦȨȪȬȮȰȲȺ-ȻȽ-ȾɁɃ-ɆɈɊɌɎͰͲͶΆΈ-ΊΌΎ-ΏΑ-ΡΣ-ΫϏϒ-ϔϘϚϜϞϠϢϤϦϨϪϬϮϴϷϹ-ϺϽ-ЯѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӀ-ӁӃӅӇӉӋӍӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӶӸӺӼӾԀԂԄԆԈԊԌԎԐԒԔԖԘԚԜԞԠԢԤԦԱ-ՖႠ-ჅჇჍḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẞẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸỺỼỾἈ-ἏἘ-ἝἨ-ἯἸ-ἿὈ-ὍὙὛὝὟὨ-ὯᾸ-ΆῈ-ΉῘ-ΊῨ-ῬῸ-Ώℂℇℋ-ℍℐ-ℒℕℙ-ℝℤΩℨK-ℭℰ-ℳℾ-ℿⅅↃⰀ-ⰮⱠⱢ-ⱤⱧⱩⱫⱭ-ⱰⱲⱵⱾ-ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢⳫⳭⳲꙀꙂꙄꙆꙈꙊꙌꙎꙐꙒꙔꙖꙘꙚꙜꙞꙠꙢꙤꙦꙨꙪꙬꚀꚂꚄꚆꚈꚊꚌꚎꚐꚒꚔꚖꜢꜤꜦꜨꜪꜬꜮꜲꜴꜶꜸꜺꜼꜾꝀꝂꝄꝆꝈꝊꝌꝎꝐꝒꝔꝖꝘꝚꝜꝞꝠꝢꝤꝦꝨꝪꝬꝮꝹꝻꝽ-ꝾꞀꞂꞄꞆꞋꞍꞐꞒꞠꞢꞤꞦꞨꞪA-Z𐐀-𐐧𝐀-𝐙𝐴-𝑍𝑨-𝒁𝒜𝒞-𝒟𝒢𝒥-𝒦𝒩-𝒬𝒮-𝒵𝓐-𝓩𝔄-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔸-𝔹𝔻-𝔾𝕀-𝕄𝕆𝕊-𝕐𝕬-𝖅𝖠-𝖹𝗔-𝗭𝘈-𝘡𝘼-𝙕𝙰-𝚉𝚨-𝛀𝛢-𝛺𝜜-𝜴𝝖-𝝮𝞐-𝞨𝟊][\w.]*)(\s+)(hiding)(\s+)(\()`, ByGroups(NameNamespace, Text, Keyword, Text, Punctuation), Push("funclist")}, | ||||
| 			{`([A-ZÀ-ÖØ-ÞĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŸ-ŹŻŽƁ-ƂƄƆ-ƇƉ-ƋƎ-ƑƓ-ƔƖ-ƘƜ-ƝƟ-ƠƢƤƦ-ƧƩƬƮ-ƯƱ-ƳƵƷ-ƸƼDŽLJNJǍǏǑǓǕǗǙǛǞǠǢǤǦǨǪǬǮDZǴǶ-ǸǺǼǾȀȂȄȆȈȊȌȎȐȒȔȖȘȚȜȞȠȢȤȦȨȪȬȮȰȲȺ-ȻȽ-ȾɁɃ-ɆɈɊɌɎͰͲͶΆΈ-ΊΌΎ-ΏΑ-ΡΣ-ΫϏϒ-ϔϘϚϜϞϠϢϤϦϨϪϬϮϴϷϹ-ϺϽ-ЯѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӀ-ӁӃӅӇӉӋӍӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӶӸӺӼӾԀԂԄԆԈԊԌԎԐԒԔԖԘԚԜԞԠԢԤԦԱ-ՖႠ-ჅჇჍḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẞẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸỺỼỾἈ-ἏἘ-ἝἨ-ἯἸ-ἿὈ-ὍὙὛὝὟὨ-ὯᾸ-ΆῈ-ΉῘ-ΊῨ-ῬῸ-Ώℂℇℋ-ℍℐ-ℒℕℙ-ℝℤΩℨK-ℭℰ-ℳℾ-ℿⅅↃⰀ-ⰮⱠⱢ-ⱤⱧⱩⱫⱭ-ⱰⱲⱵⱾ-ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢⳫⳭⳲꙀꙂꙄꙆꙈꙊꙌꙎꙐꙒꙔꙖꙘꙚꙜꙞꙠꙢꙤꙦꙨꙪꙬꚀꚂꚄꚆꚈꚊꚌꚎꚐꚒꚔꚖꜢꜤꜦꜨꜪꜬꜮꜲꜴꜶꜸꜺꜼꜾꝀꝂꝄꝆꝈꝊꝌꝎꝐꝒꝔꝖꝘꝚꝜꝞꝠꝢꝤꝦꝨꝪꝬꝮꝹꝻꝽ-ꝾꞀꞂꞄꞆꞋꞍꞐꞒꞠꞢꞤꞦꞨꞪA-Z𐐀-𐐧𝐀-𝐙𝐴-𝑍𝑨-𝒁𝒜𝒞-𝒟𝒢𝒥-𝒦𝒩-𝒬𝒮-𝒵𝓐-𝓩𝔄-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔸-𝔹𝔻-𝔾𝕀-𝕄𝕆𝕊-𝕐𝕬-𝖅𝖠-𝖹𝗔-𝗭𝘈-𝘡𝘼-𝙕𝙰-𝚉𝚨-𝛀𝛢-𝛺𝜜-𝜴𝝖-𝝮𝞐-𝞨𝟊][\w.]*)(\s+)(\()`, ByGroups(NameNamespace, Text, Punctuation), Push("funclist")}, | ||||
| 			{`[\w.]+`, NameNamespace, Pop(1)}, | ||||
| 		}, | ||||
| 		"module": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`([A-ZÀ-ÖØ-ÞĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŸ-ŹŻŽƁ-ƂƄƆ-ƇƉ-ƋƎ-ƑƓ-ƔƖ-ƘƜ-ƝƟ-ƠƢƤƦ-ƧƩƬƮ-ƯƱ-ƳƵƷ-ƸƼDŽLJNJǍǏǑǓǕǗǙǛǞǠǢǤǦǨǪǬǮDZǴǶ-ǸǺǼǾȀȂȄȆȈȊȌȎȐȒȔȖȘȚȜȞȠȢȤȦȨȪȬȮȰȲȺ-ȻȽ-ȾɁɃ-ɆɈɊɌɎͰͲͶΆΈ-ΊΌΎ-ΏΑ-ΡΣ-ΫϏϒ-ϔϘϚϜϞϠϢϤϦϨϪϬϮϴϷϹ-ϺϽ-ЯѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӀ-ӁӃӅӇӉӋӍӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӶӸӺӼӾԀԂԄԆԈԊԌԎԐԒԔԖԘԚԜԞԠԢԤԦԱ-ՖႠ-ჅჇჍḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẞẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸỺỼỾἈ-ἏἘ-ἝἨ-ἯἸ-ἿὈ-ὍὙὛὝὟὨ-ὯᾸ-ΆῈ-ΉῘ-ΊῨ-ῬῸ-Ώℂℇℋ-ℍℐ-ℒℕℙ-ℝℤΩℨK-ℭℰ-ℳℾ-ℿⅅↃⰀ-ⰮⱠⱢ-ⱤⱧⱩⱫⱭ-ⱰⱲⱵⱾ-ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢⳫⳭⳲꙀꙂꙄꙆꙈꙊꙌꙎꙐꙒꙔꙖꙘꙚꙜꙞꙠꙢꙤꙦꙨꙪꙬꚀꚂꚄꚆꚈꚊꚌꚎꚐꚒꚔꚖꜢꜤꜦꜨꜪꜬꜮꜲꜴꜶꜸꜺꜼꜾꝀꝂꝄꝆꝈꝊꝌꝎꝐꝒꝔꝖꝘꝚꝜꝞꝠꝢꝤꝦꝨꝪꝬꝮꝹꝻꝽ-ꝾꞀꞂꞄꞆꞋꞍꞐꞒꞠꞢꞤꞦꞨꞪA-Z𐐀-𐐧𝐀-𝐙𝐴-𝑍𝑨-𝒁𝒜𝒞-𝒟𝒢𝒥-𝒦𝒩-𝒬𝒮-𝒵𝓐-𝓩𝔄-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔸-𝔹𝔻-𝔾𝕀-𝕄𝕆𝕊-𝕐𝕬-𝖅𝖠-𝖹𝗔-𝗭𝘈-𝘡𝘼-𝙕𝙰-𝚉𝚨-𝛀𝛢-𝛺𝜜-𝜴𝝖-𝝮𝞐-𝞨𝟊][\w.]*)(\s+)(\()`, ByGroups(NameNamespace, Text, Punctuation), Push("funclist")}, | ||||
| 			{`[A-ZÀ-ÖØ-ÞĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŸ-ŹŻŽƁ-ƂƄƆ-ƇƉ-ƋƎ-ƑƓ-ƔƖ-ƘƜ-ƝƟ-ƠƢƤƦ-ƧƩƬƮ-ƯƱ-ƳƵƷ-ƸƼDŽLJNJǍǏǑǓǕǗǙǛǞǠǢǤǦǨǪǬǮDZǴǶ-ǸǺǼǾȀȂȄȆȈȊȌȎȐȒȔȖȘȚȜȞȠȢȤȦȨȪȬȮȰȲȺ-ȻȽ-ȾɁɃ-ɆɈɊɌɎͰͲͶΆΈ-ΊΌΎ-ΏΑ-ΡΣ-ΫϏϒ-ϔϘϚϜϞϠϢϤϦϨϪϬϮϴϷϹ-ϺϽ-ЯѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӀ-ӁӃӅӇӉӋӍӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӶӸӺӼӾԀԂԄԆԈԊԌԎԐԒԔԖԘԚԜԞԠԢԤԦԱ-ՖႠ-ჅჇჍḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẞẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸỺỼỾἈ-ἏἘ-ἝἨ-ἯἸ-ἿὈ-ὍὙὛὝὟὨ-ὯᾸ-ΆῈ-ΉῘ-ΊῨ-ῬῸ-Ώℂℇℋ-ℍℐ-ℒℕℙ-ℝℤΩℨK-ℭℰ-ℳℾ-ℿⅅↃⰀ-ⰮⱠⱢ-ⱤⱧⱩⱫⱭ-ⱰⱲⱵⱾ-ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢⳫⳭⳲꙀꙂꙄꙆꙈꙊꙌꙎꙐꙒꙔꙖꙘꙚꙜꙞꙠꙢꙤꙦꙨꙪꙬꚀꚂꚄꚆꚈꚊꚌꚎꚐꚒꚔꚖꜢꜤꜦꜨꜪꜬꜮꜲꜴꜶꜸꜺꜼꜾꝀꝂꝄꝆꝈꝊꝌꝎꝐꝒꝔꝖꝘꝚꝜꝞꝠꝢꝤꝦꝨꝪꝬꝮꝹꝻꝽ-ꝾꞀꞂꞄꞆꞋꞍꞐꞒꞠꞢꞤꞦꞨꞪA-Z𐐀-𐐧𝐀-𝐙𝐴-𝑍𝑨-𝒁𝒜𝒞-𝒟𝒢𝒥-𝒦𝒩-𝒬𝒮-𝒵𝓐-𝓩𝔄-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔸-𝔹𝔻-𝔾𝕀-𝕄𝕆𝕊-𝕐𝕬-𝖅𝖠-𝖹𝗔-𝗭𝘈-𝘡𝘼-𝙕𝙰-𝚉𝚨-𝛀𝛢-𝛺𝜜-𝜴𝝖-𝝮𝞐-𝞨𝟊][\w.]*`, NameNamespace, Pop(1)}, | ||||
| 		}, | ||||
| 		"funclist": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`[A-ZÀ-ÖØ-ÞĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŸ-ŹŻŽƁ-ƂƄƆ-ƇƉ-ƋƎ-ƑƓ-ƔƖ-ƘƜ-ƝƟ-ƠƢƤƦ-ƧƩƬƮ-ƯƱ-ƳƵƷ-ƸƼDŽLJNJǍǏǑǓǕǗǙǛǞǠǢǤǦǨǪǬǮDZǴǶ-ǸǺǼǾȀȂȄȆȈȊȌȎȐȒȔȖȘȚȜȞȠȢȤȦȨȪȬȮȰȲȺ-ȻȽ-ȾɁɃ-ɆɈɊɌɎͰͲͶΆΈ-ΊΌΎ-ΏΑ-ΡΣ-ΫϏϒ-ϔϘϚϜϞϠϢϤϦϨϪϬϮϴϷϹ-ϺϽ-ЯѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӀ-ӁӃӅӇӉӋӍӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӶӸӺӼӾԀԂԄԆԈԊԌԎԐԒԔԖԘԚԜԞԠԢԤԦԱ-ՖႠ-ჅჇჍḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẞẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸỺỼỾἈ-ἏἘ-ἝἨ-ἯἸ-ἿὈ-ὍὙὛὝὟὨ-ὯᾸ-ΆῈ-ΉῘ-ΊῨ-ῬῸ-Ώℂℇℋ-ℍℐ-ℒℕℙ-ℝℤΩℨK-ℭℰ-ℳℾ-ℿⅅↃⰀ-ⰮⱠⱢ-ⱤⱧⱩⱫⱭ-ⱰⱲⱵⱾ-ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢⳫⳭⳲꙀꙂꙄꙆꙈꙊꙌꙎꙐꙒꙔꙖꙘꙚꙜꙞꙠꙢꙤꙦꙨꙪꙬꚀꚂꚄꚆꚈꚊꚌꚎꚐꚒꚔꚖꜢꜤꜦꜨꜪꜬꜮꜲꜴꜶꜸꜺꜼꜾꝀꝂꝄꝆꝈꝊꝌꝎꝐꝒꝔꝖꝘꝚꝜꝞꝠꝢꝤꝦꝨꝪꝬꝮꝹꝻꝽ-ꝾꞀꞂꞄꞆꞋꞍꞐꞒꞠꞢꞤꞦꞨꞪA-Z𐐀-𐐧𝐀-𝐙𝐴-𝑍𝑨-𝒁𝒜𝒞-𝒟𝒢𝒥-𝒦𝒩-𝒬𝒮-𝒵𝓐-𝓩𝔄-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔸-𝔹𝔻-𝔾𝕀-𝕄𝕆𝕊-𝕐𝕬-𝖅𝖠-𝖹𝗔-𝗭𝘈-𝘡𝘼-𝙕𝙰-𝚉𝚨-𝛀𝛢-𝛺𝜜-𝜴𝝖-𝝮𝞐-𝞨𝟊]\w*`, KeywordType, nil}, | ||||
| 			{`(_[\w\']+|[a-zµß-öø-ÿāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıijĵķ-ĸĺļľŀłńņň-ʼnŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷźżž-ƀƃƅƈƌ-ƍƒƕƙ-ƛƞơƣƥƨƪ-ƫƭưƴƶƹ-ƺƽ-ƿdžljnjǎǐǒǔǖǘǚǜ-ǝǟǡǣǥǧǩǫǭǯ-ǰdzǵǹǻǽǿȁȃȅȇȉȋȍȏȑȓȕȗșțȝȟȡȣȥȧȩȫȭȯȱȳ-ȹȼȿ-ɀɂɇɉɋɍɏ-ʓʕ-ʯͱͳͷͻ-ͽΐά-ώϐ-ϑϕ-ϗϙϛϝϟϡϣϥϧϩϫϭϯ-ϳϵϸϻ-ϼа-џѡѣѥѧѩѫѭѯѱѳѵѷѹѻѽѿҁҋҍҏґғҕҗҙқҝҟҡңҥҧҩҫҭүұҳҵҷҹһҽҿӂӄӆӈӊӌӎ-ӏӑӓӕӗәӛӝӟӡӣӥӧөӫӭӯӱӳӵӷӹӻӽӿԁԃԅԇԉԋԍԏԑԓԕԗԙԛԝԟԡԣԥԧա-ևᴀ-ᴫᵫ-ᵷᵹ-ᶚḁḃḅḇḉḋḍḏḑḓḕḗḙḛḝḟḡḣḥḧḩḫḭḯḱḳḵḷḹḻḽḿṁṃṅṇṉṋṍṏṑṓṕṗṙṛṝṟṡṣṥṧṩṫṭṯṱṳṵṷṹṻṽṿẁẃẅẇẉẋẍẏẑẓẕ-ẝẟạảấầẩẫậắằẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹỻỽỿ-ἇἐ-ἕἠ-ἧἰ-ἷὀ-ὅὐ-ὗὠ-ὧὰ-ώᾀ-ᾇᾐ-ᾗᾠ-ᾧᾰ-ᾴᾶ-ᾷιῂ-ῄῆ-ῇῐ-ΐῖ-ῗῠ-ῧῲ-ῴῶ-ῷℊℎ-ℏℓℯℴℹℼ-ℽⅆ-ⅉⅎↄⰰ-ⱞⱡⱥ-ⱦⱨⱪⱬⱱⱳ-ⱴⱶ-ⱻⲁⲃⲅⲇⲉⲋⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⲳⲵⲷⲹⲻⲽⲿⳁⳃⳅⳇⳉⳋⳍⳏⳑⳓⳕⳗⳙⳛⳝⳟⳡⳣ-ⳤⳬⳮⳳⴀ-ⴥⴧⴭꙁꙃꙅꙇꙉꙋꙍꙏꙑꙓꙕꙗꙙꙛꙝꙟꙡꙣꙥꙧꙩꙫꙭꚁꚃꚅꚇꚉꚋꚍꚏꚑꚓꚕꚗꜣꜥꜧꜩꜫꜭꜯ-ꜱꜳꜵꜷꜹꜻꜽꜿꝁꝃꝅꝇꝉꝋꝍꝏꝑꝓꝕꝗꝙꝛꝝꝟꝡꝣꝥꝧꝩꝫꝭꝯꝱ-ꝸꝺꝼꝿꞁꞃꞅꞇꞌꞎꞑꞓꞡꞣꞥꞧꞩꟺff-stﬓ-ﬗa-z𐐨-𐑏𝐚-𝐳𝑎-𝑔𝑖-𝑧𝒂-𝒛𝒶-𝒹𝒻𝒽-𝓃𝓅-𝓏𝓪-𝔃𝔞-𝔷𝕒-𝕫𝖆-𝖟𝖺-𝗓𝗮-𝘇𝘢-𝘻𝙖-𝙯𝚊-𝚥𝛂-𝛚𝛜-𝛡𝛼-𝜔𝜖-𝜛𝜶-𝝎𝝐-𝝕𝝰-𝞈𝞊-𝞏𝞪-𝟂𝟄-𝟉𝟋][\w\']*)`, 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)}, | ||||
| 			{`\^[][A-ZÀ-ÖØ-ÞĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŸ-ŹŻŽƁ-ƂƄƆ-ƇƉ-ƋƎ-ƑƓ-ƔƖ-ƘƜ-ƝƟ-ƠƢƤƦ-ƧƩƬƮ-ƯƱ-ƳƵƷ-ƸƼDŽLJNJǍǏǑǓǕǗǙǛǞǠǢǤǦǨǪǬǮDZǴǶ-ǸǺǼǾȀȂȄȆȈȊȌȎȐȒȔȖȘȚȜȞȠȢȤȦȨȪȬȮȰȲȺ-ȻȽ-ȾɁɃ-ɆɈɊɌɎͰͲͶΆΈ-ΊΌΎ-ΏΑ-ΡΣ-ΫϏϒ-ϔϘϚϜϞϠϢϤϦϨϪϬϮϴϷϹ-ϺϽ-ЯѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӀ-ӁӃӅӇӉӋӍӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӶӸӺӼӾԀԂԄԆԈԊԌԎԐԒԔԖԘԚԜԞԠԢԤԦԱ-ՖႠ-ჅჇჍḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẞẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸỺỼỾἈ-ἏἘ-ἝἨ-ἯἸ-ἿὈ-ὍὙὛὝὟὨ-ὯᾸ-ΆῈ-ΉῘ-ΊῨ-ῬῸ-Ώℂℇℋ-ℍℐ-ℒℕℙ-ℝℤΩℨK-ℭℰ-ℳℾ-ℿⅅↃⰀ-ⰮⱠⱢ-ⱤⱧⱩⱫⱭ-ⱰⱲⱵⱾ-ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢⳫⳭⳲꙀꙂꙄꙆꙈꙊꙌꙎꙐꙒꙔꙖꙘꙚꙜꙞꙠꙢꙤꙦꙨꙪꙬꚀꚂꚄꚆꚈꚊꚌꚎꚐꚒꚔꚖꜢꜤꜦꜨꜪꜬꜮꜲꜴꜶꜸꜺꜼꜾꝀꝂꝄꝆꝈꝊꝌꝎꝐꝒꝔꝖꝘꝚꝜꝞꝠꝢꝤꝦꝨꝪꝬꝮꝹꝻꝽ-ꝾꞀꞂꞄꞆꞋꞍꞐꞒꞠꞢꞤꞦꞨꞪA-Z𐐀-𐐧𝐀-𝐙𝐴-𝑍𝑨-𝒁𝒜𝒞-𝒟𝒢𝒥-𝒦𝒩-𝒬𝒮-𝒵𝓐-𝓩𝔄-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔸-𝔹𝔻-𝔾𝕀-𝕄𝕆𝕊-𝕐𝕬-𝖅𝖠-𝖹𝗔-𝗭𝘈-𝘡𝘼-𝙕𝙰-𝚉𝚨-𝛀𝛢-𝛺𝜜-𝜴𝝖-𝝮𝞐-𝞨𝟊@^_]`, 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)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										640
									
								
								lexers/haxe.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										640
									
								
								lexers/haxe.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,640 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Haxe lexer. | ||||
| var Haxe = 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{ | ||||
| 		"root": { | ||||
| 			Include("spaces"), | ||||
| 			Include("meta"), | ||||
| 			{`(?:package)\b`, KeywordNamespace, Push("semicolon", "package")}, | ||||
| 			{`(?:import)\b`, KeywordNamespace, Push("semicolon", "import")}, | ||||
| 			{`(?:using)\b`, KeywordNamespace, Push("semicolon", "using")}, | ||||
| 			{`(?:extern|private)\b`, KeywordDeclaration, nil}, | ||||
| 			{`(?:abstract)\b`, KeywordDeclaration, Push("abstract")}, | ||||
| 			{`(?:class|interface)\b`, KeywordDeclaration, Push("class")}, | ||||
| 			{`(?:enum)\b`, KeywordDeclaration, Push("enum")}, | ||||
| 			{`(?:typedef)\b`, KeywordDeclaration, Push("typedef")}, | ||||
| 			{`(?=.)`, Text, Push("expr-statement")}, | ||||
| 		}, | ||||
| 		"spaces": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`//[^\n\r]*`, CommentSingle, nil}, | ||||
| 			{`/\*.*?\*/`, CommentMultiline, nil}, | ||||
| 			{`(#)(if|elseif|else|end|error)\b`, CommentPreproc, MutatorFunc(haxePreProcMutator)}, | ||||
| 		}, | ||||
| 		"string-single-interpol": { | ||||
| 			{`\$\{`, LiteralStringInterpol, Push("string-interpol-close", "expr")}, | ||||
| 			{`\$\$`, LiteralStringEscape, nil}, | ||||
| 			{`\$(?=(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+))`, LiteralStringInterpol, Push("ident")}, | ||||
| 			Include("string-single"), | ||||
| 		}, | ||||
| 		"string-single": { | ||||
| 			{`'`, LiteralStringSingle, Pop(1)}, | ||||
| 			{`\\.`, LiteralStringEscape, nil}, | ||||
| 			{`.`, LiteralStringSingle, nil}, | ||||
| 		}, | ||||
| 		"string-double": { | ||||
| 			{`"`, LiteralStringDouble, Pop(1)}, | ||||
| 			{`\\.`, LiteralStringEscape, nil}, | ||||
| 			{`.`, LiteralStringDouble, nil}, | ||||
| 		}, | ||||
| 		"string-interpol-close": { | ||||
| 			{`\$(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, LiteralStringInterpol, nil}, | ||||
| 			{`\}`, LiteralStringInterpol, Pop(1)}, | ||||
| 		}, | ||||
| 		"package": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, NameNamespace, nil}, | ||||
| 			{`\.`, Punctuation, Push("import-ident")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"import": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, NameNamespace, nil}, | ||||
| 			{`\*`, Keyword, nil}, | ||||
| 			{`\.`, Punctuation, Push("import-ident")}, | ||||
| 			{`in`, KeywordNamespace, Push("ident")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"import-ident": { | ||||
| 			Include("spaces"), | ||||
| 			{`\*`, Keyword, Pop(1)}, | ||||
| 			{`(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, NameNamespace, Pop(1)}, | ||||
| 		}, | ||||
| 		"using": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, NameNamespace, nil}, | ||||
| 			{`\.`, Punctuation, Push("import-ident")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"preproc-error": { | ||||
| 			{`\s+`, CommentPreproc, nil}, | ||||
| 			{`'`, LiteralStringSingle, Push("#pop", "string-single")}, | ||||
| 			{`"`, LiteralStringDouble, Push("#pop", "string-double")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"preproc-expr": { | ||||
| 			{`\s+`, CommentPreproc, nil}, | ||||
| 			{`\!`, CommentPreproc, nil}, | ||||
| 			{`\(`, CommentPreproc, Push("#pop", "preproc-parenthesis")}, | ||||
| 			{`(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, CommentPreproc, Pop(1)}, | ||||
| 			{`\.[0-9]+`, LiteralNumberFloat, nil}, | ||||
| 			{`[0-9]+[eE][+\-]?[0-9]+`, LiteralNumberFloat, nil}, | ||||
| 			{`[0-9]+\.[0-9]*[eE][+\-]?[0-9]+`, LiteralNumberFloat, nil}, | ||||
| 			{`[0-9]+\.[0-9]+`, LiteralNumberFloat, nil}, | ||||
| 			{`[0-9]+\.(?!(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)|\.\.)`, LiteralNumberFloat, nil}, | ||||
| 			{`0x[0-9a-fA-F]+`, LiteralNumberHex, nil}, | ||||
| 			{`[0-9]+`, LiteralNumberInteger, nil}, | ||||
| 			{`'`, LiteralStringSingle, Push("#pop", "string-single")}, | ||||
| 			{`"`, LiteralStringDouble, Push("#pop", "string-double")}, | ||||
| 		}, | ||||
| 		"preproc-parenthesis": { | ||||
| 			{`\s+`, CommentPreproc, nil}, | ||||
| 			{`\)`, CommentPreproc, Pop(1)}, | ||||
| 			Default(Push("preproc-expr-in-parenthesis")), | ||||
| 		}, | ||||
| 		"preproc-expr-chain": { | ||||
| 			{`\s+`, CommentPreproc, nil}, | ||||
| 			{`(?:%=|&=|\|=|\^=|\+=|\-=|\*=|/=|<<=|>\s*>\s*=|>\s*>\s*>\s*=|==|!=|<=|>\s*=|&&|\|\||<<|>>>|>\s*>|\.\.\.|<|>|%|&|\||\^|\+|\*|/|\-|=>|=)`, CommentPreproc, Push("#pop", "preproc-expr-in-parenthesis")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"preproc-expr-in-parenthesis": { | ||||
| 			{`\s+`, CommentPreproc, nil}, | ||||
| 			{`\!`, CommentPreproc, nil}, | ||||
| 			{`\(`, CommentPreproc, Push("#pop", "preproc-expr-chain", "preproc-parenthesis")}, | ||||
| 			{`(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, CommentPreproc, Push("#pop", "preproc-expr-chain")}, | ||||
| 			{`\.[0-9]+`, LiteralNumberFloat, Push("#pop", "preproc-expr-chain")}, | ||||
| 			{`[0-9]+[eE][+\-]?[0-9]+`, LiteralNumberFloat, Push("#pop", "preproc-expr-chain")}, | ||||
| 			{`[0-9]+\.[0-9]*[eE][+\-]?[0-9]+`, LiteralNumberFloat, Push("#pop", "preproc-expr-chain")}, | ||||
| 			{`[0-9]+\.[0-9]+`, LiteralNumberFloat, Push("#pop", "preproc-expr-chain")}, | ||||
| 			{`[0-9]+\.(?!(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)|\.\.)`, LiteralNumberFloat, Push("#pop", "preproc-expr-chain")}, | ||||
| 			{`0x[0-9a-fA-F]+`, LiteralNumberHex, Push("#pop", "preproc-expr-chain")}, | ||||
| 			{`[0-9]+`, LiteralNumberInteger, Push("#pop", "preproc-expr-chain")}, | ||||
| 			{`'`, LiteralStringSingle, Push("#pop", "preproc-expr-chain", "string-single")}, | ||||
| 			{`"`, LiteralStringDouble, Push("#pop", "preproc-expr-chain", "string-double")}, | ||||
| 		}, | ||||
| 		"abstract": { | ||||
| 			Include("spaces"), | ||||
| 			Default(Pop(1), Push("abstract-body"), Push("abstract-relation"), Push("abstract-opaque"), Push("type-param-constraint"), Push("type-name")), | ||||
| 		}, | ||||
| 		"abstract-body": { | ||||
| 			Include("spaces"), | ||||
| 			{`\{`, Punctuation, Push("#pop", "class-body")}, | ||||
| 		}, | ||||
| 		"abstract-opaque": { | ||||
| 			Include("spaces"), | ||||
| 			{`\(`, Punctuation, Push("#pop", "parenthesis-close", "type")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"abstract-relation": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?:to|from)`, KeywordDeclaration, Push("type")}, | ||||
| 			{`,`, Punctuation, nil}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"meta": { | ||||
| 			Include("spaces"), | ||||
| 			{`@`, NameDecorator, Push("meta-body", "meta-ident", "meta-colon")}, | ||||
| 		}, | ||||
| 		"meta-colon": { | ||||
| 			Include("spaces"), | ||||
| 			{`:`, NameDecorator, Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"meta-ident": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, NameDecorator, Pop(1)}, | ||||
| 		}, | ||||
| 		"meta-body": { | ||||
| 			Include("spaces"), | ||||
| 			{`\(`, NameDecorator, Push("#pop", "meta-call")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"meta-call": { | ||||
| 			Include("spaces"), | ||||
| 			{`\)`, NameDecorator, Pop(1)}, | ||||
| 			Default(Pop(1), Push("meta-call-sep"), Push("expr")), | ||||
| 		}, | ||||
| 		"meta-call-sep": { | ||||
| 			Include("spaces"), | ||||
| 			{`\)`, NameDecorator, Pop(1)}, | ||||
| 			{`,`, Punctuation, Push("#pop", "meta-call")}, | ||||
| 		}, | ||||
| 		"typedef": { | ||||
| 			Include("spaces"), | ||||
| 			Default(Pop(1), Push("typedef-body"), Push("type-param-constraint"), Push("type-name")), | ||||
| 		}, | ||||
| 		"typedef-body": { | ||||
| 			Include("spaces"), | ||||
| 			{`=`, Operator, Push("#pop", "optional-semicolon", "type")}, | ||||
| 		}, | ||||
| 		"enum": { | ||||
| 			Include("spaces"), | ||||
| 			Default(Pop(1), Push("enum-body"), Push("bracket-open"), Push("type-param-constraint"), Push("type-name")), | ||||
| 		}, | ||||
| 		"enum-body": { | ||||
| 			Include("spaces"), | ||||
| 			Include("meta"), | ||||
| 			{`\}`, Punctuation, Pop(1)}, | ||||
| 			{`(?!(?:function|class|static|var|if|else|while|do|for|break|return|continue|extends|implements|import|switch|case|default|public|private|try|untyped|catch|new|this|throw|extern|enum|in|interface|cast|override|dynamic|typedef|package|inline|using|null|true|false|abstract)\b)(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, Name, Push("enum-member", "type-param-constraint")}, | ||||
| 		}, | ||||
| 		"enum-member": { | ||||
| 			Include("spaces"), | ||||
| 			{`\(`, Punctuation, Push("#pop", "semicolon", "flag", "function-param")}, | ||||
| 			Default(Pop(1), Push("semicolon"), Push("flag")), | ||||
| 		}, | ||||
| 		"class": { | ||||
| 			Include("spaces"), | ||||
| 			Default(Pop(1), Push("class-body"), Push("bracket-open"), Push("extends"), Push("type-param-constraint"), Push("type-name")), | ||||
| 		}, | ||||
| 		"extends": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?:extends|implements)\b`, KeywordDeclaration, Push("type")}, | ||||
| 			{`,`, Punctuation, nil}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"bracket-open": { | ||||
| 			Include("spaces"), | ||||
| 			{`\{`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"bracket-close": { | ||||
| 			Include("spaces"), | ||||
| 			{`\}`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"class-body": { | ||||
| 			Include("spaces"), | ||||
| 			Include("meta"), | ||||
| 			{`\}`, Punctuation, Pop(1)}, | ||||
| 			{`(?:static|public|private|override|dynamic|inline|macro)\b`, KeywordDeclaration, nil}, | ||||
| 			Default(Push("class-member")), | ||||
| 		}, | ||||
| 		"class-member": { | ||||
| 			Include("spaces"), | ||||
| 			{`(var)\b`, KeywordDeclaration, Push("#pop", "optional-semicolon", "var")}, | ||||
| 			{`(function)\b`, KeywordDeclaration, Push("#pop", "optional-semicolon", "class-method")}, | ||||
| 		}, | ||||
| 		"function-local": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?!(?:function|class|static|var|if|else|while|do|for|break|return|continue|extends|implements|import|switch|case|default|public|private|try|untyped|catch|new|this|throw|extern|enum|in|interface|cast|override|dynamic|typedef|package|inline|using|null|true|false|abstract)\b)(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, NameFunction, Push("#pop", "optional-expr", "flag", "function-param", "parenthesis-open", "type-param-constraint")}, | ||||
| 			Default(Pop(1), Push("optional-expr"), Push("flag"), Push("function-param"), Push("parenthesis-open"), Push("type-param-constraint")), | ||||
| 		}, | ||||
| 		"optional-expr": { | ||||
| 			Include("spaces"), | ||||
| 			Include("expr"), | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"class-method": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, NameFunction, Push("#pop", "optional-expr", "flag", "function-param", "parenthesis-open", "type-param-constraint")}, | ||||
| 		}, | ||||
| 		"function-param": { | ||||
| 			Include("spaces"), | ||||
| 			{`\)`, Punctuation, Pop(1)}, | ||||
| 			{`\?`, Punctuation, nil}, | ||||
| 			{`(?!(?:function|class|static|var|if|else|while|do|for|break|return|continue|extends|implements|import|switch|case|default|public|private|try|untyped|catch|new|this|throw|extern|enum|in|interface|cast|override|dynamic|typedef|package|inline|using|null|true|false|abstract)\b)(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, Name, Push("#pop", "function-param-sep", "assign", "flag")}, | ||||
| 		}, | ||||
| 		"function-param-sep": { | ||||
| 			Include("spaces"), | ||||
| 			{`\)`, Punctuation, Pop(1)}, | ||||
| 			{`,`, Punctuation, Push("#pop", "function-param")}, | ||||
| 		}, | ||||
| 		"prop-get-set": { | ||||
| 			Include("spaces"), | ||||
| 			{`\(`, Punctuation, Push("#pop", "parenthesis-close", "prop-get-set-opt", "comma", "prop-get-set-opt")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"prop-get-set-opt": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?:default|null|never|dynamic|get|set)\b`, Keyword, Pop(1)}, | ||||
| 			{`(?!(?:function|class|static|var|if|else|while|do|for|break|return|continue|extends|implements|import|switch|case|default|public|private|try|untyped|catch|new|this|throw|extern|enum|in|interface|cast|override|dynamic|typedef|package|inline|using|null|true|false|abstract)\b)(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, Text, Pop(1)}, | ||||
| 		}, | ||||
| 		"expr-statement": { | ||||
| 			Include("spaces"), | ||||
| 			Default(Pop(1), Push("optional-semicolon"), Push("expr")), | ||||
| 		}, | ||||
| 		"expr": { | ||||
| 			Include("spaces"), | ||||
| 			{`@`, NameDecorator, Push("#pop", "optional-expr", "meta-body", "meta-ident", "meta-colon")}, | ||||
| 			{`(?:\+\+|\-\-|~(?!/)|!|\-)`, Operator, nil}, | ||||
| 			{`\(`, Punctuation, Push("#pop", "expr-chain", "parenthesis")}, | ||||
| 			{`(?:static|public|private|override|dynamic|inline)\b`, KeywordDeclaration, nil}, | ||||
| 			{`(?:function)\b`, KeywordDeclaration, Push("#pop", "expr-chain", "function-local")}, | ||||
| 			{`\{`, Punctuation, Push("#pop", "expr-chain", "bracket")}, | ||||
| 			{`(?:true|false|null)\b`, KeywordConstant, Push("#pop", "expr-chain")}, | ||||
| 			{`(?:this)\b`, Keyword, Push("#pop", "expr-chain")}, | ||||
| 			{`(?:cast)\b`, Keyword, Push("#pop", "expr-chain", "cast")}, | ||||
| 			{`(?:try)\b`, Keyword, Push("#pop", "catch", "expr")}, | ||||
| 			{`(?:var)\b`, KeywordDeclaration, Push("#pop", "var")}, | ||||
| 			{`(?:new)\b`, Keyword, Push("#pop", "expr-chain", "new")}, | ||||
| 			{`(?:switch)\b`, Keyword, Push("#pop", "switch")}, | ||||
| 			{`(?:if)\b`, Keyword, Push("#pop", "if")}, | ||||
| 			{`(?:do)\b`, Keyword, Push("#pop", "do")}, | ||||
| 			{`(?:while)\b`, Keyword, Push("#pop", "while")}, | ||||
| 			{`(?:for)\b`, Keyword, Push("#pop", "for")}, | ||||
| 			{`(?:untyped|throw)\b`, Keyword, nil}, | ||||
| 			{`(?:return)\b`, Keyword, Push("#pop", "optional-expr")}, | ||||
| 			{`(?:macro)\b`, Keyword, Push("#pop", "macro")}, | ||||
| 			{`(?:continue|break)\b`, Keyword, Pop(1)}, | ||||
| 			{`(?:\$\s*[a-z]\b|\$(?!(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)))`, Name, Push("#pop", "dollar")}, | ||||
| 			{`(?!(?:function|class|static|var|if|else|while|do|for|break|return|continue|extends|implements|import|switch|case|default|public|private|try|untyped|catch|new|this|throw|extern|enum|in|interface|cast|override|dynamic|typedef|package|inline|using|null|true|false|abstract)\b)(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, Name, Push("#pop", "expr-chain")}, | ||||
| 			{`\.[0-9]+`, LiteralNumberFloat, Push("#pop", "expr-chain")}, | ||||
| 			{`[0-9]+[eE][+\-]?[0-9]+`, LiteralNumberFloat, Push("#pop", "expr-chain")}, | ||||
| 			{`[0-9]+\.[0-9]*[eE][+\-]?[0-9]+`, LiteralNumberFloat, Push("#pop", "expr-chain")}, | ||||
| 			{`[0-9]+\.[0-9]+`, LiteralNumberFloat, Push("#pop", "expr-chain")}, | ||||
| 			{`[0-9]+\.(?!(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)|\.\.)`, LiteralNumberFloat, Push("#pop", "expr-chain")}, | ||||
| 			{`0x[0-9a-fA-F]+`, LiteralNumberHex, Push("#pop", "expr-chain")}, | ||||
| 			{`[0-9]+`, LiteralNumberInteger, Push("#pop", "expr-chain")}, | ||||
| 			{`'`, LiteralStringSingle, Push("#pop", "expr-chain", "string-single-interpol")}, | ||||
| 			{`"`, LiteralStringDouble, Push("#pop", "expr-chain", "string-double")}, | ||||
| 			{`~/(\\\\|\\/|[^/\n])*/[gimsu]*`, LiteralStringRegex, Push("#pop", "expr-chain")}, | ||||
| 			{`\[`, Punctuation, Push("#pop", "expr-chain", "array-decl")}, | ||||
| 		}, | ||||
| 		"expr-chain": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?:\+\+|\-\-)`, Operator, nil}, | ||||
| 			{`(?:%=|&=|\|=|\^=|\+=|\-=|\*=|/=|<<=|>\s*>\s*=|>\s*>\s*>\s*=|==|!=|<=|>\s*=|&&|\|\||<<|>>>|>\s*>|\.\.\.|<|>|%|&|\||\^|\+|\*|/|\-|=>|=)`, Operator, Push("#pop", "expr")}, | ||||
| 			{`(?:in)\b`, Keyword, Push("#pop", "expr")}, | ||||
| 			{`\?`, Operator, Push("#pop", "expr", "ternary", "expr")}, | ||||
| 			{`(\.)((?!(?:function|class|static|var|if|else|while|do|for|break|return|continue|extends|implements|import|switch|case|default|public|private|try|untyped|catch|new|this|throw|extern|enum|in|interface|cast|override|dynamic|typedef|package|inline|using|null|true|false|abstract)\b)(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+))`, ByGroups(Punctuation, Name), nil}, | ||||
| 			{`\[`, Punctuation, Push("array-access")}, | ||||
| 			{`\(`, Punctuation, Push("call")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"macro": { | ||||
| 			Include("spaces"), | ||||
| 			Include("meta"), | ||||
| 			{`:`, Punctuation, Push("#pop", "type")}, | ||||
| 			{`(?:extern|private)\b`, KeywordDeclaration, nil}, | ||||
| 			{`(?:abstract)\b`, KeywordDeclaration, Push("#pop", "optional-semicolon", "abstract")}, | ||||
| 			{`(?:class|interface)\b`, KeywordDeclaration, Push("#pop", "optional-semicolon", "macro-class")}, | ||||
| 			{`(?:enum)\b`, KeywordDeclaration, Push("#pop", "optional-semicolon", "enum")}, | ||||
| 			{`(?:typedef)\b`, KeywordDeclaration, Push("#pop", "optional-semicolon", "typedef")}, | ||||
| 			Default(Pop(1), Push("expr")), | ||||
| 		}, | ||||
| 		"macro-class": { | ||||
| 			{`\{`, Punctuation, Push("#pop", "class-body")}, | ||||
| 			Include("class"), | ||||
| 		}, | ||||
| 		"cast": { | ||||
| 			Include("spaces"), | ||||
| 			{`\(`, Punctuation, Push("#pop", "parenthesis-close", "cast-type", "expr")}, | ||||
| 			Default(Pop(1), Push("expr")), | ||||
| 		}, | ||||
| 		"cast-type": { | ||||
| 			Include("spaces"), | ||||
| 			{`,`, Punctuation, Push("#pop", "type")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"catch": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?:catch)\b`, Keyword, Push("expr", "function-param", "parenthesis-open")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"do": { | ||||
| 			Include("spaces"), | ||||
| 			Default(Pop(1), Push("do-while"), Push("expr")), | ||||
| 		}, | ||||
| 		"do-while": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?:while)\b`, Keyword, Push("#pop", "parenthesis", "parenthesis-open")}, | ||||
| 		}, | ||||
| 		"while": { | ||||
| 			Include("spaces"), | ||||
| 			{`\(`, Punctuation, Push("#pop", "expr", "parenthesis")}, | ||||
| 		}, | ||||
| 		"for": { | ||||
| 			Include("spaces"), | ||||
| 			{`\(`, Punctuation, Push("#pop", "expr", "parenthesis")}, | ||||
| 		}, | ||||
| 		"if": { | ||||
| 			Include("spaces"), | ||||
| 			{`\(`, Punctuation, Push("#pop", "else", "optional-semicolon", "expr", "parenthesis")}, | ||||
| 		}, | ||||
| 		"else": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?:else)\b`, Keyword, Push("#pop", "expr")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"switch": { | ||||
| 			Include("spaces"), | ||||
| 			Default(Pop(1), Push("switch-body"), Push("bracket-open"), Push("expr")), | ||||
| 		}, | ||||
| 		"switch-body": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?:case|default)\b`, Keyword, Push("case-block", "case")}, | ||||
| 			{`\}`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"case": { | ||||
| 			Include("spaces"), | ||||
| 			{`:`, Punctuation, Pop(1)}, | ||||
| 			Default(Pop(1), Push("case-sep"), Push("case-guard"), Push("expr")), | ||||
| 		}, | ||||
| 		"case-sep": { | ||||
| 			Include("spaces"), | ||||
| 			{`:`, Punctuation, Pop(1)}, | ||||
| 			{`,`, Punctuation, Push("#pop", "case")}, | ||||
| 		}, | ||||
| 		"case-guard": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?:if)\b`, Keyword, Push("#pop", "parenthesis", "parenthesis-open")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"case-block": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?!(?:case|default)\b|\})`, Keyword, Push("expr-statement")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"new": { | ||||
| 			Include("spaces"), | ||||
| 			Default(Pop(1), Push("call"), Push("parenthesis-open"), Push("type")), | ||||
| 		}, | ||||
| 		"array-decl": { | ||||
| 			Include("spaces"), | ||||
| 			{`\]`, Punctuation, Pop(1)}, | ||||
| 			Default(Pop(1), Push("array-decl-sep"), Push("expr")), | ||||
| 		}, | ||||
| 		"array-decl-sep": { | ||||
| 			Include("spaces"), | ||||
| 			{`\]`, Punctuation, Pop(1)}, | ||||
| 			{`,`, Punctuation, Push("#pop", "array-decl")}, | ||||
| 		}, | ||||
| 		"array-access": { | ||||
| 			Include("spaces"), | ||||
| 			Default(Pop(1), Push("array-access-close"), Push("expr")), | ||||
| 		}, | ||||
| 		"array-access-close": { | ||||
| 			Include("spaces"), | ||||
| 			{`\]`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"comma": { | ||||
| 			Include("spaces"), | ||||
| 			{`,`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"colon": { | ||||
| 			Include("spaces"), | ||||
| 			{`:`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"semicolon": { | ||||
| 			Include("spaces"), | ||||
| 			{`;`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"optional-semicolon": { | ||||
| 			Include("spaces"), | ||||
| 			{`;`, Punctuation, Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"ident": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, Name, Pop(1)}, | ||||
| 		}, | ||||
| 		"dollar": { | ||||
| 			Include("spaces"), | ||||
| 			{`\{`, Punctuation, Push("#pop", "expr-chain", "bracket-close", "expr")}, | ||||
| 			Default(Pop(1), Push("expr-chain")), | ||||
| 		}, | ||||
| 		"type-name": { | ||||
| 			Include("spaces"), | ||||
| 			{`_*[A-Z]\w*`, Name, Pop(1)}, | ||||
| 		}, | ||||
| 		"type-full-name": { | ||||
| 			Include("spaces"), | ||||
| 			{`\.`, Punctuation, Push("ident")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"type": { | ||||
| 			Include("spaces"), | ||||
| 			{`\?`, Punctuation, nil}, | ||||
| 			{`(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, Name, Push("#pop", "type-check", "type-full-name")}, | ||||
| 			{`\{`, Punctuation, Push("#pop", "type-check", "type-struct")}, | ||||
| 			{`\(`, Punctuation, Push("#pop", "type-check", "type-parenthesis")}, | ||||
| 		}, | ||||
| 		"type-parenthesis": { | ||||
| 			Include("spaces"), | ||||
| 			Default(Pop(1), Push("parenthesis-close"), Push("type")), | ||||
| 		}, | ||||
| 		"type-check": { | ||||
| 			Include("spaces"), | ||||
| 			{`->`, Punctuation, Push("#pop", "type")}, | ||||
| 			{`<(?!=)`, Punctuation, Push("type-param")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"type-struct": { | ||||
| 			Include("spaces"), | ||||
| 			{`\}`, Punctuation, Pop(1)}, | ||||
| 			{`\?`, Punctuation, nil}, | ||||
| 			{`>`, Punctuation, Push("comma", "type")}, | ||||
| 			{`(?!(?:function|class|static|var|if|else|while|do|for|break|return|continue|extends|implements|import|switch|case|default|public|private|try|untyped|catch|new|this|throw|extern|enum|in|interface|cast|override|dynamic|typedef|package|inline|using|null|true|false|abstract)\b)(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, Name, Push("#pop", "type-struct-sep", "type", "colon")}, | ||||
| 			Include("class-body"), | ||||
| 		}, | ||||
| 		"type-struct-sep": { | ||||
| 			Include("spaces"), | ||||
| 			{`\}`, Punctuation, Pop(1)}, | ||||
| 			{`,`, Punctuation, Push("#pop", "type-struct")}, | ||||
| 		}, | ||||
| 		"type-param-type": { | ||||
| 			{`\.[0-9]+`, LiteralNumberFloat, Pop(1)}, | ||||
| 			{`[0-9]+[eE][+\-]?[0-9]+`, LiteralNumberFloat, Pop(1)}, | ||||
| 			{`[0-9]+\.[0-9]*[eE][+\-]?[0-9]+`, LiteralNumberFloat, Pop(1)}, | ||||
| 			{`[0-9]+\.[0-9]+`, LiteralNumberFloat, Pop(1)}, | ||||
| 			{`[0-9]+\.(?!(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)|\.\.)`, LiteralNumberFloat, Pop(1)}, | ||||
| 			{`0x[0-9a-fA-F]+`, LiteralNumberHex, Pop(1)}, | ||||
| 			{`[0-9]+`, LiteralNumberInteger, Pop(1)}, | ||||
| 			{`'`, LiteralStringSingle, Push("#pop", "string-single")}, | ||||
| 			{`"`, LiteralStringDouble, Push("#pop", "string-double")}, | ||||
| 			{`~/(\\\\|\\/|[^/\n])*/[gim]*`, LiteralStringRegex, Pop(1)}, | ||||
| 			{`\[`, Operator, Push("#pop", "array-decl")}, | ||||
| 			Include("type"), | ||||
| 		}, | ||||
| 		"type-param": { | ||||
| 			Include("spaces"), | ||||
| 			Default(Pop(1), Push("type-param-sep"), Push("type-param-type")), | ||||
| 		}, | ||||
| 		"type-param-sep": { | ||||
| 			Include("spaces"), | ||||
| 			{`>`, Punctuation, Pop(1)}, | ||||
| 			{`,`, Punctuation, Push("#pop", "type-param")}, | ||||
| 		}, | ||||
| 		"type-param-constraint": { | ||||
| 			Include("spaces"), | ||||
| 			{`<(?!=)`, Punctuation, Push("#pop", "type-param-constraint-sep", "type-param-constraint-flag", "type-name")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"type-param-constraint-sep": { | ||||
| 			Include("spaces"), | ||||
| 			{`>`, Punctuation, Pop(1)}, | ||||
| 			{`,`, Punctuation, Push("#pop", "type-param-constraint-sep", "type-param-constraint-flag", "type-name")}, | ||||
| 		}, | ||||
| 		"type-param-constraint-flag": { | ||||
| 			Include("spaces"), | ||||
| 			{`:`, Punctuation, Push("#pop", "type-param-constraint-flag-type")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"type-param-constraint-flag-type": { | ||||
| 			Include("spaces"), | ||||
| 			{`\(`, Punctuation, Push("#pop", "type-param-constraint-flag-type-sep", "type")}, | ||||
| 			Default(Pop(1), Push("type")), | ||||
| 		}, | ||||
| 		"type-param-constraint-flag-type-sep": { | ||||
| 			Include("spaces"), | ||||
| 			{`\)`, Punctuation, Pop(1)}, | ||||
| 			{`,`, Punctuation, Push("type")}, | ||||
| 		}, | ||||
| 		"parenthesis": { | ||||
| 			Include("spaces"), | ||||
| 			Default(Pop(1), Push("parenthesis-close"), Push("flag"), Push("expr")), | ||||
| 		}, | ||||
| 		"parenthesis-open": { | ||||
| 			Include("spaces"), | ||||
| 			{`\(`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"parenthesis-close": { | ||||
| 			Include("spaces"), | ||||
| 			{`\)`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"var": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?!(?:function|class|static|var|if|else|while|do|for|break|return|continue|extends|implements|import|switch|case|default|public|private|try|untyped|catch|new|this|throw|extern|enum|in|interface|cast|override|dynamic|typedef|package|inline|using|null|true|false|abstract)\b)(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, Text, Push("#pop", "var-sep", "assign", "flag", "prop-get-set")}, | ||||
| 		}, | ||||
| 		"var-sep": { | ||||
| 			Include("spaces"), | ||||
| 			{`,`, Punctuation, Push("#pop", "var")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"assign": { | ||||
| 			Include("spaces"), | ||||
| 			{`=`, Operator, Push("#pop", "expr")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"flag": { | ||||
| 			Include("spaces"), | ||||
| 			{`:`, Punctuation, Push("#pop", "type")}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"ternary": { | ||||
| 			Include("spaces"), | ||||
| 			{`:`, Operator, Pop(1)}, | ||||
| 		}, | ||||
| 		"call": { | ||||
| 			Include("spaces"), | ||||
| 			{`\)`, Punctuation, Pop(1)}, | ||||
| 			Default(Pop(1), Push("call-sep"), Push("expr")), | ||||
| 		}, | ||||
| 		"call-sep": { | ||||
| 			Include("spaces"), | ||||
| 			{`\)`, Punctuation, Pop(1)}, | ||||
| 			{`,`, Punctuation, Push("#pop", "call")}, | ||||
| 		}, | ||||
| 		"bracket": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?!(?:\$\s*[a-z]\b|\$(?!(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+))))(?!(?:function|class|static|var|if|else|while|do|for|break|return|continue|extends|implements|import|switch|case|default|public|private|try|untyped|catch|new|this|throw|extern|enum|in|interface|cast|override|dynamic|typedef|package|inline|using|null|true|false|abstract)\b)(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, Name, Push("#pop", "bracket-check")}, | ||||
| 			{`'`, LiteralStringSingle, Push("#pop", "bracket-check", "string-single")}, | ||||
| 			{`"`, LiteralStringDouble, Push("#pop", "bracket-check", "string-double")}, | ||||
| 			Default(Pop(1), Push("block")), | ||||
| 		}, | ||||
| 		"bracket-check": { | ||||
| 			Include("spaces"), | ||||
| 			{`:`, Punctuation, Push("#pop", "object-sep", "expr")}, | ||||
| 			Default(Pop(1), Push("block"), Push("optional-semicolon"), Push("expr-chain")), | ||||
| 		}, | ||||
| 		"block": { | ||||
| 			Include("spaces"), | ||||
| 			{`\}`, Punctuation, Pop(1)}, | ||||
| 			Default(Push("expr-statement")), | ||||
| 		}, | ||||
| 		"object": { | ||||
| 			Include("spaces"), | ||||
| 			{`\}`, Punctuation, Pop(1)}, | ||||
| 			Default(Pop(1), Push("object-sep"), Push("expr"), Push("colon"), Push("ident-or-string")), | ||||
| 		}, | ||||
| 		"ident-or-string": { | ||||
| 			Include("spaces"), | ||||
| 			{`(?!(?:function|class|static|var|if|else|while|do|for|break|return|continue|extends|implements|import|switch|case|default|public|private|try|untyped|catch|new|this|throw|extern|enum|in|interface|cast|override|dynamic|typedef|package|inline|using|null|true|false|abstract)\b)(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+)`, Name, Pop(1)}, | ||||
| 			{`'`, LiteralStringSingle, Push("#pop", "string-single")}, | ||||
| 			{`"`, LiteralStringDouble, Push("#pop", "string-double")}, | ||||
| 		}, | ||||
| 		"object-sep": { | ||||
| 			Include("spaces"), | ||||
| 			{`\}`, Punctuation, Pop(1)}, | ||||
| 			{`,`, Punctuation, Push("#pop", "object")}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
|  | ||||
| func haxePreProcMutator(state *LexerState) error { | ||||
| 	stack, ok := state.Get("haxe-pre-proc").([][]string) | ||||
| 	if !ok { | ||||
| 		stack = [][]string{} | ||||
| 	} | ||||
|  | ||||
| 	proc := state.Groups[2] | ||||
| 	if proc == "if" { | ||||
| 		stack = append(stack, state.Stack) | ||||
| 	} else if proc == "else" || proc == "elseif" { | ||||
| 		if len(stack) > 0 { | ||||
| 			state.Stack = stack[len(stack)-1] | ||||
| 		} | ||||
| 	} else if proc == "end" { | ||||
| 		stack = stack[:len(stack)-1] | ||||
| 	} | ||||
|  | ||||
| 	if proc == "if" || proc == "elseif" { | ||||
| 		state.Stack = append(state.Stack, "preproc-expr") | ||||
| 	} | ||||
|  | ||||
| 	if proc == "error" { | ||||
| 		state.Stack = append(state.Stack, "preproc-error") | ||||
| 	} | ||||
| 	state.Set("haxe-pre-proc", stack) | ||||
| 	return nil | ||||
| } | ||||
| @@ -41,11 +41,11 @@ var HTML = Register(MustNewLexer( | ||||
| 		}, | ||||
| 		"script-content": { | ||||
| 			{`(<)(\s*)(/)(\s*)(script)(\s*)(>)`, ByGroups(Punctuation, Text, Punctuation, Text, NameTag, Text, Punctuation), Pop(1)}, | ||||
| 			{`(.+?)(<\s*/\s*script\s*>)`, Using(JavaScript, nil), Rewind()}, | ||||
| 			{`.+?(?=<\s*/\s*script\s*>)`, Using(Javascript, nil), nil}, | ||||
| 		}, | ||||
| 		"style-content": { | ||||
| 			{`(<)(\s*)(/)(\s*)(style)(\s*)(>)`, ByGroups(Punctuation, Text, Punctuation, Text, NameTag, Text, Punctuation), Pop(1)}, | ||||
| 			{`(.+?)(<\s*/\s*style\s*>)`, Using(CSS, nil), Rewind()}, | ||||
| 			{`.+?(?=<\s*/\s*style\s*>)`, Using(CSS, nil), nil}, | ||||
| 		}, | ||||
| 		"attr": { | ||||
| 			{`".*?"`, LiteralString, Pop(1)}, | ||||
|   | ||||
							
								
								
									
										50
									
								
								lexers/hy.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								lexers/hy.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Hy lexer. | ||||
| var Hy = 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}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										79
									
								
								lexers/idris.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								lexers/idris.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,79 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Idris lexer. | ||||
| var Idris = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Idris", | ||||
| 		Aliases:   []string{"idris", "idr"}, | ||||
| 		Filenames: []string{"*.idr"}, | ||||
| 		MimeTypes: []string{"text/x-idris"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`^(\s*)(%lib|link|flag|include|hide|freeze|access|default|logging|dynamic|name|error_handlers|language)`, ByGroups(Text, KeywordReserved), nil}, | ||||
| 			{`(\s*)(--(?![!#$%&*+./<=>?@^|_~:\\]).*?)$`, ByGroups(Text, CommentSingle), nil}, | ||||
| 			{`(\s*)(\|{3}.*?)$`, ByGroups(Text, CommentSingle), nil}, | ||||
| 			{`(\s*)(\{-)`, ByGroups(Text, CommentMultiline), Push("comment")}, | ||||
| 			{`^(\s*)([^\s(){}]+)(\s*)(:)(\s*)`, ByGroups(Text, NameFunction, Text, OperatorWord, Text), nil}, | ||||
| 			{`\b(case|class|data|default|using|do|else|if|in|infix[lr]?|instance|rewrite|auto|namespace|codata|mutual|private|public|abstract|total|partial|let|proof|of|then|static|where|_|with|pattern|term|syntax|prefix|postulate|parameters|record|dsl|impossible|implicit|tactics|intros|intro|compute|refine|exact|trivial)(?!\')\b`, KeywordReserved, nil}, | ||||
| 			{`(import|module)(\s+)`, ByGroups(KeywordReserved, Text), Push("module")}, | ||||
| 			{`('')?[A-Z][\w\']*`, KeywordType, nil}, | ||||
| 			{`[a-z][\w\']*`, Text, nil}, | ||||
| 			{`(<-|::|->|=>|=)`, OperatorWord, nil}, | ||||
| 			{`([(){}\[\]:!#$%&*+.\\/<=>?@^|~-]+)`, OperatorWord, nil}, | ||||
| 			{`\d+[eE][+-]?\d+`, LiteralNumberFloat, nil}, | ||||
| 			{`\d+\.\d+([eE][+-]?\d+)?`, LiteralNumberFloat, nil}, | ||||
| 			{`0[xX][\da-fA-F]+`, LiteralNumberHex, nil}, | ||||
| 			{`\d+`, LiteralNumberInteger, nil}, | ||||
| 			{`'`, LiteralStringChar, Push("character")}, | ||||
| 			{`"`, LiteralString, Push("string")}, | ||||
| 			{`[^\s(){}]+`, Text, nil}, | ||||
| 			{`\s+?`, Text, nil}, | ||||
| 		}, | ||||
| 		"module": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`([A-Z][\w.]*)(\s+)(\()`, ByGroups(NameNamespace, Text, Punctuation), Push("funclist")}, | ||||
| 			{`[A-Z][\w.]*`, NameNamespace, Pop(1)}, | ||||
| 		}, | ||||
| 		"funclist": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`[A-Z]\w*`, KeywordType, nil}, | ||||
| 			{`(_[\w\']+|[a-z][\w\']*)`, 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, nil}, | ||||
| 			{`\\`, LiteralStringEscape, Push("escape")}, | ||||
| 			{`'`, LiteralStringChar, Pop(1)}, | ||||
| 		}, | ||||
| 		"string": { | ||||
| 			{`[^\\"]+`, LiteralString, nil}, | ||||
| 			{`\\`, LiteralStringEscape, Push("escape")}, | ||||
| 			{`"`, LiteralString, Pop(1)}, | ||||
| 		}, | ||||
| 		"escape": { | ||||
| 			{`[abfnrtv"\'&\\]`, LiteralStringEscape, Pop(1)}, | ||||
| 			{`\^[][A-Z@^_]`, 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)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
| @@ -4,20 +4,20 @@ import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| var INI = Register(MustNewLexer( | ||||
| // Ini lexer. | ||||
| var Ini = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "INI", | ||||
| 		Aliases:   []string{"ini", "cfg", "dosini"}, | ||||
| 		Filenames: []string{"*.ini", "*.cfg", "*.inf"}, | ||||
| 		MimeTypes: []string{"text/x-ini", "text/inf"}, | ||||
| 	}, | ||||
| 	map[string][]Rule{ | ||||
| 		"root": []Rule{ | ||||
| 			{`\s+`, Whitespace, nil}, | ||||
| 			{`;.*?$`, Comment, nil}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`[;#].*`, CommentSingle, nil}, | ||||
| 			{`\[.*?\]$`, Keyword, nil}, | ||||
| 			{`(.*?)(\s*)(=)(\s*)(.*?)$`, ByGroups(Name, Whitespace, Operator, Whitespace, String), nil}, | ||||
| 			// standalone option, supported by some INI parsers | ||||
| 			{`(.*?)([ \t]*)(=)([ \t]*)(.*(?:\n[ \t].+)*)`, ByGroups(NameAttribute, Text, Operator, Text, LiteralString), nil}, | ||||
| 			{`(.+?)$`, NameAttribute, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
|   | ||||
							
								
								
									
										39
									
								
								lexers/io.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								lexers/io.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Io lexer. | ||||
| var Io = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Io", | ||||
| 		Aliases:   []string{"io"}, | ||||
| 		Filenames: []string{"*.io"}, | ||||
| 		MimeTypes: []string{"text/x-iosrc"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\n`, Text, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`//(.*?)\n`, CommentSingle, nil}, | ||||
| 			{`#(.*?)\n`, CommentSingle, nil}, | ||||
| 			{`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil}, | ||||
| 			{`/\+`, CommentMultiline, Push("nestedcomment")}, | ||||
| 			{`"(\\\\|\\"|[^"])*"`, LiteralString, nil}, | ||||
| 			{`::=|:=|=|\(|\)|;|,|\*|-|\+|>|<|@|!|/|\||\^|\.|%|&|\[|\]|\{|\}`, Operator, nil}, | ||||
| 			{`(clone|do|doFile|doString|method|for|if|else|elseif|then)\b`, Keyword, nil}, | ||||
| 			{`(nil|false|true)\b`, NameConstant, nil}, | ||||
| 			{`(Object|list|List|Map|args|Sequence|Coroutine|File)\b`, NameBuiltin, nil}, | ||||
| 			{`[a-zA-Z_]\w*`, Name, nil}, | ||||
| 			{`(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?`, LiteralNumberFloat, nil}, | ||||
| 			{`\d+`, LiteralNumberInteger, nil}, | ||||
| 		}, | ||||
| 		"nestedcomment": { | ||||
| 			{`[^+/]+`, CommentMultiline, nil}, | ||||
| 			{`/\+`, CommentMultiline, Push()}, | ||||
| 			{`\+/`, CommentMultiline, Pop(1)}, | ||||
| 			{`[+/]`, CommentMultiline, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
| @@ -1,50 +1,50 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
|     . "github.com/alecthomas/chroma" // nolint | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Java lexer. | ||||
| var Java = Register(MustNewLexer( | ||||
|     &Config{ | ||||
|         Name:      "Java", | ||||
|         Aliases:   []string{"java"}, | ||||
|         Filenames: []string{"*.java"}, | ||||
|         MimeTypes: []string{"text/x-java"}, | ||||
|         DotAll:    true, | ||||
|     }, | ||||
|     Rules{ | ||||
|         "root": { | ||||
|             {`[^\S\n]+`, Text, nil}, | ||||
|             {`//.*?\n`, CommentSingle, nil}, | ||||
|             {`/\*.*?\*/`, CommentMultiline, nil}, | ||||
|             {`(assert|break|case|catch|continue|default|do|else|finally|for|if|goto|instanceof|new|return|switch|this|throw|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}, | ||||
|             {`(abstract|const|enum|extends|final|implements|native|private|protected|public|static|strictfp|super|synchronized|throws|transient|volatile)\b`, KeywordDeclaration, nil}, | ||||
|             {`(boolean|byte|char|double|float|int|long|short|void)\b`, KeywordType, nil}, | ||||
|             {`(package)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")}, | ||||
|             {`(true|false|null)\b`, KeywordConstant, nil}, | ||||
|             {`(class|interface)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("class")}, | ||||
|             {`(import(?:\s+static)?)(\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}, | ||||
|             {`([0-9][0-9_]*\.([0-9][0-9_]*)?|\.[0-9][0-9_]*)([eE][+\-]?[0-9][0-9_]*)?[fFdD]?|[0-9][eE][+\-]?[0-9][0-9_]*[fFdD]?|[0-9]([eE][+\-]?[0-9][0-9_]*)?[fFdD]|0[xX]([0-9a-fA-F][0-9a-fA-F_]*\.?|([0-9a-fA-F][0-9a-fA-F_]*)?\.[0-9a-fA-F][0-9a-fA-F_]*)[pP][+\-]?[0-9][0-9_]*[fFdD]?`, 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}, | ||||
|         }, | ||||
|         "class": { | ||||
|             {`([^\W\d]|\$)[\w$]*`, NameClass, Pop(1)}, | ||||
|         }, | ||||
|         "import": { | ||||
|             {`[\w.]+\*?`, NameNamespace, Pop(1)}, | ||||
|         }, | ||||
|     }, | ||||
| 	&Config{ | ||||
| 		Name:      "Java", | ||||
| 		Aliases:   []string{"java"}, | ||||
| 		Filenames: []string{"*.java"}, | ||||
| 		MimeTypes: []string{"text/x-java"}, | ||||
| 		DotAll:    true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`[^\S\n]+`, Text, nil}, | ||||
| 			{`//.*?\n`, CommentSingle, nil}, | ||||
| 			{`/\*.*?\*/`, CommentMultiline, nil}, | ||||
| 			{`(assert|break|case|catch|continue|default|do|else|finally|for|if|goto|instanceof|new|return|switch|this|throw|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}, | ||||
| 			{`(abstract|const|enum|extends|final|implements|native|private|protected|public|static|strictfp|super|synchronized|throws|transient|volatile)\b`, KeywordDeclaration, nil}, | ||||
| 			{`(boolean|byte|char|double|float|int|long|short|void)\b`, KeywordType, nil}, | ||||
| 			{`(package)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")}, | ||||
| 			{`(true|false|null)\b`, KeywordConstant, nil}, | ||||
| 			{`(class|interface)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("class")}, | ||||
| 			{`(import(?:\s+static)?)(\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}, | ||||
| 			{`([0-9][0-9_]*\.([0-9][0-9_]*)?|\.[0-9][0-9_]*)([eE][+\-]?[0-9][0-9_]*)?[fFdD]?|[0-9][eE][+\-]?[0-9][0-9_]*[fFdD]?|[0-9]([eE][+\-]?[0-9][0-9_]*)?[fFdD]|0[xX]([0-9a-fA-F][0-9a-fA-F_]*\.?|([0-9a-fA-F][0-9a-fA-F_]*)?\.[0-9a-fA-F][0-9a-fA-F_]*)[pP][+\-]?[0-9][0-9_]*[fFdD]?`, 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}, | ||||
| 		}, | ||||
| 		"class": { | ||||
| 			{`([^\W\d]|\$)[\w$]*`, NameClass, Pop(1)}, | ||||
| 		}, | ||||
| 		"import": { | ||||
| 			{`[\w.]+\*?`, NameNamespace, Pop(1)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
|   | ||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										54
									
								
								lexers/json.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								lexers/json.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,54 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Json lexer. | ||||
| var Json = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:         "JSON", | ||||
| 		Aliases:      []string{"json"}, | ||||
| 		Filenames:    []string{"*.json"}, | ||||
| 		MimeTypes:    []string{"application/json"}, | ||||
| 		NotMultiline: true, | ||||
| 		DotAll:       true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"whitespace": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 		}, | ||||
| 		"simplevalue": { | ||||
| 			{`(true|false|null)\b`, KeywordConstant, nil}, | ||||
| 			{`-?(0|[1-9]\d*)(\.\d+[eE](\+|-)?\d+|[eE](\+|-)?\d+|\.\d+)`, LiteralNumberFloat, nil}, | ||||
| 			{`-?(0|[1-9]\d*)`, LiteralNumberInteger, nil}, | ||||
| 			{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil}, | ||||
| 		}, | ||||
| 		"objectattribute": { | ||||
| 			Include("value"), | ||||
| 			{`:`, Punctuation, nil}, | ||||
| 			{`,`, Punctuation, Pop(1)}, | ||||
| 			{`\}`, Punctuation, Pop(2)}, | ||||
| 		}, | ||||
| 		"objectvalue": { | ||||
| 			Include("whitespace"), | ||||
| 			{`"(\\\\|\\"|[^"])*"`, NameTag, Push("objectattribute")}, | ||||
| 			{`\}`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"arrayvalue": { | ||||
| 			Include("whitespace"), | ||||
| 			Include("value"), | ||||
| 			{`,`, Punctuation, nil}, | ||||
| 			{`\]`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"value": { | ||||
| 			Include("whitespace"), | ||||
| 			Include("simplevalue"), | ||||
| 			{`\{`, Punctuation, Push("objectvalue")}, | ||||
| 			{`\[`, Punctuation, Push("arrayvalue")}, | ||||
| 		}, | ||||
| 		"root": { | ||||
| 			Include("value"), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										93
									
								
								lexers/julia.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								lexers/julia.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,93 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Julia lexer. | ||||
| var Julia = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Julia", | ||||
| 		Aliases:   []string{"julia", "jl"}, | ||||
| 		Filenames: []string{"*.jl"}, | ||||
| 		MimeTypes: []string{"text/x-julia", "application/x-julia"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\n`, Text, nil}, | ||||
| 			{`[^\S\n]+`, Text, nil}, | ||||
| 			{`#=`, CommentMultiline, Push("blockcomment")}, | ||||
| 			{`#.*$`, Comment, nil}, | ||||
| 			{`[\[\]{}(),;]`, Punctuation, nil}, | ||||
| 			{`in\b`, KeywordPseudo, nil}, | ||||
| 			{`(true|false)\b`, KeywordConstant, nil}, | ||||
| 			{`(local|global|const)\b`, KeywordDeclaration, nil}, | ||||
| 			{Words(``, `\b`, `function`, `type`, `typealias`, `abstract`, `immutable`, `baremodule`, `begin`, `bitstype`, `break`, `catch`, `ccall`, `continue`, `do`, `else`, `elseif`, `end`, `export`, `finally`, `for`, `if`, `import`, `importall`, `let`, `macro`, `module`, `quote`, `return`, `try`, `using`, `while`), Keyword, nil}, | ||||
| 			{Words(``, `\b`, `ANY`, `ASCIIString`, `AbstractArray`, `AbstractChannel`, `AbstractFloat`, `AbstractMatrix`, `AbstractRNG`, `AbstractSparseArray`, `AbstractSparseMatrix`, `AbstractSparseVector`, `AbstractString`, `AbstractVecOrMat`, `AbstractVector`, `Any`, `ArgumentError`, `Array`, `AssertionError`, `Associative`, `Base64DecodePipe`, `Base64EncodePipe`, `Bidiagonal`, `BigFloat`, `BigInt`, `BitArray`, `BitMatrix`, `BitVector`, `Bool`, `BoundsError`, `Box`, `BufferStream`, `CapturedException`, `CartesianIndex`, `CartesianRange`, `Cchar`, `Cdouble`, `Cfloat`, `Channel`, `Char`, `Cint`, `Cintmax_t`, `Clong`, `Clonglong`, `ClusterManager`, `Cmd`, `Coff_t`, `Colon`, `Complex`, `Complex128`, `Complex32`, `Complex64`, `CompositeException`, `Condition`, `Cptrdiff_t`, `Cshort`, `Csize_t`, `Cssize_t`, `Cstring`, `Cuchar`, `Cuint`, `Cuintmax_t`, `Culong`, `Culonglong`, `Cushort`, `Cwchar_t`, `Cwstring`, `DataType`, `Date`, `DateTime`, `DenseArray`, `DenseMatrix`, `DenseVecOrMat`, `DenseVector`, `Diagonal`, `Dict`, `DimensionMismatch`, `Dims`, `DirectIndexString`, `Display`, `DivideError`, `DomainError`, `EOFError`, `EachLine`, `Enum`, `Enumerate`, `ErrorException`, `Exception`, `Expr`, `Factorization`, `FileMonitor`, `FileOffset`, `Filter`, `Float16`, `Float32`, `Float64`, `FloatRange`, `Function`, `GenSym`, `GlobalRef`, `GotoNode`, `HTML`, `Hermitian`, `IO`, `IOBuffer`, `IOStream`, `IPv4`, `IPv6`, `InexactError`, `InitError`, `Int`, `Int128`, `Int16`, `Int32`, `Int64`, `Int8`, `IntSet`, `Integer`, `InterruptException`, `IntrinsicFunction`, `InvalidStateException`, `Irrational`, `KeyError`, `LabelNode`, `LambdaStaticData`, `LinSpace`, `LineNumberNode`, `LoadError`, `LocalProcess`, `LowerTriangular`, `MIME`, `Matrix`, `MersenneTwister`, `Method`, `MethodError`, `MethodTable`, `Module`, `NTuple`, `NewvarNode`, `NullException`, `Nullable`, `Number`, `ObjectIdDict`, `OrdinalRange`, `OutOfMemoryError`, `OverflowError`, `Pair`, `ParseError`, `PartialQuickSort`, `Pipe`, `PollingFileWatcher`, `ProcessExitedException`, `ProcessGroup`, `Ptr`, `QuoteNode`, `RandomDevice`, `Range`, `Rational`, `RawFD`, `ReadOnlyMemoryError`, `Real`, `ReentrantLock`, `Ref`, `Regex`, `RegexMatch`, `RemoteException`, `RemoteRef`, `RepString`, `RevString`, `RopeString`, `RoundingMode`, `SegmentationFault`, `SerializationState`, `Set`, `SharedArray`, `SharedMatrix`, `SharedVector`, `Signed`, `SimpleVector`, `SparseMatrixCSC`, `StackOverflowError`, `StatStruct`, `StepRange`, `StridedArray`, `StridedMatrix`, `StridedVecOrMat`, `StridedVector`, `SubArray`, `SubString`, `SymTridiagonal`, `Symbol`, `SymbolNode`, `Symmetric`, `SystemError`, `TCPSocket`, `Task`, `Text`, `TextDisplay`, `Timer`, `TopNode`, `Tridiagonal`, `Tuple`, `Type`, `TypeConstructor`, `TypeError`, `TypeName`, `TypeVar`, `UDPSocket`, `UInt`, `UInt128`, `UInt16`, `UInt32`, `UInt64`, `UInt8`, `UTF16String`, `UTF32String`, `UTF8String`, `UndefRefError`, `UndefVarError`, `UnicodeError`, `UniformScaling`, `Union`, `UnitRange`, `Unsigned`, `UpperTriangular`, `Val`, `Vararg`, `VecOrMat`, `Vector`, `VersionNumber`, `Void`, `WString`, `WeakKeyDict`, `WeakRef`, `WorkerConfig`, `Zip`), KeywordType, nil}, | ||||
| 			{Words(``, `\b`, `ARGS`, `CPU_CORES`, `C_NULL`, `DevNull`, `ENDIAN_BOM`, `ENV`, `I`, `Inf`, `Inf16`, `Inf32`, `Inf64`, `InsertionSort`, `JULIA_HOME`, `LOAD_PATH`, `MergeSort`, `NaN`, `NaN16`, `NaN32`, `NaN64`, `OS_NAME`, `QuickSort`, `RoundDown`, `RoundFromZero`, `RoundNearest`, `RoundNearestTiesAway`, `RoundNearestTiesUp`, `RoundToZero`, `RoundUp`, `STDERR`, `STDIN`, `STDOUT`, `VERSION`, `WORD_SIZE`, `catalan`, `e`, `eu`, `eulergamma`, `golden`, `im`, `nothing`, `pi`, `γ`, `π`, `φ`), NameBuiltin, nil}, | ||||
| 			{Words(``, ``, `=`, `:=`, `+=`, `-=`, `*=`, `/=`, `//=`, `.//=`, `.*=`, `./=`, `\=`, `.\=`, `^=`, `.^=`, `÷=`, `.÷=`, `%=`, `.%=`, `|=`, `&=`, `$=`, `=>`, `<<=`, `>>=`, `>>>=`, `~`, `.+=`, `.-=`, `?`, `--`, `-->`, `||`, `&&`, `>`, `<`, `>=`, `≥`, `<=`, `≤`, `==`, `===`, `≡`, `!=`, `≠`, `!==`, `≢`, `.>`, `.<`, `.>=`, `.≥`, `.<=`, `.≤`, `.==`, `.!=`, `.≠`, `.=`, `.!`, `<:`, `>:`, `∈`, `∉`, `∋`, `∌`, `⊆`, `⊈`, `⊂`, `⊄`, `⊊`, `|>`, `<|`, `:`, `+`, `-`, `.+`, `.-`, `|`, `∪`, `$`, `<<`, `>>`, `>>>`, `.<<`, `.>>`, `.>>>`, `*`, `/`, `./`, `÷`, `.÷`, `%`, `⋅`, `.%`, `.*`, `\`, `.\`, `&`, `∩`, `//`, `.//`, `^`, `.^`, `::`, `.`, `+`, `-`, `!`, `~`, `√`, `∛`, `∜`), Operator, nil}, | ||||
| 			{`'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,3}|\\u[a-fA-F0-9]{1,4}|\\U[a-fA-F0-9]{1,6}|[^\\\'\n])'`, LiteralStringChar, nil}, | ||||
| 			{`(?<=[.\w)\]])\'+`, Operator, nil}, | ||||
| 			{`"""`, LiteralString, Push("tqstring")}, | ||||
| 			{`"`, LiteralString, Push("string")}, | ||||
| 			{`r"""`, LiteralStringRegex, Push("tqregex")}, | ||||
| 			{`r"`, LiteralStringRegex, Push("regex")}, | ||||
| 			{"`", LiteralStringBacktick, Push("command")}, | ||||
| 			{`(?:[a-zA-Z_¡-]|[𐀀-])(?:[a-zA-Z_0-9¡-]|[𐀀-])*!*`, Name, nil}, | ||||
| 			{`@(?:[a-zA-Z_¡-]|[𐀀-])(?:[a-zA-Z_0-9¡-]|[𐀀-])*!*`, NameDecorator, nil}, | ||||
| 			{`(\d+(_\d+)+\.\d*|\d*\.\d+(_\d+)+)([eEf][+-]?[0-9]+)?`, LiteralNumberFloat, nil}, | ||||
| 			{`(\d+\.\d*|\d*\.\d+)([eEf][+-]?[0-9]+)?`, LiteralNumberFloat, nil}, | ||||
| 			{`\d+(_\d+)+[eEf][+-]?[0-9]+`, LiteralNumberFloat, nil}, | ||||
| 			{`\d+[eEf][+-]?[0-9]+`, LiteralNumberFloat, nil}, | ||||
| 			{`0b[01]+(_[01]+)+`, LiteralNumberBin, nil}, | ||||
| 			{`0b[01]+`, LiteralNumberBin, nil}, | ||||
| 			{`0o[0-7]+(_[0-7]+)+`, LiteralNumberOct, nil}, | ||||
| 			{`0o[0-7]+`, LiteralNumberOct, nil}, | ||||
| 			{`0x[a-fA-F0-9]+(_[a-fA-F0-9]+)+`, LiteralNumberHex, nil}, | ||||
| 			{`0x[a-fA-F0-9]+`, LiteralNumberHex, nil}, | ||||
| 			{`\d+(_\d+)+`, LiteralNumberInteger, nil}, | ||||
| 			{`\d+`, LiteralNumberInteger, nil}, | ||||
| 		}, | ||||
| 		"blockcomment": { | ||||
| 			{`[^=#]`, CommentMultiline, nil}, | ||||
| 			{`#=`, CommentMultiline, Push()}, | ||||
| 			{`=#`, CommentMultiline, Pop(1)}, | ||||
| 			{`[=#]`, CommentMultiline, nil}, | ||||
| 		}, | ||||
| 		"string": { | ||||
| 			{`"`, LiteralString, Pop(1)}, | ||||
| 			{`\\([\\"\'$nrbtfav]|(x|u|U)[a-fA-F0-9]+|\d+)`, LiteralStringEscape, nil}, | ||||
| 			{`\$(?:[a-zA-Z_¡-]|[𐀀-])(?:[a-zA-Z_0-9¡-]|[𐀀-])*!*`, LiteralStringInterpol, nil}, | ||||
| 			{`(\$)(\()`, ByGroups(LiteralStringInterpol, Punctuation), Push("in-intp")}, | ||||
| 			{`%[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]`, LiteralStringInterpol, nil}, | ||||
| 			{`.|\s`, LiteralString, nil}, | ||||
| 		}, | ||||
| 		"tqstring": { | ||||
| 			{`"""`, LiteralString, Pop(1)}, | ||||
| 			{`\\([\\"\'$nrbtfav]|(x|u|U)[a-fA-F0-9]+|\d+)`, LiteralStringEscape, nil}, | ||||
| 			{`\$(?:[a-zA-Z_¡-]|[𐀀-])(?:[a-zA-Z_0-9¡-]|[𐀀-])*!*`, LiteralStringInterpol, nil}, | ||||
| 			{`(\$)(\()`, ByGroups(LiteralStringInterpol, Punctuation), Push("in-intp")}, | ||||
| 			{`.|\s`, LiteralString, nil}, | ||||
| 		}, | ||||
| 		"regex": { | ||||
| 			{`"`, LiteralStringRegex, Pop(1)}, | ||||
| 			{`\\"`, LiteralStringRegex, nil}, | ||||
| 			{`.|\s`, LiteralStringRegex, nil}, | ||||
| 		}, | ||||
| 		"tqregex": { | ||||
| 			{`"""`, LiteralStringRegex, Pop(1)}, | ||||
| 			{`.|\s`, LiteralStringRegex, nil}, | ||||
| 		}, | ||||
| 		"command": { | ||||
| 			{"`", LiteralStringBacktick, Pop(1)}, | ||||
| 			{`\$(?:[a-zA-Z_¡-]|[𐀀-])(?:[a-zA-Z_0-9¡-]|[𐀀-])*!*`, LiteralStringInterpol, nil}, | ||||
| 			{`(\$)(\()`, ByGroups(LiteralStringInterpol, Punctuation), Push("in-intp")}, | ||||
| 			{`.|\s`, LiteralStringBacktick, nil}, | ||||
| 		}, | ||||
| 		"in-intp": { | ||||
| 			{`\(`, Punctuation, Push()}, | ||||
| 			{`\)`, Punctuation, Pop(1)}, | ||||
| 			Include("root"), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										29
									
								
								lexers/lighttpd.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								lexers/lighttpd.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Lighttpd Configuration File lexer. | ||||
| var Lighttpd = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Lighttpd configuration file", | ||||
| 		Aliases:   []string{"lighty", "lighttpd"}, | ||||
| 		Filenames: []string{}, | ||||
| 		MimeTypes: []string{"text/x-lighttpd-conf"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`#.*\n`, CommentSingle, nil}, | ||||
| 			{`/\S*`, Name, nil}, | ||||
| 			{`[a-zA-Z._-]+`, Keyword, nil}, | ||||
| 			{`\d+\.\d+\.\d+\.\d+(?:/\d+)?`, LiteralNumber, nil}, | ||||
| 			{`[0-9]+`, LiteralNumber, nil}, | ||||
| 			{`=>|=~|\+=|==|=|\+`, Operator, nil}, | ||||
| 			{`\$[A-Z]+`, NameBuiltin, nil}, | ||||
| 			{`[(){}\[\],]`, Punctuation, nil}, | ||||
| 			{`"([^"\\]*(?:\\.[^"\\]*)*)"`, LiteralStringDouble, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										42
									
								
								lexers/llvm.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								lexers/llvm.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Llvm lexer. | ||||
| var Llvm = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "LLVM", | ||||
| 		Aliases:   []string{"llvm"}, | ||||
| 		Filenames: []string{"*.ll"}, | ||||
| 		MimeTypes: []string{"text/x-llvm"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			Include("whitespace"), | ||||
| 			{`([-a-zA-Z$._][\w\-$.]*|"[^"]*?")\s*:`, NameLabel, nil}, | ||||
| 			Include("keyword"), | ||||
| 			{`%([-a-zA-Z$._][\w\-$.]*|"[^"]*?")`, NameVariable, nil}, | ||||
| 			{`@([-a-zA-Z$._][\w\-$.]*|"[^"]*?")`, NameVariableGlobal, nil}, | ||||
| 			{`%\d+`, NameVariableAnonymous, nil}, | ||||
| 			{`@\d+`, NameVariableGlobal, nil}, | ||||
| 			{`#\d+`, NameVariableGlobal, nil}, | ||||
| 			{`!([-a-zA-Z$._][\w\-$.]*|"[^"]*?")`, NameVariable, nil}, | ||||
| 			{`!\d+`, NameVariableAnonymous, nil}, | ||||
| 			{`c?"[^"]*?"`, LiteralString, nil}, | ||||
| 			{`0[xX][a-fA-F0-9]+`, LiteralNumber, nil}, | ||||
| 			{`-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?`, LiteralNumber, nil}, | ||||
| 			{`[=<>{}\[\]()*.,!]|x\b`, Punctuation, nil}, | ||||
| 		}, | ||||
| 		"whitespace": { | ||||
| 			{`(\n|\s)+`, Text, nil}, | ||||
| 			{`;.*?\n`, Comment, nil}, | ||||
| 		}, | ||||
| 		"keyword": { | ||||
| 			{Words(``, `\b`, `begin`, `end`, `true`, `false`, `declare`, `define`, `global`, `constant`, `private`, `linker_private`, `internal`, `available_externally`, `linkonce`, `linkonce_odr`, `weak`, `weak_odr`, `appending`, `dllimport`, `dllexport`, `common`, `default`, `hidden`, `protected`, `extern_weak`, `external`, `thread_local`, `zeroinitializer`, `undef`, `null`, `to`, `tail`, `target`, `triple`, `datalayout`, `volatile`, `nuw`, `nsw`, `nnan`, `ninf`, `nsz`, `arcp`, `fast`, `exact`, `inbounds`, `align`, `addrspace`, `section`, `alias`, `module`, `asm`, `sideeffect`, `gc`, `dbg`, `linker_private_weak`, `attributes`, `blockaddress`, `initialexec`, `localdynamic`, `localexec`, `prefix`, `unnamed_addr`, `ccc`, `fastcc`, `coldcc`, `x86_stdcallcc`, `x86_fastcallcc`, `arm_apcscc`, `arm_aapcscc`, `arm_aapcs_vfpcc`, `ptx_device`, `ptx_kernel`, `intel_ocl_bicc`, `msp430_intrcc`, `spir_func`, `spir_kernel`, `x86_64_sysvcc`, `x86_64_win64cc`, `x86_thiscallcc`, `cc`, `c`, `signext`, `zeroext`, `inreg`, `sret`, `nounwind`, `noreturn`, `noalias`, `nocapture`, `byval`, `nest`, `readnone`, `readonly`, `inlinehint`, `noinline`, `alwaysinline`, `optsize`, `ssp`, `sspreq`, `noredzone`, `noimplicitfloat`, `naked`, `builtin`, `cold`, `nobuiltin`, `noduplicate`, `nonlazybind`, `optnone`, `returns_twice`, `sanitize_address`, `sanitize_memory`, `sanitize_thread`, `sspstrong`, `uwtable`, `returned`, `type`, `opaque`, `eq`, `ne`, `slt`, `sgt`, `sle`, `sge`, `ult`, `ugt`, `ule`, `uge`, `oeq`, `one`, `olt`, `ogt`, `ole`, `oge`, `ord`, `uno`, `ueq`, `une`, `x`, `acq_rel`, `acquire`, `alignstack`, `atomic`, `catch`, `cleanup`, `filter`, `inteldialect`, `max`, `min`, `monotonic`, `nand`, `personality`, `release`, `seq_cst`, `singlethread`, `umax`, `umin`, `unordered`, `xchg`, `add`, `fadd`, `sub`, `fsub`, `mul`, `fmul`, `udiv`, `sdiv`, `fdiv`, `urem`, `srem`, `frem`, `shl`, `lshr`, `ashr`, `and`, `or`, `xor`, `icmp`, `fcmp`, `phi`, `call`, `trunc`, `zext`, `sext`, `fptrunc`, `fpext`, `uitofp`, `sitofp`, `fptoui`, `fptosi`, `inttoptr`, `ptrtoint`, `bitcast`, `addrspacecast`, `select`, `va_arg`, `ret`, `br`, `switch`, `invoke`, `unwind`, `unreachable`, `indirectbr`, `landingpad`, `resume`, `malloc`, `alloca`, `free`, `load`, `store`, `getelementptr`, `extractelement`, `insertelement`, `shufflevector`, `getresult`, `extractvalue`, `insertvalue`, `atomicrmw`, `cmpxchg`, `fence`, `allocsize`, `amdgpu_cs`, `amdgpu_gs`, `amdgpu_kernel`, `amdgpu_ps`, `amdgpu_vs`, `any`, `anyregcc`, `argmemonly`, `avr_intrcc`, `avr_signalcc`, `caller`, `catchpad`, `catchret`, `catchswitch`, `cleanuppad`, `cleanupret`, `comdat`, `convergent`, `cxx_fast_tlscc`, `deplibs`, `dereferenceable`, `dereferenceable_or_null`, `distinct`, `exactmatch`, `externally_initialized`, `from`, `ghccc`, `hhvm_ccc`, `hhvmcc`, `ifunc`, `inaccessiblemem_or_argmemonly`, `inaccessiblememonly`, `inalloca`, `jumptable`, `largest`, `local_unnamed_addr`, `minsize`, `musttail`, `noduplicates`, `none`, `nonnull`, `norecurse`, `notail`, `preserve_allcc`, `preserve_mostcc`, `prologue`, `safestack`, `samesize`, `source_filename`, `swiftcc`, `swifterror`, `swiftself`, `webkit_jscc`, `within`, `writeonly`, `x86_intrcc`, `x86_vectorcallcc`), Keyword, nil}, | ||||
| 			{Words(``, ``, `void`, `half`, `float`, `double`, `x86_fp80`, `fp128`, `ppc_fp128`, `label`, `metadata`, `token`), KeywordType, nil}, | ||||
| 			{`i[1-9]\d*`, Keyword, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										74
									
								
								lexers/lua.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								lexers/lua.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,74 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Lua lexer. | ||||
| var Lua = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Lua", | ||||
| 		Aliases:   []string{"lua"}, | ||||
| 		Filenames: []string{"*.lua", "*.wlua"}, | ||||
| 		MimeTypes: []string{"text/x-lua", "application/x-lua"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`#!.*`, CommentPreproc, nil}, | ||||
| 			Default(Push("base")), | ||||
| 		}, | ||||
| 		"ws": { | ||||
| 			{`(?:--\[(?P<level>=*)\[[\w\W]*?\](?P=level)\])`, CommentMultiline, nil}, | ||||
| 			{`(?:--.*$)`, CommentSingle, nil}, | ||||
| 			{`(?:\s+)`, Text, nil}, | ||||
| 		}, | ||||
| 		"base": { | ||||
| 			Include("ws"), | ||||
| 			{`(?i)0x[\da-f]*(\.[\da-f]*)?(p[+-]?\d+)?`, LiteralNumberHex, nil}, | ||||
| 			{`(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?`, LiteralNumberFloat, nil}, | ||||
| 			{`(?i)\d+e[+-]?\d+`, LiteralNumberFloat, nil}, | ||||
| 			{`\d+`, LiteralNumberInteger, nil}, | ||||
| 			{`(?s)\[(=*)\[.*?\]\1\]`, LiteralString, nil}, | ||||
| 			{`::`, Punctuation, Push("label")}, | ||||
| 			{`\.{3}`, Punctuation, nil}, | ||||
| 			{`[=<>|~&+\-*/%#^]+|\.\.`, Operator, nil}, | ||||
| 			{`[\[\]{}().,:;]`, Punctuation, nil}, | ||||
| 			{`(and|or|not)\b`, OperatorWord, nil}, | ||||
| 			{`(break|do|else|elseif|end|for|if|in|repeat|return|then|until|while)\b`, KeywordReserved, nil}, | ||||
| 			{`goto\b`, KeywordReserved, Push("goto")}, | ||||
| 			{`(local)\b`, KeywordDeclaration, nil}, | ||||
| 			{`(true|false|nil)\b`, KeywordConstant, nil}, | ||||
| 			{`(function)\b`, KeywordReserved, Push("funcname")}, | ||||
| 			{`[A-Za-z_]\w*(\.[A-Za-z_]\w*)?`, Name, nil}, | ||||
| 			{`'`, LiteralStringSingle, Combined("stringescape", "sqs")}, | ||||
| 			{`"`, LiteralStringDouble, Combined("stringescape", "dqs")}, | ||||
| 		}, | ||||
| 		"funcname": { | ||||
| 			Include("ws"), | ||||
| 			{`[.:]`, Punctuation, nil}, | ||||
| 			{`(?:[^\W\d]\w*)(?=(?:(?:--\[(?P<level>=*)\[[\w\W]*?\](?P=level)\])|(?:--.*$)|(?:\s+))*[.:])`, NameClass, nil}, | ||||
| 			{`(?:[^\W\d]\w*)`, NameFunction, Pop(1)}, | ||||
| 			{`\(`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"goto": { | ||||
| 			Include("ws"), | ||||
| 			{`(?:[^\W\d]\w*)`, NameLabel, Pop(1)}, | ||||
| 		}, | ||||
| 		"label": { | ||||
| 			Include("ws"), | ||||
| 			{`::`, Punctuation, Pop(1)}, | ||||
| 			{`(?:[^\W\d]\w*)`, NameLabel, nil}, | ||||
| 		}, | ||||
| 		"stringescape": { | ||||
| 			{`\\([abfnrtv\\"\']|[\r\n]{1,2}|z\s*|x[0-9a-fA-F]{2}|\d{1,3}|u\{[0-9a-fA-F]+\})`, LiteralStringEscape, nil}, | ||||
| 		}, | ||||
| 		"sqs": { | ||||
| 			{`'`, LiteralStringSingle, Pop(1)}, | ||||
| 			{`[^\\']+`, LiteralStringSingle, nil}, | ||||
| 		}, | ||||
| 		"dqs": { | ||||
| 			{`"`, LiteralStringDouble, Pop(1)}, | ||||
| 			{`[^\\"]+`, LiteralStringDouble, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
| @@ -7,10 +7,10 @@ import ( | ||||
| // Makefile lexer. | ||||
| var Makefile = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Makefile", | ||||
| 		Aliases:   []string{"make", "makefile", "mf", "bsdmake"}, | ||||
| 		Filenames: []string{"*.mak", "*.mk", "Makefile", "makefile", "Makefile.*", "GNUmakefile"}, | ||||
| 		MimeTypes: []string{"text/x-makefile"}, | ||||
| 		Name:      "Base Makefile", | ||||
| 		Aliases:   []string{"make"}, | ||||
| 		Filenames: []string{}, | ||||
| 		MimeTypes: []string{}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| @@ -18,7 +18,7 @@ var Makefile = Register(MustNewLexer( | ||||
| 			{`\$[<@$+%?|*]`, Keyword, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`#.*?\n`, Comment, nil}, | ||||
| 			{`(export)(\s+)`, ByGroups(Keyword, Text), Push("export")}, | ||||
| 			{`(export)(\s+)(?=[\w${}\t -]+\n)`, ByGroups(Keyword, Text), Push("export")}, | ||||
| 			{`export\s+`, Keyword, nil}, | ||||
| 			{`([\w${}().-]+)(\s*)([!?:+]?=)([ \t]*)((?:.*\\\n)+|.*\n)`, ByGroups(NameVariable, Text, Operator, Text, Using(Bash, nil)), nil}, | ||||
| 			{`(?s)"(\\\\|\\.|[^"\\])*"`, LiteralStringDouble, nil}, | ||||
							
								
								
									
										58
									
								
								lexers/mako.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								lexers/mako.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Mako lexer. | ||||
| var Mako = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Mako", | ||||
| 		Aliases:   []string{"mako"}, | ||||
| 		Filenames: []string{"*.mao"}, | ||||
| 		MimeTypes: []string{"application/x-mako"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`(\s*)(%)(\s*end(?:\w+))(\n|\Z)`, ByGroups(Text, CommentPreproc, Keyword, Other), nil}, | ||||
| 			{`(\s*)(%)([^\n]*)(\n|\Z)`, ByGroups(Text, CommentPreproc, Using(Python, nil), Other), nil}, | ||||
| 			{`(\s*)(##[^\n]*)(\n|\Z)`, ByGroups(Text, CommentPreproc, Other), nil}, | ||||
| 			{`(?s)<%doc>.*?</%doc>`, CommentPreproc, nil}, | ||||
| 			{`(<%)([\w.:]+)`, ByGroups(CommentPreproc, NameBuiltin), Push("tag")}, | ||||
| 			{`(</%)([\w.:]+)(>)`, ByGroups(CommentPreproc, NameBuiltin, CommentPreproc), nil}, | ||||
| 			{`<%(?=([\w.:]+))`, CommentPreproc, Push("ondeftags")}, | ||||
| 			{`(<%(?:!?))(.*?)(%>)(?s)`, ByGroups(CommentPreproc, Using(Python, nil), CommentPreproc), nil}, | ||||
| 			{`(\$\{)(.*?)(\})`, ByGroups(CommentPreproc, Using(Python, nil), CommentPreproc), nil}, | ||||
| 			{`(?sx) | ||||
|                 (.+?)                # anything, followed by: | ||||
|                 (?: | ||||
|                  (?<=\n)(?=%|\#\#) | # an eval or comment line | ||||
|                  (?=\#\*) |          # multiline comment | ||||
|                  (?=</?%) |          # a python block | ||||
|                                      # call start or end | ||||
|                  (?=\$\{) |          # a substitution | ||||
|                  (?<=\n)(?=\s*%) | | ||||
|                                      # - don't consume | ||||
|                  (\\\n) |            # an escaped newline | ||||
|                  \Z                  # end of string | ||||
|                 ) | ||||
|             `, ByGroups(Other, Operator), nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 		}, | ||||
| 		"ondeftags": { | ||||
| 			{`<%`, CommentPreproc, nil}, | ||||
| 			{`(?<=<%)(include|inherit|namespace|page)`, NameBuiltin, nil}, | ||||
| 			Include("tag"), | ||||
| 		}, | ||||
| 		"tag": { | ||||
| 			{`((?:\w+)\s*=)(\s*)(".*?")`, ByGroups(NameAttribute, Text, LiteralString), nil}, | ||||
| 			{`/?\s*>`, CommentPreproc, Pop(1)}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 		}, | ||||
| 		"attr": { | ||||
| 			{`".*?"`, LiteralString, Pop(1)}, | ||||
| 			{`'.*?'`, LiteralString, Pop(1)}, | ||||
| 			{`[^\s>]+`, LiteralString, Pop(1)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
| @@ -12,25 +12,24 @@ var Markdown = Register(MustNewLexer( | ||||
| 		Filenames: []string{"*.md"}, | ||||
| 		MimeTypes: []string{"text/x-markdown"}, | ||||
| 	}, | ||||
| 	map[string][]Rule{ | ||||
| 		"root": []Rule{ | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`^(#)([^#].+\n)`, ByGroups(GenericHeading, Text), nil}, | ||||
| 			{`^(#{2,6})(.+\n)`, ByGroups(GenericSubheading, Text), nil}, | ||||
| 			{`^(\s*)([*-] )(\[[ xX]\])( .+\n)`, ByGroups(Text, Keyword, Keyword, UsingSelf("inline")), nil}, | ||||
| 			{`^(\s*)([*-])(\s)(.+\n)`, ByGroups(Text, Keyword, Text, UsingSelf("inline")), nil}, | ||||
| 			{`^(\s*)([0-9]+\.)( .+\n)`, ByGroups(Text, Keyword, UsingSelf("inline")), nil}, | ||||
| 			{`^(\s*>\s)(.+\n)`, ByGroups(Keyword, GenericEmph), nil}, | ||||
| 			{"^(```\n)([\\w\\W]*?)(^```$)", ByGroups(String, Text, String), nil}, | ||||
| 			{"^(```)(\\w+)(\n)([\\w\\W]*?)(^```$)", EmitterFunc(handleCodeblock), nil}, | ||||
| 			Include(`inline`), | ||||
| 			{"^(```\\n)([\\w\\W]*?)(^```$)", ByGroups(LiteralString, Text, LiteralString), nil}, | ||||
| 			{"^(```)(\\w+)(\\n)([\\w\\W]*?)(^```$)", EmitterFunc(handleCodeblock), nil}, | ||||
| 			Include("inline"), | ||||
| 		}, | ||||
| 		`inline`: []Rule{ | ||||
| 		"inline": { | ||||
| 			{`\\.`, Text, nil}, | ||||
| 			{`(\s)([*_][^*_]+[*_])(\W|\n)`, ByGroups(Text, GenericEmph, Text), nil}, | ||||
| 			{`(\s)(__.*?__)`, ByGroups(Whitespace, GenericUnderline), nil}, | ||||
| 			{`(\s)(\*\*.*\*\*)`, ByGroups(Text, GenericStrong), nil}, | ||||
| 			{`(\s)(~~[^~]+~~)`, ByGroups(Text, GenericDeleted), nil}, | ||||
| 			{"`[^`]+`", StringBacktick, nil}, | ||||
| 			{`(\s)((\*\*|__).*\3)((?=\W|\n))`, ByGroups(Text, GenericStrong, None, Text), nil}, | ||||
| 			{`(\s)(~~[^~]+~~)((?=\W|\n))`, ByGroups(Text, GenericDeleted, Text), nil}, | ||||
| 			{"`[^`]+`", LiteralStringBacktick, nil}, | ||||
| 			{`[@#][\w/:]+`, NameEntity, nil}, | ||||
| 			{`(!?\[)([^]]+)(\])(\()([^)]+)(\))`, ByGroups(Text, NameTag, Text, Text, NameAttribute, Text), nil}, | ||||
| 			{`[^\\\s]+`, Text, nil}, | ||||
| @@ -45,6 +44,10 @@ func handleCodeblock(groups []string, lexer Lexer, out func(*Token)) { | ||||
| 	out(&Token{Text, groups[3]}) | ||||
| 	code := groups[4] | ||||
| 	lexer = Get(groups[2]) | ||||
| 	lexer.Tokenise(nil, code, out) | ||||
| 	if lexer == nil { | ||||
| 		out(&Token{String, code}) | ||||
| 	} else { | ||||
| 		lexer.Tokenise(nil, code, out) | ||||
| 	} | ||||
| 	out(&Token{String, groups[5]}) | ||||
| } | ||||
|   | ||||
							
								
								
									
										39
									
								
								lexers/mason.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								lexers/mason.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Mason lexer. | ||||
| var Mason = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Mason", | ||||
| 		Aliases:   []string{"mason"}, | ||||
| 		Filenames: []string{"*.m", "*.mhtml", "*.mc", "*.mi", "autohandler", "dhandler"}, | ||||
| 		MimeTypes: []string{"application/x-mason"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`(<%doc>)(.*?)(</%doc>)(?s)`, ByGroups(NameTag, CommentMultiline, NameTag), nil}, | ||||
| 			{`(<%(?:def|method))(\s*)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, Text, NameFunction, NameTag, UsingSelf("root"), NameTag), nil}, | ||||
| 			{`(<%\w+)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, NameFunction, NameTag, Using(Perl, nil), NameTag), nil}, | ||||
| 			{`(<&[^|])(.*?)(,.*?)?(&>)(?s)`, ByGroups(NameTag, NameFunction, Using(Perl, nil), NameTag), nil}, | ||||
| 			{`(<&\|)(.*?)(,.*?)?(&>)(?s)`, ByGroups(NameTag, NameFunction, Using(Perl, nil), NameTag), nil}, | ||||
| 			{`</&>`, NameTag, nil}, | ||||
| 			{`(<%!?)(.*?)(%>)(?s)`, ByGroups(NameTag, Using(Perl, nil), NameTag), nil}, | ||||
| 			{`(?<=^)#[^\n]*(\n|\Z)`, Comment, nil}, | ||||
| 			{`(?<=^)(%)([^\n]*)(\n|\Z)`, ByGroups(NameTag, Using(Perl, nil), Other), nil}, | ||||
| 			{`(?sx) | ||||
|                  (.+?)               # anything, followed by: | ||||
|                  (?: | ||||
|                   (?<=\n)(?=[%#]) |  # an eval or comment line | ||||
|                   (?=</?[%&]) |      # a substitution or block or | ||||
|                                      # call start or end | ||||
|                                      # - don't consume | ||||
|                   (\\\n) |           # an escaped newline | ||||
|                   \Z                 # end of string | ||||
|                  )`, ByGroups(Using(HTML, nil), Operator), nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										31
									
								
								lexers/mathematica.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								lexers/mathematica.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Mathematica lexer. | ||||
| var Mathematica = Register(MustNewLexer( | ||||
| 	&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"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`(?s)\(\*.*?\*\)`, Comment, nil}, | ||||
| 			{"([a-zA-Z]+[A-Za-z0-9]*`)", NameNamespace, nil}, | ||||
| 			{`([A-Za-z0-9]*_+[A-Za-z0-9]*)`, NameVariable, nil}, | ||||
| 			{`#\d*`, NameVariable, nil}, | ||||
| 			{`([a-zA-Z]+[a-zA-Z0-9]*)`, Name, nil}, | ||||
| 			{`-?\d+\.\d*`, LiteralNumberFloat, nil}, | ||||
| 			{`-?\d*\.\d+`, LiteralNumberFloat, nil}, | ||||
| 			{`-?\d+`, LiteralNumberInteger, nil}, | ||||
| 			{Words(``, ``, `;;`, `=`, `=.`, `!===`, `:=`, `->`, `:>`, `/.`, `+`, `-`, `*`, `/`, `^`, `&&`, `||`, `!`, `<>`, `|`, `/;`, `?`, `@`, `//`, `/@`, `@@`, `@@@`, `~~`, `===`, `&`, `<`, `>`, `<=`, `>=`), Operator, nil}, | ||||
| 			{Words(``, ``, `,`, `;`, `(`, `)`, `[`, `]`, `{`, `}`), Punctuation, nil}, | ||||
| 			{`".*?"`, LiteralString, nil}, | ||||
| 			{`\s+`, TextWhitespace, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										114
									
								
								lexers/modula2.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								lexers/modula2.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,114 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Modula-2 lexer. | ||||
| var Modula2 = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Modula-2", | ||||
| 		Aliases:   []string{"modula2", "m2"}, | ||||
| 		Filenames: []string{"*.def", "*.mod"}, | ||||
| 		MimeTypes: []string{"text/x-modula2"}, | ||||
| 		DotAll:    true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"whitespace": { | ||||
| 			{`\n+`, Text, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 		}, | ||||
| 		"dialecttags": { | ||||
| 			{`\(\*!m2pim\*\)`, CommentSpecial, nil}, | ||||
| 			{`\(\*!m2iso\*\)`, CommentSpecial, nil}, | ||||
| 			{`\(\*!m2r10\*\)`, CommentSpecial, nil}, | ||||
| 			{`\(\*!objm2\*\)`, CommentSpecial, nil}, | ||||
| 			{`\(\*!m2iso\+aglet\*\)`, CommentSpecial, nil}, | ||||
| 			{`\(\*!m2pim\+gm2\*\)`, CommentSpecial, nil}, | ||||
| 			{`\(\*!m2iso\+p1\*\)`, CommentSpecial, nil}, | ||||
| 			{`\(\*!m2iso\+xds\*\)`, CommentSpecial, nil}, | ||||
| 		}, | ||||
| 		"identifiers": { | ||||
| 			{`([a-zA-Z_$][\w$]*)`, Name, nil}, | ||||
| 		}, | ||||
| 		"prefixed_number_literals": { | ||||
| 			{`0b[01]+(\'[01]+)*`, LiteralNumberBin, nil}, | ||||
| 			{`0[ux][0-9A-F]+(\'[0-9A-F]+)*`, LiteralNumberHex, nil}, | ||||
| 		}, | ||||
| 		"plain_number_literals": { | ||||
| 			{`[0-9]+(\'[0-9]+)*\.[0-9]+(\'[0-9]+)*[eE][+-]?[0-9]+(\'[0-9]+)*`, LiteralNumberFloat, nil}, | ||||
| 			{`[0-9]+(\'[0-9]+)*\.[0-9]+(\'[0-9]+)*`, LiteralNumberFloat, nil}, | ||||
| 			{`[0-9]+(\'[0-9]+)*`, LiteralNumberInteger, nil}, | ||||
| 		}, | ||||
| 		"suffixed_number_literals": { | ||||
| 			{`[0-7]+B`, LiteralNumberOct, nil}, | ||||
| 			{`[0-7]+C`, LiteralNumberOct, nil}, | ||||
| 			{`[0-9A-F]+H`, LiteralNumberHex, nil}, | ||||
| 		}, | ||||
| 		"string_literals": { | ||||
| 			{`'(\\\\|\\'|[^'])*'`, LiteralString, nil}, | ||||
| 			{`"(\\\\|\\"|[^"])*"`, LiteralString, nil}, | ||||
| 		}, | ||||
| 		"digraph_operators": { | ||||
| 			{`\*\.`, Operator, nil}, | ||||
| 			{`\+>`, Operator, nil}, | ||||
| 			{`<>`, Operator, nil}, | ||||
| 			{`<=`, Operator, nil}, | ||||
| 			{`>=`, Operator, nil}, | ||||
| 			{`==`, Operator, nil}, | ||||
| 			{`::`, Operator, nil}, | ||||
| 			{`:=`, Operator, nil}, | ||||
| 			{`\+\+`, Operator, nil}, | ||||
| 			{`--`, Operator, nil}, | ||||
| 		}, | ||||
| 		"unigraph_operators": { | ||||
| 			{`[+-]`, Operator, nil}, | ||||
| 			{`[*/]`, Operator, nil}, | ||||
| 			{`\\`, Operator, nil}, | ||||
| 			{`[=#<>]`, Operator, nil}, | ||||
| 			{`\^`, Operator, nil}, | ||||
| 			{`@`, Operator, nil}, | ||||
| 			{`&`, Operator, nil}, | ||||
| 			{`~`, Operator, nil}, | ||||
| 			{"`", Operator, nil}, | ||||
| 		}, | ||||
| 		"digraph_punctuation": { | ||||
| 			{`\.\.`, Punctuation, nil}, | ||||
| 			{`<<`, Punctuation, nil}, | ||||
| 			{`>>`, Punctuation, nil}, | ||||
| 			{`->`, Punctuation, nil}, | ||||
| 			{`\|#`, Punctuation, nil}, | ||||
| 			{`##`, Punctuation, nil}, | ||||
| 			{`\|\*`, Punctuation, nil}, | ||||
| 		}, | ||||
| 		"unigraph_punctuation": { | ||||
| 			{`[()\[\]{},.:;|]`, Punctuation, nil}, | ||||
| 			{`!`, Punctuation, nil}, | ||||
| 			{`\?`, Punctuation, nil}, | ||||
| 		}, | ||||
| 		"comments": { | ||||
| 			{`^//.*?\n`, CommentSingle, nil}, | ||||
| 			{`\(\*([^$].*?)\*\)`, CommentMultiline, nil}, | ||||
| 			{`/\*(.*?)\*/`, CommentMultiline, nil}, | ||||
| 		}, | ||||
| 		"pragmas": { | ||||
| 			{`<\*.*?\*>`, CommentPreproc, nil}, | ||||
| 			{`\(\*\$.*?\*\)`, CommentPreproc, nil}, | ||||
| 		}, | ||||
| 		"root": { | ||||
| 			Include("whitespace"), | ||||
| 			Include("dialecttags"), | ||||
| 			Include("pragmas"), | ||||
| 			Include("comments"), | ||||
| 			Include("identifiers"), | ||||
| 			Include("suffixed_number_literals"), | ||||
| 			Include("prefixed_number_literals"), | ||||
| 			Include("plain_number_literals"), | ||||
| 			Include("string_literals"), | ||||
| 			Include("digraph_punctuation"), | ||||
| 			Include("digraph_operators"), | ||||
| 			Include("unigraph_punctuation"), | ||||
| 			Include("unigraph_operators"), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										38
									
								
								lexers/myghty.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								lexers/myghty.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Myghty lexer. | ||||
| var Myghty = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Myghty", | ||||
| 		Aliases:   []string{"myghty"}, | ||||
| 		Filenames: []string{"*.myt", "autodelegate"}, | ||||
| 		MimeTypes: []string{"application/x-myghty"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`(<%(?:def|method))(\s*)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, Text, NameFunction, NameTag, UsingSelf("root"), NameTag), nil}, | ||||
| 			{`(<%\w+)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, NameFunction, NameTag, Using(Python, nil), NameTag), nil}, | ||||
| 			{`(<&[^|])(.*?)(,.*?)?(&>)`, ByGroups(NameTag, NameFunction, Using(Python, nil), NameTag), nil}, | ||||
| 			{`(<&\|)(.*?)(,.*?)?(&>)(?s)`, ByGroups(NameTag, NameFunction, Using(Python, nil), NameTag), nil}, | ||||
| 			{`</&>`, NameTag, nil}, | ||||
| 			{`(<%!?)(.*?)(%>)(?s)`, ByGroups(NameTag, Using(Python, nil), NameTag), nil}, | ||||
| 			{`(?<=^)#[^\n]*(\n|\Z)`, Comment, nil}, | ||||
| 			{`(?<=^)(%)([^\n]*)(\n|\Z)`, ByGroups(NameTag, Using(Python, nil), Other), nil}, | ||||
| 			{`(?sx) | ||||
|                  (.+?)               # anything, followed by: | ||||
|                  (?: | ||||
|                   (?<=\n)(?=[%#]) |  # an eval or comment line | ||||
|                   (?=</?[%&]) |      # a substitution or block or | ||||
|                                      # call start or end | ||||
|                                      # - don't consume | ||||
|                   (\\\n) |           # an escaped newline | ||||
|                   \Z                 # end of string | ||||
|                  )`, ByGroups(Other, Operator), nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										44
									
								
								lexers/mysql.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								lexers/mysql.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,44 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // MySQL lexer. | ||||
| var MySQL = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:            "MySQL", | ||||
| 		Aliases:         []string{"mysql"}, | ||||
| 		Filenames:       []string{"*.sql"}, | ||||
| 		MimeTypes:       []string{"text/x-mysql"}, | ||||
| 		NotMultiline:    true, | ||||
| 		CaseInsensitive: true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`(#|--\s+).*\n?`, CommentSingle, nil}, | ||||
| 			{`/\*`, CommentMultiline, Push("multiline-comments")}, | ||||
| 			{`[0-9]+`, LiteralNumberInteger, nil}, | ||||
| 			{`[0-9]*\.[0-9]+(e[+-][0-9]+)`, LiteralNumberFloat, nil}, | ||||
| 			{`'(\\\\|\\'|''|[^'])*'`, LiteralStringSingle, nil}, | ||||
| 			{`"(\\\\|\\"|""|[^"])*"`, LiteralStringDouble, nil}, | ||||
| 			{"`(\\\\\\\\|\\\\`|``|[^`])*`", LiteralStringSymbol, nil}, | ||||
| 			{"[+*/<>=~!@#%^&|`?-]", Operator, nil}, | ||||
| 			{`\b(tinyint|smallint|mediumint|int|integer|bigint|date|datetime|time|bit|bool|tinytext|mediumtext|longtext|text|tinyblob|mediumblob|longblob|blob|float|double|double\s+precision|real|numeric|dec|decimal|timestamp|year|char|varchar|varbinary|varcharacter|enum|set)(\b\s*)(\()?`, ByGroups(KeywordType, Text, Punctuation), nil}, | ||||
| 			{`\b(add|all|alter|analyze|and|as|asc|asensitive|before|between|bigint|binary|blob|both|by|call|cascade|case|change|char|character|check|collate|column|condition|constraint|continue|convert|create|cross|current_date|current_time|current_timestamp|current_user|cursor|database|databases|day_hour|day_microsecond|day_minute|day_second|dec|decimal|declare|default|delayed|delete|desc|describe|deterministic|distinct|distinctrow|div|double|drop|dual|each|else|elseif|enclosed|escaped|exists|exit|explain|fetch|flush|float|float4|float8|for|force|foreign|from|fulltext|grant|group|having|high_priority|hour_microsecond|hour_minute|hour_second|if|ignore|in|index|infile|inner|inout|insensitive|insert|int|int1|int2|int3|int4|int8|integer|interval|into|is|iterate|join|key|keys|kill|leading|leave|left|like|limit|lines|load|localtime|localtimestamp|lock|long|loop|low_priority|match|minute_microsecond|minute_second|mod|modifies|natural|no_write_to_binlog|not|numeric|on|optimize|option|optionally|or|order|out|outer|outfile|precision|primary|procedure|purge|raid0|read|reads|real|references|regexp|release|rename|repeat|replace|require|restrict|return|revoke|right|rlike|schema|schemas|second_microsecond|select|sensitive|separator|set|show|smallint|soname|spatial|specific|sql|sql_big_result|sql_calc_found_rows|sql_small_result|sqlexception|sqlstate|sqlwarning|ssl|starting|straight_join|table|terminated|then|to|trailing|trigger|undo|union|unique|unlock|unsigned|update|usage|use|using|utc_date|utc_time|utc_timestamp|values|varying|when|where|while|with|write|x509|xor|year_month|zerofill)\b`, Keyword, nil}, | ||||
| 			{`\b(auto_increment|engine|charset|tables)\b`, KeywordPseudo, nil}, | ||||
| 			{`(true|false|null)`, NameConstant, nil}, | ||||
| 			{`([a-z_]\w*)(\s*)(\()`, ByGroups(NameFunction, Text, Punctuation), nil}, | ||||
| 			{`[a-z_]\w*`, Name, nil}, | ||||
| 			{`@[a-z0-9]*[._]*[a-z0-9]*`, NameVariable, nil}, | ||||
| 			{`[;:()\[\],.]`, Punctuation, nil}, | ||||
| 		}, | ||||
| 		"multiline-comments": { | ||||
| 			{`/\*`, CommentMultiline, Push("multiline-comments")}, | ||||
| 			{`\*/`, CommentMultiline, Pop(1)}, | ||||
| 			{`[^/*]+`, CommentMultiline, nil}, | ||||
| 			{`[/*]`, CommentMultiline, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										58
									
								
								lexers/nasm.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								lexers/nasm.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Nasm lexer. | ||||
| var Nasm = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:            "NASM", | ||||
| 		Aliases:         []string{"nasm"}, | ||||
| 		Filenames:       []string{"*.asm", "*.ASM"}, | ||||
| 		MimeTypes:       []string{"text/x-nasm"}, | ||||
| 		CaseInsensitive: true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`^\s*%`, CommentPreproc, Push("preproc")}, | ||||
| 			Include("whitespace"), | ||||
| 			{`[a-z$._?][\w$.?#@~]*:`, NameLabel, nil}, | ||||
| 			{`([a-z$._?][\w$.?#@~]*)(\s+)(equ)`, ByGroups(NameConstant, KeywordDeclaration, KeywordDeclaration), Push("instruction-args")}, | ||||
| 			{`BITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|ORG|ALIGN|STRUC|ENDSTRUC|COMMON|CPU|GROUP|UPPERCASE|IMPORT|EXPORT|LIBRARY|MODULE`, Keyword, Push("instruction-args")}, | ||||
| 			{`(?:res|d)[bwdqt]|times`, KeywordDeclaration, Push("instruction-args")}, | ||||
| 			{`[a-z$._?][\w$.?#@~]*`, NameFunction, Push("instruction-args")}, | ||||
| 			{`[\r\n]+`, Text, nil}, | ||||
| 		}, | ||||
| 		"instruction-args": { | ||||
| 			{"\"(\\\\\"|[^\"\\n])*\"|'(\\\\'|[^'\\n])*'|`(\\\\`|[^`\\n])*`", LiteralString, nil}, | ||||
| 			{`(?:0x[0-9a-f]+|$0[0-9a-f]*|[0-9]+[0-9a-f]*h)`, LiteralNumberHex, nil}, | ||||
| 			{`[0-7]+q`, LiteralNumberOct, nil}, | ||||
| 			{`[01]+b`, LiteralNumberBin, nil}, | ||||
| 			{`[0-9]+\.e?[0-9]+`, LiteralNumberFloat, nil}, | ||||
| 			{`[0-9]+`, LiteralNumberInteger, nil}, | ||||
| 			Include("punctuation"), | ||||
| 			{`r[0-9][0-5]?[bwd]|[a-d][lh]|[er]?[a-d]x|[er]?[sb]p|[er]?[sd]i|[c-gs]s|st[0-7]|mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7]`, NameBuiltin, nil}, | ||||
| 			{`[a-z$._?][\w$.?#@~]*`, NameVariable, nil}, | ||||
| 			{`[\r\n]+`, Text, Pop(1)}, | ||||
| 			Include("whitespace"), | ||||
| 		}, | ||||
| 		"preproc": { | ||||
| 			{`[^;\n]+`, CommentPreproc, nil}, | ||||
| 			{`;.*?\n`, CommentSingle, Pop(1)}, | ||||
| 			{`\n`, CommentPreproc, Pop(1)}, | ||||
| 		}, | ||||
| 		"whitespace": { | ||||
| 			{`\n`, Text, nil}, | ||||
| 			{`[ \t]+`, Text, nil}, | ||||
| 			{`;.*`, CommentSingle, nil}, | ||||
| 		}, | ||||
| 		"punctuation": { | ||||
| 			{`[,():\[\]]+`, Punctuation, nil}, | ||||
| 			{`[&|^<>+*/%~-]+`, Operator, nil}, | ||||
| 			{`[$]+`, KeywordConstant, nil}, | ||||
| 			{`seg|wrt|strict`, OperatorWord, nil}, | ||||
| 			{`byte|[dq]?word`, KeywordType, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										54
									
								
								lexers/newspeak.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								lexers/newspeak.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,54 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Newspeak lexer. | ||||
| var Newspeak = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Newspeak", | ||||
| 		Aliases:   []string{"newspeak"}, | ||||
| 		Filenames: []string{"*.ns2"}, | ||||
| 		MimeTypes: []string{"text/x-newspeak"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\b(Newsqueak2)\b`, KeywordDeclaration, nil}, | ||||
| 			{`'[^']*'`, LiteralString, nil}, | ||||
| 			{`\b(class)(\s+)(\w+)(\s*)`, ByGroups(KeywordDeclaration, Text, NameClass, Text), nil}, | ||||
| 			{`\b(mixin|self|super|private|public|protected|nil|true|false)\b`, Keyword, nil}, | ||||
| 			{`(\w+\:)(\s*)([a-zA-Z_]\w+)`, ByGroups(NameFunction, Text, NameVariable), nil}, | ||||
| 			{`(\w+)(\s*)(=)`, ByGroups(NameAttribute, Text, Operator), nil}, | ||||
| 			{`<\w+>`, CommentSpecial, nil}, | ||||
| 			Include("expressionstat"), | ||||
| 			Include("whitespace"), | ||||
| 		}, | ||||
| 		"expressionstat": { | ||||
| 			{`(\d+\.\d*|\.\d+|\d+[fF])[fF]?`, LiteralNumberFloat, nil}, | ||||
| 			{`\d+`, LiteralNumberInteger, nil}, | ||||
| 			{`:\w+`, NameVariable, nil}, | ||||
| 			{`(\w+)(::)`, ByGroups(NameVariable, Operator), nil}, | ||||
| 			{`\w+:`, NameFunction, nil}, | ||||
| 			{`\w+`, NameVariable, nil}, | ||||
| 			{`\(|\)`, Punctuation, nil}, | ||||
| 			{`\[|\]`, Punctuation, nil}, | ||||
| 			{`\{|\}`, Punctuation, nil}, | ||||
| 			{`(\^|\+|\/|~|\*|<|>|=|@|%|\||&|\?|!|,|-|:)`, Operator, nil}, | ||||
| 			{`\.|;`, Punctuation, nil}, | ||||
| 			Include("whitespace"), | ||||
| 			Include("literals"), | ||||
| 		}, | ||||
| 		"literals": { | ||||
| 			{`\$.`, LiteralString, nil}, | ||||
| 			{`'[^']*'`, LiteralString, nil}, | ||||
| 			{`#'[^']*'`, LiteralStringSymbol, nil}, | ||||
| 			{`#\w+:?`, LiteralStringSymbol, nil}, | ||||
| 			{`#(\+|\/|~|\*|<|>|=|@|%|\||&|\?|!|,|-)+`, LiteralStringSymbol, nil}, | ||||
| 		}, | ||||
| 		"whitespace": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`"[^"]*"`, Comment, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										46
									
								
								lexers/nginx.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								lexers/nginx.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Nginx Configuration File lexer. | ||||
| var Nginx = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Nginx configuration file", | ||||
| 		Aliases:   []string{"nginx"}, | ||||
| 		Filenames: []string{"nginx.conf"}, | ||||
| 		MimeTypes: []string{"text/x-nginx-conf"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`(include)(\s+)([^\s;]+)`, ByGroups(Keyword, Text, Name), nil}, | ||||
| 			{`[^\s;#]+`, Keyword, Push("stmt")}, | ||||
| 			Include("base"), | ||||
| 		}, | ||||
| 		"block": { | ||||
| 			{`\}`, Punctuation, Pop(2)}, | ||||
| 			{`[^\s;#]+`, KeywordNamespace, Push("stmt")}, | ||||
| 			Include("base"), | ||||
| 		}, | ||||
| 		"stmt": { | ||||
| 			{`\{`, Punctuation, Push("block")}, | ||||
| 			{`;`, Punctuation, Pop(1)}, | ||||
| 			Include("base"), | ||||
| 		}, | ||||
| 		"base": { | ||||
| 			{`#.*\n`, CommentSingle, nil}, | ||||
| 			{`on|off`, NameConstant, nil}, | ||||
| 			{`\$[^\s;#()]+`, NameVariable, nil}, | ||||
| 			{`([a-z0-9.-]+)(:)([0-9]+)`, ByGroups(Name, Punctuation, LiteralNumberInteger), nil}, | ||||
| 			{`[a-z-]+/[a-z-+]+`, LiteralString, nil}, | ||||
| 			{`[0-9]+[km]?\b`, LiteralNumberInteger, nil}, | ||||
| 			{`(~)(\s*)([^\s{]+)`, ByGroups(Punctuation, Text, LiteralStringRegex), nil}, | ||||
| 			{`[:=~]`, Punctuation, nil}, | ||||
| 			{`[^\s;#{}$]+`, LiteralString, nil}, | ||||
| 			{`/[^\s;#]*`, Name, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`[$;]`, Text, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										90
									
								
								lexers/nimrod.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								lexers/nimrod.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,90 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Nimrod lexer. | ||||
| var Nimrod = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:            "Nimrod", | ||||
| 		Aliases:         []string{"nim", "nimrod"}, | ||||
| 		Filenames:       []string{"*.nim", "*.nimrod"}, | ||||
| 		MimeTypes:       []string{"text/x-nim"}, | ||||
| 		CaseInsensitive: true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`##.*$`, LiteralStringDoc, nil}, | ||||
| 			{`#.*$`, Comment, nil}, | ||||
| 			{`[*=><+\-/@$~&%!?|\\\[\]]`, Operator, nil}, | ||||
| 			{"\\.\\.|\\.|,|\\[\\.|\\.\\]|\\{\\.|\\.\\}|\\(\\.|\\.\\)|\\{|\\}|\\(|\\)|:|\\^|`|;", Punctuation, nil}, | ||||
| 			{`(?:[\w]+)"`, LiteralString, Push("rdqs")}, | ||||
| 			{`"""`, LiteralString, Push("tdqs")}, | ||||
| 			{`"`, LiteralString, Push("dqs")}, | ||||
| 			{`'`, LiteralStringChar, Push("chars")}, | ||||
| 			{`(a_?n_?d_?|o_?r_?|n_?o_?t_?|x_?o_?r_?|s_?h_?l_?|s_?h_?r_?|d_?i_?v_?|m_?o_?d_?|i_?n_?|n_?o_?t_?i_?n_?|i_?s_?|i_?s_?n_?o_?t_?)\b`, OperatorWord, nil}, | ||||
| 			{`(p_?r_?o_?c_?\s)(?![(\[\]])`, Keyword, Push("funcname")}, | ||||
| 			{`(a_?d_?d_?r_?|a_?n_?d_?|a_?s_?|a_?s_?m_?|a_?t_?o_?m_?i_?c_?|b_?i_?n_?d_?|b_?l_?o_?c_?k_?|b_?r_?e_?a_?k_?|c_?a_?s_?e_?|c_?a_?s_?t_?|c_?o_?n_?c_?e_?p_?t_?|c_?o_?n_?s_?t_?|c_?o_?n_?t_?i_?n_?u_?e_?|c_?o_?n_?v_?e_?r_?t_?e_?r_?|d_?e_?f_?e_?r_?|d_?i_?s_?c_?a_?r_?d_?|d_?i_?s_?t_?i_?n_?c_?t_?|d_?i_?v_?|d_?o_?|e_?l_?i_?f_?|e_?l_?s_?e_?|e_?n_?d_?|e_?n_?u_?m_?|e_?x_?c_?e_?p_?t_?|e_?x_?p_?o_?r_?t_?|f_?i_?n_?a_?l_?l_?y_?|f_?o_?r_?|f_?u_?n_?c_?|i_?f_?|i_?n_?|y_?i_?e_?l_?d_?|i_?n_?t_?e_?r_?f_?a_?c_?e_?|i_?s_?|i_?s_?n_?o_?t_?|i_?t_?e_?r_?a_?t_?o_?r_?|l_?e_?t_?|m_?a_?c_?r_?o_?|m_?e_?t_?h_?o_?d_?|m_?i_?x_?i_?n_?|m_?o_?d_?|n_?o_?t_?|n_?o_?t_?i_?n_?|o_?b_?j_?e_?c_?t_?|o_?f_?|o_?r_?|o_?u_?t_?|p_?r_?o_?c_?|p_?t_?r_?|r_?a_?i_?s_?e_?|r_?e_?f_?|r_?e_?t_?u_?r_?n_?|s_?h_?a_?r_?e_?d_?|s_?h_?l_?|s_?h_?r_?|s_?t_?a_?t_?i_?c_?|t_?e_?m_?p_?l_?a_?t_?e_?|t_?r_?y_?|t_?u_?p_?l_?e_?|t_?y_?p_?e_?|w_?h_?e_?n_?|w_?h_?i_?l_?e_?|w_?i_?t_?h_?|w_?i_?t_?h_?o_?u_?t_?|x_?o_?r_?)\b`, Keyword, nil}, | ||||
| 			{`(f_?r_?o_?m_?|i_?m_?p_?o_?r_?t_?|i_?n_?c_?l_?u_?d_?e_?)\b`, KeywordNamespace, nil}, | ||||
| 			{`(v_?a_?r)\b`, KeywordDeclaration, nil}, | ||||
| 			{`(i_?n_?t_?|i_?n_?t_?8_?|i_?n_?t_?1_?6_?|i_?n_?t_?3_?2_?|i_?n_?t_?6_?4_?|f_?l_?o_?a_?t_?|f_?l_?o_?a_?t_?3_?2_?|f_?l_?o_?a_?t_?6_?4_?|b_?o_?o_?l_?|c_?h_?a_?r_?|r_?a_?n_?g_?e_?|a_?r_?r_?a_?y_?|s_?e_?q_?|s_?e_?t_?|s_?t_?r_?i_?n_?g_?)\b`, KeywordType, nil}, | ||||
| 			{`(n_?i_?l_?|t_?r_?u_?e_?|f_?a_?l_?s_?e_?)\b`, KeywordPseudo, nil}, | ||||
| 			{`\b((?![_\d])\w)(((?!_)\w)|(_(?!_)\w))*`, Name, nil}, | ||||
| 			{`[0-9][0-9_]*(?=([e.]|\'f(32|64)))`, LiteralNumberFloat, Push("float-suffix", "float-number")}, | ||||
| 			{`0x[a-f0-9][a-f0-9_]*`, LiteralNumberHex, Push("int-suffix")}, | ||||
| 			{`0b[01][01_]*`, LiteralNumberBin, Push("int-suffix")}, | ||||
| 			{`0o[0-7][0-7_]*`, LiteralNumberOct, Push("int-suffix")}, | ||||
| 			{`[0-9][0-9_]*`, LiteralNumberInteger, Push("int-suffix")}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`.+$`, Error, nil}, | ||||
| 		}, | ||||
| 		"chars": { | ||||
| 			{`\\([\\abcefnrtvl"\']|x[a-f0-9]{2}|[0-9]{1,3})`, LiteralStringEscape, nil}, | ||||
| 			{`'`, LiteralStringChar, Pop(1)}, | ||||
| 			{`.`, LiteralStringChar, nil}, | ||||
| 		}, | ||||
| 		"strings": { | ||||
| 			{`(?<!\$)\$(\d+|#|\w+)+`, LiteralStringInterpol, nil}, | ||||
| 			{`[^\\\'"$\n]+`, LiteralString, nil}, | ||||
| 			{`[\'"\\]`, LiteralString, nil}, | ||||
| 			{`\$`, LiteralString, nil}, | ||||
| 		}, | ||||
| 		"dqs": { | ||||
| 			{`\\([\\abcefnrtvl"\']|\n|x[a-f0-9]{2}|[0-9]{1,3})`, LiteralStringEscape, nil}, | ||||
| 			{`"`, LiteralString, Pop(1)}, | ||||
| 			Include("strings"), | ||||
| 		}, | ||||
| 		"rdqs": { | ||||
| 			{`"(?!")`, LiteralString, Pop(1)}, | ||||
| 			{`""`, LiteralStringEscape, nil}, | ||||
| 			Include("strings"), | ||||
| 		}, | ||||
| 		"tdqs": { | ||||
| 			{`"""(?!")`, LiteralString, Pop(1)}, | ||||
| 			Include("strings"), | ||||
| 			Include("nl"), | ||||
| 		}, | ||||
| 		"funcname": { | ||||
| 			{`((?![\d_])\w)(((?!_)\w)|(_(?!_)\w))*`, NameFunction, Pop(1)}, | ||||
| 			{"`.+`", NameFunction, Pop(1)}, | ||||
| 		}, | ||||
| 		"nl": { | ||||
| 			{`\n`, LiteralString, nil}, | ||||
| 		}, | ||||
| 		"float-number": { | ||||
| 			{`\.(?!\.)[0-9_]*`, LiteralNumberFloat, nil}, | ||||
| 			{`e[+-]?[0-9][0-9_]*`, LiteralNumberFloat, nil}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"float-suffix": { | ||||
| 			{`\'f(32|64)`, LiteralNumberFloat, nil}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"int-suffix": { | ||||
| 			{`\'i(32|64)`, LiteralNumberIntegerLong, nil}, | ||||
| 			{`\'i(8|16)`, LiteralNumberInteger, nil}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										65
									
								
								lexers/ocaml.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								lexers/ocaml.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,65 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Ocaml lexer. | ||||
| var Ocaml = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "OCaml", | ||||
| 		Aliases:   []string{"ocaml"}, | ||||
| 		Filenames: []string{"*.ml", "*.mli", "*.mll", "*.mly"}, | ||||
| 		MimeTypes: []string{"text/x-ocaml"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"escape-sequence": { | ||||
| 			{`\\[\\"\'ntbr]`, LiteralStringEscape, nil}, | ||||
| 			{`\\[0-9]{3}`, LiteralStringEscape, nil}, | ||||
| 			{`\\x[0-9a-fA-F]{2}`, LiteralStringEscape, nil}, | ||||
| 		}, | ||||
| 		"root": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`false|true|\(\)|\[\]`, NameBuiltinPseudo, nil}, | ||||
| 			{`\b([A-Z][\w\']*)(?=\s*\.)`, NameNamespace, Push("dotted")}, | ||||
| 			{`\b([A-Z][\w\']*)`, NameClass, nil}, | ||||
| 			{`\(\*(?![)])`, Comment, Push("comment")}, | ||||
| 			{`\b(as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|false|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|match|method|module|mutable|new|object|of|open|private|raise|rec|sig|struct|then|to|true|try|type|value|val|virtual|when|while|with)\b`, Keyword, nil}, | ||||
| 			{"(~|\\}|\\|]|\\||\\{<|\\{|`|_|]|\\[\\||\\[>|\\[<|\\[|\\?\\?|\\?|>\\}|>]|>|=|<-|<|;;|;|:>|:=|::|:|\\.\\.|\\.|->|-\\.|-|,|\\+|\\*|\\)|\\(|&&|&|#|!=)", Operator, nil}, | ||||
| 			{`([=<>@^|&+\*/$%-]|[!?~])?[!$%&*+\./:<=>?@^|~-]`, Operator, nil}, | ||||
| 			{`\b(and|asr|land|lor|lsl|lxor|mod|or)\b`, OperatorWord, nil}, | ||||
| 			{`\b(unit|int|float|bool|string|char|list|array)\b`, KeywordType, nil}, | ||||
| 			{`[^\W\d][\w']*`, Name, nil}, | ||||
| 			{`-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)`, LiteralNumberFloat, nil}, | ||||
| 			{`0[xX][\da-fA-F][\da-fA-F_]*`, LiteralNumberHex, nil}, | ||||
| 			{`0[oO][0-7][0-7_]*`, LiteralNumberOct, nil}, | ||||
| 			{`0[bB][01][01_]*`, LiteralNumberBin, nil}, | ||||
| 			{`\d[\d_]*`, LiteralNumberInteger, nil}, | ||||
| 			{`'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'`, LiteralStringChar, nil}, | ||||
| 			{`'.'`, LiteralStringChar, nil}, | ||||
| 			{`'`, Keyword, nil}, | ||||
| 			{`"`, LiteralStringDouble, Push("string")}, | ||||
| 			{`[~?][a-z][\w\']*:`, NameVariable, nil}, | ||||
| 		}, | ||||
| 		"comment": { | ||||
| 			{`[^(*)]+`, Comment, nil}, | ||||
| 			{`\(\*`, Comment, Push()}, | ||||
| 			{`\*\)`, Comment, Pop(1)}, | ||||
| 			{`[(*)]`, Comment, nil}, | ||||
| 		}, | ||||
| 		"string": { | ||||
| 			{`[^\\"]+`, LiteralStringDouble, nil}, | ||||
| 			Include("escape-sequence"), | ||||
| 			{`\\\n`, LiteralStringDouble, nil}, | ||||
| 			{`"`, LiteralStringDouble, Pop(1)}, | ||||
| 		}, | ||||
| 		"dotted": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`\.`, Punctuation, nil}, | ||||
| 			{`[A-Z][\w\']*(?=\s*\.)`, NameNamespace, nil}, | ||||
| 			{`[A-Z][\w\']*`, NameClass, Pop(1)}, | ||||
| 			{`[a-z_][\w\']*`, Name, Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										45
									
								
								lexers/octave.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								lexers/octave.go
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										25
									
								
								lexers/pacman.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								lexers/pacman.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Pacmanconf lexer. | ||||
| var Pacmanconf = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "PacmanConf", | ||||
| 		Aliases:   []string{"pacmanconf"}, | ||||
| 		Filenames: []string{"pacman.conf"}, | ||||
| 		MimeTypes: []string{}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`#.*$`, CommentSingle, nil}, | ||||
| 			{`^\s*\[.*?\]\s*$`, Keyword, nil}, | ||||
| 			{`(\w+)(\s*)(=)`, ByGroups(NameAttribute, Text, Operator), nil}, | ||||
| 			{`^(\s*)(\w+)(\s*)$`, ByGroups(Text, NameAttribute, Text), nil}, | ||||
| 			{Words(``, `\b`, `$repo`, `$arch`, `%o`, `%u`), NameVariable, nil}, | ||||
| 			{`.`, Text, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										137
									
								
								lexers/perl.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								lexers/perl.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,137 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Perl lexer. | ||||
| var Perl = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Perl", | ||||
| 		Aliases:   []string{"perl", "pl"}, | ||||
| 		Filenames: []string{"*.pl", "*.pm", "*.t"}, | ||||
| 		MimeTypes: []string{"text/x-perl", "application/x-perl"}, | ||||
| 		DotAll:    true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"balanced-regex": { | ||||
| 			{`/(\\\\|\\[^\\]|[^\\/])*/[egimosx]*`, LiteralStringRegex, Pop(1)}, | ||||
| 			{`!(\\\\|\\[^\\]|[^\\!])*![egimosx]*`, LiteralStringRegex, Pop(1)}, | ||||
| 			{`\\(\\\\|[^\\])*\\[egimosx]*`, LiteralStringRegex, Pop(1)}, | ||||
| 			{`\{(\\\\|\\[^\\]|[^\\}])*\}[egimosx]*`, LiteralStringRegex, Pop(1)}, | ||||
| 			{`<(\\\\|\\[^\\]|[^\\>])*>[egimosx]*`, LiteralStringRegex, Pop(1)}, | ||||
| 			{`\[(\\\\|\\[^\\]|[^\\\]])*\][egimosx]*`, LiteralStringRegex, Pop(1)}, | ||||
| 			{`\((\\\\|\\[^\\]|[^\\)])*\)[egimosx]*`, LiteralStringRegex, Pop(1)}, | ||||
| 			{`@(\\\\|\\[^\\]|[^\\@])*@[egimosx]*`, LiteralStringRegex, Pop(1)}, | ||||
| 			{`%(\\\\|\\[^\\]|[^\\%])*%[egimosx]*`, LiteralStringRegex, Pop(1)}, | ||||
| 			{`\$(\\\\|\\[^\\]|[^\\$])*\$[egimosx]*`, LiteralStringRegex, Pop(1)}, | ||||
| 		}, | ||||
| 		"root": { | ||||
| 			{`\A\#!.+?$`, CommentHashbang, nil}, | ||||
| 			{`\#.*?$`, CommentSingle, nil}, | ||||
| 			{`^=[a-zA-Z0-9]+\s+.*?\n=cut`, CommentMultiline, nil}, | ||||
| 			{Words(``, `\b`, `case`, `continue`, `do`, `else`, `elsif`, `for`, `foreach`, `if`, `last`, `my`, `next`, `our`, `redo`, `reset`, `then`, `unless`, `until`, `while`, `print`, `new`, `BEGIN`, `CHECK`, `INIT`, `END`, `return`), Keyword, nil}, | ||||
| 			{`(format)(\s+)(\w+)(\s*)(=)(\s*\n)`, ByGroups(Keyword, Text, Name, Text, Punctuation, Text), Push("format")}, | ||||
| 			{`(eq|lt|gt|le|ge|ne|not|and|or|cmp)\b`, OperatorWord, nil}, | ||||
| 			{`s/(\\\\|\\[^\\]|[^\\/])*/(\\\\|\\[^\\]|[^\\/])*/[egimosx]*`, LiteralStringRegex, nil}, | ||||
| 			{`s!(\\\\|\\!|[^!])*!(\\\\|\\!|[^!])*![egimosx]*`, LiteralStringRegex, nil}, | ||||
| 			{`s\\(\\\\|[^\\])*\\(\\\\|[^\\])*\\[egimosx]*`, LiteralStringRegex, nil}, | ||||
| 			{`s@(\\\\|\\[^\\]|[^\\@])*@(\\\\|\\[^\\]|[^\\@])*@[egimosx]*`, LiteralStringRegex, nil}, | ||||
| 			{`s%(\\\\|\\[^\\]|[^\\%])*%(\\\\|\\[^\\]|[^\\%])*%[egimosx]*`, LiteralStringRegex, nil}, | ||||
| 			{`s\{(\\\\|\\[^\\]|[^\\}])*\}\s*`, LiteralStringRegex, Push("balanced-regex")}, | ||||
| 			{`s<(\\\\|\\[^\\]|[^\\>])*>\s*`, LiteralStringRegex, Push("balanced-regex")}, | ||||
| 			{`s\[(\\\\|\\[^\\]|[^\\\]])*\]\s*`, LiteralStringRegex, Push("balanced-regex")}, | ||||
| 			{`s\((\\\\|\\[^\\]|[^\\)])*\)\s*`, LiteralStringRegex, Push("balanced-regex")}, | ||||
| 			{`m?/(\\\\|\\[^\\]|[^\\/\n])*/[gcimosx]*`, LiteralStringRegex, nil}, | ||||
| 			{`m(?=[/!\\{<\[(@%$])`, LiteralStringRegex, Push("balanced-regex")}, | ||||
| 			{`((?<==~)|(?<=\())\s*/(\\\\|\\[^\\]|[^\\/])*/[gcimosx]*`, LiteralStringRegex, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{Words(``, `\b`, `abs`, `accept`, `alarm`, `atan2`, `bind`, `binmode`, `bless`, `caller`, `chdir`, `chmod`, `chomp`, `chop`, `chown`, `chr`, `chroot`, `close`, `closedir`, `connect`, `continue`, `cos`, `crypt`, `dbmclose`, `dbmopen`, `defined`, `delete`, `die`, `dump`, `each`, `endgrent`, `endhostent`, `endnetent`, `endprotoent`, `endpwent`, `endservent`, `eof`, `eval`, `exec`, `exists`, `exit`, `exp`, `fcntl`, `fileno`, `flock`, `fork`, `format`, `formline`, `getc`, `getgrent`, `getgrgid`, `getgrnam`, `gethostbyaddr`, `gethostbyname`, `gethostent`, `getlogin`, `getnetbyaddr`, `getnetbyname`, `getnetent`, `getpeername`, `getpgrp`, `getppid`, `getpriority`, `getprotobyname`, `getprotobynumber`, `getprotoent`, `getpwent`, `getpwnam`, `getpwuid`, `getservbyname`, `getservbyport`, `getservent`, `getsockname`, `getsockopt`, `glob`, `gmtime`, `goto`, `grep`, `hex`, `import`, `index`, `int`, `ioctl`, `join`, `keys`, `kill`, `last`, `lc`, `lcfirst`, `length`, `link`, `listen`, `local`, `localtime`, `log`, `lstat`, `map`, `mkdir`, `msgctl`, `msgget`, `msgrcv`, `msgsnd`, `my`, `next`, `oct`, `open`, `opendir`, `ord`, `our`, `pack`, `pipe`, `pop`, `pos`, `printf`, `prototype`, `push`, `quotemeta`, `rand`, `read`, `readdir`, `readline`, `readlink`, `readpipe`, `recv`, `redo`, `ref`, `rename`, `reverse`, `rewinddir`, `rindex`, `rmdir`, `scalar`, `seek`, `seekdir`, `select`, `semctl`, `semget`, `semop`, `send`, `setgrent`, `sethostent`, `setnetent`, `setpgrp`, `setpriority`, `setprotoent`, `setpwent`, `setservent`, `setsockopt`, `shift`, `shmctl`, `shmget`, `shmread`, `shmwrite`, `shutdown`, `sin`, `sleep`, `socket`, `socketpair`, `sort`, `splice`, `split`, `sprintf`, `sqrt`, `srand`, `stat`, `study`, `substr`, `symlink`, `syscall`, `sysopen`, `sysread`, `sysseek`, `system`, `syswrite`, `tell`, `telldir`, `tie`, `tied`, `time`, `times`, `tr`, `truncate`, `uc`, `ucfirst`, `umask`, `undef`, `unlink`, `unpack`, `unshift`, `untie`, `utime`, `values`, `vec`, `wait`, `waitpid`, `wantarray`, `warn`, `write`), NameBuiltin, nil}, | ||||
| 			{`((__(DATA|DIE|WARN)__)|(STD(IN|OUT|ERR)))\b`, NameBuiltinPseudo, nil}, | ||||
| 			{`(<<)([\'"]?)([a-zA-Z_]\w*)(\2;?\n.*?\n)(\3)(\n)`, ByGroups(LiteralString, LiteralString, LiteralStringDelimiter, LiteralString, LiteralStringDelimiter, Text), nil}, | ||||
| 			{`__END__`, CommentPreproc, Push("end-part")}, | ||||
| 			{`\$\^[ADEFHILMOPSTWX]`, NameVariableGlobal, nil}, | ||||
| 			{"\\$[\\\\\\\"\\[\\]'&`+*.,;=%~?@$!<>(^|/-](?!\\w)", NameVariableGlobal, nil}, | ||||
| 			{`[$@%#]+`, NameVariable, Push("varname")}, | ||||
| 			{`0_?[0-7]+(_[0-7]+)*`, LiteralNumberOct, nil}, | ||||
| 			{`0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*`, LiteralNumberHex, nil}, | ||||
| 			{`0b[01]+(_[01]+)*`, LiteralNumberBin, nil}, | ||||
| 			{`(?i)(\d*(_\d*)*\.\d+(_\d*)*|\d+(_\d*)*\.\d+(_\d*)*)(e[+-]?\d+)?`, LiteralNumberFloat, nil}, | ||||
| 			{`(?i)\d+(_\d*)*e[+-]?\d+(_\d*)*`, LiteralNumberFloat, nil}, | ||||
| 			{`\d+(_\d+)*`, LiteralNumberInteger, nil}, | ||||
| 			{`'(\\\\|\\[^\\]|[^'\\])*'`, LiteralString, nil}, | ||||
| 			{`"(\\\\|\\[^\\]|[^"\\])*"`, LiteralString, nil}, | ||||
| 			{"`(\\\\\\\\|\\\\[^\\\\]|[^`\\\\])*`", LiteralStringBacktick, nil}, | ||||
| 			{`<([^\s>]+)>`, LiteralStringRegex, nil}, | ||||
| 			{`(q|qq|qw|qr|qx)\{`, LiteralStringOther, Push("cb-string")}, | ||||
| 			{`(q|qq|qw|qr|qx)\(`, LiteralStringOther, Push("rb-string")}, | ||||
| 			{`(q|qq|qw|qr|qx)\[`, LiteralStringOther, Push("sb-string")}, | ||||
| 			{`(q|qq|qw|qr|qx)\<`, LiteralStringOther, Push("lt-string")}, | ||||
| 			{`(q|qq|qw|qr|qx)([\W_])(.|\n)*?\2`, LiteralStringOther, nil}, | ||||
| 			{`(package)(\s+)([a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*)`, ByGroups(Keyword, Text, NameNamespace), nil}, | ||||
| 			{`(use|require|no)(\s+)([a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*)`, ByGroups(Keyword, Text, NameNamespace), nil}, | ||||
| 			{`(sub)(\s+)`, ByGroups(Keyword, Text), Push("funcname")}, | ||||
| 			{Words(``, `\b`, `no`, `package`, `require`, `use`), Keyword, nil}, | ||||
| 			{`(\[\]|\*\*|::|<<|>>|>=|<=>|<=|={3}|!=|=~|!~|&&?|\|\||\.{1,3})`, Operator, nil}, | ||||
| 			{`[-+/*%=<>&^|!\\~]=?`, Operator, nil}, | ||||
| 			{`[()\[\]:;,<>/?{}]`, Punctuation, nil}, | ||||
| 			{`(?=\w)`, Name, Push("name")}, | ||||
| 		}, | ||||
| 		"format": { | ||||
| 			{`\.\n`, LiteralStringInterpol, Pop(1)}, | ||||
| 			{`[^\n]*\n`, LiteralStringInterpol, nil}, | ||||
| 		}, | ||||
| 		"varname": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`\{`, Punctuation, Pop(1)}, | ||||
| 			{`\)|,`, Punctuation, Pop(1)}, | ||||
| 			{`\w+::`, NameNamespace, nil}, | ||||
| 			{`[\w:]+`, NameVariable, Pop(1)}, | ||||
| 		}, | ||||
| 		"name": { | ||||
| 			{`[a-zA-Z_]\w*(::[a-zA-Z_]\w*)*(::)?(?=\s*->)`, NameNamespace, Pop(1)}, | ||||
| 			{`[a-zA-Z_]\w*(::[a-zA-Z_]\w*)*::`, NameNamespace, Pop(1)}, | ||||
| 			{`[\w:]+`, Name, Pop(1)}, | ||||
| 			{`[A-Z_]+(?=\W)`, NameConstant, Pop(1)}, | ||||
| 			{`(?=\W)`, Text, Pop(1)}, | ||||
| 		}, | ||||
| 		"funcname": { | ||||
| 			{`[a-zA-Z_]\w*[!?]?`, NameFunction, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`(\([$@%]*\))(\s*)`, ByGroups(Punctuation, Text), nil}, | ||||
| 			{`;`, Punctuation, Pop(1)}, | ||||
| 			{`.*?\{`, Punctuation, Pop(1)}, | ||||
| 		}, | ||||
| 		"cb-string": { | ||||
| 			{`\\[{}\\]`, LiteralStringOther, nil}, | ||||
| 			{`\\`, LiteralStringOther, nil}, | ||||
| 			{`\{`, LiteralStringOther, Push("cb-string")}, | ||||
| 			{`\}`, LiteralStringOther, Pop(1)}, | ||||
| 			{`[^{}\\]+`, LiteralStringOther, nil}, | ||||
| 		}, | ||||
| 		"rb-string": { | ||||
| 			{`\\[()\\]`, LiteralStringOther, nil}, | ||||
| 			{`\\`, LiteralStringOther, nil}, | ||||
| 			{`\(`, LiteralStringOther, Push("rb-string")}, | ||||
| 			{`\)`, LiteralStringOther, Pop(1)}, | ||||
| 			{`[^()]+`, LiteralStringOther, nil}, | ||||
| 		}, | ||||
| 		"sb-string": { | ||||
| 			{`\\[\[\]\\]`, LiteralStringOther, nil}, | ||||
| 			{`\\`, LiteralStringOther, nil}, | ||||
| 			{`\[`, LiteralStringOther, Push("sb-string")}, | ||||
| 			{`\]`, LiteralStringOther, Pop(1)}, | ||||
| 			{`[^\[\]]+`, LiteralStringOther, nil}, | ||||
| 		}, | ||||
| 		"lt-string": { | ||||
| 			{`\\[<>\\]`, LiteralStringOther, nil}, | ||||
| 			{`\\`, LiteralStringOther, nil}, | ||||
| 			{`\<`, LiteralStringOther, Push("lt-string")}, | ||||
| 			{`\>`, LiteralStringOther, Pop(1)}, | ||||
| 			{`[^<>]+`, LiteralStringOther, nil}, | ||||
| 		}, | ||||
| 		"end-part": { | ||||
| 			{`.+`, CommentPreproc, Pop(1)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
| @@ -22,7 +22,7 @@ var Php = Register(MustNewLexer( | ||||
| 		}, | ||||
| 		"php": { | ||||
| 			{`\?>`, CommentPreproc, Pop(1)}, | ||||
| 			// {`(<<<)([\'"]?)((?:[\\_a-z]|[^\x00-\x7f])(?:[\\\w]|[^\x00-\x7f])*)(\2\n.*?\n\s*)(\3)(;?)(\n)`, ByGroups(LiteralString, LiteralString, LiteralStringDelimiter, LiteralString, LiteralStringDelimiter, Punctuation, Text), nil}, | ||||
| 			{`(<<<)([\'"]?)((?:[\\_a-z]|[^\x00-\x7f])(?:[\\\w]|[^\x00-\x7f])*)(\2\n.*?\n\s*)(\3)(;?)(\n)`, ByGroups(LiteralString, LiteralString, LiteralStringDelimiter, LiteralString, LiteralStringDelimiter, Punctuation, Text), nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`#.*?\n`, CommentSingle, nil}, | ||||
| 			{`//.*?\n`, CommentSingle, nil}, | ||||
| @@ -34,7 +34,7 @@ var Php = Register(MustNewLexer( | ||||
| 			{`\?`, Operator, nil}, | ||||
| 			{`[\[\]{}();,]+`, Punctuation, nil}, | ||||
| 			{`(class)(\s+)`, ByGroups(Keyword, Text), Push("classname")}, | ||||
| 			{`(function)(\s*)(\()`, ByGroups(Keyword, Text), Rewind()}, | ||||
| 			{`(function)(\s*)(?=\()`, ByGroups(Keyword, Text), nil}, | ||||
| 			{`(function)(\s+)(&?)(\s*)`, ByGroups(Keyword, Text, Operator, Text), Push("functionname")}, | ||||
| 			{`(const)(\s+)((?:[\\_a-z]|[^\x00-\x7f])(?:[\\\w]|[^\x00-\x7f])*)`, ByGroups(Keyword, Text, NameConstant), nil}, | ||||
| 			{`(and|E_PARSE|old_function|E_ERROR|or|as|E_WARNING|parent|eval|PHP_OS|break|exit|case|extends|PHP_VERSION|cfunction|FALSE|print|for|require|continue|foreach|require_once|declare|return|default|static|do|switch|die|stdClass|echo|else|TRUE|elseif|var|empty|if|xor|enddeclare|include|virtual|endfor|include_once|while|endforeach|global|endif|list|endswitch|new|endwhile|not|array|E_ALL|NULL|final|php_user_filter|interface|implements|public|private|protected|abstract|clone|try|catch|throw|this|use|namespace|trait|yield|finally)\b`, Keyword, nil}, | ||||
| @@ -54,10 +54,10 @@ var Php = Register(MustNewLexer( | ||||
| 			{`"`, LiteralStringDouble, Push("string")}, | ||||
| 		}, | ||||
| 		"magicfuncs": { | ||||
| 			{`(?:__construct|__destruct|__call|__callStatic|__get|__set|__isset|__unset|__sleep|__wakeup|__toString|__invoke|__set_state|__clone|__debugInfo)\b`, NameFunctionMagic, nil}, | ||||
| 			{Words(``, `\b`, `__construct`, `__destruct`, `__call`, `__callStatic`, `__get`, `__set`, `__isset`, `__unset`, `__sleep`, `__wakeup`, `__toString`, `__invoke`, `__set_state`, `__clone`, `__debugInfo`), NameFunctionMagic, nil}, | ||||
| 		}, | ||||
| 		"magicconstants": { | ||||
| 			{`(?:__LINE__|__FILE__|__DIR__|__FUNCTION__|__CLASS__|__TRAIT__|__METHOD__|__NAMESPACE__)\b`, NameConstant, nil}, | ||||
| 			{Words(``, `\b`, `__LINE__`, `__FILE__`, `__DIR__`, `__FUNCTION__`, `__CLASS__`, `__TRAIT__`, `__METHOD__`, `__NAMESPACE__`), NameConstant, nil}, | ||||
| 		}, | ||||
| 		"classname": { | ||||
| 			{`(?:[\\_a-z]|[^\x00-\x7f])(?:[\\\w]|[^\x00-\x7f])*`, NameClass, Pop(1)}, | ||||
|   | ||||
							
								
								
									
										56
									
								
								lexers/pig.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								lexers/pig.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Pig lexer. | ||||
| var Pig = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:            "Pig", | ||||
| 		Aliases:         []string{"pig"}, | ||||
| 		Filenames:       []string{"*.pig"}, | ||||
| 		MimeTypes:       []string{"text/x-pig"}, | ||||
| 		CaseInsensitive: true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`--.*`, Comment, nil}, | ||||
| 			{`/\*[\w\W]*?\*/`, CommentMultiline, nil}, | ||||
| 			{`\\\n`, Text, nil}, | ||||
| 			{`\\`, Text, nil}, | ||||
| 			{`\'(?:\\[ntbrf\\\']|\\u[0-9a-f]{4}|[^\'\\\n\r])*\'`, LiteralString, nil}, | ||||
| 			Include("keywords"), | ||||
| 			Include("types"), | ||||
| 			Include("builtins"), | ||||
| 			Include("punct"), | ||||
| 			Include("operators"), | ||||
| 			{`[0-9]*\.[0-9]+(e[0-9]+)?[fd]?`, LiteralNumberFloat, nil}, | ||||
| 			{`0x[0-9a-f]+`, LiteralNumberHex, nil}, | ||||
| 			{`[0-9]+L?`, LiteralNumberInteger, nil}, | ||||
| 			{`\n`, Text, nil}, | ||||
| 			{`([a-z_]\w*)(\s*)(\()`, ByGroups(NameFunction, Text, Punctuation), nil}, | ||||
| 			{`[()#:]`, Text, nil}, | ||||
| 			{`[^(:#\'")\s]+`, Text, nil}, | ||||
| 			{`\S+\s+`, Text, nil}, | ||||
| 		}, | ||||
| 		"keywords": { | ||||
| 			{`(assert|and|any|all|arrange|as|asc|bag|by|cache|CASE|cat|cd|cp|%declare|%default|define|dense|desc|describe|distinct|du|dump|eval|exex|explain|filter|flatten|foreach|full|generate|group|help|if|illustrate|import|inner|input|into|is|join|kill|left|limit|load|ls|map|matches|mkdir|mv|not|null|onschema|or|order|outer|output|parallel|pig|pwd|quit|register|returns|right|rm|rmf|rollup|run|sample|set|ship|split|stderr|stdin|stdout|store|stream|through|union|using|void)\b`, Keyword, nil}, | ||||
| 		}, | ||||
| 		"builtins": { | ||||
| 			{`(AVG|BinStorage|cogroup|CONCAT|copyFromLocal|copyToLocal|COUNT|cross|DIFF|MAX|MIN|PigDump|PigStorage|SIZE|SUM|TextLoader|TOKENIZE)\b`, NameBuiltin, nil}, | ||||
| 		}, | ||||
| 		"types": { | ||||
| 			{`(bytearray|BIGINTEGER|BIGDECIMAL|chararray|datetime|double|float|int|long|tuple)\b`, KeywordType, nil}, | ||||
| 		}, | ||||
| 		"punct": { | ||||
| 			{`[;(){}\[\]]`, Punctuation, nil}, | ||||
| 		}, | ||||
| 		"operators": { | ||||
| 			{`[#=,./%+\-?]`, Operator, nil}, | ||||
| 			{`(eq|gt|lt|gte|lte|neq|matches)\b`, Operator, nil}, | ||||
| 			{`(==|<=|<|>=|>|!=)`, Operator, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										40
									
								
								lexers/pkgconfig.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								lexers/pkgconfig.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Pkgconfig lexer. | ||||
| var Pkgconfig = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "PkgConfig", | ||||
| 		Aliases:   []string{"pkgconfig"}, | ||||
| 		Filenames: []string{"*.pc"}, | ||||
| 		MimeTypes: []string{}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`#.*$`, CommentSingle, nil}, | ||||
| 			{`^(\w+)(=)`, ByGroups(NameAttribute, Operator), nil}, | ||||
| 			{`^([\w.]+)(:)`, ByGroups(NameTag, Punctuation), Push("spvalue")}, | ||||
| 			Include("interp"), | ||||
| 			{`[^${}#=:\n.]+`, Text, nil}, | ||||
| 			{`.`, Text, nil}, | ||||
| 		}, | ||||
| 		"interp": { | ||||
| 			{`\$\$`, Text, nil}, | ||||
| 			{`\$\{`, LiteralStringInterpol, Push("curly")}, | ||||
| 		}, | ||||
| 		"curly": { | ||||
| 			{`\}`, LiteralStringInterpol, Pop(1)}, | ||||
| 			{`\w+`, NameAttribute, nil}, | ||||
| 		}, | ||||
| 		"spvalue": { | ||||
| 			Include("interp"), | ||||
| 			{`#.*$`, CommentSingle, Pop(1)}, | ||||
| 			{`\n`, Text, Pop(1)}, | ||||
| 			{`[^${}#\n]+`, Text, nil}, | ||||
| 			{`.`, Text, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										57
									
								
								lexers/plsql.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								lexers/plsql.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Pl/Pgsql lexer. | ||||
| var PLpgSQL = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:            "PL/pgSQL", | ||||
| 		Aliases:         []string{"plpgsql"}, | ||||
| 		Filenames:       []string{}, | ||||
| 		MimeTypes:       []string{"text/x-plpgsql"}, | ||||
| 		NotMultiline:    true, | ||||
| 		CaseInsensitive: true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\%[a-z]\w*\b`, NameBuiltin, nil}, | ||||
| 			{`:=`, Operator, nil}, | ||||
| 			{`\<\<[a-z]\w*\>\>`, NameLabel, nil}, | ||||
| 			{`\#[a-z]\w*\b`, KeywordPseudo, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`--.*\n?`, CommentSingle, nil}, | ||||
| 			{`/\*`, CommentMultiline, Push("multiline-comments")}, | ||||
| 			{`(bigint|bigserial|bit|bit\s+varying|bool|boolean|box|bytea|char|character|character\s+varying|cidr|circle|date|decimal|double\s+precision|float4|float8|inet|int|int2|int4|int8|integer|interval|json|jsonb|line|lseg|macaddr|money|numeric|path|pg_lsn|point|polygon|real|serial|serial2|serial4|serial8|smallint|smallserial|text|time|timestamp|timestamptz|timetz|tsquery|tsvector|txid_snapshot|uuid|varbit|varchar|with\s+time\s+zone|without\s+time\s+zone|xml|anyarray|anyelement|anyenum|anynonarray|anyrange|cstring|fdw_handler|internal|language_handler|opaque|record|void)\b`, NameBuiltin, nil}, | ||||
| 			{Words(``, `\b`, `ABORT`, `ABSOLUTE`, `ACCESS`, `ACTION`, `ADD`, `ADMIN`, `AFTER`, `AGGREGATE`, `ALL`, `ALSO`, `ALTER`, `ALWAYS`, `ANALYSE`, `ANALYZE`, `AND`, `ANY`, `ARRAY`, `AS`, `ASC`, `ASSERTION`, `ASSIGNMENT`, `ASYMMETRIC`, `AT`, `ATTRIBUTE`, `AUTHORIZATION`, `BACKWARD`, `BEFORE`, `BEGIN`, `BETWEEN`, `BIGINT`, `BINARY`, `BIT`, `BOOLEAN`, `BOTH`, `BY`, `CACHE`, `CALLED`, `CASCADE`, `CASCADED`, `CASE`, `CAST`, `CATALOG`, `CHAIN`, `CHAR`, `CHARACTER`, `CHARACTERISTICS`, `CHECK`, `CHECKPOINT`, `CLASS`, `CLOSE`, `CLUSTER`, `COALESCE`, `COLLATE`, `COLLATION`, `COLUMN`, `COMMENT`, `COMMENTS`, `COMMIT`, `COMMITTED`, `CONCURRENTLY`, `CONFIGURATION`, `CONNECTION`, `CONSTRAINT`, `CONSTRAINTS`, `CONTENT`, `CONTINUE`, `CONVERSION`, `COPY`, `COST`, `CREATE`, `CROSS`, `CSV`, `CURRENT`, `CURRENT_CATALOG`, `CURRENT_DATE`, `CURRENT_ROLE`, `CURRENT_SCHEMA`, `CURRENT_TIME`, `CURRENT_TIMESTAMP`, `CURRENT_USER`, `CURSOR`, `CYCLE`, `DATA`, `DATABASE`, `DAY`, `DEALLOCATE`, `DEC`, `DECIMAL`, `DECLARE`, `DEFAULT`, `DEFAULTS`, `DEFERRABLE`, `DEFERRED`, `DEFINER`, `DELETE`, `DELIMITER`, `DELIMITERS`, `DESC`, `DICTIONARY`, `DISABLE`, `DISCARD`, `DISTINCT`, `DO`, `DOCUMENT`, `DOMAIN`, `DOUBLE`, `DROP`, `EACH`, `ELSE`, `ENABLE`, `ENCODING`, `ENCRYPTED`, `END`, `ENUM`, `ESCAPE`, `EVENT`, `EXCEPT`, `EXCLUDE`, `EXCLUDING`, `EXCLUSIVE`, `EXECUTE`, `EXISTS`, `EXPLAIN`, `EXTENSION`, `EXTERNAL`, `EXTRACT`, `FALSE`, `FAMILY`, `FETCH`, `FILTER`, `FIRST`, `FLOAT`, `FOLLOWING`, `FOR`, `FORCE`, `FOREIGN`, `FORWARD`, `FREEZE`, `FROM`, `FULL`, `FUNCTION`, `FUNCTIONS`, `GLOBAL`, `GRANT`, `GRANTED`, `GREATEST`, `GROUP`, `HANDLER`, `HAVING`, `HEADER`, `HOLD`, `HOUR`, `IDENTITY`, `IF`, `ILIKE`, `IMMEDIATE`, `IMMUTABLE`, `IMPLICIT`, `IN`, `INCLUDING`, `INCREMENT`, `INDEX`, `INDEXES`, `INHERIT`, `INHERITS`, `INITIALLY`, `INLINE`, `INNER`, `INOUT`, `INPUT`, `INSENSITIVE`, `INSERT`, `INSTEAD`, `INT`, `INTEGER`, `INTERSECT`, `INTERVAL`, `INTO`, `INVOKER`, `IS`, `ISNULL`, `ISOLATION`, `JOIN`, `KEY`, `LABEL`, `LANGUAGE`, `LARGE`, `LAST`, `LATERAL`, `LC_COLLATE`, `LC_CTYPE`, `LEADING`, `LEAKPROOF`, `LEAST`, `LEFT`, `LEVEL`, `LIKE`, `LIMIT`, `LISTEN`, `LOAD`, `LOCAL`, `LOCALTIME`, `LOCALTIMESTAMP`, `LOCATION`, `LOCK`, `MAPPING`, `MATCH`, `MATERIALIZED`, `MAXVALUE`, `MINUTE`, `MINVALUE`, `MODE`, `MONTH`, `MOVE`, `NAME`, `NAMES`, `NATIONAL`, `NATURAL`, `NCHAR`, `NEXT`, `NO`, `NONE`, `NOT`, `NOTHING`, `NOTIFY`, `NOTNULL`, `NOWAIT`, `NULL`, `NULLIF`, `NULLS`, `NUMERIC`, `OBJECT`, `OF`, `OFF`, `OFFSET`, `OIDS`, `ON`, `ONLY`, `OPERATOR`, `OPTION`, `OPTIONS`, `OR`, `ORDER`, `ORDINALITY`, `OUT`, `OUTER`, `OVER`, `OVERLAPS`, `OVERLAY`, `OWNED`, `OWNER`, `PARSER`, `PARTIAL`, `PARTITION`, `PASSING`, `PASSWORD`, `PLACING`, `PLANS`, `POLICY`, `POSITION`, `PRECEDING`, `PRECISION`, `PREPARE`, `PREPARED`, `PRESERVE`, `PRIMARY`, `PRIOR`, `PRIVILEGES`, `PROCEDURAL`, `PROCEDURE`, `PROGRAM`, `QUOTE`, `RANGE`, `READ`, `REAL`, `REASSIGN`, `RECHECK`, `RECURSIVE`, `REF`, `REFERENCES`, `REFRESH`, `REINDEX`, `RELATIVE`, `RELEASE`, `RENAME`, `REPEATABLE`, `REPLACE`, `REPLICA`, `RESET`, `RESTART`, `RESTRICT`, `RETURNING`, `RETURNS`, `REVOKE`, `RIGHT`, `ROLE`, `ROLLBACK`, `ROW`, `ROWS`, `RULE`, `SAVEPOINT`, `SCHEMA`, `SCROLL`, `SEARCH`, `SECOND`, `SECURITY`, `SELECT`, `SEQUENCE`, `SEQUENCES`, `SERIALIZABLE`, `SERVER`, `SESSION`, `SESSION_USER`, `SET`, `SETOF`, `SHARE`, `SHOW`, `SIMILAR`, `SIMPLE`, `SMALLINT`, `SNAPSHOT`, `SOME`, `STABLE`, `STANDALONE`, `START`, `STATEMENT`, `STATISTICS`, `STDIN`, `STDOUT`, `STORAGE`, `STRICT`, `STRIP`, `SUBSTRING`, `SYMMETRIC`, `SYSID`, `SYSTEM`, `TABLE`, `TABLES`, `TABLESPACE`, `TEMP`, `TEMPLATE`, `TEMPORARY`, `TEXT`, `THEN`, `TIME`, `TIMESTAMP`, `TO`, `TRAILING`, `TRANSACTION`, `TREAT`, `TRIGGER`, `TRIM`, `TRUE`, `TRUNCATE`, `TRUSTED`, `TYPE`, `TYPES`, `UNBOUNDED`, `UNCOMMITTED`, `UNENCRYPTED`, `UNION`, `UNIQUE`, `UNKNOWN`, `UNLISTEN`, `UNLOGGED`, `UNTIL`, `UPDATE`, `USER`, `USING`, `VACUUM`, `VALID`, `VALIDATE`, `VALIDATOR`, `VALUE`, `VALUES`, `VARCHAR`, `VARIADIC`, `VARYING`, `VERBOSE`, `VERSION`, `VIEW`, `VIEWS`, `VOLATILE`, `WHEN`, `WHERE`, `WHITESPACE`, `WINDOW`, `WITH`, `WITHIN`, `WITHOUT`, `WORK`, `WRAPPER`, `WRITE`, `XML`, `XMLATTRIBUTES`, `XMLCONCAT`, `XMLELEMENT`, `XMLEXISTS`, `XMLFOREST`, `XMLPARSE`, `XMLPI`, `XMLROOT`, `XMLSERIALIZE`, `YEAR`, `YES`, `ZONE`, `ALIAS`, `CONSTANT`, `DIAGNOSTICS`, `ELSIF`, `EXCEPTION`, `EXIT`, `FOREACH`, `GET`, `LOOP`, `NOTICE`, `OPEN`, `PERFORM`, `QUERY`, `RAISE`, `RETURN`, `REVERSE`, `SQLSTATE`, `WHILE`), Keyword, nil}, | ||||
| 			{"[+*/<>=~!@#%^&|`?-]+", Operator, nil}, | ||||
| 			{`::`, Operator, nil}, | ||||
| 			{`\$\d+`, NameVariable, nil}, | ||||
| 			{`([0-9]*\.[0-9]*|[0-9]+)(e[+-]?[0-9]+)?`, LiteralNumberFloat, nil}, | ||||
| 			{`[0-9]+`, LiteralNumberInteger, nil}, | ||||
| 			{`((?:E|U&)?)(')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Push("string")}, | ||||
| 			{`((?:U&)?)(")`, ByGroups(LiteralStringAffix, LiteralStringName), Push("quoted-ident")}, | ||||
| 			// { `(?s)(\$)([^$]*)(\$)(.*?)(\$)(\2)(\$)`, ?? <function language_callback at 0x108964400> ??, nil }, | ||||
| 			{`[a-z_]\w*`, Name, nil}, | ||||
| 			{`:(['"]?)[a-z]\w*\b\1`, NameVariable, nil}, | ||||
| 			{`[;:()\[\]{},.]`, Punctuation, nil}, | ||||
| 		}, | ||||
| 		"multiline-comments": { | ||||
| 			{`/\*`, CommentMultiline, Push("multiline-comments")}, | ||||
| 			{`\*/`, CommentMultiline, Pop(1)}, | ||||
| 			{`[^/*]+`, CommentMultiline, nil}, | ||||
| 			{`[/*]`, CommentMultiline, nil}, | ||||
| 		}, | ||||
| 		"string": { | ||||
| 			{`[^']+`, LiteralStringSingle, nil}, | ||||
| 			{`''`, LiteralStringSingle, nil}, | ||||
| 			{`'`, LiteralStringSingle, Pop(1)}, | ||||
| 		}, | ||||
| 		"quoted-ident": { | ||||
| 			{`[^"]+`, LiteralStringName, nil}, | ||||
| 			{`""`, LiteralStringName, nil}, | ||||
| 			{`"`, LiteralStringName, Pop(1)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										53
									
								
								lexers/postgres.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								lexers/postgres.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,53 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Postgresql Sql Dialect lexer. | ||||
| var PostgreSQL = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:            "PostgreSQL SQL dialect", | ||||
| 		Aliases:         []string{"postgresql", "postgres"}, | ||||
| 		Filenames:       []string{}, | ||||
| 		MimeTypes:       []string{"text/x-postgresql"}, | ||||
| 		NotMultiline:    true, | ||||
| 		CaseInsensitive: true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`--.*\n?`, CommentSingle, nil}, | ||||
| 			{`/\*`, CommentMultiline, Push("multiline-comments")}, | ||||
| 			{`(bigint|bigserial|bit|bit\s+varying|bool|boolean|box|bytea|char|character|character\s+varying|cidr|circle|date|decimal|double\s+precision|float4|float8|inet|int|int2|int4|int8|integer|interval|json|jsonb|line|lseg|macaddr|money|numeric|path|pg_lsn|point|polygon|real|serial|serial2|serial4|serial8|smallint|smallserial|text|time|timestamp|timestamptz|timetz|tsquery|tsvector|txid_snapshot|uuid|varbit|varchar|with\s+time\s+zone|without\s+time\s+zone|xml|anyarray|anyelement|anyenum|anynonarray|anyrange|cstring|fdw_handler|internal|language_handler|opaque|record|void)\b`, NameBuiltin, nil}, | ||||
| 			{Words(``, `\b`, `ABORT`, `ABSOLUTE`, `ACCESS`, `ACTION`, `ADD`, `ADMIN`, `AFTER`, `AGGREGATE`, `ALL`, `ALSO`, `ALTER`, `ALWAYS`, `ANALYSE`, `ANALYZE`, `AND`, `ANY`, `ARRAY`, `AS`, `ASC`, `ASSERTION`, `ASSIGNMENT`, `ASYMMETRIC`, `AT`, `ATTRIBUTE`, `AUTHORIZATION`, `BACKWARD`, `BEFORE`, `BEGIN`, `BETWEEN`, `BIGINT`, `BINARY`, `BIT`, `BOOLEAN`, `BOTH`, `BY`, `CACHE`, `CALLED`, `CASCADE`, `CASCADED`, `CASE`, `CAST`, `CATALOG`, `CHAIN`, `CHAR`, `CHARACTER`, `CHARACTERISTICS`, `CHECK`, `CHECKPOINT`, `CLASS`, `CLOSE`, `CLUSTER`, `COALESCE`, `COLLATE`, `COLLATION`, `COLUMN`, `COMMENT`, `COMMENTS`, `COMMIT`, `COMMITTED`, `CONCURRENTLY`, `CONFIGURATION`, `CONNECTION`, `CONSTRAINT`, `CONSTRAINTS`, `CONTENT`, `CONTINUE`, `CONVERSION`, `COPY`, `COST`, `CREATE`, `CROSS`, `CSV`, `CURRENT`, `CURRENT_CATALOG`, `CURRENT_DATE`, `CURRENT_ROLE`, `CURRENT_SCHEMA`, `CURRENT_TIME`, `CURRENT_TIMESTAMP`, `CURRENT_USER`, `CURSOR`, `CYCLE`, `DATA`, `DATABASE`, `DAY`, `DEALLOCATE`, `DEC`, `DECIMAL`, `DECLARE`, `DEFAULT`, `DEFAULTS`, `DEFERRABLE`, `DEFERRED`, `DEFINER`, `DELETE`, `DELIMITER`, `DELIMITERS`, `DESC`, `DICTIONARY`, `DISABLE`, `DISCARD`, `DISTINCT`, `DO`, `DOCUMENT`, `DOMAIN`, `DOUBLE`, `DROP`, `EACH`, `ELSE`, `ENABLE`, `ENCODING`, `ENCRYPTED`, `END`, `ENUM`, `ESCAPE`, `EVENT`, `EXCEPT`, `EXCLUDE`, `EXCLUDING`, `EXCLUSIVE`, `EXECUTE`, `EXISTS`, `EXPLAIN`, `EXTENSION`, `EXTERNAL`, `EXTRACT`, `FALSE`, `FAMILY`, `FETCH`, `FILTER`, `FIRST`, `FLOAT`, `FOLLOWING`, `FOR`, `FORCE`, `FOREIGN`, `FORWARD`, `FREEZE`, `FROM`, `FULL`, `FUNCTION`, `FUNCTIONS`, `GLOBAL`, `GRANT`, `GRANTED`, `GREATEST`, `GROUP`, `HANDLER`, `HAVING`, `HEADER`, `HOLD`, `HOUR`, `IDENTITY`, `IF`, `ILIKE`, `IMMEDIATE`, `IMMUTABLE`, `IMPLICIT`, `IN`, `INCLUDING`, `INCREMENT`, `INDEX`, `INDEXES`, `INHERIT`, `INHERITS`, `INITIALLY`, `INLINE`, `INNER`, `INOUT`, `INPUT`, `INSENSITIVE`, `INSERT`, `INSTEAD`, `INT`, `INTEGER`, `INTERSECT`, `INTERVAL`, `INTO`, `INVOKER`, `IS`, `ISNULL`, `ISOLATION`, `JOIN`, `KEY`, `LABEL`, `LANGUAGE`, `LARGE`, `LAST`, `LATERAL`, `LC_COLLATE`, `LC_CTYPE`, `LEADING`, `LEAKPROOF`, `LEAST`, `LEFT`, `LEVEL`, `LIKE`, `LIMIT`, `LISTEN`, `LOAD`, `LOCAL`, `LOCALTIME`, `LOCALTIMESTAMP`, `LOCATION`, `LOCK`, `MAPPING`, `MATCH`, `MATERIALIZED`, `MAXVALUE`, `MINUTE`, `MINVALUE`, `MODE`, `MONTH`, `MOVE`, `NAME`, `NAMES`, `NATIONAL`, `NATURAL`, `NCHAR`, `NEXT`, `NO`, `NONE`, `NOT`, `NOTHING`, `NOTIFY`, `NOTNULL`, `NOWAIT`, `NULL`, `NULLIF`, `NULLS`, `NUMERIC`, `OBJECT`, `OF`, `OFF`, `OFFSET`, `OIDS`, `ON`, `ONLY`, `OPERATOR`, `OPTION`, `OPTIONS`, `OR`, `ORDER`, `ORDINALITY`, `OUT`, `OUTER`, `OVER`, `OVERLAPS`, `OVERLAY`, `OWNED`, `OWNER`, `PARSER`, `PARTIAL`, `PARTITION`, `PASSING`, `PASSWORD`, `PLACING`, `PLANS`, `POLICY`, `POSITION`, `PRECEDING`, `PRECISION`, `PREPARE`, `PREPARED`, `PRESERVE`, `PRIMARY`, `PRIOR`, `PRIVILEGES`, `PROCEDURAL`, `PROCEDURE`, `PROGRAM`, `QUOTE`, `RANGE`, `READ`, `REAL`, `REASSIGN`, `RECHECK`, `RECURSIVE`, `REF`, `REFERENCES`, `REFRESH`, `REINDEX`, `RELATIVE`, `RELEASE`, `RENAME`, `REPEATABLE`, `REPLACE`, `REPLICA`, `RESET`, `RESTART`, `RESTRICT`, `RETURNING`, `RETURNS`, `REVOKE`, `RIGHT`, `ROLE`, `ROLLBACK`, `ROW`, `ROWS`, `RULE`, `SAVEPOINT`, `SCHEMA`, `SCROLL`, `SEARCH`, `SECOND`, `SECURITY`, `SELECT`, `SEQUENCE`, `SEQUENCES`, `SERIALIZABLE`, `SERVER`, `SESSION`, `SESSION_USER`, `SET`, `SETOF`, `SHARE`, `SHOW`, `SIMILAR`, `SIMPLE`, `SMALLINT`, `SNAPSHOT`, `SOME`, `STABLE`, `STANDALONE`, `START`, `STATEMENT`, `STATISTICS`, `STDIN`, `STDOUT`, `STORAGE`, `STRICT`, `STRIP`, `SUBSTRING`, `SYMMETRIC`, `SYSID`, `SYSTEM`, `TABLE`, `TABLES`, `TABLESPACE`, `TEMP`, `TEMPLATE`, `TEMPORARY`, `TEXT`, `THEN`, `TIME`, `TIMESTAMP`, `TO`, `TRAILING`, `TRANSACTION`, `TREAT`, `TRIGGER`, `TRIM`, `TRUE`, `TRUNCATE`, `TRUSTED`, `TYPE`, `TYPES`, `UNBOUNDED`, `UNCOMMITTED`, `UNENCRYPTED`, `UNION`, `UNIQUE`, `UNKNOWN`, `UNLISTEN`, `UNLOGGED`, `UNTIL`, `UPDATE`, `USER`, `USING`, `VACUUM`, `VALID`, `VALIDATE`, `VALIDATOR`, `VALUE`, `VALUES`, `VARCHAR`, `VARIADIC`, `VARYING`, `VERBOSE`, `VERSION`, `VIEW`, `VIEWS`, `VOLATILE`, `WHEN`, `WHERE`, `WHITESPACE`, `WINDOW`, `WITH`, `WITHIN`, `WITHOUT`, `WORK`, `WRAPPER`, `WRITE`, `XML`, `XMLATTRIBUTES`, `XMLCONCAT`, `XMLELEMENT`, `XMLEXISTS`, `XMLFOREST`, `XMLPARSE`, `XMLPI`, `XMLROOT`, `XMLSERIALIZE`, `YEAR`, `YES`, `ZONE`), Keyword, nil}, | ||||
| 			{"[+*/<>=~!@#%^&|`?-]+", Operator, nil}, | ||||
| 			{`::`, Operator, nil}, | ||||
| 			{`\$\d+`, NameVariable, nil}, | ||||
| 			{`([0-9]*\.[0-9]*|[0-9]+)(e[+-]?[0-9]+)?`, LiteralNumberFloat, nil}, | ||||
| 			{`[0-9]+`, LiteralNumberInteger, nil}, | ||||
| 			{`((?:E|U&)?)(')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Push("string")}, | ||||
| 			{`((?:U&)?)(")`, ByGroups(LiteralStringAffix, LiteralStringName), Push("quoted-ident")}, | ||||
| 			// { `(?s)(\$)([^$]*)(\$)(.*?)(\$)(\2)(\$)`, ?? <function language_callback at 0x101105400> ??, nil }, | ||||
| 			{`[a-z_]\w*`, Name, nil}, | ||||
| 			{`:(['"]?)[a-z]\w*\b\1`, NameVariable, nil}, | ||||
| 			{`[;:()\[\]{},.]`, Punctuation, nil}, | ||||
| 		}, | ||||
| 		"multiline-comments": { | ||||
| 			{`/\*`, CommentMultiline, Push("multiline-comments")}, | ||||
| 			{`\*/`, CommentMultiline, Pop(1)}, | ||||
| 			{`[^/*]+`, CommentMultiline, nil}, | ||||
| 			{`[/*]`, CommentMultiline, nil}, | ||||
| 		}, | ||||
| 		"string": { | ||||
| 			{`[^']+`, LiteralStringSingle, nil}, | ||||
| 			{`''`, LiteralStringSingle, nil}, | ||||
| 			{`'`, LiteralStringSingle, Pop(1)}, | ||||
| 		}, | ||||
| 		"quoted-ident": { | ||||
| 			{`[^"]+`, LiteralStringName, nil}, | ||||
| 			{`""`, LiteralStringName, nil}, | ||||
| 			{`"`, LiteralStringName, Pop(1)}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										45
									
								
								lexers/postscript.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								lexers/postscript.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Postscript lexer. | ||||
| var Postscript = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "PostScript", | ||||
| 		Aliases:   []string{"postscript", "postscr"}, | ||||
| 		Filenames: []string{"*.ps", "*.eps"}, | ||||
| 		MimeTypes: []string{"application/postscript"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`^%!.+\n`, CommentPreproc, nil}, | ||||
| 			{`%%.*\n`, CommentSpecial, nil}, | ||||
| 			{`(^%.*\n){2,}`, CommentMultiline, nil}, | ||||
| 			{`%.*\n`, CommentSingle, nil}, | ||||
| 			{`\(`, LiteralString, Push("stringliteral")}, | ||||
| 			{`[{}<>\[\]]`, Punctuation, nil}, | ||||
| 			{`<[0-9A-Fa-f]+>(?=[()<>\[\]{}/%\s])`, LiteralNumberHex, nil}, | ||||
| 			{`[0-9]+\#(\-|\+)?([0-9]+\.?|[0-9]*\.[0-9]+|[0-9]+\.[0-9]*)((e|E)[0-9]+)?(?=[()<>\[\]{}/%\s])`, LiteralNumberOct, nil}, | ||||
| 			{`(\-|\+)?([0-9]+\.?|[0-9]*\.[0-9]+|[0-9]+\.[0-9]*)((e|E)[0-9]+)?(?=[()<>\[\]{}/%\s])`, LiteralNumberFloat, nil}, | ||||
| 			{`(\-|\+)?[0-9]+(?=[()<>\[\]{}/%\s])`, LiteralNumberInteger, nil}, | ||||
| 			{`\/[^()<>\[\]{}/%\s]+(?=[()<>\[\]{}/%\s])`, NameVariable, nil}, | ||||
| 			{`[^()<>\[\]{}/%\s]+(?=[()<>\[\]{}/%\s])`, NameFunction, nil}, | ||||
| 			{`(false|true)(?=[()<>\[\]{}/%\s])`, KeywordConstant, nil}, | ||||
| 			{`(eq|ne|g[et]|l[et]|and|or|not|if(?:else)?|for(?:all)?)(?=[()<>\[\]{}/%\s])`, KeywordReserved, nil}, | ||||
| 			{Words(``, `(?=[()<>\[\]{}/%\s])`, `abs`, `add`, `aload`, `arc`, `arcn`, `array`, `atan`, `begin`, `bind`, `ceiling`, `charpath`, `clip`, `closepath`, `concat`, `concatmatrix`, `copy`, `cos`, `currentlinewidth`, `currentmatrix`, `currentpoint`, `curveto`, `cvi`, `cvs`, `def`, `defaultmatrix`, `dict`, `dictstackoverflow`, `div`, `dtransform`, `dup`, `end`, `exch`, `exec`, `exit`, `exp`, `fill`, `findfont`, `floor`, `get`, `getinterval`, `grestore`, `gsave`, `gt`, `identmatrix`, `idiv`, `idtransform`, `index`, `invertmatrix`, `itransform`, `length`, `lineto`, `ln`, `load`, `log`, `loop`, `matrix`, `mod`, `moveto`, `mul`, `neg`, `newpath`, `pathforall`, `pathbbox`, `pop`, `print`, `pstack`, `put`, `quit`, `rand`, `rangecheck`, `rcurveto`, `repeat`, `restore`, `rlineto`, `rmoveto`, `roll`, `rotate`, `round`, `run`, `save`, `scale`, `scalefont`, `setdash`, `setfont`, `setgray`, `setlinecap`, `setlinejoin`, `setlinewidth`, `setmatrix`, `setrgbcolor`, `shfill`, `show`, `showpage`, `sin`, `sqrt`, `stack`, `stringwidth`, `stroke`, `strokepath`, `sub`, `syntaxerror`, `transform`, `translate`, `truncate`, `typecheck`, `undefined`, `undefinedfilename`, `undefinedresult`), NameBuiltin, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 		}, | ||||
| 		"stringliteral": { | ||||
| 			{`[^()\\]+`, LiteralString, nil}, | ||||
| 			{`\\`, LiteralStringEscape, Push("escape")}, | ||||
| 			{`\(`, LiteralString, Push()}, | ||||
| 			{`\)`, LiteralString, Pop(1)}, | ||||
| 		}, | ||||
| 		"escape": { | ||||
| 			{`[0-8]{3}|n|r|t|b|f|\\|\(|\)`, LiteralStringEscape, Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										34
									
								
								lexers/povray.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								lexers/povray.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Povray lexer. | ||||
| var Povray = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "POVRay", | ||||
| 		Aliases:   []string{"pov"}, | ||||
| 		Filenames: []string{"*.pov", "*.inc"}, | ||||
| 		MimeTypes: []string{"text/x-povray"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`/\*[\w\W]*?\*/`, CommentMultiline, nil}, | ||||
| 			{`//.*\n`, CommentSingle, nil}, | ||||
| 			{`(?s)"(?:\\.|[^"\\])+"`, LiteralStringDouble, nil}, | ||||
| 			{Words(`#`, `\b`, `break`, `case`, `debug`, `declare`, `default`, `define`, `else`, `elseif`, `end`, `error`, `fclose`, `fopen`, `for`, `if`, `ifdef`, `ifndef`, `include`, `local`, `macro`, `range`, `read`, `render`, `statistics`, `switch`, `undef`, `version`, `warning`, `while`, `write`), CommentPreproc, nil}, | ||||
| 			{Words(`\b`, `\b`, `aa_level`, `aa_threshold`, `abs`, `acos`, `acosh`, `adaptive`, `adc_bailout`, `agate`, `agate_turb`, `all`, `alpha`, `ambient`, `ambient_light`, `angle`, `aperture`, `arc_angle`, `area_light`, `asc`, `asin`, `asinh`, `assumed_gamma`, `atan`, `atan2`, `atanh`, `atmosphere`, `atmospheric_attenuation`, `attenuating`, `average`, `background`, `black_hole`, `blue`, `blur_samples`, `bounded_by`, `box_mapping`, `bozo`, `break`, `brick`, `brick_size`, `brightness`, `brilliance`, `bumps`, `bumpy1`, `bumpy2`, `bumpy3`, `bump_map`, `bump_size`, `case`, `caustics`, `ceil`, `checker`, `chr`, `clipped_by`, `clock`, `color`, `color_map`, `colour`, `colour_map`, `component`, `composite`, `concat`, `confidence`, `conic_sweep`, `constant`, `control0`, `control1`, `cos`, `cosh`, `count`, `crackle`, `crand`, `cube`, `cubic_spline`, `cylindrical_mapping`, `debug`, `declare`, `default`, `degrees`, `dents`, `diffuse`, `direction`, `distance`, `distance_maximum`, `div`, `dust`, `dust_type`, `eccentricity`, `else`, `emitting`, `end`, `error`, `error_bound`, `exp`, `exponent`, `fade_distance`, `fade_power`, `falloff`, `falloff_angle`, `false`, `file_exists`, `filter`, `finish`, `fisheye`, `flatness`, `flip`, `floor`, `focal_point`, `fog`, `fog_alt`, `fog_offset`, `fog_type`, `frequency`, `gif`, `global_settings`, `glowing`, `gradient`, `granite`, `gray_threshold`, `green`, `halo`, `hexagon`, `hf_gray_16`, `hierarchy`, `hollow`, `hypercomplex`, `if`, `ifdef`, `iff`, `image_map`, `incidence`, `include`, `int`, `interpolate`, `inverse`, `ior`, `irid`, `irid_wavelength`, `jitter`, `lambda`, `leopard`, `linear`, `linear_spline`, `linear_sweep`, `location`, `log`, `looks_like`, `look_at`, `low_error_factor`, `mandel`, `map_type`, `marble`, `material_map`, `matrix`, `max`, `max_intersections`, `max_iteration`, `max_trace_level`, `max_value`, `metallic`, `min`, `minimum_reuse`, `mod`, `mortar`, `nearest_count`, `no`, `normal`, `normal_map`, `no_shadow`, `number_of_waves`, `octaves`, `off`, `offset`, `omega`, `omnimax`, `on`, `once`, `onion`, `open`, `orthographic`, `panoramic`, `pattern1`, `pattern2`, `pattern3`, `perspective`, `pgm`, `phase`, `phong`, `phong_size`, `pi`, `pigment`, `pigment_map`, `planar_mapping`, `png`, `point_at`, `pot`, `pow`, `ppm`, `precision`, `pwr`, `quadratic_spline`, `quaternion`, `quick_color`, `quick_colour`, `quilted`, `radial`, `radians`, `radiosity`, `radius`, `rainbow`, `ramp_wave`, `rand`, `range`, `reciprocal`, `recursion_limit`, `red`, `reflection`, `refraction`, `render`, `repeat`, `rgb`, `rgbf`, `rgbft`, `rgbt`, `right`, `ripples`, `rotate`, `roughness`, `samples`, `scale`, `scallop_wave`, `scattering`, `seed`, `shadowless`, `sin`, `sine_wave`, `sinh`, `sky`, `sky_sphere`, `slice`, `slope_map`, `smooth`, `specular`, `spherical_mapping`, `spiral`, `spiral1`, `spiral2`, `spotlight`, `spotted`, `sqr`, `sqrt`, `statistics`, `str`, `strcmp`, `strength`, `strlen`, `strlwr`, `strupr`, `sturm`, `substr`, `switch`, `sys`, `t`, `tan`, `tanh`, `test_camera_1`, `test_camera_2`, `test_camera_3`, `test_camera_4`, `texture`, `texture_map`, `tga`, `thickness`, `threshold`, `tightness`, `tile2`, `tiles`, `track`, `transform`, `translate`, `transmit`, `triangle_wave`, `true`, `ttf`, `turbulence`, `turb_depth`, `type`, `ultra_wide_angle`, `up`, `use_color`, `use_colour`, `use_index`, `u_steps`, `val`, `variance`, `vaxis_rotate`, `vcross`, `vdot`, `version`, `vlength`, `vnormalize`, `volume_object`, `volume_rendered`, `vol_with_light`, `vrotate`, `v_steps`, `warning`, `warp`, `water_level`, `waves`, `while`, `width`, `wood`, `wrinkles`, `yes`), Keyword, nil}, | ||||
| 			{Words(``, `\b`, `bicubic_patch`, `blob`, `box`, `camera`, `cone`, `cubic`, `cylinder`, `difference`, `disc`, `height_field`, `intersection`, `julia_fractal`, `lathe`, `light_source`, `merge`, `mesh`, `object`, `plane`, `poly`, `polygon`, `prism`, `quadric`, `quartic`, `smooth_triangle`, `sor`, `sphere`, `superellipsoid`, `text`, `torus`, `triangle`, `union`), NameBuiltin, nil}, | ||||
| 			{`[\[\](){}<>;,]`, Punctuation, nil}, | ||||
| 			{`[-+*/=]`, Operator, nil}, | ||||
| 			{`\b(x|y|z|u|v)\b`, NameBuiltinPseudo, nil}, | ||||
| 			{`[a-zA-Z_]\w*`, Name, nil}, | ||||
| 			{`[0-9]+\.[0-9]*`, LiteralNumberFloat, nil}, | ||||
| 			{`\.[0-9]+`, LiteralNumberFloat, nil}, | ||||
| 			{`[0-9]+`, LiteralNumberInteger, nil}, | ||||
| 			{`"(\\\\|\\"|[^"])*"`, LiteralString, nil}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										63
									
								
								lexers/powershell.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								lexers/powershell.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,63 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Powershell lexer. | ||||
| var Powershell = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:            "PowerShell", | ||||
| 		Aliases:         []string{"powershell", "posh", "ps1", "psm1"}, | ||||
| 		Filenames:       []string{"*.ps1", "*.psm1"}, | ||||
| 		MimeTypes:       []string{"text/x-powershell"}, | ||||
| 		DotAll:          true, | ||||
| 		CaseInsensitive: true, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\(`, Punctuation, Push("child")}, | ||||
| 			{`\s+`, Text, nil}, | ||||
| 			{`^(\s*#[#\s]*)(\.(?:component|description|example|externalhelp|forwardhelpcategory|forwardhelptargetname|functionality|inputs|link|notes|outputs|parameter|remotehelprunspace|role|synopsis))([^\n]*$)`, ByGroups(Comment, LiteralStringDoc, Comment), nil}, | ||||
| 			{`#[^\n]*?$`, Comment, nil}, | ||||
| 			{`(<|<)#`, CommentMultiline, Push("multline")}, | ||||
| 			{`@"\n`, LiteralStringHeredoc, Push("heredoc-double")}, | ||||
| 			{`@'\n.*?\n'@`, LiteralStringHeredoc, nil}, | ||||
| 			{"`[\\'\"$@-]", Punctuation, nil}, | ||||
| 			{`"`, LiteralStringDouble, Push("string")}, | ||||
| 			{`'([^']|'')*'`, LiteralStringSingle, nil}, | ||||
| 			{`(\$|@@|@)((global|script|private|env):)?\w+`, NameVariable, nil}, | ||||
| 			{`(while|validateset|validaterange|validatepattern|validatelength|validatecount|until|trap|switch|return|ref|process|param|parameter|in|if|global:|function|foreach|for|finally|filter|end|elseif|else|dynamicparam|do|default|continue|cmdletbinding|break|begin|alias|\?|%|#script|#private|#local|#global|mandatory|parametersetname|position|valuefrompipeline|valuefrompipelinebypropertyname|valuefromremainingarguments|helpmessage|try|catch|throw)\b`, Keyword, nil}, | ||||
| 			{`-(and|as|band|bnot|bor|bxor|casesensitive|ccontains|ceq|cge|cgt|cle|clike|clt|cmatch|cne|cnotcontains|cnotlike|cnotmatch|contains|creplace|eq|exact|f|file|ge|gt|icontains|ieq|ige|igt|ile|ilike|ilt|imatch|ine|inotcontains|inotlike|inotmatch|ireplace|is|isnot|le|like|lt|match|ne|not|notcontains|notlike|notmatch|or|regex|replace|wildcard)\b`, Operator, nil}, | ||||
| 			{`(write|where|wait|use|update|unregister|undo|trace|test|tee|take|suspend|stop|start|split|sort|skip|show|set|send|select|scroll|resume|restore|restart|resolve|resize|reset|rename|remove|register|receive|read|push|pop|ping|out|new|move|measure|limit|join|invoke|import|group|get|format|foreach|export|expand|exit|enter|enable|disconnect|disable|debug|cxnew|copy|convertto|convertfrom|convert|connect|complete|compare|clear|checkpoint|aggregate|add)-[a-z_]\w*\b`, NameBuiltin, nil}, | ||||
| 			{"\\[[a-z_\\[][\\w. `,\\[\\]]*\\]", NameConstant, nil}, | ||||
| 			{`-[a-z_]\w*`, Name, nil}, | ||||
| 			{`\w+`, Name, nil}, | ||||
| 			{"[.,;@{}\\[\\]$()=+*/\\\\&%!~?^`|<>-]|::", Punctuation, nil}, | ||||
| 		}, | ||||
| 		"child": { | ||||
| 			{`\)`, Punctuation, Pop(1)}, | ||||
| 			Include("root"), | ||||
| 		}, | ||||
| 		"multline": { | ||||
| 			{`[^#&.]+`, CommentMultiline, nil}, | ||||
| 			{`#(>|>)`, CommentMultiline, Pop(1)}, | ||||
| 			{`\.(component|description|example|externalhelp|forwardhelpcategory|forwardhelptargetname|functionality|inputs|link|notes|outputs|parameter|remotehelprunspace|role|synopsis)`, LiteralStringDoc, nil}, | ||||
| 			{`[#&.]`, CommentMultiline, nil}, | ||||
| 		}, | ||||
| 		"string": { | ||||
| 			{"`[0abfnrtv'\\\"$`]", LiteralStringEscape, nil}, | ||||
| 			{"[^$`\"]+", LiteralStringDouble, nil}, | ||||
| 			{`\$\(`, Punctuation, Push("child")}, | ||||
| 			{`""`, LiteralStringDouble, nil}, | ||||
| 			{"[`$]", LiteralStringDouble, nil}, | ||||
| 			{`"`, LiteralStringDouble, Pop(1)}, | ||||
| 		}, | ||||
| 		"heredoc-double": { | ||||
| 			{`\n"@`, LiteralStringHeredoc, Pop(1)}, | ||||
| 			{`\$\(`, Punctuation, Push("child")}, | ||||
| 			{`[^@\n]+"]`, LiteralStringHeredoc, nil}, | ||||
| 			{`.`, LiteralStringHeredoc, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										50
									
								
								lexers/prolog.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								lexers/prolog.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Prolog lexer. | ||||
| var Prolog = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Prolog", | ||||
| 		Aliases:   []string{"prolog"}, | ||||
| 		Filenames: []string{"*.ecl", "*.prolog", "*.pro", "*.pl"}, | ||||
| 		MimeTypes: []string{"text/x-prolog"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`^#.*`, CommentSingle, nil}, | ||||
| 			{`/\*`, CommentMultiline, Push("nested-comment")}, | ||||
| 			{`%.*`, CommentSingle, nil}, | ||||
| 			{`0\'.`, LiteralStringChar, nil}, | ||||
| 			{`0b[01]+`, LiteralNumberBin, nil}, | ||||
| 			{`0o[0-7]+`, LiteralNumberOct, nil}, | ||||
| 			{`0x[0-9a-fA-F]+`, LiteralNumberHex, nil}, | ||||
| 			{`\d\d?\'[a-zA-Z0-9]+`, LiteralNumberInteger, nil}, | ||||
| 			{`(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?`, LiteralNumberFloat, nil}, | ||||
| 			{`\d+`, LiteralNumberInteger, nil}, | ||||
| 			{`[\[\](){}|.,;!]`, Punctuation, nil}, | ||||
| 			{`:-|-->`, Punctuation, nil}, | ||||
| 			{`"(?:\\x[0-9a-fA-F]+\\|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|\\[0-7]+\\|\\["\nabcefnrstv]|[^\\"])*"`, LiteralStringDouble, nil}, | ||||
| 			{`'(?:''|[^'])*'`, LiteralStringAtom, nil}, | ||||
| 			{`is\b`, Operator, nil}, | ||||
| 			{`(<|>|=<|>=|==|=:=|=|/|//|\*|\+|-)(?=\s|[a-zA-Z0-9\[])`, Operator, nil}, | ||||
| 			{`(mod|div|not)\b`, Operator, nil}, | ||||
| 			{`_`, Keyword, nil}, | ||||
| 			{`([a-z]+)(:)`, ByGroups(NameNamespace, Punctuation), nil}, | ||||
| 			{`([a-zÀ---][\w$À---]*)(\s*)(:-|-->)`, ByGroups(NameFunction, Text, Operator), nil}, | ||||
| 			{`([a-zÀ---][\w$À---]*)(\s*)(\()`, ByGroups(NameFunction, Text, Punctuation), nil}, | ||||
| 			{`[a-zÀ---][\w$À---]*`, LiteralStringAtom, nil}, | ||||
| 			{`[#&*+\-./:<=>?@\\^~¡-¿‐-〿]+`, LiteralStringAtom, nil}, | ||||
| 			{`[A-Z_]\w*`, NameVariable, nil}, | ||||
| 			{`\s+|[ --]`, Text, nil}, | ||||
| 		}, | ||||
| 		"nested-comment": { | ||||
| 			{`\*/`, CommentMultiline, Pop(1)}, | ||||
| 			{`/\*`, CommentMultiline, Push()}, | ||||
| 			{`[^*/]+`, CommentMultiline, nil}, | ||||
| 			{`[*/]`, CommentMultiline, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
| @@ -1,52 +1,52 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
|     . "github.com/alecthomas/chroma" // nolint | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Protocol Buffer lexer. | ||||
| // ProtocolBuffer lexer. | ||||
| var ProtocolBuffer = Register(MustNewLexer( | ||||
|     &Config{ | ||||
|         Name:      "Protocol Buffer", | ||||
|         Aliases:   []string{"protobuf", "proto"}, | ||||
|         Filenames: []string{"*.proto"}, | ||||
|         MimeTypes: []string{}, | ||||
|     }, | ||||
|     Rules{ | ||||
|         "root": { | ||||
|             {`[ \t]+`, Text, nil}, | ||||
|             {`[,;{}\[\]()<>]`, Punctuation, nil}, | ||||
|             {`/(\\\n)?/(\n|(.|\n)*?[^\\]\n)`, CommentSingle, nil}, | ||||
|             {`/(\\\n)?\*(.|\n)*?\*(\\\n)?/`, CommentMultiline, nil}, | ||||
|             {`\b(?:import|option|optional|required|repeated|default|packed|ctype|extensions|to|max|rpc|returns|oneof)\b`, Keyword, nil}, | ||||
|             {`(?:int32|int64|uint32|uint64|sint32|sint64|fixed32|fixed64|sfixed32|sfixed64|float|double|bool|string|bytes)\b`, KeywordType, nil}, | ||||
|             {`(true|false)\b`, KeywordConstant, nil}, | ||||
|             {`(package)(\s+)`, ByGroups(KeywordNamespace, Text), Push("package")}, | ||||
|             {`(message|extend)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("message")}, | ||||
|             {`(enum|group|service)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("type")}, | ||||
|             {`\".*?\"`, LiteralString, nil}, | ||||
|             {`\'.*?\'`, LiteralString, nil}, | ||||
|             {`(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*`, LiteralNumberFloat, nil}, | ||||
|             {`(\d+\.\d*|\.\d+|\d+[fF])[fF]?`, LiteralNumberFloat, nil}, | ||||
|             {`(\-?(inf|nan))\b`, LiteralNumberFloat, nil}, | ||||
|             {`0x[0-9a-fA-F]+[LlUu]*`, LiteralNumberHex, nil}, | ||||
|             {`0[0-7]+[LlUu]*`, LiteralNumberOct, nil}, | ||||
|             {`\d+[LlUu]*`, LiteralNumberInteger, nil}, | ||||
|             {`[+-=]`, Operator, nil}, | ||||
|             {`([a-zA-Z_][\w.]*)([ \t]*)(=)`, ByGroups(Name, Text, Operator), nil}, | ||||
|             {`[a-zA-Z_][\w.]*`, Name, nil}, | ||||
|         }, | ||||
|         "package": { | ||||
|             {`[a-zA-Z_]\w*`, NameNamespace, Pop(1)}, | ||||
|             Default(Pop(1)), | ||||
|         }, | ||||
|         "message": { | ||||
|             {`[a-zA-Z_]\w*`, NameClass, Pop(1)}, | ||||
|             Default(Pop(1)), | ||||
|         }, | ||||
|         "type": { | ||||
|             {`[a-zA-Z_]\w*`, Name, Pop(1)}, | ||||
|             Default(Pop(1)), | ||||
|         }, | ||||
|     }, | ||||
| 	&Config{ | ||||
| 		Name:      "Protocol Buffer", | ||||
| 		Aliases:   []string{"protobuf", "proto"}, | ||||
| 		Filenames: []string{"*.proto"}, | ||||
| 		MimeTypes: []string{}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`[ \t]+`, Text, nil}, | ||||
| 			{`[,;{}\[\]()<>]`, Punctuation, nil}, | ||||
| 			{`/(\\\n)?/(\n|(.|\n)*?[^\\]\n)`, CommentSingle, nil}, | ||||
| 			{`/(\\\n)?\*(.|\n)*?\*(\\\n)?/`, CommentMultiline, nil}, | ||||
| 			{Words(`\b`, `\b`, `import`, `option`, `optional`, `required`, `repeated`, `default`, `packed`, `ctype`, `extensions`, `to`, `max`, `rpc`, `returns`, `oneof`), Keyword, nil}, | ||||
| 			{Words(``, `\b`, `int32`, `int64`, `uint32`, `uint64`, `sint32`, `sint64`, `fixed32`, `fixed64`, `sfixed32`, `sfixed64`, `float`, `double`, `bool`, `string`, `bytes`), KeywordType, nil}, | ||||
| 			{`(true|false)\b`, KeywordConstant, nil}, | ||||
| 			{`(package)(\s+)`, ByGroups(KeywordNamespace, Text), Push("package")}, | ||||
| 			{`(message|extend)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("message")}, | ||||
| 			{`(enum|group|service)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("type")}, | ||||
| 			{`\".*?\"`, LiteralString, nil}, | ||||
| 			{`\'.*?\'`, LiteralString, nil}, | ||||
| 			{`(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*`, LiteralNumberFloat, nil}, | ||||
| 			{`(\d+\.\d*|\.\d+|\d+[fF])[fF]?`, LiteralNumberFloat, nil}, | ||||
| 			{`(\-?(inf|nan))\b`, LiteralNumberFloat, nil}, | ||||
| 			{`0x[0-9a-fA-F]+[LlUu]*`, LiteralNumberHex, nil}, | ||||
| 			{`0[0-7]+[LlUu]*`, LiteralNumberOct, nil}, | ||||
| 			{`\d+[LlUu]*`, LiteralNumberInteger, nil}, | ||||
| 			{`[+-=]`, Operator, nil}, | ||||
| 			{`([a-zA-Z_][\w.]*)([ \t]*)(=)`, ByGroups(NameAttribute, Text, Operator), nil}, | ||||
| 			{`[a-zA-Z_][\w.]*`, Name, nil}, | ||||
| 		}, | ||||
| 		"package": { | ||||
| 			{`[a-zA-Z_]\w*`, NameNamespace, Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"message": { | ||||
| 			{`[a-zA-Z_]\w*`, NameClass, Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"type": { | ||||
| 			{`[a-zA-Z_]\w*`, Name, Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
|   | ||||
							
								
								
									
										55
									
								
								lexers/puppet.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								lexers/puppet.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,55 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Puppet lexer. | ||||
| var Puppet = Register(MustNewLexer( | ||||
| 	&Config{ | ||||
| 		Name:      "Puppet", | ||||
| 		Aliases:   []string{"puppet"}, | ||||
| 		Filenames: []string{"*.pp"}, | ||||
| 		MimeTypes: []string{}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			Include("comments"), | ||||
| 			Include("keywords"), | ||||
| 			Include("names"), | ||||
| 			Include("numbers"), | ||||
| 			Include("operators"), | ||||
| 			Include("strings"), | ||||
| 			{`[]{}:(),;[]`, Punctuation, nil}, | ||||
| 			{`[^\S\n]+`, Text, nil}, | ||||
| 		}, | ||||
| 		"comments": { | ||||
| 			{`\s*#.*$`, Comment, nil}, | ||||
| 			{`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil}, | ||||
| 		}, | ||||
| 		"operators": { | ||||
| 			{`(=>|\?|<|>|=|\+|-|/|\*|~|!|\|)`, Operator, nil}, | ||||
| 			{`(in|and|or|not)\b`, OperatorWord, nil}, | ||||
| 		}, | ||||
| 		"names": { | ||||
| 			{`[a-zA-Z_]\w*`, NameAttribute, nil}, | ||||
| 			{`(\$\S+)(\[)(\S+)(\])`, ByGroups(NameVariable, Punctuation, LiteralString, Punctuation), nil}, | ||||
| 			{`\$\S+`, NameVariable, nil}, | ||||
| 		}, | ||||
| 		"numbers": { | ||||
| 			{`(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?`, LiteralNumberFloat, nil}, | ||||
| 			{`\d+[eE][+-]?[0-9]+j?`, LiteralNumberFloat, nil}, | ||||
| 			{`0[0-7]+j?`, LiteralNumberOct, nil}, | ||||
| 			{`0[xX][a-fA-F0-9]+`, LiteralNumberHex, nil}, | ||||
| 			{`\d+L`, LiteralNumberIntegerLong, nil}, | ||||
| 			{`\d+j?`, LiteralNumberInteger, nil}, | ||||
| 		}, | ||||
| 		"keywords": { | ||||
| 			{Words(`(?i)`, `\b`, `absent`, `alert`, `alias`, `audit`, `augeas`, `before`, `case`, `check`, `class`, `computer`, `configured`, `contained`, `create_resources`, `crit`, `cron`, `debug`, `default`, `define`, `defined`, `directory`, `else`, `elsif`, `emerg`, `err`, `exec`, `extlookup`, `fail`, `false`, `file`, `filebucket`, `fqdn_rand`, `generate`, `host`, `if`, `import`, `include`, `info`, `inherits`, `inline_template`, `installed`, `interface`, `k5login`, `latest`, `link`, `loglevel`, `macauthorization`, `mailalias`, `maillist`, `mcx`, `md5`, `mount`, `mounted`, `nagios_command`, `nagios_contact`, `nagios_contactgroup`, `nagios_host`, `nagios_hostdependency`, `nagios_hostescalation`, `nagios_hostextinfo`, `nagios_hostgroup`, `nagios_service`, `nagios_servicedependency`, `nagios_serviceescalation`, `nagios_serviceextinfo`, `nagios_servicegroup`, `nagios_timeperiod`, `node`, `noop`, `notice`, `notify`, `package`, `present`, `purged`, `realize`, `regsubst`, `resources`, `role`, `router`, `running`, `schedule`, `scheduled_task`, `search`, `selboolean`, `selmodule`, `service`, `sha1`, `shellquote`, `split`, `sprintf`, `ssh_authorized_key`, `sshkey`, `stage`, `stopped`, `subscribe`, `tag`, `tagged`, `template`, `tidy`, `true`, `undef`, `unmounted`, `user`, `versioncmp`, `vlan`, `warning`, `yumrepo`, `zfs`, `zone`, `zpool`), Keyword, nil}, | ||||
| 		}, | ||||
| 		"strings": { | ||||
| 			{`"([^"])*"`, LiteralString, nil}, | ||||
| 			{`'(\\'|[^'])*'`, LiteralString, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
							
								
								
									
										256
									
								
								lexers/python.go
									
									
									
									
									
								
							
							
						
						
									
										256
									
								
								lexers/python.go
									
									
									
									
									
								
							| @@ -1,136 +1,136 @@ | ||||
| package lexers | ||||
|  | ||||
| import ( | ||||
|     . "github.com/alecthomas/chroma" // nolint | ||||
| 	. "github.com/alecthomas/chroma" // nolint | ||||
| ) | ||||
|  | ||||
| // Python lexer. | ||||
| var Python = Register(MustNewLexer( | ||||
|     &Config{ | ||||
|         Name:      "Python", | ||||
|         Aliases:   []string{"python", "py", "sage"}, | ||||
|         Filenames: []string{"*.py", "*.pyw", "*.sc", "SConstruct", "SConscript", "*.tac", "*.sage"}, | ||||
|         MimeTypes: []string{"text/x-python", "application/x-python"}, | ||||
|     }, | ||||
|     Rules{ | ||||
|         "root": { | ||||
|             {`\n`, Text, nil}, | ||||
|             {`^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")`, ByGroups(Text, LiteralStringAffix, LiteralStringDoc), nil}, | ||||
|             {`^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')`, ByGroups(Text, LiteralStringAffix, LiteralStringDoc), nil}, | ||||
|             {`[^\S\n]+`, Text, nil}, | ||||
|             {`\A#!.+$`, CommentHashbang, nil}, | ||||
|             {`#.*$`, CommentSingle, nil}, | ||||
|             {`[]{}:(),;[]`, Punctuation, nil}, | ||||
|             {`\\\n`, Text, nil}, | ||||
|             {`\\`, Text, nil}, | ||||
|             {`(in|is|and|or|not)\b`, OperatorWord, nil}, | ||||
|             {`!=|==|<<|>>|[-~+/*%=<>&^|.]`, Operator, nil}, | ||||
|             Include("keywords"), | ||||
|             {`(def)((?:\s|\\\s)+)`, ByGroups(Keyword, Text), Push("funcname")}, | ||||
|             {`(class)((?:\s|\\\s)+)`, ByGroups(Keyword, Text), Push("classname")}, | ||||
|             {`(from)((?:\s|\\\s)+)`, ByGroups(KeywordNamespace, Text), Push("fromimport")}, | ||||
|             {`(import)((?:\s|\\\s)+)`, ByGroups(KeywordNamespace, Text), Push("import")}, | ||||
|             Include("builtins"), | ||||
|             Include("magicfuncs"), | ||||
|             Include("magicvars"), | ||||
|             Include("backtick"), | ||||
|             {`([rR]|[uUbB][rR]|[rR][uUbB])(""")`, ByGroups(LiteralStringAffix, LiteralStringDouble), Push("tdqs")}, | ||||
|             {`([rR]|[uUbB][rR]|[rR][uUbB])(''')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Push("tsqs")}, | ||||
|             {`([rR]|[uUbB][rR]|[rR][uUbB])(")`, ByGroups(LiteralStringAffix, LiteralStringDouble), Push("dqs")}, | ||||
|             {`([rR]|[uUbB][rR]|[rR][uUbB])(')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Push("sqs")}, | ||||
|             {`([uUbB]?)(""")`, ByGroups(LiteralStringAffix, LiteralStringDouble), Combined("stringescape", "tdqs")}, | ||||
|             {`([uUbB]?)(''')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Combined("stringescape", "tsqs")}, | ||||
|             {`([uUbB]?)(")`, ByGroups(LiteralStringAffix, LiteralStringDouble), Combined("stringescape", "dqs")}, | ||||
|             {`([uUbB]?)(')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Combined("stringescape", "sqs")}, | ||||
|             Include("name"), | ||||
|             Include("numbers"), | ||||
|         }, | ||||
|         "keywords": { | ||||
|             {`(?:assert|break|continue|del|elif|else|except|exec|finally|for|global|if|lambda|pass|print|raise|return|try|while|yield|yield from|as|with)\b`, Keyword, nil}, | ||||
|         }, | ||||
|         "builtins": { | ||||
|             {`(?:__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)\b`, NameBuiltin, nil}, | ||||
|             {`(self|None|Ellipsis|NotImplemented|False|True|cls)\b`, NameBuiltinPseudo, nil}, | ||||
|             {`(?: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)\b`, NameException, nil}, | ||||
|         }, | ||||
|         "magicfuncs": { | ||||
|             {`(?:__abs__|__add__|__and__|__call__|__cmp__|__coerce__|__complex__|__contains__|__del__|__delattr__|__delete__|__delitem__|__delslice__|__div__|__divmod__|__enter__|__eq__|__exit__|__float__|__floordiv__|__ge__|__get__|__getattr__|__getattribute__|__getitem__|__getslice__|__gt__|__hash__|__hex__|__iadd__|__iand__|__idiv__|__ifloordiv__|__ilshift__|__imod__|__imul__|__index__|__init__|__instancecheck__|__int__|__invert__|__iop__|__ior__|__ipow__|__irshift__|__isub__|__iter__|__itruediv__|__ixor__|__le__|__len__|__long__|__lshift__|__lt__|__missing__|__mod__|__mul__|__ne__|__neg__|__new__|__nonzero__|__oct__|__op__|__or__|__pos__|__pow__|__radd__|__rand__|__rcmp__|__rdiv__|__rdivmod__|__repr__|__reversed__|__rfloordiv__|__rlshift__|__rmod__|__rmul__|__rop__|__ror__|__rpow__|__rrshift__|__rshift__|__rsub__|__rtruediv__|__rxor__|__set__|__setattr__|__setitem__|__setslice__|__str__|__sub__|__subclasscheck__|__truediv__|__unicode__|__xor__)\b`, NameFunctionMagic, nil}, | ||||
|         }, | ||||
|         "magicvars": { | ||||
|             {`(?:__bases__|__class__|__closure__|__code__|__defaults__|__dict__|__doc__|__file__|__func__|__globals__|__metaclass__|__module__|__mro__|__name__|__self__|__slots__|__weakref__)\b`, NameVariableMagic, nil}, | ||||
|         }, | ||||
|         "numbers": { | ||||
|             {`(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?`, LiteralNumberFloat, nil}, | ||||
|             {`\d+[eE][+-]?[0-9]+j?`, LiteralNumberFloat, nil}, | ||||
|             {`0[0-7]+j?`, LiteralNumberOct, nil}, | ||||
|             {`0[bB][01]+`, LiteralNumberBin, nil}, | ||||
|             {`0[xX][a-fA-F0-9]+`, LiteralNumberHex, nil}, | ||||
|             {`\d+L`, LiteralNumberIntegerLong, nil}, | ||||
|             {`\d+j?`, LiteralNumberInteger, nil}, | ||||
|         }, | ||||
|         "backtick": { | ||||
|             {"`.*?`", LiteralStringBacktick, nil}, | ||||
|         }, | ||||
|         "name": { | ||||
|             {`@[\w.]+`, NameDecorator, nil}, | ||||
|             {`[a-zA-Z_]\w*`, Name, nil}, | ||||
|         }, | ||||
|         "funcname": { | ||||
|             Include("magicfuncs"), | ||||
|             {`[a-zA-Z_]\w*`, NameFunction, Pop(1)}, | ||||
|             Default(Pop(1)), | ||||
|         }, | ||||
|         "classname": { | ||||
|             {`[a-zA-Z_]\w*`, NameClass, Pop(1)}, | ||||
|         }, | ||||
|         "import": { | ||||
|             {`(?:[ \t]|\\\n)+`, Text, nil}, | ||||
|             {`as\b`, KeywordNamespace, nil}, | ||||
|             {`,`, Operator, nil}, | ||||
|             {`[a-zA-Z_][\w.]*`, NameNamespace, nil}, | ||||
|             Default(Pop(1)), | ||||
|         }, | ||||
|         "fromimport": { | ||||
|             {`(?:[ \t]|\\\n)+`, Text, nil}, | ||||
|             {`import\b`, KeywordNamespace, Pop(1)}, | ||||
|             {`None\b`, NameBuiltinPseudo, Pop(1)}, | ||||
|             {`[a-zA-Z_.][\w.]*`, NameNamespace, nil}, | ||||
|             Default(Pop(1)), | ||||
|         }, | ||||
|         "stringescape": { | ||||
|             {`\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})`, LiteralStringEscape, nil}, | ||||
|         }, | ||||
|         "strings-single": { | ||||
|             {`%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]`, LiteralStringInterpol, nil}, | ||||
|             {`[^\\\'"%\n]+`, LiteralStringSingle, nil}, | ||||
|             {`[\'"\\]`, LiteralStringSingle, nil}, | ||||
|             {`%`, LiteralStringSingle, nil}, | ||||
|         }, | ||||
|         "strings-double": { | ||||
|             {`%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]`, LiteralStringInterpol, nil}, | ||||
|             {`[^\\\'"%\n]+`, LiteralStringDouble, nil}, | ||||
|             {`[\'"\\]`, LiteralStringDouble, nil}, | ||||
|             {`%`, LiteralStringDouble, nil}, | ||||
|         }, | ||||
|         "dqs": { | ||||
|             {`"`, LiteralStringDouble, Pop(1)}, | ||||
|             {`\\\\|\\"|\\\n`, LiteralStringEscape, nil}, | ||||
|             Include("strings-double"), | ||||
|         }, | ||||
|         "sqs": { | ||||
|             {`'`, LiteralStringSingle, Pop(1)}, | ||||
|             {`\\\\|\\'|\\\n`, LiteralStringEscape, nil}, | ||||
|             Include("strings-single"), | ||||
|         }, | ||||
|         "tdqs": { | ||||
|             {`"""`, LiteralStringDouble, Pop(1)}, | ||||
|             Include("strings-double"), | ||||
|             {`\n`, LiteralStringDouble, nil}, | ||||
|         }, | ||||
|         "tsqs": { | ||||
|             {`'''`, LiteralStringSingle, Pop(1)}, | ||||
|             Include("strings-single"), | ||||
|             {`\n`, LiteralStringSingle, nil}, | ||||
|         }, | ||||
|     }, | ||||
| 	&Config{ | ||||
| 		Name:      "Python", | ||||
| 		Aliases:   []string{"python", "py", "sage"}, | ||||
| 		Filenames: []string{"*.py", "*.pyw", "*.sc", "SConstruct", "SConscript", "*.tac", "*.sage"}, | ||||
| 		MimeTypes: []string{"text/x-python", "application/x-python"}, | ||||
| 	}, | ||||
| 	Rules{ | ||||
| 		"root": { | ||||
| 			{`\n`, Text, nil}, | ||||
| 			{`^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")`, ByGroups(Text, LiteralStringAffix, LiteralStringDoc), nil}, | ||||
| 			{`^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')`, ByGroups(Text, LiteralStringAffix, LiteralStringDoc), nil}, | ||||
| 			{`[^\S\n]+`, Text, nil}, | ||||
| 			{`\A#!.+$`, CommentHashbang, nil}, | ||||
| 			{`#.*$`, CommentSingle, nil}, | ||||
| 			{`[]{}:(),;[]`, Punctuation, nil}, | ||||
| 			{`\\\n`, Text, nil}, | ||||
| 			{`\\`, Text, nil}, | ||||
| 			{`(in|is|and|or|not)\b`, OperatorWord, nil}, | ||||
| 			{`!=|==|<<|>>|[-~+/*%=<>&^|.]`, Operator, nil}, | ||||
| 			Include("keywords"), | ||||
| 			{`(def)((?:\s|\\\s)+)`, ByGroups(Keyword, Text), Push("funcname")}, | ||||
| 			{`(class)((?:\s|\\\s)+)`, ByGroups(Keyword, Text), Push("classname")}, | ||||
| 			{`(from)((?:\s|\\\s)+)`, ByGroups(KeywordNamespace, Text), Push("fromimport")}, | ||||
| 			{`(import)((?:\s|\\\s)+)`, ByGroups(KeywordNamespace, Text), Push("import")}, | ||||
| 			Include("builtins"), | ||||
| 			Include("magicfuncs"), | ||||
| 			Include("magicvars"), | ||||
| 			Include("backtick"), | ||||
| 			{`([rR]|[uUbB][rR]|[rR][uUbB])(""")`, ByGroups(LiteralStringAffix, LiteralStringDouble), Push("tdqs")}, | ||||
| 			{`([rR]|[uUbB][rR]|[rR][uUbB])(''')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Push("tsqs")}, | ||||
| 			{`([rR]|[uUbB][rR]|[rR][uUbB])(")`, ByGroups(LiteralStringAffix, LiteralStringDouble), Push("dqs")}, | ||||
| 			{`([rR]|[uUbB][rR]|[rR][uUbB])(')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Push("sqs")}, | ||||
| 			{`([uUbB]?)(""")`, ByGroups(LiteralStringAffix, LiteralStringDouble), Combined("stringescape", "tdqs")}, | ||||
| 			{`([uUbB]?)(''')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Combined("stringescape", "tsqs")}, | ||||
| 			{`([uUbB]?)(")`, ByGroups(LiteralStringAffix, LiteralStringDouble), Combined("stringescape", "dqs")}, | ||||
| 			{`([uUbB]?)(')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Combined("stringescape", "sqs")}, | ||||
| 			Include("name"), | ||||
| 			Include("numbers"), | ||||
| 		}, | ||||
| 		"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}, | ||||
| 		}, | ||||
| 		"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}, | ||||
| 		}, | ||||
| 		"magicfuncs": { | ||||
| 			{Words(``, `\b`, `__abs__`, `__add__`, `__and__`, `__call__`, `__cmp__`, `__coerce__`, `__complex__`, `__contains__`, `__del__`, `__delattr__`, `__delete__`, `__delitem__`, `__delslice__`, `__div__`, `__divmod__`, `__enter__`, `__eq__`, `__exit__`, `__float__`, `__floordiv__`, `__ge__`, `__get__`, `__getattr__`, `__getattribute__`, `__getitem__`, `__getslice__`, `__gt__`, `__hash__`, `__hex__`, `__iadd__`, `__iand__`, `__idiv__`, `__ifloordiv__`, `__ilshift__`, `__imod__`, `__imul__`, `__index__`, `__init__`, `__instancecheck__`, `__int__`, `__invert__`, `__iop__`, `__ior__`, `__ipow__`, `__irshift__`, `__isub__`, `__iter__`, `__itruediv__`, `__ixor__`, `__le__`, `__len__`, `__long__`, `__lshift__`, `__lt__`, `__missing__`, `__mod__`, `__mul__`, `__ne__`, `__neg__`, `__new__`, `__nonzero__`, `__oct__`, `__op__`, `__or__`, `__pos__`, `__pow__`, `__radd__`, `__rand__`, `__rcmp__`, `__rdiv__`, `__rdivmod__`, `__repr__`, `__reversed__`, `__rfloordiv__`, `__rlshift__`, `__rmod__`, `__rmul__`, `__rop__`, `__ror__`, `__rpow__`, `__rrshift__`, `__rshift__`, `__rsub__`, `__rtruediv__`, `__rxor__`, `__set__`, `__setattr__`, `__setitem__`, `__setslice__`, `__str__`, `__sub__`, `__subclasscheck__`, `__truediv__`, `__unicode__`, `__xor__`), NameFunctionMagic, nil}, | ||||
| 		}, | ||||
| 		"magicvars": { | ||||
| 			{Words(``, `\b`, `__bases__`, `__class__`, `__closure__`, `__code__`, `__defaults__`, `__dict__`, `__doc__`, `__file__`, `__func__`, `__globals__`, `__metaclass__`, `__module__`, `__mro__`, `__name__`, `__self__`, `__slots__`, `__weakref__`), NameVariableMagic, nil}, | ||||
| 		}, | ||||
| 		"numbers": { | ||||
| 			{`(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?`, LiteralNumberFloat, nil}, | ||||
| 			{`\d+[eE][+-]?[0-9]+j?`, LiteralNumberFloat, nil}, | ||||
| 			{`0[0-7]+j?`, LiteralNumberOct, nil}, | ||||
| 			{`0[bB][01]+`, LiteralNumberBin, nil}, | ||||
| 			{`0[xX][a-fA-F0-9]+`, LiteralNumberHex, nil}, | ||||
| 			{`\d+L`, LiteralNumberIntegerLong, nil}, | ||||
| 			{`\d+j?`, LiteralNumberInteger, nil}, | ||||
| 		}, | ||||
| 		"backtick": { | ||||
| 			{"`.*?`", LiteralStringBacktick, nil}, | ||||
| 		}, | ||||
| 		"name": { | ||||
| 			{`@[\w.]+`, NameDecorator, nil}, | ||||
| 			{`[a-zA-Z_]\w*`, Name, nil}, | ||||
| 		}, | ||||
| 		"funcname": { | ||||
| 			Include("magicfuncs"), | ||||
| 			{`[a-zA-Z_]\w*`, NameFunction, Pop(1)}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"classname": { | ||||
| 			{`[a-zA-Z_]\w*`, NameClass, Pop(1)}, | ||||
| 		}, | ||||
| 		"import": { | ||||
| 			{`(?:[ \t]|\\\n)+`, Text, nil}, | ||||
| 			{`as\b`, KeywordNamespace, nil}, | ||||
| 			{`,`, Operator, nil}, | ||||
| 			{`[a-zA-Z_][\w.]*`, NameNamespace, nil}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"fromimport": { | ||||
| 			{`(?:[ \t]|\\\n)+`, Text, nil}, | ||||
| 			{`import\b`, KeywordNamespace, Pop(1)}, | ||||
| 			{`None\b`, NameBuiltinPseudo, Pop(1)}, | ||||
| 			{`[a-zA-Z_.][\w.]*`, NameNamespace, nil}, | ||||
| 			Default(Pop(1)), | ||||
| 		}, | ||||
| 		"stringescape": { | ||||
| 			{`\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})`, LiteralStringEscape, nil}, | ||||
| 		}, | ||||
| 		"strings-single": { | ||||
| 			{`%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]`, LiteralStringInterpol, nil}, | ||||
| 			{`[^\\\'"%\n]+`, LiteralStringSingle, nil}, | ||||
| 			{`[\'"\\]`, LiteralStringSingle, nil}, | ||||
| 			{`%`, LiteralStringSingle, nil}, | ||||
| 		}, | ||||
| 		"strings-double": { | ||||
| 			{`%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]`, LiteralStringInterpol, nil}, | ||||
| 			{`[^\\\'"%\n]+`, LiteralStringDouble, nil}, | ||||
| 			{`[\'"\\]`, LiteralStringDouble, nil}, | ||||
| 			{`%`, LiteralStringDouble, nil}, | ||||
| 		}, | ||||
| 		"dqs": { | ||||
| 			{`"`, LiteralStringDouble, Pop(1)}, | ||||
| 			{`\\\\|\\"|\\\n`, LiteralStringEscape, nil}, | ||||
| 			Include("strings-double"), | ||||
| 		}, | ||||
| 		"sqs": { | ||||
| 			{`'`, LiteralStringSingle, Pop(1)}, | ||||
| 			{`\\\\|\\'|\\\n`, LiteralStringEscape, nil}, | ||||
| 			Include("strings-single"), | ||||
| 		}, | ||||
| 		"tdqs": { | ||||
| 			{`"""`, LiteralStringDouble, Pop(1)}, | ||||
| 			Include("strings-double"), | ||||
| 			{`\n`, LiteralStringDouble, nil}, | ||||
| 		}, | ||||
| 		"tsqs": { | ||||
| 			{`'''`, LiteralStringSingle, Pop(1)}, | ||||
| 			Include("strings-single"), | ||||
| 			{`\n`, LiteralStringSingle, nil}, | ||||
| 		}, | ||||
| 	}, | ||||
| )) | ||||
|   | ||||
							
								
								
									
										134
									
								
								lexers/python3.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								lexers/python3.go
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user