summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaurav Jain <gaurav@gauravjain.org>2014-05-14 22:08:28 -0400
committerGaurav Jain <gaurav@gauravjain.org>2014-05-14 22:08:28 -0400
commit745f1e190950d2510aecc33de9f1727e24ddddf0 (patch)
treecf23557213ee9ab7b6cae7cfb30b54f92bdf9fc6
parent41dc0d839cbee3a6bde8511d6fe246503b605c66 (diff)
downloadpygments-745f1e190950d2510aecc33de9f1727e24ddddf0.tar.gz
Replace all occurences of [a-zA-Z0-9_] with \w
-rw-r--r--pygments/lexers/agile.py72
-rw-r--r--pygments/lexers/compiled.py66
-rw-r--r--pygments/lexers/dalvik.py2
-rw-r--r--pygments/lexers/dotnet.py18
-rw-r--r--pygments/lexers/functional.py8
-rw-r--r--pygments/lexers/graph.py2
-rw-r--r--pygments/lexers/hdl.py28
-rw-r--r--pygments/lexers/inferno.py4
-rw-r--r--pygments/lexers/jvm.py58
-rw-r--r--pygments/lexers/math.py18
-rw-r--r--pygments/lexers/other.py96
-rw-r--r--pygments/lexers/shell.py4
-rw-r--r--pygments/lexers/sql.py8
-rw-r--r--pygments/lexers/templates.py28
-rw-r--r--pygments/lexers/text.py2
-rw-r--r--pygments/lexers/web.py58
16 files changed, 236 insertions, 236 deletions
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py
index 9057ac40..77473b65 100644
--- a/pygments/lexers/agile.py
+++ b/pygments/lexers/agile.py
@@ -120,13 +120,13 @@ class PythonLexer(RegexLexer):
],
'name': [
(r'@[a-zA-Z0-9_.]+', Name.Decorator),
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ ('[a-zA-Z_]\w*', Name),
],
'funcname': [
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Function, '#pop')
+ ('[a-zA-Z_]\w*', Name.Function, '#pop')
],
'classname': [
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+ ('[a-zA-Z_]\w*', Name.Class, '#pop')
],
'import': [
(r'(?:[ \t]|\\\n)+', Text),
@@ -152,7 +152,7 @@ class PythonLexer(RegexLexer):
r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
],
'strings': [
- (r'%(\([a-zA-Z0-9_]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
+ (r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
'[hlL]?[diouxXeEfFgGcrs%]', String.Interpol),
(r'[^\\\'"%\n]+', String),
# quotes, percents and backslashes must be parsed one at a time
@@ -255,7 +255,7 @@ class Python3Lexer(RegexLexer):
]
tokens['backtick'] = []
tokens['name'] = [
- (r'@[a-zA-Z0-9_]+', Name.Decorator),
+ (r'@\w+', Name.Decorator),
(uni_name, Name),
]
tokens['funcname'] = [
@@ -406,7 +406,7 @@ class PythonTracebackLexer(RegexLexer):
bygroups(Text, Comment, Text)), # for doctests...
(r'^([^:]+)(: )(.+)(\n)',
bygroups(Generic.Error, Text, Name, Text), '#pop'),
- (r'^([a-zA-Z_][a-zA-Z0-9_]*)(:?\n)',
+ (r'^([a-zA-Z_]\w*)(:?\n)',
bygroups(Generic.Error, Text), '#pop')
],
}
@@ -445,7 +445,7 @@ class Python3TracebackLexer(RegexLexer):
bygroups(Text, Comment, Text)), # for doctests...
(r'^([^:]+)(: )(.+)(\n)',
bygroups(Generic.Error, Text, Name, Text), '#pop'),
- (r'^([a-zA-Z_][a-zA-Z0-9_]*)(:?\n)',
+ (r'^([a-zA-Z_]\w*)(:?\n)',
bygroups(Generic.Error, Text), '#pop')
],
}
@@ -535,7 +535,7 @@ class RubyLexer(ExtendedRegexLexer):
(r":'(\\\\|\\'|[^'])*'", String.Symbol),
(r"'(\\\\|\\'|[^'])*'", String.Single),
(r':"', String.Symbol, 'simple-sym'),
- (r'([a-zA-Z_][a-zA-Z0-9_]*)(:)(?!:)',
+ (r'([a-zA-Z_]\w*)(:)(?!:)',
bygroups(String.Symbol, Punctuation)), # Since Ruby 1.9
(r'"', String.Double, 'simple-string'),
(r'(?<!\.)`', String.Backtick, 'simple-backtick'),
@@ -621,8 +621,8 @@ class RubyLexer(ExtendedRegexLexer):
r'rescue|raise|retry|return|super|then|undef|unless|until|when|'
r'while|yield)\b', Keyword),
# start of function, class and module names
- (r'(module)(\s+)([a-zA-Z_][a-zA-Z0-9_]*'
- r'(?:::[a-zA-Z_][a-zA-Z0-9_]*)*)',
+ (r'(module)(\s+)([a-zA-Z_]\w*'
+ r'(?:::[a-zA-Z_]\w*)*)',
bygroups(Keyword, Text, Name.Namespace)),
(r'(def)(\s+)', bygroups(Keyword, Text), 'funcname'),
(r'def(?=[*%&^`~+-/\[<>=])', Keyword, 'funcname'),
@@ -713,9 +713,9 @@ class RubyLexer(ExtendedRegexLexer):
(r'([\d]+(?:_\d+)*)(\s*)([/?])?',
bygroups(Number.Integer, Text, Operator)),
# Names
- (r'@@[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable.Class),
- (r'@[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable.Instance),
- (r'\$[a-zA-Z0-9_]+', Name.Variable.Global),
+ (r'@@[a-zA-Z_]\w*', Name.Variable.Class),
+ (r'@[a-zA-Z_]\w*', Name.Variable.Instance),
+ (r'\$\w+', Name.Variable.Global),
(r'\$[!@&`\'+~=/\\,;.<>_*$?:"]', Name.Variable.Global),
(r'\$-[0adFiIlpvw]', Name.Variable.Global),
(r'::', Operator),
@@ -725,7 +725,7 @@ class RubyLexer(ExtendedRegexLexer):
r'(\\([\\abefnrstv#"\']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})|\S)'
r'(?!\w)',
String.Char),
- (r'[A-Z][a-zA-Z0-9_]+', Name.Constant),
+ (r'[A-Z]\w+', Name.Constant),
# this is needed because ruby attributes can look
# like keywords (class) or like this: ` ?!?
(r'(\.|::)([a-zA-Z_]\w*[\!\?]?|[*%&^`~+-/\[<>=])',
@@ -739,7 +739,7 @@ class RubyLexer(ExtendedRegexLexer):
],
'funcname': [
(r'\(', Punctuation, 'defexpr'),
- (r'(?:([a-zA-Z_][a-zA-Z0-9_]*)(\.))?'
+ (r'(?:([a-zA-Z_]\w*)(\.))?'
r'([a-zA-Z_]\w*[\!\?]?|\*\*?|[-+]@?|'
r'[/%&|^`~]|\[\]=?|<<|>>|<=?>|>=?|===?)',
bygroups(Name.Class, Operator, Name.Function), '#pop'),
@@ -762,8 +762,8 @@ class RubyLexer(ExtendedRegexLexer):
],
'string-intp': [
(r'#{', String.Interpol, 'in-intp'),
- (r'#@@?[a-zA-Z_][a-zA-Z0-9_]*', String.Interpol),
- (r'#\$[a-zA-Z_][a-zA-Z0-9_]*', String.Interpol)
+ (r'#@@?[a-zA-Z_]\w*', String.Interpol),
+ (r'#\$[a-zA-Z_]\w*', String.Interpol)
],
'string-intp-escaped': [
include('string-intp'),
@@ -814,7 +814,7 @@ class RubyConsoleLexer(Lexer):
aliases = ['rbcon', 'irb']
mimetypes = ['text/x-ruby-shellsession']
- _prompt_re = re.compile('irb\([a-zA-Z_][a-zA-Z0-9_]*\):\d{3}:\d+[>*"\'] '
+ _prompt_re = re.compile('irb\([a-zA-Z_]\w*\):\d{3}:\d+[>*"\'] '
'|>> |\?> ')
def get_tokens_unprocessed(self, text):
@@ -875,7 +875,7 @@ class PerlLexer(RegexLexer):
(r'(case|continue|do|else|elsif|for|foreach|if|last|my|'
r'next|our|redo|reset|then|unless|until|while|use|'
r'print|new|BEGIN|CHECK|INIT|END|return)\b', Keyword),
- (r'(format)(\s+)([a-zA-Z0-9_]+)(\s*)(=)(\s*\n)',
+ (r'(format)(\s+)(\w+)(\s*)(=)(\s*\n)',
bygroups(Keyword, Text, Name, Text, Punctuation, Text), 'format'),
(r'(eq|lt|gt|le|ge|ne|not|and|or|cmp)\b', Operator.Word),
# common delimiters
@@ -928,7 +928,7 @@ class PerlLexer(RegexLexer):
r'utime|values|vec|wait|waitpid|wantarray|warn|write'
r')\b', Name.Builtin),
(r'((__(DATA|DIE|WARN)__)|(STD(IN|OUT|ERR)))\b', Name.Builtin.Pseudo),
- (r'<<([\'"]?)([a-zA-Z_][a-zA-Z0-9_]*)\1;?\n.*?\n\2\n', String),
+ (r'<<([\'"]?)([a-zA-Z_]\w*)\1;?\n.*?\n\2\n', String),
(r'__END__', Comment.Preproc, 'end-part'),
(r'\$\^[ADEFHILMOPSTWX]', Name.Variable.Global),
(r"\$[\\\"\[\]'&`+*.,;=%~?@$!<>(^|/-](?!\w)", Name.Variable.Global),
@@ -966,11 +966,11 @@ class PerlLexer(RegexLexer):
(r'\s+', Text),
(r'\{', Punctuation, '#pop'), # hash syntax?
(r'\)|,', Punctuation, '#pop'), # argument specifier
- (r'[a-zA-Z0-9_]+::', Name.Namespace),
+ (r'\w+::', Name.Namespace),
(r'[a-zA-Z0-9_:]+', Name.Variable, '#pop'),
],
'name': [
- (r'[a-zA-Z0-9_]+::', Name.Namespace),
+ (r'\w+::', Name.Namespace),
(r'[a-zA-Z0-9_:]+', Name, '#pop'),
(r'[A-Z_]+(?=[^a-zA-Z0-9_])', Name.Constant, '#pop'),
(r'(?=[^a-zA-Z0-9_])', Text, '#pop'),
@@ -1085,7 +1085,7 @@ class LuaLexer(RegexLexer):
(r'(function)\b', Keyword, 'funcname'),
- (r'[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?', Name),
+ (r'[A-Za-z_]\w*(\.[A-Za-z_]\w*)?', Name),
("'", String.Single, combined('stringescape', 'sqs')),
('"', String.Double, combined('stringescape', 'dqs'))
@@ -1093,7 +1093,7 @@ class LuaLexer(RegexLexer):
'funcname': [
(r'\s+', Text),
- ('(?:([A-Za-z_][A-Za-z0-9_]*)(\.))?([A-Za-z_][A-Za-z0-9_]*)',
+ ('(?:([A-Za-z_]\w*)(\.))?([A-Za-z_]\w*)',
bygroups(Name.Class, Punctuation, Name.Function), '#pop'),
# inline function
('\(', Punctuation, '#pop'),
@@ -1176,20 +1176,20 @@ class MoonScriptLexer(LuaLexer):
(r'[^\S\n]+', Text),
(r'(?s)\[(=*)\[.*?\]\1\]', String),
(r'(->|=>)', Name.Function),
- (r':[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable),
+ (r':[a-zA-Z_]\w*', Name.Variable),
(r'(==|!=|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#!.\\:])', Operator),
(r'[;,]', Punctuation),
(r'[\[\]\{\}\(\)]', Keyword.Type),
- (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Variable),
+ (r'[a-zA-Z_]\w*:', Name.Variable),
(r"(class|extends|if|then|super|do|with|import|export|"
r"while|elseif|return|for|in|from|when|using|else|"
r"and|or|not|switch|break)\b", Keyword),
(r'(true|false|nil)\b', Keyword.Constant),
(r'(and|or|not)\b', Operator.Word),
(r'(self)\b', Name.Builtin.Pseudo),
- (r'@@?([a-zA-Z_][a-zA-Z0-9_]*)?', Name.Variable.Class),
+ (r'@@?([a-zA-Z_]\w*)?', Name.Variable.Class),
(r'[A-Z]\w*', Name.Class), # proper name
- (r'[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?', Name),
+ (r'[A-Za-z_]\w*(\.[A-Za-z_]\w*)?', Name),
("'", String.Single, combined('stringescape', 'sqs')),
('"', String.Double, combined('stringescape', 'dqs'))
],
@@ -1320,7 +1320,7 @@ class IoLexer(RegexLexer):
# names
(r'(Object|list|List|Map|args|Sequence|Coroutine|File)\b',
Name.Builtin),
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ ('[a-zA-Z_]\w*', Name),
# numbers
(r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
(r'\d+', Number.Integer)
@@ -1857,14 +1857,14 @@ class FancyLexer(RegexLexer):
r'FalseClass|Tuple|Symbol|Stack|Set|FancySpec|Method|Package|'
r'Range)\b', Name.Builtin),
# functions
- (r'[a-zA-Z]([a-zA-Z0-9_]|[-+?!=*/^><%])*:', Name.Function),
+ (r'[a-zA-Z](\w|[-+?!=*/^><%])*:', Name.Function),
# operators, must be below functions
(r'[-+*/~,<>=&!?%^\[\]\.$]+', Operator),
- ('[A-Z][a-zA-Z0-9_]*', Name.Constant),
- ('@[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable.Instance),
- ('@@[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable.Class),
+ ('[A-Z]\w*', Name.Constant),
+ ('@[a-zA-Z_]\w*', Name.Variable.Instance),
+ ('@@[a-zA-Z_]\w*', Name.Variable.Class),
('@@?', Operator),
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ ('[a-zA-Z_]\w*', Name),
# numbers - / checks are necessary to avoid mismarking regexes,
# see comment in RubyLexer
(r'(0[oO]?[0-7]+(?:_[0-7]+)*)(\s*)([/?])?',
@@ -1949,7 +1949,7 @@ class DgLexer(RegexLexer):
r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
],
'string': [
- (r'%(\([a-zA-Z0-9_]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
+ (r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
'[hlL]?[diouxXeEfFgGcrs%]', String.Interpol),
(r'[^\\\'"%\n]+', String),
# quotes, percents and backslashes must be parsed one at a time
@@ -2534,7 +2534,7 @@ class ChaiscriptLexer(RegexLexer):
(r'(true|false)\b', Keyword.Constant),
(r'(eval|throw)\b', Name.Builtin),
(r'`\S+`', 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),
diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py
index 0a59aa4a..5eb78669 100644
--- a/pygments/lexers/compiled.py
+++ b/pygments/lexers/compiled.py
@@ -88,13 +88,13 @@ class CFamilyLexer(RegexLexer):
r'raise|noop|identifier|forceinline|assume)\b', Keyword.Reserved),
(r'(true|false|NULL)\b', Name.Builtin),
(r'([a-zA-Z_]\w*)(\s*)(:)(?!:)', bygroups(Name.Label, Text, Punctuation)),
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ ('[a-zA-Z_]\w*', Name),
],
'root': [
include('whitespace'),
# functions
(r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
+ r'([a-zA-Z_]\w*)' # method name
r'(\s*\([^;]*?\))' # signature
r'(' + _ws + r')?({)',
bygroups(using(this), Name.Function, using(this), using(this),
@@ -102,7 +102,7 @@ class CFamilyLexer(RegexLexer):
'function'),
# function declarations
(r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
+ r'([a-zA-Z_]\w*)' # method name
r'(\s*\([^;]*?\))' # signature
r'(' + _ws + r')?(;)',
bygroups(using(this), Name.Function, using(this), using(this),
@@ -223,7 +223,7 @@ class CppLexer(CFamilyLexer):
(r'(__offload|__blockingoffload|__outer)\b', Keyword.Pseudo),
],
'classname': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop'),
# template specification
(r'\s*(?=>)', Text, '#pop'),
],
@@ -268,7 +268,7 @@ class PikeLexer(CppLexer):
inherit,
],
'classname': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop'),
# template specification
(r'\s*(?=>)', Text, '#pop'),
],
@@ -363,7 +363,7 @@ class ECLexer(CLexer):
inherit,
],
'classname': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop'),
# template specification
(r'\s*(?=>)', Text, '#pop'),
],
@@ -1374,9 +1374,9 @@ def objective(baselexer):
# Matches [ <ws>? identifier <ws> ( identifier <ws>? ] | identifier? : )
# (note the identifier is *optional* when there is a ':'!)
- _oc_message = re.compile(r'\[\s*[a-zA-Z_][a-zA-Z0-9_]*\s+'
- r'(?:[a-zA-Z_][a-zA-Z0-9_]*\s*\]|'
- r'(?:[a-zA-Z_][a-zA-Z0-9_]*)?:)')
+ _oc_message = re.compile(r'\[\s*[a-zA-Z_]\w*\s+'
+ r'(?:[a-zA-Z_]\w*\s*\]|'
+ r'(?:[a-zA-Z_]\w*)?:)')
class GeneratedObjectiveCVariant(baselexer):
"""
@@ -1761,7 +1761,7 @@ class PrologLexer(RegexLexer):
# This one includes !
(u'[#&*+\\-./:<=>?@\\\\^~\u00a1-\u00bf\u2010-\u303f]+',
String.Atom), # atom, graphics
- (r'[A-Z_][A-Za-z0-9_]*', Name.Variable),
+ (r'[A-Z_]\w*', Name.Variable),
(u'\\s+|[\u2000-\u200f\ufff0-\ufffe\uffef]', Text),
],
'nested-comment': [
@@ -1867,28 +1867,28 @@ class CythonLexer(RegexLexer):
('`.*?`', String.Backtick),
],
'name': [
- (r'@[a-zA-Z0-9_]+', Name.Decorator),
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ (r'@\w+', Name.Decorator),
+ ('[a-zA-Z_]\w*', Name),
],
'funcname': [
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Function, '#pop')
+ ('[a-zA-Z_]\w*', Name.Function, '#pop')
],
'cdef': [
(r'(public|readonly|extern|api|inline)\b', Keyword.Reserved),
(r'(struct|enum|union|class)\b', Keyword),
- (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(?=[(:#=]|$)',
+ (r'([a-zA-Z_]\w*)(\s*)(?=[(:#=]|$)',
bygroups(Name.Function, Text), '#pop'),
- (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(,)',
+ (r'([a-zA-Z_]\w*)(\s*)(,)',
bygroups(Name.Function, Text, Punctuation)),
(r'from\b', Keyword, '#pop'),
(r'as\b', Keyword),
(r':', Punctuation, '#pop'),
(r'(?=["\'])', Text, '#pop'),
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Keyword.Type),
+ (r'[a-zA-Z_]\w*', Keyword.Type),
(r'.', Text),
],
'classname': [
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+ ('[a-zA-Z_]\w*', Name.Class, '#pop')
],
'import': [
(r'(\s+)(as)(\s+)', bygroups(Text, Keyword, Text)),
@@ -1990,14 +1990,14 @@ class ValaLexer(RegexLexer):
'namespace'),
(r'(class|errordomain|interface|struct)(\s+)',
bygroups(Keyword.Declaration, Text), 'class'),
- (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)',
+ (r'(\.)([a-zA-Z_]\w*)',
bygroups(Operator, Name.Attribute)),
# void is an actual keyword, others are in glib-2.0.vapi
(r'(void|bool|char|double|float|int|int8|int16|int32|int64|long|'
r'short|size_t|ssize_t|string|time_t|uchar|uint|uint8|uint16|'
r'uint32|uint64|ulong|unichar|ushort)\b', Keyword.Type),
(r'(true|false|null)\b', Name.Builtin),
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ ('[a-zA-Z_]\w*', Name),
],
'root': [
include('whitespace'),
@@ -2023,7 +2023,7 @@ class ValaLexer(RegexLexer):
(r'.*?\n', Comment),
],
'class': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
],
'namespace': [
(r'[a-zA-Z_][a-zA-Z0-9_.]*', Name.Namespace, '#pop')
@@ -2050,9 +2050,9 @@ class OocLexer(RegexLexer):
r'while|do|switch|case|as|in|version|return|true|false|null)\b',
Keyword),
(r'include\b', Keyword, 'include'),
- (r'(cover)([ \t]+)(from)([ \t]+)([a-zA-Z0-9_]+[*@]?)',
+ (r'(cover)([ \t]+)(from)([ \t]+)(\w+[*@]?)',
bygroups(Keyword, Text, Keyword, Text, Name.Class)),
- (r'(func)((?:[ \t]|\\\n)+)(~[a-z_][a-zA-Z0-9_]*)',
+ (r'(func)((?:[ \t]|\\\n)+)(~[a-z_]\w*)',
bygroups(Keyword, Text, Name.Function)),
(r'\bfunc\b', Keyword),
# Note: %= and ^= not listed on http://ooc-lang.org/syntax
@@ -2063,11 +2063,11 @@ class OocLexer(RegexLexer):
(r'(\.)([ \t]*)([a-z]\w*)', bygroups(Operator, Text,
Name.Function)),
(r'[A-Z][A-Z0-9_]+', Name.Constant),
- (r'[A-Z][a-zA-Z0-9_]*([@*]|\[[ \t]*\])?', Name.Class),
+ (r'[A-Z]\w*([@*]|\[[ \t]*\])?', Name.Class),
- (r'([a-z][a-zA-Z0-9_]*(?:~[a-z][a-zA-Z0-9_]*)?)((?:[ \t]|\\\n)*)(?=\()',
+ (r'([a-z]\w*(?:~[a-z]\w*)?)((?:[ \t]|\\\n)*)(?=\()',
bygroups(Name.Function, Text)),
- (r'[a-z][a-zA-Z0-9_]*', Name.Variable),
+ (r'[a-z]\w*', Name.Variable),
# : introduces types
(r'[:(){}\[\];,]', Punctuation),
@@ -2449,7 +2449,7 @@ class AdaLexer(RegexLexer):
(r'task|protected', Keyword.Declaration),
(r'(subtype)(\s+)', bygroups(Keyword.Declaration, Text)),
(r'(end)(\s+)', bygroups(Keyword.Reserved, Text), 'end'),
- (r'(pragma)(\s+)([a-zA-Z0-9_]+)', bygroups(Keyword.Reserved, Text,
+ (r'(pragma)(\s+)(\w+)', bygroups(Keyword.Reserved, Text,
Comment.Preproc)),
(r'(true|false|null)\b', Keyword.Constant),
(r'(Address|Byte|Boolean|Character|Controlled|Count|Cursor|'
@@ -2492,7 +2492,7 @@ class AdaLexer(RegexLexer):
(r'[0-9_]+', Number.Integer),
],
'attribute' : [
- (r"(')([a-zA-Z0-9_]+)", bygroups(Punctuation, Name.Attribute)),
+ (r"(')(\w+)", bygroups(Punctuation, Name.Attribute)),
],
'subprogram' : [
(r'\(', Punctuation, ('#pop', 'formal_part')),
@@ -3083,7 +3083,7 @@ class FantomLexer(RegexLexer):
dict (
pod = r'[\"\w\.]+',
eos = r'\n|;',
- id = r'[a-zA-Z_][a-zA-Z0-9_]*',
+ id = r'[a-zA-Z_]\w*',
# all chars which can be part of type definition. Starts with
# either letter, or [ (maps), or | (funcs)
type = r'(?:\[|[a-zA-Z_]|\|)[:\w\[\]\|\->\?]*?',
@@ -3368,7 +3368,7 @@ class RustLexer(RegexLexer):
r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|.)'""",
String.Char),
# Lifetime
- (r"""'[a-zA-Z_][a-zA-Z0-9_]*""", Name.Label),
+ (r"""'[a-zA-Z_]\w*""", Name.Label),
# Binary Literal
(r'0b[01_]+', Number, 'number_lit'),
# Octal Literal
@@ -3496,10 +3496,10 @@ class MonkeyLexer(RegexLexer):
filenames = ['*.monkey']
mimetypes = ['text/x-monkey']
- name_variable = r'[a-z_][a-zA-Z0-9_]*'
- name_function = r'[A-Z][a-zA-Z0-9_]*'
+ name_variable = r'[a-z_]\w*'
+ name_function = r'[A-Z]\w*'
name_constant = r'[A-Z_][A-Z0-9_]*'
- name_class = r'[A-Z][a-zA-Z0-9_]*'
+ name_class = r'[A-Z]\w*'
name_module = r'[a-z0-9_]*'
keyword_type = r'(?:Int|Float|String|Bool|Object|Array|Void)'
@@ -3997,7 +3997,7 @@ class EiffelLexer(RegexLexer):
(r"'([^'%]|%'|%%)'", String.Char),
(r"(//|\\\\|>=|<=|:=|/=|~|/~|[\\\?!#%&@|+/\-=\>\*$<|^\[\]])", Operator),
(r"([{}():;,.])", Punctuation),
- (r'([a-z][a-zA-Z0-9_]*)|([A-Z][A-Z0-9_]*[a-z][a-zA-Z0-9_]*)', Name),
+ (r'([a-z]\w*)|([A-Z][A-Z0-9_]*[a-z]\w*)', Name),
(r'([A-Z][A-Z0-9_]*)', Name.Class),
(r'\n+', Text),
],
diff --git a/pygments/lexers/dalvik.py b/pygments/lexers/dalvik.py
index 901b7c5a..44ec040c 100644
--- a/pygments/lexers/dalvik.py
+++ b/pygments/lexers/dalvik.py
@@ -82,7 +82,7 @@ class SmaliLexer(RegexLexer):
bygroups(Punctuation, Name.Function, Punctuation)),
],
'label': [
- (r':[A-Za-z0-9_]+', Name.Label),
+ (r':\w+', Name.Label),
],
'class': [
# class names in the form Lcom/namespace/ClassName;
diff --git a/pygments/lexers/dotnet.py b/pygments/lexers/dotnet.py
index d6691bf1..491ac9c8 100644
--- a/pygments/lexers/dotnet.py
+++ b/pygments/lexers/dotnet.py
@@ -58,7 +58,7 @@ class CSharpLexer(RegexLexer):
# see http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf
levels = {
- 'none': '@?[_a-zA-Z][a-zA-Z0-9_]*',
+ 'none': '@?[_a-zA-Z]\w*',
'basic': ('@?[_' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl + ']' +
'[' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl +
uni.Nd + uni.Pc + uni.Cf + uni.Mn + uni.Mc + ']*'),
@@ -170,7 +170,7 @@ class NemerleLexer(RegexLexer):
# http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf
levels = dict(
- none = '@?[_a-zA-Z][a-zA-Z0-9_]*',
+ none = '@?[_a-zA-Z]\w*',
basic = ('@?[_' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl + ']' +
'[' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl +
uni.Nd + uni.Pc + uni.Cf + uni.Mn + uni.Mc + ']*'),
@@ -336,7 +336,7 @@ class BooLexer(RegexLexer):
(r'"""(\\\\|\\"|.*?)"""', String.Double),
(r'"(\\\\|\\"|[^"]*?)"', String.Double),
(r"'(\\\\|\\'|[^']*?)'", String.Single),
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ (r'[a-zA-Z_]\w*', Name),
(r'(\d+\.\d*|\d*\.\d+)([fF][+-]?[0-9]+)?', Number.Float),
(r'[0-9][0-9\.]*(ms?|d|h|s)', Number),
(r'0\d+', Number.Oct),
@@ -351,10 +351,10 @@ class BooLexer(RegexLexer):
('[*/]', Comment.Multiline)
],
'funcname': [
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Function, '#pop')
+ ('[a-zA-Z_]\w*', Name.Function, '#pop')
],
'classname': [
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+ ('[a-zA-Z_]\w*', Name.Class, '#pop')
],
'namespace': [
('[a-zA-Z_][a-zA-Z0-9_.]*', Name.Namespace, '#pop')
@@ -425,7 +425,7 @@ class VbNetLexer(RegexLexer):
r'<=|>=|<>|[-&*/\\^+=<>]',
Operator),
('"', String, 'string'),
- ('[a-zA-Z_][a-zA-Z0-9_]*[%&@!#$]?', Name),
+ ('[a-zA-Z_]\w*[%&@!#$]?', Name),
('#.*?#', Literal.Date),
(r'(\d+\.\d*|\d*\.\d+)([fF][+-]?[0-9]+)?', Number.Float),
(r'\d+([SILDFR]|US|UI|UL)?', Number.Integer),
@@ -608,11 +608,11 @@ class FSharpLexer(RegexLexer):
(r'\b(open|module)(\s+)([a-zA-Z0-9_.]+)',
bygroups(Keyword, Text, Name.Namespace)),
- (r'\b(let!?)(\s+)([a-zA-Z0-9_]+)',
+ (r'\b(let!?)(\s+)(\w+)',
bygroups(Keyword, Text, Name.Variable)),
- (r'\b(type)(\s+)([a-zA-Z0-9_]+)',
+ (r'\b(type)(\s+)(\w+)',
bygroups(Keyword, Text, Name.Class)),
- (r'\b(member|override)(\s+)([a-zA-Z0-9_]+)(\.)([a-zA-Z0-9_]+)',
+ (r'\b(member|override)(\s+)(\w+)(\.)(\w+)',
bygroups(Keyword, Text, Name, Punctuation, Name.Function)),
(r'\b(%s)\b' % '|'.join(keywords), Keyword),
(r'(%s)' % '|'.join(keyopts), Operator),
diff --git a/pygments/lexers/functional.py b/pygments/lexers/functional.py
index af9918a0..9b977533 100644
--- a/pygments/lexers/functional.py
+++ b/pygments/lexers/functional.py
@@ -975,7 +975,7 @@ class HaskellLexer(RegexLexer):
],
'funclist': [
(r'\s+', Text),
- (r'[A-Z][a-zA-Z0-9_]*', Keyword.Type),
+ (r'[A-Z]\w*', Keyword.Type),
(r'(_[\w\']+|[a-z][\w\']*)', Name.Function),
(r'--(?![!#$%&*+./<=>?@\^|_~:\\]).*?$', Comment.Single),
(r'{-', Comment.Multiline, 'comment'),
@@ -1084,7 +1084,7 @@ class IdrisLexer(RegexLexer):
],
'funclist': [
(r'\s+', Text),
- (r'[A-Z][a-zA-Z0-9_]*', Keyword.Type),
+ (r'[A-Z]\w*', Keyword.Type),
(r'(_[\w\']+|[a-z][\w\']*)', Name.Function),
(r'--.*$', Comment.Single),
(r'{-', Comment.Multiline, 'comment'),
@@ -1801,9 +1801,9 @@ class ErlangLexer(RegexLexer):
'div', 'not', 'or', 'orelse', 'rem', 'xor'
]
- atom_re = r"(?:[a-z][a-zA-Z0-9_]*|'[^\n']*[^\\]')"
+ atom_re = r"(?:[a-z]\w*|'[^\n']*[^\\]')"
- variable_re = r'(?:[A-Z_][a-zA-Z0-9_]*)'
+ variable_re = r'(?:[A-Z_]\w*)'
escape_re = r'(?:\\(?:[bdefnrstv\'"\\/]|[0-7][0-7]?[0-7]?|\^[a-zA-Z]))'
diff --git a/pygments/lexers/graph.py b/pygments/lexers/graph.py
index fccba5a4..6aa446c7 100644
--- a/pygments/lexers/graph.py
+++ b/pygments/lexers/graph.py
@@ -73,7 +73,7 @@ class CypherLexer(RegexLexer):
(r'\s+', Whitespace),
],
'barewords': [
- (r'[a-z][a-zA-Z0-9_]*', Name),
+ (r'[a-z]\w*', Name),
(r'\d+', Number),
],
}
diff --git a/pygments/lexers/hdl.py b/pygments/lexers/hdl.py
index 1ebe4e5c..29abecbe 100644
--- a/pygments/lexers/hdl.py
+++ b/pygments/lexers/hdl.py
@@ -54,7 +54,7 @@ class VerilogLexer(RegexLexer):
(r'\*/', Error),
(r'[~!%^&*+=|?:<>/-]', Operator),
(r'[()\[\],.;\']', Punctuation),
- (r'`[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant),
+ (r'`[a-zA-Z_]\w*', Name.Constant),
(r'^(\s*)(package)(\s+)', bygroups(Text, Keyword.Namespace, Text)),
(r'^(\s*)(import)(\s+)', bygroups(Text, Keyword.Namespace, Text),
@@ -96,8 +96,8 @@ class VerilogLexer(RegexLexer):
r'bit|logic|reg|'
r'supply0|supply1|tri|triand|trior|tri0|tri1|trireg|uwire|wire|wand|wor'
r'shortreal|real|realtime)\b', Keyword.Type),
- ('[a-zA-Z_][a-zA-Z0-9_]*:(?!:)', Name.Label),
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ ('[a-zA-Z_]\w*:(?!:)', Name.Label),
+ ('[a-zA-Z_]\w*', Name),
],
'string': [
(r'"', String, '#pop'),
@@ -169,7 +169,7 @@ class SystemVerilogLexer(RegexLexer):
(r'\*/', Error),
(r'[~!%^&*+=|?:<>/-]', Operator),
(r'[()\[\],.;\']', Punctuation),
- (r'`[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant),
+ (r'`[a-zA-Z_]\w*', Name.Constant),
(r'(accept_on|alias|always|always_comb|always_ff|always_latch|'
r'and|assert|assign|assume|automatic|before|begin|bind|bins|'
@@ -230,11 +230,11 @@ class SystemVerilogLexer(RegexLexer):
r'bit|logic|reg|'
r'supply0|supply1|tri|triand|trior|tri0|tri1|trireg|uwire|wire|wand|wor'
r'shortreal|real|realtime)\b', Keyword.Type),
- ('[a-zA-Z_][a-zA-Z0-9_]*:(?!:)', Name.Label),
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ ('[a-zA-Z_]\w*:(?!:)', Name.Label),
+ ('[a-zA-Z_]\w*', Name),
],
'classname': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop'),
],
'string': [
(r'"', String, '#pop'),
@@ -290,19 +290,19 @@ class VhdlLexer(RegexLexer):
(r'--(?![!#$%&*+./<=>?@\^|_~]).*?$', Comment.Single),
(r"'(U|X|0|1|Z|W|L|H|-)'", String.Char),
(r'[~!%^&*+=|?:<>/-]', Operator),
- (r"'[a-zA-Z_][a-zA-Z0-9_]*", Name.Attribute),
+ (r"'[a-zA-Z_]\w*", Name.Attribute),
(r'[()\[\],.;\']', Punctuation),
(r'"[^\n\\]*"', String),
- (r'(library)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
+ (r'(library)(\s+)([a-zA-Z_]\w*)',
bygroups(Keyword, Text, Name.Namespace)),
(r'(use)(\s+)(entity)', bygroups(Keyword, Text, Keyword)),
(r'(use)(\s+)([a-zA-Z_][\.a-zA-Z0-9_]*)',
bygroups(Keyword, Text, Name.Namespace)),
- (r'(entity|component)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
+ (r'(entity|component)(\s+)([a-zA-Z_]\w*)',
bygroups(Keyword, Text, Name.Class)),
- (r'(architecture|configuration)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)(\s+)'
- r'(of)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)(\s+)(is)',
+ (r'(architecture|configuration)(\s+)([a-zA-Z_]\w*)(\s+)'
+ r'(of)(\s+)([a-zA-Z_]\w*)(\s+)(is)',
bygroups(Keyword, Text, Name.Class, Text, Keyword, Text,
Name.Class, Text, Keyword)),
@@ -312,11 +312,11 @@ class VhdlLexer(RegexLexer):
include('keywords'),
include('numbers'),
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ (r'[a-zA-Z_]\w*', Name),
],
'endblock': [
include('keywords'),
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class),
+ (r'[a-zA-Z_]\w*', Name.Class),
(r'(\s+)', Text),
(r';', Punctuation, '#pop'),
],
diff --git a/pygments/lexers/inferno.py b/pygments/lexers/inferno.py
index 56f02b98..6aecafdb 100644
--- a/pygments/lexers/inferno.py
+++ b/pygments/lexers/inferno.py
@@ -35,7 +35,7 @@ class LimboLexer(RegexLexer):
tokens = {
'whitespace': [
- (r'^(\s*)([a-zA-Z_][a-zA-Z0-9_]*:(\s*)\n)',
+ (r'^(\s*)([a-zA-Z_]\w*:(\s*)\n)',
bygroups(Text, Name.Label)),
(r'\n', Text),
(r'\s+', Text),
@@ -64,7 +64,7 @@ class LimboLexer(RegexLexer):
(r'(byte|int|big|real|string|array|chan|list|adt'
r'|fn|ref|of|module|self|type)\b', Keyword.Type),
(r'(con|iota|nil)\b', Keyword.Constant),
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ ('[a-zA-Z_]\w*', Name),
],
'statement' : [
include('whitespace'),
diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py
index 2c45a0f4..9daead34 100644
--- a/pygments/lexers/jvm.py
+++ b/pygments/lexers/jvm.py
@@ -52,7 +52,7 @@ class JavaLexer(RegexLexer):
Keyword.Type),
# method names
(r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]<>]*\s+)+?)' # return arguments
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
+ r'([a-zA-Z_]\w*)' # method name
r'(\s*)(\()', # signature start
bygroups(using(this), Name.Function, Text, Operator)),
(r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
@@ -61,9 +61,9 @@ class JavaLexer(RegexLexer):
(r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
(r'"(\\\\|\\"|[^"])*"', String),
(r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
- (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)),
- (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
- (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
+ (r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)),
+ (r'[a-zA-Z_]\w*:', Name.Label),
+ (r'[a-zA-Z_\$]\w*', Name),
(r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
@@ -71,7 +71,7 @@ class JavaLexer(RegexLexer):
(r'\n', Text)
],
'class': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
],
'import': [
(r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
@@ -341,7 +341,7 @@ class GosuLexer(RegexLexer):
'root': [
# method names
(r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # modifiers etc.
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
+ r'([a-zA-Z_]\w*)' # method name
r'(\s*)(\()', # signature start
bygroups(using(this), Name.Function, Text, Operator)),
(r'[^\S\n]+', Text),
@@ -360,16 +360,16 @@ class GosuLexer(RegexLexer):
Keyword.Type),
(r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
(r'(true|false|null|NaN|Infinity)\b', Keyword.Constant),
- (r'(class|interface|enhancement|enum)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
+ (r'(class|interface|enhancement|enum)(\s+)([a-zA-Z_]\w*)',
bygroups(Keyword.Declaration, Text, Name.Class)),
(r'(uses)(\s+)([a-zA-Z0-9_.]+\*?)',
bygroups(Keyword.Namespace, Text, Name.Namespace)),
(r'"', String, 'string'),
- (r'(\??[\.#])([a-zA-Z_][a-zA-Z0-9_]*)',
+ (r'(\??[\.#])([a-zA-Z_]\w*)',
bygroups(Operator, Name.Attribute)),
- (r'(:)([a-zA-Z_][a-zA-Z0-9_]*)',
+ (r'(:)([a-zA-Z_]\w*)',
bygroups(Operator, Name.Attribute)),
- (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
+ (r'[a-zA-Z_\$]\w*', Name),
(r'and|or|not|[\\~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'[0-9]+', Number.Integer),
@@ -439,7 +439,7 @@ class GroovyLexer(RegexLexer):
'root': [
# method names
(r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
+ r'([a-zA-Z_]\w*)' # method name
r'(\s*)(\()', # signature start
bygroups(using(this), Name.Function, Text, Operator)),
(r'[^\S\n]+', Text),
@@ -464,9 +464,9 @@ class GroovyLexer(RegexLexer):
(r'\$/((?!/\$).)*/\$', String),
(r'/(\\\\|\\"|[^/])*/', String),
(r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
- (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)),
- (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
- (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
+ (r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)),
+ (r'[a-zA-Z_]\w*:', Name.Label),
+ (r'[a-zA-Z_\$]\w*', Name),
(r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
@@ -474,7 +474,7 @@ class GroovyLexer(RegexLexer):
(r'\n', Text)
],
'class': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
],
'import': [
(r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
@@ -564,7 +564,7 @@ class IokeLexer(RegexLexer):
(r'#\[', String, 'squareText'),
#Mimic
- (r'[a-zA-Z0-9_][a-zA-Z0-9!?_:]+(?=\s*=.*mimic\s)', Name.Entity),
+ (r'\w[a-zA-Z0-9!?_:]+(?=\s*=.*mimic\s)', Name.Entity),
#Assignment
(r'[a-zA-Z_][a-zA-Z0-9_!:?]*(?=[\s]*[+*/-]?=[^=].*($|\.))',
@@ -841,7 +841,7 @@ class TeaLangLexer(RegexLexer):
'root': [
# method names
(r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
+ r'([a-zA-Z_]\w*)' # method name
r'(\s*)(\()', # signature start
bygroups(using(this), Name.Function, Text, Operator)),
(r'[^\S\n]+', Text),
@@ -856,9 +856,9 @@ class TeaLangLexer(RegexLexer):
(r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
(r'"(\\\\|\\"|[^"])*"', String),
(r'\'(\\\\|\\\'|[^\'])*\'', String),
- (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)),
- (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
- (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
+ (r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)),
+ (r'[a-zA-Z_]\w*:', Name.Label),
+ (r'[a-zA-Z_\$]\w*', Name),
(r'(isa|[.]{3}|[.]{2}|[=#!<>+-/%&;,.\*\\\(\)\[\]\{\}])', Operator),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
@@ -866,7 +866,7 @@ class TeaLangLexer(RegexLexer):
(r'\n', Text)
],
'template': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
],
'import': [
(r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
@@ -895,7 +895,7 @@ class CeylonLexer(RegexLexer):
'root': [
# method names
(r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
+ r'([a-zA-Z_]\w*)' # method name
r'(\s*)(\()', # signature start
bygroups(using(this), Name.Function, Text, Operator)),
(r'[^\S\n]+', Text),
@@ -919,10 +919,10 @@ class CeylonLexer(RegexLexer):
(r'"(\\\\|\\"|[^"])*"', String),
(r"'\\.'|'[^\\]'|'\\\{#[0-9a-fA-F]{4}\}'", String.Char),
(r'".*``.*``.*"', String.Interpol),
- (r'(\.)([a-z_][a-zA-Z0-9_]*)',
+ (r'(\.)([a-z_]\w*)',
bygroups(Operator, Name.Attribute)),
- (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'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
(r'\d{1,3}(_\d{3})+\.\d{1,3}(_\d{3})+[kMGTPmunpf]?', Number.Float),
(r'\d{1,3}(_\d{3})+\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?',
@@ -939,7 +939,7 @@ class CeylonLexer(RegexLexer):
(r'\n', Text)
],
'class': [
- (r'[A-Za-z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+ (r'[A-Za-z_]\w*', Name.Class, '#pop')
],
'import': [
(r'[a-z][a-zA-Z0-9_.]*',
@@ -1060,8 +1060,8 @@ class XtendLexer(RegexLexer):
(u'(\u00BB)', String, 'template'),
(r'"(\\\\|\\"|[^"])*"', String),
(r"'(\\\\|\\'|[^'])*'", String),
- (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'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
@@ -1069,7 +1069,7 @@ class XtendLexer(RegexLexer):
(r'\n', Text)
],
'class': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
],
'import': [
(r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
diff --git a/pygments/lexers/math.py b/pygments/lexers/math.py
index cfbfc432..d8cc0f06 100644
--- a/pygments/lexers/math.py
+++ b/pygments/lexers/math.py
@@ -98,7 +98,7 @@ class JuliaLexer(RegexLexer):
# names
(r'@[a-zA-Z0-9_.]+', Name.Decorator),
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ (r'[a-zA-Z_]\w*', Name),
# numbers
(r'(\d+(_\d+)+\.\d*|\d*\.\d+(_\d+)+)([eEf][+-]?[0-9]+)?', Number.Float),
@@ -116,13 +116,13 @@ class JuliaLexer(RegexLexer):
],
'funcname': [
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Function, '#pop'),
+ ('[a-zA-Z_]\w*', Name.Function, '#pop'),
('\([^\s\w{]{1,2}\)', Operator, '#pop'),
('[^\s\w{]{1,2}', Operator, '#pop'),
],
'typename': [
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+ ('[a-zA-Z_]\w*', Name.Class, '#pop')
],
'stringescape': [
@@ -133,7 +133,7 @@ class JuliaLexer(RegexLexer):
'string': [
(r'"', String, '#pop'),
(r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings
- (r'\$(\([a-zA-Z0-9_]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?',
+ (r'\$(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?',
String.Interpol),
(r'[^\\"$]+', String),
# quotes, dollar signs, and backslashes must be parsed one at a time
@@ -357,7 +357,7 @@ class MatlabLexer(RegexLexer):
(r'\d+', Number.Integer),
(r'(?<![\w\)\].])\'', String, 'string'),
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ ('[a-zA-Z_]\w*', Name),
(r'.', Text),
],
'string': [
@@ -816,7 +816,7 @@ class OctaveLexer(RegexLexer):
(r'(?<=[\w\)\].])\'+', Operator),
(r'(?<![\w\)\].])\'', String, 'string'),
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ ('[a-zA-Z_]\w*', Name),
(r'.', Text),
],
'string': [
@@ -881,7 +881,7 @@ class ScilabLexer(RegexLexer):
(r'\d+[eEf][+-]?[0-9]+', Number.Float),
(r'\d+', Number.Integer),
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ ('[a-zA-Z_]\w*', Name),
(r'.', Text),
],
'string': [
@@ -1619,10 +1619,10 @@ class StanLexer(RegexLexer):
+ _stan_builtins.DISTRIBUTIONS),
Name.Builtin),
# Special names ending in __, like lp__
- (r'[A-Za-z][A-Za-z0-9_]*__\b', Name.Builtin.Pseudo),
+ (r'[A-Za-z]\w*__\b', Name.Builtin.Pseudo),
(r'(%s)\b' % r'|'.join(_stan_builtins.RESERVED), Keyword.Reserved),
# Regular variable names
- (r'[A-Za-z][A-Za-z0-9_]*\b', Name),
+ (r'[A-Za-z]\w*\b', Name),
# Real Literals
(r'-?[0-9]+(\.[0-9]+)?[eE]-?[0-9]+', Number.Float),
(r'-?[0-9]*\.[0-9]*', Number.Float),
diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py
index c27e7f24..b804f9c3 100644
--- a/pygments/lexers/other.py
+++ b/pygments/lexers/other.py
@@ -95,7 +95,7 @@ class LSLLexer(RegexLexer):
(lsl_invalid_unimplemented, Error),
(lsl_reserved_godmode, Keyword.Reserved),
(lsl_reserved_log, Keyword.Reserved),
- (r'\b([a-zA-Z_][a-zA-Z0-9_]*)\b', Name.Variable),
+ (r'\b([a-zA-Z_]\w*)\b', Name.Variable),
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d*', Number.Float),
(r'(\d+\.\d*|\.\d+)', Number.Float),
(r'0[xX][0-9a-fA-F]+', Number.Hex),
@@ -164,7 +164,7 @@ class ECLLexer(RegexLexer):
(r'\*/', Error),
(r'[~!%^&*+=|?:<>/-]+', Operator),
(r'[{}()\[\],.;]', Punctuation),
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ (r'[a-zA-Z_]\w*', Name),
],
'hash': [
(r'^#.*$', Comment.Preproc),
@@ -514,7 +514,7 @@ class LogtalkLexer(RegexLexer):
(r'0x[0-9a-fA-F]+', Number),
(r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
# Variables
- (r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
+ (r'([A-Z_]\w*)', Name.Variable),
# Event handlers
(r'(after|before)(?=[(])', Keyword),
# Execution-context methods
@@ -630,7 +630,7 @@ class LogtalkLexer(RegexLexer):
# Ponctuation
(r'[()\[\],.|]', Text),
# Atoms
- (r"[a-z][a-zA-Z0-9_]*", Text),
+ (r"[a-z]\w*", Text),
(r"'", String, 'quoted_atom'),
],
@@ -661,8 +661,8 @@ class LogtalkLexer(RegexLexer):
(r'op(?=[(])', Keyword, 'root'),
(r'(c(alls|oinductive)|reexport|use(s|_module))(?=[(])',
Keyword, 'root'),
- (r'[a-z][a-zA-Z0-9_]*(?=[(])', Text, 'root'),
- (r'[a-z][a-zA-Z0-9_]*[.]', Text, 'root'),
+ (r'[a-z]\w*(?=[(])', Text, 'root'),
+ (r'[a-z]\w*[.]', Text, 'root'),
],
'entityrelations': [
@@ -675,9 +675,9 @@ class LogtalkLexer(RegexLexer):
(r'0x[0-9a-fA-F]+', Number),
(r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
# Variables
- (r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
+ (r'([A-Z_]\w*)', Name.Variable),
# Atoms
- (r"[a-z][a-zA-Z0-9_]*", Text),
+ (r"[a-z]\w*", Text),
(r"'", String, 'quoted_atom'),
# Strings
(r'"(\\\\|\\"|[^"])*"', String),
@@ -747,11 +747,11 @@ class GnuplotLexer(RegexLexer):
(_shortened_many('pwd$', 're$read', 'res$et', 'scr$eendump',
'she$ll', 'test$'),
Keyword, 'noargs'),
- ('([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(=)',
+ ('([a-zA-Z_]\w*)(\s*)(=)',
bygroups(Name.Variable, Text, Operator), 'genericargs'),
- ('([a-zA-Z_][a-zA-Z0-9_]*)(\s*\(.*?\)\s*)(=)',
+ ('([a-zA-Z_]\w*)(\s*\(.*?\)\s*)(=)',
bygroups(Name.Function, Text, Operator), 'genericargs'),
- (r'@[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant), # macros
+ (r'@[a-zA-Z_]\w*', Name.Constant), # macros
(r';', Keyword),
],
'comment': [
@@ -797,10 +797,10 @@ class GnuplotLexer(RegexLexer):
('[,.~!%^&*+=|?:<>/-]', Operator),
('[{}()\[\]]', Punctuation),
(r'(eq|ne)\b', Operator.Word),
- (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(\()',
+ (r'([a-zA-Z_]\w*)(\s*)(\()',
bygroups(Name.Function, Text, Punctuation)),
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
- (r'@[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant), # macros
+ (r'[a-zA-Z_]\w*', Name),
+ (r'@[a-zA-Z_]\w*', Name.Constant), # macros
(r'\\\n', Text),
],
'optionarg': [
@@ -1803,15 +1803,15 @@ class NewspeakLexer(RegexLexer):
'root' : [
(r'\b(Newsqueak2)\b',Keyword.Declaration),
(r"'[^']*'",String),
- (r'\b(class)(\s+)([a-zA-Z0-9_]+)(\s*)',
+ (r'\b(class)(\s+)(\w+)(\s*)',
bygroups(Keyword.Declaration,Text,Name.Class,Text)),
(r'\b(mixin|self|super|private|public|protected|nil|true|false)\b',
Keyword),
- (r'([a-zA-Z0-9_]+\:)(\s*)([a-zA-Z_]\w+)',
+ (r'(\w+\:)(\s*)([a-zA-Z_]\w+)',
bygroups(Name.Function,Text,Name.Variable)),
- (r'([a-zA-Z0-9_]+)(\s*)(=)',
+ (r'(\w+)(\s*)(=)',
bygroups(Name.Attribute,Text,Operator)),
- (r'<[a-zA-Z0-9_]+>', Comment.Special),
+ (r'<\w+>', Comment.Special),
include('expressionstat'),
include('whitespace')
],
@@ -2022,14 +2022,14 @@ class AsymptoteLexer(RegexLexer):
r'bounds|coord|frame|guide|horner|int|linefit|marginT|pair|pen|'
r'picture|position|real|revolution|slice|splitface|ticksgridT|'
r'tickvalues|tree|triple|vertex|void)\b', Keyword.Type),
- ('[a-zA-Z_][a-zA-Z0-9_]*:(?!:)', Name.Label),
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ ('[a-zA-Z_]\w*:(?!:)', Name.Label),
+ ('[a-zA-Z_]\w*', Name),
],
'root': [
include('whitespace'),
# functions
(r'((?:[a-zA-Z0-9_*\s])+?(?:\s|\*))' # return arguments
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
+ r'([a-zA-Z_]\w*)' # method name
r'(\s*\([^;]*?\))' # signature
r'(' + _ws + r')({)',
bygroups(using(this), Name.Function, using(this), using(this),
@@ -2037,7 +2037,7 @@ class AsymptoteLexer(RegexLexer):
'function'),
# function declarations
(r'((?:[a-zA-Z0-9_*\s])+?(?:\s|\*))' # return arguments
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
+ r'([a-zA-Z_]\w*)' # method name
r'(\s*\([^;]*?\))' # signature
r'(' + _ws + r')(;)',
bygroups(using(this), Name.Function, using(this), using(this),
@@ -2496,13 +2496,13 @@ class ProtoBufLexer(RegexLexer):
('[a-zA-Z_][a-zA-Z0-9_\.]*', Name),
],
'package': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Namespace, '#pop')
+ (r'[a-zA-Z_]\w*', Name.Namespace, '#pop')
],
'message': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
],
'type': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name, '#pop')
+ (r'[a-zA-Z_]\w*', Name, '#pop')
],
}
@@ -2525,7 +2525,7 @@ class HybrisLexer(RegexLexer):
'root': [
# method names
(r'^(\s*(?:function|method|operator\s+)+?)'
- r'([a-zA-Z_][a-zA-Z0-9_]*)'
+ r'([a-zA-Z_]\w*)'
r'(\s*)(\()', bygroups(Keyword, Name.Function, Text, Operator)),
(r'[^\S\n]+', Text),
(r'//.*?\n', Comment.Single),
@@ -2566,10 +2566,10 @@ class HybrisLexer(RegexLexer):
r'Exception)\b', Keyword.Type),
(r'"(\\\\|\\"|[^"])*"', String),
(r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char),
- (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)',
+ (r'(\.)([a-zA-Z_]\w*)',
bygroups(Operator, Name.Attribute)),
- (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'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?\-@]+', Operator),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-f]+', Number.Hex),
@@ -2577,7 +2577,7 @@ class HybrisLexer(RegexLexer):
(r'\n', Text),
],
'class': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
],
'import': [
(r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
@@ -2629,7 +2629,7 @@ class AwkLexer(RegexLexer):
(r'(ARGC|ARGIND|ARGV|CONVFMT|ENVIRON|ERRNO|FIELDWIDTHS|FILENAME|FNR|FS|'
r'IGNORECASE|NF|NR|OFMT|OFS|ORFS|RLENGTH|RS|RSTART|RT|'
r'SUBSEP)\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),
@@ -2846,7 +2846,7 @@ class UrbiscriptLexer(ExtendedRegexLexer):
Operator.Word),
(r'[{}\[\]()]+', Punctuation),
(r'(?:;|\||,|&|\?|!)+', Punctuation),
- (r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
+ (r'[$a-zA-Z_]\w*', Name.Other),
(r'0x[0-9a-fA-F]+', Number.Hex),
# Float, Integer, Angle and Duration
(r'(?:[0-9]+(?:(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)?'
@@ -3052,7 +3052,7 @@ class MscgenLexer(RegexLexer):
aliases = ['mscgen', 'msc']
filenames = ['*.msc']
- _var = r'([a-zA-Z0-9_]+|"(?:\\"|[^"])*")'
+ _var = r'(\w+|"(?:\\"|[^"])*")'
tokens = {
'root': [
@@ -3254,7 +3254,7 @@ class SourcePawnLexer(RegexLexer):
r'public|return|sizeof|static|decl|struct|switch)\b', Keyword),
(r'(bool|Float)\b', Keyword.Type),
(r'(true|false)\b', Keyword.Constant),
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ ('[a-zA-Z_]\w*', Name),
],
'string': [
(r'"', String, '#pop'),
@@ -3354,7 +3354,7 @@ class PuppetLexer(RegexLexer):
],
'names': [
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Attribute),
+ ('[a-zA-Z_]\w*', Name.Attribute),
(r'(\$\S+)(\[)(\S+)(\])', bygroups(Name.Variable, Punctuation,
String, Punctuation)),
(r'\$\S+', Name.Variable),
@@ -3591,9 +3591,9 @@ class RPMSpecLexer(RegexLexer):
'interpol': [
(r'%\{?__[a-z_]+\}?', Name.Function),
(r'%\{?_([a-z_]+dir|[a-z_]+path|prefix)\}?', Keyword.Pseudo),
- (r'%\{\?[A-Za-z0-9_]+\}', Name.Variable),
+ (r'%\{\?\w+\}', Name.Variable),
(r'\$\{?RPM_[A-Z0-9_]+\}?', Name.Variable.Global),
- (r'%\{[a-zA-Z][a-zA-Z0-9_]+\}', Keyword.Constant),
+ (r'%\{[a-zA-Z]\w+\}', Keyword.Constant),
]
}
@@ -3724,7 +3724,7 @@ class AutoItLexer(RegexLexer):
(r'(#comments-start|#cs).*?(#comments-end|#ce)', Comment.Multiline),
(r'[\[\]{}(),;]', Punctuation),
(r'(and|or|not)\b', Operator.Word),
- (r'[\$|@][a-zA-Z_][a-zA-Z0-9_]*', Name.Variable),
+ (r'[\$|@][a-zA-Z_]\w*', Name.Variable),
(r'!=|==|:=|\.=|<<|>>|[-~+/*%=<>&^|?:!.]', Operator),
include('commands'),
include('labels'),
@@ -4001,12 +4001,12 @@ class AmbientTalkLexer(RegexLexer):
(r'"(\\\\|\\"|[^"])*"', String),
(r'\|', Punctuation, 'arglist'),
(r'<:|[\^\*!%&<>+=,./?-]|:=', Operator),
- (r"`[a-zA-Z_][a-zA-Z0-9_]*", String.Symbol),
- (r"[a-zA-Z_][a-zA-Z0-9_]*:", Name.Function),
+ (r"`[a-zA-Z_]\w*", String.Symbol),
+ (r"[a-zA-Z_]\w*:", Name.Function),
(r"[\{\}()\[\];`]", Punctuation),
(r'(self|super)\b', Name.Variable.Instance),
- (r"[a-zA-Z_][a-zA-Z0-9_]*", Name.Variable),
- (r"@[a-zA-Z_][a-zA-Z0-9_]*", Name.Class),
+ (r"[a-zA-Z_]\w*", Name.Variable),
+ (r"@[a-zA-Z_]\w*", Name.Class),
(r"@\[", Name.Class, 'annotations'),
include('numbers'),
],
@@ -4015,9 +4015,9 @@ class AmbientTalkLexer(RegexLexer):
(r'\d+', Number.Integer)
],
'namespace': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*\.', Name.Namespace),
- (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Function , '#pop'),
- (r'[a-zA-Z_][a-zA-Z0-9_]*(?!\.)', Name.Function , '#pop')
+ (r'[a-zA-Z_]\w*\.', Name.Namespace),
+ (r'[a-zA-Z_]\w*:', Name.Function , '#pop'),
+ (r'[a-zA-Z_]\w*(?!\.)', Name.Function , '#pop')
],
'annotations' : [
(r"(.*?)\]", Name.Class, '#pop')
@@ -4025,7 +4025,7 @@ class AmbientTalkLexer(RegexLexer):
'arglist' : [
(r'\|', Punctuation, '#pop'),
(r'\s*(,)\s*', Punctuation),
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable),
+ (r'[a-zA-Z_]\w*', Name.Variable),
],
}
@@ -4072,7 +4072,7 @@ class PawnLexer(RegexLexer):
r'public|return|sizeof|tagof|state|goto)\b', Keyword),
(r'(bool|Float)\b', Keyword.Type),
(r'(true|false)\b', Keyword.Constant),
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ ('[a-zA-Z_]\w*', Name),
],
'string': [
(r'"', String, '#pop'),
@@ -4231,7 +4231,7 @@ class PanLexer(RegexLexer):
'curly': [
(r'}', Keyword, '#pop'),
(r':-', Keyword),
- (r'[a-zA-Z0-9_]+', Name.Variable),
+ (r'\w+', Name.Variable),
(r'[^}:"\'`$]+', Punctuation),
(r':', Punctuation),
include('root'),
diff --git a/pygments/lexers/shell.py b/pygments/lexers/shell.py
index f809dae9..13201912 100644
--- a/pygments/lexers/shell.py
+++ b/pygments/lexers/shell.py
@@ -79,7 +79,7 @@ class BashLexer(RegexLexer):
'curly': [
(r'}', Keyword, '#pop'),
(r':-', Keyword),
- (r'[a-zA-Z0-9_]+', Name.Variable),
+ (r'\w+', Name.Variable),
(r'[^}:"\'`$]+', Punctuation),
(r':', Punctuation),
include('root'),
@@ -314,7 +314,7 @@ class TcshLexer(RegexLexer):
'curly': [
(r'}', Keyword, '#pop'),
(r':-', Keyword),
- (r'[a-zA-Z0-9_]+', Name.Variable),
+ (r'\w+', Name.Variable),
(r'[^}:"\'`$]+', Punctuation),
(r':', Punctuation),
include('root'),
diff --git a/pygments/lexers/sql.py b/pygments/lexers/sql.py
index 9a3dcb8d..53df0f75 100644
--- a/pygments/lexers/sql.py
+++ b/pygments/lexers/sql.py
@@ -150,7 +150,7 @@ class PostgresLexer(PostgresBase, RegexLexer):
(r"(E|U&)?'(''|[^'])*'", String.Single),
(r'(U&)?"(""|[^"])*"', String.Name), # quoted identifier
(r'(?s)(\$[^\$]*\$)(.*?)(\1)', language_callback),
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ (r'[a-zA-Z_]\w*', Name),
# psql variable in SQL
(r""":(['"]?)[a-z][a-z0-9_]*\b\1""", Name.Variable),
@@ -435,7 +435,7 @@ class SqlLexer(RegexLexer):
# TODO: Backslash escapes?
(r"'(''|[^'])*'", String.Single),
(r'"(""|[^"])*"', String.Symbol), # not a real string literal in ANSI SQL
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ (r'[a-zA-Z_]\w*', Name),
(r'[;:()\[\],\.]', Punctuation)
],
'multiline-comments': [
@@ -506,9 +506,9 @@ class MySqlLexer(RegexLexer):
# TODO: this list is not complete
(r'\b(auto_increment|engine|charset|tables)\b', Keyword.Pseudo),
(r'(true|false|null)', Name.Constant),
- (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(\()',
+ (r'([a-zA-Z_]\w*)(\s*)(\()',
bygroups(Name.Function, Text, Punctuation)),
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ (r'[a-zA-Z_]\w*', Name),
(r'@[A-Za-z0-9]*[._]*[A-Za-z0-9]*', Name.Variable),
(r'[;:()\[\],\.]', Punctuation)
],
diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py
index 84f7a19b..6655cd60 100644
--- a/pygments/lexers/templates.py
+++ b/pygments/lexers/templates.py
@@ -161,22 +161,22 @@ class SmartyLexer(RegexLexer):
(r'(\{php\})(.*?)(\{/php\})',
bygroups(Comment.Preproc, using(PhpLexer, startinline=True),
Comment.Preproc)),
- (r'(\{)(/?[a-zA-Z_][a-zA-Z0-9_]*)(\s*)',
+ (r'(\{)(/?[a-zA-Z_]\w*)(\s*)',
bygroups(Comment.Preproc, Name.Function, Text), 'smarty'),
(r'\{', Comment.Preproc, 'smarty')
],
'smarty': [
(r'\s+', Text),
(r'\}', Comment.Preproc, '#pop'),
- (r'#[a-zA-Z_][a-zA-Z0-9_]*#', Name.Variable),
- (r'\$[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z0-9_]+)*', Name.Variable),
+ (r'#[a-zA-Z_]\w*#', Name.Variable),
+ (r'\$[a-zA-Z_]\w*(\.\w+)*', Name.Variable),
(r'[~!%^&*()+=|\[\]:;,.<>/?{}@-]', Operator),
(r'(true|false|null)\b', Keyword.Constant),
(r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
r"0[xX][0-9a-fA-F]+[Ll]?", Number),
(r'"(\\\\|\\"|[^"])*"', String.Double),
(r"'(\\\\|\\'|[^'])*'", String.Single),
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Attribute)
+ (r'[a-zA-Z_]\w*', Name.Attribute)
]
}
@@ -207,7 +207,7 @@ class VelocityLexer(RegexLexer):
flags = re.MULTILINE | re.DOTALL
- identifier = r'[a-zA-Z_][a-zA-Z0-9_]*'
+ identifier = r'[a-zA-Z_]\w*'
tokens = {
'root': [
@@ -267,8 +267,8 @@ class VelocityLexer(RegexLexer):
rv += 0.15
if re.search(r'#\{?foreach\}?\(.+?\).*?#\{?end\}?', text):
rv += 0.15
- if re.search(r'\$\{?[a-zA-Z_][a-zA-Z0-9_]*(\([^)]*\))?'
- r'(\.[a-zA-Z0-9_]+(\([^)]*\))?)*\}?', text):
+ if re.search(r'\$\{?[a-zA-Z_]\w*(\([^)]*\))?'
+ r'(\.\w+(\([^)]*\))?)*\}?', text):
rv += 0.01
return rv
@@ -347,17 +347,17 @@ class DjangoLexer(RegexLexer):
Text, Comment.Preproc, Text, Keyword, Text,
Comment.Preproc)),
# filter blocks
- (r'(\{%)(-?\s*)(filter)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
+ (r'(\{%)(-?\s*)(filter)(\s+)([a-zA-Z_]\w*)',
bygroups(Comment.Preproc, Text, Keyword, Text, Name.Function),
'block'),
- (r'(\{%)(-?\s*)([a-zA-Z_][a-zA-Z0-9_]*)',
+ (r'(\{%)(-?\s*)([a-zA-Z_]\w*)',
bygroups(Comment.Preproc, Text, Keyword), 'block'),
(r'\{', Other)
],
'varnames': [
- (r'(\|)(\s*)([a-zA-Z_][a-zA-Z0-9_]*)',
+ (r'(\|)(\s*)([a-zA-Z_]\w*)',
bygroups(Operator, Text, Name.Function)),
- (r'(is)(\s+)(not)?(\s+)?([a-zA-Z_][a-zA-Z0-9_]*)',
+ (r'(is)(\s+)(not)?(\s+)?([a-zA-Z_]\w*)',
bygroups(Keyword, Text, Keyword, Text, Name.Function)),
(r'(_|true|false|none|True|False|None)\b', Keyword.Pseudo),
(r'(in|as|reversed|recursive|not|and|or|is|if|else|import|'
@@ -365,7 +365,7 @@ class DjangoLexer(RegexLexer):
Keyword),
(r'(loop|block|super|forloop)\b', Name.Builtin),
(r'[a-zA-Z][a-zA-Z0-9_-]*', Name.Variable),
- (r'\.[a-zA-Z0-9_]+', Name.Variable),
+ (r'\.\w+', Name.Variable),
(r':?"(\\\\|\\"|[^"])*"', String.Double),
(r":?'(\\\\|\\'|[^'])*'", String.Single),
(r'([{}()\[\]+\-*/,:~]|[><=]=?)', Operator),
@@ -745,7 +745,7 @@ class CheetahLexer(RegexLexer):
(bygroups(Comment.Preproc, using(CheetahPythonLexer),
Comment.Preproc))),
# TODO support other Python syntax like $foo['bar']
- (r'(\$)([a-zA-Z_][a-zA-Z0-9_\.]*[a-zA-Z0-9_])',
+ (r'(\$)([a-zA-Z_][a-zA-Z0-9_\.]*\w)',
bygroups(Comment.Preproc, using(CheetahPythonLexer))),
(r'(\$\{!?)(.*?)(\})(?s)',
bygroups(Comment.Preproc, using(CheetahPythonLexer),
@@ -1806,7 +1806,7 @@ class HandlebarsLexer(RegexLexer):
(r':?"(\\\\|\\"|[^"])*"', String.Double),
(r":?'(\\\\|\\'|[^'])*'", String.Single),
(r'[a-zA-Z][a-zA-Z0-9_-]*', Name.Variable),
- (r'\.[a-zA-Z0-9_]+', Name.Variable),
+ (r'\.\w+', Name.Variable),
(r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
r"0[xX][0-9a-fA-F]+[Ll]?", Number),
]
diff --git a/pygments/lexers/text.py b/pygments/lexers/text.py
index fc1cc6a6..836eed60 100644
--- a/pygments/lexers/text.py
+++ b/pygments/lexers/text.py
@@ -588,7 +588,7 @@ class ApacheConfLexer(RegexLexer):
(r'(#.*?)$', Comment),
(r'(<[^\s>]+)(?:(\s+)(.*?))?(>)',
bygroups(Name.Tag, Text, String, Name.Tag)),
- (r'([a-zA-Z][a-zA-Z0-9_]*)(\s+)',
+ (r'([a-zA-Z]\w*)(\s+)',
bygroups(Name.Builtin, Text), 'value'),
(r'\.+', Text),
],
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py
index 7c028859..44f8926c 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),
@@ -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),
@@ -271,7 +271,7 @@ class ActionScript3Lexer(RegexLexer):
mimetypes = ['application/x-actionscript', 'text/x-actionscript',
'text/actionscript']
- identifier = r'[$a-zA-Z_][a-zA-Z0-9_]*'
+ identifier = r'[$a-zA-Z_]\w*'
typeidentifier = identifier + '(?:\.<\w+>)?'
flags = re.DOTALL | re.MULTILINE
@@ -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"),
],
@@ -3699,8 +3699,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 +3710,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 +3735,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))
],
@@ -3832,7 +3832,7 @@ class TypeScriptLexer(RegexLexer):
# Match stuff like: (function: return type)
(r'([a-zA-Z0-9_?.$][\w?.$]*)(\s*:\s*)([a-zA-Z0-9_?.$][\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 +4165,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),