summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnteru <bitbucket@ca.sh13.net>2018-11-27 20:01:27 +0000
committerAnteru <bitbucket@ca.sh13.net>2018-11-27 20:01:27 +0000
commit85239f21e00837e5aac77f532ea64aa9bc14ac3f (patch)
tree092d720228246797e825c5cbf73dec027da574de
parented3bd801548a301071823a38ce6e19aa18e8215b (diff)
parentda957c6a2ae6f77f92e060e926627e762d6d6de9 (diff)
downloadpygments-85239f21e00837e5aac77f532ea64aa9bc14ac3f.tar.gz
Merged in kevinastone/pygments-main (pull request #720)
Added pep 515 support to the python lexer
-rw-r--r--.hgignore1
-rw-r--r--AUTHORS4
-rw-r--r--CHANGES23
-rw-r--r--Makefile6
-rw-r--r--bitbucket-pipelines.yml34
-rw-r--r--doc/docs/quickstart.rst4
-rw-r--r--doc/faq.rst4
-rw-r--r--doc/languages.rst2
-rw-r--r--pygments/__init__.py2
-rw-r--r--pygments/lexers/_csound_builtins.py2990
-rw-r--r--pygments/lexers/_lua_builtins.py2
-rw-r--r--pygments/lexers/_mapping.py4
-rw-r--r--pygments/lexers/ampl.py4
-rw-r--r--pygments/lexers/clean.py380
-rw-r--r--pygments/lexers/configs.py22
-rw-r--r--pygments/lexers/csound.py453
-rw-r--r--pygments/lexers/css.py23
-rw-r--r--pygments/lexers/graphics.py156
-rw-r--r--pygments/lexers/javascript.py6
-rw-r--r--pygments/lexers/jvm.py2
-rw-r--r--pygments/lexers/lisp.py78
-rw-r--r--pygments/lexers/markup.py7
-rw-r--r--pygments/lexers/python.py2
-rw-r--r--pygments/lexers/r.py274
-rw-r--r--pygments/lexers/rust.py2
-rw-r--r--pygments/lexers/sql.py14
-rw-r--r--pygments/lexers/webmisc.py3
-rw-r--r--pygments/lexers/xorg.py5
-rw-r--r--pygments/plugin.py4
-rw-r--r--pygments/sphinxext.py2
-rw-r--r--scripts/release-checklist24
-rwxr-xr-xsetup.py2
-rw-r--r--tests/examplefiles/StdGeneric.icl44
-rw-r--r--tests/examplefiles/docker.docker33
-rw-r--r--tests/examplefiles/example.hlsl168
-rw-r--r--tests/examplefiles/fennelview.fnl156
-rw-r--r--tests/examplefiles/test.csd264
-rw-r--r--tests/examplefiles/test.orc306
-rw-r--r--tests/examplefiles/test.sco32
-rw-r--r--tests/test_csound.py480
-rw-r--r--tests/test_markdown_lexer.py31
-rw-r--r--tests/test_r.py70
-rw-r--r--tox.ini2
43 files changed, 3526 insertions, 2599 deletions
diff --git a/.hgignore b/.hgignore
index 850baf13..b564df83 100644
--- a/.hgignore
+++ b/.hgignore
@@ -8,6 +8,7 @@ syntax: glob
.project
.tags
.tox
+.cache/
Pygments.egg-info/*
TAGS
build/*
diff --git a/AUTHORS b/AUTHORS
index f9ba2675..18e642f1 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -72,7 +72,7 @@ Other contributors, listed alphabetically, are:
* Alex Gosse -- TrafficScript lexer
* Patrick Gotthardt -- PHP namespaces support
* Olivier Guibe -- Asymptote lexer
-* Jordi Gutiérrez Hermoso -- Octave lexer
+* Phil Hagelberg -- Fennel lexer
* Florian Hahn -- Boogie lexer
* Martin Harriman -- SNOBOL lexer
* Matthew Harrison -- SVG formatter
@@ -81,6 +81,7 @@ Other contributors, listed alphabetically, are:
* Aslak Hellesøy -- Gherkin lexer
* Greg Hendershott -- Racket lexer
* Justin Hendrick -- ParaSail lexer
+* Jordi Gutiérrez Hermoso -- Octave lexer
* David Hess, Fish Software, Inc. -- Objective-J lexer
* Varun Hiremath -- Debian control lexer
* Rob Hoelz -- Perl 6 lexer
@@ -160,6 +161,7 @@ Other contributors, listed alphabetically, are:
* Elias Rabel -- Fortran fixed form lexer
* raichoo -- Idris lexer
* Kashif Rasul -- CUDA lexer
+* Nathan Reed -- HLSL lexer
* Justin Reidy -- MXML lexer
* Norman Richards -- JSON lexer
* Corey Richardson -- Rust lexer updates
diff --git a/CHANGES b/CHANGES
index 0bab9118..c82ca1cf 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,9 +6,30 @@ Issue numbers refer to the tracker at
pull request numbers to the requests at
<https://bitbucket.org/birkenfeld/pygments-main/pull-requests/merged>.
+Version 2.3.0
+-------------
+(released Nov 25, 2018)
+
+- Added lexers:
+
+ * Fennel (PR#783)
+ * HLSL (PR#675)
+
+- Updated lexers:
+
+ * Dockerfile (PR#714)
+
+- Minimum Python versions changed to 2.7 and 3.5
+- Added support for Python 3.7 generator changes (PR#772)
+- Fix incorrect token type in SCSS for single-quote strings (#1322)
+- Use `terminal256` formatter if `TERM` contains `256` (PR#666)
+- Fix incorrect handling of GitHub style fences in Markdown (PR#741, #1389)
+- Fix `%a` not being highlighted in Python3 strings (PR#727)
+
+
Version 2.2.0
-------------
-(release Jan 22, 2017)
+(released Jan 22, 2017)
- Added lexers:
diff --git a/Makefile b/Makefile
index 82c4a124..878b94b7 100644
--- a/Makefile
+++ b/Makefile
@@ -63,3 +63,9 @@ tox-test:
tox-test-coverage:
@tox -- --with-coverage --cover-package=pygments --cover-erase $(TEST)
+
+RLMODULES = pygments.lexers
+
+regexlint:
+ @if [ -z "$(REGEXLINT)" ]; then echo "Please set REGEXLINT=checkout path"; exit 1; fi
+ PYTHONPATH=`pwd`:$(REGEXLINT) $(REGEXLINT)/regexlint/cmdline.py $(RLMODULES)
diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml
new file mode 100644
index 00000000..fc745f0f
--- /dev/null
+++ b/bitbucket-pipelines.yml
@@ -0,0 +1,34 @@
+pipelines:
+ default:
+ - step:
+ name: Test on Python 2.7
+ image: python:2.7
+ caches:
+ - pip
+ script:
+ - pip install -r requirements.txt
+ - tox -e py27
+ - step:
+ name: Test on Python 3.4
+ image: python:3.4
+ caches:
+ - pip
+ script:
+ - pip install -r requirements.txt
+ - tox -e py34
+ - step:
+ name: Test on Python 3.6
+ image: python:3.6
+ caches:
+ - pip
+ script:
+ - pip install -r requirements.txt
+ - tox -e py36
+ - step:
+ name: Test on Python 3.7
+ image: python:3.7
+ caches:
+ - pip
+ script:
+ - pip install -r requirements.txt
+ - tox -e py37
diff --git a/doc/docs/quickstart.rst b/doc/docs/quickstart.rst
index dba7698a..3a823e7f 100644
--- a/doc/docs/quickstart.rst
+++ b/doc/docs/quickstart.rst
@@ -39,7 +39,7 @@ Here is a small example for highlighting Python code:
from pygments.formatters import HtmlFormatter
code = 'print "Hello World"'
- print highlight(code, PythonLexer(), HtmlFormatter())
+ print(highlight(code, PythonLexer(), HtmlFormatter()))
which prints something like this:
@@ -56,7 +56,7 @@ can be produced by:
.. sourcecode:: python
- print HtmlFormatter().get_style_defs('.highlight')
+ print(HtmlFormatter().get_style_defs('.highlight'))
The argument to :func:`get_style_defs` is used as an additional CSS selector:
the output may look like this:
diff --git a/doc/faq.rst b/doc/faq.rst
index f375828b..172929e0 100644
--- a/doc/faq.rst
+++ b/doc/faq.rst
@@ -35,8 +35,8 @@ and in this case, source code!
What are the system requirements?
---------------------------------
-Pygments only needs a standard Python install, version 2.6 or higher or version
-3.3 or higher for Python 3. No additional libraries are needed.
+Pygments only needs a standard Python install, version 2.7 or higher or version
+3.5 or higher for Python 3. No additional libraries are needed.
How can I use Pygments?
-----------------------
diff --git a/doc/languages.rst b/doc/languages.rst
index 7fa8eb2f..e5399403 100644
--- a/doc/languages.rst
+++ b/doc/languages.rst
@@ -37,6 +37,7 @@ Programming languages
* `Ezhil <http://ezhillang.org>`_ Ezhil - A Tamil programming language
* Factor
* Fancy
+* `Fennel <https://fennel-lang.org/>`_
* Fortran
* F#
* GAP
@@ -44,6 +45,7 @@ Programming languages
* GL shaders
* Groovy
* `Haskell <http://www.haskell.org>`_ (incl. Literate Haskell)
+* HLSL
* IDL
* Io
* Java
diff --git a/pygments/__init__.py b/pygments/__init__.py
index 394a85f2..19aafdeb 100644
--- a/pygments/__init__.py
+++ b/pygments/__init__.py
@@ -29,7 +29,7 @@ import sys
from pygments.util import StringIO, BytesIO
-__version__ = '2.2.0'
+__version__ = '2.3.0'
__docformat__ = 'restructuredtext'
__all__ = ['lex', 'format', 'highlight']
diff --git a/pygments/lexers/_csound_builtins.py b/pygments/lexers/_csound_builtins.py
index e5a9aaf7..56b5a452 100644
--- a/pygments/lexers/_csound_builtins.py
+++ b/pygments/lexers/_csound_builtins.py
@@ -3,1344 +3,1658 @@
pygments.lexers._csound_builtins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2018 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-# Opcodes in Csound 6.05 from
-# csound --list-opcodes
-# except
-# cggoto <http://www.csounds.com/manual/html/cggoto.html>
-# cigoto <http://www.csounds.com/manual/html/cigoto.html>
-# cingoto (undocumented)
-# ckgoto <http://www.csounds.com/manual/html/ckgoto.html>
-# cngoto <http://www.csounds.com/manual/html/cngoto.html>
-# endin <http://www.csounds.com/manual/html/endin.html
-# endop <http://www.csounds.com/manual/html/endop.html
-# goto <http://www.csounds.com/manual/html/goto.html>
-# igoto <http://www.csounds.com/manual/html/igoto.html>
-# instr <http://www.csounds.com/manual/html/instr.html>
-# kgoto <http://www.csounds.com/manual/html/kgoto.html>
-# loop_ge <http://www.csounds.com/manual/html/loop_ge.html>
-# loop_gt <http://www.csounds.com/manual/html/loop_gt.html>
-# loop_le <http://www.csounds.com/manual/html/loop_le.html>
-# loop_lt <http://www.csounds.com/manual/html/loop_lt.html>
-# opcode <http://www.csounds.com/manual/html/opcode.html>
-# return <http://www.csounds.com/manual/html/return.html>
-# rigoto <http://www.csounds.com/manual/html/rigoto.html>
-# tigoto <http://www.csounds.com/manual/html/tigoto.html>
-# timout <http://www.csounds.com/manual/html/timout.html>
-# which are treated as keywords; the scoreline opcodes
-# scoreline <http://www.csounds.com/manual/html/scoreline.html>
-# scoreline_i <http://www.csounds.com/manual/html/scoreline_i.html>
-# which allow Csound Score highlighting; the pyrun opcodes
-# <http://www.csounds.com/manual/html/pyrun.html>
-# pylrun
-# pylruni
-# pylrunt
-# pyrun
-# pyruni
-# pyrunt
-# which allow Python highlighting; and the Lua opcodes
-# lua_exec <http://www.csounds.com/manual/html/lua_exec.html>
-# lua_opdef <http://www.csounds.com/manual/html/lua_opdef.html>
-# which allow Lua highlighting.
-OPCODES = set((
- 'ATSadd',
- 'ATSaddnz',
- 'ATSbufread',
- 'ATScross',
- 'ATSinfo',
- 'ATSinterpread',
- 'ATSpartialtap',
- 'ATSread',
- 'ATSreadnz',
- 'ATSsinnoi',
- 'FLbox',
- 'FLbutBank',
- 'FLbutton',
- 'FLcloseButton',
- 'FLcolor',
- 'FLcolor2',
- 'FLcount',
- 'FLexecButton',
- 'FLgetsnap',
- 'FLgroup',
- 'FLgroupEnd',
- 'FLgroup_end',
- 'FLhide',
- 'FLhvsBox',
- 'FLhvsBoxSetValue',
- 'FLjoy',
- 'FLkeyIn',
- 'FLknob',
- 'FLlabel',
- 'FLloadsnap',
- 'FLmouse',
- 'FLpack',
- 'FLpackEnd',
- 'FLpack_end',
- 'FLpanel',
- 'FLpanelEnd',
- 'FLpanel_end',
- 'FLprintk',
- 'FLprintk2',
- 'FLroller',
- 'FLrun',
- 'FLsavesnap',
- 'FLscroll',
- 'FLscrollEnd',
- 'FLscroll_end',
- 'FLsetAlign',
- 'FLsetBox',
- 'FLsetColor',
- 'FLsetColor2',
- 'FLsetFont',
- 'FLsetPosition',
- 'FLsetSize',
- 'FLsetSnapGroup',
- 'FLsetText',
- 'FLsetTextColor',
- 'FLsetTextSize',
- 'FLsetTextType',
- 'FLsetVal',
- 'FLsetVal_i',
- 'FLsetVali',
- 'FLsetsnap',
- 'FLshow',
- 'FLslidBnk',
- 'FLslidBnk2',
- 'FLslidBnk2Set',
- 'FLslidBnk2Setk',
- 'FLslidBnkGetHandle',
- 'FLslidBnkSet',
- 'FLslidBnkSetk',
- 'FLslider',
- 'FLtabs',
- 'FLtabsEnd',
- 'FLtabs_end',
- 'FLtext',
- 'FLupdate',
- 'FLvalue',
- 'FLvkeybd',
- 'FLvslidBnk',
- 'FLvslidBnk2',
- 'FLxyin',
- 'MixerClear',
- 'MixerGetLevel',
- 'MixerReceive',
- 'MixerSend',
- 'MixerSetLevel',
- 'MixerSetLevel_i',
- 'OSCinit',
- 'OSClisten',
- 'OSCsend',
- 'a',
- 'abs',
- 'active',
- 'adsr',
- 'adsyn',
- 'adsynt',
- 'adsynt2',
- 'aftouch',
- 'alpass',
- 'alwayson',
- 'ampdb',
- 'ampdbfs',
- 'ampmidi',
- 'ampmidid',
- 'areson',
- 'aresonk',
- 'array',
- 'atone',
- 'atonek',
- 'atonex',
- 'babo',
- 'balance',
- 'bamboo',
- 'barmodel',
- 'bbcutm',
- 'bbcuts',
- 'betarand',
- 'bexprnd',
- 'bformdec',
- 'bformdec1',
- 'bformenc',
- 'bformenc1',
- 'binit',
- 'biquad',
- 'biquada',
- 'birnd',
- 'bqrez',
- 'buchla',
- 'butbp',
- 'butbr',
- 'buthp',
- 'butlp',
- 'butterbp',
- 'butterbr',
- 'butterhp',
- 'butterlp',
- 'button',
- 'buzz',
- 'c2r',
- 'cabasa',
- 'cauchy',
- 'cauchyi',
- 'ceil',
- 'cell',
- 'cent',
- 'centroid',
- 'ceps',
- #'cggoto',
- 'chanctrl',
- 'changed',
- 'chani',
- 'chano',
- 'chebyshevpoly',
- 'checkbox',
- 'chn_S',
- 'chn_a',
- 'chn_k',
- 'chnclear',
- 'chnexport',
- 'chnget',
- 'chnmix',
- 'chnparams',
- 'chnset',
- 'chuap',
- #'cigoto',
- #'cingoto',
- #'ckgoto',
- 'clear',
- 'clfilt',
- 'clip',
- 'clockoff',
- 'clockon',
- 'cmplxprod',
- #'cngoto',
- 'comb',
- 'combinv',
- 'compilecsd',
- 'compileorc',
- 'compilestr',
- 'compress',
- 'connect',
- 'control',
- 'convle',
- 'convolve',
- 'copy2ftab',
- 'copy2ttab',
- 'copya2ftab',
- 'copyf2array',
- 'cos',
- 'cosh',
- 'cosinv',
- 'cosseg',
- 'cossegb',
- 'cossegr',
- 'cps2pch',
- 'cpsmidi',
- 'cpsmidib',
- 'cpsmidinn',
- 'cpsoct',
- 'cpspch',
- 'cpstmid',
- 'cpstun',
- 'cpstuni',
- 'cpsxpch',
- 'cpuprc',
- 'cross2',
- 'crossfm',
- 'crossfmi',
- 'crossfmpm',
- 'crossfmpmi',
- 'crosspm',
- 'crosspmi',
- 'crunch',
- 'ctlchn',
- 'ctrl14',
- 'ctrl21',
- 'ctrl7',
- 'ctrlinit',
- 'cuserrnd',
- 'dam',
- 'date',
- 'dates',
- 'db',
- 'dbamp',
- 'dbfsamp',
- 'dcblock',
- 'dcblock2',
- 'dconv',
- 'delay',
- 'delay1',
- 'delayk',
- 'delayr',
- 'delayw',
- 'deltap',
- 'deltap3',
- 'deltapi',
- 'deltapn',
- 'deltapx',
- 'deltapxw',
- 'denorm',
- 'diff',
- 'diskgrain',
- 'diskin',
- 'diskin2',
- 'dispfft',
- 'display',
- 'distort',
- 'distort1',
- 'divz',
- 'doppler',
- 'downsamp',
- 'dripwater',
- 'dumpk',
- 'dumpk2',
- 'dumpk3',
- 'dumpk4',
- 'duserrnd',
- 'dust',
- 'dust2',
- #'endin',
- #'endop',
- 'envlpx',
- 'envlpxr',
- 'ephasor',
- 'eqfil',
- 'evalstr',
- 'event',
- 'event_i',
- 'exciter',
- 'exitnow',
- 'exp',
- 'expcurve',
- 'expon',
- 'exprand',
- 'exprandi',
- 'expseg',
- 'expsega',
- 'expsegb',
- 'expsegba',
- 'expsegr',
- 'fareylen',
- 'fareyleni',
- 'faustaudio',
- 'faustcompile',
- 'faustctl',
- 'faustgen',
- 'fft',
- 'fftinv',
- 'ficlose',
- 'filebit',
- 'filelen',
- 'filenchnls',
- 'filepeak',
- 'filesr',
- 'filevalid',
- 'fillarray',
- 'filter2',
- 'fin',
- 'fini',
- 'fink',
- 'fiopen',
- 'flanger',
- 'flashtxt',
- 'flooper',
- 'flooper2',
- 'floor',
- 'fluidAllOut',
- 'fluidCCi',
- 'fluidCCk',
- 'fluidControl',
- 'fluidEngine',
- 'fluidLoad',
- 'fluidNote',
- 'fluidOut',
- 'fluidProgramSelect',
- 'fluidSetInterpMethod',
- 'fmb3',
- 'fmbell',
- 'fmmetal',
- 'fmpercfl',
- 'fmrhode',
- 'fmvoice',
- 'fmwurlie',
- 'fof',
- 'fof2',
- 'fofilter',
- 'fog',
- 'fold',
- 'follow',
- 'follow2',
- 'foscil',
- 'foscili',
- 'fout',
- 'fouti',
- 'foutir',
- 'foutk',
- 'fprintks',
- 'fprints',
- 'frac',
- 'fractalnoise',
- 'freeverb',
- 'ftchnls',
- 'ftconv',
- 'ftcps',
- 'ftfree',
- 'ftgen',
- 'ftgenonce',
- 'ftgentmp',
- 'ftlen',
- 'ftload',
- 'ftloadk',
- 'ftlptim',
- 'ftmorf',
- 'ftresize',
- 'ftresizei',
- 'ftsave',
- 'ftsavek',
- 'ftsr',
- 'gain',
- 'gainslider',
- 'gauss',
- 'gaussi',
- 'gausstrig',
- 'gbuzz',
- 'genarray',
- 'genarray_i',
- 'gendy',
- 'gendyc',
- 'gendyx',
- 'getcfg',
- 'getcol',
- 'getrow',
- 'gogobel',
- #'goto',
- 'grain',
- 'grain2',
- 'grain3',
- 'granule',
- 'guiro',
- 'harmon',
- 'harmon2',
- 'harmon3',
- 'harmon4',
- 'hdf5read',
- 'hdf5write',
- 'hilbert',
- 'hrtfearly',
- 'hrtfer',
- 'hrtfmove',
- 'hrtfmove2',
- 'hrtfreverb',
- 'hrtfstat',
- 'hsboscil',
- 'hvs1',
- 'hvs2',
- 'hvs3',
- 'i',
- 'iceps',
- #'igoto',
- 'ihold',
- 'imagecreate',
- 'imagefree',
- 'imagegetpixel',
- 'imageload',
- 'imagesave',
- 'imagesetpixel',
- 'imagesize',
- 'in',
- 'in32',
- 'inch',
- 'inh',
- 'init',
- 'initc14',
- 'initc21',
- 'initc7',
- 'inleta',
- 'inletf',
- 'inletk',
- 'inletkid',
- 'inletv',
- 'ino',
- 'inq',
- 'inrg',
- 'ins',
- 'insglobal',
- 'insremot',
- #'instr',
- 'int',
- 'integ',
- 'interp',
- 'invalue',
- 'inx',
- 'inz',
- 'jitter',
- 'jitter2',
- 'jspline',
- 'k',
- #'kgoto',
- 'ktableseg',
- 'lenarray',
- 'lentab',
- 'lfo',
- 'limit',
- 'line',
- 'linen',
- 'linenr',
- 'lineto',
- 'linrand',
- 'linseg',
- 'linsegb',
- 'linsegr',
- 'locsend',
- 'locsig',
- 'log',
- 'log10',
- 'log2',
- 'logbtwo',
- 'logcurve',
- #'loop_ge',
- #'loop_gt',
- #'loop_le',
- #'loop_lt',
- 'loopseg',
- 'loopsegp',
- 'looptseg',
- 'loopxseg',
- 'lorenz',
- 'loscil',
- 'loscil3',
- 'loscilx',
- 'lowpass2',
- 'lowres',
- 'lowresx',
- 'lpf18',
- 'lpform',
- 'lpfreson',
- 'lphasor',
- 'lpinterp',
- 'lposcil',
- 'lposcil3',
- 'lposcila',
- 'lposcilsa',
- 'lposcilsa2',
- 'lpread',
- 'lpreson',
- 'lpshold',
- 'lpsholdp',
- 'lpslot',
- #'lua_exec',
- 'lua_ikopcall',
- #'lua_opdef',
- 'mac',
- 'maca',
- 'madsr',
- 'mags',
- 'mandel',
- 'mandol',
- 'maparray',
- 'maparray_i',
- 'marimba',
- 'massign',
- 'max',
- 'max_k',
- 'maxabs',
- 'maxabsaccum',
- 'maxaccum',
- 'maxalloc',
- 'maxarray',
- 'maxtab',
- 'mclock',
- 'mdelay',
- 'median',
- 'mediank',
- 'metro',
- 'midglobal',
- 'midic14',
- 'midic21',
- 'midic7',
- 'midichannelaftertouch',
- 'midichn',
- 'midicontrolchange',
- 'midictrl',
- 'mididefault',
- 'midifilestatus',
- 'midiin',
- 'midinoteoff',
- 'midinoteoncps',
- 'midinoteonkey',
- 'midinoteonoct',
- 'midinoteonpch',
- 'midion',
- 'midion2',
- 'midiout',
- 'midipgm',
- 'midipitchbend',
- 'midipolyaftertouch',
- 'midiprogramchange',
- 'miditempo',
- 'midremot',
- 'min',
- 'minabs',
- 'minabsaccum',
- 'minaccum',
- 'minarray',
- 'mincer',
- 'mintab',
- 'mirror',
- 'mode',
- 'modmatrix',
- 'monitor',
- 'moog',
- 'moogladder',
- 'moogvcf',
- 'moogvcf2',
- 'moscil',
- 'mp3bitrate',
- 'mp3in',
- 'mp3len',
- 'mp3nchnls',
- 'mp3sr',
- 'mpulse',
- 'mrtmsg',
- 'multitap',
- 'mute',
- 'mxadsr',
- 'nestedap',
- 'nlalp',
- 'nlfilt',
- 'nlfilt2',
- 'noise',
- 'noteoff',
- 'noteon',
- 'noteondur',
- 'noteondur2',
- 'notnum',
- 'nreverb',
- 'nrpn',
- 'nsamp',
- 'nstance',
- 'nstrnum',
- 'ntrpol',
- 'octave',
- 'octcps',
- 'octmidi',
- 'octmidib',
- 'octmidinn',
- 'octpch',
- #'opcode',
- 'oscbnk',
- 'oscil',
- 'oscil1',
- 'oscil1i',
- 'oscil3',
- 'oscili',
- 'oscilikt',
- 'osciliktp',
- 'oscilikts',
- 'osciln',
- 'oscils',
- 'oscilx',
- 'out',
- 'out32',
- 'outc',
- 'outch',
- 'outh',
- 'outiat',
- 'outic',
- 'outic14',
- 'outipat',
- 'outipb',
- 'outipc',
- 'outkat',
- 'outkc',
- 'outkc14',
- 'outkpat',
- 'outkpb',
- 'outkpc',
- 'outleta',
- 'outletf',
- 'outletk',
- 'outletkid',
- 'outletv',
- 'outo',
- 'outq',
- 'outq1',
- 'outq2',
- 'outq3',
- 'outq4',
- 'outrg',
- 'outs',
- 'outs1',
- 'outs2',
- 'outvalue',
- 'outx',
- 'outz',
- 'p',
- 'pan',
- 'pan2',
- 'pareq',
- 'partials',
- 'partikkel',
- 'partikkelget',
- 'partikkelset',
- 'partikkelsync',
- 'passign',
- 'pcauchy',
- 'pchbend',
- 'pchmidi',
- 'pchmidib',
- 'pchmidinn',
- 'pchoct',
- 'pconvolve',
- 'pcount',
- 'pdclip',
- 'pdhalf',
- 'pdhalfy',
- 'peak',
- 'pgmassign',
- 'pgmchn',
- 'phaser1',
- 'phaser2',
- 'phasor',
- 'phasorbnk',
- 'phs',
- 'pindex',
- 'pinker',
- 'pinkish',
- 'pitch',
- 'pitchac',
- 'pitchamdf',
- 'planet',
- 'platerev',
- 'plltrack',
- 'pluck',
- 'poisson',
- 'pol2rect',
- 'polyaft',
- 'polynomial',
- 'pop',
- 'pop_f',
- 'port',
- 'portk',
- 'poscil',
- 'poscil3',
- 'pow',
- 'powershape',
- 'powoftwo',
- 'prealloc',
- 'prepiano',
- 'print',
- 'print_type',
- 'printf',
- 'printf_i',
- 'printk',
- 'printk2',
- 'printks',
- 'printks2',
- 'prints',
- 'product',
- 'pset',
- 'ptable',
- 'ptable3',
- 'ptablei',
- 'ptableiw',
- 'ptablew',
- 'ptrack',
- 'push',
- 'push_f',
- 'puts',
- 'pvadd',
- 'pvbufread',
- 'pvcross',
- 'pvinterp',
- 'pvoc',
- 'pvread',
- 'pvs2array',
- 'pvs2tab',
- 'pvsadsyn',
- 'pvsanal',
- 'pvsarp',
- 'pvsbandp',
- 'pvsbandr',
- 'pvsbin',
- 'pvsblur',
- 'pvsbuffer',
- 'pvsbufread',
- 'pvsbufread2',
- 'pvscale',
- 'pvscent',
- 'pvsceps',
- 'pvscross',
- 'pvsdemix',
- 'pvsdiskin',
- 'pvsdisp',
- 'pvsenvftw',
- 'pvsfilter',
- 'pvsfread',
- 'pvsfreeze',
- 'pvsfromarray',
- 'pvsftr',
- 'pvsftw',
- 'pvsfwrite',
- 'pvsgain',
- 'pvsgendy',
- 'pvshift',
- 'pvsifd',
- 'pvsin',
- 'pvsinfo',
- 'pvsinit',
- 'pvslock',
- 'pvsmaska',
- 'pvsmix',
- 'pvsmooth',
- 'pvsmorph',
- 'pvsosc',
- 'pvsout',
- 'pvspitch',
- 'pvstanal',
- 'pvstencil',
- 'pvsvoc',
- 'pvswarp',
- 'pvsynth',
- 'pwd',
- 'pyassign',
- 'pyassigni',
- 'pyassignt',
- 'pycall',
- 'pycall1',
- 'pycall1i',
- 'pycall1t',
- 'pycall2',
- 'pycall2i',
- 'pycall2t',
- 'pycall3',
- 'pycall3i',
- 'pycall3t',
- 'pycall4',
- 'pycall4i',
- 'pycall4t',
- 'pycall5',
- 'pycall5i',
- 'pycall5t',
- 'pycall6',
- 'pycall6i',
- 'pycall6t',
- 'pycall7',
- 'pycall7i',
- 'pycall7t',
- 'pycall8',
- 'pycall8i',
- 'pycall8t',
- 'pycalli',
- 'pycalln',
- 'pycallni',
- 'pycallt',
- 'pyeval',
- 'pyevali',
- 'pyevalt',
- 'pyexec',
- 'pyexeci',
- 'pyexect',
- 'pyinit',
- 'pylassign',
- 'pylassigni',
- 'pylassignt',
- 'pylcall',
- 'pylcall1',
- 'pylcall1i',
- 'pylcall1t',
- 'pylcall2',
- 'pylcall2i',
- 'pylcall2t',
- 'pylcall3',
- 'pylcall3i',
- 'pylcall3t',
- 'pylcall4',
- 'pylcall4i',
- 'pylcall4t',
- 'pylcall5',
- 'pylcall5i',
- 'pylcall5t',
- 'pylcall6',
- 'pylcall6i',
- 'pylcall6t',
- 'pylcall7',
- 'pylcall7i',
- 'pylcall7t',
- 'pylcall8',
- 'pylcall8i',
- 'pylcall8t',
- 'pylcalli',
- 'pylcalln',
- 'pylcallni',
- 'pylcallt',
- 'pyleval',
- 'pylevali',
- 'pylevalt',
- 'pylexec',
- 'pylexeci',
- 'pylexect',
- #'pylrun',
- #'pylruni',
- #'pylrunt',
- #'pyrun',
- #'pyruni',
- #'pyrunt',
- 'qinf',
- 'qnan',
- 'r2c',
- 'rand',
- 'randh',
- 'randi',
- 'random',
- 'randomh',
- 'randomi',
- 'rbjeq',
- 'readclock',
- 'readf',
- 'readfi',
- 'readk',
- 'readk2',
- 'readk3',
- 'readk4',
- 'readks',
- 'readscore',
- 'readscratch',
- 'rect2pol',
- 'reinit',
- 'release',
- 'remoteport',
- 'remove',
- 'repluck',
- 'reson',
- 'resonk',
- 'resonr',
- 'resonx',
- 'resonxk',
- 'resony',
- 'resonz',
- 'resyn',
- #'return',
- 'reverb',
- 'reverb2',
- 'reverbsc',
- 'rewindscore',
- 'rezzy',
- 'rfft',
- 'rifft',
- #'rigoto',
- 'rireturn',
- 'rms',
- 'rnd',
- 'rnd31',
- 'round',
- 'rspline',
- 'rtclock',
- 's16b14',
- 's32b14',
- 'samphold',
- 'sandpaper',
- 'scale',
- 'scalearray',
- 'scalet',
- 'scanhammer',
- 'scans',
- 'scantable',
- 'scanu',
- 'schedkwhen',
- 'schedkwhennamed',
- 'schedule',
- 'schedwhen',
- #'scoreline',
- #'scoreline_i',
- 'seed',
- 'sekere',
- 'semitone',
- 'sense',
- 'sensekey',
- 'seqtime',
- 'seqtime2',
- 'serialBegin',
- 'serialEnd',
- 'serialFlush',
- 'serialPrint',
- 'serialRead',
- 'serialWrite',
- 'serialWrite_i',
- 'setcol',
- 'setctrl',
- 'setksmps',
- 'setrow',
- 'setscorepos',
- 'sfilist',
- 'sfinstr',
- 'sfinstr3',
- 'sfinstr3m',
- 'sfinstrm',
- 'sfload',
- 'sflooper',
- 'sfpassign',
- 'sfplay',
- 'sfplay3',
- 'sfplay3m',
- 'sfplaym',
- 'sfplist',
- 'sfpreset',
- 'shaker',
- 'shiftin',
- 'shiftout',
- 'signalflowgraph',
- 'signum',
- 'sin',
- 'sinh',
- 'sininv',
- 'sinsyn',
- 'sleighbells',
- 'slicearray',
- 'slider16',
- 'slider16f',
- 'slider16table',
- 'slider16tablef',
- 'slider32',
- 'slider32f',
- 'slider32table',
- 'slider32tablef',
- 'slider64',
- 'slider64f',
- 'slider64table',
- 'slider64tablef',
- 'slider8',
- 'slider8f',
- 'slider8table',
- 'slider8tablef',
- 'sliderKawai',
- 'sndload',
- 'sndloop',
- 'sndwarp',
- 'sndwarpst',
- 'sockrecv',
- 'sockrecvs',
- 'socksend',
- 'socksends',
- 'soundin',
- 'soundout',
- 'soundouts',
- 'space',
- 'spat3d',
- 'spat3di',
- 'spat3dt',
- 'spdist',
- 'specaddm',
- 'specdiff',
- 'specdisp',
- 'specfilt',
- 'spechist',
- 'specptrk',
- 'specscal',
- 'specsum',
- 'spectrum',
- 'splitrig',
- 'sprintf',
- 'sprintfk',
- 'spsend',
- 'sqrt',
- 'stack',
- 'statevar',
- 'stix',
- 'strcat',
- 'strcatk',
- 'strchar',
- 'strchark',
- 'strcmp',
- 'strcmpk',
- 'strcpy',
- 'strcpyk',
- 'strecv',
- 'streson',
- 'strfromurl',
- 'strget',
- 'strindex',
- 'strindexk',
- 'strlen',
- 'strlenk',
- 'strlower',
- 'strlowerk',
- 'strrindex',
- 'strrindexk',
- 'strset',
- 'strsub',
- 'strsubk',
- 'strtod',
- 'strtodk',
- 'strtol',
- 'strtolk',
- 'strupper',
- 'strupperk',
- 'stsend',
- 'subinstr',
- 'subinstrinit',
- 'sum',
- 'sumarray',
- 'sumtab',
- 'svfilter',
- 'syncgrain',
- 'syncloop',
- 'syncphasor',
- 'system',
- 'system_i',
- 'tab',
- 'tab2pvs',
- 'tab_i',
- 'tabgen',
- 'table',
- 'table3',
- 'table3kt',
- 'tablecopy',
- 'tablefilter',
- 'tablefilteri',
- 'tablegpw',
- 'tablei',
- 'tableicopy',
- 'tableigpw',
- 'tableikt',
- 'tableimix',
- 'tableiw',
- 'tablekt',
- 'tablemix',
- 'tableng',
- 'tablera',
- 'tableseg',
- 'tableshuffle',
- 'tableshufflei',
- 'tablew',
- 'tablewa',
- 'tablewkt',
- 'tablexkt',
- 'tablexseg',
- 'tabmap',
- 'tabmap_i',
- 'tabmorph',
- 'tabmorpha',
- 'tabmorphak',
- 'tabmorphi',
- 'tabplay',
- 'tabrec',
- 'tabslice',
- 'tabsum',
- 'tabw',
- 'tabw_i',
- 'tambourine',
- 'tan',
- 'tanh',
- 'taninv',
- 'taninv2',
- 'tb0',
- 'tb0_init',
- 'tb1',
- 'tb10',
- 'tb10_init',
- 'tb11',
- 'tb11_init',
- 'tb12',
- 'tb12_init',
- 'tb13',
- 'tb13_init',
- 'tb14',
- 'tb14_init',
- 'tb15',
- 'tb15_init',
- 'tb1_init',
- 'tb2',
- 'tb2_init',
- 'tb3',
- 'tb3_init',
- 'tb4',
- 'tb4_init',
- 'tb5',
- 'tb5_init',
- 'tb6',
- 'tb6_init',
- 'tb7',
- 'tb7_init',
- 'tb8',
- 'tb8_init',
- 'tb9',
- 'tb9_init',
- 'tbvcf',
- 'tempest',
- 'tempo',
- 'temposcal',
- 'tempoval',
- #'tigoto',
- 'timedseq',
- 'timeinstk',
- 'timeinsts',
- 'timek',
- 'times',
- #'timout',
- 'tival',
- 'tlineto',
- 'tone',
- 'tonek',
- 'tonex',
- 'tradsyn',
- 'trandom',
- 'transeg',
- 'transegb',
- 'transegr',
- 'trcross',
- 'trfilter',
- 'trhighest',
- 'trigger',
- 'trigseq',
- 'trirand',
- 'trlowest',
- 'trmix',
- 'trscale',
- 'trshift',
- 'trsplit',
- 'turnoff',
- 'turnoff2',
- 'turnon',
- 'unirand',
- 'unwrap',
- 'upsamp',
- 'urd',
- 'vactrol',
- 'vadd',
- 'vadd_i',
- 'vaddv',
- 'vaddv_i',
- 'vaget',
- 'valpass',
- 'vaset',
- 'vbap',
- 'vbap16',
- 'vbap4',
- 'vbap4move',
- 'vbap8',
- 'vbap8move',
- 'vbapg',
- 'vbapgmove',
- 'vbaplsinit',
- 'vbapmove',
- 'vbapz',
- 'vbapzmove',
- 'vcella',
- 'vco',
- 'vco2',
- 'vco2ft',
- 'vco2ift',
- 'vco2init',
- 'vcomb',
- 'vcopy',
- 'vcopy_i',
- 'vdel_k',
- 'vdelay',
- 'vdelay3',
- 'vdelayk',
- 'vdelayx',
- 'vdelayxq',
- 'vdelayxs',
- 'vdelayxw',
- 'vdelayxwq',
- 'vdelayxws',
- 'vdivv',
- 'vdivv_i',
- 'vecdelay',
- 'veloc',
- 'vexp',
- 'vexp_i',
- 'vexpseg',
- 'vexpv',
- 'vexpv_i',
- 'vibes',
- 'vibr',
- 'vibrato',
- 'vincr',
- 'vlimit',
- 'vlinseg',
- 'vlowres',
- 'vmap',
- 'vmirror',
- 'vmult',
- 'vmult_i',
- 'vmultv',
- 'vmultv_i',
- 'voice',
- 'vosim',
- 'vphaseseg',
- 'vport',
- 'vpow',
- 'vpow_i',
- 'vpowv',
- 'vpowv_i',
- 'vpvoc',
- 'vrandh',
- 'vrandi',
- 'vsubv',
- 'vsubv_i',
- 'vtaba',
- 'vtabi',
- 'vtabk',
- 'vtable1k',
- 'vtablea',
- 'vtablei',
- 'vtablek',
- 'vtablewa',
- 'vtablewi',
- 'vtablewk',
- 'vtabwa',
- 'vtabwi',
- 'vtabwk',
- 'vwrap',
- 'waveset',
- 'weibull',
- 'wgbow',
- 'wgbowedbar',
- 'wgbrass',
- 'wgclar',
- 'wgflute',
- 'wgpluck',
- 'wgpluck2',
- 'wguide1',
- 'wguide2',
- 'wiiconnect',
- 'wiidata',
- 'wiirange',
- 'wiisend',
- 'window',
- 'wrap',
- 'writescratch',
- 'wterrain',
- 'xadsr',
- 'xin',
- 'xout',
- 'xscanmap',
- 'xscans',
- 'xscansmap',
- 'xscanu',
- 'xtratim',
- 'xyin',
- 'zacl',
- 'zakinit',
- 'zamod',
- 'zar',
- 'zarg',
- 'zaw',
- 'zawm',
- 'zfilter2',
- 'zir',
- 'ziw',
- 'ziwm',
- 'zkcl',
- 'zkmod',
- 'zkr',
- 'zkw',
- 'zkwm'
-))
+# Opcodes in Csound 6.12.0 at commit 6ca322bd31f1ca907c008616b40a5f237ff449db using
+# python -c "
+# import re, subprocess
+# output = subprocess.Popen(['csound', '--list-opcodes0'], stderr=subprocess.PIPE).communicate()[1]
+# opcodes = output[re.search(r'^$', output, re.M).end():re.search(r'^\d+ opcodes$', output, re.M).start()].split()
+# output = subprocess.Popen(['csound', '--list-opcodes2'], stderr=subprocess.PIPE).communicate()[1]
+# all_opcodes = output[re.search(r'^$', output, re.M).end():re.search(r'^\d+ opcodes$', output, re.M).start()].split()
+# deprecated_opcodes = [opcode for opcode in all_opcodes if opcode not in opcodes]
+# print '''OPCODES = set(\'''
+# {}
+# \'''.split())
+#
+# DEPRECATED_OPCODES = set(\'''
+# {}
+# \'''.split())
+# '''.format('\n'.join(opcodes), '\n'.join(deprecated_opcodes))
+# "
+# except for
+# cggoto csound.com/docs/manual/cggoto.html
+# cigoto csound.com/docs/manual/cigoto.html
+# cingoto (undocumented)
+# ckgoto csound.com/docs/manual/ckgoto.html
+# cngoto csound.com/docs/manual/cngoto.html
+# cnkgoto (undocumented)
+# endin csound.com/docs/manual/endin.html
+# endop csound.com/docs/manual/endop.html
+# goto csound.com/docs/manual/goto.html
+# igoto csound.com/docs/manual/igoto.html
+# instr csound.com/docs/manual/instr.html
+# kgoto csound.com/docs/manual/kgoto.html
+# loop_ge csound.com/docs/manual/loop_ge.html
+# loop_gt csound.com/docs/manual/loop_gt.html
+# loop_le csound.com/docs/manual/loop_le.html
+# loop_lt csound.com/docs/manual/loop_lt.html
+# opcode csound.com/docs/manual/opcode.html
+# reinit csound.com/docs/manual/reinit.html
+# return csound.com/docs/manual/return.html
+# rireturn csound.com/docs/manual/rireturn.html
+# rigoto csound.com/docs/manual/rigoto.html
+# tigoto csound.com/docs/manual/tigoto.html
+# timout csound.com/docs/manual/timout.html
+# which are treated as keywords in csound.py.
+
+OPCODES = set('''
+ATSadd
+ATSaddnz
+ATSbufread
+ATScross
+ATSinfo
+ATSinterpread
+ATSpartialtap
+ATSread
+ATSreadnz
+ATSsinnoi
+FLbox
+FLbutBank
+FLbutton
+FLcloseButton
+FLcolor
+FLcolor2
+FLcount
+FLexecButton
+FLgetsnap
+FLgroup
+FLgroupEnd
+FLgroup_end
+FLhide
+FLhvsBox
+FLhvsBoxSetValue
+FLjoy
+FLkeyIn
+FLknob
+FLlabel
+FLloadsnap
+FLmouse
+FLpack
+FLpackEnd
+FLpack_end
+FLpanel
+FLpanelEnd
+FLpanel_end
+FLprintk
+FLprintk2
+FLroller
+FLrun
+FLsavesnap
+FLscroll
+FLscrollEnd
+FLscroll_end
+FLsetAlign
+FLsetBox
+FLsetColor
+FLsetColor2
+FLsetFont
+FLsetPosition
+FLsetSize
+FLsetSnapGroup
+FLsetText
+FLsetTextColor
+FLsetTextSize
+FLsetTextType
+FLsetVal
+FLsetVal_i
+FLsetVali
+FLsetsnap
+FLshow
+FLslidBnk
+FLslidBnk2
+FLslidBnk2Set
+FLslidBnk2Setk
+FLslidBnkGetHandle
+FLslidBnkSet
+FLslidBnkSetk
+FLslider
+FLtabs
+FLtabsEnd
+FLtabs_end
+FLtext
+FLupdate
+FLvalue
+FLvkeybd
+FLvslidBnk
+FLvslidBnk2
+FLxyin
+JackoAudioIn
+JackoAudioInConnect
+JackoAudioOut
+JackoAudioOutConnect
+JackoFreewheel
+JackoInfo
+JackoInit
+JackoMidiInConnect
+JackoMidiOut
+JackoMidiOutConnect
+JackoNoteOut
+JackoOn
+JackoTransport
+K35_hpf
+K35_lpf
+MixerClear
+MixerGetLevel
+MixerReceive
+MixerSend
+MixerSetLevel
+MixerSetLevel_i
+OSCbundle
+OSCcount
+OSCinit
+OSCinitM
+OSClisten
+OSCraw
+OSCsend
+OSCsend_lo
+S
+STKBandedWG
+STKBeeThree
+STKBlowBotl
+STKBlowHole
+STKBowed
+STKBrass
+STKClarinet
+STKDrummer
+STKFlute
+STKFMVoices
+STKHevyMetl
+STKMandolin
+STKModalBar
+STKMoog
+STKPercFlut
+STKPlucked
+STKResonate
+STKRhodey
+STKSaxofony
+STKShakers
+STKSimple
+STKSitar
+STKStifKarp
+STKTubeBell
+STKVoicForm
+STKWhistle
+STKWurley
+a
+abs
+active
+adsr
+adsyn
+adsynt
+adsynt2
+aftouch
+alpass
+alwayson
+ampdb
+ampdbfs
+ampmidi
+ampmidid
+areson
+aresonk
+atone
+atonek
+atonex
+babo
+balance
+balance2
+bamboo
+barmodel
+bbcutm
+bbcuts
+beadsynt
+beosc
+betarand
+bexprnd
+bformdec1
+bformenc1
+binit
+biquad
+biquada
+birnd
+bpf
+bpfcos
+bqrez
+butbp
+butbr
+buthp
+butlp
+butterbp
+butterbr
+butterhp
+butterlp
+button
+buzz
+c2r
+cabasa
+cauchy
+cauchyi
+cbrt
+ceil
+cell
+cent
+centroid
+ceps
+cepsinv
+chanctrl
+changed
+changed2
+chani
+chano
+chebyshevpoly
+checkbox
+chn_S
+chn_a
+chn_k
+chnclear
+chnexport
+chnget
+chngetks
+chnmix
+chnparams
+chnset
+chnsetks
+chuap
+clear
+clfilt
+clip
+clockoff
+clockon
+cmp
+cmplxprod
+comb
+combinv
+compilecsd
+compileorc
+compilestr
+compress
+compress2
+connect
+control
+convle
+convolve
+copya2ftab
+copyf2array
+cos
+cosh
+cosinv
+cosseg
+cossegb
+cossegr
+cps2pch
+cpsmidi
+cpsmidib
+cpsmidinn
+cpsoct
+cpspch
+cpstmid
+cpstun
+cpstuni
+cpsxpch
+cpumeter
+cpuprc
+cross2
+crossfm
+crossfmi
+crossfmpm
+crossfmpmi
+crosspm
+crosspmi
+crunch
+ctlchn
+ctrl14
+ctrl21
+ctrl7
+ctrlinit
+cuserrnd
+dam
+date
+dates
+db
+dbamp
+dbfsamp
+dcblock
+dcblock2
+dconv
+dct
+dctinv
+deinterleave
+delay
+delay1
+delayk
+delayr
+delayw
+deltap
+deltap3
+deltapi
+deltapn
+deltapx
+deltapxw
+denorm
+diff
+diode_ladder
+directory
+diskgrain
+diskin
+diskin2
+dispfft
+display
+distort
+distort1
+divz
+doppler
+dot
+downsamp
+dripwater
+dssiactivate
+dssiaudio
+dssictls
+dssiinit
+dssilist
+dumpk
+dumpk2
+dumpk3
+dumpk4
+duserrnd
+dust
+dust2
+envlpx
+envlpxr
+ephasor
+eqfil
+evalstr
+event
+event_i
+exciter
+exitnow
+exp
+expcurve
+expon
+exprand
+exprandi
+expseg
+expsega
+expsegb
+expsegba
+expsegr
+fareylen
+fareyleni
+faustaudio
+faustcompile
+faustctl
+faustdsp
+faustgen
+faustplay
+fft
+fftinv
+ficlose
+filebit
+filelen
+filenchnls
+filepeak
+filescal
+filesr
+filevalid
+fillarray
+filter2
+fin
+fini
+fink
+fiopen
+flanger
+flashtxt
+flooper
+flooper2
+floor
+fmanal
+fmax
+fmb3
+fmbell
+fmin
+fmmetal
+fmod
+fmpercfl
+fmrhode
+fmvoice
+fmwurlie
+fof
+fof2
+fofilter
+fog
+fold
+follow
+follow2
+foscil
+foscili
+fout
+fouti
+foutir
+foutk
+fprintks
+fprints
+frac
+fractalnoise
+framebuffer
+freeverb
+ftaudio
+ftchnls
+ftconv
+ftcps
+ftfree
+ftgen
+ftgenonce
+ftgentmp
+ftlen
+ftload
+ftloadk
+ftlptim
+ftmorf
+ftom
+ftprint
+ftresize
+ftresizei
+ftsamplebank
+ftsave
+ftsavek
+ftslice
+ftsr
+gain
+gainslider
+gauss
+gaussi
+gausstrig
+gbuzz
+genarray
+genarray_i
+gendy
+gendyc
+gendyx
+getcfg
+getcol
+getftargs
+getrow
+getrowlin
+getseed
+gogobel
+grain
+grain2
+grain3
+granule
+guiro
+harmon
+harmon2
+harmon3
+harmon4
+hdf5read
+hdf5write
+hilbert
+hilbert2
+hrtfearly
+hrtfmove
+hrtfmove2
+hrtfreverb
+hrtfstat
+hsboscil
+hvs1
+hvs2
+hvs3
+hypot
+i
+ihold
+imagecreate
+imagefree
+imagegetpixel
+imageload
+imagesave
+imagesetpixel
+imagesize
+in
+in32
+inch
+inh
+init
+initc14
+initc21
+initc7
+inleta
+inletf
+inletk
+inletkid
+inletv
+ino
+inq
+inrg
+ins
+insglobal
+insremot
+int
+integ
+interleave
+interp
+invalue
+inx
+inz
+jacktransport
+jitter
+jitter2
+joystick
+jspline
+k
+la_i_add_mc
+la_i_add_mr
+la_i_add_vc
+la_i_add_vr
+la_i_assign_mc
+la_i_assign_mr
+la_i_assign_t
+la_i_assign_vc
+la_i_assign_vr
+la_i_conjugate_mc
+la_i_conjugate_mr
+la_i_conjugate_vc
+la_i_conjugate_vr
+la_i_distance_vc
+la_i_distance_vr
+la_i_divide_mc
+la_i_divide_mr
+la_i_divide_vc
+la_i_divide_vr
+la_i_dot_mc
+la_i_dot_mc_vc
+la_i_dot_mr
+la_i_dot_mr_vr
+la_i_dot_vc
+la_i_dot_vr
+la_i_get_mc
+la_i_get_mr
+la_i_get_vc
+la_i_get_vr
+la_i_invert_mc
+la_i_invert_mr
+la_i_lower_solve_mc
+la_i_lower_solve_mr
+la_i_lu_det_mc
+la_i_lu_det_mr
+la_i_lu_factor_mc
+la_i_lu_factor_mr
+la_i_lu_solve_mc
+la_i_lu_solve_mr
+la_i_mc_create
+la_i_mc_set
+la_i_mr_create
+la_i_mr_set
+la_i_multiply_mc
+la_i_multiply_mr
+la_i_multiply_vc
+la_i_multiply_vr
+la_i_norm_euclid_mc
+la_i_norm_euclid_mr
+la_i_norm_euclid_vc
+la_i_norm_euclid_vr
+la_i_norm_inf_mc
+la_i_norm_inf_mr
+la_i_norm_inf_vc
+la_i_norm_inf_vr
+la_i_norm_max_mc
+la_i_norm_max_mr
+la_i_norm1_mc
+la_i_norm1_mr
+la_i_norm1_vc
+la_i_norm1_vr
+la_i_print_mc
+la_i_print_mr
+la_i_print_vc
+la_i_print_vr
+la_i_qr_eigen_mc
+la_i_qr_eigen_mr
+la_i_qr_factor_mc
+la_i_qr_factor_mr
+la_i_qr_sym_eigen_mc
+la_i_qr_sym_eigen_mr
+la_i_random_mc
+la_i_random_mr
+la_i_random_vc
+la_i_random_vr
+la_i_size_mc
+la_i_size_mr
+la_i_size_vc
+la_i_size_vr
+la_i_subtract_mc
+la_i_subtract_mr
+la_i_subtract_vc
+la_i_subtract_vr
+la_i_t_assign
+la_i_trace_mc
+la_i_trace_mr
+la_i_transpose_mc
+la_i_transpose_mr
+la_i_upper_solve_mc
+la_i_upper_solve_mr
+la_i_vc_create
+la_i_vc_set
+la_i_vr_create
+la_i_vr_set
+la_k_a_assign
+la_k_add_mc
+la_k_add_mr
+la_k_add_vc
+la_k_add_vr
+la_k_assign_a
+la_k_assign_f
+la_k_assign_mc
+la_k_assign_mr
+la_k_assign_t
+la_k_assign_vc
+la_k_assign_vr
+la_k_conjugate_mc
+la_k_conjugate_mr
+la_k_conjugate_vc
+la_k_conjugate_vr
+la_k_current_f
+la_k_current_vr
+la_k_distance_vc
+la_k_distance_vr
+la_k_divide_mc
+la_k_divide_mr
+la_k_divide_vc
+la_k_divide_vr
+la_k_dot_mc
+la_k_dot_mc_vc
+la_k_dot_mr
+la_k_dot_mr_vr
+la_k_dot_vc
+la_k_dot_vr
+la_k_f_assign
+la_k_get_mc
+la_k_get_mr
+la_k_get_vc
+la_k_get_vr
+la_k_invert_mc
+la_k_invert_mr
+la_k_lower_solve_mc
+la_k_lower_solve_mr
+la_k_lu_det_mc
+la_k_lu_det_mr
+la_k_lu_factor_mc
+la_k_lu_factor_mr
+la_k_lu_solve_mc
+la_k_lu_solve_mr
+la_k_mc_set
+la_k_mr_set
+la_k_multiply_mc
+la_k_multiply_mr
+la_k_multiply_vc
+la_k_multiply_vr
+la_k_norm_euclid_mc
+la_k_norm_euclid_mr
+la_k_norm_euclid_vc
+la_k_norm_euclid_vr
+la_k_norm_inf_mc
+la_k_norm_inf_mr
+la_k_norm_inf_vc
+la_k_norm_inf_vr
+la_k_norm_max_mc
+la_k_norm_max_mr
+la_k_norm1_mc
+la_k_norm1_mr
+la_k_norm1_vc
+la_k_norm1_vr
+la_k_qr_eigen_mc
+la_k_qr_eigen_mr
+la_k_qr_factor_mc
+la_k_qr_factor_mr
+la_k_qr_sym_eigen_mc
+la_k_qr_sym_eigen_mr
+la_k_random_mc
+la_k_random_mr
+la_k_random_vc
+la_k_random_vr
+la_k_subtract_mc
+la_k_subtract_mr
+la_k_subtract_vc
+la_k_subtract_vr
+la_k_t_assign
+la_k_trace_mc
+la_k_trace_mr
+la_k_upper_solve_mc
+la_k_upper_solve_mr
+la_k_vc_set
+la_k_vr_set
+lenarray
+lfo
+limit
+limit1
+lincos
+line
+linen
+linenr
+lineto
+link_beat_force
+link_beat_get
+link_beat_request
+link_create
+link_enable
+link_is_enabled
+link_metro
+link_peers
+link_tempo_get
+link_tempo_set
+linlin
+linrand
+linseg
+linsegb
+linsegr
+liveconv
+locsend
+locsig
+log
+log10
+log2
+logbtwo
+logcurve
+loopseg
+loopsegp
+looptseg
+loopxseg
+lorenz
+loscil
+loscil3
+loscil3phs
+loscilphs
+loscilx
+lowpass2
+lowres
+lowresx
+lpf18
+lpform
+lpfreson
+lphasor
+lpinterp
+lposcil
+lposcil3
+lposcila
+lposcilsa
+lposcilsa2
+lpread
+lpreson
+lpshold
+lpsholdp
+lpslot
+lua_exec
+lua_iaopcall
+lua_iaopcall_off
+lua_ikopcall
+lua_ikopcall_off
+lua_iopcall
+lua_iopcall_off
+lua_opdef
+mac
+maca
+madsr
+mags
+mandel
+mandol
+maparray
+maparray_i
+marimba
+massign
+max
+max_k
+maxabs
+maxabsaccum
+maxaccum
+maxalloc
+maxarray
+mclock
+mdelay
+median
+mediank
+metro
+mfb
+midglobal
+midiarp
+midic14
+midic21
+midic7
+midichannelaftertouch
+midichn
+midicontrolchange
+midictrl
+mididefault
+midifilestatus
+midiin
+midinoteoff
+midinoteoncps
+midinoteonkey
+midinoteonoct
+midinoteonpch
+midion
+midion2
+midiout
+midiout_i
+midipgm
+midipitchbend
+midipolyaftertouch
+midiprogramchange
+miditempo
+midremot
+min
+minabs
+minabsaccum
+minaccum
+minarray
+mincer
+mirror
+mode
+modmatrix
+monitor
+moog
+moogladder
+moogladder2
+moogvcf
+moogvcf2
+moscil
+mp3bitrate
+mp3in
+mp3len
+mp3nchnls
+mp3scal
+mp3sr
+mpulse
+mrtmsg
+mtof
+mton
+multitap
+mute
+mvchpf
+mvclpf1
+mvclpf2
+mvclpf3
+mvclpf4
+mxadsr
+nchnls_hw
+nestedap
+nlalp
+nlfilt
+nlfilt2
+noise
+noteoff
+noteon
+noteondur
+noteondur2
+notnum
+nreverb
+nrpn
+nsamp
+nstance
+nstrnum
+ntom
+ntrpol
+nxtpow2
+octave
+octcps
+octmidi
+octmidib
+octmidinn
+octpch
+olabuffer
+oscbnk
+oscil
+oscil1
+oscil1i
+oscil3
+oscili
+oscilikt
+osciliktp
+oscilikts
+osciln
+oscils
+oscilx
+out
+out32
+outc
+outch
+outh
+outiat
+outic
+outic14
+outipat
+outipb
+outipc
+outkat
+outkc
+outkc14
+outkpat
+outkpb
+outkpc
+outleta
+outletf
+outletk
+outletkid
+outletv
+outo
+outq
+outq1
+outq2
+outq3
+outq4
+outrg
+outs
+outs1
+outs2
+outvalue
+outx
+outz
+p
+p5gconnect
+p5gdata
+pan
+pan2
+pareq
+part2txt
+partials
+partikkel
+partikkelget
+partikkelset
+partikkelsync
+passign
+paulstretch
+pcauchy
+pchbend
+pchmidi
+pchmidib
+pchmidinn
+pchoct
+pchtom
+pconvolve
+pcount
+pdclip
+pdhalf
+pdhalfy
+peak
+pgmassign
+pgmchn
+phaser1
+phaser2
+phasor
+phasorbnk
+phs
+pindex
+pinker
+pinkish
+pitch
+pitchac
+pitchamdf
+planet
+platerev
+plltrack
+pluck
+poisson
+pol2rect
+polyaft
+polynomial
+port
+portk
+poscil
+poscil3
+pow
+powershape
+powoftwo
+pows
+prealloc
+prepiano
+print
+print_type
+printarray
+printf
+printf_i
+printk
+printk2
+printks
+printks2
+prints
+product
+pset
+ptable
+ptable3
+ptablei
+ptableiw
+ptablew
+ptrack
+puts
+pvadd
+pvbufread
+pvcross
+pvinterp
+pvoc
+pvread
+pvs2array
+pvs2tab
+pvsadsyn
+pvsanal
+pvsarp
+pvsbandp
+pvsbandr
+pvsbin
+pvsblur
+pvsbuffer
+pvsbufread
+pvsbufread2
+pvscale
+pvscent
+pvsceps
+pvscross
+pvsdemix
+pvsdiskin
+pvsdisp
+pvsenvftw
+pvsfilter
+pvsfread
+pvsfreeze
+pvsfromarray
+pvsftr
+pvsftw
+pvsfwrite
+pvsgain
+pvshift
+pvsifd
+pvsin
+pvsinfo
+pvsinit
+pvslock
+pvsmaska
+pvsmix
+pvsmooth
+pvsmorph
+pvsosc
+pvsout
+pvspitch
+pvstanal
+pvstencil
+pvstrace
+pvsvoc
+pvswarp
+pvsynth
+pwd
+pyassign
+pyassigni
+pyassignt
+pycall
+pycall1
+pycall1i
+pycall1t
+pycall2
+pycall2i
+pycall2t
+pycall3
+pycall3i
+pycall3t
+pycall4
+pycall4i
+pycall4t
+pycall5
+pycall5i
+pycall5t
+pycall6
+pycall6i
+pycall6t
+pycall7
+pycall7i
+pycall7t
+pycall8
+pycall8i
+pycall8t
+pycalli
+pycalln
+pycallni
+pycallt
+pyeval
+pyevali
+pyevalt
+pyexec
+pyexeci
+pyexect
+pyinit
+pylassign
+pylassigni
+pylassignt
+pylcall
+pylcall1
+pylcall1i
+pylcall1t
+pylcall2
+pylcall2i
+pylcall2t
+pylcall3
+pylcall3i
+pylcall3t
+pylcall4
+pylcall4i
+pylcall4t
+pylcall5
+pylcall5i
+pylcall5t
+pylcall6
+pylcall6i
+pylcall6t
+pylcall7
+pylcall7i
+pylcall7t
+pylcall8
+pylcall8i
+pylcall8t
+pylcalli
+pylcalln
+pylcallni
+pylcallt
+pyleval
+pylevali
+pylevalt
+pylexec
+pylexeci
+pylexect
+pylrun
+pylruni
+pylrunt
+pyrun
+pyruni
+pyrunt
+qinf
+qnan
+r2c
+rand
+randh
+randi
+random
+randomh
+randomi
+rbjeq
+readclock
+readf
+readfi
+readk
+readk2
+readk3
+readk4
+readks
+readscore
+readscratch
+rect2pol
+release
+remoteport
+remove
+repluck
+reshapearray
+reson
+resonk
+resonr
+resonx
+resonxk
+resony
+resonz
+resyn
+reverb
+reverb2
+reverbsc
+rewindscore
+rezzy
+rfft
+rifft
+rms
+rnd
+rnd31
+round
+rspline
+rtclock
+s16b14
+s32b14
+samphold
+sandpaper
+sc_lag
+sc_lagud
+sc_phasor
+sc_trig
+scale
+scalearray
+scanhammer
+scans
+scantable
+scanu
+schedkwhen
+schedkwhennamed
+schedule
+schedwhen
+scoreline
+scoreline_i
+seed
+sekere
+select
+semitone
+sense
+sensekey
+seqtime
+seqtime2
+serialBegin
+serialEnd
+serialFlush
+serialPrint
+serialRead
+serialWrite
+serialWrite_i
+setcol
+setctrl
+setksmps
+setrow
+setscorepos
+sfilist
+sfinstr
+sfinstr3
+sfinstr3m
+sfinstrm
+sfload
+sflooper
+sfpassign
+sfplay
+sfplay3
+sfplay3m
+sfplaym
+sfplist
+sfpreset
+shaker
+shiftin
+shiftout
+signum
+sin
+sinh
+sininv
+sinsyn
+sleighbells
+slicearray
+slicearray_i
+slider16
+slider16f
+slider16table
+slider16tablef
+slider32
+slider32f
+slider32table
+slider32tablef
+slider64
+slider64f
+slider64table
+slider64tablef
+slider8
+slider8f
+slider8table
+slider8tablef
+sliderKawai
+sndloop
+sndwarp
+sndwarpst
+sockrecv
+sockrecvs
+socksend
+socksends
+sorta
+sortd
+soundin
+space
+spat3d
+spat3di
+spat3dt
+spdist
+splitrig
+sprintf
+sprintfk
+spsend
+sqrt
+squinewave
+statevar
+stix
+strcat
+strcatk
+strchar
+strchark
+strcmp
+strcmpk
+strcpy
+strcpyk
+strecv
+streson
+strfromurl
+strget
+strindex
+strindexk
+strlen
+strlenk
+strlower
+strlowerk
+strrindex
+strrindexk
+strset
+strsub
+strsubk
+strtod
+strtodk
+strtol
+strtolk
+strupper
+strupperk
+stsend
+subinstr
+subinstrinit
+sum
+sumarray
+svfilter
+syncgrain
+syncloop
+syncphasor
+system
+system_i
+tab
+tab2array
+tab2pvs
+tab_i
+tabifd
+table
+table3
+table3kt
+tablecopy
+tablefilter
+tablefilteri
+tablegpw
+tablei
+tableicopy
+tableigpw
+tableikt
+tableimix
+tableiw
+tablekt
+tablemix
+tableng
+tablera
+tableseg
+tableshuffle
+tableshufflei
+tablew
+tablewa
+tablewkt
+tablexkt
+tablexseg
+tabmorph
+tabmorpha
+tabmorphak
+tabmorphi
+tabplay
+tabrec
+tabrowlin
+tabsum
+tabw
+tabw_i
+tambourine
+tan
+tanh
+taninv
+taninv2
+tbvcf
+tempest
+tempo
+temposcal
+tempoval
+timedseq
+timeinstk
+timeinsts
+timek
+times
+tival
+tlineto
+tone
+tonek
+tonex
+tradsyn
+trandom
+transeg
+transegb
+transegr
+trcross
+trfilter
+trhighest
+trigger
+trigseq
+trim
+trim_i
+trirand
+trlowest
+trmix
+trscale
+trshift
+trsplit
+turnoff
+turnoff2
+turnon
+tvconv
+unirand
+unwrap
+upsamp
+urandom
+urd
+vactrol
+vadd
+vadd_i
+vaddv
+vaddv_i
+vaget
+valpass
+vaset
+vbap
+vbapg
+vbapgmove
+vbaplsinit
+vbapmove
+vbapz
+vbapzmove
+vcella
+vco
+vco2
+vco2ft
+vco2ift
+vco2init
+vcomb
+vcopy
+vcopy_i
+vdel_k
+vdelay
+vdelay3
+vdelayk
+vdelayx
+vdelayxq
+vdelayxs
+vdelayxw
+vdelayxwq
+vdelayxws
+vdivv
+vdivv_i
+vecdelay
+veloc
+vexp
+vexp_i
+vexpseg
+vexpv
+vexpv_i
+vibes
+vibr
+vibrato
+vincr
+vlimit
+vlinseg
+vlowres
+vmap
+vmirror
+vmult
+vmult_i
+vmultv
+vmultv_i
+voice
+vosim
+vphaseseg
+vport
+vpow
+vpow_i
+vpowv
+vpowv_i
+vpvoc
+vrandh
+vrandi
+vsubv
+vsubv_i
+vtaba
+vtabi
+vtabk
+vtable1k
+vtablea
+vtablei
+vtablek
+vtablewa
+vtablewi
+vtablewk
+vtabwa
+vtabwi
+vtabwk
+vwrap
+waveset
+websocket
+weibull
+wgbow
+wgbowedbar
+wgbrass
+wgclar
+wgflute
+wgpluck
+wgpluck2
+wguide1
+wguide2
+wiiconnect
+wiidata
+wiirange
+wiisend
+window
+wrap
+writescratch
+wterrain
+xadsr
+xin
+xout
+xscanmap
+xscans
+xscansmap
+xscanu
+xtratim
+xyscale
+zacl
+zakinit
+zamod
+zar
+zarg
+zaw
+zawm
+zdf_1pole
+zdf_1pole_mode
+zdf_2pole
+zdf_2pole_mode
+zdf_ladder
+zfilter2
+zir
+ziw
+ziwm
+zkcl
+zkmod
+zkr
+zkw
+zkwm
+'''.split())
+
+DEPRECATED_OPCODES = set('''
+array
+bformdec
+bformenc
+copy2ftab
+copy2ttab
+hrtfer
+ktableseg
+lentab
+maxtab
+mintab
+pop
+pop_f
+push
+push_f
+scalet
+sndload
+soundout
+soundouts
+specaddm
+specdiff
+specdisp
+specfilt
+spechist
+specptrk
+specscal
+specsum
+spectrum
+stack
+sumtab
+tabgen
+tabmap
+tabmap_i
+tabslice
+tb0
+tb0_init
+tb1
+tb10
+tb10_init
+tb11
+tb11_init
+tb12
+tb12_init
+tb13
+tb13_init
+tb14
+tb14_init
+tb15
+tb15_init
+tb1_init
+tb2
+tb2_init
+tb3
+tb3_init
+tb4
+tb4_init
+tb5
+tb5_init
+tb6
+tb6_init
+tb7
+tb7_init
+tb8
+tb8_init
+tb9
+tb9_init
+vbap16
+vbap4
+vbap4move
+vbap8
+vbap8move
+xyin
+'''.split())
diff --git a/pygments/lexers/_lua_builtins.py b/pygments/lexers/_lua_builtins.py
index c60bf5a2..0561725d 100644
--- a/pygments/lexers/_lua_builtins.py
+++ b/pygments/lexers/_lua_builtins.py
@@ -288,7 +288,7 @@ if __name__ == '__main__': # pragma: no cover
print('>> %s' % full_function_name)
m = get_function_module(full_function_name)
modules.setdefault(m, []).append(full_function_name)
- modules = {k: tuple(v) for k, v in modules.iteritems()}
+ modules = dict((k, tuple(v)) for k, v in modules.iteritems())
regenerate(__file__, modules)
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index b48ee1d1..9ccc7615 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -153,6 +153,7 @@ LEXERS = {
'FancyLexer': ('pygments.lexers.ruby', 'Fancy', ('fancy', 'fy'), ('*.fy', '*.fancypack'), ('text/x-fancysrc',)),
'FantomLexer': ('pygments.lexers.fantom', 'Fantom', ('fan',), ('*.fan',), ('application/x-fantom',)),
'FelixLexer': ('pygments.lexers.felix', 'Felix', ('felix', 'flx'), ('*.flx', '*.flxh'), ('text/x-felix',)),
+ 'FennelLexer': ('pygments.lexers.lisp', 'Fennel', ('fennel', 'fnl'), ('*.fnl',), ()),
'FishShellLexer': ('pygments.lexers.shell', 'Fish', ('fish', 'fishshell'), ('*.fish', '*.load'), ('application/x-fish',)),
'FlatlineLexer': ('pygments.lexers.dsls', 'Flatline', ('flatline',), (), ('text/x-flatline',)),
'ForthLexer': ('pygments.lexers.forth', 'Forth', ('forth',), ('*.frt', '*.fs'), ('application/x-forth',)),
@@ -174,6 +175,7 @@ LEXERS = {
'GosuTemplateLexer': ('pygments.lexers.jvm', 'Gosu Template', ('gst',), ('*.gst',), ('text/x-gosu-template',)),
'GroffLexer': ('pygments.lexers.markup', 'Groff', ('groff', 'nroff', 'man'), ('*.[1234567]', '*.man'), ('application/x-troff', 'text/troff')),
'GroovyLexer': ('pygments.lexers.jvm', 'Groovy', ('groovy',), ('*.groovy', '*.gradle'), ('text/x-groovy',)),
+ 'HLSLShaderLexer': ('pygments.lexers.graphics', 'HLSL', ('hlsl',), ('*.hlsl', '*.hlsli'), ('text/x-hlsl',)),
'HamlLexer': ('pygments.lexers.html', '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',), (), ()),
@@ -367,7 +369,7 @@ LEXERS = {
'RtsLexer': ('pygments.lexers.trafficscript', 'TrafficScript', ('rts', 'trafficscript'), ('*.rts',), ()),
'RubyConsoleLexer': ('pygments.lexers.ruby', 'Ruby irb session', ('rbcon', 'irb'), (), ('text/x-ruby-shellsession',)),
'RubyLexer': ('pygments.lexers.ruby', 'Ruby', ('rb', 'ruby', 'duby'), ('*.rb', '*.rbw', 'Rakefile', '*.rake', '*.gemspec', '*.rbx', '*.duby', 'Gemfile'), ('text/x-ruby', 'application/x-ruby')),
- 'RustLexer': ('pygments.lexers.rust', 'Rust', ('rust',), ('*.rs', '*.rs.in'), ('text/rust',)),
+ 'RustLexer': ('pygments.lexers.rust', 'Rust', ('rust', 'rs'), ('*.rs', '*.rs.in'), ('text/rust',)),
'SASLexer': ('pygments.lexers.sas', 'SAS', ('sas',), ('*.SAS', '*.sas'), ('text/x-sas', 'text/sas', 'application/x-sas')),
'SLexer': ('pygments.lexers.r', '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.ml', 'Standard ML', ('sml',), ('*.sml', '*.sig', '*.fun'), ('text/x-standardml', 'application/x-standardml')),
diff --git a/pygments/lexers/ampl.py b/pygments/lexers/ampl.py
index d439cb19..638d025d 100644
--- a/pygments/lexers/ampl.py
+++ b/pygments/lexers/ampl.py
@@ -3,7 +3,7 @@
pygments.lexers.ampl
~~~~~~~~~~~~~~~~~~~~
- Lexers for the ampl language. <http://ampl.com/>
+ Lexers for the AMPL language.
:copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
@@ -18,7 +18,7 @@ __all__ = ['AmplLexer']
class AmplLexer(RegexLexer):
"""
- For AMPL source code.
+ For `AMPL <http://ampl.com/>`_ source code.
.. versionadded:: 2.2
"""
diff --git a/pygments/lexers/clean.py b/pygments/lexers/clean.py
index ba2569f6..dc973bea 100644
--- a/pygments/lexers/clean.py
+++ b/pygments/lexers/clean.py
@@ -5,14 +5,13 @@
Lexer for the Clean language.
- :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-from pygments.lexer import ExtendedRegexLexer, LexerContext, \
- bygroups, words, include, default
-from pygments.token import Comment, Keyword, Literal, Name, Number, Operator, \
- Punctuation, String, Text, Whitespace
+from pygments.lexer import ExtendedRegexLexer, words, include, bygroups
+from pygments.token import Comment, Error, Keyword, Literal, Name, Number, \
+ Operator, Punctuation, String, Whitespace
__all__ = ['CleanLexer']
@@ -28,261 +27,152 @@ class CleanLexer(ExtendedRegexLexer):
aliases = ['clean']
filenames = ['*.icl', '*.dcl']
- def get_tokens_unprocessed(self, text=None, context=None):
- ctx = LexerContext(text, 0)
- ctx.indent = 0
- return ExtendedRegexLexer.get_tokens_unprocessed(self, text, context=ctx)
+ keywords = (
+ 'case', 'ccall', 'class', 'code', 'code inline', 'derive', 'export',
+ 'foreign', 'generic', 'if', 'in', 'infix', 'infixl', 'infixr',
+ 'instance', 'let', 'of', 'otherwise', 'special', 'stdcall', 'where',
+ 'with')
- def check_class_not_import(lexer, match, ctx):
- if match.group(0) == 'import':
- yield match.start(), Keyword.Namespace, match.group(0)
- ctx.stack = ctx.stack[:-1] + ['fromimportfunc']
- else:
- yield match.start(), Name.Class, match.group(0)
- ctx.pos = match.end()
+ modulewords = ('implementation', 'definition', 'system')
- def check_instance_class(lexer, match, ctx):
- if match.group(0) == 'instance' or match.group(0) == 'class':
- yield match.start(), Keyword, match.group(0)
- else:
- yield match.start(), Name.Function, match.group(0)
- ctx.stack = ctx.stack + ['fromimportfunctype']
- ctx.pos = match.end()
-
- @staticmethod
- def indent_len(text):
- # Tabs are four spaces:
- # https://svn.cs.ru.nl/repos/clean-platform/trunk/doc/STANDARDS.txt
- text = text.replace('\n', '')
- return len(text.replace('\t', ' ')), len(text)
-
- def store_indent(lexer, match, ctx):
- ctx.indent, _ = CleanLexer.indent_len(match.group(0))
- ctx.pos = match.end()
- yield match.start(), Text, match.group(0)
-
- def check_indent1(lexer, match, ctx):
- indent, reallen = CleanLexer.indent_len(match.group(0))
- if indent > ctx.indent:
- yield match.start(), Whitespace, match.group(0)
- ctx.pos = match.start() + reallen + 1
- else:
- ctx.indent = 0
- ctx.pos = match.start()
- ctx.stack = ctx.stack[:-1]
- yield match.start(), Whitespace, match.group(0)[1:]
-
- def check_indent2(lexer, match, ctx):
- indent, reallen = CleanLexer.indent_len(match.group(0))
- if indent > ctx.indent:
- yield match.start(), Whitespace, match.group(0)
- ctx.pos = match.start() + reallen + 1
- else:
- ctx.indent = 0
- ctx.pos = match.start()
- ctx.stack = ctx.stack[:-2]
-
- def check_indent3(lexer, match, ctx):
- indent, reallen = CleanLexer.indent_len(match.group(0))
- if indent > ctx.indent:
- yield match.start(), Whitespace, match.group(0)
- ctx.pos = match.start() + reallen + 1
- else:
- ctx.indent = 0
- ctx.pos = match.start()
- ctx.stack = ctx.stack[:-3]
- yield match.start(), Whitespace, match.group(0)[1:]
- if match.group(0) == '\n\n':
- ctx.pos = ctx.pos + 1
-
- def skip(lexer, match, ctx):
- ctx.stack = ctx.stack[:-1]
- ctx.pos = match.end()
- yield match.start(), Comment, match.group(0)
-
- keywords = ('class', 'instance', 'where', 'with', 'let', 'let!',
- 'in', 'case', 'of', 'infix', 'infixr', 'infixl', 'generic',
- 'derive', 'otherwise', 'code', 'inline')
+ lowerId = r'[a-z`][\w\d`]*'
+ upperId = r'[A-Z`][\w\d`]*'
+ funnyId = r'[~@#\$%\^?!+\-*<>\\/|&=:]+'
+ scoreUpperId = r'_' + upperId
+ scoreLowerId = r'_' + lowerId
+ moduleId = r'[a-zA-Z_][a-zA-Z0-9_.`]+'
+ classId = '|'.join([lowerId, upperId, funnyId])
tokens = {
- 'common': [
- (r';', Punctuation, '#pop'),
- (r'//', Comment, 'singlecomment'),
- ],
'root': [
- # Comments
+ include('comments'),
+ include('keywords'),
+ include('module'),
+ include('import'),
+ include('whitespace'),
+ include('literals'),
+ include('operators'),
+ include('delimiters'),
+ include('names'),
+ ],
+ 'whitespace': [
+ (r'\s+', Whitespace),
+ ],
+ 'comments': [
(r'//.*\n', Comment.Single),
- (r'(?s)/\*\*.*?\*/', Comment.Special),
- (r'(?s)/\*.*?\*/', Comment.Multi),
-
- # Modules, imports, etc.
- (r'\b((?:implementation|definition|system)\s+)?(module)(\s+)([\w`.]+)',
- bygroups(Keyword.Namespace, Keyword.Namespace, Text, Name.Class)),
- (r'(?<=\n)import(?=\s)', Keyword.Namespace, 'import'),
- (r'(?<=\n)from(?=\s)', Keyword.Namespace, 'fromimport'),
-
- # Keywords
- # We cannot use (?s)^|(?<=\s) as prefix, so need to repeat this
- (words(keywords, prefix=r'(?<=\s)', suffix=r'(?=\s)'), Keyword),
- (words(keywords, prefix=r'^', suffix=r'(?=\s)'), Keyword),
-
- # Function definitions
- (r'(?=\{\|)', Whitespace, 'genericfunction'),
- (r'(?<=\n)([ \t]*)([\w`$()=\-<>~*\^|+&%]+)((?:\s+\w)*)(\s*)(::)',
- bygroups(store_indent, Name.Function, Keyword.Type, Whitespace,
- Punctuation),
- 'functiondefargs'),
-
- # Type definitions
- (r'(?<=\n)([ \t]*)(::)', bygroups(store_indent, Punctuation), 'typedef'),
- (r'^([ \t]*)(::)', bygroups(store_indent, Punctuation), 'typedef'),
-
- # Literals
- (r'\'\\?.(?<!\\)\'', String.Char),
- (r'\'\\\d+\'', String.Char),
- (r'\'\\\\\'', String.Char), # (special case for '\\')
- (r'[+\-~]?\s*\d+\.\d+(E[+\-~]?\d+)?\b', Number.Float),
- (r'[+\-~]?\s*0[0-7]\b', Number.Oct),
- (r'[+\-~]?\s*0x[0-9a-fA-F]\b', Number.Hex),
- (r'[+\-~]?\s*\d+\b', Number.Integer),
- (r'"', String.Double, 'doubleqstring'),
- (words(('True', 'False'), prefix=r'(?<=\s)', suffix=r'(?=\s)'),
- Literal),
-
- # Qualified names
- (r'(\')([\w.]+)(\'\.)',
- bygroups(Punctuation, Name.Namespace, Punctuation)),
-
- # Everything else is some name
- (r'([\w`$%/?@]+\.?)*[\w`$%/?@]+', Name),
-
- # Punctuation
- (r'[{}()\[\],:;.#]', Punctuation),
- (r'[+\-=!<>|&~*\^/]', Operator),
- (r'\\\\', Operator),
-
- # Lambda expressions
- (r'\\.*?(->|\.|=)', Name.Function),
-
- # Whitespace
- (r'\s', Whitespace),
-
- include('common'),
+ (r'/\*', Comment.Multi, 'comments.in'),
+ (r'/\*\*', Comment.Special, 'comments.in'),
],
- 'fromimport': [
- include('common'),
- (r'([\w`.]+)', check_class_not_import),
- (r'\n', Whitespace, '#pop'),
- (r'\s', Whitespace),
+ 'comments.in': [
+ (r'\*\/', Comment.Multi, '#pop'),
+ (r'/\*', Comment.Multi, '#push'),
+ (r'[^*/]+', Comment.Multi),
+ (r'\*(?!/)', Comment.Multi),
+ (r'/', Comment.Multi),
],
- 'fromimportfunc': [
- include('common'),
- (r'(::)(\s+)([^,\s]+)', bygroups(Punctuation, Text, Keyword.Type)),
- (r'([\w`$()=\-<>~*\^|+&%/]+)', check_instance_class),
- (r',', Punctuation),
- (r'\n', Whitespace, '#pop'),
- (r'\s', Whitespace),
+ 'keywords': [
+ (words(keywords, prefix=r'\b', suffix=r'\b'), Keyword),
],
- 'fromimportfunctype': [
- include('common'),
- (r'[{(\[]', Punctuation, 'combtype'),
- (r',', Punctuation, '#pop'),
- (r'[:;.#]', Punctuation),
- (r'\n', Whitespace, '#pop:2'),
- (r'[^\S\n]+', Whitespace),
- (r'\S+', Keyword.Type),
+ 'module': [
+ (words(modulewords, prefix=r'\b', suffix=r'\b'), Keyword.Namespace),
+ (r'\bmodule\b', Keyword.Namespace, 'module.name'),
],
- 'combtype': [
- include('common'),
- (r'[})\]]', Punctuation, '#pop'),
- (r'[{(\[]', Punctuation, '#pop'),
- (r'[,:;.#]', Punctuation),
- (r'\s+', Whitespace),
- (r'\S+', Keyword.Type),
+ 'module.name': [
+ include('whitespace'),
+ (moduleId, Name.Class, '#pop'),
],
'import': [
- include('common'),
- (words(('from', 'import', 'as', 'qualified'),
- prefix='(?<=\s)', suffix='(?=\s)'), Keyword.Namespace),
- (r'[\w`.]+', Name.Class),
- (r'\n', Whitespace, '#pop'),
- (r',', Punctuation),
- (r'[^\S\n]+', Whitespace),
- ],
- 'singlecomment': [
- (r'(.)(?=\n)', skip),
- (r'.+(?!\n)', Comment),
- ],
- 'doubleqstring': [
- (r'[^\\"]+', String.Double),
- (r'"', String.Double, '#pop'),
- (r'\\.', String.Double),
- ],
- 'typedef': [
- include('common'),
- (r'[\w`]+', Keyword.Type),
- (r'[:=|(),\[\]{}!*]', Punctuation),
- (r'->', Punctuation),
- (r'\n(?=[^\s|])', Whitespace, '#pop'),
- (r'\s', Whitespace),
- (r'.', Keyword.Type),
+ (r'\b(import)\b(\s*)', bygroups(Keyword, Whitespace), 'import.module'),
+ (r'\b(from)\b(\s*)\b(' + moduleId + r')\b(\s*)\b(import)\b',
+ bygroups(Keyword, Whitespace, Name.Class, Whitespace, Keyword),
+ 'import.what'),
+ ],
+ 'import.module': [
+ (r'\b(qualified)\b(\s*)', bygroups(Keyword, Whitespace)),
+ (r'(\s*)\b(as)\b', bygroups(Whitespace, Keyword), ('#pop', 'import.module.as')),
+ (moduleId, Name.Class),
+ (r'(\s*)(,)(\s*)', bygroups(Whitespace, Punctuation, Whitespace)),
+ (r'\s*', Whitespace, '#pop'),
+ ],
+ 'import.module.as': [
+ include('whitespace'),
+ (lowerId, Name.Class, '#pop'),
+ (upperId, Name.Class, '#pop'),
+ ],
+ 'import.what': [
+ (r'\b(class)\b(\s+)(' + classId + r')',
+ bygroups(Keyword, Whitespace, Name.Class), 'import.what.class'),
+ (r'\b(instance)(\s+)(' + classId + r')(\s+)',
+ bygroups(Keyword, Whitespace, Name.Class, Whitespace), 'import.what.instance'),
+ (r'(::)(\s*)\b(' + upperId + r')\b',
+ bygroups(Punctuation, Whitespace, Name.Class), 'import.what.type'),
+ (r'\b(generic)\b(\s+)\b(' + lowerId + '|' + upperId + r')\b',
+ bygroups(Keyword, Whitespace, Name)),
+ include('names'),
+ (r'(,)(\s+)', bygroups(Punctuation, Whitespace)),
+ (r'$', Whitespace, '#pop'),
+ include('whitespace'),
+ ],
+ 'import.what.class': [
+ (r',', Punctuation, '#pop'),
+ (r'\(', Punctuation, 'import.what.class.members'),
+ (r'$', Whitespace, '#pop:2'),
+ include('whitespace'),
],
- 'genericfunction': [
- include('common'),
- (r'\{\|', Punctuation),
- (r'\|\}', Punctuation, '#pop'),
+ 'import.what.class.members': [
(r',', Punctuation),
- (r'->', Punctuation),
- (r'(\s+of\s+)(\{)', bygroups(Keyword, Punctuation), 'genericftypes'),
- (r'\s', Whitespace),
- (r'[\w`\[\]{}!]+', Keyword.Type),
- (r'[*()]', Punctuation),
+ (r'\.\.', Punctuation),
+ (r'\)', Punctuation, '#pop'),
+ include('names'),
+ ],
+ 'import.what.instance': [
+ (r'[,)]', Punctuation, '#pop'),
+ (r'\(', Punctuation, 'import.what.instance'),
+ (r'$', Whitespace, '#pop:2'),
+ include('whitespace'),
+ include('names'),
+ ],
+ 'import.what.type': [
+ (r',', Punctuation, '#pop'),
+ (r'[({]', Punctuation, 'import.what.type.consesandfields'),
+ (r'$', Whitespace, '#pop:2'),
+ include('whitespace'),
],
- 'genericftypes': [
- include('common'),
- (r'[\w`]+', Keyword.Type),
+ 'import.what.type.consesandfields': [
(r',', Punctuation),
- (r'\s', Whitespace),
- (r'\}', Punctuation, '#pop'),
- ],
- 'functiondefargs': [
- include('common'),
- (r'\n(\s*)', check_indent1),
- (r'[!{}()\[\],:;.#]', Punctuation),
- (r'->', Punctuation, 'functiondefres'),
- (r'^(?=\S)', Whitespace, '#pop'),
- (r'\S', Keyword.Type),
- (r'\s', Whitespace),
- ],
- 'functiondefres': [
- include('common'),
- (r'\n(\s*)', check_indent2),
- (r'^(?=\S)', Whitespace, '#pop:2'),
- (r'[!{}()\[\],:;.#]', Punctuation),
- (r'\|', Punctuation, 'functiondefclasses'),
- (r'\S', Keyword.Type),
- (r'\s', Whitespace),
- ],
- 'functiondefclasses': [
- include('common'),
- (r'\n(\s*)', check_indent3),
- (r'^(?=\S)', Whitespace, '#pop:3'),
- (r'[,&]', Punctuation),
- (r'\[', Punctuation, 'functiondefuniquneq'),
- (r'[\w`$()=\-<>~*\^|+&%/{}\[\]@]', Name.Function, 'functionname'),
- (r'\s+', Whitespace),
- ],
- 'functiondefuniquneq': [
- include('common'),
- (r'[a-z]+', Keyword.Type),
- (r'\s+', Whitespace),
- (r'<=|,', Punctuation),
- (r'\]', Punctuation, '#pop')
- ],
- 'functionname': [
- include('common'),
- (r'[\w`$()=\-<>~*\^|+&%/]+', Name.Function),
- (r'(?=\{\|)', Punctuation, 'genericfunction'),
- default('#pop'),
+ (r'\.\.', Punctuation),
+ (r'[)}]', Punctuation, '#pop'),
+ include('names'),
+ ],
+ 'literals': [
+ (r'\'([^\'\\]|\\(x[\da-fA-F]+|\d+|.))\'', Literal.Char),
+ (r'[+~-]?0[0-7]+\b', Number.Oct),
+ (r'[+~-]?\d+\.\d+(E[+-]?\d+)?', Number.Float),
+ (r'[+~-]?\d+\b', Number.Integer),
+ (r'[+~-]?0x[\da-fA-F]+\b', Number.Hex),
+ (r'True|False', Literal),
+ (r'"', String.Double, 'literals.stringd'),
+ ],
+ 'literals.stringd': [
+ (r'[^\\"\n]+', String.Double),
+ (r'"', String.Double, '#pop'),
+ (r'\\.', String.Double),
+ (r'[$\n]', Error, '#pop'),
+ ],
+ 'operators': [
+ (r'[-~@#\$%\^?!+*<>\\/|&=:\.]+', Operator),
+ (r'\b_+\b', Operator),
+ ],
+ 'delimiters': [
+ (r'[,;(){}\[\]]', Punctuation),
+ (r'(\')([\w`.]+)(\')',
+ bygroups(Punctuation, Name.Class, Punctuation)),
+ ],
+ 'names': [
+ (lowerId, Name),
+ (scoreLowerId, Name),
+ (funnyId, Name.Function),
+ (upperId, Name.Class),
+ (scoreUpperId, Name.Class),
]
}
diff --git a/pygments/lexers/configs.py b/pygments/lexers/configs.py
index c39b1a52..4af2adb6 100644
--- a/pygments/lexers/configs.py
+++ b/pygments/lexers/configs.py
@@ -15,6 +15,7 @@ from pygments.lexer import RegexLexer, default, words, bygroups, include, using
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
Number, Punctuation, Whitespace, Literal
from pygments.lexers.shell import BashLexer
+from pygments.lexers.data import JsonLexer
__all__ = ['IniLexer', 'RegeditLexer', 'PropertiesLexer', 'KconfigLexer',
'Cfengine3Lexer', 'ApacheConfLexer', 'SquidConfLexer',
@@ -539,20 +540,25 @@ class DockerLexer(RegexLexer):
filenames = ['Dockerfile', '*.docker']
mimetypes = ['text/x-dockerfile-config']
- _keywords = (r'(?:FROM|MAINTAINER|CMD|EXPOSE|ENV|ADD|ENTRYPOINT|'
- r'VOLUME|WORKDIR)')
-
+ _keywords = (r'(?:FROM|MAINTAINER|EXPOSE|WORKDIR|USER|STOPSIGNAL)')
+ _bash_keywords = (r'(?:RUN|CMD|ENTRYPOINT|ENV|ARG|LABEL|ADD|COPY)')
+ _lb = r'(?:\s*\\?\s*)' # dockerfile line break regex
flags = re.IGNORECASE | re.MULTILINE
tokens = {
'root': [
- (r'^(ONBUILD)(\s+)(%s)\b' % (_keywords,),
- bygroups(Name.Keyword, Whitespace, Keyword)),
- (r'^(%s)\b(.*)' % (_keywords,), bygroups(Keyword, String)),
(r'#.*', Comment),
- (r'RUN', Keyword), # Rest of line falls through
+ (r'(ONBUILD)(%s)' % (_lb,), bygroups(Keyword, using(BashLexer))),
+ (r'(HEALTHCHECK)((%s--\w+=\w+%s)*)' % (_lb, _lb),
+ bygroups(Keyword, using(BashLexer))),
+ (r'(VOLUME|ENTRYPOINT|CMD|SHELL)(%s)(\[.*?\])' % (_lb,),
+ bygroups(Keyword, using(BashLexer), using(JsonLexer))),
+ (r'(LABEL|ENV|ARG)((%s\w+=\w+%s)*)' % (_lb, _lb),
+ bygroups(Keyword, using(BashLexer))),
+ (r'(%s|VOLUME)\b(.*)' % (_keywords), bygroups(Keyword, String)),
+ (r'(%s)' % (_bash_keywords,), Keyword),
(r'(.*\\\n)*.+', using(BashLexer)),
- ],
+ ]
}
diff --git a/pygments/lexers/csound.py b/pygments/lexers/csound.py
index 858aa348..b86de091 100644
--- a/pygments/lexers/csound.py
+++ b/pygments/lexers/csound.py
@@ -3,7 +3,7 @@
pygments.lexers.csound
~~~~~~~~~~~~~~~~~~~~~~
- Lexers for CSound languages.
+ Lexers for Csound languages.
:copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
@@ -12,9 +12,9 @@
import re
from pygments.lexer import RegexLexer, bygroups, default, include, using, words
-from pygments.token import Comment, Keyword, Name, Number, Operator, Punctuation, \
- String, Text
-from pygments.lexers._csound_builtins import OPCODES
+from pygments.token import Comment, Error, Keyword, Name, Number, Operator, Punctuation, \
+ String, Text, Whitespace
+from pygments.lexers._csound_builtins import OPCODES, DEPRECATED_OPCODES
from pygments.lexers.html import HtmlLexer
from pygments.lexers.python import PythonLexer
from pygments.lexers.scripting import LuaLexer
@@ -25,74 +25,104 @@ newline = (r'((?:(?:;|//).*)*)(\n)', bygroups(Comment.Single, Text))
class CsoundLexer(RegexLexer):
- # Subclasses must define a 'single-line string' state.
tokens = {
'whitespace': [
(r'[ \t]+', Text),
- (r'\\\n', Text),
- (r'/[*](.|\n)*?[*]/', Comment.Multiline)
+ (r'/[*](?:.|\n)*?[*]/', Comment.Multiline),
+ (r'(?:;|//).*$', Comment.Single),
+ (r'(\\)(\n)', bygroups(Whitespace, Text))
],
- 'macro call': [
- (r'(\$\w+\.?)(\()', bygroups(Comment.Preproc, Punctuation),
- 'function macro call'),
- (r'\$\w+(\.|\b)', Comment.Preproc)
- ],
- 'function macro call': [
- (r"((?:\\['\)]|[^'\)])+)(')", bygroups(Comment.Preproc, Punctuation)),
- (r"([^'\)]+)(\))", bygroups(Comment.Preproc, Punctuation), '#pop')
+ 'preprocessor directives': [
+ (r'#(?:e(?:nd(?:if)?|lse)\b|##)|@@?[ \t]*\d+', Comment.Preproc),
+ (r'#include', Comment.Preproc, 'include directive'),
+ (r'#[ \t]*define', Comment.Preproc, 'define directive'),
+ (r'#(?:ifn?def|undef)\b', Comment.Preproc, 'macro directive')
],
- 'whitespace or macro call': [
+ 'include directive': [
include('whitespace'),
- include('macro call')
+ (r'([^ \t]).*?\1', String, '#pop')
],
- 'preprocessor directives': [
- (r'#(e(nd(if)?|lse)|ifn?def|undef)\b|##', Comment.Preproc),
- (r'#include\b', Comment.Preproc, 'include'),
- (r'#[ \t]*define\b', Comment.Preproc, 'macro name'),
- (r'@+[ \t]*\d*', Comment.Preproc)
+ 'define directive': [
+ (r'\n', Text),
+ include('whitespace'),
+ (r'([A-Z_a-z]\w*)(\()', bygroups(Comment.Preproc, Punctuation),
+ ('#pop', 'macro parameter name list')),
+ (r'[A-Z_a-z]\w*', Comment.Preproc, ('#pop', 'before macro body'))
],
-
- 'include': [
+ 'macro parameter name list': [
include('whitespace'),
- (r'"', String, 'single-line string')
+ (r'[A-Z_a-z]\w*', Comment.Preproc),
+ (r"['#]", Punctuation),
+ (r'\)', Punctuation, ('#pop', 'before macro body'))
],
-
- 'macro name': [
+ 'before macro body': [
+ (r'\n', Text),
include('whitespace'),
- (r'(\w+)(\()', bygroups(Comment.Preproc, Text),
- 'function macro argument list'),
- (r'\w+', Comment.Preproc, 'object macro definition after name')
+ (r'#', Punctuation, ('#pop', 'macro body'))
+ ],
+ 'macro body': [
+ (r'(?:\\(?!#)|[^#\\]|\n)+', Comment.Preproc),
+ (r'\\#', Comment.Preproc),
+ (r'(?<!\\)#', Punctuation, '#pop')
],
- 'object macro definition after name': [
+
+ 'macro directive': [
include('whitespace'),
- (r'#', Punctuation, 'object macro replacement text')
+ (r'[A-Z_a-z]\w*', Comment.Preproc, '#pop')
+ ],
+
+ 'macro uses': [
+ (r'(\$[A-Z_a-z]\w*\.?)(\()', bygroups(Comment.Preproc, Punctuation),
+ 'macro parameter value list'),
+ (r'\$[A-Z_a-z]\w*(?:\.|\b)', Comment.Preproc)
],
- 'object macro replacement text': [
- (r'(\\#|[^#])+', Comment.Preproc),
- (r'#', Punctuation, '#pop:3')
+ 'macro parameter value list': [
+ (r'(?:[^\'#"{()]|\{(?!\{))+', Comment.Preproc),
+ (r"['#]", Punctuation),
+ (r'"', String, 'macro parameter value quoted string'),
+ (r'\{\{', String, 'macro parameter value braced string'),
+ (r'\(', Comment.Preproc, 'macro parameter value parenthetical'),
+ (r'\)', Punctuation, '#pop')
],
- 'function macro argument list': [
- (r"(\w+)(['#])", bygroups(Comment.Preproc, Punctuation)),
- (r'(\w+)(\))', bygroups(Comment.Preproc, Punctuation),
- 'function macro definition after name')
+ 'macro parameter value quoted string': [
+ (r"\\[#'()]", Comment.Preproc),
+ (r"[#'()]", Error),
+ include('quoted string')
],
- 'function macro definition after name': [
- (r'[ \t]+', Text),
- (r'#', Punctuation, 'function macro replacement text')
+ 'macro parameter value braced string': [
+ (r"\\[#'()]", Comment.Preproc),
+ (r"[#'()]", Error),
+ include('braced string')
+ ],
+ 'macro parameter value parenthetical': [
+ (r'(?:[^\\()]|\\\))+', Comment.Preproc),
+ (r'\(', Comment.Preproc, '#push'),
+ (r'\)', Comment.Preproc, '#pop')
],
- 'function macro replacement text': [
- (r'(\\#|[^#])+', Comment.Preproc),
- (r'#', Punctuation, '#pop:4')
+
+ 'whitespace and macro uses': [
+ include('whitespace'),
+ include('macro uses')
+ ],
+
+ 'numbers': [
+ (r'\d+[Ee][+-]?\d+|(\d+\.\d*|\d*\.\d+)([Ee][+-]?\d+)?', Number.Float),
+ (r'(0[Xx])([0-9A-Fa-f]+)', bygroups(Keyword.Type, Number.Hex)),
+ (r'\d+', Number.Integer)
+ ],
+
+ 'braced string': [
+ # Do nothing. This must be defined in subclasses.
]
}
class CsoundScoreLexer(CsoundLexer):
"""
- For `Csound <http://csound.github.io>`_ scores.
+ For `Csound <https://csound.github.io>`_ scores.
.. versionadded:: 2.1
"""
@@ -102,47 +132,77 @@ class CsoundScoreLexer(CsoundLexer):
filenames = ['*.sco']
tokens = {
- 'partial statement': [
+ 'root': [
+ (r'\n', Text),
+ include('whitespace and macro uses'),
include('preprocessor directives'),
- (r'\d+e[+-]?\d+|(\d+\.\d*|\d*\.\d+)(e[+-]?\d+)?', Number.Float),
- (r'0[xX][a-fA-F0-9]+', Number.Hex),
- (r'\d+', Number.Integer),
- (r'"', String, 'single-line string'),
- (r'[+\-*/%^!=<>|&#~.]', Operator),
- (r'[]()[]', Punctuation),
- (r'\w+', Comment.Preproc)
- ],
- 'statement': [
- include('whitespace or macro call'),
- newline + ('#pop',),
- include('partial statement')
+ (r'[abCdefiqstvxy]', Keyword),
+ # There is also a w statement that is generated internally and should not be
+ # used; see https://github.com/csound/csound/issues/750.
+
+ (r'z', Keyword.Constant),
+ # z is a constant equal to 800,000,000,000. 800 billion seconds is about
+ # 25,367.8 years. See also
+ # https://csound.github.io/docs/manual/ScoreTop.html and
+ # https://github.com/csound/csound/search?q=stof+path%3AEngine+filename%3Asread.c.
+
+ (r'([nNpP][pP])(\d+)', bygroups(Keyword, Number.Integer)),
+
+ (r'[mn]', Keyword, 'mark statement'),
+
+ include('numbers'),
+ (r'[!+\-*/^%&|<>#~.]', Operator),
+ (r'[()\[\]]', Punctuation),
+ (r'"', String, 'quoted string'),
+ (r'\{', Comment.Preproc, 'loop after left brace'),
],
- 'root': [
- newline,
- include('whitespace or macro call'),
- (r'[{}]', Punctuation, 'statement'),
- (r'[abefimq-tv-z]|[nN][pP]?', Keyword, 'statement')
+ 'mark statement': [
+ include('whitespace and macro uses'),
+ (r'[A-Z_a-z]\w*', Name.Label),
+ (r'\n', Text, '#pop')
],
- 'single-line string': [
+ 'quoted string': [
(r'"', String, '#pop'),
- (r'[^\\"]+', String)
+ (r'[^"$]+', String),
+ include('macro uses'),
+ (r'[$]', String)
+ ],
+
+ 'loop after left brace': [
+ include('whitespace and macro uses'),
+ (r'\d+', Number.Integer, ('#pop', 'loop after repeat count')),
+ ],
+ 'loop after repeat count': [
+ include('whitespace and macro uses'),
+ (r'[A-Z_a-z]\w*', Comment.Preproc, ('#pop', 'loop'))
+ ],
+ 'loop': [
+ (r'\}', Comment.Preproc, '#pop'),
+ include('root')
+ ],
+
+ # Braced strings are not allowed in Csound scores, but this is needed
+ # because the superclass includes it.
+ 'braced string': [
+ (r'\}\}', String, '#pop'),
+ (r'[^}]|\}(?!\})', String)
]
}
class CsoundOrchestraLexer(CsoundLexer):
"""
- For `Csound <http://csound.github.io>`_ orchestras.
+ For `Csound <https://csound.github.io>`_ orchestras.
.. versionadded:: 2.1
"""
name = 'Csound Orchestra'
aliases = ['csound', 'csound-orc']
- filenames = ['*.orc']
+ filenames = ['*.orc', '*.udo']
user_defined_opcodes = set()
@@ -152,13 +212,16 @@ class CsoundOrchestraLexer(CsoundLexer):
yield match.start(), Name.Function, opcode
def name_callback(lexer, match):
- name = match.group(0)
- if re.match('p\d+$', name) or name in OPCODES:
+ name = match.group(1)
+ if name in OPCODES or name in DEPRECATED_OPCODES:
yield match.start(), Name.Builtin, name
+ if match.group(2):
+ yield match.start(2), Punctuation, match.group(2)
+ yield match.start(3), Keyword.Type, match.group(3)
elif name in lexer.user_defined_opcodes:
yield match.start(), Name.Function, name
else:
- nameMatch = re.search(r'^(g?[aikSw])(\w+)', name)
+ nameMatch = re.search(r'^(g?[afikSw])(\w+)', name)
if nameMatch:
yield nameMatch.start(1), Keyword.Type, nameMatch.group(1)
yield nameMatch.start(2), Name, nameMatch.group(2)
@@ -166,145 +229,165 @@ class CsoundOrchestraLexer(CsoundLexer):
yield match.start(), Name, name
tokens = {
- 'label': [
- (r'\b(\w+)(:)', bygroups(Name.Label, Punctuation))
- ],
+ 'root': [
+ (r'\n', Text),
+
+ (r'^([ \t]*)(\w+)(:)(?:[ \t]+|$)', bygroups(Text, Name.Label, Punctuation)),
- 'partial expression': [
+ include('whitespace and macro uses'),
include('preprocessor directives'),
- (r'\b(0dbfs|k(r|smps)|nchnls(_i)?|sr)\b', Name.Variable.Global),
- (r'\d+e[+-]?\d+|(\d+\.\d*|\d*\.\d+)(e[+-]?\d+)?', Number.Float),
- (r'0[xX][a-fA-F0-9]+', Number.Hex),
- (r'\d+', Number.Integer),
- (r'"', String, 'single-line string'),
- (r'\{\{', String, 'multi-line string'),
- (r'[+\-*/%^!=&|<>#~¬]', Operator),
- (r'[](),?:[]', Punctuation),
+
+ (r'\binstr\b', Keyword.Declaration, 'instrument numbers and identifiers'),
+ (r'\bopcode\b', Keyword.Declaration, 'after opcode keyword'),
+ (r'\b(?:end(?:in|op))\b', Keyword.Declaration),
+
+ include('partial statements')
+ ],
+
+ 'partial statements': [
+ (r'\b(?:0dbfs|A4|k(?:r|smps)|nchnls(?:_i)?|sr)\b', Name.Variable.Global),
+
+ include('numbers'),
+
+ (r'\+=|-=|\*=|/=|<<|>>|<=|>=|==|!=|&&|\|\||[~¬]|[=!+\-*/^%&|<>#?:]', Operator),
+ (r'[(),\[\]]', Punctuation),
+
+ (r'"', String, 'quoted string'),
+ (r'\{\{', String, 'braced string'),
+
(words((
- # Keywords
'do', 'else', 'elseif', 'endif', 'enduntil', 'fi', 'if', 'ithen', 'kthen',
'od', 'then', 'until', 'while',
- # Opcodes that act as control structures
- 'return', 'timout'
), prefix=r'\b', suffix=r'\b'), Keyword),
- (words(('goto', 'igoto', 'kgoto', 'rigoto', 'tigoto'),
- prefix=r'\b', suffix=r'\b'), Keyword, 'goto label'),
- (words(('cggoto', 'cigoto', 'cingoto', 'ckgoto', 'cngoto'),
- prefix=r'\b', suffix=r'\b'), Keyword,
- ('goto label', 'goto expression')),
- (words(('loop_ge', 'loop_gt', 'loop_le', 'loop_lt'),
- prefix=r'\b', suffix=r'\b'), Keyword,
- ('goto label', 'goto expression', 'goto expression', 'goto expression')),
- (r'\bscoreline(_i)?\b', Name.Builtin, 'scoreline opcode'),
- (r'\bpyl?run[it]?\b', Name.Builtin, 'python opcode'),
- (r'\blua_(exec|opdef)\b', Name.Builtin, 'lua opcode'),
- (r'\b[a-zA-Z_]\w*\b', name_callback)
- ],
-
- 'expression': [
- include('whitespace or macro call'),
- newline + ('#pop',),
- include('partial expression')
- ],
+ (words(('return', 'rireturn'), prefix=r'\b', suffix=r'\b'), Keyword.Pseudo),
- 'root': [
- newline,
- include('whitespace or macro call'),
- (r'\binstr\b', Keyword, ('instrument block', 'instrument name list')),
- (r'\bopcode\b', Keyword, ('opcode block', 'opcode parameter list',
- 'opcode types', 'opcode types', 'opcode name')),
- include('label'),
- default('expression')
- ],
-
- 'instrument name list': [
- include('whitespace or macro call'),
- (r'\d+|\+?[a-zA-Z_]\w*', Name.Function),
- (r',', Punctuation),
- newline + ('#pop',)
+ (r'\b[ik]?goto\b', Keyword, 'goto label'),
+ (r'\b(r(?:einit|igoto)|tigoto)(\(|\b)', bygroups(Keyword.Pseudo, Punctuation),
+ 'goto label'),
+ (r'\b(c(?:g|in?|k|nk?)goto)(\(|\b)', bygroups(Keyword.Pseudo, Punctuation),
+ ('goto label', 'goto argument')),
+ (r'\b(timout)(\(|\b)', bygroups(Keyword.Pseudo, Punctuation),
+ ('goto label', 'goto argument', 'goto argument')),
+ (r'\b(loop_[gl][et])(\(|\b)', bygroups(Keyword.Pseudo, Punctuation),
+ ('goto label', 'goto argument', 'goto argument', 'goto argument')),
+
+ (r'\bprintk?s\b', Name.Builtin, 'prints opcode'),
+ (r'\b(?:readscore|scoreline(?:_i)?)\b', Name.Builtin, 'Csound score opcode'),
+ (r'\bpyl?run[it]?\b', Name.Builtin, 'Python opcode'),
+ (r'\blua_(?:exec|opdef)\b', Name.Builtin, 'Lua opcode'),
+ (r'\bp\d+\b', Name.Variable.Instance),
+ (r'\b([A-Z_a-z]\w*)(?:(:)([A-Za-z]))?\b', name_callback)
],
- 'instrument block': [
- newline,
- include('whitespace or macro call'),
- (r'\bendin\b', Keyword, '#pop'),
- include('label'),
- default('expression')
+
+ 'instrument numbers and identifiers': [
+ include('whitespace and macro uses'),
+ (r'\d+|[A-Z_a-z]\w*', Name.Function),
+ (r'[+,]', Punctuation),
+ (r'\n', Text, '#pop')
],
- 'opcode name': [
- include('whitespace or macro call'),
- (r'[a-zA-Z_]\w*', opcode_name_callback, '#pop')
+ 'after opcode keyword': [
+ include('whitespace and macro uses'),
+ (r'[A-Z_a-z]\w*', opcode_name_callback, ('#pop', 'opcode type signatures')),
+ (r'\n', Text, '#pop')
],
- 'opcode types': [
- include('whitespace or macro call'),
- (r'0|[]afijkKoOpPStV[]+', Keyword.Type, '#pop'),
- (r',', Punctuation)
+ 'opcode type signatures': [
+ include('whitespace and macro uses'),
+
+ # https://github.com/csound/csound/search?q=XIDENT+path%3AEngine+filename%3Acsound_orc.lex
+ (r'0|[afijkKoOpPStV\[\]]+', Keyword.Type),
+
+ (r',', Punctuation),
+ (r'\n', Text, '#pop')
],
- 'opcode parameter list': [
- include('whitespace or macro call'),
- newline + ('#pop',)
+
+ 'quoted string': [
+ (r'"', String, '#pop'),
+ (r'[^\\"$%)]+', String),
+ include('macro uses'),
+ include('escape sequences'),
+ include('format specifiers'),
+ (r'[\\$%)]', String)
],
- 'opcode block': [
- newline,
- include('whitespace or macro call'),
- (r'\bendop\b', Keyword, '#pop'),
- include('label'),
- default('expression')
+ 'braced string': [
+ (r'\}\}', String, '#pop'),
+ (r'(?:[^\\%)}]|\}(?!\}))+', String),
+ include('escape sequences'),
+ include('format specifiers'),
+ (r'[\\%)]', String)
+ ],
+ 'escape sequences': [
+ # https://github.com/csound/csound/search?q=unquote_string+path%3AEngine+filename%3Acsound_orc_compile.c
+ (r'\\(?:[\\abnrt"]|[0-7]{1,3})', String.Escape)
+ ],
+ # Format specifiers are highlighted in all strings, even though only
+ # fprintks https://csound.github.io/docs/manual/fprintks.html
+ # fprints https://csound.github.io/docs/manual/fprints.html
+ # printf/printf_i https://csound.github.io/docs/manual/printf.html
+ # printks https://csound.github.io/docs/manual/printks.html
+ # prints https://csound.github.io/docs/manual/prints.html
+ # sprintf https://csound.github.io/docs/manual/sprintf.html
+ # sprintfk https://csound.github.io/docs/manual/sprintfk.html
+ # work with strings that contain format specifiers. In addition, these
+ # opcodes’ handling of format specifiers is inconsistent:
+ # - fprintks, fprints, printks, and prints do accept %a and %A
+ # specifiers, but can’t accept %s specifiers.
+ # - printf, printf_i, sprintf, and sprintfk don’t accept %a and %A
+ # specifiers, but can accept %s specifiers.
+ # See https://github.com/csound/csound/issues/747 for more information.
+ 'format specifiers': [
+ (r'%[#0\- +]*\d*(?:\.\d+)?[diuoxXfFeEgGaAcs]', String.Interpol),
+ (r'%%', String.Escape)
+ ],
+
+ 'goto argument': [
+ include('whitespace and macro uses'),
+ (r',', Punctuation, '#pop'),
+ include('partial statements')
],
-
'goto label': [
- include('whitespace or macro call'),
+ include('whitespace and macro uses'),
(r'\w+', Name.Label, '#pop'),
default('#pop')
],
- 'goto expression': [
- include('whitespace or macro call'),
- (r',', Punctuation, '#pop'),
- include('partial expression')
- ],
- 'single-line string': [
- include('macro call'),
- (r'"', String, '#pop'),
- # From https://github.com/csound/csound/blob/develop/Opcodes/fout.c#L1405
- (r'%\d*(\.\d+)?[cdhilouxX]', String.Interpol),
- (r'%[!%nNrRtT]|[~^]|\\([\\aAbBnNrRtT"]|[0-7]{1,3})', String.Escape),
- (r'[^\\"~$%\^\n]+', String),
- (r'[\\"~$%\^\n]', String)
+ 'prints opcode': [
+ include('whitespace and macro uses'),
+ (r'"', String, 'prints quoted string'),
+ default('#pop')
],
- 'multi-line string': [
- (r'\}\}', String, '#pop'),
- (r'[^}]+|\}(?!\})', String)
+ 'prints quoted string': [
+ (r'\\\\[aAbBnNrRtT]', String.Escape),
+ (r'%[!nNrRtT]|[~^]{1,2}', String.Escape),
+ include('quoted string')
],
- 'scoreline opcode': [
- include('whitespace or macro call'),
- (r'\{\{', String, 'scoreline'),
- default('#pop')
+ 'Csound score opcode': [
+ include('whitespace and macro uses'),
+ (r'\{\{', String, 'Csound score'),
+ (r'\n', Text, '#pop')
],
- 'scoreline': [
+ 'Csound score': [
(r'\}\}', String, '#pop'),
(r'([^}]+)|\}(?!\})', using(CsoundScoreLexer))
],
- 'python opcode': [
- include('whitespace or macro call'),
- (r'\{\{', String, 'python'),
- default('#pop')
+ 'Python opcode': [
+ include('whitespace and macro uses'),
+ (r'\{\{', String, 'Python'),
+ (r'\n', Text, '#pop')
],
- 'python': [
+ 'Python': [
(r'\}\}', String, '#pop'),
(r'([^}]+)|\}(?!\})', using(PythonLexer))
],
- 'lua opcode': [
- include('whitespace or macro call'),
- (r'"', String, 'single-line string'),
- (r'\{\{', String, 'lua'),
- (r',', Punctuation),
- default('#pop')
+ 'Lua opcode': [
+ include('whitespace and macro uses'),
+ (r'\{\{', String, 'Lua'),
+ (r'\n', Text, '#pop')
],
- 'lua': [
+ 'Lua': [
(r'\}\}', String, '#pop'),
(r'([^}]+)|\}(?!\})', using(LuaLexer))
]
@@ -313,7 +396,7 @@ class CsoundOrchestraLexer(CsoundLexer):
class CsoundDocumentLexer(RegexLexer):
"""
- For `Csound <http://csound.github.io>`_ documents.
+ For `Csound <https://csound.github.io>`_ documents.
.. versionadded:: 2.1
"""
@@ -331,15 +414,18 @@ class CsoundDocumentLexer(RegexLexer):
# be XML files.
tokens = {
'root': [
- newline,
(r'/[*](.|\n)*?[*]/', Comment.Multiline),
- (r'[^<&;/]+', Text),
+ (r'(?:;|//).*$', Comment.Single),
+ (r'[^/;<]+|/(?!/)', Text),
+
(r'<\s*CsInstruments', Name.Tag, ('orchestra', 'tag')),
(r'<\s*CsScore', Name.Tag, ('score', 'tag')),
- (r'<\s*[hH][tT][mM][lL]', Name.Tag, ('HTML', 'tag')),
+ (r'<\s*[Hh][Tt][Mm][Ll]', Name.Tag, ('HTML', 'tag')),
+
(r'<\s*[\w:.-]+', Name.Tag, 'tag'),
(r'<\s*/\s*[\w:.-]+\s*>', Name.Tag)
],
+
'orchestra': [
(r'<\s*/\s*CsInstruments\s*>', Name.Tag, '#pop'),
(r'(.|\n)+?(?=<\s*/\s*CsInstruments\s*>)', using(CsoundOrchestraLexer))
@@ -349,9 +435,10 @@ class CsoundDocumentLexer(RegexLexer):
(r'(.|\n)+?(?=<\s*/\s*CsScore\s*>)', using(CsoundScoreLexer))
],
'HTML': [
- (r'<\s*/\s*[hH][tT][mM][lL]\s*>', Name.Tag, '#pop'),
- (r'(.|\n)+?(?=<\s*/\s*[hH][tT][mM][lL]\s*>)', using(HtmlLexer))
+ (r'<\s*/\s*[Hh][Tt][Mm][Ll]\s*>', Name.Tag, '#pop'),
+ (r'(.|\n)+?(?=<\s*/\s*[Hh][Tt][Mm][Ll]\s*>)', using(HtmlLexer))
],
+
'tag': [
(r'\s+', Text),
(r'[\w.:-]+\s*=', Name.Attribute, 'attr'),
diff --git a/pygments/lexers/css.py b/pygments/lexers/css.py
index 29d83707..ce97730e 100644
--- a/pygments/lexers/css.py
+++ b/pygments/lexers/css.py
@@ -125,7 +125,7 @@ _css_properties = (
'wrap-flow', 'wrap-inside', 'wrap-through', 'writing-mode', 'z-index',
)
-# List of keyword values obtained from:
+# List of keyword values obtained from:
# http://cssvalues.com/
_keyword_values = (
'absolute', 'alias', 'all', 'all-petite-caps', 'all-scroll',
@@ -263,7 +263,7 @@ _time_units = (
's', 'ms',
)
_all_units = _angle_units + _frequency_units + _length_units + \
- _resolution_units + _time_units
+ _resolution_units + _time_units
class CssLexer(RegexLexer):
@@ -322,16 +322,18 @@ class CssLexer(RegexLexer):
include('urls'),
(r'('+r'|'.join(_functional_notation_keyword_values)+r')(\()',
bygroups(Name.Builtin, Punctuation), 'function-start'),
- (r'([a-zA-Z_][\w-]+)(\()', bygroups(Name.Function, Punctuation), 'function-start'),
+ (r'([a-zA-Z_][\w-]+)(\()',
+ bygroups(Name.Function, Punctuation), 'function-start'),
(words(_keyword_values, suffix=r'\b'), Keyword.Constant),
(words(_other_keyword_values, suffix=r'\b'), Keyword.Constant),
(words(_color_keywords, suffix=r'\b'), Keyword.Constant),
- (words(_css_properties, suffix=r'\b'), Keyword), # for transition-property etc.
+ # for transition-property etc.
+ (words(_css_properties, suffix=r'\b'), Keyword),
(r'\!important', Comment.Preproc),
(r'/\*(?:.|\n)*?\*/', Comment),
include('numeric-values'),
-
+
(r'[~^*!%&<>|+=@:./?-]+', Operator),
(r'[\[\](),]+', Punctuation),
(r'"(\\\\|\\"|[^"])*"', String.Double),
@@ -351,7 +353,8 @@ class CssLexer(RegexLexer):
# function-start may be entered recursively
(r'(' + r'|'.join(_functional_notation_keyword_values) + r')(\()',
bygroups(Name.Builtin, Punctuation), 'function-start'),
- (r'([a-zA-Z_][\w-]+)(\()', bygroups(Name.Function, Punctuation), 'function-start'),
+ (r'([a-zA-Z_][\w-]+)(\()',
+ bygroups(Name.Function, Punctuation), 'function-start'),
(r'/\*(?:.|\n)*?\*/', Comment),
include('numeric-values'),
@@ -373,8 +376,8 @@ class CssLexer(RegexLexer):
'numeric-values': [
(r'\#[a-zA-Z0-9]{1,6}', Number.Hex),
(r'[+\-]?[0-9]*[.][0-9]+', Number.Float, 'numeric-end'),
- (r'[+\-]?[0-9]+', Number.Integer, 'numeric-end'),
- ],
+ (r'[+\-]?[0-9]+', Number.Integer, 'numeric-end'),
+ ],
'numeric-end': [
(words(_all_units, suffix=r'\b'), Keyword.Type),
(r'%', Keyword.Type),
@@ -466,9 +469,9 @@ common_sass_tokens = {
],
'string-single': [
- (r"(\\.|#(?=[^\n{])|[^\n'#])+", String.Double),
+ (r"(\\.|#(?=[^\n{])|[^\n'#])+", String.Single),
(r'#\{', String.Interpol, 'interpolation'),
- (r"'", String.Double, '#pop'),
+ (r"'", String.Single, '#pop'),
],
'string-url': [
diff --git a/pygments/lexers/graphics.py b/pygments/lexers/graphics.py
index c8af9f99..fa5aa372 100644
--- a/pygments/lexers/graphics.py
+++ b/pygments/lexers/graphics.py
@@ -15,7 +15,7 @@ from pygments.token import Text, Comment, Operator, Keyword, Name, \
Number, Punctuation, String
__all__ = ['GLShaderLexer', 'PostScriptLexer', 'AsymptoteLexer', 'GnuplotLexer',
- 'PovrayLexer']
+ 'PovrayLexer', 'HLSLShaderLexer']
class GLShaderLexer(RegexLexer):
@@ -75,6 +75,160 @@ class GLShaderLexer(RegexLexer):
}
+class HLSLShaderLexer(RegexLexer):
+ """
+ HLSL (Microsoft Direct3D Shader) lexer.
+
+ .. versionadded:: 2.3
+ """
+ name = 'HLSL'
+ aliases = ['hlsl']
+ filenames = ['*.hlsl', '*.hlsli']
+ mimetypes = ['text/x-hlsl']
+
+ tokens = {
+ 'root': [
+ (r'^#.*', Comment.Preproc),
+ (r'//.*', Comment.Single),
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
+ (r'\+|-|~|!=?|\*|/|%|<<|>>|<=?|>=?|==?|&&?|\^|\|\|?',
+ Operator),
+ (r'[?:]', Operator), # quick hack for ternary
+ (r'\bdefined\b', Operator),
+ (r'[;{}(),.\[\]]', Punctuation),
+ # FIXME when e is present, no decimal point needed
+ (r'[+-]?\d*\.\d+([eE][-+]?\d+)?f?', Number.Float),
+ (r'[+-]?\d+\.\d*([eE][-+]?\d+)?f?', Number.Float),
+ (r'0[xX][0-9a-fA-F]*', Number.Hex),
+ (r'0[0-7]*', Number.Oct),
+ (r'[1-9][0-9]*', Number.Integer),
+ (r'"', String, 'string'),
+ (words((
+ 'asm','asm_fragment','break','case','cbuffer','centroid','class',
+ 'column_major','compile','compile_fragment','const','continue',
+ 'default','discard','do','else','export','extern','for','fxgroup',
+ 'globallycoherent','groupshared','if','in','inline','inout',
+ 'interface','line','lineadj','linear','namespace','nointerpolation',
+ 'noperspective','NULL','out','packoffset','pass','pixelfragment',
+ 'point','precise','return','register','row_major','sample',
+ 'sampler','shared','stateblock','stateblock_state','static',
+ 'struct','switch','tbuffer','technique','technique10',
+ 'technique11','texture','typedef','triangle','triangleadj',
+ 'uniform','vertexfragment','volatile','while'),
+ prefix=r'\b', suffix=r'\b'),
+ Keyword),
+ (words(('true','false'), prefix=r'\b', suffix=r'\b'),
+ Keyword.Constant),
+ (words((
+ 'auto','catch','char','const_cast','delete','dynamic_cast','enum',
+ 'explicit','friend','goto','long','mutable','new','operator',
+ 'private','protected','public','reinterpret_cast','short','signed',
+ 'sizeof','static_cast','template','this','throw','try','typename',
+ 'union','unsigned','using','virtual'),
+ prefix=r'\b', suffix=r'\b'),
+ Keyword.Reserved),
+ (words((
+ 'dword','matrix','snorm','string','unorm','unsigned','void','vector',
+ 'BlendState','Buffer','ByteAddressBuffer','ComputeShader',
+ 'DepthStencilState','DepthStencilView','DomainShader',
+ 'GeometryShader','HullShader','InputPatch','LineStream',
+ 'OutputPatch','PixelShader','PointStream','RasterizerState',
+ 'RenderTargetView','RasterizerOrderedBuffer',
+ 'RasterizerOrderedByteAddressBuffer',
+ 'RasterizerOrderedStructuredBuffer','RasterizerOrderedTexture1D',
+ 'RasterizerOrderedTexture1DArray','RasterizerOrderedTexture2D',
+ 'RasterizerOrderedTexture2DArray','RasterizerOrderedTexture3D',
+ 'RWBuffer','RWByteAddressBuffer','RWStructuredBuffer',
+ 'RWTexture1D','RWTexture1DArray','RWTexture2D','RWTexture2DArray',
+ 'RWTexture3D','SamplerState','SamplerComparisonState',
+ 'StructuredBuffer','Texture1D','Texture1DArray','Texture2D',
+ 'Texture2DArray','Texture2DMS','Texture2DMSArray','Texture3D',
+ 'TextureCube','TextureCubeArray','TriangleStream','VertexShader'),
+ prefix=r'\b', suffix=r'\b'),
+ Keyword.Type),
+ (words((
+ 'bool','double','float','int','half','min16float','min10float',
+ 'min16int','min12int','min16uint','uint'),
+ prefix=r'\b', suffix=r'([1-4](x[1-4])?)?\b'),
+ Keyword.Type), # vector and matrix types
+ (words((
+ 'abort','abs','acos','all','AllMemoryBarrier',
+ 'AllMemoryBarrierWithGroupSync','any','AppendStructuredBuffer',
+ 'asdouble','asfloat','asin','asint','asuint','asuint','atan',
+ 'atan2','ceil','CheckAccessFullyMapped','clamp','clip',
+ 'CompileShader','ConsumeStructuredBuffer','cos','cosh','countbits',
+ 'cross','D3DCOLORtoUBYTE4','ddx','ddx_coarse','ddx_fine','ddy',
+ 'ddy_coarse','ddy_fine','degrees','determinant',
+ 'DeviceMemoryBarrier','DeviceMemoryBarrierWithGroupSync','distance',
+ 'dot','dst','errorf','EvaluateAttributeAtCentroid',
+ 'EvaluateAttributeAtSample','EvaluateAttributeSnapped','exp',
+ 'exp2','f16tof32','f32tof16','faceforward','firstbithigh',
+ 'firstbitlow','floor','fma','fmod','frac','frexp','fwidth',
+ 'GetRenderTargetSampleCount','GetRenderTargetSamplePosition',
+ 'GlobalOrderedCountIncrement','GroupMemoryBarrier',
+ 'GroupMemoryBarrierWithGroupSync','InterlockedAdd','InterlockedAnd',
+ 'InterlockedCompareExchange','InterlockedCompareStore',
+ 'InterlockedExchange','InterlockedMax','InterlockedMin',
+ 'InterlockedOr','InterlockedXor','isfinite','isinf','isnan',
+ 'ldexp','length','lerp','lit','log','log10','log2','mad','max',
+ 'min','modf','msad4','mul','noise','normalize','pow','printf',
+ 'Process2DQuadTessFactorsAvg','Process2DQuadTessFactorsMax',
+ 'Process2DQuadTessFactorsMin','ProcessIsolineTessFactors',
+ 'ProcessQuadTessFactorsAvg','ProcessQuadTessFactorsMax',
+ 'ProcessQuadTessFactorsMin','ProcessTriTessFactorsAvg',
+ 'ProcessTriTessFactorsMax','ProcessTriTessFactorsMin',
+ 'QuadReadLaneAt','QuadSwapX','QuadSwapY','radians','rcp',
+ 'reflect','refract','reversebits','round','rsqrt','saturate',
+ 'sign','sin','sincos','sinh','smoothstep','sqrt','step','tan',
+ 'tanh','tex1D','tex1D','tex1Dbias','tex1Dgrad','tex1Dlod',
+ 'tex1Dproj','tex2D','tex2D','tex2Dbias','tex2Dgrad','tex2Dlod',
+ 'tex2Dproj','tex3D','tex3D','tex3Dbias','tex3Dgrad','tex3Dlod',
+ 'tex3Dproj','texCUBE','texCUBE','texCUBEbias','texCUBEgrad',
+ 'texCUBElod','texCUBEproj','transpose','trunc','WaveAllBitAnd',
+ 'WaveAllMax','WaveAllMin','WaveAllBitOr','WaveAllBitXor',
+ 'WaveAllEqual','WaveAllProduct','WaveAllSum','WaveAllTrue',
+ 'WaveAnyTrue','WaveBallot','WaveGetLaneCount','WaveGetLaneIndex',
+ 'WaveGetOrderedIndex','WaveIsHelperLane','WaveOnce',
+ 'WavePrefixProduct','WavePrefixSum','WaveReadFirstLane',
+ 'WaveReadLaneAt'),
+ prefix=r'\b', suffix=r'\b'),
+ Name.Builtin), # built-in functions
+ (words((
+ 'SV_ClipDistance','SV_ClipDistance0','SV_ClipDistance1',
+ 'SV_Culldistance','SV_CullDistance0','SV_CullDistance1',
+ 'SV_Coverage','SV_Depth','SV_DepthGreaterEqual',
+ 'SV_DepthLessEqual','SV_DispatchThreadID','SV_DomainLocation',
+ 'SV_GroupID','SV_GroupIndex','SV_GroupThreadID','SV_GSInstanceID',
+ 'SV_InnerCoverage','SV_InsideTessFactor','SV_InstanceID',
+ 'SV_IsFrontFace','SV_OutputControlPointID','SV_Position',
+ 'SV_PrimitiveID','SV_RenderTargetArrayIndex','SV_SampleIndex',
+ 'SV_StencilRef','SV_TessFactor','SV_VertexID',
+ 'SV_ViewportArrayIndex'),
+ prefix=r'\b', suffix=r'\b'),
+ Name.Decorator), # system-value semantics
+ (r'\bSV_Target[0-7]?\b', Name.Decorator),
+ (words((
+ 'allow_uav_condition','branch','call','domain','earlydepthstencil',
+ 'fastopt','flatten','forcecase','instance','loop','maxtessfactor',
+ 'numthreads','outputcontrolpoints','outputtopology','partitioning',
+ 'patchconstantfunc','unroll'),
+ prefix=r'\b', suffix=r'\b'),
+ Name.Decorator), # attributes
+ (r'[a-zA-Z_]\w*', Name),
+ (r'\\$', Comment.Preproc), # backslash at end of line -- usually macro continuation
+ (r'\s+', Text),
+ ],
+ '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'\\\n', String), # line continuation
+ (r'\\', String), # stray backslash
+ ],
+ }
+
+
class PostScriptLexer(RegexLexer):
"""
Lexer for PostScript files.
diff --git a/pygments/lexers/javascript.py b/pygments/lexers/javascript.py
index 862535c9..663557ab 100644
--- a/pygments/lexers/javascript.py
+++ b/pygments/lexers/javascript.py
@@ -1500,8 +1500,10 @@ class JuttleLexer(RegexLexer):
(r'^(?=\s|/)', Text, 'slashstartsregex'),
include('commentsandwhitespace'),
(r':\d{2}:\d{2}:\d{2}(\.\d*)?:', String.Moment),
- (r':(now|beginning|end|forever|yesterday|today|tomorrow|(\d+(\.\d*)?|\.\d+)(ms|[smhdwMy])?):', String.Moment),
- (r':\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d*)?)?(Z|[+-]\d{2}:\d{2}|[+-]\d{4})?:', String.Moment),
+ (r':(now|beginning|end|forever|yesterday|today|tomorrow|'
+ r'(\d+(\.\d*)?|\.\d+)(ms|[smhdwMy])?):', String.Moment),
+ (r':\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d*)?)?'
+ r'(Z|[+-]\d{2}:\d{2}|[+-]\d{4})?:', String.Moment),
(r':((\d+(\.\d*)?|\.\d+)[ ]+)?(millisecond|second|minute|hour|day|week|month|year)[s]?'
r'(([ ]+and[ ]+(\d+[ ]+)?(millisecond|second|minute|hour|day|week|month|year)[s]?)'
r'|[ ]+(ago|from[ ]+now))*:', String.Moment),
diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py
index f4392839..ccff41c1 100644
--- a/pygments/lexers/jvm.py
+++ b/pygments/lexers/jvm.py
@@ -801,7 +801,7 @@ class ClojureLexer(RegexLexer):
# TODO / should divide keywords/symbols into namespace/rest
# but that's hard, so just pretend / is part of the name
- valid_name = r'(?!#)[\w!$%*+<=>?/.#-]+'
+ valid_name = r'(?!#)[\w!$%*+<=>?/.#|-]+'
tokens = {
'root': [
diff --git a/pygments/lexers/lisp.py b/pygments/lexers/lisp.py
index e258c347..4a1ce137 100644
--- a/pygments/lexers/lisp.py
+++ b/pygments/lexers/lisp.py
@@ -19,7 +19,7 @@ from pygments.lexers.python import PythonLexer
__all__ = ['SchemeLexer', 'CommonLispLexer', 'HyLexer', 'RacketLexer',
'NewLispLexer', 'EmacsLispLexer', 'ShenLexer', 'CPSALexer',
- 'XtlangLexer']
+ 'XtlangLexer', 'FennelLexer']
class SchemeLexer(RegexLexer):
@@ -2327,13 +2327,13 @@ class ShenLexer(RegexLexer):
token = Name.Function if token == Literal else token
yield index, token, value
- raise StopIteration
+ return
def _process_signature(self, tokens):
for index, token, value in tokens:
if token == Literal and value == '}':
yield index, Punctuation, value
- raise StopIteration
+ return
elif token in (Literal, Name.Function):
token = Name.Variable if value.istitle() else Keyword.Type
yield index, token, value
@@ -2619,3 +2619,75 @@ class XtlangLexer(RegexLexer):
include('scheme')
],
}
+
+
+class FennelLexer(RegexLexer):
+ """A lexer for the `Fennel programming language <https://fennel-lang.org>`_.
+
+ Fennel compiles to Lua, so all the Lua builtins are recognized as well
+ as the special forms that are particular to the Fennel compiler.
+
+ .. versionadded:: 2.3
+ """
+ name = 'Fennel'
+ aliases = ['fennel', 'fnl']
+ filenames = ['*.fnl']
+
+ # these two lists are taken from fennel-mode.el:
+ # https://gitlab.com/technomancy/fennel-mode
+ # this list is current as of Fennel version 0.1.0.
+ special_forms = (
+ u'require-macros', u'eval-compiler',
+ u'do', u'values', u'if', u'when', u'each', u'for', u'fn', u'lambda',
+ u'λ', u'set', u'global', u'var', u'local', u'let', u'tset', u'doto',
+ u'set-forcibly!', u'defn', u'partial', u'while', u'or', u'and', u'true',
+ u'false', u'nil', u'.', u'+', u'..', u'^', u'-', u'*', u'%', u'/', u'>',
+ u'<', u'>=', u'<=', u'=', u'~=', u'#', u'...', u':', u'->', u'->>',
+ )
+
+ # Might be nicer to use the list from _lua_builtins.py but it's unclear how?
+ builtins = (
+ u'_G', u'_VERSION', u'arg', u'assert', u'bit32', u'collectgarbage',
+ u'coroutine', u'debug', u'dofile', u'error', u'getfenv',
+ u'getmetatable', u'io', u'ipairs', u'load', u'loadfile', u'loadstring',
+ u'math', u'next', u'os', u'package', u'pairs', u'pcall', u'print',
+ u'rawequal', u'rawget', u'rawlen', u'rawset', u'require', u'select',
+ u'setfenv', u'setmetatable', u'string', u'table', u'tonumber',
+ u'tostring', u'type', u'unpack', u'xpcall'
+ )
+
+ # based on the scheme definition, but disallowing leading digits and commas
+ valid_name = r'[a-zA-Z_!$%&*+/:<=>?@^~|-][\w!$%&*+/:<=>?@^~|\.-]*'
+
+ tokens = {
+ 'root': [
+ # the only comment form is a semicolon; goes to the end of the line
+ (r';.*$', Comment.Single),
+
+ (r'[,\s]+', Text),
+ (r'-?\d+\.\d+', Number.Float),
+ (r'-?\d+', Number.Integer),
+
+ (r'"(\\\\|\\"|[^"])*"', String),
+ (r"'(\\\\|\\'|[^'])*'", String),
+
+ # these are technically strings, but it's worth visually
+ # distinguishing them because their intent is different
+ # from regular strings.
+ (r':' + valid_name, String.Symbol),
+
+ # special forms are keywords
+ (words(special_forms, suffix=' '), Keyword),
+ # lua standard library are builtins
+ (words(builtins, suffix=' '), Name.Builtin),
+ # special-case the vararg symbol
+ (r'\.\.\.', Name.Variable),
+ # regular identifiers
+ (valid_name, Name.Variable),
+
+ # all your normal paired delimiters for your programming enjoyment
+ (r'(\(|\))', Punctuation),
+ (r'(\[|\])', Punctuation),
+ (r'(\{|\})', Punctuation),
+ ]
+ }
diff --git a/pygments/lexers/markup.py b/pygments/lexers/markup.py
index 92dc9e7a..e6265f40 100644
--- a/pygments/lexers/markup.py
+++ b/pygments/lexers/markup.py
@@ -536,10 +536,9 @@ class MarkdownLexer(RegexLexer):
# no lexer for this language. handle it like it was a code block
if lexer is None:
yield match.start(4), String, code
- return
-
- for item in do_insertions([], lexer.get_tokens_unprocessed(code)):
- yield item
+ else:
+ for item in do_insertions([], lexer.get_tokens_unprocessed(code)):
+ yield item
yield match.start(5), String , match.group(5)
diff --git a/pygments/lexers/python.py b/pygments/lexers/python.py
index 9e861aab..212f38af 100644
--- a/pygments/lexers/python.py
+++ b/pygments/lexers/python.py
@@ -262,7 +262,7 @@ class Python3Lexer(RegexLexer):
return [
# the old style '%s' % (...) string formatting (still valid in Py3)
(r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
- '[hlL]?[E-GXc-giorsux%]', String.Interpol),
+ '[hlL]?[E-GXc-giorsaux%]', String.Interpol),
# the new style '{}'.format(...) string formatting
(r'\{'
'((\w+)((\.\w+)|(\[[^\]]+\]))*)?' # field name
diff --git a/pygments/lexers/r.py b/pygments/lexers/r.py
index dce61969..6ecdb95d 100644
--- a/pygments/lexers/r.py
+++ b/pygments/lexers/r.py
@@ -11,7 +11,7 @@
import re
-from pygments.lexer import Lexer, RegexLexer, include, words, do_insertions
+from pygments.lexer import Lexer, RegexLexer, include, do_insertions, bygroups
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
Number, Punctuation, Generic
@@ -80,286 +80,25 @@ class SLexer(RegexLexer):
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'
- )
-
+ valid_name = r'(?:`[^`\\]*(?:\\.[^`\\]*)*`)|(?:(?:[a-zA-z]|[_.][^0-9])[\w_.]*)'
tokens = {
'comments': [
(r'#.*$', Comment.Single),
],
'valid_name': [
- (r'[a-zA-Z][\w.]*', Text),
- # can begin with ., but not if that is followed by a digit
- (r'\.[a-zA-Z_][\w.]*', Text),
+ (valid_name, Name),
],
'punctuation': [
(r'\[{1,2}|\]{1,2}|\(|\)|;|,', Punctuation),
],
'keywords': [
- (words(builtins_base, suffix=r'(?![\w. =])'),
- Keyword.Pseudo),
(r'(if|else|for|while|repeat|in|next|break|return|switch|function)'
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),
- (r'\*|\+|\^|/|!|%[^%]*%|=|~|\$|@|:{1,3}', Operator)
+ (r'\*|\+|\^|/|!|%[^%]*%|=|~|\$|@|:{1,3}', Operator),
],
'builtin_symbols': [
(r'(NULL|NA(_(integer|real|complex|character)_)?|'
@@ -379,17 +118,18 @@ class SLexer(RegexLexer):
include('comments'),
# whitespaces
(r'\s+', Text),
- (r'`.*?`', String.Backtick),
(r'\'', String, 'string_squote'),
(r'\"', String, 'string_dquote'),
include('builtin_symbols'),
+ include('valid_name'),
include('numbers'),
include('keywords'),
include('punctuation'),
include('operators'),
- include('valid_name'),
],
'root': [
+ # calls:
+ ('r%s\s*(?=\()' % valid_name, Name.Function),
include('statements'),
# blocks:
(r'\{|\}', Punctuation),
diff --git a/pygments/lexers/rust.py b/pygments/lexers/rust.py
index 6914f54d..10097fba 100644
--- a/pygments/lexers/rust.py
+++ b/pygments/lexers/rust.py
@@ -24,7 +24,7 @@ class RustLexer(RegexLexer):
"""
name = 'Rust'
filenames = ['*.rs', '*.rs.in']
- aliases = ['rust']
+ aliases = ['rust', 'rs']
mimetypes = ['text/rust']
keyword_types = (
diff --git a/pygments/lexers/sql.py b/pygments/lexers/sql.py
index 7507c0fc..3f7dfdb8 100644
--- a/pygments/lexers/sql.py
+++ b/pygments/lexers/sql.py
@@ -308,14 +308,7 @@ class PostgresConsoleLexer(Lexer):
# and continue until the end of command is detected
curcode = ''
insertions = []
- while 1:
- try:
- line = next(lines)
- except StopIteration:
- # allow the emission of partially collected items
- # the repl loop will be broken below
- break
-
+ for line in lines:
# Identify a shell prompt in case of psql commandline example
if line.startswith('$') and not curcode:
lexer = get_lexer_by_name('console', **self.options)
@@ -346,8 +339,7 @@ class PostgresConsoleLexer(Lexer):
# Emit the output lines
out_token = Generic.Output
- while 1:
- line = next(lines)
+ for line in lines:
mprompt = re_prompt.match(line)
if mprompt is not None:
# push the line back to have it processed by the prompt
@@ -363,6 +355,8 @@ class PostgresConsoleLexer(Lexer):
yield (mmsg.start(2), out_token, mmsg.group(2))
else:
yield (0, out_token, line)
+ else:
+ return
class SqlLexer(RegexLexer):
diff --git a/pygments/lexers/webmisc.py b/pygments/lexers/webmisc.py
index 712c8246..30dd3717 100644
--- a/pygments/lexers/webmisc.py
+++ b/pygments/lexers/webmisc.py
@@ -661,7 +661,8 @@ class XQueryLexer(ExtendedRegexLexer):
# NAMESPACE KEYWORD
(r'(declare)(\s+)(default)(\s+)(element|function)',
- bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Keyword.Declaration), 'namespacekeyword'),
+ bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Keyword.Declaration),
+ 'namespacekeyword'),
(r'(import)(\s+)(schema|module)',
bygroups(Keyword.Pseudo, Text, Keyword.Pseudo), 'namespacekeyword'),
(r'(declare)(\s+)(copy-namespaces)',
diff --git a/pygments/lexers/xorg.py b/pygments/lexers/xorg.py
index 89475a80..3bba930f 100644
--- a/pygments/lexers/xorg.py
+++ b/pygments/lexers/xorg.py
@@ -16,6 +16,7 @@ __all__ = ['XorgLexer']
class XorgLexer(RegexLexer):
+ """Lexer for xorg.conf file."""
name = 'Xorg'
aliases = ['xorg.conf']
filenames = ['xorg.conf']
@@ -26,8 +27,8 @@ class XorgLexer(RegexLexer):
(r'\s+', Text),
(r'#.*$', Comment),
- (r'((|Sub)Section)(\s+)("\w+")',
- bygroups(String.Escape, String.Escape, Text, String.Escape)),
+ (r'((?:Sub)?Section)(\s+)("\w+")',
+ bygroups(String.Escape, Text, String.Escape)),
(r'(End(|Sub)Section)', String.Escape),
(r'(\w+)(\s+)([^\n#]+)',
diff --git a/pygments/plugin.py b/pygments/plugin.py
index 7987d646..08d9b5b4 100644
--- a/pygments/plugin.py
+++ b/pygments/plugin.py
@@ -40,14 +40,16 @@ FORMATTER_ENTRY_POINT = 'pygments.formatters'
STYLE_ENTRY_POINT = 'pygments.styles'
FILTER_ENTRY_POINT = 'pygments.filters'
+
def iter_entry_points(group_name):
try:
import pkg_resources
- except ImportError:
+ except (ImportError, IOError):
return []
return pkg_resources.iter_entry_points(group_name)
+
def find_plugin_lexers():
for entrypoint in iter_entry_points(LEXER_ENTRY_POINT):
yield entrypoint.load()
diff --git a/pygments/sphinxext.py b/pygments/sphinxext.py
index f962f8c6..5c8ac8b9 100644
--- a/pygments/sphinxext.py
+++ b/pygments/sphinxext.py
@@ -16,7 +16,7 @@ import sys
from docutils import nodes
from docutils.statemachine import ViewList
-from sphinx.util.compat import Directive
+from docutils.parsers.rst import Directive
from sphinx.util.nodes import nested_parse_with_titles
diff --git a/scripts/release-checklist b/scripts/release-checklist
new file mode 100644
index 00000000..efc1e1e8
--- /dev/null
+++ b/scripts/release-checklist
@@ -0,0 +1,24 @@
+Release checklist
+=================
+
+* Check ``hg status``
+* ``make check``
+* LATER when configured properly: ``make pylint``
+* ``tox``
+* Update version info in ``setup.py/__init__.py``
+* Check setup.py metadata: long description, trove classifiers
+* Update release date/code name in ``CHANGES``
+* ``hg commit``
+* ``make clean``
+* ``python2 setup.py release bdist_wheel``
+* ``python3 setup.py release bdist_wheel sdist``
+* ``twine upload dist/Pygments-$NEWVER*``
+* Check PyPI release page for obvious errors
+* ``hg tag``
+* Merge default into stable if this was a ``x.y.0``
+* Update homepage (release info), regenerate docs (+printable!)
+* Add new version/milestone to tracker categories
+* Write announcement and send to mailing list/python-announce
+* Update version info, add new ``CHANGES`` entry for next version
+* ``hg commit``
+* ``hg push``
diff --git a/setup.py b/setup.py
index 1705923c..7e6eca8c 100755
--- a/setup.py
+++ b/setup.py
@@ -48,7 +48,7 @@ else:
setup(
name = 'Pygments',
- version = '2.2.0',
+ version = '2.3.0',
url = 'http://pygments.org/',
license = 'BSD License',
author = 'Georg Brandl',
diff --git a/tests/examplefiles/StdGeneric.icl b/tests/examplefiles/StdGeneric.icl
index 2e6c3931..891b510a 100644
--- a/tests/examplefiles/StdGeneric.icl
+++ b/tests/examplefiles/StdGeneric.icl
@@ -1,5 +1,13 @@
implementation module StdGeneric
+/**
+ * NOTE: this is a collection of different tricky parts of Clean modules (even
+ * though the file is simply called StdGeneric.icl). The code is taken from:
+ *
+ * - StdGeneric (StdEnv)
+ * - Graphics.Scalable.Image (Platform)
+ */
+
import StdInt, StdMisc, StdClass, StdFunc
generic bimap a b :: Bimap .a .b
@@ -89,4 +97,38 @@ where
= [ ConsLeft : doit i (n/2) ]
| otherwise
= [ ConsRight : doit (i - (n/2)) (n - (n/2)) ]
- \ No newline at end of file
+
+:: NoAttr m = NoAttr
+:: DashAttr m = { dash :: ![Int] }
+:: FillAttr m = { fill :: !SVGColor }
+:: LineEndMarker m = { endmarker :: !Image m }
+:: LineMidMarker m = { midmarker :: !Image m }
+:: LineStartMarker m = { startmarker :: !Image m }
+:: MaskAttr m = { mask :: !Image m }
+:: OpacityAttr m = { opacity :: !Real }
+:: StrokeAttr m = { stroke :: !SVGColor }
+:: StrokeWidthAttr m = { strokewidth :: !Span }
+:: XRadiusAttr m = { xradius :: !Span }
+:: YRadiusAttr m = { yradius :: !Span }
+
+
+instance tuneImage NoAttr where tuneImage image _ = image
+instance tuneImage DashAttr where tuneImage image attr = Attr` (BasicImageAttr` (BasicImgDashAttr attr.DashAttr.dash)) image
+instance tuneImage FillAttr where tuneImage image attr = Attr` (BasicImageAttr` (BasicImgFillAttr attr.FillAttr.fill)) image
+instance tuneImage LineEndMarker where tuneImage image attr = Attr` (LineMarkerAttr` {LineMarkerAttr | markerImg = attr.LineEndMarker.endmarker, markerPos = LineMarkerEnd}) image
+instance tuneImage LineMidMarker where tuneImage image attr = Attr` (LineMarkerAttr` {LineMarkerAttr | markerImg = attr.LineMidMarker.midmarker, markerPos = LineMarkerMid}) image
+instance tuneImage LineStartMarker where tuneImage image attr = Attr` (LineMarkerAttr` {LineMarkerAttr | markerImg = attr.LineStartMarker.startmarker, markerPos = LineMarkerStart}) image
+instance tuneImage MaskAttr where tuneImage image attr = Attr` (MaskAttr` attr.MaskAttr.mask) image
+instance tuneImage OpacityAttr where tuneImage image attr = Attr` (BasicImageAttr` (BasicImgFillOpacityAttr attr.OpacityAttr.opacity)) image
+instance tuneImage StrokeAttr where tuneImage image attr = Attr` (BasicImageAttr` (BasicImgStrokeAttr attr.StrokeAttr.stroke)) image
+instance tuneImage StrokeWidthAttr where tuneImage image attr = Attr` (BasicImageAttr` (BasicImgStrokeWidthAttr attr.StrokeWidthAttr.strokewidth)) image
+instance tuneImage XRadiusAttr where tuneImage image attr = Attr` (BasicImageAttr` (BasicImgXRadiusAttr attr.XRadiusAttr.xradius)) image
+instance tuneImage YRadiusAttr where tuneImage image attr = Attr` (BasicImageAttr` (BasicImgYRadiusAttr attr.YRadiusAttr.yradius)) image
+
+instance tuneImage DraggableAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerDraggableAttr attr)) image
+instance tuneImage OnClickAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerOnClickAttr attr)) image
+instance tuneImage OnMouseDownAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerOnMouseDownAttr attr)) image
+instance tuneImage OnMouseMoveAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerOnMouseMoveAttr attr)) image
+instance tuneImage OnMouseOutAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerOnMouseOutAttr attr)) image
+instance tuneImage OnMouseOverAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerOnMouseOverAttr attr)) image
+instance tuneImage OnMouseUpAttr where tuneImage image attr = Attr` (HandlerAttr` (ImgEventhandlerOnMouseUpAttr attr)) image
diff --git a/tests/examplefiles/docker.docker b/tests/examplefiles/docker.docker
index d65385b6..1ae3c3a1 100644
--- a/tests/examplefiles/docker.docker
+++ b/tests/examplefiles/docker.docker
@@ -1,5 +1,34 @@
-maintainer First O'Last
+FROM alpine:3.5
+MAINTAINER First O'Last
+# comment
run echo \
123 $bar
-# comment
+RUN apk --update add rsync dumb-init
+
+# Test env with both syntax
+ENV FOO = "BAR"
+ENV FOO \
+ "BAR"
+
+COPY foo "bar"
+COPY foo \
+ "bar"
+
+HEALTHCHECK \
+ --interval=5m --timeout=3s \
+ CMD curl -f http://localhost/ || exit 1
+
+# ONBUILD keyword, then with linebreak
+ONBUILD ADD . /app/src
+ONBUILD \
+ RUN echo 123 $bar
+
+# Potential JSON array parsing, mixed with linebreaks
+VOLUME \
+ /foo
+VOLUME \
+ ["/bar"]
+VOLUME ["/bar"]
+VOLUME /foo
+CMD ["foo", "bar"]
diff --git a/tests/examplefiles/example.hlsl b/tests/examplefiles/example.hlsl
new file mode 100644
index 00000000..21d0a672
--- /dev/null
+++ b/tests/examplefiles/example.hlsl
@@ -0,0 +1,168 @@
+// A few random snippets of HLSL shader code I gathered...
+
+[numthreads(256, 1, 1)]
+void cs_main(uint3 threadId : SV_DispatchThreadID)
+{
+ // Seed the PRNG using the thread ID
+ rng_state = threadId.x;
+
+ // Generate a few numbers...
+ uint r0 = rand_xorshift();
+ uint r1 = rand_xorshift();
+ // Do some stuff with them...
+
+ // Generate a random float in [0, 1)...
+ float f0 = float(rand_xorshift()) * (1.0 / 4294967296.0);
+
+ // ...etc.
+}
+
+// Constant buffer of parameters
+cbuffer IntegratorParams : register(b0)
+{
+ float2 specPow; // Spec powers in XY directions (equal for isotropic BRDFs)
+ float3 L; // Unit vector toward light
+ int2 cThread; // Total threads launched in XY dimensions
+ int2 xyOutput; // Where in the output buffer to store the result
+}
+
+static const float pi = 3.141592654;
+
+float AshikhminShirleyNDF(float3 H)
+{
+ float normFactor = sqrt((specPow.x + 2.0f) * (specPow.y + 2.0)) * (0.5f / pi);
+ float NdotH = H.z;
+ float2 Hxy = normalize(H.xy);
+ return normFactor * pow(NdotH, dot(specPow, Hxy * Hxy));
+}
+
+float BeckmannNDF(float3 H)
+{
+ float glossFactor = specPow.x * 0.5f + 1.0f; // This is 1/m^2 in the usual Beckmann formula
+ float normFactor = glossFactor * (1.0f / pi);
+ float NdotHSq = H.z * H.z;
+ return normFactor / (NdotHSq * NdotHSq) * exp(glossFactor * (1.0f - 1.0f / NdotHSq));
+}
+
+// Output buffer for compute shader (actually float, but must be declared as uint
+// for atomic operations to work)
+globallycoherent RWTexture2D<uint> o_data : register(u0);
+
+// Sum up the outputs of all threads and store to the output location
+static const uint threadGroupSize2D = 16;
+static const uint threadGroupSize1D = threadGroupSize2D * threadGroupSize2D;
+groupshared float g_partialSums[threadGroupSize1D];
+void SumAcrossThreadsAndStore(float value, uint iThreadInGroup)
+{
+ // First reduce within the threadgroup: partial sums of 2, 4, 8... elements
+ // are calculated by 1/2, 1/4, 1/8... of the threads, always keeping the
+ // active threads at the front of the group to minimize divergence.
+
+ // NOTE: there are faster ways of doing this...but this is simple to code
+ // and good enough.
+
+ g_partialSums[iThreadInGroup] = value;
+ GroupMemoryBarrierWithGroupSync();
+
+ [unroll] for (uint i = threadGroupSize1D / 2; i > 0; i /= 2)
+ {
+ if (iThreadInGroup < i)
+ {
+ g_partialSums[iThreadInGroup] += g_partialSums[iThreadInGroup + i];
+ }
+ GroupMemoryBarrierWithGroupSync();
+ }
+
+ // Then reduce across threadgroups: one thread from each group adds the group
+ // total to the final output location, using a software transactional memory
+ // style since D3D11 doesn't support atomic add on floats.
+ // (Assumes the output value has been cleared to zero beforehand.)
+
+ if (iThreadInGroup == 0)
+ {
+ float threadGroupSum = g_partialSums[0];
+ uint outputValueRead = o_data[xyOutput];
+ while (true)
+ {
+ uint newOutputValue = asuint(asfloat(outputValueRead) + threadGroupSum);
+ uint previousOutputValue;
+ InterlockedCompareExchange(
+ o_data[xyOutput], outputValueRead, newOutputValue, previousOutputValue);
+ if (previousOutputValue == outputValueRead)
+ break;
+ outputValueRead = previousOutputValue;
+ }
+ }
+}
+
+void main(
+ in Vertex i_vtx,
+ out Vertex o_vtx,
+ out float3 o_vecCamera : CAMERA,
+ out float4 o_uvzwShadow : UVZW_SHADOW,
+ out float4 o_posClip : SV_Position)
+{
+ o_vtx = i_vtx;
+ o_vecCamera = g_posCamera - i_vtx.m_pos;
+ o_uvzwShadow = mul(float4(i_vtx.m_pos, 1.0), g_matWorldToUvzwShadow);
+ o_posClip = mul(float4(i_vtx.m_pos, 1.0), g_matWorldToClip);
+}
+
+#pragma pack_matrix(row_major)
+
+struct Vertex
+{
+ float3 m_pos : POSITION;
+ float3 m_normal : NORMAL;
+ float2 m_uv : UV;
+};
+
+cbuffer CBFrame : CB_FRAME // matches struct CBFrame in test.cpp
+{
+ float4x4 g_matWorldToClip;
+ float4x4 g_matWorldToUvzwShadow;
+ float3x3 g_matWorldToUvzShadowNormal;
+ float3 g_posCamera;
+
+ float3 g_vecDirectionalLight;
+ float3 g_rgbDirectionalLight;
+
+ float2 g_dimsShadowMap;
+ float g_normalOffsetShadow;
+ float g_shadowSharpening;
+
+ float g_exposure; // Exposure multiplier
+}
+
+Texture2D<float3> g_texDiffuse : register(t0);
+SamplerState g_ss : register(s0);
+
+void main(
+ in Vertex i_vtx,
+ in float3 i_vecCamera : CAMERA,
+ in float4 i_uvzwShadow : UVZW_SHADOW,
+ out float3 o_rgb : SV_Target)
+{
+ float3 normal = normalize(i_vtx.m_normal);
+
+ // Sample shadow map
+ float shadow = EvaluateShadow(i_uvzwShadow, normal);
+
+ // Evaluate diffuse lighting
+ float3 diffuseColor = g_texDiffuse.Sample(g_ss, i_vtx.m_uv);
+ float3 diffuseLight = g_rgbDirectionalLight * (shadow * saturate(dot(normal, g_vecDirectionalLight)));
+ diffuseLight += SimpleAmbient(normal);
+
+ o_rgb = diffuseColor * diffuseLight;
+}
+
+[domain("quad")]
+void ds(
+ in float edgeFactors[4] : SV_TessFactor,
+ in float insideFactors[2] : SV_InsideTessFactor,
+ in OutputPatch<VData, 4> inp,
+ in float2 uv : SV_DomainLocation,
+ out float4 o_pos : SV_Position)
+{
+ o_pos = lerp(lerp(inp[0].pos, inp[1].pos, uv.x), lerp(inp[2].pos, inp[3].pos, uv.x), uv.y);
+}
diff --git a/tests/examplefiles/fennelview.fnl b/tests/examplefiles/fennelview.fnl
new file mode 100644
index 00000000..fd0fc648
--- /dev/null
+++ b/tests/examplefiles/fennelview.fnl
@@ -0,0 +1,156 @@
+;; A pretty-printer that outputs tables in Fennel syntax.
+;; Loosely based on inspect.lua: http://github.com/kikito/inspect.lua
+
+(local quote (fn [str] (.. '"' (: str :gsub '"' '\\"') '"')))
+
+(local short-control-char-escapes
+ {"\a" "\\a" "\b" "\\b" "\f" "\\f" "\n" "\\n"
+ "\r" "\\r" "\t" "\\t" "\v" "\\v"})
+
+(local long-control-char-esapes
+ (let [long {}]
+ (for [i 0 31]
+ (let [ch (string.char i)]
+ (when (not (. short-control-char-escapes ch))
+ (tset short-control-char-escapes ch (.. "\\" i))
+ (tset long ch (: "\\%03d" :format i)))))
+ long))
+
+(fn escape [str]
+ (let [str (: str :gsub "\\" "\\\\")
+ str (: str :gsub "(%c)%f[0-9]" long-control-char-esapes)]
+ (: str :gsub "%c" short-control-char-escapes)))
+
+(fn sequence-key? [k len]
+ (and (= (type k) "number")
+ (<= 1 k)
+ (<= k len)
+ (= (math.floor k) k)))
+
+(local type-order {:number 1 :boolean 2 :string 3 :table 4
+ :function 5 :userdata 6 :thread 7})
+
+(fn sort-keys [a b]
+ (let [ta (type a) tb (type b)]
+ (if (and (= ta tb) (~= ta "boolean")
+ (or (= ta "string") (= ta "number")))
+ (< a b)
+ (let [dta (. type-order a)
+ dtb (. type-order b)]
+ (if (and dta dtb)
+ (< dta dtb)
+ dta true
+ dtb false
+ :else (< ta tb))))))
+
+(fn get-sequence-length [t]
+ (var len 1)
+ (each [i (ipairs t)] (set len i))
+ len)
+
+(fn get-nonsequential-keys [t]
+ (let [keys {}
+ sequence-length (get-sequence-length t)]
+ (each [k (pairs t)]
+ (when (not (sequence-key? k sequence-length))
+ (table.insert keys k)))
+ (table.sort keys sort-keys)
+ (values keys sequence-length)))
+
+(fn count-table-appearances [t appearances]
+ (if (= (type t) "table")
+ (when (not (. appearances t))
+ (tset appearances t 1)
+ (each [k v (pairs t)]
+ (count-table-appearances k appearances)
+ (count-table-appearances v appearances)))
+ (when (and t (= t t)) ; no nans please
+ (tset appearances t (+ (or (. appearances t) 0) 1))))
+ appearances)
+
+
+
+(var put-value nil) ; mutual recursion going on; defined below
+
+(fn puts [self ...]
+ (each [_ v (ipairs [...])]
+ (table.insert self.buffer v)))
+
+(fn tabify [self] (puts self "\n" (: self.indent :rep self.level)))
+
+(fn already-visited? [self v] (~= (. self.ids v) nil))
+
+(fn get-id [self v]
+ (var id (. self.ids v))
+ (when (not id)
+ (let [tv (type v)]
+ (set id (+ (or (. self.max-ids tv) 0) 1))
+ (tset self.max-ids tv id)
+ (tset self.ids v id)))
+ (tostring id))
+
+(fn put-sequential-table [self t length]
+ (puts self "[")
+ (set self.level (+ self.level 1))
+ (for [i 1 length]
+ (puts self " ")
+ (put-value self (. t i)))
+ (set self.level (- self.level 1))
+ (puts self " ]"))
+
+(fn put-key [self k]
+ (if (and (= (type k) "string")
+ (: k :find "^[-%w?\\^_`!#$%&*+./@~:|<=>]+$"))
+ (puts self ":" k)
+ (put-value self k)))
+
+(fn put-kv-table [self t]
+ (puts self "{")
+ (set self.level (+ self.level 1))
+ (each [k v (pairs t)]
+ (tabify self)
+ (put-key self k)
+ (puts self " ")
+ (put-value self v))
+ (set self.level (- self.level 1))
+ (tabify self)
+ (puts self "}"))
+
+(fn put-table [self t]
+ (if (already-visited? self t)
+ (puts self "#<table " (get-id self t) ">")
+ (>= self.level self.depth)
+ (puts self "{...}")
+ :else
+ (let [(non-seq-keys length) (get-nonsequential-keys t)
+ id (get-id self t)]
+ (if (> (. self.appearances t) 1)
+ (puts self "#<" id ">")
+ (and (= (# non-seq-keys) 0) (= (# t) 0))
+ (puts self "{}")
+ (= (# non-seq-keys) 0)
+ (put-sequential-table self t length)
+ :else
+ (put-kv-table self t)))))
+
+(set put-value (fn [self v]
+ (let [tv (type v)]
+ (if (= tv "string")
+ (puts self (quote (escape v)))
+ (or (= tv "number") (= tv "boolean") (= tv "nil"))
+ (puts self (tostring v))
+ (= tv "table")
+ (put-table self v)
+ :else
+ (puts self "#<" (tostring v) ">")))))
+
+
+
+(fn fennelview [root options]
+ (let [options (or options {})
+ inspector {:appearances (count-table-appearances root {})
+ :depth (or options.depth 128)
+ :level 0 :buffer {} :ids {} :max-ids {}
+ :indent (or options.indent " ")}]
+ (put-value inspector root)
+ (table.concat inspector.buffer)))
diff --git a/tests/examplefiles/test.csd b/tests/examplefiles/test.csd
index 9122309b..6512d99e 100644
--- a/tests/examplefiles/test.csd
+++ b/tests/examplefiles/test.csd
@@ -1,260 +1,18 @@
+/*
+ * comment
+ */
+; comment
+// comment
+/
<CsoundSynthesizer>
<CsInstruments>
-// This is a Csound orchestra file for testing a Pygments <http://pygments.org>
-// lexer. Csound single-line comments can be preceded by a pair of forward
-// slashes...
-; ...or a semicolon.
-
-/* Block comments begin with /* and end with */
-
-// Orchestras begin with a header of audio parameters.
-nchnls = 1
-nchnls_i = 1
-sr = 44100
0dbfs = 1
-ksmps = 10
-
-// The control rate kr = sr / ksmps can be omitted when the number of audio
-// samples in a control period (ksmps) is set, but kr may appear in older
-// orchestras.
-kr = 4410
-
-// Orchestras contain instruments. These begin with the keyword instr followed
-// by a comma-separated list of numbers or names of the instrument. Instruments
-// end at the endin keyword and cannot be nested.
-instr 1, N_a_M_e_, +Name
- // Instruments contain statements. Here is a typical statement:
- aSignal oscil 0dbfs, 440, 1
- // Statements are terminated with a newline (possibly preceded by a comment).
- // To write a statement on several lines, precede the newline with a
- // backslash.
- prints \
- "hello, world\n";comment
-
- // Csound 6 introduced function syntax for opcodes with one or zero outputs.
- // The oscil statement above is the same as
- aSignal = oscil(0dbfs, 440, 1)
-
- // Instruments can contain control structures.
- kNote = p3
- if (kNote == 0) then
- kFrequency = 220
- elseif kNote == 1 then // Parentheses around binary expressions are optional.
- kFrequency = 440
- endif
-
- // Csound 6 introduced looping structures.
- iIndex = 0
- while iIndex < 5 do
- print iIndex
- iIndex += 1
- od
- iIndex = 0
- until iIndex >= 5 do
- print iIndex
- iIndex += 1
- enduntil
- // Both kinds of loops can be terminated by either od or enduntil.
-
- // Single-line strings are enclosed in double-quotes.
- prints "string\\\r\n\t\""
- // Multi-line strings are enclosed in pairs of curly braces.
- prints {{
- hello,
-
- world
- }}
-
- // Instruments often end with a statement containing an output opcode.
- outc aSignal
-endin
-
-// Orchestras can also contain user-defined opcodes (UDOs). Here is an
-// oscillator with one audio-rate output and two control-rate inputs:
-opcode anOscillator, a, kk
- kAmplitude, kFrequency xin
- aSignal vco2 kAmplitude, kFrequency
- xout aSignal
-endop
-instr TestOscillator
- outc(anOscillator(0dbfs, 110))
-endin
-
-// Python can be executed in Csound
-// <http://www.csounds.com/manual/html/pyrun.html>. So can Lua
-// <http://www.csounds.com/manual/html/lua.html>.
-pyruni {{
-import random
-
-pool = [(1 + i / 10.0) ** 1.2 for i in range(100)]
-
-def get_number_from_pool(n, p):
- if random.random() < p:
- i = int(random.random() * len(pool))
- pool[i] = n
- return random.choice(pool)
-}}
-
-// The Csound preprocessor supports conditional compilation and including files.
-#ifdef DEBUG
-#undef DEBUG
-#include "filename.orc"
-#endif
-
-// The preprocessor also supports object- and function-like macros. This is an
-// object-like macro that defines a number:
-#define A_HZ #440#
-
-// This is a function-like macro:
-#define OSCIL_MACRO(VOLUME'FREQUENCY'TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE#
-
-// Bodies of macros are enclosed in # and can contain newlines. The arguments of
-// function-like macros are separated by single-quotes. Uses of macros are
-// prefixed with a dollar sign.
-instr TestMacro
- aSignal $OSCIL_MACRO(1'$A_HZ'1)
- // Not unlike PHP, macros expand in double-quoted strings.
- prints "The frequency of the oscillator is $A_HZ Hz.\n"
- out aSignal
-endin
-
-// Here are other things to note about Csound.
-
-// There are two bitwise NOT operators, ~ and ¬ (U+00AC). The latter is common
-// on keyboards in the United Kingdom
-// <https://en.wikipedia.org/wiki/British_and_American_keyboards>.
-instr TestBitwiseNOT
- print ~42
- print ¬42
-endin
-
-// Csound uses # for bitwise XOR, which the Csound manual calls bitwise
-// non-equivalence <http://www.csounds.com/manual/html/opnonequiv.html>.
-instr TestBitwiseXOR
- print 0 # 0
- print 0 # 1
- print 1 # 0
- print 1 # 1
-endin
-
-// Loops and if-then statements are relatively recent additions to Csound. There
-// are many flow-control opcodes that involve goto and labels.
-instr TestGoto
- // This...
- if p3 > 0 goto if_label
- goto else_label
-if_label:
- prints "if branch\n"
- goto endif_label
-else_label:
- prints "else branch\n"
-endif_label:
-
- // ...is the same as this.
- if p3 > 0 then
- prints "if branch\n"
- else
- prints "else branch\n"
- endif
-
- // This...
- iIndex = 0
-loop_label:
- print iIndex
- iIndex += 1
- if iIndex < 10 goto loop_label
-
- // ...is the same as this...
- iIndex = 0
-loop_lt_label:
- print iIndex
- loop_lt iIndex, 1, 10, loop_lt_label
-
- // ...and this.
- iIndex = 0
- while iIndex < 10 do
- print iIndex
- iIndex += 1
- od
-endin
-
-// The prints and printks opcodes
-// <https://github.com/csound/csound/blob/develop/OOps/ugrw1.c#L831>, arguably
-// the primary methods of logging output, treat certain sequences of characters
-// different from printf in C.
-instr TestPrints
- // ^ prints an ESCAPE character (U+001B), not a CIRCUMFLEX ACCENT character
- // (U+005E). ^^ prints a CIRCUMFLEX ACCENT.
- prints "^^\n"
- // ~ prints an ESCAPE character (U+001B) followed by a [, not a TILDE
- // character (U+007E). ~~ prints a TILDE.
- prints "~~\n"
- // \A, \B, \N, \R, and \T correspond to the escaped lowercase characters (that
- // is, BELL (U+0007), BACKSPACE (U+0008), new line (U+000A), CARRIAGE RETURN
- // (U+000D), and tab (U+0009)).
- prints "\T\R\N"
- // %n, %r, and %t are the same as \n, \r, and \t, as are %N, %R, and %T.
- prints "%t%r%n"
- // %! prints a semicolon. This is a hold-over from old versions of Csound that
- // allowed comments to begin in strings.
- prints "; %!\n"
-endin
-
-// The arguments of function-like macros can be separated by # instead of '.
-// These two lines define the same macro.
-#define OSCIL_MACRO(VOLUME'FREQUENCY'TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE#
-#define OSCIL_MACRO(VOLUME#FREQUENCY#TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE#
-
-// Uses of macros can optionally be suffixed with a period.
-instr TestMacroPeriodSuffix
- aSignal $OSCIL_MACRO.(1'$A_HZ'1)
- prints "The frequency of the oscillator is $A_HZ.Hz.\n"
- out aSignal
-endin
-
-// Csound has @ and @@ operator-like macros that, when followed by a literal
-// non-negative integer, expand to the next power of 2 and the next power of 2
-// plus 1:
-// @x = 2^(ceil(log2(x + 1))), x >= 0
-// @@0 = 2
-// @@x = 2^(ceil(log2(x))) + 1, x > 0
-// These macros are in
-// <https://github.com/csound/csound/blob/develop/Engine/csound_orc.l#L542> (and
-// <https://github.com/csound/csound/blob/develop/Engine/csound_sco.lex#L202>)
-// and are described at <http://www.csounds.com/manual/html/ScoreEval.html>.
-instr TestAt
- prints "%d %2d %2d\n", 0, @0, @@0
- prints "%d %2d %2d\n", 1, @1, @@1
- prints "%d %2d %2d\n", 2, @2, @@2
- prints "%d %2d %2d\n", 3, @3, @@3
- prints "%d %2d %2d\n", 4, @4, @@4
- prints "%d %2d %2d\n", 5, @5, @@5
- prints "%d %2d %2d\n", 6, @6, @@6
- prints "%d %2d %2d\n", 7, @7, @@7
- prints "%d %2d %2d\n", 8, @8, @@8
- prints "%d %2d %2d\n", 9, @9, @@9
-endin
-
-// Including newlines in macros can lead to confusing code, but it tests the
-// lexer.
-instr MacroAbuse
- if 1 == 1 then
- prints "on\n"
-#define FOO#
-BAR
-#endif // This ends the if statement. It is not a preprocessor directive.
-endin
+prints "hello, world\n"
</CsInstruments>
<CsScore>
-f 1 0 16384 10 1
-i "N_a_M_e_" 0 2
-i "TestOscillator" 2 2
-i "TestBitwiseNOT" 0 1
-i "TestBitwiseXOR" 0 1
-i "TestGoto" 0 1
-i "TestMacroPeriodSuffix" 4 1
-i "TestAt" 0 1
-i "MacroAbuse" 0 1
-e
+i 1 0 0
</CsScore>
+<html>
+<!DOCTYPE html>
+</html>
</CsoundSynthesizer>
diff --git a/tests/examplefiles/test.orc b/tests/examplefiles/test.orc
index 36725342..d113303e 100644
--- a/tests/examplefiles/test.orc
+++ b/tests/examplefiles/test.orc
@@ -1,257 +1,81 @@
-// This is a Csound orchestra file for testing a Pygments <http://pygments.org>
-// lexer. Csound single-line comments can be preceded by a pair of forward
-// slashes...
-; ...or a semicolon.
-
-/* Block comments begin with /* and end with */
-
-// Orchestras begin with a header of audio parameters.
-nchnls = 1
-nchnls_i = 1
-sr = 44100
-0dbfs = 1
-ksmps = 10
-
-// The control rate kr = sr / ksmps can be omitted when the number of audio
-// samples in a control period (ksmps) is set, but kr may appear in older
-// orchestras.
-kr = 4410
-
-// Orchestras contain instruments. These begin with the keyword instr followed
-// by a comma-separated list of numbers or names of the instrument. Instruments
-// end at the endin keyword and cannot be nested.
-instr 1, N_a_M_e_, +Name
- // Instruments contain statements. Here is a typical statement:
- aSignal oscil 0dbfs, 440, 1
- // Statements are terminated with a newline (possibly preceded by a comment).
- // To write a statement on several lines, precede the newline with a
- // backslash.
- prints \
- "hello, world\n";comment
-
- // Csound 6 introduced function syntax for opcodes with one or zero outputs.
- // The oscil statement above is the same as
- aSignal = oscil(0dbfs, 440, 1)
-
- // Instruments can contain control structures.
- kNote = p3
- if (kNote == 0) then
- kFrequency = 220
- elseif kNote == 1 then // Parentheses around binary expressions are optional.
- kFrequency = 440
- endif
-
- // Csound 6 introduced looping structures.
- iIndex = 0
- while iIndex < 5 do
- print iIndex
- iIndex += 1
- od
- iIndex = 0
- until iIndex >= 5 do
- print iIndex
- iIndex += 1
- enduntil
- // Both kinds of loops can be terminated by either od or enduntil.
-
- // Single-line strings are enclosed in double-quotes.
- prints "string\\\r\n\t\""
- // Multi-line strings are enclosed in pairs of curly braces.
- prints {{
- hello,
-
- world
- }}
-
- // Instruments often end with a statement containing an output opcode.
- outc aSignal
+/*
+ * comment
+ */
+; comment
+// comment
+
+instr/**/1,/**/N_a_M_e_,/**/+Name/**///
+ iDuration = p3
+ outc:a(aSignal)
endin
-// Orchestras can also contain user-defined opcodes (UDOs). Here is an
-// oscillator with one audio-rate output and two control-rate inputs:
-opcode anOscillator, a, kk
- kAmplitude, kFrequency xin
- aSignal vco2 kAmplitude, kFrequency
- xout aSignal
+opcode/**/aUDO,/**/i[],/**/aik//
+ aUDO
endop
-instr TestOscillator
- outc(anOscillator(0dbfs, 110))
-endin
-// Python can be executed in Csound
-// <http://www.csounds.com/manual/html/pyrun.html>. So can Lua
-// <http://www.csounds.com/manual/html/lua.html>.
-pyruni {{
-import random
+123 0123456789
+0xabcdef0123456789 0XABCDEF
+1e2 3e+4 5e-6 7E8 9E+0 1E-2 3. 4.56 .789
-pool = [(1 + i / 10.0) ** 1.2 for i in range(100)]
+"characters$MACRO."
+"\\\a\b\n\r\t\012\345\67\""
-def get_number_from_pool(n, p):
- if random.random() < p:
- i = int(random.random() * len(pool))
- pool[i] = n
- return random.choice(pool)
+{{
+characters$MACRO.
}}
+{{\\\a\b\n\r\t\"\012\345\67}}
-// The Csound preprocessor supports conditional compilation and including files.
-#ifdef DEBUG
-#undef DEBUG
-#include "filename.orc"
-#endif
-
-// The preprocessor also supports object- and function-like macros. This is an
-// object-like macro that defines a number:
-#define A_HZ #440#
-
-// This is a function-like macro:
-#define OSCIL_MACRO(VOLUME'FREQUENCY'TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE#
-
-// Bodies of macros are enclosed in # and can contain newlines. The arguments of
-// function-like macros are separated by single-quotes. Uses of macros are
-// prefixed with a dollar sign.
-instr TestMacro
- aSignal $OSCIL_MACRO(1'$A_HZ'1)
- // Not unlike PHP, macros expand in double-quoted strings.
- prints "The frequency of the oscillator is $A_HZ Hz.\n"
- out aSignal
-endin
-
-// Here are other things to note about Csound.
++ - ~ ¬ ! * / ^ % << >> < > <= >= == != & # | && || ? : += -= *= /=
-// There are two bitwise NOT operators, ~ and ¬ (U+00AC). The latter is common
-// on keyboards in the United Kingdom
-// <https://en.wikipedia.org/wiki/British_and_American_keyboards>.
-instr TestBitwiseNOT
- print ~42
- print ¬42
-endin
-
-// Csound uses # for bitwise XOR, which the Csound manual calls bitwise
-// non-equivalence <http://www.csounds.com/manual/html/opnonequiv.html>.
-instr TestBitwiseXOR
- print 0 # 0
- print 0 # 1
- print 1 # 0
- print 1 # 1
-endin
+0dbfs A4 kr ksmps nchnls nchnls_i sr
-// Loops and if-then statements are relatively recent additions to Csound. There
-// are many flow-control opcodes that involve goto and labels.
-instr TestGoto
- // This...
- if p3 > 0 goto if_label
- goto else_label
-if_label:
- prints "if branch\n"
- goto endif_label
-else_label:
- prints "else branch\n"
-endif_label:
+do else elseif endif enduntil fi if ithen kthen od then until while
+return rireturn
- // ...is the same as this.
- if p3 > 0 then
- prints "if branch\n"
- else
- prints "else branch\n"
- endif
+aLabel:
+ label2:
- // This...
- iIndex = 0
-loop_label:
- print iIndex
- iIndex += 1
- if iIndex < 10 goto loop_label
+goto aLabel
+reinit aLabel
+cggoto 1==0, aLabel
+timout 0, 0, aLabel
+loop_ge 0, 0, 0, aLabel
- // ...is the same as this...
- iIndex = 0
-loop_lt_label:
- print iIndex
- loop_lt iIndex, 1, 10, loop_lt_label
-
- // ...and this.
- iIndex = 0
- while iIndex < 10 do
- print iIndex
- iIndex += 1
- od
-endin
+prints "%! %% %n%N %r%R %t%T \\a\\A \\b\\B \\n\\N \\r\\R \\t\\T"
+prints Soutput
-// The prints and printks opcodes
-// <https://github.com/csound/csound/blob/develop/OOps/ugrw1.c#L831>, arguably
-// the primary methods of logging output, treat certain sequences of characters
-// different from printf in C.
-instr TestPrints
- // ^ prints an ESCAPE character (U+001B), not a CIRCUMFLEX ACCENT character
- // (U+005E). ^^ prints a CIRCUMFLEX ACCENT.
- prints "^^\n"
- // ~ prints an ESCAPE character (U+001B) followed by a [, not a TILDE
- // character (U+007E). ~~ prints a TILDE.
- prints "~~\n"
- // \A, \B, \N, \R, and \T correspond to the escaped lowercase characters (that
- // is, BELL (U+0007), BACKSPACE (U+0008), new line (U+000A), CARRIAGE RETURN
- // (U+000D), and tab (U+0009)).
- prints "\T\R\N"
- // %n, %r, and %t are the same as \n, \r, and \t, as are %N, %R, and %T.
- prints "%t%r%n"
- // %! prints a semicolon. This is a hold-over from old versions of Csound that
- // allowed comments to begin in strings.
- prints "; %!\n"
-endin
-
-// The arguments of function-like macros can be separated by # instead of '.
-// These two lines define the same macro.
-#define OSCIL_MACRO(VOLUME'FREQUENCY'TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE#
-#define OSCIL_MACRO(VOLUME#FREQUENCY#TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE#
-
-// Uses of macros can optionally be suffixed with a period.
-instr TestMacroPeriodSuffix
- aSignal $OSCIL_MACRO.(1'$A_HZ'1)
- prints "The frequency of the oscillator is $A_HZ.Hz.\n"
- out aSignal
-endin
-
-// Csound has @ and @@ operator-like macros that, when followed by a literal
-// non-negative integer, expand to the next power of 2 and the next power of 2
-// plus 1:
-// @x = 2^(ceil(log2(x + 1))), x >= 0
-// @@0 = 2
-// @@x = 2^(ceil(log2(x))) + 1, x > 0
-// These macros are in
-// <https://github.com/csound/csound/blob/develop/Engine/csound_orc.l#L542> (and
-// <https://github.com/csound/csound/blob/develop/Engine/csound_sco.lex#L202>)
-// and are described at <http://www.csounds.com/manual/html/ScoreEval.html>.
-instr TestAt
- prints "%d %2d %2d\n", 0, @0, @@0
- prints "%d %2d %2d\n", 1, @1, @@1
- prints "%d %2d %2d\n", 2, @2, @@2
- prints "%d %2d %2d\n", 3, @3, @@3
- prints "%d %2d %2d\n", 4, @4, @@4
- prints "%d %2d %2d\n", 5, @5, @@5
- prints "%d %2d %2d\n", 6, @6, @@6
- prints "%d %2d %2d\n", 7, @7, @@7
- prints "%d %2d %2d\n", 8, @8, @@8
- prints "%d %2d %2d\n", 9, @9, @@9
-endin
+readscore {{
+i 1 0 0
+}}
+pyrun {{
+# Python
+}}
+lua_exec {{
+-- Lua
+}}
-// Including newlines in macros can lead to confusing code, but it tests the
-// lexer.
-instr MacroAbuse
- if 1 == 1 then
- prints "on\n"
-#define FOO#
-BAR
-#endif // This ends the if statement. It is not a preprocessor directive.
-endin
+#include/**/"file.udo"
+#include/**/|file.udo|
-scoreline_i {{
-f 1 0 16384 10 1
-i "N_a_M_e_" 0 2
-i "TestOscillator" 2 2
-i "TestBitwiseNOT" 0 1
-i "TestBitwiseXOR" 0 1
-i "TestGoto" 0 1
-i "TestMacroPeriodSuffix" 4 1
-i "TestAt" 0 1
-i "MacroAbuse" 0 1
-e
-}}
+#ifdef MACRO
+#else
+#ifndef MACRO
+#endif
+#undef MACRO
+
+# define MACRO#macro_body#
+#define/**/
+MACRO/**/
+#\#macro
+body\##
+
+#define MACRO(ARG1#ARG2) #macro_body#
+#define/**/
+MACRO(ARG1'ARG2'ARG3)/**/
+#\#macro
+body\##
+
+$MACRO $MACRO.
+$MACRO(x)
+@0
+@@ 1
diff --git a/tests/examplefiles/test.sco b/tests/examplefiles/test.sco
index a0b39251..d997c1b3 100644
--- a/tests/examplefiles/test.sco
+++ b/tests/examplefiles/test.sco
@@ -1,10 +1,22 @@
-f 1 0 16384 10 1
-i "N_a_M_e_" 0 2
-i "TestOscillator" 2 2
-i "TestBitwiseNOT" 0 1
-i "TestBitwiseXOR" 0 1
-i "TestGoto" 0 1
-i "TestMacroPeriodSuffix" 4 1
-i "TestAt" 0 1
-i "MacroAbuse" 0 1
-e
+/*
+ * comment
+ */
+; comment
+// comment
+a b C d e f i q s t v x y
+z
+np0 nP1 Np2 NP3
+m/**/label;
+n label
+123 0123456789
+0xabcdef0123456789 0XABCDEF
+1e2 3e+4 5e-6 7E8 9E+0 1E-2 3. 4.56 .789
+"characters$MACRO."
+{ 1 I
+ { 2 J
+ { 3 K
+ $I $J $K
+ }
+ }
+}
+#include "score.sco"
diff --git a/tests/test_csound.py b/tests/test_csound.py
new file mode 100644
index 00000000..4d10c267
--- /dev/null
+++ b/tests/test_csound.py
@@ -0,0 +1,480 @@
+# -*- coding: utf-8 -*-
+"""
+ Csound lexer tests
+ ~~~~~~~~~~~~~~~~~~~~
+
+ :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import unittest
+from textwrap import dedent
+
+from pygments.token import Comment, Error, Keyword, Name, Number, Operator, Punctuation, \
+ String, Text
+from pygments.lexers import CsoundOrchestraLexer
+
+
+class CsoundOrchestraTest(unittest.TestCase):
+
+ def setUp(self):
+ self.lexer = CsoundOrchestraLexer()
+ self.maxDiff = None
+
+ def testComments(self):
+ fragment = dedent('''\
+ /*
+ * comment
+ */
+ ; comment
+ // comment
+ ''')
+ tokens = [
+ (Comment.Multiline, u'/*\n * comment\n */'),
+ (Text, u'\n'),
+ (Comment.Single, u'; comment'),
+ (Text, u'\n'),
+ (Comment.Single, u'// comment'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testInstrumentBlocks(self):
+ fragment = dedent('''\
+ instr/**/1,/**/N_a_M_e_,/**/+Name/**///
+ iDuration = p3
+ outc:a(aSignal)
+ endin
+ ''')
+ tokens = [
+ (Keyword.Declaration, u'instr'),
+ (Comment.Multiline, u'/**/'),
+ (Name.Function, u'1'),
+ (Punctuation, u','),
+ (Comment.Multiline, u'/**/'),
+ (Name.Function, u'N_a_M_e_'),
+ (Punctuation, u','),
+ (Comment.Multiline, u'/**/'),
+ (Punctuation, u'+'),
+ (Name.Function, u'Name'),
+ (Comment.Multiline, u'/**/'),
+ (Comment.Single, u'//'),
+ (Text, u'\n'),
+ (Text, u' '),
+ (Keyword.Type, u'i'),
+ (Name, u'Duration'),
+ (Text, u' '),
+ (Operator, u'='),
+ (Text, u' '),
+ (Name.Variable.Instance, u'p3'),
+ (Text, u'\n'),
+ (Text, u' '),
+ (Name.Builtin, u'outc'),
+ (Punctuation, u':'),
+ (Keyword.Type, u'a'),
+ (Punctuation, u'('),
+ (Keyword.Type, u'a'),
+ (Name, u'Signal'),
+ (Punctuation, u')'),
+ (Text, u'\n'),
+ (Keyword.Declaration, u'endin'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testUserDefinedOpcodes(self):
+ fragment = dedent('''\
+ opcode/**/aUDO,/**/i[],/**/aik//
+ aUDO
+ endop
+ ''')
+ tokens = [
+ (Keyword.Declaration, u'opcode'),
+ (Comment.Multiline, u'/**/'),
+ (Name.Function, u'aUDO'),
+ (Punctuation, u','),
+ (Comment.Multiline, u'/**/'),
+ (Keyword.Type, u'i[]'),
+ (Punctuation, u','),
+ (Comment.Multiline, u'/**/'),
+ (Keyword.Type, u'aik'),
+ (Comment.Single, u'//'),
+ (Text, u'\n'),
+ (Text, u' '),
+ (Name.Function, u'aUDO'),
+ (Text, u'\n'),
+ (Keyword.Declaration, u'endop'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testNumbers(self):
+ fragment = '123 0123456789'
+ tokens = [
+ (Number.Integer, u'123'),
+ (Text, u' '),
+ (Number.Integer, u'0123456789'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+ fragment = '0xabcdef0123456789 0XABCDEF'
+ tokens = [
+ (Keyword.Type, u'0x'),
+ (Number.Hex, u'abcdef0123456789'),
+ (Text, u' '),
+ (Keyword.Type, u'0X'),
+ (Number.Hex, u'ABCDEF'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+ fragments = ['1e2', '3e+4', '5e-6', '7E8', '9E+0', '1E-2', '3.', '4.56', '.789']
+ for fragment in fragments:
+ tokens = [
+ (Number.Float, fragment),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testQuotedStrings(self):
+ fragment = '"characters$MACRO."'
+ tokens = [
+ (String, u'"'),
+ (String, u'characters'),
+ (Comment.Preproc, u'$MACRO.'),
+ (String, u'"'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testBracedStrings(self):
+ fragment = dedent('''\
+ {{
+ characters$MACRO.
+ }}
+ ''')
+ tokens = [
+ (String, u'{{'),
+ (String, u'\ncharacters$MACRO.\n'),
+ (String, u'}}'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testEscapeSequences(self):
+ for character in ['\\', 'a', 'b', 'n', 'r', 't', '"', '012', '345', '67']:
+ escapedCharacter = '\\' + character
+ fragment = '"' + escapedCharacter + '"'
+ tokens = [
+ (String, u'"'),
+ (String.Escape, escapedCharacter),
+ (String, u'"'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+ fragment = '{{' + escapedCharacter + '}}'
+ tokens = [
+ (String, u'{{'),
+ (String.Escape, escapedCharacter),
+ (String, u'}}'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testOperators(self):
+ fragments = ['+', '-', '~', u'¬', '!', '*', '/', '^', '%', '<<', '>>', '<', '>',
+ '<=', '>=', '==', '!=', '&', '#', '|', '&&', '||', '?', ':', '+=',
+ '-=', '*=', '/=']
+ for fragment in fragments:
+ tokens = [
+ (Operator, fragment),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testGlobalValueIdentifiers(self):
+ for fragment in ['0dbfs', 'A4', 'kr', 'ksmps', 'nchnls', 'nchnls_i', 'sr']:
+ tokens = [
+ (Name.Variable.Global, fragment),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testKeywords(self):
+ fragments = ['do', 'else', 'elseif', 'endif', 'enduntil', 'fi', 'if', 'ithen',
+ 'kthen', 'od', 'then', 'until', 'while']
+ for fragment in fragments:
+ tokens = [
+ (Keyword, fragment),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+ for fragment in ['return', 'rireturn']:
+ tokens = [
+ (Keyword.Pseudo, fragment),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testLabels(self):
+ fragment = dedent('''\
+ aLabel:
+ label2:
+ ''')
+ tokens = [
+ (Name.Label, u'aLabel'),
+ (Punctuation, u':'),
+ (Text, u'\n'),
+ (Text, u' '),
+ (Name.Label, u'label2'),
+ (Punctuation, u':'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testPrintksAndPrintsEscapeSequences(self):
+ escapedCharacters = ['%!', '%%', '%n', '%N', '%r', '%R', '%t', '%T', '\\\\a',
+ '\\\\A', '\\\\b', '\\\\B', '\\\\n', '\\\\N', '\\\\r',
+ '\\\\R', '\\\\t', '\\\\T']
+ for opcode in ['printks', 'prints']:
+ for escapedCharacter in escapedCharacters:
+ fragment = opcode + ' "' + escapedCharacter + '"'
+ tokens = [
+ (Name.Builtin, opcode),
+ (Text, u' '),
+ (String, u'"'),
+ (String.Escape, escapedCharacter),
+ (String, u'"'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testGotoStatements(self):
+ for keyword in ['goto', 'igoto', 'kgoto']:
+ fragment = keyword + ' aLabel'
+ tokens = [
+ (Keyword, keyword),
+ (Text, u' '),
+ (Name.Label, u'aLabel'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+ for opcode in ['reinit', 'rigoto', 'tigoto']:
+ fragment = opcode + ' aLabel'
+ tokens = [
+ (Keyword.Pseudo, opcode),
+ (Text, u' '),
+ (Name.Label, u'aLabel'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+ for opcode in ['cggoto', 'cigoto', 'cingoto', 'ckgoto', 'cngoto', 'cnkgoto']:
+ fragment = opcode + ' 1==0, aLabel'
+ tokens = [
+ (Keyword.Pseudo, opcode),
+ (Text, u' '),
+ (Number.Integer, u'1'),
+ (Operator, u'=='),
+ (Number.Integer, u'0'),
+ (Punctuation, u','),
+ (Text, u' '),
+ (Name.Label, u'aLabel'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+ fragment = 'timout 0, 0, aLabel'
+ tokens = [
+ (Keyword.Pseudo, 'timout'),
+ (Text, u' '),
+ (Number.Integer, u'0'),
+ (Punctuation, u','),
+ (Text, u' '),
+ (Number.Integer, u'0'),
+ (Punctuation, u','),
+ (Text, u' '),
+ (Name.Label, u'aLabel'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+ for opcode in ['loop_ge', 'loop_gt', 'loop_le', 'loop_lt']:
+ fragment = opcode + ' 0, 0, 0, aLabel'
+ tokens = [
+ (Keyword.Pseudo, opcode),
+ (Text, u' '),
+ (Number.Integer, u'0'),
+ (Punctuation, u','),
+ (Text, u' '),
+ (Number.Integer, u'0'),
+ (Punctuation, u','),
+ (Text, u' '),
+ (Number.Integer, u'0'),
+ (Punctuation, u','),
+ (Text, u' '),
+ (Name.Label, u'aLabel'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testIncludeDirectives(self):
+ for character in ['"', '|']:
+ fragment = '#include/**/' + character + 'file.udo' + character
+ tokens = [
+ (Comment.Preproc, u'#include'),
+ (Comment.Multiline, u'/**/'),
+ (String, character + u'file.udo' + character),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testObjectLikeMacroDefinitions(self):
+ fragment = dedent('''\
+ # \tdefine MACRO#macro_body#
+ #define/**/
+ MACRO/**/
+ #\\#macro
+ body\\##
+ ''')
+ tokens = [
+ (Comment.Preproc, u'# \tdefine'),
+ (Text, u' '),
+ (Comment.Preproc, u'MACRO'),
+ (Punctuation, u'#'),
+ (Comment.Preproc, u'macro_body'),
+ (Punctuation, u'#'),
+ (Text, u'\n'),
+ (Comment.Preproc, u'#define'),
+ (Comment.Multiline, u'/**/'),
+ (Text, u'\n'),
+ (Comment.Preproc, u'MACRO'),
+ (Comment.Multiline, u'/**/'),
+ (Text, u'\n'),
+ (Punctuation, u'#'),
+ (Comment.Preproc, u'\\#'),
+ (Comment.Preproc, u'macro\nbody'),
+ (Comment.Preproc, u'\\#'),
+ (Punctuation, u'#'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testFunctionLikeMacroDefinitions(self):
+ fragment = dedent('''\
+ #define MACRO(ARG1#ARG2) #macro_body#
+ #define/**/
+ MACRO(ARG1'ARG2' ARG3)/**/
+ #\\#macro
+ body\\##
+ ''')
+ tokens = [
+ (Comment.Preproc, u'#define'),
+ (Text, u' '),
+ (Comment.Preproc, u'MACRO'),
+ (Punctuation, u'('),
+ (Comment.Preproc, u'ARG1'),
+ (Punctuation, u'#'),
+ (Comment.Preproc, u'ARG2'),
+ (Punctuation, u')'),
+ (Text, u' '),
+ (Punctuation, u'#'),
+ (Comment.Preproc, u'macro_body'),
+ (Punctuation, u'#'),
+ (Text, u'\n'),
+ (Comment.Preproc, u'#define'),
+ (Comment.Multiline, u'/**/'),
+ (Text, u'\n'),
+ (Comment.Preproc, u'MACRO'),
+ (Punctuation, u'('),
+ (Comment.Preproc, u'ARG1'),
+ (Punctuation, u"'"),
+ (Comment.Preproc, u'ARG2'),
+ (Punctuation, u"'"),
+ (Text, u' '),
+ (Comment.Preproc, u'ARG3'),
+ (Punctuation, u')'),
+ (Comment.Multiline, u'/**/'),
+ (Text, u'\n'),
+ (Punctuation, u'#'),
+ (Comment.Preproc, u'\\#'),
+ (Comment.Preproc, u'macro\nbody'),
+ (Comment.Preproc, u'\\#'),
+ (Punctuation, u'#'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testMacroPreprocessorDirectives(self):
+ for directive in ['#ifdef', '#ifndef', '#undef']:
+ fragment = directive + ' MACRO'
+ tokens = [
+ (Comment.Preproc, directive),
+ (Text, u' '),
+ (Comment.Preproc, u'MACRO'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testOtherPreprocessorDirectives(self):
+ fragment = dedent('''\
+ #else
+ #end
+ #endif
+ ###
+ @ \t12345
+ @@ \t67890
+ ''')
+ tokens = [
+ (Comment.Preproc, u'#else'),
+ (Text, u'\n'),
+ (Comment.Preproc, u'#end'),
+ (Text, u'\n'),
+ (Comment.Preproc, u'#endif'),
+ (Text, u'\n'),
+ (Comment.Preproc, u'###'),
+ (Text, u'\n'),
+ (Comment.Preproc, u'@ \t12345'),
+ (Text, u'\n'),
+ (Comment.Preproc, u'@@ \t67890'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testFunctionLikeMacros(self):
+ fragment = "$MACRO.(((x#y\\)))' \"(#'x)\\)x\\))\"# {{x\\))x)\\)(#'}});"
+ tokens = [
+ (Comment.Preproc, u'$MACRO.'),
+ (Punctuation, u'('),
+ (Comment.Preproc, u'('),
+ (Comment.Preproc, u'('),
+ (Comment.Preproc, u'x#y\\)'),
+ (Comment.Preproc, u')'),
+ (Comment.Preproc, u')'),
+ (Punctuation, u"'"),
+ (Comment.Preproc, u' '),
+ (String, u'"'),
+ (Error, u'('),
+ (Error, u'#'),
+ (Error, u"'"),
+ (String, u'x'),
+ (Error, u')'),
+ (Comment.Preproc, u'\\)'),
+ (String, u'x'),
+ (Comment.Preproc, u'\\)'),
+ (Error, u')'),
+ (String, u'"'),
+ (Punctuation, u'#'),
+ (Comment.Preproc, u' '),
+ (String, u'{{'),
+ (String, u'x'),
+ (Comment.Preproc, u'\\)'),
+ (Error, u')'),
+ (String, u'x'),
+ (Error, u')'),
+ (Comment.Preproc, u'\\)'),
+ (Error, u'('),
+ (Error, u'#'),
+ (Error, u"'"),
+ (String, u'}}'),
+ (Punctuation, u')'),
+ (Comment.Single, u';'),
+ (Text, u'\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
diff --git a/tests/test_markdown_lexer.py b/tests/test_markdown_lexer.py
new file mode 100644
index 00000000..16d1f28d
--- /dev/null
+++ b/tests/test_markdown_lexer.py
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+"""
+ Pygments regex lexer tests
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+import unittest
+
+from pygments.lexers.markup import MarkdownLexer
+
+
+class SameTextTests(unittest.TestCase):
+
+ lexer = MarkdownLexer()
+
+ def assert_same_text(self, text):
+ """Show that lexed markdown does not remove any content. """
+ tokens = list(self.lexer.get_tokens_unprocessed(text))
+ output = ''.join(t[2] for t in tokens)
+ self.assertEqual(text, output)
+
+ def test_code_fence(self):
+ self.assert_same_text(r'```\nfoo\n```\n')
+
+ def test_code_fence_gsm(self):
+ self.assert_same_text(r'```markdown\nfoo\n```\n')
+
+ def test_code_fence_gsm_with_no_lexer(self):
+ self.assert_same_text(r'```invalid-lexer\nfoo\n```\n')
diff --git a/tests/test_r.py b/tests/test_r.py
new file mode 100644
index 00000000..d0e9090b
--- /dev/null
+++ b/tests/test_r.py
@@ -0,0 +1,70 @@
+# -*- coding: utf-8 -*-
+"""
+ R Tests
+ ~~~~~~~~~
+
+ :copyright: Copyright 2006-2016 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import unittest
+
+from pygments.lexers import SLexer
+from pygments.token import Token, Name, Punctuation
+
+
+class RTest(unittest.TestCase):
+ def setUp(self):
+ self.lexer = SLexer()
+
+ def testCall(self):
+ fragment = u'f(1, a)\n'
+ tokens = [
+ (Name.Function, u'f'),
+ (Punctuation, u'('),
+ (Token.Literal.Number, u'1'),
+ (Punctuation, u','),
+ (Token.Text, u' '),
+ (Token.Name, u'a'),
+ (Punctuation, u')'),
+ (Token.Text, u'\n'),
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testName1(self):
+ fragment = u'._a_2.c'
+ tokens = [
+ (Name, u'._a_2.c'),
+ (Token.Text, u'\n'),
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testName2(self):
+ # Invalid names are valid if backticks are used
+ fragment = u'`.1 blah`'
+ tokens = [
+ (Name, u'`.1 blah`'),
+ (Token.Text, u'\n'),
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testName3(self):
+ # Internal backticks can be escaped
+ fragment = u'`.1 \` blah`'
+ tokens = [
+ (Name, u'`.1 \` blah`'),
+ (Token.Text, u'\n'),
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def testCustomOperator(self):
+ fragment = u'7 % and % 8'
+ tokens = [
+ (Token.Literal.Number, u'7'),
+ (Token.Text, u' '),
+ (Token.Operator, u'% and %'),
+ (Token.Text, u' '),
+ (Token.Literal.Number, u'8'),
+ (Token.Text, u'\n'),
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
diff --git a/tox.ini b/tox.ini
index 8a33f99c..2c63c292 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py26, py27, py33, py34
+envlist = py27, py35, py36, py37
[testenv]
deps =
nose