summaryrefslogtreecommitdiff
path: root/pygments/lexers/web.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/lexers/web.py')
-rw-r--r--pygments/lexers/web.py266
1 files changed, 148 insertions, 118 deletions
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py
index f8c89204..2428ffcd 100644
--- a/pygments/lexers/web.py
+++ b/pygments/lexers/web.py
@@ -81,7 +81,7 @@ class JavascriptLexer(RegexLexer):
r'decodeURIComponent|encodeURI|encodeURIComponent|'
r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
r'window)\b', Name.Builtin),
- (r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
+ (r'[$a-zA-Z_]\w*', Name.Other),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
(r'[0-9]+', Number.Integer),
@@ -184,8 +184,8 @@ class ActionScriptLexer(RegexLexer):
name = 'ActionScript'
aliases = ['as', 'actionscript']
filenames = ['*.as']
- mimetypes = ['application/x-actionscript3', 'text/x-actionscript3',
- 'text/actionscript3']
+ mimetypes = ['application/x-actionscript', 'text/x-actionscript',
+ 'text/actionscript']
flags = re.DOTALL
tokens = {
@@ -248,7 +248,7 @@ class ActionScriptLexer(RegexLexer):
r'isXMLName|clearInterval|fscommand|getTimer|getURL|getVersion|'
r'isFinite|parseFloat|parseInt|setInterval|trace|updateAfterEvent|'
r'unescape)\b',Name.Function),
- (r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
+ (r'[$a-zA-Z_]\w*', Name.Other),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-f]+', Number.Hex),
(r'[0-9]+', Number.Integer),
@@ -268,10 +268,10 @@ class ActionScript3Lexer(RegexLexer):
name = 'ActionScript 3'
aliases = ['as3', 'actionscript3']
filenames = ['*.as']
- mimetypes = ['application/x-actionscript', 'text/x-actionscript',
- 'text/actionscript']
+ mimetypes = ['application/x-actionscript3', 'text/x-actionscript3',
+ 'text/actionscript3']
- identifier = r'[$a-zA-Z_][a-zA-Z0-9_]*'
+ identifier = r'[$a-zA-Z_]\w*'
typeidentifier = identifier + '(?:\.<\w+>)?'
flags = re.DOTALL | re.MULTILINE
@@ -359,11 +359,11 @@ class CssLexer(RegexLexer):
(r'\s+', Text),
(r'/\*(?:.|\n)*?\*/', Comment),
(r'{', Punctuation, 'content'),
- (r'\:[a-zA-Z0-9_-]+', Name.Decorator),
- (r'\.[a-zA-Z0-9_-]+', Name.Class),
- (r'\#[a-zA-Z0-9_-]+', Name.Function),
- (r'@[a-zA-Z0-9_-]+', Keyword, 'atrule'),
- (r'[a-zA-Z0-9_-]+', Name.Tag),
+ (r'\:[\w-]+', Name.Decorator),
+ (r'\.[\w-]+', Name.Class),
+ (r'\#[\w-]+', Name.Function),
+ (r'@[\w-]+', Keyword, 'atrule'),
+ (r'[\w-]+', Name.Tag),
(r'[~\^\*!%&$\[\]\(\)<>\|+=@:;,./?-]', Operator),
(r'"(\\\\|\\"|[^"])*"', String.Double),
(r"'(\\\\|\\'|[^'])*'", String.Single)
@@ -475,7 +475,7 @@ class CssLexer(RegexLexer):
(r'[\[\]();]+', Punctuation),
(r'"(\\\\|\\"|[^"])*"', String.Double),
(r"'(\\\\|\\'|[^'])*'", String.Single),
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name)
+ (r'[a-zA-Z_]\w*', Name)
]
}
@@ -595,26 +595,26 @@ class ObjectiveJLexer(RegexLexer):
r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
r'window)\b', Name.Builtin),
- (r'([$a-zA-Z_][a-zA-Z0-9_]*)(' + _ws + r')(?=\()',
+ (r'([$a-zA-Z_]\w*)(' + _ws + r')(?=\()',
bygroups(Name.Function, using(this))),
- (r'[$a-zA-Z_][a-zA-Z0-9_]*', Name),
+ (r'[$a-zA-Z_]\w*', Name),
],
'classname' : [
# interface definition that inherits
- (r'([a-zA-Z_][a-zA-Z0-9_]*)(' + _ws + r':' + _ws +
- r')([a-zA-Z_][a-zA-Z0-9_]*)?',
+ (r'([a-zA-Z_]\w*)(' + _ws + r':' + _ws +
+ r')([a-zA-Z_]\w*)?',
bygroups(Name.Class, using(this), Name.Class), '#pop'),
# interface definition for a category
- (r'([a-zA-Z_][a-zA-Z0-9_]*)(' + _ws + r'\()([a-zA-Z_][a-zA-Z0-9_]*)(\))',
+ (r'([a-zA-Z_]\w*)(' + _ws + r'\()([a-zA-Z_]\w*)(\))',
bygroups(Name.Class, using(this), Name.Label, Text), '#pop'),
# simple interface / implementation
- (r'([a-zA-Z_][a-zA-Z0-9_]*)', Name.Class, '#pop'),
+ (r'([a-zA-Z_]\w*)', Name.Class, '#pop'),
],
'forward_classname' : [
- (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*,\s*)',
+ (r'([a-zA-Z_]\w*)(\s*,\s*)',
bygroups(Name.Class, Text), '#push'),
- (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*;?)',
+ (r'([a-zA-Z_]\w*)(\s*;?)',
bygroups(Name.Class, Text), '#pop'),
],
'function_signature': [
@@ -622,26 +622,26 @@ class ObjectiveJLexer(RegexLexer):
# start of a selector w/ parameters
(r'(\(' + _ws + r')' # open paren
- r'([a-zA-Z_][a-zA-Z0-9_]+)' # return type
+ r'([a-zA-Z_]\w+)' # return type
r'(' + _ws + r'\)' + _ws + r')' # close paren
- r'([$a-zA-Z_][a-zA-Z0-9_]+' + _ws + r':)', # function name
+ r'([$a-zA-Z_]\w+' + _ws + r':)', # function name
bygroups(using(this), Keyword.Type, using(this),
Name.Function), 'function_parameters'),
# no-param function
(r'(\(' + _ws + r')' # open paren
- r'([a-zA-Z_][a-zA-Z0-9_]+)' # return type
+ r'([a-zA-Z_]\w+)' # return type
r'(' + _ws + r'\)' + _ws + r')' # close paren
- r'([$a-zA-Z_][a-zA-Z0-9_]+)', # function name
+ r'([$a-zA-Z_]\w+)', # function name
bygroups(using(this), Keyword.Type, using(this),
Name.Function), "#pop"),
# no return type given, start of a selector w/ parameters
- (r'([$a-zA-Z_][a-zA-Z0-9_]+' + _ws + r':)', # function name
+ (r'([$a-zA-Z_]\w+' + _ws + r':)', # function name
bygroups (Name.Function), 'function_parameters'),
# no return type given, no-param function
- (r'([$a-zA-Z_][a-zA-Z0-9_]+)', # function name
+ (r'([$a-zA-Z_]\w+)', # function name
bygroups(Name.Function), "#pop"),
('', Text, '#pop'),
@@ -653,11 +653,11 @@ class ObjectiveJLexer(RegexLexer):
(r'(\(' + _ws + ')' # open paren
r'([^\)]+)' # type
r'(' + _ws + r'\)' + _ws + r')' # close paren
- r'([$a-zA-Z_][a-zA-Z0-9_]+)', # param name
+ r'([$a-zA-Z_]\w+)', # param name
bygroups(using(this), Keyword.Type, using(this), Text)),
# one piece of a selector name
- (r'([$a-zA-Z_][a-zA-Z0-9_]+' + _ws + r':)', # function name
+ (r'([$a-zA-Z_]\w+' + _ws + r':)', # function name
Name.Function),
# smallest possible selector piece
@@ -667,10 +667,10 @@ class ObjectiveJLexer(RegexLexer):
(r'(,' + _ws + r'\.\.\.)', using(this)),
# param name
- (r'([$a-zA-Z_][a-zA-Z0-9_]+)', Text),
+ (r'([$a-zA-Z_]\w+)', Text),
],
'expression' : [
- (r'([$a-zA-Z_][a-zA-Z0-9_]*)(\()', bygroups(Name.Function,
+ (r'([$a-zA-Z_]\w*)(\()', bygroups(Name.Function,
Punctuation)),
(r'(\))', Punctuation, "#pop"),
],
@@ -737,8 +737,8 @@ class HtmlLexer(RegexLexer):
],
'tag': [
(r'\s+', Text),
- (r'[a-zA-Z0-9_:-]+\s*=', Name.Attribute, 'attr'),
- (r'[a-zA-Z0-9_:-]+', Name.Attribute),
+ (r'[\w:-]+\s*=', Name.Attribute, 'attr'),
+ (r'[\w:-]+', Name.Attribute),
(r'/?\s*>', Name.Tag, '#pop'),
],
'script-content': [
@@ -801,8 +801,8 @@ class PhpLexer(RegexLexer):
# Note that a backslash is included in the following two patterns
# PHP uses a backslash as a namespace separator
- _ident_char = r'[\\_a-zA-Z0-9]|[^\x00-\x7f]'
- _ident_begin = r'(?:[\\_a-zA-Z]|[^\x00-\x7f])'
+ _ident_char = r'[\\\w]|[^\x00-\x7f]'
+ _ident_begin = r'(?:[\\_a-z]|[^\x00-\x7f])'
_ident_end = r'(?:' + _ident_char + ')*'
_ident_inner = _ident_begin + _ident_end
@@ -852,7 +852,7 @@ class PhpLexer(RegexLexer):
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
(r'\d+[eE][+-]?[0-9]+', Number.Float),
(r'0[0-7]+', Number.Oct),
- (r'0[xX][a-fA-F0-9]+', Number.Hex),
+ (r'0[xX][a-f0-9]+', Number.Hex),
(r'\d+', Number.Integer),
(r'0b[01]+', Number.Binary),
(r"'([^'\\]*(?:\\.[^'\\]*)*)'", String.Single),
@@ -868,7 +868,7 @@ class PhpLexer(RegexLexer):
'string': [
(r'"', String.Double, '#pop'),
(r'[^{$"\\]+', String.Double),
- (r'\\([nrt\"$\\]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})', String.Escape),
+ (r'\\([nrt\"$\\]|[0-7]{1,3}|x[0-9a-f]{1,2})', String.Escape),
(r'\$' + _ident_inner + '(\[\S+?\]|->' + _ident_inner + ')?',
String.Interpol),
(r'(\{\$\{)(.*?)(\}\})',
@@ -1118,8 +1118,8 @@ class MxmlLexer(RegexLexer):
('<!--', Comment, 'comment'),
(r'<\?.*?\?>', Comment.Preproc),
('<![^>]*>', Comment.Preproc),
- (r'<\s*[a-zA-Z0-9:._-]+', Name.Tag, 'tag'),
- (r'<\s*/\s*[a-zA-Z0-9:._-]+\s*>', Name.Tag),
+ (r'<\s*[\w:.-]+', Name.Tag, 'tag'),
+ (r'<\s*/\s*[\w:.-]+\s*>', Name.Tag),
],
'comment': [
('[^-]+', Comment),
@@ -1128,7 +1128,7 @@ class MxmlLexer(RegexLexer):
],
'tag': [
(r'\s+', Text),
- (r'[a-zA-Z0-9_.:-]+\s*=', Name.Attribute, 'attr'),
+ (r'[\w.:-]+\s*=', Name.Attribute, 'attr'),
(r'/?\s*>', Name.Tag, '#pop'),
],
'attr': [
@@ -1161,11 +1161,10 @@ class HaxeLexer(ExtendedRegexLexer):
r'inline|using|null|true|false|abstract)\b')
# idtype in lexer.mll
- typeid = r'_*[A-Z][_a-zA-Z0-9]*'
+ typeid = r'_*[A-Z]\w*'
# combined ident and dollar and idtype
- ident = r'(?:_*[a-z][_a-zA-Z0-9]*|_+[0-9][_a-zA-Z0-9]*|' + typeid + \
- '|_+|\$[_a-zA-Z0-9]+)'
+ ident = r'(?:_*[a-z]\w*|_+[0-9]\w*|' + typeid + '|_+|\$\w+)'
binop = (r'(?:%=|&=|\|=|\^=|\+=|\-=|\*=|/=|<<=|>\s*>\s*=|>\s*>\s*>\s*=|==|'
r'!=|<=|>\s*=|&&|\|\||<<|>>>|>\s*>|\.\.\.|<|>|%|&|\||\^|\+|\*|'
@@ -1297,6 +1296,19 @@ class HaxeLexer(ExtendedRegexLexer):
(r'\(', Comment.Preproc, ('#pop', 'preproc-parenthesis')),
(ident, Comment.Preproc, '#pop'),
+
+ # Float
+ (r'\.[0-9]+', Number.Float),
+ (r'[0-9]+[eE][\+\-]?[0-9]+', Number.Float),
+ (r'[0-9]+\.[0-9]*[eE][\+\-]?[0-9]+', Number.Float),
+ (r'[0-9]+\.[0-9]+', Number.Float),
+ (r'[0-9]+\.(?!' + ident + '|\.\.)', Number.Float),
+
+ # Int
+ (r'0x[0-9a-fA-F]+', Number.Hex),
+ (r'[0-9]+', Number.Integer),
+
+ # String
(r"'", String.Single, ('#pop', 'string-single')),
(r'"', String.Double, ('#pop', 'string-double')),
],
@@ -1321,6 +1333,19 @@ class HaxeLexer(ExtendedRegexLexer):
('#pop', 'preproc-expr-chain', 'preproc-parenthesis')),
(ident, Comment.Preproc, ('#pop', 'preproc-expr-chain')),
+
+ # Float
+ (r'\.[0-9]+', Number.Float, ('#pop', 'preproc-expr-chain')),
+ (r'[0-9]+[eE][\+\-]?[0-9]+', Number.Float, ('#pop', 'preproc-expr-chain')),
+ (r'[0-9]+\.[0-9]*[eE][\+\-]?[0-9]+', Number.Float, ('#pop', 'preproc-expr-chain')),
+ (r'[0-9]+\.[0-9]+', Number.Float, ('#pop', 'preproc-expr-chain')),
+ (r'[0-9]+\.(?!' + ident + '|\.\.)', Number.Float, ('#pop', 'preproc-expr-chain')),
+
+ # Int
+ (r'0x[0-9a-fA-F]+', Number.Hex, ('#pop', 'preproc-expr-chain')),
+ (r'[0-9]+', Number.Integer, ('#pop', 'preproc-expr-chain')),
+
+ # String
(r"'", String.Single,
('#pop', 'preproc-expr-chain', 'string-single')),
(r'"', String.Double,
@@ -1454,7 +1479,7 @@ class HaxeLexer(ExtendedRegexLexer):
'class-member': [
include('spaces'),
(r'(var)\b', Keyword.Declaration,
- ('#pop', 'optional-semicolon', 'prop')),
+ ('#pop', 'optional-semicolon', 'var')),
(r'(function)\b', Keyword.Declaration,
('#pop', 'optional-semicolon', 'class-method')),
],
@@ -1463,7 +1488,7 @@ class HaxeLexer(ExtendedRegexLexer):
'function-local': [
include('spaces'),
(r'(' + ident_no_keyword + ')?', Name.Function,
- ('#pop', 'expr', 'flag', 'function-param',
+ ('#pop', 'optional-expr', 'flag', 'function-param',
'parenthesis-open', 'type-param-constraint')),
],
@@ -1495,13 +1520,6 @@ class HaxeLexer(ExtendedRegexLexer):
(r',', Punctuation, ('#pop', 'function-param')),
],
- # class property
- # eg. var prop(default, null):String;
- 'prop': [
- include('spaces'),
- (ident_no_keyword, Name, ('#pop', 'assign', 'flag', 'prop-get-set')),
- ],
-
'prop-get-set': [
include('spaces'),
(r'\(', Punctuation, ('#pop', 'parenthesis-close',
@@ -1528,7 +1546,8 @@ class HaxeLexer(ExtendedRegexLexer):
'meta-ident', 'meta-colon')),
(r'(?:\+\+|\-\-|~(?!/)|!|\-)', Operator),
(r'\(', Punctuation, ('#pop', 'expr-chain', 'parenthesis')),
- (r'(?:inline)\b', Keyword.Declaration),
+ (r'(?:static|public|private|override|dynamic|inline)\b',
+ Keyword.Declaration),
(r'(?:function)\b', Keyword.Declaration, ('#pop', 'expr-chain',
'function-local')),
(r'\{', Punctuation, ('#pop', 'expr-chain', 'bracket')),
@@ -1587,7 +1606,15 @@ class HaxeLexer(ExtendedRegexLexer):
# macro reification
'macro': [
include('spaces'),
+ include('meta'),
(r':', Punctuation, ('#pop', 'type')),
+
+ (r'(?:extern|private)\b', Keyword.Declaration),
+ (r'(?:abstract)\b', Keyword.Declaration, ('#pop', 'optional-semicolon', 'abstract')),
+ (r'(?:class|interface)\b', Keyword.Declaration, ('#pop', 'optional-semicolon', 'class')),
+ (r'(?:enum)\b', Keyword.Declaration, ('#pop', 'optional-semicolon', 'enum')),
+ (r'(?:typedef)\b', Keyword.Declaration, ('#pop', 'optional-semicolon', 'typedef')),
+
(r'', Text, ('#pop', 'expr')),
],
@@ -1740,7 +1767,7 @@ class HaxeLexer(ExtendedRegexLexer):
'dollar': [
include('spaces'),
- (r'\{', Keyword, ('#pop', 'bracket-close', 'expr')),
+ (r'\{', Punctuation, ('#pop', 'expr-chain', 'bracket-close', 'expr')),
(r'', Text, ('#pop', 'expr-chain')),
],
@@ -1868,7 +1895,7 @@ class HaxeLexer(ExtendedRegexLexer):
# a parenthesis expr that contain exactly one expr
'parenthesis': [
include('spaces'),
- (r'', Text, ('#pop', 'parenthesis-close', 'expr')),
+ (r'', Text, ('#pop', 'parenthesis-close', 'flag', 'expr')),
],
'parenthesis-open': [
@@ -1883,7 +1910,7 @@ class HaxeLexer(ExtendedRegexLexer):
'var': [
include('spaces'),
- (ident_no_keyword, Text, ('#pop', 'var-sep', 'assign', 'flag')),
+ (ident_no_keyword, Text, ('#pop', 'var-sep', 'assign', 'flag', 'prop-get-set')),
],
# optional more var decl.
@@ -2038,8 +2065,8 @@ class HamlLexer(ExtendedRegexLexer):
],
'css': [
- (r'\.[a-z0-9_:-]+', Name.Class, 'tag'),
- (r'\#[a-z0-9_:-]+', Name.Function, 'tag'),
+ (r'\.[\w:-]+', Name.Class, 'tag'),
+ (r'\#[\w:-]+', Name.Function, 'tag'),
],
'eval-or-plain': [
@@ -2052,7 +2079,7 @@ class HamlLexer(ExtendedRegexLexer):
'content': [
include('css'),
- (r'%[a-z0-9_:-]+', Name.Tag, 'tag'),
+ (r'%[\w:-]+', Name.Tag, 'tag'),
(r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'),
(r'(/)(\[' + _dot + '*?\])(' + _dot + r'*\n)',
bygroups(Comment, Comment.Special, Comment),
@@ -2088,16 +2115,16 @@ class HamlLexer(ExtendedRegexLexer):
'html-attributes': [
(r'\s+', Text),
- (r'[a-z0-9_:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
- (r'[a-z0-9_:-]+', Name.Attribute),
+ (r'[\w:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
+ (r'[\w:-]+', Name.Attribute),
(r'\)', Text, '#pop'),
],
'html-attribute-value': [
(r'[ \t]+', Text),
- (r'[a-z0-9_]+', Name.Variable, '#pop'),
- (r'@[a-z0-9_]+', Name.Variable.Instance, '#pop'),
- (r'\$[a-z0-9_]+', Name.Variable.Global, '#pop'),
+ (r'\w+', Name.Variable, '#pop'),
+ (r'@\w+', Name.Variable.Instance, '#pop'),
+ (r'\$\w+', Name.Variable.Global, '#pop'),
(r"'(\\\\|\\'|[^'\n])*'", String, '#pop'),
(r'"(\\\\|\\"|[^"\n])*"', String, '#pop'),
],
@@ -2237,7 +2264,7 @@ common_sass_tokens = {
(r'\:', Name.Decorator, 'pseudo-class'),
(r'\.', Name.Class, 'class'),
(r'\#', Name.Namespace, 'id'),
- (r'[a-zA-Z0-9_-]+', Name.Tag),
+ (r'[\w-]+', Name.Tag),
(r'#\{', String.Interpol, 'interpolation'),
(r'&', Keyword),
(r'[~\^\*!&\[\]\(\)<>\|+=@:;,./?-]', Operator),
@@ -2317,7 +2344,7 @@ class SassLexer(ExtendedRegexLexer):
(r'(@mixin)( [\w-]+)', bygroups(Keyword, Name.Function), 'value'),
(r'(@include)( [\w-]+)', bygroups(Keyword, Name.Decorator), 'value'),
(r'@extend', Keyword, 'selector'),
- (r'@[a-z0-9_-]+', Keyword, 'selector'),
+ (r'@[\w-]+', Keyword, 'selector'),
(r'=[\w-]+', Name.Function, 'value'),
(r'\+[\w-]+', Name.Decorator, 'value'),
(r'([!$][\w-]\w*)([ \t]*(?:(?:\|\|)?=|:))',
@@ -2390,7 +2417,7 @@ class ScssLexer(RegexLexer):
(r'(@mixin)( [\w-]+)', bygroups(Keyword, Name.Function), 'value'),
(r'(@include)( [\w-]+)', bygroups(Keyword, Name.Decorator), 'value'),
(r'@extend', Keyword, 'selector'),
- (r'@[a-z0-9_-]+', Keyword, 'selector'),
+ (r'@[\w-]+', Keyword, 'selector'),
(r'(\$[\w-]*\w)([ \t]*:)', bygroups(Name.Variable, Operator), 'value'),
(r'(?=[^;{}][;}])', Name.Attribute, 'attr'),
(r'(?=[^;{}:]+:[^a-z])', Name.Attribute, 'attr'),
@@ -2473,12 +2500,12 @@ class CoffeeScriptLexer(RegexLexer):
r'decodeURIComponent|encodeURI|encodeURIComponent|'
r'eval|isFinite|isNaN|parseFloat|parseInt|document|window)\b',
Name.Builtin),
- (r'[$a-zA-Z_][a-zA-Z0-9_\.:\$]*\s*[:=]\s', Name.Variable,
+ (r'[$a-zA-Z_][\w\.:\$]*\s*[:=]\s', Name.Variable,
'slashstartsregex'),
- (r'@[$a-zA-Z_][a-zA-Z0-9_\.:\$]*\s*[:=]\s', Name.Variable.Instance,
+ (r'@[$a-zA-Z_][\w\.:\$]*\s*[:=]\s', Name.Variable.Instance,
'slashstartsregex'),
(r'@', Name.Other, 'slashstartsregex'),
- (r'@?[$a-zA-Z_][a-zA-Z0-9_\$]*', Name.Other, 'slashstartsregex'),
+ (r'@?[$a-zA-Z_][\w\$]*', Name.Other, 'slashstartsregex'),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
(r'[0-9]+', Number.Integer),
@@ -2500,6 +2527,7 @@ class CoffeeScriptLexer(RegexLexer):
(r'"', String, '#pop'),
(r'\\.|\'', String), # double-quoted string don't need ' escapes
(r'#{', String.Interpol, "interpoling_string"),
+ (r'#', String),
include('strings')
],
'sqs': [
@@ -2511,6 +2539,7 @@ class CoffeeScriptLexer(RegexLexer):
(r'"""', String, '#pop'),
(r'\\.|\'|"', String), # no need to escape quotes in triple-string
(r'#{', String.Interpol, "interpoling_string"),
+ (r'#', String),
include('strings'),
],
'tsqs': [
@@ -2544,13 +2573,13 @@ class KalLexer(RegexLexer):
(r'#(?!##[^#]).*?\n', Comment.Single),
],
'functiondef': [
- (r'[$a-zA-Z_][a-zA-Z0-9_\$]*\s*', Name.Function, '#pop'),
+ (r'[$a-zA-Z_][\w\$]*\s*', Name.Function, '#pop'),
include('commentsandwhitespace'),
],
'classdef': [
(r'\binherits\s+from\b', Keyword),
- (r'[$a-zA-Z_][a-zA-Z0-9_\$]*\s*\n', Name.Class, '#pop'),
- (r'[$a-zA-Z_][a-zA-Z0-9_\$]*\s*', Name.Class),
+ (r'[$a-zA-Z_][\w\$]*\s*\n', Name.Class, '#pop'),
+ (r'[$a-zA-Z_][\w\$]*\s*', Name.Class),
include('commentsandwhitespace'),
],
'listcomprehension': [
@@ -2579,7 +2608,7 @@ class KalLexer(RegexLexer):
(r'\b(function|method|task)\b', Keyword.Declaration, 'functiondef'),
(r'\bclass\b', Keyword.Declaration, 'classdef'),
(r'\b(safe\s+)?wait\s+for\b', Keyword, 'waitfor'),
- (r'\b(me|this)(\.[$a-zA-Z_][a-zA-Z0-9_\.\$]*)?\b', Name.Variable.Instance),
+ (r'\b(me|this)(\.[$a-zA-Z_][\w\.\$]*)?\b', Name.Variable.Instance),
(r'(?<![\.\$])(for(\s+(parallel|series))?|in|of|while|until|'
r'break|return|continue|'
r'when|if|unless|else|otherwise|except\s+when|'
@@ -2595,7 +2624,7 @@ class KalLexer(RegexLexer):
r'eval|isFinite|isNaN|parseFloat|parseInt|document|window|'
r'print)\b',
Name.Builtin),
- (r'[$a-zA-Z_][a-zA-Z0-9_\.\$]*\s*(:|[\+\-\*\/]?\=)?\b', Name.Variable),
+ (r'[$a-zA-Z_][\w\.\$]*\s*(:|[\+\-\*\/]?\=)?\b', Name.Variable),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
(r'[0-9]+', Number.Integer),
@@ -2698,19 +2727,19 @@ class LiveScriptLexer(RegexLexer):
r'decodeURIComponent|encodeURI|encodeURIComponent|'
r'eval|isFinite|isNaN|parseFloat|parseInt|document|window)\b',
Name.Builtin),
- (r'[$a-zA-Z_][a-zA-Z0-9_\.\-:\$]*\s*[:=]\s', Name.Variable,
+ (r'[$a-zA-Z_][\w\.\-:\$]*\s*[:=]\s', Name.Variable,
'slashstartsregex'),
- (r'@[$a-zA-Z_][a-zA-Z0-9_\.\-:\$]*\s*[:=]\s', Name.Variable.Instance,
+ (r'@[$a-zA-Z_][\w\.\-:\$]*\s*[:=]\s', Name.Variable.Instance,
'slashstartsregex'),
(r'@', Name.Other, 'slashstartsregex'),
- (r'@?[$a-zA-Z_][a-zA-Z0-9_\-]*', Name.Other, 'slashstartsregex'),
+ (r'@?[$a-zA-Z_][\w\-]*', Name.Other, 'slashstartsregex'),
(r'[0-9]+\.[0-9]+([eE][0-9]+)?[fd]?(?:[a-zA-Z_]+)?', Number.Float),
(r'[0-9]+(~[0-9a-z]+)?(?:[a-zA-Z_]+)?', Number.Integer),
('"""', String, 'tdqs'),
("'''", String, 'tsqs'),
('"', String, 'dqs'),
("'", String, 'sqs'),
- (r'\\[\w$-]+', String),
+ (r'\\\S+', String),
(r'<\[.*?\]>', String),
],
'strings': [
@@ -2808,8 +2837,8 @@ class ScamlLexer(ExtendedRegexLexer):
],
'css': [
- (r'\.[a-z0-9_:-]+', Name.Class, 'tag'),
- (r'\#[a-z0-9_:-]+', Name.Function, 'tag'),
+ (r'\.[\w:-]+', Name.Class, 'tag'),
+ (r'\#[\w:-]+', Name.Function, 'tag'),
],
'eval-or-plain': [
@@ -2822,7 +2851,7 @@ class ScamlLexer(ExtendedRegexLexer):
'content': [
include('css'),
- (r'%[a-z0-9_:-]+', Name.Tag, 'tag'),
+ (r'%[\w:-]+', Name.Tag, 'tag'),
(r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'),
(r'(/)(\[' + _dot + '*?\])(' + _dot + r'*\n)',
bygroups(Comment, Comment.Special, Comment),
@@ -2861,16 +2890,16 @@ class ScamlLexer(ExtendedRegexLexer):
'html-attributes': [
(r'\s+', Text),
- (r'[a-z0-9_:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
- (r'[a-z0-9_:-]+', Name.Attribute),
+ (r'[\w:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
+ (r'[\w:-]+', Name.Attribute),
(r'\)', Text, '#pop'),
],
'html-attribute-value': [
(r'[ \t]+', Text),
- (r'[a-z0-9_]+', Name.Variable, '#pop'),
- (r'@[a-z0-9_]+', Name.Variable.Instance, '#pop'),
- (r'\$[a-z0-9_]+', Name.Variable.Global, '#pop'),
+ (r'\w+', Name.Variable, '#pop'),
+ (r'@\w+', Name.Variable.Instance, '#pop'),
+ (r'\$\w+', Name.Variable.Global, '#pop'),
(r"'(\\\\|\\'|[^'\n])*'", String, '#pop'),
(r'"(\\\\|\\"|[^"\n])*"', String, '#pop'),
],
@@ -2918,8 +2947,8 @@ class JadeLexer(ExtendedRegexLexer):
],
'css': [
- (r'\.[a-z0-9_:-]+', Name.Class, 'tag'),
- (r'\#[a-z0-9_:-]+', Name.Function, 'tag'),
+ (r'\.[\w:-]+', Name.Class, 'tag'),
+ (r'\#[\w:-]+', Name.Function, 'tag'),
],
'eval-or-plain': [
@@ -2947,7 +2976,7 @@ class JadeLexer(ExtendedRegexLexer):
'#pop'),
(r':' + _dot + r'*\n', _starts_block(Name.Decorator, 'filter-block'),
'#pop'),
- (r'[a-z0-9_:-]+', Name.Tag, 'tag'),
+ (r'[\w:-]+', Name.Tag, 'tag'),
(r'\|', Text, 'eval-or-plain'),
],
@@ -2970,16 +2999,16 @@ class JadeLexer(ExtendedRegexLexer):
'html-attributes': [
(r'\s+', Text),
- (r'[a-z0-9_:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
- (r'[a-z0-9_:-]+', Name.Attribute),
+ (r'[\w:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
+ (r'[\w:-]+', Name.Attribute),
(r'\)', Text, '#pop'),
],
'html-attribute-value': [
(r'[ \t]+', Text),
- (r'[a-z0-9_]+', Name.Variable, '#pop'),
- (r'@[a-z0-9_]+', Name.Variable.Instance, '#pop'),
- (r'\$[a-z0-9_]+', Name.Variable.Global, '#pop'),
+ (r'\w+', Name.Variable, '#pop'),
+ (r'@\w+', Name.Variable.Instance, '#pop'),
+ (r'\$\w+', Name.Variable.Global, '#pop'),
(r"'(\\\\|\\'|[^'\n])*'", String, '#pop'),
(r'"(\\\\|\\"|[^"\n])*"', String, '#pop'),
],
@@ -3699,8 +3728,8 @@ class DartLexer(RegexLexer):
(r'\b(bool|double|Dynamic|int|num|Object|String|void)\b', Keyword.Type),
(r'\b(false|null|true)\b', Keyword.Constant),
(r'[~!%^&*+=|?:<>/-]|as\b', Operator),
- (r'[a-zA-Z_$][a-zA-Z0-9_]*:', Name.Label),
- (r'[a-zA-Z_$][a-zA-Z0-9_]*', Name),
+ (r'[a-zA-Z_$]\w*:', Name.Label),
+ (r'[a-zA-Z_$]\w*', Name),
(r'[(){}\[\],.;]', Punctuation),
(r'0[xX][0-9a-fA-F]+', Number.Hex),
# DIGIT+ (‘.’ DIGIT*)? EXPONENT?
@@ -3710,13 +3739,13 @@ class DartLexer(RegexLexer):
# pseudo-keyword negate intentionally left out
],
'class': [
- (r'[a-zA-Z_$][a-zA-Z0-9_]*', Name.Class, '#pop')
+ (r'[a-zA-Z_$]\w*', Name.Class, '#pop')
],
'import_decl': [
include('string_literal'),
(r'\s+', Text),
(r'\b(as|show|hide)\b', Keyword),
- (r'[a-zA-Z_$][a-zA-Z0-9_]*', Name),
+ (r'[a-zA-Z_$]\w*', Name),
(r'\,', Punctuation),
(r'\;', Punctuation, '#pop')
],
@@ -3735,7 +3764,7 @@ class DartLexer(RegexLexer):
'string_common': [
(r"\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\{[0-9A-Fa-f]*\}|[a-z\'\"$\\])",
String.Escape),
- (r'(\$)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(String.Interpol, Name)),
+ (r'(\$)([a-zA-Z_]\w*)', bygroups(String.Interpol, Name)),
(r'(\$\{)(.*?)(\})',
bygroups(String.Interpol, using(this), String.Interpol))
],
@@ -3818,7 +3847,7 @@ class TypeScriptLexer(RegexLexer):
r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
r'window)\b', Name.Builtin),
# Match stuff like: module name {...}
- (r'\b(module)(\s*)(\s*[a-zA-Z0-9_?.$][\w?.$]*)(\s*)',
+ (r'\b(module)(\s*)(\s*[\w?.$][\w?.$]*)(\s*)',
bygroups(Keyword.Reserved, Text, Name.Other, Text), 'slashstartsregex'),
# Match variable type keywords
(r'\b(string|bool|number)\b', Keyword.Type),
@@ -3830,9 +3859,9 @@ class TypeScriptLexer(RegexLexer):
# Match stuff like: function() {...}
(r'([a-zA-Z_?.$][\w?.$]*)\(\) \{', Name.Other, 'slashstartsregex'),
# Match stuff like: (function: return type)
- (r'([a-zA-Z0-9_?.$][\w?.$]*)(\s*:\s*)([a-zA-Z0-9_?.$][\w?.$]*)',
+ (r'([\w?.$][\w?.$]*)(\s*:\s*)([\w?.$][\w?.$]*)',
bygroups(Name.Other, Text, Keyword.Type)),
- (r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
+ (r'[$a-zA-Z_]\w*', Name.Other),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
(r'[0-9]+', Number.Integer),
@@ -4165,7 +4194,7 @@ class QmlLexer(RegexLexer):
r'decodeURIComponent|encodeURI|encodeURIComponent|'
r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
r'window)\b', Name.Builtin),
- (r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
+ (r'[$a-zA-Z_]\w*', Name.Other),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
(r'[0-9]+', Number.Integer),
@@ -4256,8 +4285,8 @@ class MaskLexer(RegexLexer):
(r'"', String, 'string-double'),
(r'([\w-]+)', Name.Tag, 'node'),
(r'([^\.#;{>\s]+)', Name.Class, 'node'),
- (r'(#[\w_-]+)', Name.Function, 'node'),
- (r'(\.[\w_-]+)', Name.Variable.Class, 'node')
+ (r'(#[\w-]+)', Name.Function, 'node'),
+ (r'(\.[\w-]+)', Name.Variable.Class, 'node')
],
'string-base': [
(r'\\.', String.Escape),
@@ -4294,8 +4323,8 @@ class MaskLexer(RegexLexer):
(r'\.', Name.Variable.Class, 'node-class'),
(r'\#', Name.Function, 'node-id'),
(r'style[ \t]*=', Name.Attribute, 'node-attr-style-value'),
- (r'[\w_:-]+[ \t]*=', Name.Attribute, 'node-attr-value'),
- (r'[\w_:-]+', Name.Attribute),
+ (r'[\w:-]+[ \t]*=', Name.Attribute, 'node-attr-value'),
+ (r'[\w:-]+', Name.Attribute),
(r'[>{;]', Punctuation, '#pop')
],
'node-class': [
@@ -4310,7 +4339,7 @@ class MaskLexer(RegexLexer):
],
'node-attr-value':[
(r'\s+', Text),
- (r'[\w_]+', Name.Variable, '#pop'),
+ (r'\w+', Name.Variable, '#pop'),
(r"'", String, 'string-single-pop2'),
(r'"', String, 'string-double-pop2'),
(r'', Text, '#pop')
@@ -4323,8 +4352,8 @@ class MaskLexer(RegexLexer):
],
'css-base': [
(r'\s+', Text),
- (r"[;]", Punctuation),
- (r"[\w\-_]+\s*:", Name.Builtin)
+ (r";", Punctuation),
+ (r"[\w\-]+\s*:", Name.Builtin)
],
'css-single-end': [
include('css-base'),
@@ -4388,19 +4417,20 @@ class ZephirLexer(RegexLexer):
r'(<<|>>>?|==?|!=?|->|[-<>+*%&\|\^/])=?', Operator, 'slashstartsregex'),
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
(r'[})\].]', Punctuation),
- (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|loop|require|inline|'
- r'throw|try|catch|finally|new|delete|typeof|instanceof|void|namespace|use|extends|'
- r'this|fetch|isset|unset|echo|fetch|likely|unlikely|empty)\b', Keyword, 'slashstartsregex'),
+ (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|loop|'
+ r'require|inline|throw|try|catch|finally|new|delete|typeof|instanceof|void|'
+ r'namespace|use|extends|this|fetch|isset|unset|echo|fetch|likely|unlikely|'
+ r'empty)\b', Keyword, 'slashstartsregex'),
(r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
- (r'(abstract|boolean|bool|char|class|const|double|enum|export|'
- r'extends|final|float|goto|implements|import|int|string|interface|long|ulong|char|uchar|native|unsigned|'
- r'private|protected|public|short|static|self|throws|reverse|'
+ (r'(abstract|boolean|bool|char|class|const|double|enum|export|extends|final|'
+ r'native|goto|implements|import|int|string|interface|long|ulong|char|uchar|'
+ r'float|unsigned|private|protected|public|short|static|self|throws|reverse|'
r'transient|volatile)\b', Keyword.Reserved),
(r'(true|false|null|undefined)\b', Keyword.Constant),
(r'(Array|Boolean|Date|_REQUEST|_COOKIE|_SESSION|'
r'_GET|_POST|_SERVER|this|stdClass|range|count|iterator|'
r'window)\b', Name.Builtin),
- (r'[$a-zA-Z_][a-zA-Z0-9_\\]*', Name.Other),
+ (r'[$a-zA-Z_][\w\\]*', Name.Other),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
(r'[0-9]+', Number.Integer),