summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-11-06 12:41:40 +0100
committerGeorg Brandl <georg@python.org>2014-11-06 12:41:40 +0100
commit6fe296e816745123f1d3dbb3a55d8033ddb943d9 (patch)
treede7f51cf9a1c1db6390fb10eb6d94c76a6b85029
parent24935597c6308c1e61c408abea331af5ef892579 (diff)
downloadpygments-6fe296e816745123f1d3dbb3a55d8033ddb943d9.tar.gz
Simplify charclasses in a few more modules
-rw-r--r--pygments/lexers/parsers.py34
-rw-r--r--pygments/lexers/pascal.py32
-rw-r--r--pygments/lexers/php.py10
-rw-r--r--pygments/lexers/prolog.py12
-rw-r--r--pygments/lexers/rdf.py8
-rw-r--r--pygments/lexers/rebol.py110
6 files changed, 101 insertions, 105 deletions
diff --git a/pygments/lexers/parsers.py b/pygments/lexers/parsers.py
index e84447b3..91add67f 100644
--- a/pygments/lexers/parsers.py
+++ b/pygments/lexers/parsers.py
@@ -71,7 +71,7 @@ class RagelLexer(RegexLexer):
(r'/(?!\*)(\\\\|\\/|[^/])*/', String.Regex), # regular expressions
],
'identifiers': [
- (r'[a-zA-Z_][a-zA-Z_0-9]*', Name.Variable),
+ (r'[a-zA-Z_]\w*', Name.Variable),
],
'operators': [
(r',', Operator), # Join
@@ -186,7 +186,7 @@ class RagelEmbeddedLexer(RegexLexer):
r'/(?!\*)(\\\\|\\/|[^/])*/\*',
# allow / as long as it's not followed by another / or by a *
- r'/(?=[^/\*]|$)',
+ r'/(?=[^/*]|$)',
# We want to match as many of these as we can in one block.
# Not sure if we need the + sign here,
@@ -338,9 +338,9 @@ class AntlrLexer(RegexLexer):
aliases = ['antlr']
filenames = []
- _id = r'[A-Za-z][A-Za-z_0-9]*'
- _TOKEN_REF = r'[A-Z][A-Za-z_0-9]*'
- _RULE_REF = r'[a-z][A-Za-z_0-9]*'
+ _id = r'[A-Za-z]\w*'
+ _TOKEN_REF = r'[A-Z]\w*'
+ _RULE_REF = r'[a-z]\w*'
_STRING_LITERAL = r'\'(?:\\\\|\\\'|[^\']*)\''
_INT = r'[0-9]+'
@@ -427,9 +427,9 @@ class AntlrLexer(RegexLexer):
(r'<<([^>]|>[^>])>>', String),
# identifiers
# Tokens start with capital letter.
- (r'\$?[A-Z_][A-Za-z_0-9]*', Name.Constant),
+ (r'\$?[A-Z_]\w*', Name.Constant),
# Rules start with small letter.
- (r'\$?[a-z_][A-Za-z_0-9]*', Name.Variable),
+ (r'\$?[a-z_]\w*', Name.Variable),
# operators
(r'(\+|\||->|=>|=|\(|\)|\.\.|\.|\?|\*|\^|!|\#|~)', Operator),
(r',', Punctuation),
@@ -458,8 +458,8 @@ class AntlrLexer(RegexLexer):
(r'\}', Punctuation, '#pop'),
],
'action': [
- (r'(' + r'|'.join(( # keep host code in largest possible chunks
- r'[^\${}\'"/\\]+', # exclude unsafe characters
+ (r'(' + r'|'.join(( # keep host code in largest possible chunks
+ r'[^${}\'"/\\]+', # exclude unsafe characters
# strings and comments may safely contain unsafe characters
r'"(\\\\|\\"|[^"])*"', # double quote string
@@ -485,8 +485,8 @@ class AntlrLexer(RegexLexer):
(r'\}', Punctuation, '#pop'),
],
'nested-arg-action': [
- (r'(' + r'|'.join(( # keep host code in largest possible chunks.
- r'[^\$\[\]\'"/]+', # exclude unsafe characters
+ (r'(' + r'|'.join(( # keep host code in largest possible chunks.
+ r'[^$\[\]\'"/]+', # exclude unsafe characters
# strings and comments may safely contain unsafe characters
r'"(\\\\|\\"|[^"])*"', # double quote string
@@ -720,26 +720,26 @@ class TreetopBaseLexer(RegexLexer):
include('end'),
(r'module\b', Keyword, '#push'),
(r'grammar\b', Keyword, 'grammar'),
- (r'[A-Z][A-Za-z_0-9]*(?:::[A-Z][A-Za-z_0-9]*)*', Name.Namespace),
+ (r'[A-Z]\w*(?:::[A-Z]\w*)*', Name.Namespace),
],
'grammar': [
include('space'),
include('end'),
(r'rule\b', Keyword, 'rule'),
(r'include\b', Keyword, 'include'),
- (r'[A-Z][A-Za-z_0-9]*', Name),
+ (r'[A-Z]\w*', Name),
],
'include': [
include('space'),
- (r'[A-Z][A-Za-z_0-9]*(?:::[A-Z][A-Za-z_0-9]*)*', Name.Class, '#pop'),
+ (r'[A-Z]\w*(?:::[A-Z]\w*)*', Name.Class, '#pop'),
],
'rule': [
include('space'),
include('end'),
(r'"(\\\\|\\"|[^"])*"', String.Double),
(r"'(\\\\|\\'|[^'])*'", String.Single),
- (r'([A-Za-z_][A-Za-z_0-9]*)(:)', bygroups(Name.Label, Punctuation)),
- (r'[A-Za-z_][A-Za-z_0-9]*', Name),
+ (r'([A-Za-z_]\w*)(:)', bygroups(Name.Label, Punctuation)),
+ (r'[A-Za-z_]\w*', Name),
(r'[()]', Punctuation),
(r'[?+*/&!~]', Operator),
(r'\[(?:\\.|\[:\^?[a-z]+:\]|[^\\\]])+\]', String.Regex),
@@ -830,6 +830,6 @@ class EbnfLexer(RegexLexer):
(r'[*)]', Comment.Multiline),
],
'identifier': [
- (r'([a-zA-Z][a-zA-Z0-9_ \-]*)', Keyword),
+ (r'([a-zA-Z][\w \-]*)', Keyword),
],
}
diff --git a/pygments/lexers/pascal.py b/pygments/lexers/pascal.py
index 0381f19f..54877485 100644
--- a/pygments/lexers/pascal.py
+++ b/pygments/lexers/pascal.py
@@ -535,7 +535,7 @@ class Modula2Lexer(RegexLexer):
(r'\s+', Text), # whitespace
],
'identifiers': [
- (r'([a-zA-Z_\$][\w\$]*)', Name),
+ (r'([a-zA-Z_$][\w$]*)', Name),
],
'numliterals': [
(r'[01]+B', Number.Bin), # binary number (ObjM2)
@@ -560,12 +560,12 @@ class Modula2Lexer(RegexLexer):
(r'::', Operator), # type conversion (ObjM2)
],
'punctuation': [
- (r'[\(\)\[\]{},.:;|]', Punctuation),
+ (r'[()\[\]{},.:;|]', Punctuation),
],
'comments': [
(r'//.*?\n', Comment.Single), # ObjM2
(r'/\*(.*?)\*/', Comment.Multiline), # ObjM2
- (r'\(\*([^\$].*?)\*\)', Comment.Multiline),
+ (r'\(\*([^$].*?)\*\)', Comment.Multiline),
# TO DO: nesting of (* ... *) comments
],
'pragmas': [
@@ -709,7 +709,7 @@ class AdaLexer(RegexLexer):
filenames = ['*.adb', '*.ads', '*.ada']
mimetypes = ['text/x-ada']
- flags = re.MULTILINE | re.I # Ignore case
+ flags = re.MULTILINE | re.IGNORECASE
tokens = {
'root': [
@@ -717,7 +717,7 @@ class AdaLexer(RegexLexer):
(r'--.*?\n', Comment.Single),
(r'[^\S\n]+', Text),
(r'function|procedure|entry', Keyword.Declaration, 'subprogram'),
- (r'(subtype|type)(\s+)([a-z0-9_]+)',
+ (r'(subtype|type)(\s+)(\w+)',
bygroups(Keyword.Declaration, Text, Keyword.Type), 'type_def'),
(r'task|protected', Keyword.Declaration),
(r'(subtype)(\s+)', bygroups(Keyword.Declaration, Text)),
@@ -737,11 +737,11 @@ class AdaLexer(RegexLexer):
(r'package', Keyword.Declaration, 'package'),
(r'array\b', Keyword.Reserved, 'array_def'),
(r'(with|use)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
- (r'([a-z0-9_]+)(\s*)(:)(\s*)(constant)',
+ (r'(\w+)(\s*)(:)(\s*)(constant)',
bygroups(Name.Constant, Text, Punctuation, Text,
Keyword.Reserved)),
- (r'<<[a-z0-9_]+>>', Name.Label),
- (r'([a-z0-9_]+)(\s*)(:)(\s*)(declare|begin|loop|for|while)',
+ (r'<<\w+>>', Name.Label),
+ (r'(\w+)(\s*)(:)(\s*)(declare|begin|loop|for|while)',
bygroups(Name.Label, Text, Punctuation, Text, Keyword.Reserved)),
(words((
'abort', 'abs', 'abstract', 'accept', 'access', 'aliased', 'all',
@@ -758,7 +758,7 @@ class AdaLexer(RegexLexer):
include('attribute'),
include('numbers'),
(r"'[^']'", String.Character),
- (r'([a-z0-9_]+)(\s*|[(,])', bygroups(Name, using(this))),
+ (r'(\w+)(\s*|[(,])', bygroups(Name, using(this))),
(r"(<>|=>|:=|[()|:;,.'])", Punctuation),
(r'[*<>+=/&-]', Operator),
(r'\n+', Text),
@@ -775,7 +775,7 @@ class AdaLexer(RegexLexer):
(r'\(', Punctuation, ('#pop', 'formal_part')),
(r';', Punctuation, '#pop'),
(r'is\b', Keyword.Reserved, '#pop'),
- (r'"[^"]+"|[a-z0-9_]+', Name.Function),
+ (r'"[^"]+"|\w+', Name.Function),
include('root'),
],
'end': [
@@ -795,8 +795,7 @@ class AdaLexer(RegexLexer):
],
'array_def': [
(r';', Punctuation, '#pop'),
- (r'([a-z0-9_]+)(\s+)(range)', bygroups(Keyword.Type, Text,
- Keyword.Reserved)),
+ (r'(\w+)(\s+)(range)', bygroups(Keyword.Type, Text, Keyword.Reserved)),
include('root'),
],
'record_def': [
@@ -804,12 +803,12 @@ class AdaLexer(RegexLexer):
include('root'),
],
'import': [
- (r'[a-z0-9_.]+', Name.Namespace, '#pop'),
+ (r'[\w.]+', Name.Namespace, '#pop'),
default('#pop'),
],
'formal_part': [
(r'\)', Punctuation, '#pop'),
- (r'[a-z0-9_]+', Name.Variable),
+ (r'\w+', Name.Variable),
(r',|:[^=]', Punctuation),
(r'(in|not|null|out|access)\b', Keyword.Reserved),
include('root'),
@@ -824,9 +823,8 @@ class AdaLexer(RegexLexer):
include('root'),
],
'package_instantiation': [
- (r'("[^"]+"|[a-z0-9_]+)(\s+)(=>)', bygroups(Name.Variable,
- Text, Punctuation)),
- (r'[a-z0-9._\'"]', Text),
+ (r'("[^"]+"|\w+)(\s+)(=>)', bygroups(Name.Variable, Text, Punctuation)),
+ (r'[\w.\'"]', Text),
(r'\)', Punctuation, '#pop'),
include('root'),
],
diff --git a/pygments/lexers/php.py b/pygments/lexers/php.py
index 5d1d650d..06aa3718 100644
--- a/pygments/lexers/php.py
+++ b/pygments/lexers/php.py
@@ -57,7 +57,7 @@ class ZephirLexer(RegexLexer):
(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
include('commentsandwhitespace'),
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
- r'(<<|>>>?|==?|!=?|->|[-<>+*%&\|\^/])=?', Operator, 'slashstartsregex'),
+ r'(<<|>>>?|==?|!=?|->|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
(r'[})\].]', Punctuation),
(r'(for|in|while|do|break|return|continue|switch|case|default|if|else|loop|'
@@ -172,10 +172,10 @@ class PhpLexer(RegexLexer):
(r'\$\{\$+' + _ident_inner + '\}', Name.Variable),
(r'\$+' + _ident_inner, Name.Variable),
(_ident_inner, Name.Other),
- (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
- (r'\d+[eE][+-]?[0-9]+', Number.Float),
+ (r'(\d+\.\d*|\d*\.\d+)(e[+-]?[0-9]+)?', Number.Float),
+ (r'\d+e[+-]?[0-9]+', Number.Float),
(r'0[0-7]+', Number.Oct),
- (r'0[xX][a-f0-9]+', Number.Hex),
+ (r'0x[a-f0-9]+', Number.Hex),
(r'\d+', Number.Integer),
(r'0b[01]+', Number.Bin),
(r"'([^'\\]*(?:\\.[^'\\]*)*)'", String.Single),
@@ -191,7 +191,7 @@ class PhpLexer(RegexLexer):
'string': [
(r'"', String.Double, '#pop'),
(r'[^{$"\\]+', String.Double),
- (r'\\([nrt\"$\\]|[0-7]{1,3}|x[0-9a-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'(\{\$\{)(.*?)(\}\})',
diff --git a/pygments/lexers/prolog.py b/pygments/lexers/prolog.py
index 95acf8e0..270239de 100644
--- a/pygments/lexers/prolog.py
+++ b/pygments/lexers/prolog.py
@@ -114,7 +114,7 @@ class LogtalkLexer(RegexLexer):
(r'0x[0-9a-fA-F]+', Number.Hex),
(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),
# Message forwarding handler
@@ -230,7 +230,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'),
],
@@ -259,8 +259,8 @@ class LogtalkLexer(RegexLexer):
r's(et_(logtalk|prolog)_flag|ynchronized))(?=[(])', Keyword, 'root'),
(r'op(?=[(])', Keyword, 'root'),
(r'(c(alls|oinductive)|module|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': [
@@ -272,9 +272,9 @@ class LogtalkLexer(RegexLexer):
(r'0x[0-9a-fA-F]+', Number.Hex),
(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),
diff --git a/pygments/lexers/rdf.py b/pygments/lexers/rdf.py
index 8d16c14f..292b1ae2 100644
--- a/pygments/lexers/rdf.py
+++ b/pygments/lexers/rdf.py
@@ -40,12 +40,12 @@ class SparqlLexer(RegexLexer):
r'insert\s+data|delete\s+data|delete\s+where|delete|insert|'
r'using named|using|graph|default|named|all|optional|service|'
r'silent|bind|union|not in|in|as|a)', Keyword),
- (r'(prefix|base)(\s+)([a-z][a-z\d_\-]*)(\s*)(\:)',
+ (r'(prefix|base)(\s+)([a-z][\w-]*)(\s*)(\:)',
bygroups(Keyword, Whitespace, Name.Namespace, Whitespace,
Punctuation)),
- (r'\?[a-z_][a-z\d_]*', Name.Variable),
+ (r'\?[a-z_]\w*', Name.Variable),
(r'<[^>]+>', Name.Label),
- (r'([a-z][a-z\d_\-]*)(\:)([a-z][a-z\d_\-]*)',
+ (r'([a-z][\w-]*)(\:)([a-z][\w-]*)',
bygroups(Name.Namespace, Punctuation, Name.Tag)),
(r'(str|lang|langmatches|datatype|bound|iri|uri|bnode|rand|abs|'
r'ceil|floor|round|concat|strlen|ucase|lcase|encode_for_uri|'
@@ -57,7 +57,7 @@ class SparqlLexer(RegexLexer):
Name.Function),
(r'(true|false)', Literal),
(r'[+\-]?\d*\.\d+', Number.Float),
- (r'[+\-]?\d*(:?\.\d+)?[eE][+\-]?\d+', Number.Float),
+ (r'[+\-]?\d*(:?\.\d+)?E[+\-]?\d+', Number.Float),
(r'[+\-]?\d+', Number.Integer),
(r'(\|\||&&|=|\*|\-|\+|/)', Operator),
(r'[(){}.;,:^]', Punctuation),
diff --git a/pygments/lexers/rebol.py b/pygments/lexers/rebol.py
index 2a0579ec..8ff97ee2 100644
--- a/pygments/lexers/rebol.py
+++ b/pygments/lexers/rebol.py
@@ -31,8 +31,6 @@ class RebolLexer(RegexLexer):
flags = re.IGNORECASE | re.MULTILINE
- re.IGNORECASE
-
escape_re = r'(?:\^\([0-9a-f]{1,4}\)*)'
def word_callback(lexer, match):
@@ -138,47 +136,47 @@ class RebolLexer(RegexLexer):
(r';\*+.*\n', Comment.Preproc),
(r';.*\n', Comment),
(r'%"', Name.Decorator, 'stringFile'),
- (r'%[^(\^{^")\s\[\]]+', Name.Decorator),
+ (r'%[^(^{")\s\[\]]+', Name.Decorator),
(r'[+-]?([a-z]{1,3})?\$\d+(\.\d+)?', Number.Float), # money
(r'[+-]?\d+\:\d+(\:\d+)?(\.\d+)?', String.Other), # time
- (r'\d+[\-\/][0-9a-z]+[\-\/]\d+(\/\d+\:\d+((\:\d+)?'
- r'([\.\d+]?([+-]?\d+:\d+)?)?)?)?', String.Other), # date
+ (r'\d+[\-/][0-9a-z]+[\-/]\d+(\/\d+\:\d+((\:\d+)?'
+ r'([.\d+]?([+-]?\d+:\d+)?)?)?)?', String.Other), # date
(r'\d+(\.\d+)+\.\d+', Keyword.Constant), # tuple
- (r'\d+[xX]\d+', Keyword.Constant), # pair
- (r'[+-]?\d+(\'\d+)?([\.,]\d*)?[eE][+-]?\d+', Number.Float),
- (r'[+-]?\d+(\'\d+)?[\.,]\d*', Number.Float),
+ (r'\d+X\d+', Keyword.Constant), # pair
+ (r'[+-]?\d+(\'\d+)?([.,]\d*)?E[+-]?\d+', Number.Float),
+ (r'[+-]?\d+(\'\d+)?[.,]\d*', Number.Float),
(r'[+-]?\d+(\'\d+)?', Number),
- (r'[\[\]\(\)]', Generic.Strong),
- (r'[a-z]+[^(\^{"\s:)]*://[^(\^{"\s)]*', Name.Decorator), # url
- (r'mailto:[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # url
- (r'[^(\^{"@\s)]+@[^(\^\{"@\s)]+', Name.Decorator), # email
+ (r'[\[\]()]', Generic.Strong),
+ (r'[a-z]+[^(^{"\s:)]*://[^(^{"\s)]*', Name.Decorator), # url
+ (r'mailto:[^(^{"@\s)]+@[^(^{"@\s)]+', Name.Decorator), # url
+ (r'[^(^{"@\s)]+@[^(^{"@\s)]+', Name.Decorator), # email
(r'comment\s"', Comment, 'commentString1'),
(r'comment\s\{', Comment, 'commentString2'),
(r'comment\s\[', Comment, 'commentBlock'),
- (r'comment\s[^(\s\{\"\[]+', Comment),
- (r'/[^(\^{^")\s/[\]]*', Name.Attribute),
- (r'([^(\^{^")\s/[\]]+)(?=[:({"\s/\[\]])', word_callback),
+ (r'comment\s[^(\s{"\[]+', Comment),
+ (r'/[^(^{")\s/[\]]*', Name.Attribute),
+ (r'([^(^{")\s/[\]]+)(?=[:({"\s/\[\]])', word_callback),
(r'<[\w:.-]*>', Name.Tag),
(r'<[^(<>\s")]+', Name.Tag, 'tag'),
- (r'([^(\^{^")\s]+)', Text),
+ (r'([^(^{")\s]+)', Text),
],
'string': [
- (r'[^(\^")]+', String),
+ (r'[^(^")]+', String),
(escape_re, String.Escape),
- (r'[\(|\)]+', String),
+ (r'[(|)]+', String),
(r'\^.', String.Escape),
(r'"', String, '#pop'),
],
'string2': [
- (r'[^(\^{^})]+', String),
+ (r'[^(^{})]+', String),
(escape_re, String.Escape),
- (r'[\(|\)]+', String),
+ (r'[(|)]+', String),
(r'\^.', String.Escape),
(r'\{', String, '#push'),
(r'\}', String, '#pop'),
],
'stringFile': [
- (r'[^(\^")]+', Name.Decorator),
+ (r'[^(^")]+', Name.Decorator),
(escape_re, Name.Decorator),
(r'\^.', Name.Decorator),
(r'"', Name.Decorator, '#pop'),
@@ -195,9 +193,9 @@ class RebolLexer(RegexLexer):
(r'>', Name.Tag, '#pop'),
],
'tagString': [
- (r'[^(\^")]+', Name.Tag),
+ (r'[^(^")]+', Name.Tag),
(escape_re, Name.Tag),
- (r'[\(|\)]+', Name.Tag),
+ (r'[(|)]+', Name.Tag),
(r'\^.', Name.Tag),
(r'"', Name.Tag, '#pop'),
],
@@ -207,20 +205,20 @@ class RebolLexer(RegexLexer):
],
'bin2': [
(r'\s+', Number.Hex),
- (r'([0-1]\s*){8}', Number.Hex),
+ (r'([01]\s*){8}', Number.Hex),
(r'\}', Number.Hex, '#pop'),
],
'commentString1': [
- (r'[^(\^")]+', Comment),
+ (r'[^(^")]+', Comment),
(escape_re, Comment),
- (r'[\(|\)]+', Comment),
+ (r'[(|)]+', Comment),
(r'\^.', Comment),
(r'"', Comment, '#pop'),
],
'commentString2': [
- (r'[^(\^{^})]+', Comment),
+ (r'[^(^{})]+', Comment),
(escape_re, Comment),
- (r'[\(|\)]+', Comment),
+ (r'[(|)]+', Comment),
(r'\^.', Comment),
(r'\{', Comment, '#push'),
(r'\}', Comment, '#pop'),
@@ -230,7 +228,7 @@ class RebolLexer(RegexLexer):
(r'\]', Comment, '#pop'),
(r'"', Comment, "commentString1"),
(r'\{', Comment, "commentString2"),
- (r'[^(\[\]\"{)]+', Comment),
+ (r'[^(\[\]"{)]+', Comment),
],
}
@@ -328,7 +326,7 @@ class RedLexer(RegexLexer):
(r'#\{[0-9a-f\s]*\}', Number.Hex),
(r'2#\{', Number.Hex, 'bin2'),
(r'64#\{[0-9a-z+/=\s]*\}', Number.Hex),
- (r'([0-9a-f]+)(h)((\s)|(?=[\[\]{}"\(\)]))',
+ (r'([0-9a-f]+)(h)((\s)|(?=[\[\]{}"()]))',
bygroups(Number.Hex, Name.Variable, Whitespace)),
(r'"', String, 'string'),
(r'\{', String, 'string2'),
@@ -336,47 +334,47 @@ class RedLexer(RegexLexer):
(r';\*+.*\n', Comment.Preproc),
(r';.*\n', Comment),
(r'%"', Name.Decorator, 'stringFile'),
- (r'%[^(\^{^")\s\[\]]+', Name.Decorator),
+ (r'%[^(^{")\s\[\]]+', Name.Decorator),
(r'[+-]?([a-z]{1,3})?\$\d+(\.\d+)?', Number.Float), # money
(r'[+-]?\d+\:\d+(\:\d+)?(\.\d+)?', String.Other), # time
- (r'\d+[\-\/][0-9a-z]+[\-\/]\d+(\/\d+\:\d+((\:\d+)?'
+ (r'\d+[\-/][0-9a-z]+[\-/]\d+(/\d+:\d+((:\d+)?'
r'([\.\d+]?([+-]?\d+:\d+)?)?)?)?', String.Other), # date
(r'\d+(\.\d+)+\.\d+', Keyword.Constant), # tuple
- (r'\d+[xX]\d+', Keyword.Constant), # pair
- (r'[+-]?\d+(\'\d+)?([\.,]\d*)?[eE][+-]?\d+', Number.Float),
- (r'[+-]?\d+(\'\d+)?[\.,]\d*', Number.Float),
+ (r'\d+X\d+', Keyword.Constant), # pair
+ (r'[+-]?\d+(\'\d+)?([.,]\d*)?E[+-]?\d+', Number.Float),
+ (r'[+-]?\d+(\'\d+)?[.,]\d*', Number.Float),
(r'[+-]?\d+(\'\d+)?', Number),
- (r'[\[\]\(\)]', Generic.Strong),
- (r'[a-z]+[^(\^{"\s:)]*://[^(\^{"\s)]*', Name.Decorator), # url
- (r'mailto:[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # url
- (r'[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # email
+ (r'[\[\]()]', Generic.Strong),
+ (r'[a-z]+[^(^{"\s:)]*://[^(^{"\s)]*', Name.Decorator), # url
+ (r'mailto:[^(^{"@\s)]+@[^(^{"@\s)]+', Name.Decorator), # url
+ (r'[^(^{"@\s)]+@[^(^{"@\s)]+', Name.Decorator), # email
(r'comment\s"', Comment, 'commentString1'),
(r'comment\s\{', Comment, 'commentString2'),
(r'comment\s\[', Comment, 'commentBlock'),
- (r'comment\s[^(\s{\"\[]+', Comment),
- (r'/[^(\^{^")\s/[\]]*', Name.Attribute),
- (r'([^(\^{^")\s/[\]]+)(?=[:({"\s/\[\]])', word_callback),
+ (r'comment\s[^(\s{"\[]+', Comment),
+ (r'/[^(^{^")\s/[\]]*', Name.Attribute),
+ (r'([^(^{^")\s/[\]]+)(?=[:({"\s/\[\]])', word_callback),
(r'<[\w:.-]*>', Name.Tag),
(r'<[^(<>\s")]+', Name.Tag, 'tag'),
- (r'([^(\^{^")\s]+)', Text),
+ (r'([^(^{")\s]+)', Text),
],
'string': [
- (r'[^(\^")]+', String),
+ (r'[^(^")]+', String),
(escape_re, String.Escape),
- (r'[\(|\)]+', String),
+ (r'[(|)]+', String),
(r'\^.', String.Escape),
(r'"', String, '#pop'),
],
'string2': [
- (r'[^(\^{^})]+', String),
+ (r'[^(^{})]+', String),
(escape_re, String.Escape),
- (r'[\(|\)]+', String),
+ (r'[(|)]+', String),
(r'\^.', String.Escape),
(r'\{', String, '#push'),
(r'\}', String, '#pop'),
],
'stringFile': [
- (r'[^(\^")]+', Name.Decorator),
+ (r'[^(^")]+', Name.Decorator),
(escape_re, Name.Decorator),
(r'\^.', Name.Decorator),
(r'"', Name.Decorator, '#pop'),
@@ -393,9 +391,9 @@ class RedLexer(RegexLexer):
(r'>', Name.Tag, '#pop'),
],
'tagString': [
- (r'[^(\^")]+', Name.Tag),
+ (r'[^(^")]+', Name.Tag),
(escape_re, Name.Tag),
- (r'[\(|\)]+', Name.Tag),
+ (r'[(|)]+', Name.Tag),
(r'\^.', Name.Tag),
(r'"', Name.Tag, '#pop'),
],
@@ -405,20 +403,20 @@ class RedLexer(RegexLexer):
],
'bin2': [
(r'\s+', Number.Hex),
- (r'([0-1]\s*){8}', Number.Hex),
+ (r'([01]\s*){8}', Number.Hex),
(r'\}', Number.Hex, '#pop'),
],
'commentString1': [
- (r'[^(\^")]+', Comment),
+ (r'[^(^")]+', Comment),
(escape_re, Comment),
- (r'[\(|\)]+', Comment),
+ (r'[(|)]+', Comment),
(r'\^.', Comment),
(r'"', Comment, '#pop'),
],
'commentString2': [
- (r'[^(\^{^})]+', Comment),
+ (r'[^(^{})]+', Comment),
(escape_re, Comment),
- (r'[\(|\)]+', Comment),
+ (r'[(|)]+', Comment),
(r'\^.', Comment),
(r'\{', Comment, '#push'),
(r'\}', Comment, '#pop'),
@@ -428,6 +426,6 @@ class RedLexer(RegexLexer):
(r'\]', Comment, '#pop'),
(r'"', Comment, "commentString1"),
(r'\{', Comment, "commentString2"),
- (r'[^(\[\]\"{)]+', Comment),
+ (r'[^(\[\]"{)]+', Comment),
],
}