summaryrefslogtreecommitdiff
path: root/pygments
diff options
context:
space:
mode:
authorTim Hatch <tim@timhatch.com>2014-04-14 20:17:01 -0400
committerTim Hatch <tim@timhatch.com>2014-04-14 20:17:01 -0400
commita26518b3a05c107c2d29b8a54e6bf3ac542aaf68 (patch)
treec1f24d7a8ac348a9687a6e51a979426940147094 /pygments
parent3bdae5a385e198dcdbee2d37adac212d780fd380 (diff)
parentc75a752481251a0f2033a0db2466f293e73fa7e2 (diff)
downloadpygments-a26518b3a05c107c2d29b8a54e6bf3ac542aaf68.tar.gz
Merged in jaingaurav2/pygments-main (pull request #314)
Diffstat (limited to 'pygments')
-rw-r--r--pygments/cmdline.py10
-rw-r--r--pygments/formatters/latex.py92
-rw-r--r--pygments/formatters/rtf.py11
-rw-r--r--pygments/formatters/terminal.py40
-rw-r--r--pygments/lexers/_mapping.py20
-rw-r--r--pygments/lexers/agile.py422
-rw-r--r--pygments/lexers/compiled.py21
-rw-r--r--pygments/lexers/functional.py2
-rw-r--r--pygments/lexers/inferno.py99
-rw-r--r--pygments/lexers/jvm.py200
-rw-r--r--pygments/lexers/math.py325
-rw-r--r--pygments/lexers/other.py330
-rw-r--r--pygments/lexers/rdf.py98
-rw-r--r--pygments/lexers/sql.py33
-rw-r--r--pygments/lexers/templates.py64
-rw-r--r--pygments/lexers/text.py102
-rw-r--r--pygments/lexers/web.py92
-rw-r--r--pygments/styles/__init__.py2
-rw-r--r--pygments/styles/paraiso-dark.py119
-rw-r--r--pygments/styles/paraiso-light.py119
-rw-r--r--pygments/token.py2
21 files changed, 1970 insertions, 233 deletions
diff --git a/pygments/cmdline.py b/pygments/cmdline.py
index af8d48ea..7c23ebee 100644
--- a/pygments/cmdline.py
+++ b/pygments/cmdline.py
@@ -19,6 +19,7 @@ from pygments import __version__, highlight
from pygments.util import ClassNotFound, OptionError, docstring_headline
from pygments.lexers import get_all_lexers, get_lexer_by_name, get_lexer_for_filename, \
find_lexer_class, guess_lexer, TextLexer
+from pygments.formatters.latex import LatexEmbeddedLexer, LatexFormatter
from pygments.formatters import get_all_formatters, get_formatter_by_name, \
get_formatter_for_filename, find_formatter_class, \
TerminalFormatter # pylint:disable-msg=E0611
@@ -405,6 +406,15 @@ def main(args=sys.argv):
else:
code = sys.stdin.read()
+ # When using the LaTeX formatter and the option `escapeinside` is
+ # specified, we need a special lexer which collects escaped text
+ # before running the chosen language lexer.
+ escapeinside = parsed_opts.get('escapeinside', '')
+ if len(escapeinside) == 2 and isinstance(fmter, LatexFormatter):
+ left = escapeinside[0]
+ right = escapeinside[1]
+ lexer = LatexEmbeddedLexer(left, right, lexer)
+
# No encoding given? Use latin1 if output file given,
# stdin/stdout encoding otherwise.
# (This is a compromise, I'm not too happy with it...)
diff --git a/pygments/formatters/latex.py b/pygments/formatters/latex.py
index 0f2397eb..fee177c5 100644
--- a/pygments/formatters/latex.py
+++ b/pygments/formatters/latex.py
@@ -12,6 +12,7 @@
from __future__ import division
from pygments.formatter import Formatter
+from pygments.lexer import Lexer
from pygments.token import Token, STANDARD_TYPES
from pygments.util import get_bool_opt, get_int_opt, StringIO, xrange, \
iteritems
@@ -226,6 +227,15 @@ class LatexFormatter(Formatter):
``False``).
.. versionadded:: 1.2
+
+ `escapeinside`
+ If set to a string of length 2, enables escaping to LaTeX. Text
+ delimited by these 2 characters is read as LaTeX code and
+ typeset accordingly. It has no effect in string literals. It has
+ no effect in comments if `texcomments` or `mathescape` is
+ set. (default: ``''``).
+
+ .. versionadded:: 2.0
"""
name = 'LaTeX'
aliases = ['latex', 'tex']
@@ -243,6 +253,13 @@ class LatexFormatter(Formatter):
self.commandprefix = options.get('commandprefix', 'PY')
self.texcomments = get_bool_opt(options, 'texcomments', False)
self.mathescape = get_bool_opt(options, 'mathescape', False)
+ self.escapeinside = options.get('escapeinside', '')
+
+ if len(self.escapeinside) == 2:
+ self.left = self.escapeinside[0]
+ self.right = self.escapeinside[1]
+ else:
+ self.escapeinside = ''
self._create_stylesheet()
@@ -314,14 +331,14 @@ class LatexFormatter(Formatter):
realoutfile = outfile
outfile = StringIO()
- outfile.write(r'\begin{Verbatim}[commandchars=\\\{\}')
+ outfile.write(u'\\begin{Verbatim}[commandchars=\\\\\\{\\}')
if self.linenos:
start, step = self.linenostart, self.linenostep
outfile.write(u',numbers=left' +
(start and u',firstnumber=%d' % start or u'') +
(step and u',stepnumber=%d' % step or u''))
- if self.mathescape or self.texcomments:
- outfile.write(r',codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8}')
+ if self.mathescape or self.texcomments or self.escapeinside:
+ outfile.write(u',codes={\\catcode`\\$=3\\catcode`\\^=7\\catcode`\\_=8}')
if self.verboptions:
outfile.write(u',' + self.verboptions)
outfile.write(u']\n')
@@ -350,9 +367,22 @@ class LatexFormatter(Formatter):
parts[i] = escape_tex(part, self.commandprefix)
in_math = not in_math
value = '$'.join(parts)
+ elif self.escapeinside:
+ text = value
+ value = ''
+ while len(text) > 0:
+ a,sep1,text = text.partition(self.left)
+ if len(sep1) > 0:
+ b,sep2,text = text.partition(self.right)
+ if len(sep2) > 0:
+ value = value + escape_tex(a, self.commandprefix) + b
+ else:
+ value = value + escape_tex(a + sep1 + b, self.commandprefix)
+ else:
+ value = value + escape_tex(a, self.commandprefix)
else:
value = escape_tex(value, self.commandprefix)
- else:
+ elif not (ttype in Token.Escape):
value = escape_tex(value, self.commandprefix)
styles = []
while ttype is not Token:
@@ -384,3 +414,57 @@ class LatexFormatter(Formatter):
encoding = self.encoding or 'latin1',
styledefs = self.get_style_defs(),
code = outfile.getvalue()))
+
+
+class LatexEmbeddedLexer(Lexer):
+ r"""
+
+ This lexer takes one lexer as argument, the lexer for the language
+ being formatted, and the left and right delimiters for escaped text.
+
+ First everything is scanned using the language lexer to obtain
+ strings and comments. All other consecutive tokens are merged and
+ the resulting text is scanned for escaped segments, which are given
+ the Token.Escape type. Finally text that is not escaped is scanned
+ again with the language lexer.
+ """
+ def __init__(self, left, right, lang, **options):
+ self.left = left
+ self.right = right
+ self.lang = lang
+ Lexer.__init__(self, **options)
+
+ def get_tokens_unprocessed(self, text):
+ buf = ''
+ for i, t, v in self.lang.get_tokens_unprocessed(text):
+ if t in Token.Comment or t in Token.String:
+ if buf:
+ for x in self.get_tokens_aux(idx, buf):
+ yield x
+ buf = ''
+ yield i, t, v
+ else:
+ if not buf:
+ idx = i;
+ buf += v
+ if buf:
+ for x in self.get_tokens_aux(idx, buf):
+ yield x
+
+ def get_tokens_aux(self, index, text):
+ while text:
+ a, sep1, text = text.partition(self.left)
+ if a:
+ for i, t, v in self.lang.get_tokens_unprocessed(a):
+ yield index + i, t, v
+ index += len(a)
+ if sep1:
+ b, sep2, text = text.partition(self.right)
+ if sep2:
+ yield index + len(sep1), Token.Escape, b
+ index += len(sep1) + len(b) + len(sep2)
+ else:
+ yield index, Token.Error, sep1
+ index += len(sep1)
+ text = b
+
diff --git a/pygments/formatters/rtf.py b/pygments/formatters/rtf.py
index 59d97742..9d87e8f1 100644
--- a/pygments/formatters/rtf.py
+++ b/pygments/formatters/rtf.py
@@ -10,6 +10,7 @@
"""
from pygments.formatter import Formatter
+from pygments.util import get_int_opt
__all__ = ['RtfFormatter']
@@ -32,6 +33,12 @@ class RtfFormatter(Formatter):
`fontface`
The used font famliy, for example ``Bitstream Vera Sans``. Defaults to
some generic font which is supposed to have fixed width.
+
+ `fontsize`
+ Size of the font used. Size is specified in half points. The
+ default is 24 half-points, giving a size 12 font.
+
+ .. versionadded:: 2.0
"""
name = 'RTF'
aliases = ['rtf']
@@ -49,9 +56,11 @@ class RtfFormatter(Formatter):
specification claims that ``\fmodern`` are "Fixed-pitch serif
and sans serif fonts". Hope every RTF implementation thinks
the same about modern...
+
"""
Formatter.__init__(self, **options)
self.fontface = options.get('fontface') or ''
+ self.fontsize = get_int_opt(options, 'fontsize', 0)
def _escape(self, text):
return text.replace('\\', '\\\\') \
@@ -106,6 +115,8 @@ class RtfFormatter(Formatter):
))
offset += 1
outfile.write(r'}\f0')
+ if self.fontsize:
+ outfile.write(r'\fs%d' % (self.fontsize))
# highlight stream
for ttype, value in tokensource:
diff --git a/pygments/formatters/terminal.py b/pygments/formatters/terminal.py
index 539b0be9..34af3afe 100644
--- a/pygments/formatters/terminal.py
+++ b/pygments/formatters/terminal.py
@@ -73,6 +73,10 @@ class TerminalFormatter(Formatter):
`colorscheme`
A dictionary mapping token types to (lightbg, darkbg) color names or
``None`` (default: ``None`` = use builtin colorscheme).
+
+ `linenos`
+ Set to ``True`` to have line numbers on the terminal output as well
+ (default: ``False`` = no line numbers).
"""
name = 'Terminal'
aliases = ['terminal', 'console']
@@ -83,6 +87,8 @@ class TerminalFormatter(Formatter):
self.darkbg = get_choice_opt(options, 'bg',
['light', 'dark'], 'light') == 'dark'
self.colorscheme = options.get('colorscheme', None) or TERMINAL_COLORS
+ self.linenos = options.get('linenos', False)
+ self._lineno = 0
def format(self, tokensource, outfile):
# hack: if the output is a terminal and has an encoding set,
@@ -93,7 +99,40 @@ class TerminalFormatter(Formatter):
self.encoding = outfile.encoding
return Formatter.format(self, tokensource, outfile)
+ def _write_lineno(self, outfile):
+ self._lineno += 1
+ outfile.write("\n%04d: " % self._lineno)
+
+ def _format_unencoded_with_lineno(self, tokensource, outfile):
+ self._write_lineno(outfile)
+
+ for ttype, value in tokensource:
+ if value.endswith("\n"):
+ self._write_lineno(outfile)
+ value = value[:-1]
+ color = self.colorscheme.get(ttype)
+ while color is None:
+ ttype = ttype[:-1]
+ color = self.colorscheme.get(ttype)
+ if color:
+ color = color[self.darkbg]
+ spl = value.split('\n')
+ for line in spl[:-1]:
+ self._write_lineno(outfile)
+ if line:
+ outfile.write(ansiformat(color, line[:-1]))
+ if spl[-1]:
+ outfile.write(ansiformat(color, spl[-1]))
+ else:
+ outfile.write(value)
+
+ outfile.write("\n")
+
def format_unencoded(self, tokensource, outfile):
+ if self.linenos:
+ self._format_unencoded_with_lineno(tokensource, outfile)
+ return
+
for ttype, value in tokensource:
color = self.colorscheme.get(ttype)
while color is None:
@@ -110,3 +149,4 @@ class TerminalFormatter(Formatter):
outfile.write(ansiformat(color, spl[-1]))
else:
outfile.write(value)
+
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index 3258c865..d9311558 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -17,10 +17,12 @@ from __future__ import print_function
LEXERS = {
'ABAPLexer': ('pygments.lexers.other', 'ABAP', ('abap',), ('*.abap',), ('text/x-abap',)),
+ 'APLLexer': ('pygments.lexers.other', 'APL', ('apl',), ('*.apl',), ()),
'ActionScript3Lexer': ('pygments.lexers.web', 'ActionScript 3', ('as3', 'actionscript3'), ('*.as',), ('application/x-actionscript', 'text/x-actionscript', 'text/actionscript')),
'ActionScriptLexer': ('pygments.lexers.web', 'ActionScript', ('as', 'actionscript'), ('*.as',), ('application/x-actionscript3', 'text/x-actionscript3', 'text/actionscript3')),
'AdaLexer': ('pygments.lexers.compiled', 'Ada', ('ada', 'ada95ada2005'), ('*.adb', '*.ads', '*.ada'), ('text/x-ada',)),
'AgdaLexer': ('pygments.lexers.functional', 'Agda', ('agda',), ('*.agda',), ('text/x-agda',)),
+ 'AmbientTalkLexer': ('pygments.lexers.other', 'AmbientTalk', ('at', 'ambienttalk', 'ambienttalk/2'), ('*.at',), ('text/x-ambienttalk',)),
'AntlrActionScriptLexer': ('pygments.lexers.parsers', 'ANTLR With ActionScript Target', ('antlr-as', 'antlr-actionscript'), ('*.G', '*.g'), ()),
'AntlrCSharpLexer': ('pygments.lexers.parsers', 'ANTLR With C# Target', ('antlr-csharp', 'antlr-c#'), ('*.G', '*.g'), ()),
'AntlrCppLexer': ('pygments.lexers.parsers', 'ANTLR With CPP Target', ('antlr-cpp',), ('*.G', '*.g'), ()),
@@ -66,13 +68,14 @@ LEXERS = {
'CirruLexer': ('pygments.lexers.web', 'Cirru', ('cirru',), ('*.cirru', '*.cr'), ('text/x-cirru',)),
'ClayLexer': ('pygments.lexers.compiled', 'Clay', ('clay',), ('*.clay',), ('text/x-clay',)),
'ClojureLexer': ('pygments.lexers.jvm', 'Clojure', ('clojure', 'clj'), ('*.clj',), ('text/x-clojure', 'application/x-clojure')),
+ 'ClojureScriptLexer': ('pygments.lexers.jvm', 'ClojureScript', ('clojurescript', 'cljs'), ('*.cljs',), ('text/x-clojurescript', 'application/x-clojurescript')),
'CobolFreeformatLexer': ('pygments.lexers.compiled', 'COBOLFree', ('cobolfree',), ('*.cbl', '*.CBL'), ()),
'CobolLexer': ('pygments.lexers.compiled', 'COBOL', ('cobol',), ('*.cob', '*.COB', '*.cpy', '*.CPY'), ('text/x-cobol',)),
'CoffeeScriptLexer': ('pygments.lexers.web', 'CoffeeScript', ('coffee-script', 'coffeescript', 'coffee'), ('*.coffee',), ('text/coffeescript',)),
'ColdfusionCFCLexer': ('pygments.lexers.templates', 'Coldfusion CFC', ('cfc',), ('*.cfc',), ()),
'ColdfusionHtmlLexer': ('pygments.lexers.templates', 'Coldfusion HTML', ('cfm',), ('*.cfm', '*.cfml'), ('application/x-coldfusion',)),
'ColdfusionLexer': ('pygments.lexers.templates', 'cfstatement', ('cfs',), (), ()),
- 'CommonLispLexer': ('pygments.lexers.functional', 'Common Lisp', ('common-lisp', 'cl', 'lisp'), ('*.cl', '*.lisp', '*.el'), ('text/x-common-lisp',)),
+ 'CommonLispLexer': ('pygments.lexers.functional', 'Common Lisp', ('common-lisp', 'cl', 'lisp', 'elisp', 'emacs'), ('*.cl', '*.lisp', '*.el'), ('text/x-common-lisp',)),
'CoqLexer': ('pygments.lexers.functional', 'Coq', ('coq',), ('*.v',), ('text/x-coq',)),
'CppLexer': ('pygments.lexers.compiled', 'C++', ('cpp', 'c++'), ('*.cpp', '*.hpp', '*.c++', '*.h++', '*.cc', '*.hh', '*.cxx', '*.hxx', '*.C', '*.H', '*.cp', '*.CPP'), ('text/x-c++hdr', 'text/x-c++src')),
'CppObjdumpLexer': ('pygments.lexers.asm', 'cpp-objdump', ('cpp-objdump', 'c++-objdumb', 'cxx-objdump'), ('*.cpp-objdump', '*.c++-objdump', '*.cxx-objdump'), ('text/x-cpp-objdump',)),
@@ -118,6 +121,7 @@ LEXERS = {
'FelixLexer': ('pygments.lexers.compiled', 'Felix', ('felix', 'flx'), ('*.flx', '*.flxh'), ('text/x-felix',)),
'FortranLexer': ('pygments.lexers.compiled', 'Fortran', ('fortran',), ('*.f', '*.f90', '*.F', '*.F90'), ('text/x-fortran',)),
'FoxProLexer': ('pygments.lexers.foxpro', 'FoxPro', ('foxpro', 'vfp', 'clipper', 'xbase'), ('*.PRG', '*.prg'), ()),
+ 'GAPLexer': ('pygments.lexers.math', 'GAP', ('gap',), ('*.g', '*.gd', '*.gi', '*.gap'), ()),
'GLShaderLexer': ('pygments.lexers.compiled', 'GLSL', ('glsl',), ('*.vert', '*.frag', '*.geo'), ('text/x-glslsrc',)),
'GasLexer': ('pygments.lexers.asm', 'GAS', ('gas', 'asm'), ('*.s', '*.S'), ('text/x-gas',)),
'GenshiLexer': ('pygments.lexers.templates', 'Genshi', ('genshi', 'kid', 'xml+genshi', 'xml+kid'), ('*.kid',), ('application/x-genshi', 'application/x-kid')),
@@ -126,12 +130,15 @@ LEXERS = {
'GherkinLexer': ('pygments.lexers.other', 'Gherkin', ('cucumber', 'gherkin'), ('*.feature',), ('text/x-gherkin',)),
'GnuplotLexer': ('pygments.lexers.other', 'Gnuplot', ('gnuplot',), ('*.plot', '*.plt'), ('text/x-gnuplot',)),
'GoLexer': ('pygments.lexers.compiled', 'Go', ('go',), ('*.go',), ('text/x-gosrc',)),
+ 'GoloLexer': ('pygments.lexers.jvm', 'Golo', ('golo',), ('*.golo',), ()),
'GoodDataCLLexer': ('pygments.lexers.other', 'GoodData-CL', ('gooddata-cl',), ('*.gdc',), ('text/x-gooddata-cl',)),
'GosuLexer': ('pygments.lexers.jvm', 'Gosu', ('gosu',), ('*.gs', '*.gsx', '*.gsp', '*.vark'), ('text/x-gosu',)),
'GosuTemplateLexer': ('pygments.lexers.jvm', 'Gosu Template', ('gst',), ('*.gst',), ('text/x-gosu-template',)),
'GroffLexer': ('pygments.lexers.text', 'Groff', ('groff', 'nroff', 'man'), ('*.[1234567]', '*.man'), ('application/x-troff', 'text/troff')),
'GroovyLexer': ('pygments.lexers.jvm', 'Groovy', ('groovy',), ('*.groovy',), ('text/x-groovy',)),
'HamlLexer': ('pygments.lexers.web', 'Haml', ('haml',), ('*.haml',), ('text/x-haml',)),
+ 'HandlebarsHtmlLexer': ('pygments.lexers.templates', 'HTML+Handlebars', ('html+handlebars',), ('*.handlebars', '*.hbs'), ('text/html+handlebars', 'text/x-handlebars-template')),
+ 'HandlebarsLexer': ('pygments.lexers.templates', 'Handlebars', ('handlebars',), (), ()),
'HaskellLexer': ('pygments.lexers.functional', 'Haskell', ('haskell', 'hs'), ('*.hs',), ('text/x-haskell',)),
'HaxeLexer': ('pygments.lexers.web', 'Haxe', ('hx', 'haxe', 'hxsl'), ('*.hx', '*.hxsl'), ('text/haxe', 'text/x-haxe', 'text/x-hx')),
'HtmlDjangoLexer': ('pygments.lexers.templates', 'HTML+Django/Jinja', ('html+django', 'html+jinja', 'htmldjango'), (), ('text/html+django', 'text/html+jinja')),
@@ -170,12 +177,14 @@ LEXERS = {
'KconfigLexer': ('pygments.lexers.other', 'Kconfig', ('kconfig', 'menuconfig', 'linux-config', 'kernel-config'), ('Kconfig', '*Config.in*', 'external.in*', 'standard-modules.in'), ('text/x-kconfig',)),
'KokaLexer': ('pygments.lexers.functional', 'Koka', ('koka',), ('*.kk', '*.kki'), ('text/x-koka',)),
'KotlinLexer': ('pygments.lexers.jvm', 'Kotlin', ('kotlin',), ('*.kt',), ('text/x-kotlin',)),
+ 'LSLLexer': ('pygments.lexers.other', 'LSL', ('lsl',), ('*.lsl',), ('text/x-lsl',)),
'LassoCssLexer': ('pygments.lexers.templates', 'CSS+Lasso', ('css+lasso',), (), ('text/css+lasso',)),
'LassoHtmlLexer': ('pygments.lexers.templates', 'HTML+Lasso', ('html+lasso',), (), ('text/html+lasso', 'application/x-httpd-lasso', 'application/x-httpd-lasso[89]')),
'LassoJavascriptLexer': ('pygments.lexers.templates', 'JavaScript+Lasso', ('js+lasso', 'javascript+lasso'), (), ('application/x-javascript+lasso', 'text/x-javascript+lasso', 'text/javascript+lasso')),
'LassoLexer': ('pygments.lexers.web', 'Lasso', ('lasso', 'lassoscript'), ('*.lasso', '*.lasso[89]'), ('text/x-lasso',)),
'LassoXmlLexer': ('pygments.lexers.templates', 'XML+Lasso', ('xml+lasso',), (), ('application/xml+lasso',)),
'LighttpdConfLexer': ('pygments.lexers.text', 'Lighttpd configuration file', ('lighty', 'lighttpd'), (), ('text/x-lighttpd-conf',)),
+ 'LimboLexer': ('pygments.lexers.inferno', 'Limbo', ('limbo',), ('*.b',), ('text/limbo',)),
'LiterateAgdaLexer': ('pygments.lexers.functional', 'Literate Agda', ('lagda', 'literate-agda'), ('*.lagda',), ('text/x-literate-agda',)),
'LiterateHaskellLexer': ('pygments.lexers.functional', 'Literate Haskell', ('lhs', 'literate-haskell', 'lhaskell'), ('*.lhs',), ('text/x-literate-haskell',)),
'LiterateIdrisLexer': ('pygments.lexers.functional', 'Literate Idris', ('lidr', 'literate-idris', 'lidris'), ('*.lidr',), ('text/x-literate-idris',)),
@@ -233,9 +242,11 @@ LEXERS = {
'OocLexer': ('pygments.lexers.compiled', 'Ooc', ('ooc',), ('*.ooc',), ('text/x-ooc',)),
'OpaLexer': ('pygments.lexers.functional', 'Opa', ('opa',), ('*.opa',), ('text/x-opa',)),
'OpenEdgeLexer': ('pygments.lexers.other', 'OpenEdge ABL', ('openedge', 'abl', 'progress'), ('*.p', '*.cls'), ('text/x-openedge', 'application/x-openedge')),
+ 'PawnLexer': ('pygments.lexers.other', 'Pawn', ('pawn',), ('*.p', '*.pwn', '*.inc'), ('text/x-pawn',)),
'Perl6Lexer': ('pygments.lexers.agile', 'Perl6', ('perl6', 'pl6'), ('*.pl', '*.pm', '*.nqp', '*.p6', '*.6pl', '*.p6l', '*.pl6', '*.6pm', '*.p6m', '*.pm6', '*.t'), ('text/x-perl6', 'application/x-perl6')),
'PerlLexer': ('pygments.lexers.agile', 'Perl', ('perl', 'pl'), ('*.pl', '*.pm', '*.t'), ('text/x-perl', 'application/x-perl')),
'PhpLexer': ('pygments.lexers.web', 'PHP', ('php', 'php3', 'php4', 'php5'), ('*.php', '*.php[345]', '*.inc'), ('text/x-php',)),
+ 'PigLexer': ('pygments.lexers.jvm', 'Pig', ('pig',), ('*.pig',), ('text/x-pig',)),
'PikeLexer': ('pygments.lexers.compiled', 'Pike', ('pike',), ('*.pike', '*.pmod'), ('text/x-pike',)),
'PlPgsqlLexer': ('pygments.lexers.sql', 'PL/pgSQL', ('plpgsql',), (), ('text/x-plpgsql',)),
'PostScriptLexer': ('pygments.lexers.other', 'PostScript', ('postscript', 'postscr'), ('*.ps', '*.eps'), ('application/postscript',)),
@@ -273,11 +284,12 @@ LEXERS = {
'RexxLexer': ('pygments.lexers.other', 'Rexx', ('rexx', 'arexx'), ('*.rexx', '*.rex', '*.rx', '*.arexx'), ('text/x-rexx',)),
'RhtmlLexer': ('pygments.lexers.templates', 'RHTML', ('rhtml', 'html+erb', 'html+ruby'), ('*.rhtml',), ('text/html+ruby',)),
'RobotFrameworkLexer': ('pygments.lexers.other', 'RobotFramework', ('robotframework',), ('*.txt', '*.robot'), ('text/x-robotframework',)),
+ 'RqlLexer': ('pygments.lexers.sql', 'RQL', ('rql',), ('*.rql',), ('text/x-rql',)),
'RstLexer': ('pygments.lexers.text', 'reStructuredText', ('rst', 'rest', 'restructuredtext'), ('*.rst', '*.rest'), ('text/x-rst', 'text/prs.fallenstein.rst')),
'RubyConsoleLexer': ('pygments.lexers.agile', 'Ruby irb session', ('rbcon', 'irb'), (), ('text/x-ruby-shellsession',)),
'RubyLexer': ('pygments.lexers.agile', 'Ruby', ('rb', 'ruby', 'duby'), ('*.rb', '*.rbw', 'Rakefile', '*.rake', '*.gemspec', '*.rbx', '*.duby'), ('text/x-ruby', 'application/x-ruby')),
'RustLexer': ('pygments.lexers.compiled', 'Rust', ('rust',), ('*.rs',), ('text/x-rustsrc',)),
- 'SLexer': ('pygments.lexers.math', 'S', ('splus', 's', 'r'), ('*.S', '*.R', '.Rhistory', '.Rprofile'), ('text/S-plus', 'text/S', 'text/x-r-source', 'text/x-r', 'text/x-R', 'text/x-r-history', 'text/x-r-profile')),
+ 'SLexer': ('pygments.lexers.math', 'S', ('splus', 's', 'r'), ('*.S', '*.R', '.Rhistory', '.Rprofile', '.Renviron'), ('text/S-plus', 'text/S', 'text/x-r-source', 'text/x-r', 'text/x-R', 'text/x-r-history', 'text/x-r-profile')),
'SMLLexer': ('pygments.lexers.functional', 'Standard ML', ('sml',), ('*.sml', '*.sig', '*.fun'), ('text/x-standardml', 'application/x-standardml')),
'SassLexer': ('pygments.lexers.web', 'Sass', ('sass',), ('*.sass',), ('text/x-sass',)),
'ScalaLexer': ('pygments.lexers.jvm', 'Scala', ('scala',), ('*.scala',), ('text/x-scala',)),
@@ -292,6 +304,7 @@ LEXERS = {
'SnobolLexer': ('pygments.lexers.other', 'Snobol', ('snobol',), ('*.snobol',), ('text/x-snobol',)),
'SourcePawnLexer': ('pygments.lexers.other', 'SourcePawn', ('sp',), ('*.sp',), ('text/x-sourcepawn',)),
'SourcesListLexer': ('pygments.lexers.text', 'Debian Sourcelist', ('sourceslist', 'sources.list', 'debsources'), ('sources.list',), ()),
+ 'SparqlLexer': ('pygments.lexers.rdf', 'SPARQL', ('sparql',), ('*.rq', '*.sparql'), ('application/sparql-query',)),
'SqlLexer': ('pygments.lexers.sql', 'SQL', ('sql',), ('*.sql',), ('text/x-sql',)),
'SqliteConsoleLexer': ('pygments.lexers.sql', 'sqlite3con', ('sqlite3',), ('*.sqlite3-console',), ('text/x-sqlite3-console',)),
'SquidConfLexer': ('pygments.lexers.text', 'SquidConf', ('squidconf', 'squid.conf', 'squid'), ('squid.conf',), ('text/x-squidconf',)),
@@ -304,9 +317,11 @@ LEXERS = {
'TeaTemplateLexer': ('pygments.lexers.templates', 'Tea', ('tea',), ('*.tea',), ('text/x-tea',)),
'TexLexer': ('pygments.lexers.text', 'TeX', ('tex', 'latex'), ('*.tex', '*.aux', '*.toc'), ('text/x-tex', 'text/x-latex')),
'TextLexer': ('pygments.lexers.special', 'Text only', ('text',), ('*.txt',), ('text/plain',)),
+ 'TodotxtLexer': ('pygments.lexers.text', 'Todotxt', ('todotxt',), ('todo.txt', '*.todotxt'), ('text/x-todo',)),
'TreetopLexer': ('pygments.lexers.parsers', 'Treetop', ('treetop',), ('*.treetop', '*.tt'), ()),
'TypeScriptLexer': ('pygments.lexers.web', 'TypeScript', ('ts',), ('*.ts',), ('text/x-typescript',)),
'UrbiscriptLexer': ('pygments.lexers.other', 'UrbiScript', ('urbiscript',), ('*.u',), ('application/x-urbiscript',)),
+ 'VCTreeStatusLexer': ('pygments.lexers.other', 'VCTreeStatus', ('vctreestatus',), (), ()),
'VGLLexer': ('pygments.lexers.other', 'VGL', ('vgl',), ('*.rpf',), ()),
'ValaLexer': ('pygments.lexers.compiled', 'Vala', ('vala', 'vapi'), ('*.vala', '*.vapi'), ('text/x-vala',)),
'VbNetAspxLexer': ('pygments.lexers.dotnet', 'aspx-vb', ('aspx-vb',), ('*.aspx', '*.asax', '*.ascx', '*.ashx', '*.asmx', '*.axd'), ()),
@@ -326,6 +341,7 @@ LEXERS = {
'XsltLexer': ('pygments.lexers.web', 'XSLT', ('xslt',), ('*.xsl', '*.xslt', '*.xpl'), ('application/xsl+xml', 'application/xslt+xml')),
'XtendLexer': ('pygments.lexers.jvm', 'Xtend', ('xtend',), ('*.xtend',), ('text/x-xtend',)),
'YamlLexer': ('pygments.lexers.text', 'YAML', ('yaml',), ('*.yaml', '*.yml'), ('text/x-yaml',)),
+ 'ZephirLexer': ('pygments.lexers.web', 'Zephir', ('zephir',), ('*.zep',), ()),
}
if __name__ == '__main__':
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py
index a49289dc..0a780a3e 100644
--- a/pygments/lexers/agile.py
+++ b/pygments/lexers/agile.py
@@ -1477,232 +1477,272 @@ class FactorLexer(RegexLexer):
flags = re.MULTILINE | re.UNICODE
builtin_kernel = (
- r'(?:or|2bi|2tri|while|wrapper|nip|4dip|wrapper\\?|bi\\*|'
- r'callstack>array|both\\?|hashcode|die|dupd|callstack|'
- r'callstack\\?|3dup|tri@|pick|curry|build|\\?execute|3bi|'
- r'prepose|>boolean|\\?if|clone|eq\\?|tri\\*|\\?|=|swapd|'
- r'2over|2keep|3keep|clear|2dup|when|not|tuple\\?|dup|2bi\\*|'
- r'2tri\\*|call|tri-curry|object|bi@|do|unless\\*|if\\*|loop|'
- r'bi-curry\\*|drop|when\\*|assert=|retainstack|assert\\?|-rot|'
- r'execute|2bi@|2tri@|boa|with|either\\?|3drop|bi|curry\\?|'
- r'datastack|until|3dip|over|3curry|tri-curry\\*|tri-curry@|swap|'
- r'and|2nip|throw|bi-curry|\\(clone\\)|hashcode\\*|compose|2dip|if|3tri|'
- r'unless|compose\\?|tuple|keep|2curry|equal\\?|assert|tri|2drop|'
- r'most|<wrapper>|boolean\\?|identity-hashcode|identity-tuple\\?|'
- r'null|new|dip|bi-curry@|rot|xor|identity-tuple|boolean)\s'
- )
+ r'(?:-rot|2bi|2bi@|2bi\*|2curry|2dip|2drop|2dup|2keep|2nip|'
+ r'2over|2tri|2tri@|2tri\*|3bi|3curry|3dip|3drop|3dup|3keep|'
+ r'3tri|4dip|4drop|4dup|4keep|<wrapper>|=|>boolean|\(clone\)|'
+ r'\?|\?execute|\?if|and|assert|assert=|assert\?|bi|bi-curry|'
+ r'bi-curry@|bi-curry\*|bi@|bi\*|boa|boolean|boolean\?|both\?|'
+ r'build|call|callstack|callstack>array|callstack\?|clear|clone|'
+ r'compose|compose\?|curry|curry\?|datastack|die|dip|do|drop|'
+ r'dup|dupd|either\?|eq\?|equal\?|execute|hashcode|hashcode\*|'
+ r'identity-hashcode|identity-tuple|identity-tuple\?|if|if\*|'
+ r'keep|loop|most|new|nip|not|null|object|or|over|pick|prepose|'
+ r'retainstack|rot|same\?|swap|swapd|throw|tri|tri-curry|'
+ r'tri-curry@|tri-curry\*|tri@|tri\*|tuple|tuple\?|unless|'
+ r'unless\*|until|when|when\*|while|with|wrapper|wrapper\?|xor)\s'
+ )
builtin_assocs = (
- r'(?:\\?at|assoc\\?|assoc-clone-like|assoc=|delete-at\\*|'
- r'assoc-partition|extract-keys|new-assoc|value\\?|assoc-size|'
- r'map>assoc|push-at|assoc-like|key\\?|assoc-intersect|'
- r'assoc-refine|update|assoc-union|assoc-combine|at\\*|'
- r'assoc-empty\\?|at\\+|set-at|assoc-all\\?|assoc-subset\\?|'
- r'assoc-hashcode|change-at|assoc-each|assoc-diff|zip|values|'
- r'value-at|rename-at|inc-at|enum\\?|at|cache|assoc>map|<enum>|'
- r'assoc|assoc-map|enum|value-at\\*|assoc-map-as|>alist|'
- r'assoc-filter-as|clear-assoc|assoc-stack|maybe-set-at|'
- r'substitute|assoc-filter|2cache|delete-at|assoc-find|keys|'
- r'assoc-any\\?|unzip)\s'
- )
+ r'(?:2cache|<enum>|>alist|\?at|\?of|assoc|assoc-all\?|'
+ r'assoc-any\?|assoc-clone-like|assoc-combine|assoc-diff|'
+ r'assoc-diff!|assoc-differ|assoc-each|assoc-empty\?|'
+ r'assoc-filter|assoc-filter!|assoc-filter-as|assoc-find|'
+ r'assoc-hashcode|assoc-intersect|assoc-like|assoc-map|'
+ r'assoc-map-as|assoc-partition|assoc-refine|assoc-size|'
+ r'assoc-stack|assoc-subset\?|assoc-union|assoc-union!|'
+ r'assoc=|assoc>map|assoc\?|at|at+|at\*|cache|change-at|'
+ r'clear-assoc|delete-at|delete-at\*|enum|enum\?|extract-keys|'
+ r'inc-at|key\?|keys|map>assoc|maybe-set-at|new-assoc|of|'
+ r'push-at|rename-at|set-at|sift-keys|sift-values|substitute|'
+ r'unzip|value-at|value-at\*|value\?|values|zip)\s'
+ )
builtin_combinators = (
- r'(?:case|execute-effect|no-cond|no-case\\?|3cleave>quot|2cleave|'
- r'cond>quot|wrong-values\\?|no-cond\\?|cleave>quot|no-case|'
- r'case>quot|3cleave|wrong-values|to-fixed-point|alist>quot|'
- r'case-find|cond|cleave|call-effect|2cleave>quot|recursive-hashcode|'
- r'linear-case-quot|spread|spread>quot)\s'
- )
+ r'(?:2cleave|2cleave>quot|3cleave|3cleave>quot|4cleave|'
+ r'4cleave>quot|alist>quot|call-effect|case|case-find|'
+ r'case>quot|cleave|cleave>quot|cond|cond>quot|deep-spread>quot|'
+ r'execute-effect|linear-case-quot|no-case|no-case\?|no-cond|'
+ r'no-cond\?|recursive-hashcode|shallow-spread>quot|spread|'
+ r'to-fixed-point|wrong-values|wrong-values\?)\s'
+ )
builtin_math = (
- r'(?:number=|if-zero|next-power-of-2|each-integer|\\?1\\+|'
- r'fp-special\\?|imaginary-part|unless-zero|float>bits|number\\?|'
- r'fp-infinity\\?|bignum\\?|fp-snan\\?|denominator|fp-bitwise=|\\*|'
- r'\\+|power-of-2\\?|-|u>=|/|>=|bitand|log2-expects-positive|<|'
- r'log2|>|integer\\?|number|bits>double|2/|zero\\?|(find-integer)|'
- r'bits>float|float\\?|shift|ratio\\?|even\\?|ratio|fp-sign|bitnot|'
- r'>fixnum|complex\\?|/i|/f|byte-array>bignum|when-zero|sgn|>bignum|'
- r'next-float|u<|u>|mod|recip|rational|find-last-integer|>float|'
- r'(all-integers\\?)|2^|times|integer|fixnum\\?|neg|fixnum|sq|'
- r'bignum|(each-integer)|bit\\?|fp-qnan\\?|find-integer|complex|'
- r'<fp-nan>|real|double>bits|bitor|rem|fp-nan-payload|all-integers\\?|'
- r'real-part|log2-expects-positive\\?|prev-float|align|unordered\\?|'
- r'float|fp-nan\\?|abs|bitxor|u<=|odd\\?|<=|/mod|rational\\?|>integer|'
- r'real\\?|numerator)\s'
- )
+ r'(?:-|/|/f|/i|/mod|2/|2\^|<|<=|<fp-nan>|>|>=|>bignum|'
+ r'>fixnum|>float|>integer|\(all-integers\?\)|'
+ r'\(each-integer\)|\(find-integer\)|\*|\+|\?1\+|'
+ r'abs|align|all-integers\?|bignum|bignum\?|bit\?|bitand|'
+ r'bitnot|bitor|bits>double|bits>float|bitxor|complex|'
+ r'complex\?|denominator|double>bits|each-integer|even\?|'
+ r'find-integer|find-last-integer|fixnum|fixnum\?|float|'
+ r'float>bits|float\?|fp-bitwise=|fp-infinity\?|fp-nan-payload|'
+ r'fp-nan\?|fp-qnan\?|fp-sign|fp-snan\?|fp-special\?|'
+ r'if-zero|imaginary-part|integer|integer>fixnum|'
+ r'integer>fixnum-strict|integer\?|log2|log2-expects-positive|'
+ r'log2-expects-positive\?|mod|neg|neg\?|next-float|'
+ r'next-power-of-2|number|number=|number\?|numerator|odd\?|'
+ r'out-of-fixnum-range|out-of-fixnum-range\?|power-of-2\?|'
+ r'prev-float|ratio|ratio\?|rational|rational\?|real|'
+ r'real-part|real\?|recip|rem|sgn|shift|sq|times|u<|u<=|u>|'
+ r'u>=|unless-zero|unordered\?|when-zero|zero\?)\s'
+ )
builtin_sequences = (
- r'(?:member-eq\\?|append|assert-sequence=|find-last-from|trim-head-slice|'
- r'clone-like|3sequence|assert-sequence\\?|map-as|last-index-from|'
- r'reversed|index-from|cut\\*|pad-tail|remove-eq!|concat-as|'
- r'but-last|snip|trim-tail|nths|nth|2selector|sequence|slice\\?|'
- r'<slice>|partition|remove-nth|tail-slice|empty\\?|tail\\*|'
- r'if-empty|find-from|virtual-sequence\\?|member\\?|set-length|'
- r'drop-prefix|unclip|unclip-last-slice|iota|map-sum|'
- r'bounds-error\\?|sequence-hashcode-step|selector-for|'
- r'accumulate-as|map|start|midpoint@|\\(accumulate\\)|rest-slice|'
- r'prepend|fourth|sift|accumulate!|new-sequence|follow|map!|'
- r'like|first4|1sequence|reverse|slice|unless-empty|padding|'
- r'virtual@|repetition\\?|set-last|index|4sequence|max-length|'
- r'set-second|immutable-sequence|first2|first3|replicate-as|'
- r'reduce-index|unclip-slice|supremum|suffix!|insert-nth|'
- r'trim-tail-slice|tail|3append|short|count|suffix|concat|'
- r'flip|filter|sum|immutable\\?|reverse!|2sequence|map-integers|'
- r'delete-all|start\\*|indices|snip-slice|check-slice|sequence\\?|'
- r'head|map-find|filter!|append-as|reduce|sequence=|halves|'
- r'collapse-slice|interleave|2map|filter-as|binary-reduce|'
- r'slice-error\\?|product|bounds-check\\?|bounds-check|harvest|'
- r'immutable|virtual-exemplar|find|produce|remove|pad-head|last|'
- r'replicate|set-fourth|remove-eq|shorten|reversed\\?|'
- r'map-find-last|3map-as|2unclip-slice|shorter\\?|3map|find-last|'
- r'head-slice|pop\\*|2map-as|tail-slice\\*|but-last-slice|'
- r'2map-reduce|iota\\?|collector-for|accumulate|each|selector|'
- r'append!|new-resizable|cut-slice|each-index|head-slice\\*|'
- r'2reverse-each|sequence-hashcode|pop|set-nth|\\?nth|'
- r'<flat-slice>|second|join|when-empty|collector|'
- r'immutable-sequence\\?|<reversed>|all\\?|3append-as|'
- r'virtual-sequence|subseq\\?|remove-nth!|push-either|new-like|'
- r'length|last-index|push-if|2all\\?|lengthen|assert-sequence|'
- r'copy|map-reduce|move|third|first|3each|tail\\?|set-first|'
- r'prefix|bounds-error|any\\?|<repetition>|trim-slice|exchange|'
- r'surround|2reduce|cut|change-nth|min-length|set-third|produce-as|'
- r'push-all|head\\?|delete-slice|rest|sum-lengths|2each|head\\*|'
- r'infimum|remove!|glue|slice-error|subseq|trim|replace-slice|'
- r'push|repetition|map-index|trim-head|unclip-last|mismatch)\s'
- )
+ r'(?:1sequence|2all\?|2each|2map|2map-as|2map-reduce|2reduce|'
+ r'2selector|2sequence|3append|3append-as|3each|3map|3map-as|'
+ r'3sequence|4sequence|<repetition>|<reversed>|<slice>|\?first|'
+ r'\?last|\?nth|\?second|\?set-nth|accumulate|accumulate!|'
+ r'accumulate-as|all\?|any\?|append|append!|append-as|'
+ r'assert-sequence|assert-sequence=|assert-sequence\?|'
+ r'binary-reduce|bounds-check|bounds-check\?|bounds-error|'
+ r'bounds-error\?|but-last|but-last-slice|cartesian-each|'
+ r'cartesian-map|cartesian-product|change-nth|check-slice|'
+ r'check-slice-error|clone-like|collapse-slice|collector|'
+ r'collector-for|concat|concat-as|copy|count|cut|cut-slice|'
+ r'cut\*|delete-all|delete-slice|drop-prefix|each|each-from|'
+ r'each-index|empty\?|exchange|filter|filter!|filter-as|find|'
+ r'find-from|find-index|find-index-from|find-last|find-last-from|'
+ r'first|first2|first3|first4|flip|follow|fourth|glue|halves|'
+ r'harvest|head|head-slice|head-slice\*|head\*|head\?|'
+ r'if-empty|immutable|immutable-sequence|immutable-sequence\?|'
+ r'immutable\?|index|index-from|indices|infimum|infimum-by|'
+ r'insert-nth|interleave|iota|iota-tuple|iota-tuple\?|join|'
+ r'join-as|last|last-index|last-index-from|length|lengthen|'
+ r'like|longer|longer\?|longest|map|map!|map-as|map-find|'
+ r'map-find-last|map-index|map-integers|map-reduce|map-sum|'
+ r'max-length|member-eq\?|member\?|midpoint@|min-length|'
+ r'mismatch|move|new-like|new-resizable|new-sequence|'
+ r'non-negative-integer-expected|non-negative-integer-expected\?|'
+ r'nth|nths|pad-head|pad-tail|padding|partition|pop|pop\*|'
+ r'prefix|prepend|prepend-as|produce|produce-as|product|push|'
+ r'push-all|push-either|push-if|reduce|reduce-index|remove|'
+ r'remove!|remove-eq|remove-eq!|remove-nth|remove-nth!|repetition|'
+ r'repetition\?|replace-slice|replicate|replicate-as|rest|'
+ r'rest-slice|reverse|reverse!|reversed|reversed\?|second|'
+ r'selector|selector-for|sequence|sequence-hashcode|sequence=|'
+ r'sequence\?|set-first|set-fourth|set-last|set-length|set-nth|'
+ r'set-second|set-third|short|shorten|shorter|shorter\?|'
+ r'shortest|sift|slice|slice-error|slice-error\?|slice\?|'
+ r'snip|snip-slice|start|start\*|subseq|subseq\?|suffix|'
+ r'suffix!|sum|sum-lengths|supremum|supremum-by|surround|tail|'
+ r'tail-slice|tail-slice\*|tail\*|tail\?|third|trim|'
+ r'trim-head|trim-head-slice|trim-slice|trim-tail|trim-tail-slice|'
+ r'unclip|unclip-last|unclip-last-slice|unclip-slice|unless-empty|'
+ r'virtual-exemplar|virtual-sequence|virtual-sequence\?|virtual@|'
+ r'when-empty)\s'
+ )
builtin_namespaces = (
- r'(?:global|\\+@|change|set-namestack|change-global|init-namespaces|'
- r'on|off|set-global|namespace|set|with-scope|bind|with-variable|'
- r'inc|dec|counter|initialize|namestack|get|get-global|make-assoc)\s'
- )
+ r'(?:\+@|change|change-global|counter|dec|get|get-global|'
+ r'global|inc|init-namespaces|initialize|is-global|make-assoc|'
+ r'namespace|namestack|off|on|set|set-global|set-namestack|'
+ r'toggle|with-global|with-scope|with-variable|with-variables)\s'
+ )
builtin_arrays = (
- r'(?:<array>|2array|3array|pair|>array|1array|4array|pair\\?|'
- r'array|resize-array|array\\?)\s'
- )
+ r'(?:1array|2array|3array|4array|<array>|>array|array|array\?|'
+ r'pair|pair\?|resize-array)\s'
+ )
builtin_io = (
- r'(?:\\+character\\+|bad-seek-type\\?|readln|each-morsel|stream-seek|'
- r'read|print|with-output-stream|contents|write1|stream-write1|'
- r'stream-copy|stream-element-type|with-input-stream|'
- r'stream-print|stream-read|stream-contents|stream-tell|'
- r'tell-output|bl|seek-output|bad-seek-type|nl|stream-nl|write|'
- r'flush|stream-lines|\\+byte\\+|stream-flush|read1|'
- r'seek-absolute\\?|stream-read1|lines|stream-readln|'
- r'stream-read-until|each-line|seek-end|with-output-stream\\*|'
- r'seek-absolute|with-streams|seek-input|seek-relative\\?|'
- r'input-stream|stream-write|read-partial|seek-end\\?|'
- r'seek-relative|error-stream|read-until|with-input-stream\\*|'
- r'with-streams\\*|tell-input|each-block|output-stream|'
- r'stream-read-partial|each-stream-block|each-stream-line)\s'
- )
+ r'(?:\(each-stream-block-slice\)|\(each-stream-block\)|'
+ r'\(stream-contents-by-block\)|\(stream-contents-by-element\)|'
+ r'\(stream-contents-by-length-or-block\)|'
+ r'\(stream-contents-by-length\)|\+byte\+|\+character\+|'
+ r'bad-seek-type|bad-seek-type\?|bl|contents|each-block|'
+ r'each-block-size|each-block-slice|each-line|each-morsel|'
+ r'each-stream-block|each-stream-block-slice|each-stream-line|'
+ r'error-stream|flush|input-stream|input-stream\?|'
+ r'invalid-read-buffer|invalid-read-buffer\?|lines|nl|'
+ r'output-stream|output-stream\?|print|read|read-into|'
+ r'read-partial|read-partial-into|read-until|read1|readln|'
+ r'seek-absolute|seek-absolute\?|seek-end|seek-end\?|'
+ r'seek-input|seek-output|seek-relative|seek-relative\?|'
+ r'stream-bl|stream-contents|stream-contents\*|stream-copy|'
+ r'stream-copy\*|stream-element-type|stream-flush|'
+ r'stream-length|stream-lines|stream-nl|stream-print|'
+ r'stream-read|stream-read-into|stream-read-partial|'
+ r'stream-read-partial-into|stream-read-partial-unsafe|'
+ r'stream-read-unsafe|stream-read-until|stream-read1|'
+ r'stream-readln|stream-seek|stream-seekable\?|stream-tell|'
+ r'stream-write|stream-write1|tell-input|tell-output|'
+ r'with-error-stream|with-error-stream\*|with-error>output|'
+ r'with-input-output\+error-streams|'
+ r'with-input-output\+error-streams\*|with-input-stream|'
+ r'with-input-stream\*|with-output-stream|with-output-stream\*|'
+ r'with-output>error|with-output\+error-stream|'
+ r'with-output\+error-stream\*|with-streams|with-streams\*|'
+ r'write|write1)\s'
+ )
builtin_strings = (
- r'(?:resize-string|>string|<string>|1string|string|string\\?)\s'
- )
+ r'(?:1string|<string>|>string|resize-string|string|string\?)\s'
+ )
builtin_vectors = (
- r'(?:vector\\?|<vector>|\\?push|vector|>vector|1vector)\s'
- )
+ r'(?:1vector|<vector>|>vector|\?push|vector|vector\?)\s'
+ )
builtin_continuations = (
- r'(?:with-return|restarts|return-continuation|with-datastack|'
- r'recover|rethrow-restarts|<restart>|ifcc|set-catchstack|'
- r'>continuation<|cleanup|ignore-errors|restart\\?|'
- r'compute-restarts|attempt-all-error|error-thread|continue|'
- r'<continuation>|attempt-all-error\\?|condition\\?|'
- r'<condition>|throw-restarts|error|catchstack|continue-with|'
- r'thread-error-hook|continuation|rethrow|callcc1|'
- r'error-continuation|callcc0|attempt-all|condition|'
- r'continuation\\?|restart|return)\s'
- )
+ r'(?:<condition>|<continuation>|<restart>|attempt-all|'
+ r'attempt-all-error|attempt-all-error\?|callback-error-hook|'
+ r'callcc0|callcc1|cleanup|compute-restarts|condition|'
+ r'condition\?|continuation|continuation\?|continue|'
+ r'continue-restart|continue-with|current-continuation|'
+ r'error|error-continuation|error-in-thread|error-thread|'
+ r'ifcc|ignore-errors|in-callback\?|original-error|recover|'
+ r'restart|restart\?|restarts|rethrow|rethrow-restarts|'
+ r'return|return-continuation|thread-error-hook|throw-continue|'
+ r'throw-restarts|with-datastack|with-return)\s'
+ )
tokens = {
'root': [
- # TODO: (( inputs -- outputs ))
- # TODO: << ... >>
+ # factor allows a file to start with a shebang
+ (r'#!.*$', Comment.Preproc),
+ (r'', Text, 'base'),
+ ],
+ 'base': [
+ (r'\s+', Text),
# defining words
- (r'(\s*)(:|::|MACRO:|MEMO:)(\s+)(\S+)',
- bygroups(Text, Keyword, Text, Name.Function)),
- (r'(\s*)(M:)(\s+)(\S+)(\s+)(\S+)',
- bygroups(Text, Keyword, Text, Name.Class, Text, Name.Function)),
- (r'(\s*)(GENERIC:)(\s+)(\S+)',
- bygroups(Text, Keyword, Text, Name.Function)),
- (r'(\s*)(HOOK:|GENERIC#)(\s+)(\S+)(\s+)(\S+)',
- bygroups(Text, Keyword, Text, Name.Function, Text, Name.Function)),
- (r'(\()(\s+)', bygroups(Name.Function, Text), 'stackeffect'),
- (r'\;\s', Keyword),
+ (r'((?:MACRO|MEMO|TYPED)?:[:]?)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Function)),
+ (r'(M:[:]?)(\s+)(\S+)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Class, Text, Name.Function)),
+ (r'(C:)(\s+)(\S+)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Function, Text, Name.Class)),
+ (r'(GENERIC:)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Function)),
+ (r'(HOOK:|GENERIC#)(\s+)(\S+)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Function, Text, Name.Function)),
+ (r'\(\s', Name.Function, 'stackeffect'),
+ (r';\s', Keyword),
# imports and namespaces
- (r'(USING:)((?:\s|\\\s)+)',
- bygroups(Keyword.Namespace, Text), 'import'),
- (r'(USE:)(\s+)(\S+)',
- bygroups(Keyword.Namespace, Text, Name.Namespace)),
- (r'(UNUSE:)(\s+)(\S+)',
- bygroups(Keyword.Namespace, Text, Name.Namespace)),
- (r'(QUALIFIED:)(\s+)(\S+)',
+ (r'(USING:)(\s+)',
+ bygroups(Keyword.Namespace, Text), 'vocabs'),
+ (r'(USE:|UNUSE:|IN:|QUALIFIED:)(\s+)(\S+)',
bygroups(Keyword.Namespace, Text, Name.Namespace)),
- (r'(QUALIFIED-WITH:)(\s+)(\S+)',
- bygroups(Keyword.Namespace, Text, Name.Namespace)),
- (r'(FROM:|EXCLUDE:)(\s+)(\S+)(\s+)(=>)',
- bygroups(Keyword.Namespace, Text, Name.Namespace, Text, Text)),
- (r'(IN:)(\s+)(\S+)',
- bygroups(Keyword.Namespace, Text, Name.Namespace)),
- (r'(?:ALIAS|DEFER|FORGET|POSTPONE):', Keyword.Namespace),
+ (r'(QUALIFIED-WITH:)(\s+)(\S+)(\s+)(\S+)',
+ bygroups(Keyword.Namespace, Text, Name.Namespace, Text, Name.Namespace)),
+ (r'(FROM:|EXCLUDE:)(\s+)(\S+)(\s+=>\s)',
+ bygroups(Keyword.Namespace, Text, Name.Namespace, Text), 'words'),
+ (r'(RENAME:)(\s+)(\S+)(\s+)(\S+)(\s+=>\s+)(\S+)',
+ bygroups(Keyword.Namespace, Text, Name.Function, Text, Name.Namespace, Text, Name.Function)),
+ (r'(ALIAS:|TYPEDEF:)(\s+)(\S+)(\s+)(\S+)',
+ bygroups(Keyword.Namespace, Text, Name.Function, Text, Name.Function)),
+ (r'(DEFER:|FORGET:|POSTPONE:)(\s+)(\S+)',
+ bygroups(Keyword.Namespace, Text, Name.Function)),
# tuples and classes
- (r'(TUPLE:)(\s+)(\S+)(\s+<\s+)(\S+)',
+ (r'(TUPLE:|ERROR:)(\s+)(\S+)(\s+<\s+)(\S+)',
bygroups(Keyword, Text, Name.Class, Text, Name.Class), 'slots'),
- (r'(TUPLE:)(\s+)(\S+)',
+ (r'(TUPLE:|ERROR:|BUILTIN:)(\s+)(\S+)',
bygroups(Keyword, Text, Name.Class), 'slots'),
- (r'(UNION:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Class)),
- (r'(INTERSECTION:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Class)),
+ (r'(MIXIN:|UNION:|INTERSECTION:)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Class)),
(r'(PREDICATE:)(\s+)(\S+)(\s+<\s+)(\S+)',
- bygroups(Keyword, Text, Name.Class, Text, Name.Class)),
+ bygroups(Keyword, Text, Name.Class, Text, Name.Class)),
(r'(C:)(\s+)(\S+)(\s+)(\S+)',
- bygroups(Keyword, Text, Name.Function, Text, Name.Class)),
- (r'INSTANCE:', Keyword),
- (r'SLOT:', Keyword),
- (r'MIXIN:', Keyword),
- (r'(?:SINGLETON|SINGLETONS):', Keyword),
+ bygroups(Keyword, Text, Name.Function, Text, Name.Class)),
+ (r'(INSTANCE:)(\s+)(\S+)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Class, Text, Name.Class)),
+ (r'(SLOT:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Function)),
+ (r'(SINGLETON:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Class)),
+ (r'SINGLETONS:', Keyword, 'classes'),
# other syntax
- (r'CONSTANT:', Keyword),
- (r'(?:SYMBOL|SYMBOLS):', Keyword),
- (r'ERROR:', Keyword),
- (r'SYNTAX:', Keyword),
- (r'(HELP:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Function)),
- (r'(MAIN:)(\s+)(\S+)',
- bygroups(Keyword.Namespace, Text, Name.Function)),
- (r'(?:ALIEN|TYPEDEF|FUNCTION|STRUCT):', Keyword),
+ (r'(CONSTANT:|SYMBOL:|MAIN:|HELP:)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Function)),
+ (r'SYMBOLS:\s', Keyword, 'words'),
+ (r'SYNTAX:\s', Keyword),
+ (r'ALIEN:\s', Keyword),
+ (r'(STRUCT:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Class)),
+ (r'(FUNCTION:)(\s+\S+\s+)(\S+)(\s+\(\s+[^\)]+\)\s)',
+ bygroups(Keyword.Namespace, Text, Name.Function, Text)),
+ (r'(FUNCTION-ALIAS:)(\s+)(\S+)(\s+\S+\s+)(\S+)(\s+\(\s+[^\)]+\)\s)',
+ bygroups(Keyword.Namespace, Text, Name.Function, Text, Name.Function, Text)),
# vocab.private
- # TODO: words inside vocab.private should have red names?
- (r'(?:<PRIVATE|PRIVATE>)', Keyword.Namespace),
+ (r'(?:<PRIVATE|PRIVATE>)\s', Keyword.Namespace),
# strings
(r'"""\s+(?:.|\n)*?\s+"""', String),
(r'"(?:\\\\|\\"|[^"])*"', String),
- (r'CHAR:\s+(\\[\\abfnrstv]*|\S)\s', String.Char),
+ (r'\S+"\s+(?:\\\\|\\"|[^"])*"', String),
+ (r'CHAR:\s+(\\[\\abfnrstv]|[^\\]\S+)\s', String.Char),
# comments
- (r'\!\s+.*$', Comment),
- (r'#\!\s+.*$', Comment),
+ (r'!\s+.*$', Comment),
+ (r'#!\s+.*$', Comment),
+ (r'/\*\s+(?:.|\n)*?\s\*/\s', Comment),
# boolean constants
(r'(t|f)\s', Name.Constant),
- # numbers
- (r'-?\d+\.\d+\s', Number.Float),
- (r'-?\d+\s', Number.Integer),
- (r'HEX:\s+[a-fA-F\d]+\s', Number.Hex),
- (r'BIN:\s+[01]+\s', Number.Integer),
- (r'OCT:\s+[0-7]+\s', Number.Oct),
+ # symbols and literals
+ (r'[\\$]\s+\S+', Name.Constant),
+ (r'M\\\s+\S+\s+\S+', Name.Constant),
- # operators
- (r'[-+/*=<>^]\s', Operator),
+ # numbers
+ (r'[+-]?([\d,]*\d)?\.(\d([\d,]*\d)?)?([eE][+-]?\d+)?\s', Number),
+ (r'[+-]?\d([\d,]*\d)?([eE][+-]?\d+)?\s', Number),
+ (r'0x[a-fA-F\d]([a-fA-F\d,]*[a-fA-F\d])?(p\d([\d,]*\d)?)?\s', Number),
+ (r'NAN:\s+[a-fA-F\d]([a-fA-F\d,]*[a-fA-F\d])?(p\d([\d,]*\d)?)?\s', Number),
+ (r'0b[01]+\s', Number),
+ (r'0o[0-7]+\s', Number),
+ (r'(\d([\d,]*\d)?)?\+\d([\d,]*\d)?/\d([\d,]*\d)?\s', Number),
+ (r'(\-\d([\d,]*\d)?)?\-\d([\d,]*\d)?/\d([\d,]*\d)?\s', Number),
# keywords
(r'(?:deprecated|final|foldable|flushable|inline|recursive)\s',
@@ -1721,31 +1761,37 @@ class FactorLexer(RegexLexer):
(builtin_vectors, Name.Builtin),
(builtin_continuations, Name.Builtin),
- # whitespaces - usually not relevant
- (r'\s+', Text),
-
# everything else is text
(r'\S+', Text),
],
-
'stackeffect': [
- (r'\s*\(', Name.Function, 'stackeffect'),
- (r'\)', Name.Function, '#pop'),
- (r'\-\-', Name.Function),
(r'\s+', Text),
+ (r'\(\s+', Name.Function, 'stackeffect'),
+ (r'\)\s', Name.Function, '#pop'),
+ (r'--\s', Name.Function),
(r'\S+', Name.Variable),
],
-
'slots': [
(r'\s+', Text),
(r';\s', Keyword, '#pop'),
+ (r'({\s+)(\S+)(\s+[^}]+\s+}\s)',
+ bygroups(Text, Name.Variable, Text)),
(r'\S+', Name.Variable),
],
-
- 'import': [
- (r';', Keyword, '#pop'),
+ 'vocabs': [
+ (r'\s+', Text),
+ (r';\s', Keyword, '#pop'),
(r'\S+', Name.Namespace),
+ ],
+ 'classes': [
+ (r'\s+', Text),
+ (r';\s', Keyword, '#pop'),
+ (r'\S+', Name.Class),
+ ],
+ 'words': [
(r'\s+', Text),
+ (r';\s', Keyword, '#pop'),
+ (r'\S+', Name.Function),
],
}
diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py
index 58cd6869..103a9be5 100644
--- a/pygments/lexers/compiled.py
+++ b/pygments/lexers/compiled.py
@@ -469,20 +469,23 @@ class DLexer(RegexLexer):
(r'(abstract|alias|align|asm|assert|auto|body|break|case|cast'
r'|catch|class|const|continue|debug|default|delegate|delete'
r'|deprecated|do|else|enum|export|extern|finally|final'
- r'|foreach_reverse|foreach|for|function|goto|if|import|inout'
- r'|interface|invariant|in|is|lazy|mixin|module|new|nothrow|out'
+ r'|foreach_reverse|foreach|for|function|goto|if|immutable|import'
+ r'|interface|invariant|inout|in|is|lazy|mixin|module|new|nothrow|out'
r'|override|package|pragma|private|protected|public|pure|ref|return'
- r'|scope|static|struct|super|switch|synchronized|template|this'
+ r'|scope|shared|static|struct|super|switch|synchronized|template|this'
r'|throw|try|typedef|typeid|typeof|union|unittest|version|volatile'
- r'|while|with|__traits)\b', Keyword
+ r'|while|with|__gshared|__traits|__vector|__parameters)\b', Keyword
),
(r'(bool|byte|cdouble|cent|cfloat|char|creal|dchar|double|float'
r'|idouble|ifloat|int|ireal|long|real|short|ubyte|ucent|uint|ulong'
r'|ushort|void|wchar)\b', Keyword.Type
),
(r'(false|true|null)\b', Keyword.Constant),
+ (r'(__FILE__|__MODULE__|__LINE__|__FUNCTION__|__PRETTY_FUNCTION__'
+ r'|__DATE__|__EOF__|__TIME__|__TIMESTAMP__|__VENDOR__|__VERSION__)\b',
+ Keyword.Pseudo),
(r'macro\b', Keyword.Reserved),
- (r'(string|wstring|dstring)\b', Name.Builtin),
+ (r'(string|wstring|dstring|size_t|ptrdiff_t)\b', Name.Builtin),
# FloatLiteral
# -- HexFloat
(r'0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)'
@@ -528,6 +531,8 @@ class DLexer(RegexLexer):
(r'q"(.).*?\1"', String),
# -- TokenString
(r'q{', String, 'token_string'),
+ # Attributes
+ (r'@([a-zA-Z_]\w*)?', Name.Decorator),
# Tokens
(r'(~=|\^=|%=|\*=|==|!>=|!<=|!<>=|!<>|!<|!>|!=|>>>=|>>>|>>=|>>|>='
r'|<>=|<>|<<=|<<|<=|\+\+|\+=|--|-=|\|\||\|=|&&|&=|\.\.\.|\.\.|/=)'
@@ -535,6 +540,8 @@ class DLexer(RegexLexer):
),
# Identifier
(r'[a-zA-Z_]\w*', Name),
+ # Line
+ (r'#line\s.*\n', Comment.Special),
],
'nested_comment': [
(r'[^+/]+', Comment.Multiline),
@@ -1434,8 +1441,8 @@ def objective(baselexer):
# discussion in Issue 789
(r',', Punctuation),
(r'\.\.\.', Punctuation),
- (r'(\(.*?\))([a-zA-Z$_][a-zA-Z0-9$_]*)', bygroups(using(this),
- Name.Variable)),
+ (r'(\(.*?\))(\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)',
+ bygroups(using(this), Text, Name.Variable)),
(r'[a-zA-Z$_][a-zA-Z0-9$_]*:', Name.Function),
(';', Punctuation, '#pop'),
('{', Punctuation, 'function'),
diff --git a/pygments/lexers/functional.py b/pygments/lexers/functional.py
index 55ac1937..122114fa 100644
--- a/pygments/lexers/functional.py
+++ b/pygments/lexers/functional.py
@@ -723,7 +723,7 @@ class CommonLispLexer(RegexLexer):
.. versionadded:: 0.9
"""
name = 'Common Lisp'
- aliases = ['common-lisp', 'cl', 'lisp']
+ aliases = ['common-lisp', 'cl', 'lisp', 'elisp', 'emacs']
filenames = ['*.cl', '*.lisp', '*.el'] # use for Elisp too
mimetypes = ['text/x-common-lisp']
diff --git a/pygments/lexers/inferno.py b/pygments/lexers/inferno.py
new file mode 100644
index 00000000..16a7014b
--- /dev/null
+++ b/pygments/lexers/inferno.py
@@ -0,0 +1,99 @@
+# -*- coding: utf-8 -*-
+"""
+ pygments.lexers.inferno
+ ~~~~~~~~~~~~~~~~~~~~~
+
+ Lexers for Inferno os and all the related stuff.
+
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import re
+
+from pygments.lexer import RegexLexer, include, bygroups, using, \
+ this, combined, ExtendedRegexLexer
+from pygments.token import Error, Punctuation, Literal, Token, \
+ Text, Comment, Operator, Keyword, Name, String, Number, Generic, \
+ Whitespace
+from pygments.util import get_bool_opt
+
+__all__ = ['LimboLexer']
+
+
+class LimboLexer(RegexLexer):
+ """
+ Lexer for `Limbo programming language <http://www.vitanuova.com/inferno/limbo.html>`_
+
+ TODO:
+ - maybe implement better var declaration highlighting
+ - some simple syntax error highlighting
+
+ .. versionadded:: 2.0
+ """
+ name = 'Limbo'
+ aliases = ['limbo']
+ filenames = ['*.b']
+ mimetypes = ['text/limbo']
+
+ tokens = {
+ 'whitespace': [
+ (r'^(\s*)([a-zA-Z_][a-zA-Z0-9_]*:(\s*)\n)',
+ bygroups(Text, Name.Label)),
+ (r'\n', Text),
+ (r'\s+', Text),
+ (r'#(\n|(.|\n)*?[^\\]\n)', Comment.Single),
+ ],
+ 'string': [
+ (r'"', String, '#pop'),
+ (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|'
+ r'u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})', String.Escape),
+ (r'[^\\"\n]+', String), # all other characters
+ (r'\\', String), # stray backslash
+ ],
+ 'statements': [
+ (r'"', String, 'string'),
+ (r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
+ (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+', Number.Float),
+ (r'(\d+\.\d*|\.\d+|\d+[fF])', Number.Float),
+ (r'16r[0-9a-fA-F]+', Number.Hex),
+ (r'8r[0-7]+', Number.Oct),
+ (r'((([1-3]\d)|([2-9]))r)?(\d+)', Number.Integer),
+ (r'[()\[\],.]', Punctuation),
+ (r'[~!%^&*+=|?:<>/-]|(->)|(<-)|(=>)|(::)', Operator),
+ (r'(alt|break|case|continue|cyclic|do|else|exit'
+ r'for|hd|if|implement|import|include|len|load|or'
+ r'pick|return|spawn|tagof|tl|to|while)\b', Keyword),
+ (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),
+ ],
+ 'statement' : [
+ include('whitespace'),
+ include('statements'),
+ ('[{}]', Punctuation),
+ (';', Punctuation, '#pop'),
+ ],
+ 'root': [
+ include('whitespace'),
+ ('', Text, 'statement'),
+ ],
+ }
+
+ def analyse_text(text):
+ # Any limbo module implements something
+ if re.search(r'^implement \w+;', text, re.MULTILINE):
+ return 0.7
+
+# TODO:
+# - Make lexers for:
+# - asm sources
+# - man pages
+# - mkfiles
+# - module definitions
+# - namespace definitions
+# - shell scripts
+# - maybe keyfiles and fonts
+# they all seem to be quite similar to their equivalents
+# from unix world, so there should not be a lot of problems
diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py
index 5c535142..4b91e723 100644
--- a/pygments/lexers/jvm.py
+++ b/pygments/lexers/jvm.py
@@ -12,15 +12,16 @@
import re
from pygments.lexer import Lexer, RegexLexer, include, bygroups, using, \
- this
+ this, combined
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
Number, Punctuation
from pygments import unistring as uni
__all__ = ['JavaLexer', 'ScalaLexer', 'GosuLexer', 'GosuTemplateLexer',
- 'GroovyLexer', 'IokeLexer', 'ClojureLexer', 'KotlinLexer',
- 'XtendLexer', 'AspectJLexer', 'CeylonLexer']
+ 'GroovyLexer', 'IokeLexer', 'ClojureLexer', 'ClojureScriptLexer',
+ 'KotlinLexer', 'XtendLexer', 'AspectJLexer', 'CeylonLexer',
+ 'PigLexer', 'GoloLexer']
class JavaLexer(RegexLexer):
@@ -66,7 +67,7 @@ class JavaLexer(RegexLexer):
(r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
- (r'[0-9]+L?', Number.Integer),
+ (r'[0-9]+(_+[0-9]+)*L?', Number.Integer),
(r'\n', Text)
],
'class': [
@@ -813,6 +814,19 @@ class ClojureLexer(RegexLexer):
}
+class ClojureScriptLexer(ClojureLexer):
+ """
+ Lexer for `ClojureScript <http://clojure.org/clojurescript>`_
+ source code.
+
+ .. versionadded:: 2.0
+ """
+ name = 'ClojureScript'
+ aliases = ['clojurescript', 'cljs']
+ filenames = ['*.cljs']
+ mimetypes = ['text/x-clojurescript', 'application/x-clojurescript']
+
+
class TeaLangLexer(RegexLexer):
"""
For `Tea <http://teatrove.org/>`_ source code. Only used within a
@@ -1066,3 +1080,181 @@ class XtendLexer(RegexLexer):
(r'.', String)
],
}
+
+class PigLexer(RegexLexer):
+ """
+ For `Pig Latin <https://pig.apache.org/>`_ source code.
+
+ .. versionadded:: 2.0
+ """
+
+ name = 'Pig'
+ aliases = ['pig']
+ filenames = ['*.pig']
+ mimetypes = ['text/x-pig']
+
+ flags = re.MULTILINE | re.IGNORECASE
+
+ tokens = {
+ 'root': [
+ (r'\s+', Text),
+ (r'--.*', Comment),
+ (r'/\*[\w\W]*?\*/', Comment.Multiline),
+ (r'\\\n', Text),
+ (r'\\', Text),
+ (r'\'(?:\\[ntbrf\\\']|\\u[0-9a-f]{4}|[^\'\\\n\r])*\'', String),
+ include('keywords'),
+ include('types'),
+ include('builtins'),
+ include('punct'),
+ include('operators'),
+ (r'[0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
+ (r'0x[0-9a-f]+', Number.Hex),
+ (r'[0-9]+L?', Number.Integer),
+ (r'\n', Text),
+ (r'([a-z_][a-z0-9_]*)(\s*)(\()',
+ bygroups(Name.Function, Text, Punctuation)),
+ (r'[()#:]', Text),
+ (r'[^(:#\'\")\s]+', Text),
+ (r'\S+\s+', Text) # TODO: make tests pass without \s+
+ ],
+ 'keywords': [
+ (r'(assert|and|any|all|arrange|as|asc|bag|by|cache|CASE|cat|cd|cp|'
+ r'%declare|%default|define|dense|desc|describe|distinct|du|dump|'
+ r'eval|exex|explain|filter|flatten|foreach|full|generate|group|'
+ r'help|if|illustrate|import|inner|input|into|is|join|kill|left|'
+ r'limit|load|ls|map|matches|mkdir|mv|not|null|onschema|or|order|'
+ r'outer|output|parallel|pig|pwd|quit|register|returns|right|rm|'
+ r'rmf|rollup|run|sample|set|ship|split|stderr|stdin|stdout|store|'
+ r'stream|through|union|using|void)\b', Keyword)
+ ],
+ 'builtins': [
+ (r'(AVG|BinStorage|cogroup|CONCAT|copyFromLocal|copyToLocal|COUNT|'
+ r'cross|DIFF|MAX|MIN|PigDump|PigStorage|SIZE|SUM|TextLoader|'
+ r'TOKENIZE)\b', Name.Builtin)
+ ],
+ 'types': [
+ (r'(bytearray|BIGINTEGER|BIGDECIMAL|chararray|datetime|double|float|'
+ r'int|long|tuple)\b', Keyword.Type)
+ ],
+ 'punct': [
+ (r'[;(){}\[\]]', Punctuation),
+ ],
+ 'operators': [
+ (r'[#=,./%+\-?]', Operator),
+ (r'(eq|gt|lt|gte|lte|neq|matches)\b', Operator),
+ (r'(==|<=|<|>=|>|!=)', Operator),
+ ],
+ }
+
+
+class GoloLexer(RegexLexer):
+ """
+ For `Golo <http://golo-lang.org/>`_ source code.
+
+ .. versionadded:: 2.0
+ """
+
+ name = 'Golo'
+ filenames = ['*.golo']
+ aliases = ['golo']
+
+ tokens = {
+ 'root': [
+ (r'[^\S\n]+', Text),
+
+ (r'#.*$', Comment),
+
+ (r'(\^|\.\.\.|:|\?:|->|==|!=|=|\+|\*|%|/|<=|<|>=|>|=|\.)',
+ Operator),
+ (r'(?<=[^-])(-)(?=[^-])', Operator),
+
+ (r'(?<=[^`])(is|isnt|and|or|not|oftype|in|orIfNull)\b', Operator.Word),
+ (r'[]{}|(),[]', Punctuation),
+
+ (r'(module|import)(\s+)',
+ bygroups(Keyword.Namespace, Text),
+ 'modname'),
+ (r'\b([a-zA-Z_][a-z$A-Z0-9._]*)(::)', bygroups(Name.Namespace, Punctuation)),
+ (r'\b([a-zA-Z_][a-z$A-Z0-9_]*(?:\.[a-zA-Z_][a-z$A-Z0-9_]*)+)\b', Name.Namespace),
+
+ (r'(let|var)(\s+)',
+ bygroups(Keyword.Declaration, Text),
+ 'varname'),
+ (r'(struct)(\s+)',
+ bygroups(Keyword.Declaration, Text),
+ 'structname'),
+ (r'(function)(\s+)',
+ bygroups(Keyword.Declaration, Text),
+ 'funcname'),
+
+ (r'(null|true|false)\b', Keyword.Constant),
+ (r'(augment|pimp'
+ r'|if|else|case|match|return'
+ r'|case|when|then|otherwise'
+ r'|while|for|foreach'
+ r'|try|catch|finally|throw'
+ r'|local'
+ r'|continue|break)\b', Keyword),
+
+ (r'(map|array|list|set|vector|tuple)(\[)',
+ bygroups(Name.Builtin, Punctuation)),
+ (r'(print|println|readln|raise|fun'
+ r'|asInterfaceInstance)\b', Name.Builtin),
+ (r'(`?[a-zA-Z_][a-z$A-Z0-9_]*)(\()',
+ bygroups(Name.Function, Punctuation)),
+
+ (r'-?[\d_]*\.[\d_]*([eE][+-]?\d[\d_]*)?F?', Number.Float),
+ (r'0[0-7]+j?', Number.Oct),
+ (r'0[xX][a-fA-F0-9]+', Number.Hex),
+ (r'-?\d[\d_]*L', Number.Integer.Long),
+ (r'-?\d[\d_]*', Number.Integer),
+
+ ('`?[a-zA-Z_][a-z$A-Z0-9_]*', Name),
+
+ (r'"""', String, combined('stringescape', 'triplestring')),
+ (r'"', String, combined('stringescape', 'doublestring')),
+ (r"'", String, combined('stringescape', 'singlestring')),
+ (r'----((.|\n)*?)----', String.Doc)
+
+ ],
+
+ 'funcname': [
+ (r'`?[a-zA-Z_][a-z$A-Z0-9_]*', Name.Function, '#pop'),
+ ],
+ 'modname': [
+ (r'[a-zA-Z_][a-z$A-Z0-9._]*\*?', Name.Namespace, '#pop')
+ ],
+ 'structname': [
+ (r'`?[a-zA-Z0-9_.]+\*?', Name.Class, '#pop')
+ ],
+ 'varname': [
+ (r'`?[a-zA-Z_][a-z$A-Z0-9_]*', Name.Variable, '#pop'),
+ ],
+ 'string': [
+ (r'[^\\\'"\n]+', String),
+ (r'[\'"\\]', String)
+ ],
+ 'stringescape': [
+ (r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|'
+ r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
+ ],
+ 'triplestring': [
+ (r'"""', String, '#pop'),
+ include('string'),
+ (r'\n', String),
+ ],
+ 'doublestring': [
+ (r'"', String.Double, '#pop'),
+ include('string'),
+ ],
+ 'singlestring': [
+ (r"'", String, '#pop'),
+ include('string'),
+ ],
+ 'operators': [
+ (r'[#=,./%+\-?]', Operator),
+ (r'(eq|gt|lt|gte|lte|neq|matches)\b', Operator),
+ (r'(==|<=|<|>=|>|!=)', Operator),
+ ],
+ }
diff --git a/pygments/lexers/math.py b/pygments/lexers/math.py
index 1bce106c..c587ca93 100644
--- a/pygments/lexers/math.py
+++ b/pygments/lexers/math.py
@@ -26,7 +26,7 @@ from pygments.lexers import _stan_builtins
__all__ = ['JuliaLexer', 'JuliaConsoleLexer', 'MuPADLexer', 'MatlabLexer',
'MatlabSessionLexer', 'OctaveLexer', 'ScilabLexer', 'NumPyLexer',
'RConsoleLexer', 'SLexer', 'JagsLexer', 'BugsLexer', 'StanLexer',
- 'IDLLexer', 'RdLexer', 'IgorLexer', 'MathematicaLexer']
+ 'IDLLexer', 'RdLexer', 'IgorLexer', 'MathematicaLexer', 'GAPLexer']
class JuliaLexer(RegexLexer):
@@ -1047,10 +1047,261 @@ class SLexer(RegexLexer):
name = 'S'
aliases = ['splus', 's', 'r']
- filenames = ['*.S', '*.R', '.Rhistory', '.Rprofile']
+ filenames = ['*.S', '*.R', '.Rhistory', '.Rprofile', '.Renviron']
mimetypes = ['text/S-plus', 'text/S', 'text/x-r-source', 'text/x-r',
'text/x-R', 'text/x-r-history', 'text/x-r-profile']
+ builtins_base = [
+ 'Arg', 'Conj', 'Cstack_info', 'Encoding', 'FALSE',
+ 'Filter', 'Find', 'I', 'ISOdate', 'ISOdatetime', 'Im', 'Inf',
+ 'La\.svd', 'Map', 'Math\.Date', 'Math\.POSIXt', 'Math\.data\.frame',
+ 'Math\.difftime', 'Math\.factor', 'Mod', 'NA_character_',
+ 'NA_complex_', 'NA_real_', 'NCOL', 'NROW', 'NULLNA_integer_', 'NaN',
+ 'Negate', 'NextMethod', 'Ops\.Date', 'Ops\.POSIXt', 'Ops\.data\.frame',
+ 'Ops\.difftime', 'Ops\.factor', 'Ops\.numeric_version', 'Ops\.ordered',
+ 'Position', 'R\.Version', 'R\.home', 'R\.version', 'R\.version\.string',
+ 'RNGkind', 'RNGversion', 'R_system_version', 'Re', 'Recall',
+ 'Reduce', 'Summary\.Date', 'Summary\.POSIXct', 'Summary\.POSIXlt',
+ 'Summary\.data\.frame', 'Summary\.difftime', 'Summary\.factor',
+ 'Summary\.numeric_version', 'Summary\.ordered', 'Sys\.Date',
+ 'Sys\.chmod', 'Sys\.getenv', 'Sys\.getlocale', 'Sys\.getpid',
+ 'Sys\.glob', 'Sys\.info', 'Sys\.localeconv', 'Sys\.readlink',
+ 'Sys\.setFileTime', 'Sys\.setenv', 'Sys\.setlocale', 'Sys\.sleep',
+ 'Sys\.time', 'Sys\.timezone', 'Sys\.umask', 'Sys\.unsetenv',
+ 'Sys\.which', 'TRUE', 'UseMethod', 'Vectorize', 'abbreviate', 'abs',
+ 'acos', 'acosh', 'addNA', 'addTaskCallback', 'agrep', 'alist',
+ 'all', 'all\.equal', 'all\.equal\.POSIXct', 'all\.equal\.character',
+ 'all\.equal\.default', 'all\.equal\.factor', 'all\.equal\.formula',
+ 'all\.equal\.language', 'all\.equal\.list', 'all\.equal\.numeric',
+ 'all\.equal\.raw', 'all\.names', 'all\.vars', 'any', 'anyDuplicated',
+ 'anyDuplicated\.array', 'anyDuplicated\.data\.frame',
+ 'anyDuplicated\.default', 'anyDuplicated\.matrix', 'aperm',
+ 'aperm\.default', 'aperm\.table', 'append', 'apply', 'args',
+ 'arrayInd', 'as\.Date', 'as\.Date\.POSIXct', 'as\.Date\.POSIXlt',
+ 'as\.Date\.character', 'as\.Date\.date', 'as\.Date\.dates',
+ 'as\.Date\.default', 'as\.Date\.factor', 'as\.Date\.numeric',
+ 'as\.POSIXct', 'as\.POSIXct\.Date', 'as\.POSIXct\.POSIXlt',
+ 'as\.POSIXct\.date', 'as\.POSIXct\.dates', 'as\.POSIXct\.default',
+ 'as\.POSIXct\.numeric', 'as\.POSIXlt', 'as\.POSIXlt\.Date',
+ 'as\.POSIXlt\.POSIXct', 'as\.POSIXlt\.character', 'as\.POSIXlt\.date',
+ 'as\.POSIXlt\.dates', 'as\.POSIXlt\.default', 'as\.POSIXlt\.factor',
+ 'as\.POSIXlt\.numeric', 'as\.array', 'as\.array\.default', 'as\.call',
+ 'as\.character', 'as\.character\.Date', 'as\.character\.POSIXt',
+ 'as\.character\.condition', 'as\.character\.default',
+ 'as\.character\.error', 'as\.character\.factor', 'as\.character\.hexmode',
+ 'as\.character\.numeric_version', 'as\.character\.octmode',
+ 'as\.character\.srcref', 'as\.complex', 'as\.data\.frame',
+ 'as\.data\.frame\.AsIs', 'as\.data\.frame\.Date', 'as\.data\.frame\.POSIXct',
+ 'as\.data\.frame\.POSIXlt', 'as\.data\.frame\.array',
+ 'as\.data\.frame\.character', 'as\.data\.frame\.complex',
+ 'as\.data\.frame\.data\.frame', 'as\.data\.frame\.default',
+ 'as\.data\.frame\.difftime', 'as\.data\.frame\.factor',
+ 'as\.data\.frame\.integer', 'as\.data\.frame\.list',
+ 'as\.data\.frame\.logical', 'as\.data\.frame\.matrix',
+ 'as\.data\.frame\.model\.matrix', 'as\.data\.frame\.numeric',
+ 'as\.data\.frame\.numeric_version', 'as\.data\.frame\.ordered',
+ 'as\.data\.frame\.raw', 'as\.data\.frame\.table', 'as\.data\.frame\.ts',
+ 'as\.data\.frame\.vector', 'as\.difftime', 'as\.double',
+ 'as\.double\.POSIXlt', 'as\.double\.difftime', 'as\.environment',
+ 'as\.expression', 'as\.expression\.default', 'as\.factor',
+ 'as\.function', 'as\.function\.default', 'as\.hexmode', 'as\.integer',
+ 'as\.list', 'as\.list\.Date', 'as\.list\.POSIXct', 'as\.list\.data\.frame',
+ 'as\.list\.default', 'as\.list\.environment', 'as\.list\.factor',
+ 'as\.list\.function', 'as\.list\.numeric_version', 'as\.logical',
+ 'as\.logical\.factor', 'as\.matrix', 'as\.matrix\.POSIXlt',
+ 'as\.matrix\.data\.frame', 'as\.matrix\.default', 'as\.matrix\.noquote',
+ 'as\.name', 'as\.null', 'as\.null\.default', 'as\.numeric',
+ 'as\.numeric_version', 'as\.octmode', 'as\.ordered',
+ 'as\.package_version', 'as\.pairlist', 'as\.qr', 'as\.raw', 'as\.single',
+ 'as\.single\.default', 'as\.symbol', 'as\.table', 'as\.table\.default',
+ 'as\.vector', 'as\.vector\.factor', 'asNamespace', 'asS3', 'asS4',
+ 'asin', 'asinh', 'assign', 'atan', 'atan2', 'atanh',
+ 'attachNamespace', 'attr', 'attr\.all\.equal', 'attributes',
+ 'autoload', 'autoloader', 'backsolve', 'baseenv', 'basename',
+ 'besselI', 'besselJ', 'besselK', 'besselY', 'beta',
+ 'bindingIsActive', 'bindingIsLocked', 'bindtextdomain', 'bitwAnd',
+ 'bitwNot', 'bitwOr', 'bitwShiftL', 'bitwShiftR', 'bitwXor', 'body',
+ 'bquote', 'browser', 'browserCondition', 'browserSetDebug',
+ 'browserText', 'builtins', 'by', 'by\.data\.frame', 'by\.default',
+ 'bzfile', 'c\.Date', 'c\.POSIXct', 'c\.POSIXlt', 'c\.noquote',
+ 'c\.numeric_version', 'call', 'callCC', 'capabilities', 'casefold',
+ 'cat', 'category', 'cbind', 'cbind\.data\.frame', 'ceiling',
+ 'char\.expand', 'charToRaw', 'charmatch', 'chartr', 'check_tzones',
+ 'chol', 'chol\.default', 'chol2inv', 'choose', 'class',
+ 'clearPushBack', 'close', 'close\.connection', 'close\.srcfile',
+ 'close\.srcfilealias', 'closeAllConnections', 'col', 'colMeans',
+ 'colSums', 'colnames', 'commandArgs', 'comment', 'computeRestarts',
+ 'conditionCall', 'conditionCall\.condition', 'conditionMessage',
+ 'conditionMessage\.condition', 'conflicts', 'contributors', 'cos',
+ 'cosh', 'crossprod', 'cummax', 'cummin', 'cumprod', 'cumsum', 'cut',
+ 'cut\.Date', 'cut\.POSIXt', 'cut\.default', 'dQuote', 'data\.class',
+ 'data\.matrix', 'date', 'debug', 'debugonce',
+ 'default\.stringsAsFactors', 'delayedAssign', 'deparse', 'det',
+ 'determinant', 'determinant\.matrix', 'dget', 'diag', 'diff',
+ 'diff\.Date', 'diff\.POSIXt', 'diff\.default', 'difftime', 'digamma',
+ 'dim', 'dim\.data\.frame', 'dimnames', 'dimnames\.data\.frame', 'dir',
+ 'dir\.create', 'dirname', 'do\.call', 'dput', 'drop', 'droplevels',
+ 'droplevels\.data\.frame', 'droplevels\.factor', 'dump', 'duplicated',
+ 'duplicated\.POSIXlt', 'duplicated\.array', 'duplicated\.data\.frame',
+ 'duplicated\.default', 'duplicated\.matrix',
+ 'duplicated\.numeric_version', 'dyn\.load', 'dyn\.unload', 'eapply',
+ 'eigen', 'else', 'emptyenv', 'enc2native', 'enc2utf8',
+ 'encodeString', 'enquote', 'env\.profile', 'environment',
+ 'environmentIsLocked', 'environmentName', 'eval', 'eval\.parent',
+ 'evalq', 'exists', 'exp', 'expand\.grid', 'expm1', 'expression',
+ 'factor', 'factorial', 'fifo', 'file', 'file\.access', 'file\.append',
+ 'file\.choose', 'file\.copy', 'file\.create', 'file\.exists',
+ 'file\.info', 'file\.link', 'file\.path', 'file\.remove', 'file\.rename',
+ 'file\.show', 'file\.symlink', 'find\.package', 'findInterval',
+ 'findPackageEnv', 'findRestart', 'floor', 'flush',
+ 'flush\.connection', 'force', 'formals', 'format',
+ 'format\.AsIs', 'format\.Date', 'format\.POSIXct', 'format\.POSIXlt',
+ 'format\.data\.frame', 'format\.default', 'format\.difftime',
+ 'format\.factor', 'format\.hexmode', 'format\.info',
+ 'format\.libraryIQR', 'format\.numeric_version', 'format\.octmode',
+ 'format\.packageInfo', 'format\.pval', 'format\.summaryDefault',
+ 'formatC', 'formatDL', 'forwardsolve', 'gamma', 'gc', 'gc\.time',
+ 'gcinfo', 'gctorture', 'gctorture2', 'get', 'getAllConnections',
+ 'getCallingDLL', 'getCallingDLLe', 'getConnection',
+ 'getDLLRegisteredRoutines', 'getDLLRegisteredRoutines\.DLLInfo',
+ 'getDLLRegisteredRoutines\.character', 'getElement',
+ 'getExportedValue', 'getHook', 'getLoadedDLLs', 'getNamespace',
+ 'getNamespaceExports', 'getNamespaceImports', 'getNamespaceInfo',
+ 'getNamespaceName', 'getNamespaceUsers', 'getNamespaceVersion',
+ 'getNativeSymbolInfo', 'getOption', 'getRversion', 'getSrcLines',
+ 'getTaskCallbackNames', 'geterrmessage', 'gettext', 'gettextf',
+ 'getwd', 'gl', 'globalenv', 'gregexpr', 'grep', 'grepRaw', 'grepl',
+ 'gsub', 'gzcon', 'gzfile', 'head', 'iconv', 'iconvlist',
+ 'icuSetCollate', 'identical', 'identity', 'ifelse', 'importIntoEnv',
+ 'in', 'inherits', 'intToBits', 'intToUtf8', 'interaction', 'interactive',
+ 'intersect', 'inverse\.rle', 'invisible', 'invokeRestart',
+ 'invokeRestartInteractively', 'is\.R', 'is\.array', 'is\.atomic',
+ 'is\.call', 'is\.character', 'is\.complex', 'is\.data\.frame',
+ 'is\.double', 'is\.element', 'is\.environment', 'is\.expression',
+ 'is\.factor', 'is\.finite', 'is\.function', 'is\.infinite',
+ 'is\.integer', 'is\.language', 'is\.list', 'is\.loaded', 'is\.logical',
+ 'is\.matrix', 'is\.na', 'is\.na\.POSIXlt', 'is\.na\.data\.frame',
+ 'is\.na\.numeric_version', 'is\.name', 'is\.nan', 'is\.null',
+ 'is\.numeric', 'is\.numeric\.Date', 'is\.numeric\.POSIXt',
+ 'is\.numeric\.difftime', 'is\.numeric_version', 'is\.object',
+ 'is\.ordered', 'is\.package_version', 'is\.pairlist', 'is\.primitive',
+ 'is\.qr', 'is\.raw', 'is\.recursive', 'is\.single', 'is\.symbol',
+ 'is\.table', 'is\.unsorted', 'is\.vector', 'isBaseNamespace',
+ 'isIncomplete', 'isNamespace', 'isOpen', 'isRestart', 'isS4',
+ 'isSeekable', 'isSymmetric', 'isSymmetric\.matrix', 'isTRUE',
+ 'isatty', 'isdebugged', 'jitter', 'julian', 'julian\.Date',
+ 'julian\.POSIXt', 'kappa', 'kappa\.default', 'kappa\.lm', 'kappa\.qr',
+ 'kronecker', 'l10n_info', 'labels', 'labels\.default', 'lapply',
+ 'lazyLoad', 'lazyLoadDBexec', 'lazyLoadDBfetch', 'lbeta', 'lchoose',
+ 'length', 'length\.POSIXlt', 'letters', 'levels', 'levels\.default',
+ 'lfactorial', 'lgamma', 'library\.dynam', 'library\.dynam\.unload',
+ 'licence', 'license', 'list\.dirs', 'list\.files', 'list2env', 'load',
+ 'loadNamespace', 'loadedNamespaces', 'loadingNamespaceInfo',
+ 'local', 'lockBinding', 'lockEnvironment', 'log', 'log10', 'log1p',
+ 'log2', 'logb', 'lower\.tri', 'ls', 'make\.names', 'make\.unique',
+ 'makeActiveBinding', 'mapply', 'margin\.table', 'mat\.or\.vec',
+ 'match', 'match\.arg', 'match\.call', 'match\.fun', 'max', 'max\.col',
+ 'mean', 'mean\.Date', 'mean\.POSIXct', 'mean\.POSIXlt', 'mean\.default',
+ 'mean\.difftime', 'mem\.limits', 'memCompress', 'memDecompress',
+ 'memory\.profile', 'merge', 'merge\.data\.frame', 'merge\.default',
+ 'message', 'mget', 'min', 'missing', 'mode', 'month\.abb',
+ 'month\.name', 'months', 'months\.Date', 'months\.POSIXt',
+ 'months\.abb', 'months\.nameletters', 'names', 'names\.POSIXlt',
+ 'namespaceExport', 'namespaceImport', 'namespaceImportClasses',
+ 'namespaceImportFrom', 'namespaceImportMethods', 'nargs', 'nchar',
+ 'ncol', 'new\.env', 'ngettext', 'nlevels', 'noquote', 'norm',
+ 'normalizePath', 'nrow', 'numeric_version', 'nzchar', 'objects',
+ 'oldClass', 'on\.exit', 'open', 'open\.connection', 'open\.srcfile',
+ 'open\.srcfilealias', 'open\.srcfilecopy', 'options', 'order',
+ 'ordered', 'outer', 'packBits', 'packageEvent',
+ 'packageHasNamespace', 'packageStartupMessage', 'package_version',
+ 'pairlist', 'parent\.env', 'parent\.frame', 'parse',
+ 'parseNamespaceFile', 'paste', 'paste0', 'path\.expand',
+ 'path\.package', 'pipe', 'pmatch', 'pmax', 'pmax\.int', 'pmin',
+ 'pmin\.int', 'polyroot', 'pos\.to\.env', 'pretty', 'pretty\.default',
+ 'prettyNum', 'print', 'print\.AsIs', 'print\.DLLInfo',
+ 'print\.DLLInfoList', 'print\.DLLRegisteredRoutines', 'print\.Date',
+ 'print\.NativeRoutineList', 'print\.POSIXct', 'print\.POSIXlt',
+ 'print\.by', 'print\.condition', 'print\.connection',
+ 'print\.data\.frame', 'print\.default', 'print\.difftime',
+ 'print\.factor', 'print\.function', 'print\.hexmode',
+ 'print\.libraryIQR', 'print\.listof', 'print\.noquote',
+ 'print\.numeric_version', 'print\.octmode', 'print\.packageInfo',
+ 'print\.proc_time', 'print\.restart', 'print\.rle',
+ 'print\.simple\.list', 'print\.srcfile', 'print\.srcref',
+ 'print\.summary\.table', 'print\.summaryDefault', 'print\.table',
+ 'print\.warnings', 'prmatrix', 'proc\.time', 'prod', 'prop\.table',
+ 'provideDimnames', 'psigamma', 'pushBack', 'pushBackLength', 'q',
+ 'qr', 'qr\.Q', 'qr\.R', 'qr\.X', 'qr\.coef', 'qr\.default', 'qr\.fitted',
+ 'qr\.qty', 'qr\.qy', 'qr\.resid', 'qr\.solve', 'quarters',
+ 'quarters\.Date', 'quarters\.POSIXt', 'quit', 'quote', 'range',
+ 'range\.default', 'rank', 'rapply', 'raw', 'rawConnection',
+ 'rawConnectionValue', 'rawShift', 'rawToBits', 'rawToChar', 'rbind',
+ 'rbind\.data\.frame', 'rcond', 'read\.dcf', 'readBin', 'readChar',
+ 'readLines', 'readRDS', 'readRenviron', 'readline', 'reg\.finalizer',
+ 'regexec', 'regexpr', 'registerS3method', 'registerS3methods',
+ 'regmatches', 'remove', 'removeTaskCallback', 'rep', 'rep\.Date',
+ 'rep\.POSIXct', 'rep\.POSIXlt', 'rep\.factor', 'rep\.int',
+ 'rep\.numeric_version', 'rep_len', 'replace', 'replicate',
+ 'requireNamespace', 'restartDescription', 'restartFormals',
+ 'retracemem', 'rev', 'rev\.default', 'rle', 'rm', 'round',
+ 'round\.Date', 'round\.POSIXt', 'row', 'row\.names',
+ 'row\.names\.data\.frame', 'row\.names\.default', 'rowMeans', 'rowSums',
+ 'rownames', 'rowsum', 'rowsum\.data\.frame', 'rowsum\.default',
+ 'sQuote', 'sample', 'sample\.int', 'sapply', 'save', 'save\.image',
+ 'saveRDS', 'scale', 'scale\.default', 'scan', 'search',
+ 'searchpaths', 'seek', 'seek\.connection', 'seq', 'seq\.Date',
+ 'seq\.POSIXt', 'seq\.default', 'seq\.int', 'seq_along', 'seq_len',
+ 'sequence', 'serialize', 'set\.seed', 'setHook', 'setNamespaceInfo',
+ 'setSessionTimeLimit', 'setTimeLimit', 'setdiff', 'setequal',
+ 'setwd', 'shQuote', 'showConnections', 'sign', 'signalCondition',
+ 'signif', 'simpleCondition', 'simpleError', 'simpleMessage',
+ 'simpleWarning', 'simplify2array', 'sin', 'single',
+ 'sinh', 'sink', 'sink\.number', 'slice\.index', 'socketConnection',
+ 'socketSelect', 'solve', 'solve\.default', 'solve\.qr', 'sort',
+ 'sort\.POSIXlt', 'sort\.default', 'sort\.int', 'sort\.list', 'split',
+ 'split\.Date', 'split\.POSIXct', 'split\.data\.frame', 'split\.default',
+ 'sprintf', 'sqrt', 'srcfile', 'srcfilealias', 'srcfilecopy',
+ 'srcref', 'standardGeneric', 'stderr', 'stdin', 'stdout', 'stop',
+ 'stopifnot', 'storage\.mode', 'strftime', 'strptime', 'strsplit',
+ 'strtoi', 'strtrim', 'structure', 'strwrap', 'sub', 'subset',
+ 'subset\.data\.frame', 'subset\.default', 'subset\.matrix',
+ 'substitute', 'substr', 'substring', 'sum', 'summary',
+ 'summary\.Date', 'summary\.POSIXct', 'summary\.POSIXlt',
+ 'summary\.connection', 'summary\.data\.frame', 'summary\.default',
+ 'summary\.factor', 'summary\.matrix', 'summary\.proc_time',
+ 'summary\.srcfile', 'summary\.srcref', 'summary\.table',
+ 'suppressMessages', 'suppressPackageStartupMessages',
+ 'suppressWarnings', 'svd', 'sweep', 'sys\.call', 'sys\.calls',
+ 'sys\.frame', 'sys\.frames', 'sys\.function', 'sys\.load\.image',
+ 'sys\.nframe', 'sys\.on\.exit', 'sys\.parent', 'sys\.parents',
+ 'sys\.save\.image', 'sys\.source', 'sys\.status', 'system',
+ 'system\.file', 'system\.time', 'system2', 't', 't\.data\.frame',
+ 't\.default', 'table', 'tabulate', 'tail', 'tan', 'tanh', 'tapply',
+ 'taskCallbackManager', 'tcrossprod', 'tempdir', 'tempfile',
+ 'testPlatformEquivalence', 'textConnection', 'textConnectionValue',
+ 'toString', 'toString\.default', 'tolower', 'topenv', 'toupper',
+ 'trace', 'traceback', 'tracemem', 'tracingState', 'transform',
+ 'transform\.data\.frame', 'transform\.default', 'trigamma', 'trunc',
+ 'trunc\.Date', 'trunc\.POSIXt', 'truncate', 'truncate\.connection',
+ 'try', 'tryCatch', 'typeof', 'unclass', 'undebug', 'union',
+ 'unique', 'unique\.POSIXlt', 'unique\.array', 'unique\.data\.frame',
+ 'unique\.default', 'unique\.matrix', 'unique\.numeric_version',
+ 'units', 'units\.difftime', 'unix\.time', 'unlink', 'unlist',
+ 'unloadNamespace', 'unlockBinding', 'unname', 'unserialize',
+ 'unsplit', 'untrace', 'untracemem', 'unz', 'upper\.tri', 'url',
+ 'utf8ToInt', 'vapply', 'version', 'warning', 'warnings', 'weekdays',
+ 'weekdays\.Date', 'weekdays\.POSIXt', 'which', 'which\.max',
+ 'which\.min', 'with', 'with\.default', 'withCallingHandlers',
+ 'withRestarts', 'withVisible', 'within', 'within\.data\.frame',
+ 'within\.list', 'write', 'write\.dcf', 'writeBin', 'writeChar',
+ 'writeLines', 'xor', 'xor\.hexmode', 'xor\.octmode',
+ 'xpdrows\.data\.frame', 'xtfrm', 'xtfrm\.AsIs', 'xtfrm\.Date',
+ 'xtfrm\.POSIXct', 'xtfrm\.POSIXlt', 'xtfrm\.Surv', 'xtfrm\.default',
+ 'xtfrm\.difftime', 'xtfrm\.factor', 'xtfrm\.numeric_version', 'xzfile',
+ 'zapsmall'
+ ]
+
tokens = {
'comments': [
(r'#.*$', Comment.Single),
@@ -1064,9 +1315,19 @@ class SLexer(RegexLexer):
(r'\[{1,2}|\]{1,2}|\(|\)|;|,', Punctuation),
],
'keywords': [
+ (r'(' + r'|'.join(builtins_base) + r')'
+ r'(?![\w\. =])',
+ Keyword.Pseudo),
(r'(if|else|for|while|repeat|in|next|break|return|switch|function)'
- r'(?![0-9a-zA-Z\._])',
- Keyword.Reserved)
+ r'(?![\w\.])',
+ Keyword.Reserved),
+ (r'(array|category|character|complex|double|function|integer|list|'
+ r'logical|matrix|numeric|vector|data.frame|c)'
+ r'(?![\w\.])',
+ Keyword.Type),
+ (r'(library|require|attach|detach|source)'
+ r'(?![\w\.])',
+ Keyword.Namespace)
],
'operators': [
(r'<<?-|->>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|\?', Operator),
@@ -1074,16 +1335,16 @@ class SLexer(RegexLexer):
],
'builtin_symbols': [
(r'(NULL|NA(_(integer|real|complex|character)_)?|'
- r'Inf|TRUE|FALSE|NaN|\.\.(\.|[0-9]+))'
+ r'letters|LETTERS|Inf|TRUE|FALSE|NaN|pi|\.\.(\.|[0-9]+))'
r'(?![0-9a-zA-Z\._])',
Keyword.Constant),
- (r'(T|F)\b', Keyword.Variable),
+ (r'(T|F)\b', Name.Builtin.Pseudo),
],
'numbers': [
# hex number
(r'0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?', Number.Hex),
# decimal number
- (r'[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?[Li]?',
+ (r'[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+|\.)([eE][+-]?[0-9]+)?[Li]?',
Number),
],
'statements': [
@@ -1972,3 +2233,53 @@ class MathematicaLexer(RegexLexer):
(r'\s+', Text.Whitespace),
],
}
+
+class GAPLexer(RegexLexer):
+ """
+ For `GAP <http://www.gap-system.org>`_ source code.
+
+ .. versionadded:: 2.0
+ """
+ name = 'GAP'
+ aliases = ['gap']
+ filenames = ['*.g', '*.gd', '*.gi', '*.gap']
+
+ tokens = {
+ 'root' : [
+ (r'#.*$', Comment.Single),
+ (r'"(?:[^"\\]|\\.)*"', String),
+ (r'\(|\)|\[|\]|\{|\}', Punctuation),
+ (r'''(?x)\b(?:
+ if|then|elif|else|fi|
+ for|while|do|od|
+ repeat|until|
+ break|continue|
+ function|local|return|end|
+ rec|
+ quit|QUIT|
+ IsBound|Unbind|
+ TryNextMethod|
+ Info|Assert
+ )\b''', Keyword),
+ (r'''(?x)\b(?:
+ true|false|fail|infinity
+ )\b''',
+ Name.Constant),
+ (r'''(?x)\b(?:
+ (Declare|Install)([A-Z][A-Za-z]+)|
+ BindGlobal|BIND_GLOBAL
+ )\b''',
+ Name.Builtin),
+ (r'\.|,|:=|;|=|\+|-|\*|/|\^|>|<', Operator),
+ (r'''(?x)\b(?:
+ and|or|not|mod|in
+ )\b''',
+ Operator.Word),
+ (r'''(?x)
+ (?:[a-zA-Z_0-9]+|`[^`]*`)
+ (?:::[a-zA-Z_0-9]+|`[^`]*`)*''', Name.Variable),
+ (r'[0-9]+(?:\.[0-9]*)?(?:e[0-9]+)?', Number),
+ (r'\.[0-9]+(?:e[0-9]+)?', Number),
+ (r'.', Text)
+ ]
+ }
diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py
index d9e7440a..ddfe645c 100644
--- a/pygments/lexers/other.py
+++ b/pygments/lexers/other.py
@@ -36,7 +36,90 @@ __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer',
'ECLLexer', 'UrbiscriptLexer', 'OpenEdgeLexer', 'BroLexer',
'MscgenLexer', 'KconfigLexer', 'VGLLexer', 'SourcePawnLexer',
'RobotFrameworkLexer', 'PuppetLexer', 'NSISLexer', 'RPMSpecLexer',
- 'CbmBasicV2Lexer', 'AutoItLexer', 'RexxLexer']
+ 'CbmBasicV2Lexer', 'AutoItLexer', 'RexxLexer', 'APLLexer',
+ 'LSLLexer', 'AmbientTalkLexer', 'PawnLexer', 'VCTreeStatusLexer']
+
+
+class LSLLexer(RegexLexer):
+ """
+ For Second Life's Linden Scripting Language source code.
+ """
+
+ name = 'LSL'
+ aliases = ['lsl']
+ filenames = ['*.lsl']
+ mimetypes = ['text/x-lsl']
+
+ flags = re.MULTILINE
+
+ lsl_keywords = r'\b(?:do|else|for|if|jump|return|while)\b'
+ lsl_types = r'\b(?:float|integer|key|list|quaternion|rotation|string|vector)\b'
+ lsl_states = r'\b(?:(?:state)\s+\w+|default)\b'
+ lsl_events = r'\b(?:state_(?:entry|exit)|touch(?:_(?:start|end))?|(?:land_)?collision(?:_(?:start|end))?|timer|listen|(?:no_)?sensor|control|(?:not_)?at_(?:rot_)?target|money|email|run_time_permissions|changed|attach|dataserver|moving_(?:start|end)|link_message|(?:on|object)_rez|remote_data|http_re(?:sponse|quest)|path_update|transaction_result)\b'
+ lsl_functions_builtin = r'\b(?:ll(?:ReturnObjectsBy(?:ID|Owner)|Json(?:2List|[GS]etValue|ValueType)|Sin|Cos|Tan|Atan2|Sqrt|Pow|Abs|Fabs|Frand|Floor|Ceil|Round|Vec(?:Mag|Norm|Dist)|Rot(?:Between|2(?:Euler|Fwd|Left|Up))|(?:Euler|Axes)2Rot|Whisper|(?:Region|Owner)?Say|Shout|Listen(?:Control|Remove)?|Sensor(?:Repeat|Remove)?|Detected(?:Name|Key|Owner|Type|Pos|Vel|Grab|Rot|Group|LinkNumber)|Die|Ground|Wind|(?:[GS]et)(?:AnimationOverride|MemoryLimit|PrimMediaParams|ParcelMusicURL|Object(?:Desc|Name)|PhysicsMaterial|Status|Scale|Color|Alpha|Texture|Pos|Rot|Force|Torque)|ResetAnimationOverride|(?:Scale|Offset|Rotate)Texture|(?:Rot)?Target(?:Remove)?|(?:Stop)?MoveToTarget|Apply(?:Rotational)?Impulse|Set(?:KeyframedMotion|ContentType|RegionPos|(?:Angular)?Velocity|Buoyancy|HoverHeight|ForceAndTorque|TimerEvent|ScriptState|Damage|TextureAnim|Sound(?:Queueing|Radius)|Vehicle(?:Type|(?:Float|Vector|Rotation)Param)|(?:Touch|Sit)?Text|Camera(?:Eye|At)Offset|PrimitiveParams|ClickAction|Link(?:Alpha|Color|PrimitiveParams(?:Fast)?|Texture(?:Anim)?|Camera|Media)|RemoteScriptAccessPin|PayPrice|LocalRot)|ScaleByFactor|Get(?:(?:Max|Min)ScaleFactor|ClosestNavPoint|StaticPath|SimStats|Env|PrimitiveParams|Link(?:PrimitiveParams|Number(?:OfSides)?|Key|Name|Media)|HTTPHeader|FreeURLs|Object(?:Details|PermMask|PrimCount)|Parcel(?:MaxPrims|Details|Prim(?:Count|Owners))|Attached|(?:SPMax|Free|Used)Memory|Region(?:Name|TimeDilation|FPS|Corner|AgentCount)|Root(?:Position|Rotation)|UnixTime|(?:Parcel|Region)Flags|(?:Wall|GMT)clock|SimulatorHostname|BoundingBox|GeometricCenter|Creator|NumberOf(?:Prims|NotecardLines|Sides)|Animation(?:List)?|(?:Camera|Local)(?:Pos|Rot)|Vel|Accel|Omega|Time(?:stamp|OfDay)|(?:Object|CenterOf)?Mass|MassMKS|Energy|Owner|(?:Owner)?Key|SunDirection|Texture(?:Offset|Scale|Rot)|Inventory(?:Number|Name|Key|Type|Creator|PermMask)|Permissions(?:Key)?|StartParameter|List(?:Length|EntryType)|Date|Agent(?:Size|Info|Language|List)|LandOwnerAt|NotecardLine|Script(?:Name|State))|(?:Get|Reset|GetAndReset)Time|PlaySound(?:Slave)?|LoopSound(?:Master|Slave)?|(?:Trigger|Stop|Preload)Sound|(?:(?:Get|Delete)Sub|Insert)String|To(?:Upper|Lower)|Give(?:InventoryList|Money)|RezObject|(?:Stop)?LookAt|Sleep|CollisionFilter|(?:Take|Release)Controls|DetachFromAvatar|AttachToAvatar(?:Temp)?|InstantMessage|(?:GetNext)?Email|StopHover|MinEventDelay|RotLookAt|String(?:Length|Trim)|(?:Start|Stop)Animation|TargetOmega|RequestPermissions|(?:Create|Break)Link|BreakAllLinks|(?:Give|Remove)Inventory|Water|PassTouches|Request(?:Agent|Inventory)Data|TeleportAgent(?:Home|GlobalCoords)?|ModifyLand|CollisionSound|ResetScript|MessageLinked|PushObject|PassCollisions|AxisAngle2Rot|Rot2(?:Axis|Angle)|A(?:cos|sin)|AngleBetween|AllowInventoryDrop|SubStringIndex|List2(?:CSV|Integer|Json|Float|String|Key|Vector|Rot|List(?:Strided)?)|DeleteSubList|List(?:Statistics|Sort|Randomize|(?:Insert|Find|Replace)List)|EdgeOfWorld|AdjustSoundVolume|Key2Name|TriggerSoundLimited|EjectFromLand|(?:CSV|ParseString)2List|OverMyLand|SameGroup|UnSit|Ground(?:Slope|Normal|Contour)|GroundRepel|(?:Set|Remove)VehicleFlags|(?:AvatarOn)?(?:Link)?SitTarget|Script(?:Danger|Profiler)|Dialog|VolumeDetect|ResetOtherScript|RemoteLoadScriptPin|(?:Open|Close)RemoteDataChannel|SendRemoteData|RemoteDataReply|(?:Integer|String)ToBase64|XorBase64|Log(?:10)?|Base64To(?:String|Integer)|ParseStringKeepNulls|RezAtRoot|RequestSimulatorData|ForceMouselook|(?:Load|Release|(?:E|Une)scape)URL|ParcelMedia(?:CommandList|Query)|ModPow|MapDestination|(?:RemoveFrom|AddTo|Reset)Land(?:Pass|Ban)List|(?:Set|Clear)CameraParams|HTTP(?:Request|Response)|TextBox|DetectedTouch(?:UV|Face|Pos|(?:N|Bin)ormal|ST)|(?:MD5|SHA1|DumpList2)String|Request(?:Secure)?URL|Clear(?:Prim|Link)Media|(?:Link)?ParticleSystem|(?:Get|Request)(?:Username|DisplayName)|RegionSayTo|CastRay|GenerateKey|TransferLindenDollars|ManageEstateAccess|(?:Create|Delete)Character|ExecCharacterCmd|Evade|FleeFrom|NavigateTo|PatrolPoints|Pursue|UpdateCharacter|WanderWithin))\b'
+ lsl_constants_float = r'\b(?:DEG_TO_RAD|PI(?:_BY_TWO)?|RAD_TO_DEG|SQRT2|TWO_PI)\b'
+ lsl_constants_integer = r'\b(?:JSON_APPEND|STATUS_(?:PHYSICS|ROTATE_[XYZ]|PHANTOM|SANDBOX|BLOCK_GRAB(?:_OBJECT)?|(?:DIE|RETURN)_AT_EDGE|CAST_SHADOWS|OK|MALFORMED_PARAMS|TYPE_MISMATCH|BOUNDS_ERROR|NOT_(?:FOUND|SUPPORTED)|INTERNAL_ERROR|WHITELIST_FAILED)|AGENT(?:_(?:BY_(?:LEGACY_|USER)NAME|FLYING|ATTACHMENTS|SCRIPTED|MOUSELOOK|SITTING|ON_OBJECT|AWAY|WALKING|IN_AIR|TYPING|CROUCHING|BUSY|ALWAYS_RUN|AUTOPILOT|LIST_(?:PARCEL(?:_OWNER)?|REGION)))?|CAMERA_(?:PITCH|DISTANCE|BEHINDNESS_(?:ANGLE|LAG)|(?:FOCUS|POSITION)(?:_(?:THRESHOLD|LOCKED|LAG))?|FOCUS_OFFSET|ACTIVE)|ANIM_ON|LOOP|REVERSE|PING_PONG|SMOOTH|ROTATE|SCALE|ALL_SIDES|LINK_(?:ROOT|SET|ALL_(?:OTHERS|CHILDREN)|THIS)|ACTIVE|PASSIVE|SCRIPTED|CONTROL_(?:FWD|BACK|(?:ROT_)?(?:LEFT|RIGHT)|UP|DOWN|(?:ML_)?LBUTTON)|PERMISSION_(?:RETURN_OBJECTS|DEBIT|OVERRIDE_ANIMATIONS|SILENT_ESTATE_MANAGEMENT|TAKE_CONTROLS|TRIGGER_ANIMATION|ATTACH|CHANGE_LINKS|(?:CONTROL|TRACK)_CAMERA|TELEPORT)|INVENTORY_(?:TEXTURE|SOUND|OBJECT|SCRIPT|LANDMARK|CLOTHING|NOTECARD|BODYPART|ANIMATION|GESTURE|ALL|NONE)|CHANGED_(?:INVENTORY|COLOR|SHAPE|SCALE|TEXTURE|LINK|ALLOWED_DROP|OWNER|REGION(?:_START)?|TELEPORT|MEDIA)|OBJECT_(?:(?:PHYSICS|SERVER|STREAMING)_COST|UNKNOWN_DETAIL|CHARACTER_TIME|PHANTOM|PHYSICS|TEMP_ON_REZ|NAME|DESC|POS|PRIM_EQUIVALENCE|RETURN_(?:PARCEL(?:_OWNER)?|REGION)|ROO?T|VELOCITY|OWNER|GROUP|CREATOR|ATTACHED_POINT|RENDER_WEIGHT|PATHFINDING_TYPE|(?:RUNNING|TOTAL)_SCRIPT_COUNT|SCRIPT_(?:MEMORY|TIME))|TYPE_(?:INTEGER|FLOAT|STRING|KEY|VECTOR|ROTATION|INVALID)|(?:DEBUG|PUBLIC)_CHANNEL|ATTACH_(?:AVATAR_CENTER|CHEST|HEAD|BACK|PELVIS|MOUTH|CHIN|NECK|NOSE|BELLY|[LR](?:SHOULDER|HAND|FOOT|EAR|EYE|[UL](?:ARM|LEG)|HIP)|(?:LEFT|RIGHT)_PEC|HUD_(?:CENTER_[12]|TOP_(?:RIGHT|CENTER|LEFT)|BOTTOM(?:_(?:RIGHT|LEFT))?))|LAND_(?:LEVEL|RAISE|LOWER|SMOOTH|NOISE|REVERT)|DATA_(?:ONLINE|NAME|BORN|SIM_(?:POS|STATUS|RATING)|PAYINFO)|PAYMENT_INFO_(?:ON_FILE|USED)|REMOTE_DATA_(?:CHANNEL|REQUEST|REPLY)|PSYS_(?:PART_(?:BF_(?:ZERO|ONE(?:_MINUS_(?:DEST_COLOR|SOURCE_(ALPHA|COLOR)))?|DEST_COLOR|SOURCE_(ALPHA|COLOR))|BLEND_FUNC_(DEST|SOURCE)|FLAGS|(?:START|END)_(?:COLOR|ALPHA|SCALE|GLOW)|MAX_AGE|(?:RIBBON|WIND|INTERP_(?:COLOR|SCALE)|BOUNCE|FOLLOW_(?:SRC|VELOCITY)|TARGET_(?:POS|LINEAR)|EMISSIVE)_MASK)|SRC_(?:MAX_AGE|PATTERN|ANGLE_(?:BEGIN|END)|BURST_(?:RATE|PART_COUNT|RADIUS|SPEED_(?:MIN|MAX))|ACCEL|TEXTURE|TARGET_KEY|OMEGA|PATTERN_(?:DROP|EXPLODE|ANGLE(?:_CONE(?:_EMPTY)?)?)))|VEHICLE_(?:REFERENCE_FRAME|TYPE_(?:NONE|SLED|CAR|BOAT|AIRPLANE|BALLOON)|(?:LINEAR|ANGULAR)_(?:FRICTION_TIMESCALE|MOTOR_DIRECTION)|LINEAR_MOTOR_OFFSET|HOVER_(?:HEIGHT|EFFICIENCY|TIMESCALE)|BUOYANCY|(?:LINEAR|ANGULAR)_(?:DEFLECTION_(?:EFFICIENCY|TIMESCALE)|MOTOR_(?:DECAY_)?TIMESCALE)|VERTICAL_ATTRACTION_(?:EFFICIENCY|TIMESCALE)|BANKING_(?:EFFICIENCY|MIX|TIMESCALE)|FLAG_(?:NO_DEFLECTION_UP|LIMIT_(?:ROLL_ONLY|MOTOR_UP)|HOVER_(?:(?:WATER|TERRAIN|UP)_ONLY|GLOBAL_HEIGHT)|MOUSELOOK_(?:STEER|BANK)|CAMERA_DECOUPLED))|PRIM_(?:TYPE(?:_(?:BOX|CYLINDER|PRISM|SPHERE|TORUS|TUBE|RING|SCULPT))?|HOLE_(?:DEFAULT|CIRCLE|SQUARE|TRIANGLE)|MATERIAL(?:_(?:STONE|METAL|GLASS|WOOD|FLESH|PLASTIC|RUBBER))?|SHINY_(?:NONE|LOW|MEDIUM|HIGH)|BUMP_(?:NONE|BRIGHT|DARK|WOOD|BARK|BRICKS|CHECKER|CONCRETE|TILE|STONE|DISKS|GRAVEL|BLOBS|SIDING|LARGETILE|STUCCO|SUCTION|WEAVE)|TEXGEN_(?:DEFAULT|PLANAR)|SCULPT_(?:TYPE_(?:SPHERE|TORUS|PLANE|CYLINDER|MASK)|FLAG_(?:MIRROR|INVERT))|PHYSICS(?:_(?:SHAPE_(?:CONVEX|NONE|PRIM|TYPE)))?|(?:POS|ROT)_LOCAL|SLICE|TEXT|FLEXIBLE|POINT_LIGHT|TEMP_ON_REZ|PHANTOM|POSITION|SIZE|ROTATION|TEXTURE|NAME|OMEGA|DESC|LINK_TARGET|COLOR|BUMP_SHINY|FULLBRIGHT|TEXGEN|GLOW|MEDIA_(?:ALT_IMAGE_ENABLE|CONTROLS|(?:CURRENT|HOME)_URL|AUTO_(?:LOOP|PLAY|SCALE|ZOOM)|FIRST_CLICK_INTERACT|(?:WIDTH|HEIGHT)_PIXELS|WHITELIST(?:_ENABLE)?|PERMS_(?:INTERACT|CONTROL)|PARAM_MAX|CONTROLS_(?:STANDARD|MINI)|PERM_(?:NONE|OWNER|GROUP|ANYONE)|MAX_(?:URL_LENGTH|WHITELIST_(?:SIZE|COUNT)|(?:WIDTH|HEIGHT)_PIXELS)))|MASK_(?:BASE|OWNER|GROUP|EVERYONE|NEXT)|PERM_(?:TRANSFER|MODIFY|COPY|MOVE|ALL)|PARCEL_(?:MEDIA_COMMAND_(?:STOP|PAUSE|PLAY|LOOP|TEXTURE|URL|TIME|AGENT|UNLOAD|AUTO_ALIGN|TYPE|SIZE|DESC|LOOP_SET)|FLAG_(?:ALLOW_(?:FLY|(?:GROUP_)?SCRIPTS|LANDMARK|TERRAFORM|DAMAGE|CREATE_(?:GROUP_)?OBJECTS)|USE_(?:ACCESS_(?:GROUP|LIST)|BAN_LIST|LAND_PASS_LIST)|LOCAL_SOUND_ONLY|RESTRICT_PUSHOBJECT|ALLOW_(?:GROUP|ALL)_OBJECT_ENTRY)|COUNT_(?:TOTAL|OWNER|GROUP|OTHER|SELECTED|TEMP)|DETAILS_(?:NAME|DESC|OWNER|GROUP|AREA|ID|SEE_AVATARS))|LIST_STAT_(?:MAX|MIN|MEAN|MEDIAN|STD_DEV|SUM(?:_SQUARES)?|NUM_COUNT|GEOMETRIC_MEAN|RANGE)|PAY_(?:HIDE|DEFAULT)|REGION_FLAG_(?:ALLOW_DAMAGE|FIXED_SUN|BLOCK_TERRAFORM|SANDBOX|DISABLE_(?:COLLISIONS|PHYSICS)|BLOCK_FLY|ALLOW_DIRECT_TELEPORT|RESTRICT_PUSHOBJECT)|HTTP_(?:METHOD|MIMETYPE|BODY_(?:MAXLENGTH|TRUNCATED)|CUSTOM_HEADER|PRAGMA_NO_CACHE|VERBOSE_THROTTLE|VERIFY_CERT)|STRING_(?:TRIM(?:_(?:HEAD|TAIL))?)|CLICK_ACTION_(?:NONE|TOUCH|SIT|BUY|PAY|OPEN(?:_MEDIA)?|PLAY|ZOOM)|TOUCH_INVALID_FACE|PROFILE_(?:NONE|SCRIPT_MEMORY)|RC_(?:DATA_FLAGS|DETECT_PHANTOM|GET_(?:LINK_NUM|NORMAL|ROOT_KEY)|MAX_HITS|REJECT_(?:TYPES|AGENTS|(?:NON)?PHYSICAL|LAND))|RCERR_(?:CAST_TIME_EXCEEDED|SIM_PERF_LOW|UNKNOWN)|ESTATE_ACCESS_(?:ALLOWED_(?:AGENT|GROUP)_(?:ADD|REMOVE)|BANNED_AGENT_(?:ADD|REMOVE))|DENSITY|FRICTION|RESTITUTION|GRAVITY_MULTIPLIER|KFM_(?:COMMAND|CMD_(?:PLAY|STOP|PAUSE|SET_MODE)|MODE|FORWARD|LOOP|PING_PONG|REVERSE|DATA|ROTATION|TRANSLATION)|ERR_(?:GENERIC|PARCEL_PERMISSIONS|MALFORMED_PARAMS|RUNTIME_PERMISSIONS|THROTTLED)|CHARACTER_(?:CMD_(?:(?:SMOOTH_)?STOP|JUMP)|DESIRED_(?:TURN_)?SPEED|RADIUS|STAY_WITHIN_PARCEL|LENGTH|ORIENTATION|ACCOUNT_FOR_SKIPPED_FRAMES|AVOIDANCE_MODE|TYPE(?:_(?:[ABCD]|NONE))?|MAX_(?:DECEL|TURN_RADIUS|(?:ACCEL|SPEED)))|PURSUIT_(?:OFFSET|FUZZ_FACTOR|GOAL_TOLERANCE|INTERCEPT)|REQUIRE_LINE_OF_SIGHT|FORCE_DIRECT_PATH|VERTICAL|HORIZONTAL|AVOID_(?:CHARACTERS|DYNAMIC_OBSTACLES|NONE)|PU_(?:EVADE_(?:HIDDEN|SPOTTED)|FAILURE_(?:DYNAMIC_PATHFINDING_DISABLED|INVALID_(?:GOAL|START)|NO_(?:NAVMESH|VALID_DESTINATION)|OTHER|TARGET_GONE|(?:PARCEL_)?UNREACHABLE)|(?:GOAL|SLOWDOWN_DISTANCE)_REACHED)|TRAVERSAL_TYPE(?:_(?:FAST|NONE|SLOW))?|CONTENT_TYPE_(?:ATOM|FORM|HTML|JSON|LLSD|RSS|TEXT|XHTML|XML)|GCNP_(?:RADIUS|STATIC)|(?:PATROL|WANDER)_PAUSE_AT_WAYPOINTS|OPT_(?:AVATAR|CHARACTER|EXCLUSION_VOLUME|LEGACY_LINKSET|MATERIAL_VOLUME|OTHER|STATIC_OBSTACLE|WALKABLE)|SIM_STAT_PCT_CHARS_STEPPED)\b'
+ lsl_constants_integer_boolean = r'\b(?:FALSE|TRUE)\b'
+ lsl_constants_rotation = r'\b(?:ZERO_ROTATION)\b'
+ lsl_constants_string = r'\b(?:EOF|JSON_(?:ARRAY|DELETE|FALSE|INVALID|NULL|NUMBER|OBJECT|STRING|TRUE)|NULL_KEY|TEXTURE_(?:BLANK|DEFAULT|MEDIA|PLYWOOD|TRANSPARENT)|URL_REQUEST_(?:GRANTED|DENIED))\b'
+ lsl_constants_vector = r'\b(?:TOUCH_INVALID_(?:TEXCOORD|VECTOR)|ZERO_VECTOR)\b'
+ lsl_invalid_broken = r'\b(?:LAND_(?:LARGE|MEDIUM|SMALL)_BRUSH)\b'
+ lsl_invalid_deprecated = r'\b(?:ATTACH_[LR]PEC|DATA_RATING|OBJECT_ATTACHMENT_(?:GEOMETRY_BYTES|SURFACE_AREA)|PRIM_(?:CAST_SHADOWS|MATERIAL_LIGHT|TYPE_LEGACY)|PSYS_SRC_(?:INNER|OUTER)ANGLE|VEHICLE_FLAG_NO_FLY_UP|ll(?:Cloud|Make(?:Explosion|Fountain|Smoke|Fire)|RemoteDataSetRegion|Sound(?:Preload)?|XorBase64Strings(?:Correct)?))\b'
+ lsl_invalid_illegal = r'\b(?:event)\b'
+ lsl_invalid_unimplemented = r'\b(?:CHARACTER_(?:MAX_ANGULAR_(?:ACCEL|SPEED)|TURN_SPEED_MULTIPLIER)|PERMISSION_(?:CHANGE_(?:JOINTS|PERMISSIONS)|RELEASE_OWNERSHIP|REMAP_CONTROLS)|PRIM_PHYSICS_MATERIAL|PSYS_SRC_OBJ_REL_MASK|ll(?:CollisionSprite|(?:Stop)?PointAt|(?:(?:Refresh|Set)Prim)URL|(?:Take|Release)Camera|RemoteLoadScript))\b'
+ lsl_reserved_godmode = r'\b(?:ll(?:GodLikeRezObject|Set(?:Inventory|Object)PermMask))\b'
+ lsl_reserved_log = r'\b(?:print)\b'
+ lsl_operators = r'\+\+|\-\-|<<|>>|&&?|\|\|?|\^|~|[!%<>=*+\-\/]=?'
+
+ tokens = {
+ 'root':
+ [
+ (r'//.*?\n', Comment.Single),
+ (r'/\*', Comment.Multiline, 'comment'),
+ (r'"', String.Double, 'string'),
+ (lsl_keywords, Keyword),
+ (lsl_types, Keyword.Type),
+ (lsl_states, Name.Class),
+ (lsl_events, Name.Builtin),
+ (lsl_functions_builtin, Name.Function),
+ (lsl_constants_float, Keyword.Constant),
+ (lsl_constants_integer, Keyword.Constant),
+ (lsl_constants_integer_boolean, Keyword.Constant),
+ (lsl_constants_rotation, Keyword.Constant),
+ (lsl_constants_string, Keyword.Constant),
+ (lsl_constants_vector, Keyword.Constant),
+ (lsl_invalid_broken, Error),
+ (lsl_invalid_deprecated, Error),
+ (lsl_invalid_illegal, Error),
+ (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'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d*', Number.Float),
+ (r'(\d+\.\d*|\.\d+)', Number.Float),
+ (r'0[xX][0-9a-fA-F]+', Number.Hex),
+ (r'\d+', Number.Integer),
+ (lsl_operators, Operator),
+ (r':=?', Error),
+ (r'[,;{}\(\)\[\]]', Punctuation),
+ (r'\n+', Whitespace),
+ (r'\s+', Whitespace)
+ ],
+ 'comment':
+ [
+ (r'[^*/]+', Comment.Multiline),
+ (r'/\*', Comment.Multiline, '#push'),
+ (r'\*/', Comment.Multiline, '#pop'),
+ (r'[*/]', Comment.Multiline)
+ ],
+ 'string':
+ [
+ (r'\\([nt"\\])', String.Escape),
+ (r'"', String.Double, '#pop'),
+ (r'\\.', Error),
+ (r'[^"\\]+', String.Double),
+ ]
+ }
class ECLLexer(RegexLexer):
@@ -1235,9 +1318,9 @@ class ModelicaLexer(RegexLexer):
'root': [
include('whitespace'),
include('keywords'),
+ include('classes'),
include('functions'),
include('operators'),
- include('classes'),
(r'("<html>|<html>)', Name.Tag, 'html-content'),
include('statements'),
],
@@ -1264,9 +1347,9 @@ class ModelicaLexer(RegexLexer):
r'terminate)\b', Name.Builtin),
],
'classes': [
- (r'(block|class|connector|end|function|model|package|'
+ (r'(operator)?(\s+)?(block|class|connector|end|function|model|operator|package|'
r'record|type)(\s+)((?!if|when|while)[A-Za-z_]\w*|[\'][^\']+[\'])([;]?)',
- bygroups(Keyword, Text, Name.Class, Text))
+ bygroups(Keyword, Text, Keyword, Text, Name.Class, Text))
],
'quoted_ident': [
(r'\'', Name, '#pop'),
@@ -2528,11 +2611,11 @@ class AwkLexer(RegexLexer):
'root': [
(r'^(?=\s|/)', Text, 'slashstartsregex'),
include('commentsandwhitespace'),
- (r'\+\+|--|\|\||&&|in|\$|!?~|'
+ (r'\+\+|--|\|\||&&|in\b|\$|!?~|'
r'(\*\*|[-<>+*%\^/!=])=?', Operator, 'slashstartsregex'),
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
(r'[})\].]', Punctuation),
- (r'(break|continue|do|while|exit|for|if|'
+ (r'(break|continue|do|while|exit|for|if|else|'
r'return)\b', Keyword, 'slashstartsregex'),
(r'function\b', Keyword.Declaration, 'slashstartsregex'),
(r'(atan2|cos|exp|int|log|rand|sin|sqrt|srand|gensub|gsub|index|'
@@ -3799,3 +3882,238 @@ class RexxLexer(RegexLexer):
for (pattern, weight) in RexxLexer.PATTERNS_AND_WEIGHTS
if pattern.search(lowerText)) + 0.01
return min(result, 1.0)
+
+
+class APLLexer(RegexLexer):
+ """
+ A simple APL lexer.
+
+ .. versionadded:: 2.0
+ """
+ name = 'APL'
+ aliases = ['apl']
+ filenames = ['*.apl']
+
+ tokens = {
+ 'root': [
+ # Whitespace
+ # ==========
+ (r'\s+', Text),
+ #
+ # Comment
+ # =======
+ # '⍝' is traditional; '#' is supported by GNU APL and NGN (but not Dyalog)
+ (u'[⍝#].*$', Comment.Single),
+ #
+ # Strings
+ # =======
+ (r'\'((\'\')|[^\'])*\'', String.Single),
+ (r'"(("")|[^"])*"', String.Double), # supported by NGN APL
+ #
+ # Punctuation
+ # ===========
+ # This token type is used for diamond and parenthesis
+ # but not for bracket and ; (see below)
+ (u'[⋄◇()]', Punctuation),
+ #
+ # Array indexing
+ # ==============
+ # Since this token type is very important in APL, it is not included in
+ # the punctuation token type but rather in the following one
+ (r'[\[\];]', String.Regex),
+ #
+ # Distinguished names
+ # ===================
+ # following IBM APL2 standard
+ (u'⎕[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*', Name.Function),
+ #
+ # Labels
+ # ======
+ # following IBM APL2 standard
+ # (u'[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*:', Name.Label),
+ #
+ # Variables
+ # =========
+ # following IBM APL2 standard
+ (u'[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*', Name.Variable),
+ #
+ # Numbers
+ # =======
+ (u'¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞)'
+ u'([Jj]¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞))?',
+ Number),
+ #
+ # Operators
+ # ==========
+ (u'[\.\\\/⌿⍀¨⍣⍨⍠⍤∘]', Name.Attribute), # closest token type
+ (u'[+\-×÷⌈⌊∣|⍳?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⌸⍯↗]',
+ Operator),
+ #
+ # Constant
+ # ========
+ (u'⍬', Name.Constant),
+ #
+ # Quad symbol
+ # ===========
+ (u'[⎕⍞]', Name.Variable.Global),
+ #
+ # Arrows left/right
+ # =================
+ (u'[←→]', Keyword.Declaration),
+ #
+ # D-Fn
+ # ====
+ (u'[⍺⍵⍶⍹∇:]', Name.Builtin.Pseudo),
+ (r'[{}]', Keyword.Type),
+ ],
+ }
+
+class AmbientTalkLexer(RegexLexer):
+ """
+ Lexer for `AmbientTalk <https://code.google.com/p/ambienttalk>`_ source code.
+
+ .. versionadded:: 2.0
+ """
+ name = 'AmbientTalk'
+ filenames = ['*.at']
+ aliases = ['at', 'ambienttalk', 'ambienttalk/2']
+ mimetypes = ['text/x-ambienttalk']
+
+ flags = re.MULTILINE | re.DOTALL
+
+ builtin = ['if:', 'then:', 'else:', 'when:', 'whenever:', 'discovered:',
+ 'disconnected:', 'reconnected:', 'takenOffline:', 'becomes:',
+ 'export:', 'as:', 'object:', 'actor:', 'mirror:', 'taggedAs:',
+ 'mirroredBy:', 'is:']
+ tokens = {
+ 'root' : [
+ (r'\s+', Text),
+ (r'//.*?\n', Comment.Single),
+ (r'/\*.*?\*/', Comment.Multiline),
+ (r'(def|deftype|import|alias|exclude)\b', Keyword),
+ (r"(%s)" % "|".join(builtin), Name.Builtin),
+ (r'(true|false|nil)\b', Keyword.Constant),
+ (r'(~|lobby|jlobby|/)\.', Keyword.Constant, 'namespace'),
+ (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"[\{\}()\[\];`]", 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"@\[", Name.Class, 'annotations'),
+ include('numbers'),
+ ],
+ 'numbers' : [
+ (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
+ (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')
+ ],
+ 'annotations' : [
+ (r"(.*?)\]", Name.Class, '#pop')
+ ],
+ 'arglist' : [
+ (r'\|', Punctuation, '#pop'),
+ (r'\s*(,)\s*', Punctuation),
+ (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable),
+ ],
+ }
+
+
+class PawnLexer(RegexLexer):
+ """
+ For Pawn source code
+ """
+
+ name = 'Pawn'
+ aliases = ['pawn']
+ filenames = ['*.p', '*.pwn', '*.inc']
+ mimetypes = ['text/x-pawn']
+
+ #: optional Comment or Whitespace
+ _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
+
+ tokens = {
+ 'root': [
+ # preprocessor directives: without whitespace
+ ('^#if\s+0', Comment.Preproc, 'if0'),
+ ('^#', Comment.Preproc, 'macro'),
+ # or with whitespace
+ ('^' + _ws + r'#if\s+0', Comment.Preproc, 'if0'),
+ ('^' + _ws + '#', Comment.Preproc, 'macro'),
+ (r'\n', Text),
+ (r'\s+', Text),
+ (r'\\\n', Text), # line continuation
+ (r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
+ (r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment.Multiline),
+ (r'[{}]', Punctuation),
+ (r'L?"', String, 'string'),
+ (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
+ (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
+ (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
+ (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
+ (r'0[0-7]+[LlUu]*', Number.Oct),
+ (r'\d+[LlUu]*', Number.Integer),
+ (r'\*/', Error),
+ (r'[~!%^&*+=|?:<>/-]', Operator),
+ (r'[()\[\],.;]', Punctuation),
+ (r'(switch|case|default|const|new|static|char|continue|break|'
+ r'if|else|for|while|do|operator|enum|'
+ 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),
+ ],
+ 'string': [
+ (r'"', String, '#pop'),
+ (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
+ (r'[^\\"\n]+', String), # all other characters
+ (r'\\\n', String), # line continuation
+ (r'\\', String), # stray backslash
+ ],
+ 'macro': [
+ (r'[^/\n]+', Comment.Preproc),
+ (r'/\*(.|\n)*?\*/', Comment.Multiline),
+ (r'//.*?\n', Comment.Single, '#pop'),
+ (r'/', Comment.Preproc),
+ (r'(?<=\\)\n', Comment.Preproc),
+ (r'\n', Comment.Preproc, '#pop'),
+ ],
+ 'if0': [
+ (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
+ (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
+ (r'.*?\n', Comment),
+ ]
+ }
+
+
+class VCTreeStatusLexer(RegexLexer):
+ """
+ For colorizing output of version control status commans, like "hg
+ status" or "svn status".
+
+ .. versionadded:: 2.0
+ """
+ name = 'VCTreeStatus'
+ aliases = ['vctreestatus']
+ filenames = []
+ mimetypes = []
+
+ tokens = {
+ 'root' : [
+ (r'^A \+ C\s+', Generic.Error),
+ (r'^A\s+\+?\s+', String),
+ (r'^M\s+', Generic.Inserted),
+ (r'^C\s+', Generic.Error),
+ (r'^D\s+', Generic.Deleted),
+ (r'^[\?!]\s+', Comment.Preproc),
+ (r' >\s+.*\n', Comment.Preproc),
+ (r'.*\n', Text)
+ ]
+ }
diff --git a/pygments/lexers/rdf.py b/pygments/lexers/rdf.py
new file mode 100644
index 00000000..bd3c06c1
--- /dev/null
+++ b/pygments/lexers/rdf.py
@@ -0,0 +1,98 @@
+# -*- coding: utf-8 -*-
+"""
+ pygments.lexers.rdf
+ ~~~~~~~~~~~~~~~~~~~
+
+ Lexers for semantic web and RDF query languages and markup.
+
+ :copyright: Copyright 2012-2014 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+import re
+
+from pygments.lexer import RegexLexer, include, this, bygroups, include
+from pygments.token import Keyword, Punctuation, String, Number, Operator, \
+ Whitespace, Name, Literal, Comment, Text
+
+__all__ = ['SparqlLexer']
+
+
+class SparqlLexer(RegexLexer):
+ """
+ Lexer for `SPARQL <http://www.w3.org/TR/rdf-sparql-query/>`_ query language.
+
+ .. versionadded:: 2.0
+ """
+ name = 'SPARQL'
+ aliases = ['sparql']
+ filenames = ['*.rq', '*.sparql']
+ mimetypes = ['application/sparql-query']
+
+ flags = re.IGNORECASE
+
+ tokens = {
+ 'root': [
+ (r'\s+', Whitespace),
+ (r'(select|construct|describe|ask|where|filter|group\s+by|minus|'
+ r'distinct|reduced|from named|from|order\s+by|limit|'
+ r'offset|bindings|load|clear|drop|create|add|move|copy|'
+ 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*)(\:)',
+ bygroups(Keyword, Whitespace, Name.Namespace, Whitespace,
+ Punctuation)),
+ (r'\?[a-z_][a-z\d_]*', Name.Variable),
+ (r'<[^>]+>', Name.Label),
+ (r'([a-z][a-z\d_\-]*)(\:)([a-z][a-z\d_\-]*)',
+ 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|'
+ r'contains|strstarts|strends|strbefore|strafter|year|month|day|'
+ r'hours|minutes|seconds|timezone|tz|now|md5|sha1|sha256|sha384|'
+ r'sha512|coalesce|if|strlang|strdt|sameterm|isiri|isuri|isblank|'
+ r'isliteral|isnumeric|regex|substr|replace|exists|not exists|'
+ r'count|sum|min|max|avg|sample|group_concat|separator)\b',
+ Name.Function),
+ (r'(true|false)', Literal),
+ (r'[+\-]?\d*\.\d+', Number.Float),
+ (r'[+\-]?\d*(:?\.\d+)?[eE][+\-]?\d+', Number.Float),
+ (r'[+\-]?\d+', Number.Integer),
+ (r'(\|\||&&|=|\*|\-|\+|/)', Operator),
+ (r'[(){}.;,:^]', Punctuation),
+ (r'#[^\n]+', Comment),
+ (r'"""', String, 'triple-double-quoted-string'),
+ (r'"', String, 'single-double-quoted-string'),
+ (r"'''", String, 'triple-single-quoted-string'),
+ (r"'", String, 'single-single-quoted-string'),
+ ],
+ 'triple-double-quoted-string': [
+ (r'"""', String, 'end-of-string'),
+ (r'[^\\]+', String),
+ (r'\\', String, 'string-escape'),
+ ],
+ 'single-double-quoted-string': [
+ (r'"', String, 'end-of-string'),
+ (r'[^"\\\n]+', String),
+ (r'\\', String, 'string-escape'),
+ ],
+ 'triple-single-quoted-string': [
+ (r"'''", String, 'end-of-string'),
+ (r'[^\\]+', String),
+ (r'\\', String, 'string-escape'),
+ ],
+ 'single-single-quoted-string': [
+ (r"'", String, 'end-of-string'),
+ (r"[^'\\\n]+", String),
+ (r'\\', String, 'string-escape'),
+ ],
+ 'string-escape': [
+ (r'.', String, '#pop'),
+ ],
+ 'end-of-string': [
+ (r'(@)([a-z]+(:?-[a-z0-9]+)*)',
+ bygroups(Operator, Name.Function), '#pop:2'),
+ (r'\^\^', Operator, '#pop:2'),
+ (r'', Text, '#pop:2'),
+ ],
+ }
diff --git a/pygments/lexers/sql.py b/pygments/lexers/sql.py
index 73180772..9a3dcb8d 100644
--- a/pygments/lexers/sql.py
+++ b/pygments/lexers/sql.py
@@ -51,7 +51,7 @@ from pygments.lexers._postgres_builtins import KEYWORDS, DATATYPES, \
__all__ = ['PostgresLexer', 'PlPgsqlLexer', 'PostgresConsoleLexer',
- 'SqlLexer', 'MySqlLexer', 'SqliteConsoleLexer']
+ 'SqlLexer', 'MySqlLexer', 'SqliteConsoleLexer', 'RqlLexer']
line_re = re.compile('.*?\n')
@@ -559,3 +559,34 @@ class SqliteConsoleLexer(Lexer):
for item in do_insertions(insertions,
sql.get_tokens_unprocessed(curcode)):
yield item
+
+
+class RqlLexer(RegexLexer):
+ """
+ Lexer for Relation Query Language.
+
+ `RQL <http://www.logilab.org/project/rql>`_
+
+ .. versionadded:: 2.0
+ """
+ name = 'RQL'
+ aliases = ['rql']
+ filenames = ['*.rql']
+ mimetypes = ['text/x-rql']
+
+ flags = re.IGNORECASE
+ tokens = {
+ 'root': [
+ (r'\s+', Text),
+ (r'(DELETE|SET|INSERT|UNION|DISTINCT|WITH|WHERE|BEING|OR'
+ r'|AND|NOT|GROUPBY|HAVING|ORDERBY|ASC|DESC|LIMIT|OFFSET'
+ r'|TODAY|NOW|TRUE|FALSE|NULL|EXISTS)\b', Keyword),
+ (r'[+*/<>=%-]', Operator),
+ (r'(Any|is|instance_of|CWEType|CWRelation)\b', Name.Builtin),
+ (r'[0-9]+', Number.Integer),
+ (r'[A-Z_][A-Z0-9_]*\??', Name),
+ (r"'(''|[^'])*'", String.Single),
+ (r'"(""|[^"])*"', String.Single),
+ (r'[;:()\[\],\.]', Punctuation)
+ ],
+ }
diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py
index 72f81d63..a2de2f9c 100644
--- a/pygments/lexers/templates.py
+++ b/pygments/lexers/templates.py
@@ -39,7 +39,8 @@ __all__ = ['HtmlPhpLexer', 'XmlPhpLexer', 'CssPhpLexer',
'ColdfusionHtmlLexer', 'ColdfusionCFCLexer', 'VelocityLexer',
'VelocityHtmlLexer', 'VelocityXmlLexer', 'SspLexer',
'TeaTemplateLexer', 'LassoHtmlLexer', 'LassoXmlLexer',
- 'LassoCssLexer', 'LassoJavascriptLexer']
+ 'LassoCssLexer', 'LassoJavascriptLexer', 'HandlebarsLexer',
+ 'HandlebarsHtmlLexer']
class ErbLexer(Lexer):
@@ -1762,3 +1763,64 @@ class LassoJavascriptLexer(DelegatingLexer):
if 'function' in text:
rv += 0.2
return rv
+
+class HandlebarsLexer(RegexLexer):
+ """
+ Generic `handlebars <http://handlebarsjs.com/>` template lexer.
+
+ Highlights only the Handlebars template tags (stuff between `{{` and `}}`).
+ Everything else is left for a delegating lexer.
+ """
+
+ name = "Handlebars"
+ aliases = ['handlebars']
+
+ tokens = {
+ 'root': [
+ (r'[^{]+', Other),
+
+ (r'{{!.*}}', Comment),
+
+ (r'({{{)(\s*)', bygroups(Comment.Special, Text), 'tag'),
+ (r'({{)(\s*)', bygroups(Comment.Preproc, Text), 'tag'),
+ ],
+
+ 'tag': [
+ (r'\s+', Text),
+ (r'\}\}\}', Comment.Special, '#pop'),
+ (r'\}\}', Comment.Preproc, '#pop'),
+
+ # Handlebars
+ (r'([\#/]*)(each|if|unless|else|with|log|in)', bygroups(Keyword,
+ Keyword)),
+
+ # General {{#block}}
+ (r'([\#/])(\w+)', bygroups(Name.Function, Name.Function)),
+
+ # {{opt=something}}
+ (r'(\w+)(=)', bygroups(Name.Attribute, Operator)),
+
+ # borrowed from DjangoLexer
+ (r':?"(\\\\|\\"|[^"])*"', String.Double),
+ (r":?'(\\\\|\\'|[^'])*'", String.Single),
+ (r'[a-zA-Z][a-zA-Z0-9_-]*', Name.Variable),
+ (r'\.[a-zA-Z0-9_]+', Name.Variable),
+ (r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
+ r"0[xX][0-9a-fA-F]+[Ll]?", Number),
+ ]
+ }
+
+
+class HandlebarsHtmlLexer(DelegatingLexer):
+ """
+ Subclass of the `HandlebarsLexer` that highlights unlexed data with the
+ `HtmlLexer`.
+ """
+
+ name = "HTML+Handlebars"
+ aliases = ["html+handlebars"]
+ filenames = ['*.handlebars', '*.hbs']
+ mimetypes = ['text/html+handlebars', 'text/x-handlebars-template']
+
+ def __init__(self, **options):
+ super(HandlebarsHtmlLexer, self).__init__(HtmlLexer, HandlebarsLexer, **options)
diff --git a/pygments/lexers/text.py b/pygments/lexers/text.py
index 1bab62f3..c0679aa6 100644
--- a/pygments/lexers/text.py
+++ b/pygments/lexers/text.py
@@ -25,7 +25,8 @@ __all__ = ['IniLexer', 'PropertiesLexer', 'SourcesListLexer', 'BaseMakefileLexer
'RstLexer', 'VimLexer', 'GettextLexer', 'SquidConfLexer',
'DebianControlLexer', 'DarcsPatchLexer', 'YamlLexer',
'LighttpdConfLexer', 'NginxConfLexer', 'CMakeLexer', 'HttpLexer',
- 'PyPyLogLexer', 'RegeditLexer', 'HxmlLexer', 'EbnfLexer']
+ 'PyPyLogLexer', 'RegeditLexer', 'HxmlLexer', 'EbnfLexer',
+ 'TodotxtLexer']
class IniLexer(RegexLexer):
@@ -1911,3 +1912,102 @@ class EbnfLexer(RegexLexer):
(r'([a-zA-Z][a-zA-Z0-9 \-]*)', Keyword),
],
}
+
+class TodotxtLexer(RegexLexer):
+ """
+ Lexer for `Todo.txt <http://todotxt.com/>`_ todo list format.
+
+ .. versionadded:: 2.0
+ """
+
+ name = 'Todotxt'
+ aliases = ['todotxt']
+ # *.todotxt is not a standard extension for Todo.txt files; including it
+ # makes testing easier, and also makes autodetecting file type easier.
+ filenames = ['todo.txt', '*.todotxt']
+ mimetypes = ['text/x-todo']
+
+ ## Aliases mapping standard token types of Todo.txt format concepts
+ CompleteTaskText = Operator # Chosen to de-emphasize complete tasks
+ IncompleteTaskText = Text # Incomplete tasks should look like plain text
+
+ # Priority should have most emphasis to indicate importance of tasks
+ Priority = Generic.Heading
+ # Dates should have next most emphasis because time is important
+ Date = Generic.Subheading
+
+ # Project and context should have equal weight, and be in different colors
+ Project = Generic.Error
+ Context = String
+
+ # If tag functionality is added, it should have the same weight as Project
+ # and Context, and a different color. Generic.Traceback would work well.
+
+ # Regex patterns for building up rules; dates, priorities, projects, and
+ # contexts are all atomic
+ # TODO: Make date regex more ISO 8601 compliant
+ date_regex = r'\d{4,}-\d{2}-\d{2}'
+ priority_regex = r'\([A-Z]\)'
+ project_regex = r'\+\S+'
+ context_regex = r'@\S+'
+
+ # Compound regex expressions
+ complete_one_date_regex = r'(x )(' + date_regex + r')'
+ complete_two_date_regex = (complete_one_date_regex + r'( )(' +
+ date_regex + r')')
+ priority_date_regex = r'(' + priority_regex + r')( )(' + date_regex + r')'
+
+ tokens = {
+ # Should parse starting at beginning of line; each line is a task
+ 'root': [
+ ## Complete task entry points: two total:
+ # 1. Complete task with two dates
+ (complete_two_date_regex, bygroups(CompleteTaskText, Date,
+ CompleteTaskText, Date),
+ 'complete'),
+ # 2. Complete task with one date
+ (complete_one_date_regex, bygroups(CompleteTaskText, Date),
+ 'complete'),
+
+ ## Incomplete task entry points: six total:
+ # 1. Priority plus date
+ (priority_date_regex, bygroups(Priority, IncompleteTaskText, Date),
+ 'incomplete'),
+ # 2. Priority only
+ (priority_regex, Priority, 'incomplete'),
+ # 3. Leading date
+ (date_regex, Date, 'incomplete'),
+ # 4. Leading context
+ (context_regex, Context, 'incomplete'),
+ # 5. Leading project
+ (project_regex, Project, 'incomplete'),
+ # 6. Non-whitespace catch-all
+ ('\S+', IncompleteTaskText, 'incomplete'),
+ ],
+
+ # Parse a complete task
+ 'complete': [
+ # Newline indicates end of task, should return to root
+ (r'\s*\n', CompleteTaskText, '#pop'),
+ # Tokenize contexts and projects
+ (context_regex, Context),
+ (project_regex, Project),
+ # Tokenize non-whitespace text
+ ('\S+', CompleteTaskText),
+ # Tokenize whitespace not containing a newline
+ ('\s+', CompleteTaskText),
+ ],
+
+ # Parse an incomplete task
+ 'incomplete': [
+ # Newline indicates end of task, should return to root
+ (r'\s*\n', IncompleteTaskText, '#pop'),
+ # Tokenize contexts and projects
+ (context_regex, Context),
+ (project_regex, Project),
+ # Tokenize non-whitespace text
+ ('\S+', IncompleteTaskText),
+ # Tokenize whitespace not containing a newline
+ ('\s+', IncompleteTaskText),
+ ],
+ }
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py
index c975ad80..f388f611 100644
--- a/pygments/lexers/web.py
+++ b/pygments/lexers/web.py
@@ -28,7 +28,7 @@ __all__ = ['HtmlLexer', 'XmlLexer', 'JavascriptLexer', 'JsonLexer', 'CssLexer',
'ObjectiveJLexer', 'CoffeeScriptLexer', 'LiveScriptLexer',
'DuelLexer', 'ScamlLexer', 'JadeLexer', 'XQueryLexer',
'DtdLexer', 'DartLexer', 'LassoLexer', 'QmlLexer', 'TypeScriptLexer',
- 'KalLexer', 'CirruLexer', 'MaskLexer']
+ 'KalLexer', 'CirruLexer', 'MaskLexer', 'ZephirLexer']
class JavascriptLexer(RegexLexer):
@@ -799,6 +799,13 @@ class PhpLexer(RegexLexer):
filenames = ['*.php', '*.php[345]', '*.inc']
mimetypes = ['text/x-php']
+ # 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_end = r'(?:' + _ident_char + ')*'
+ _ident_inner = _ident_begin + _ident_end
+
flags = re.IGNORECASE | re.DOTALL | re.MULTILINE
tokens = {
'root': [
@@ -808,7 +815,7 @@ class PhpLexer(RegexLexer):
],
'php': [
(r'\?>', Comment.Preproc, '#pop'),
- (r'<<<(\'?)([a-zA-Z_][a-zA-Z0-9_]*)\1\n.*?\n\2\;?\n', String),
+ (r'<<<(\'?)(' + _ident_inner + ')\1\n.*?\n\2\;?\n', String),
(r'\s+', Text),
(r'#.*?\n', Comment.Single),
(r'//.*?\n', Comment.Single),
@@ -817,7 +824,7 @@ class PhpLexer(RegexLexer):
(r'/\*\*/', Comment.Multiline),
(r'/\*\*.*?\*/', String.Doc),
(r'/\*.*?\*/', Comment.Multiline),
- (r'(->|::)(\s*)([a-zA-Z_][a-zA-Z0-9_]*)',
+ (r'(->|::)(\s*)(' + _ident_inner + ')',
bygroups(Operator, Text, Name.Attribute)),
(r'[~!%^&*+=|:.<>/?@-]+', Operator),
(r'[\[\]{}();,]+', Punctuation),
@@ -825,7 +832,7 @@ class PhpLexer(RegexLexer):
(r'(function)(\s*)(?=\()', bygroups(Keyword, Text)),
(r'(function)(\s+)(&?)(\s*)',
bygroups(Keyword, Text, Operator, Text), 'functionname'),
- (r'(const)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
+ (r'(const)(\s+)(' + _ident_inner + ')',
bygroups(Keyword, Text, Name.Constant)),
(r'(and|E_PARSE|old_function|E_ERROR|or|as|E_WARNING|parent|'
r'eval|PHP_OS|break|exit|case|extends|PHP_VERSION|cfunction|'
@@ -839,9 +846,9 @@ class PhpLexer(RegexLexer):
r'catch|throw|this|use|namespace|trait|yield|'
r'finally)\b', Keyword),
(r'(true|false|null)\b', Keyword.Constant),
- (r'\$\{\$+[a-zA-Z_][a-zA-Z0-9_]*\}', Name.Variable),
- (r'\$+[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable),
- (r'[\\a-zA-Z_][\\a-zA-Z0-9_]*', Name.Other),
+ (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'0[0-7]+', Number.Oct),
@@ -853,16 +860,16 @@ class PhpLexer(RegexLexer):
(r'"', String.Double, 'string'),
],
'classname': [
- (r'[a-zA-Z_][\\a-zA-Z0-9_]*', Name.Class, '#pop')
+ (_ident_inner, Name.Class, '#pop')
],
'functionname': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Function, '#pop')
+ (_ident_inner, Name.Function, '#pop')
],
'string': [
(r'"', String.Double, '#pop'),
(r'[^{$"\\]+', String.Double),
(r'\\([nrt\"$\\]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})', String.Escape),
- (r'\$[a-zA-Z_][a-zA-Z0-9_]*(\[\S+?\]|->[a-zA-Z_][a-zA-Z0-9_]*)?',
+ (r'\$' + _ident_inner + '(\[\S+?\]|->' + _ident_inner + ')?',
String.Interpol),
(r'(\{\$\{)(.*?)(\}\})',
bygroups(String.Interpol, using(this, _startinline=True),
@@ -3691,7 +3698,7 @@ class DartLexer(RegexLexer):
r'native|operator|set|static|typedef|var)\b', Keyword.Declaration),
(r'\b(bool|double|Dynamic|int|num|Object|String|void)\b', Keyword.Type),
(r'\b(false|null|true)\b', Keyword.Constant),
- (r'[~!%^&*+=|?:<>/-]|as', Operator),
+ (r'[~!%^&*+=|?:<>/-]|as\b', Operator),
(r'[a-zA-Z_$][a-zA-Z0-9_]*:', Name.Label),
(r'[a-zA-Z_$][a-zA-Z0-9_]*', Name),
(r'[(){}\[\],.;]', Punctuation),
@@ -4336,5 +4343,68 @@ class MaskLexer(RegexLexer):
'string-double-pop2':[
(r'"', String.Single, '#pop:2'),
include('string-base')
+ ],
+ }
+
+
+class ZephirLexer(RegexLexer):
+ """
+ For `Zephir language <http://zephir-lang.com/>`_ source code.
+
+ Zephir is a compiled high level language aimed
+ to the creation of C-extensions for PHP.
+
+ .. versionadded:: 2.0
+ """
+
+ name = 'Zephir'
+ aliases = ['zephir']
+ filenames = ['*.zep']
+
+ zephir_keywords = [ 'fetch', 'echo', 'isset', 'empty']
+ zephir_type = [ 'bit', 'bits' , 'string' ]
+
+ flags = re.DOTALL | re.MULTILINE
+
+ tokens = {
+ 'commentsandwhitespace': [
+ (r'\s+', Text),
+ (r'//.*?\n', Comment.Single),
+ (r'/\*.*?\*/', Comment.Multiline)
+ ],
+ 'slashstartsregex': [
+ include('commentsandwhitespace'),
+ (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
+ r'([gim]+\b|\B)', String.Regex, '#pop'),
+ (r'', Text, '#pop')
+ ],
+ 'badregex': [
+ (r'\n', Text, '#pop')
+ ],
+ 'root': [
+ (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
+ include('commentsandwhitespace'),
+ (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
+ 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'(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'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'[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),
+ (r'"(\\\\|\\"|[^"])*"', String.Double),
+ (r"'(\\\\|\\'|[^'])*'", String.Single),
]
}
diff --git a/pygments/styles/__init__.py b/pygments/styles/__init__.py
index 04c2e70a..828a0451 100644
--- a/pygments/styles/__init__.py
+++ b/pygments/styles/__init__.py
@@ -36,6 +36,8 @@ STYLE_MAP = {
'rrt': 'rrt::RrtStyle',
'xcode': 'xcode::XcodeStyle',
'igor': 'igor::IgorStyle',
+ 'paraiso-light': 'paraiso-light::paraiso_light',
+ 'paraiso-dark': 'paraiso-dark::paraiso_dark',
}
diff --git a/pygments/styles/paraiso-dark.py b/pygments/styles/paraiso-dark.py
new file mode 100644
index 00000000..c3548490
--- /dev/null
+++ b/pygments/styles/paraiso-dark.py
@@ -0,0 +1,119 @@
+# -*- coding: utf-8 -*-
+"""
+Paraíso (Dark)
+by Jan T. Sott
+
+Pygments template by Jan T. Sott (https://github.com/idleberg)
+Created with Base16 Builder by Chris Kempson (https://github.com/chriskempson/base16-builder)
+"""
+
+from pygments.style import Style
+from pygments.token import Keyword, Name, Comment, String, Error, Text, \
+ Number, Operator, Generic, Whitespace, Punctuation, Other, Literal
+
+
+BACKGROUND = "#2f1e2e"
+CURRENT_LINE = "#41323f"
+SELECTION = "#4f424c"
+FOREGROUND = "#e7e9db"
+COMMENT = "#776e71"
+RED = "#ef6155"
+ORANGE = "#f99b15"
+YELLOW = "#fec418"
+GREEN = "#48b685"
+AQUA = "#5bc4bf"
+BLUE = "#06b6ef"
+PURPLE = "#815ba4"
+
+
+class paraiso_dark(Style):
+
+ default_style = ''
+
+ background_color = BACKGROUND
+ highlight_color = SELECTION
+
+ background_color = BACKGROUND
+ highlight_color = SELECTION
+
+ styles = {
+ # No corresponding class for the following:
+ Text: FOREGROUND, # class: ''
+ Whitespace: "", # class: 'w'
+ Error: RED, # class: 'err'
+ Other: "", # class 'x'
+
+ Comment: COMMENT, # class: 'c'
+ Comment.Multiline: "", # class: 'cm'
+ Comment.Preproc: "", # class: 'cp'
+ Comment.Single: "", # class: 'c1'
+ Comment.Special: "", # class: 'cs'
+
+ Keyword: PURPLE, # class: 'k'
+ Keyword.Constant: "", # class: 'kc'
+ Keyword.Declaration: "", # class: 'kd'
+ Keyword.Namespace: AQUA, # class: 'kn'
+ Keyword.Pseudo: "", # class: 'kp'
+ Keyword.Reserved: "", # class: 'kr'
+ Keyword.Type: YELLOW, # class: 'kt'
+
+ Operator: AQUA, # class: 'o'
+ Operator.Word: "", # class: 'ow' - like keywords
+
+ Punctuation: FOREGROUND, # class: 'p'
+
+ Name: FOREGROUND, # class: 'n'
+ Name.Attribute: BLUE, # class: 'na' - to be revised
+ Name.Builtin: "", # class: 'nb'
+ Name.Builtin.Pseudo: "", # class: 'bp'
+ Name.Class: YELLOW, # class: 'nc' - to be revised
+ Name.Constant: RED, # class: 'no' - to be revised
+ Name.Decorator: AQUA, # class: 'nd' - to be revised
+ Name.Entity: "", # class: 'ni'
+ Name.Exception: RED, # class: 'ne'
+ Name.Function: BLUE, # class: 'nf'
+ Name.Property: "", # class: 'py'
+ Name.Label: "", # class: 'nl'
+ Name.Namespace: YELLOW, # class: 'nn' - to be revised
+ Name.Other: BLUE, # class: 'nx'
+ Name.Tag: AQUA, # class: 'nt' - like a keyword
+ Name.Variable: RED, # class: 'nv' - to be revised
+ Name.Variable.Class: "", # class: 'vc' - to be revised
+ Name.Variable.Global: "", # class: 'vg' - to be revised
+ Name.Variable.Instance: "", # class: 'vi' - to be revised
+
+ Number: ORANGE, # class: 'm'
+ Number.Float: "", # class: 'mf'
+ Number.Hex: "", # class: 'mh'
+ Number.Integer: "", # class: 'mi'
+ Number.Integer.Long: "", # class: 'il'
+ Number.Oct: "", # class: 'mo'
+
+ Literal: ORANGE, # class: 'l'
+ Literal.Date: GREEN, # class: 'ld'
+
+ String: GREEN, # class: 's'
+ String.Backtick: "", # class: 'sb'
+ String.Char: FOREGROUND, # class: 'sc'
+ String.Doc: COMMENT, # class: 'sd' - like a comment
+ String.Double: "", # class: 's2'
+ String.Escape: ORANGE, # class: 'se'
+ String.Heredoc: "", # class: 'sh'
+ String.Interpol: ORANGE, # class: 'si'
+ String.Other: "", # class: 'sx'
+ String.Regex: "", # class: 'sr'
+ String.Single: "", # class: 's1'
+ String.Symbol: "", # class: 'ss'
+
+ Generic: "", # class: 'g'
+ Generic.Deleted: RED, # class: 'gd',
+ Generic.Emph: "italic", # class: 'ge'
+ Generic.Error: "", # class: 'gr'
+ Generic.Heading: "bold " + FOREGROUND, # class: 'gh'
+ Generic.Inserted: GREEN, # class: 'gi'
+ Generic.Output: "", # class: 'go'
+ Generic.Prompt: "bold " + COMMENT, # class: 'gp'
+ Generic.Strong: "bold", # class: 'gs'
+ Generic.Subheading: "bold " + AQUA, # class: 'gu'
+ Generic.Traceback: "", # class: 'gt'
+ }
diff --git a/pygments/styles/paraiso-light.py b/pygments/styles/paraiso-light.py
new file mode 100644
index 00000000..7ed9f682
--- /dev/null
+++ b/pygments/styles/paraiso-light.py
@@ -0,0 +1,119 @@
+# -*- coding: utf-8 -*-
+"""
+Paraíso (Light)
+by Jan T. Sott
+
+Pygments template by Jan T. Sott (https://github.com/idleberg)
+Created with Base16 Builder by Chris Kempson (https://github.com/chriskempson/base16-builder)
+"""
+
+from pygments.style import Style
+from pygments.token import Keyword, Name, Comment, String, Error, Text, \
+ Number, Operator, Generic, Whitespace, Punctuation, Other, Literal
+
+
+BACKGROUND = "#e7e9db"
+CURRENT_LINE = "#b9b6b0"
+SELECTION = "#a39e9b"
+FOREGROUND = "#2f1e2e"
+COMMENT = "#8d8687"
+RED = "#ef6155"
+ORANGE = "#f99b15"
+YELLOW = "#fec418"
+GREEN = "#48b685"
+AQUA = "#5bc4bf"
+BLUE = "#06b6ef"
+PURPLE = "#815ba4"
+
+
+class paraiso_light(Style):
+
+ default_style = ''
+
+ background_color = BACKGROUND
+ highlight_color = SELECTION
+
+ background_color = BACKGROUND
+ highlight_color = SELECTION
+
+ styles = {
+ # No corresponding class for the following:
+ Text: FOREGROUND, # class: ''
+ Whitespace: "", # class: 'w'
+ Error: RED, # class: 'err'
+ Other: "", # class 'x'
+
+ Comment: COMMENT, # class: 'c'
+ Comment.Multiline: "", # class: 'cm'
+ Comment.Preproc: "", # class: 'cp'
+ Comment.Single: "", # class: 'c1'
+ Comment.Special: "", # class: 'cs'
+
+ Keyword: PURPLE, # class: 'k'
+ Keyword.Constant: "", # class: 'kc'
+ Keyword.Declaration: "", # class: 'kd'
+ Keyword.Namespace: AQUA, # class: 'kn'
+ Keyword.Pseudo: "", # class: 'kp'
+ Keyword.Reserved: "", # class: 'kr'
+ Keyword.Type: YELLOW, # class: 'kt'
+
+ Operator: AQUA, # class: 'o'
+ Operator.Word: "", # class: 'ow' - like keywords
+
+ Punctuation: FOREGROUND, # class: 'p'
+
+ Name: FOREGROUND, # class: 'n'
+ Name.Attribute: BLUE, # class: 'na' - to be revised
+ Name.Builtin: "", # class: 'nb'
+ Name.Builtin.Pseudo: "", # class: 'bp'
+ Name.Class: YELLOW, # class: 'nc' - to be revised
+ Name.Constant: RED, # class: 'no' - to be revised
+ Name.Decorator: AQUA, # class: 'nd' - to be revised
+ Name.Entity: "", # class: 'ni'
+ Name.Exception: RED, # class: 'ne'
+ Name.Function: BLUE, # class: 'nf'
+ Name.Property: "", # class: 'py'
+ Name.Label: "", # class: 'nl'
+ Name.Namespace: YELLOW, # class: 'nn' - to be revised
+ Name.Other: BLUE, # class: 'nx'
+ Name.Tag: AQUA, # class: 'nt' - like a keyword
+ Name.Variable: RED, # class: 'nv' - to be revised
+ Name.Variable.Class: "", # class: 'vc' - to be revised
+ Name.Variable.Global: "", # class: 'vg' - to be revised
+ Name.Variable.Instance: "", # class: 'vi' - to be revised
+
+ Number: ORANGE, # class: 'm'
+ Number.Float: "", # class: 'mf'
+ Number.Hex: "", # class: 'mh'
+ Number.Integer: "", # class: 'mi'
+ Number.Integer.Long: "", # class: 'il'
+ Number.Oct: "", # class: 'mo'
+
+ Literal: ORANGE, # class: 'l'
+ Literal.Date: GREEN, # class: 'ld'
+
+ String: GREEN, # class: 's'
+ String.Backtick: "", # class: 'sb'
+ String.Char: FOREGROUND, # class: 'sc'
+ String.Doc: COMMENT, # class: 'sd' - like a comment
+ String.Double: "", # class: 's2'
+ String.Escape: ORANGE, # class: 'se'
+ String.Heredoc: "", # class: 'sh'
+ String.Interpol: ORANGE, # class: 'si'
+ String.Other: "", # class: 'sx'
+ String.Regex: "", # class: 'sr'
+ String.Single: "", # class: 's1'
+ String.Symbol: "", # class: 'ss'
+
+ Generic: "", # class: 'g'
+ Generic.Deleted: RED, # class: 'gd',
+ Generic.Emph: "italic", # class: 'ge'
+ Generic.Error: "", # class: 'gr'
+ Generic.Heading: "bold " + FOREGROUND, # class: 'gh'
+ Generic.Inserted: GREEN, # class: 'gi'
+ Generic.Output: "", # class: 'go'
+ Generic.Prompt: "bold " + COMMENT, # class: 'gp'
+ Generic.Strong: "bold", # class: 'gs'
+ Generic.Subheading: "bold " + AQUA, # class: 'gu'
+ Generic.Traceback: "", # class: 'gt'
+ }
diff --git a/pygments/token.py b/pygments/token.py
index f6c3066d..c40ffd33 100644
--- a/pygments/token.py
+++ b/pygments/token.py
@@ -49,6 +49,7 @@ Token = _TokenType()
# Special token types
Text = Token.Text
Whitespace = Text.Whitespace
+Escape = Token.Escape
Error = Token.Error
# Text that doesn't belong to this lexer (e.g. HTML in PHP)
Other = Token.Other
@@ -116,6 +117,7 @@ STANDARD_TYPES = {
Text: '',
Whitespace: 'w',
+ Escape: 'esc',
Error: 'err',
Other: 'x',