Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(words(object_attributes, prefix=r'\.'), Name.Builtin, '#pop'),
(r'\$', Name.Builtin),
(r'\[', Text, '#pop'),
],
'variable_name': [
include('operator'),
include('number'),
(words(variables_string, suffix=r'\$'), Name.Variable.Global),
(words(variables_numeric,
suffix=r'(?=[^a-zA-Z0-9\._"\'\$#\[:\(]|\s|^|$)'),
Name.Variable.Global),
(words(objects, prefix=r'\b', suffix=r"(_)"),
bygroups(Name.Builtin, Name.Builtin),
'object_reference'),
(r'\.?_?[a-z][\w.]*(\$|#)?', Text),
(r'[\[\]]', Punctuation, 'comma_list'),
include('string_interpolated'),
],
'operator': [
(r'([+\/*<>=!-]=?|[&*|][&*|]?|\^|<>)', Operator),
(r'(?
(r'until'+_nkw, Keyword),
(r'and'+_nkw, Keyword),
(r'or'+_nkw, Keyword),
(r'not'+_nkw, Keyword),
(r'lambda'+_nkw, Keyword),
(r'try'+_nkw, Keyword),
(r'catch'+_nkw, Keyword),
(r'return'+_nkw, Keyword),
(r'next'+_nkw, Keyword),
(r'last'+_nkw, Keyword),
(r'throw'+_nkw, Keyword),
(r'use'+_nkw, Keyword),
(r'switch'+_nkw, Keyword),
(r'\\', Keyword),
(r'λ', Keyword),
(r'__FILE__'+_nkw, Name.Builtin.Pseudo),
(r'__LINE__'+_nkw, Name.Builtin.Pseudo),
(r'[A-Z][a-zA-Z0-9_\']*'+_nkw, Name.Constant),
(r'[a-z_][a-zA-Z0-9_\']*'+_nkw, Name),
(r'@[a-z_][a-zA-Z0-9_\']*'+_nkw, Name.Variable.Instance),
(r'@@[a-z_][a-zA-Z0-9_\']*'+_nkw, Name.Variable.Class),
(r'\(', Punctuation),
(r'\)', Punctuation),
(r'\[', Punctuation),
(r'\]', Punctuation),
(r'\{', Punctuation),
(r'\}', right_angle_bracket),
(r';', Punctuation),
(r',', Punctuation),
(r'<<=', Operator),
(r'>>=', Operator),
(r'<<', Operator),
function|local|return|end|
rec|
quit|QUIT|
IsBound|Unbind|
TryNextMethod|
Info|Assert
)\b''', Keyword),
(r'''(?x)\b(?:
true|false|fail|infinity
)\b''',
Name.Constant),
(r'''(?x)\b(?:
(Declare|Install)([A-Z][A-Za-z]+)|
BindGlobal|BIND_GLOBAL
)\b''',
Name.Builtin),
(r'\.|,|:=|;|=|\+|-|\*|/|\^|>|<', Operator),
(r'''(?x)\b(?:
and|or|not|mod|in
)\b''',
Operator.Word),
(r'''(?x)
(?:\w+|`[^`]*`)
(?:::\w+|`[^`]*`)*''', Name.Variable),
(r'[0-9]+(?:\.[0-9]*)?(?:e[0-9]+)?', Number),
(r'\.[0-9]+(?:e[0-9]+)?', Number),
(r'.', Text)
],
}
def analyse_text(text):
score = 0.0
class JinjaStyle(Style):
title = 'Jinja Style'
default_style = ""
styles = {
Comment: 'italic #aaaaaa',
Comment.Preproc: 'noitalic #B11414',
Comment.Special: 'italic #505050',
Keyword: 'bold #B80000',
Keyword.Type: '#808080',
Operator.Word: 'bold #B80000',
Name.Builtin: '#333333',
Name.Function: '#333333',
Name.Class: 'bold #333333',
Name.Namespace: 'bold #333333',
Name.Entity: 'bold #363636',
Name.Attribute: '#686868',
Name.Tag: 'bold #686868',
Name.Decorator: '#686868',
String: '#AA891C',
Number: '#444444',
Generic.Heading: 'bold #000080',
Generic.Subheading: 'bold #800080',
Generic.Deleted: '#aa0000',
Generic.Inserted: '#00aa00',
Generic.Error: '#aa0000',
'statements': [
(words((
'virtual', 'class', 'private', 'public', 'property', 'import',
'delete', 'new', 'new0', 'renew', 'renew0', 'define', 'get',
'set', 'remote', 'dllexport', 'dllimport', 'stdcall', 'subclass',
'__on_register_module', 'namespace', 'using', 'typed_object',
'any_object', 'incref', 'register', 'watch', 'stopwatching', 'firewatchers',
'watchable', 'class_designer', 'class_fixed', 'class_no_expansion', 'isset',
'class_default_property', 'property_category', 'class_data',
'class_property', 'thisclass', 'dbtable', 'dbindex',
'database_open', 'dbfield'), suffix=r'\b'), Keyword),
(words(('uint', 'uint16', 'uint32', 'uint64', 'bool', 'byte',
'unichar', 'int64'), suffix=r'\b'),
Keyword.Type),
(r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
(r'(null|value|this)\b', Name.Builtin),
inherit,
]
}
class ValaLexer(RegexLexer):
"""
For Vala source code with preprocessor directives.
.. versionadded:: 1.1
"""
name = 'Vala'
aliases = ['vala', 'vapi']
filenames = ['*.vala', '*.vapi']
mimetypes = ['text/x-vala']
Keyword.Constant: "",
Keyword.Declaration: "",
Keyword.Namespace: AQUA,
Keyword.Pseudo: "",
Keyword.Reserved: "",
Keyword.Type: YELLOW,
Operator: AQUA,
Operator.Word: "",
Punctuation: FOREGROUND,
Name: FOREGROUND,
Name.Attribute: BLUE,
Name.Builtin: "",
Name.Builtin.Pseudo: "",
Name.Class: YELLOW,
Name.Constant: RED,
Name.Decorator: AQUA,
Name.Entity: "",
Name.Exception: RED,
Name.Function: BLUE,
Name.Property: "",
Name.Label: "",
Name.Namespace: YELLOW,
Name.Other: BLUE,
Name.Tag: '#21b799',
Name.Variable: RED,
Name.Variable.Class: "",
Name.Variable.Global: "",
Name.Variable.Instance: "",
],
'comment': [
(r';.*?$', Comment.Singleline),
(r'#\|', Comment.Multiline, 'multilinecomment')
],
'multilinecomment': [
(r'[^#|]', Comment.Multiline),
(r'#\|', Comment.Multiline, '#push'),
(r'\|#', Comment.Multiline, '#pop'),
(r'[#|]', Comment.Multiline)
],
'typedef': [
(r'\s+', Text),
(r'\.', Punctuation, '#pop'),
# probably ok to reuse letterset for %suffix and %prefix
(r'(%prefix|%suffix)', Name.Builtin, 'letterset'),
include('conjunction')
],
'conjunction': [
(r'\s+', Text),
(r'&', Operator),
(r'"[^"\\]*(?:\\.[^"\\]*)*"', String.Doc),
include('term'),
(r'', Text, '#pop')
],
'term': [
include('comment'),
(r'\[', Punctuation, 'avm'),
(r'
styles = {
Comment: '#177500',
Comment.Preproc: '#633820',
String: '#C41A16',
String.Char: '#2300CE',
Operator: '#000000',
Keyword: '#A90D91',
Name: '#000000',
Name.Attribute: '#836C28',
Name.Class: '#3F6E75',
Name.Function: '#000000',
Name.Builtin: '#A90D91',
# In Obj-C code this token is used to colour Cocoa types
Name.Builtin.Pseudo: '#5B269A',
Name.Variable: '#000000',
Name.Tag: '#000000',
Name.Decorator: '#000000',
# Workaround for a BUG here: lexer treats multiline method signatres as labels
Name.Label: '#000000',
Literal: '#1C01CE',
Number: '#1C01CE',
Error: '#000000',
}
def get_tokens_unprocessed(self, text):
for index, token, value in \
RegexLexer.get_tokens_unprocessed(self, text):
if token is Name:
if self.smhighlighting:
if value in self.SM_TYPES:
token = Keyword.Type
elif value in self._functions:
token = Name.Builtin
yield index, token, value
'list', 'exn', 'obj', 'enum',
]
# See http://msdn.microsoft.com/en-us/library/dd233181.aspx and/or
# http://fsharp.org/about/files/spec.pdf for reference. Good luck.
tokens = {
'escape-sequence': [
(r'\\[\\"\'ntbrafv]', String.Escape),
(r'\\[0-9]{3}', String.Escape),
(r'\\u[0-9a-fA-F]{4}', String.Escape),
(r'\\U[0-9a-fA-F]{8}', String.Escape),
],
'root': [
(r'\s+', Text),
(r'\(\)|\[\]', Name.Builtin.Pseudo),
(r'\b(?