pygments.rb 1.2.1 → 2.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +13 -0
- data/.github/workflows/ci.yml +28 -0
- data/.github/workflows/release.yml +24 -0
- data/.gitignore +5 -6
- data/CHANGELOG.adoc +119 -0
- data/Gemfile +3 -1
- data/LICENSE +1 -1
- data/README.adoc +161 -0
- data/Rakefile +10 -21
- data/bench.rb +8 -7
- data/cache-lexers.rb +3 -2
- data/lib/pygments.rb +10 -11
- data/lib/pygments/lexer.rb +5 -5
- data/lib/pygments/mentos.py +23 -66
- data/lib/pygments/popen.rb +152 -204
- data/lib/pygments/version.rb +2 -2
- data/pygments.rb.gemspec +11 -9
- data/test/test_pygments.rb +51 -84
- data/vendor/pygments-main/{AUTHORS → Pygments-2.7.3.dist-info/AUTHORS} +21 -3
- data/vendor/pygments-main/Pygments-2.7.3.dist-info/INSTALLER +1 -0
- data/vendor/pygments-main/{LICENSE → Pygments-2.7.3.dist-info/LICENSE} +1 -1
- data/vendor/pygments-main/Pygments-2.7.3.dist-info/METADATA +49 -0
- data/vendor/pygments-main/Pygments-2.7.3.dist-info/RECORD +482 -0
- data/vendor/pygments-main/Pygments-2.7.3.dist-info/REQUESTED +0 -0
- data/vendor/pygments-main/Pygments-2.7.3.dist-info/WHEEL +5 -0
- data/vendor/pygments-main/Pygments-2.7.3.dist-info/entry_points.txt +3 -0
- data/vendor/pygments-main/Pygments-2.7.3.dist-info/top_level.txt +1 -0
- data/vendor/pygments-main/bin/pygmentize +8 -0
- data/vendor/pygments-main/pygments/__init__.py +6 -11
- data/vendor/pygments-main/pygments/__main__.py +18 -0
- data/vendor/pygments-main/pygments/cmdline.py +38 -29
- data/vendor/pygments-main/pygments/console.py +6 -9
- data/vendor/pygments-main/pygments/filter.py +4 -6
- data/vendor/pygments-main/pygments/filters/__init__.py +609 -21
- data/vendor/pygments-main/pygments/formatter.py +4 -4
- data/vendor/pygments-main/pygments/formatters/__init__.py +9 -8
- data/vendor/pygments-main/pygments/formatters/_mapping.py +1 -3
- data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
- data/vendor/pygments-main/pygments/formatters/html.py +223 -135
- data/vendor/pygments-main/pygments/formatters/img.py +68 -41
- data/vendor/pygments-main/pygments/formatters/irc.py +39 -39
- data/vendor/pygments-main/pygments/formatters/latex.py +56 -26
- data/vendor/pygments-main/pygments/formatters/other.py +12 -8
- data/vendor/pygments-main/pygments/formatters/rtf.py +29 -29
- data/vendor/pygments-main/pygments/formatters/svg.py +38 -4
- data/vendor/pygments-main/pygments/formatters/terminal.py +25 -31
- data/vendor/pygments-main/pygments/formatters/terminal256.py +22 -12
- data/vendor/pygments-main/pygments/lexer.py +41 -39
- data/vendor/pygments-main/pygments/lexers/__init__.py +342 -0
- data/vendor/pygments-main/pygments/lexers/_asy_builtins.py +1645 -0
- data/vendor/pygments-main/pygments/lexers/_cl_builtins.py +232 -0
- data/vendor/pygments-main/pygments/lexers/_cocoa_builtins.py +71 -0
- data/vendor/pygments-main/pygments/lexers/_csound_builtins.py +1725 -0
- data/vendor/pygments-main/pygments/lexers/_lasso_builtins.py +5327 -0
- data/vendor/pygments-main/pygments/lexers/_lua_builtins.py +293 -0
- data/vendor/pygments-main/pygments/lexers/_mapping.py +551 -0
- data/vendor/pygments-main/pygments/lexers/_mql_builtins.py +1172 -0
- data/vendor/pygments-main/pygments/lexers/_mysql_builtins.py +1282 -0
- data/vendor/pygments-main/pygments/lexers/_openedge_builtins.py +2547 -0
- data/vendor/pygments-main/pygments/lexers/_php_builtins.py +4753 -0
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +678 -0
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +3094 -0
- data/vendor/pygments-main/pygments/lexers/_sourcemod_builtins.py +1161 -0
- data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +558 -0
- data/vendor/pygments-main/pygments/lexers/_stata_builtins.py +421 -0
- data/vendor/pygments-main/pygments/lexers/_tsql_builtins.py +1004 -0
- data/vendor/pygments-main/pygments/lexers/_usd_builtins.py +113 -0
- data/vendor/pygments-main/pygments/lexers/_vbscript_builtins.py +280 -0
- data/vendor/pygments-main/pygments/lexers/_vim_builtins.py +1939 -0
- data/vendor/pygments-main/pygments/lexers/actionscript.py +245 -0
- data/vendor/pygments-main/pygments/lexers/agile.py +24 -0
- data/vendor/pygments-main/pygments/lexers/algebra.py +240 -0
- data/vendor/pygments-main/pygments/lexers/ambient.py +76 -0
- data/vendor/pygments-main/pygments/lexers/ampl.py +87 -0
- data/vendor/pygments-main/pygments/lexers/apl.py +101 -0
- data/vendor/pygments-main/pygments/lexers/archetype.py +318 -0
- data/vendor/pygments-main/pygments/lexers/arrow.py +117 -0
- data/vendor/pygments-main/pygments/lexers/asm.py +1005 -0
- data/vendor/pygments-main/pygments/lexers/automation.py +374 -0
- data/vendor/pygments-main/pygments/lexers/bare.py +104 -0
- data/vendor/pygments-main/pygments/lexers/basic.py +662 -0
- data/vendor/pygments-main/pygments/lexers/bibtex.py +160 -0
- data/vendor/pygments-main/pygments/lexers/boa.py +102 -0
- data/vendor/pygments-main/pygments/lexers/business.py +627 -0
- data/vendor/pygments-main/pygments/lexers/c_cpp.py +344 -0
- data/vendor/pygments-main/pygments/lexers/c_like.py +566 -0
- data/vendor/pygments-main/pygments/lexers/capnproto.py +78 -0
- data/vendor/pygments-main/pygments/lexers/chapel.py +112 -0
- data/vendor/pygments-main/pygments/lexers/clean.py +179 -0
- data/vendor/pygments-main/pygments/lexers/compiled.py +34 -0
- data/vendor/pygments-main/pygments/lexers/configs.py +984 -0
- data/vendor/pygments-main/pygments/lexers/console.py +114 -0
- data/vendor/pygments-main/pygments/lexers/crystal.py +392 -0
- data/vendor/pygments-main/pygments/lexers/csound.py +467 -0
- data/vendor/pygments-main/pygments/lexers/css.py +691 -0
- data/vendor/pygments-main/pygments/lexers/d.py +256 -0
- data/vendor/pygments-main/pygments/lexers/dalvik.py +125 -0
- data/vendor/pygments-main/pygments/lexers/data.py +698 -0
- data/vendor/pygments-main/pygments/lexers/devicetree.py +109 -0
- data/vendor/pygments-main/pygments/lexers/diff.py +165 -0
- data/vendor/pygments-main/pygments/lexers/dotnet.py +707 -0
- data/vendor/pygments-main/pygments/lexers/dsls.py +960 -0
- data/vendor/pygments-main/pygments/lexers/dylan.py +287 -0
- data/vendor/pygments-main/pygments/lexers/ecl.py +139 -0
- data/vendor/pygments-main/pygments/lexers/eiffel.py +65 -0
- data/vendor/pygments-main/pygments/lexers/elm.py +121 -0
- data/vendor/pygments-main/pygments/lexers/email.py +151 -0
- data/vendor/pygments-main/pygments/lexers/erlang.py +530 -0
- data/vendor/pygments-main/pygments/lexers/esoteric.py +304 -0
- data/vendor/pygments-main/pygments/lexers/ezhil.py +77 -0
- data/vendor/pygments-main/pygments/lexers/factor.py +344 -0
- data/vendor/pygments-main/pygments/lexers/fantom.py +250 -0
- data/vendor/pygments-main/pygments/lexers/felix.py +273 -0
- data/vendor/pygments-main/pygments/lexers/floscript.py +83 -0
- data/vendor/pygments-main/pygments/lexers/forth.py +178 -0
- data/vendor/pygments-main/pygments/lexers/fortran.py +206 -0
- data/vendor/pygments-main/pygments/lexers/foxpro.py +428 -0
- data/vendor/pygments-main/pygments/lexers/freefem.py +898 -0
- data/vendor/pygments-main/pygments/lexers/functional.py +21 -0
- data/vendor/pygments-main/pygments/lexers/gdscript.py +346 -0
- data/vendor/pygments-main/pygments/lexers/go.py +101 -0
- data/vendor/pygments-main/pygments/lexers/grammar_notation.py +270 -0
- data/vendor/pygments-main/pygments/lexers/graph.py +85 -0
- data/vendor/pygments-main/pygments/lexers/graphics.py +800 -0
- data/vendor/pygments-main/pygments/lexers/haskell.py +870 -0
- data/vendor/pygments-main/pygments/lexers/haxe.py +936 -0
- data/vendor/pygments-main/pygments/lexers/hdl.py +472 -0
- data/vendor/pygments-main/pygments/lexers/hexdump.py +103 -0
- data/vendor/pygments-main/pygments/lexers/html.py +614 -0
- data/vendor/pygments-main/pygments/lexers/idl.py +281 -0
- data/vendor/pygments-main/pygments/lexers/igor.py +420 -0
- data/vendor/pygments-main/pygments/lexers/inferno.py +96 -0
- data/vendor/pygments-main/pygments/lexers/installers.py +322 -0
- data/vendor/pygments-main/pygments/lexers/int_fiction.py +1368 -0
- data/vendor/pygments-main/pygments/lexers/iolang.py +63 -0
- data/vendor/pygments-main/pygments/lexers/j.py +146 -0
- data/vendor/pygments-main/pygments/lexers/javascript.py +1540 -0
- data/vendor/pygments-main/pygments/lexers/julia.py +331 -0
- data/vendor/pygments-main/pygments/lexers/jvm.py +1673 -0
- data/vendor/pygments-main/pygments/lexers/lisp.py +2699 -0
- data/vendor/pygments-main/pygments/lexers/make.py +206 -0
- data/vendor/pygments-main/pygments/lexers/markup.py +765 -0
- data/vendor/pygments-main/pygments/lexers/math.py +21 -0
- data/vendor/pygments-main/pygments/lexers/matlab.py +720 -0
- data/vendor/pygments-main/pygments/lexers/mime.py +226 -0
- data/vendor/pygments-main/pygments/lexers/ml.py +958 -0
- data/vendor/pygments-main/pygments/lexers/modeling.py +366 -0
- data/vendor/pygments-main/pygments/lexers/modula2.py +1580 -0
- data/vendor/pygments-main/pygments/lexers/monte.py +204 -0
- data/vendor/pygments-main/pygments/lexers/mosel.py +448 -0
- data/vendor/pygments-main/pygments/lexers/ncl.py +894 -0
- data/vendor/pygments-main/pygments/lexers/nimrod.py +159 -0
- data/vendor/pygments-main/pygments/lexers/nit.py +64 -0
- data/vendor/pygments-main/pygments/lexers/nix.py +136 -0
- data/vendor/pygments-main/pygments/lexers/oberon.py +121 -0
- data/vendor/pygments-main/pygments/lexers/objective.py +504 -0
- data/vendor/pygments-main/pygments/lexers/ooc.py +85 -0
- data/vendor/pygments-main/pygments/lexers/other.py +41 -0
- data/vendor/pygments-main/pygments/lexers/parasail.py +79 -0
- data/vendor/pygments-main/pygments/lexers/parsers.py +800 -0
- data/vendor/pygments-main/pygments/lexers/pascal.py +644 -0
- data/vendor/pygments-main/pygments/lexers/pawn.py +205 -0
- data/vendor/pygments-main/pygments/lexers/perl.py +732 -0
- data/vendor/pygments-main/pygments/lexers/php.py +321 -0
- data/vendor/pygments-main/pygments/lexers/pointless.py +71 -0
- data/vendor/pygments-main/pygments/lexers/pony.py +94 -0
- data/vendor/pygments-main/pygments/lexers/praat.py +302 -0
- data/vendor/pygments-main/pygments/lexers/prolog.py +306 -0
- data/vendor/pygments-main/pygments/lexers/promql.py +183 -0
- data/vendor/pygments-main/pygments/lexers/python.py +1151 -0
- data/vendor/pygments-main/pygments/lexers/qvt.py +152 -0
- data/vendor/pygments-main/pygments/lexers/r.py +191 -0
- data/vendor/pygments-main/pygments/lexers/rdf.py +463 -0
- data/vendor/pygments-main/pygments/lexers/rebol.py +431 -0
- data/vendor/pygments-main/pygments/lexers/resource.py +85 -0
- data/vendor/pygments-main/pygments/lexers/ride.py +139 -0
- data/vendor/pygments-main/pygments/lexers/rnc.py +67 -0
- data/vendor/pygments-main/pygments/lexers/roboconf.py +82 -0
- data/vendor/pygments-main/pygments/lexers/robotframework.py +552 -0
- data/vendor/pygments-main/pygments/lexers/ruby.py +517 -0
- data/vendor/pygments-main/pygments/lexers/rust.py +224 -0
- data/vendor/pygments-main/pygments/lexers/sas.py +228 -0
- data/vendor/pygments-main/pygments/lexers/scdoc.py +83 -0
- data/vendor/pygments-main/pygments/lexers/scripting.py +1284 -0
- data/vendor/pygments-main/pygments/lexers/sgf.py +61 -0
- data/vendor/pygments-main/pygments/lexers/shell.py +914 -0
- data/vendor/pygments-main/pygments/lexers/sieve.py +69 -0
- data/vendor/pygments-main/pygments/lexers/slash.py +185 -0
- data/vendor/pygments-main/pygments/lexers/smalltalk.py +195 -0
- data/vendor/pygments-main/pygments/lexers/smv.py +79 -0
- data/vendor/pygments-main/pygments/lexers/snobol.py +83 -0
- data/vendor/pygments-main/pygments/lexers/solidity.py +92 -0
- data/vendor/pygments-main/pygments/lexers/special.py +105 -0
- data/vendor/pygments-main/pygments/lexers/sql.py +837 -0
- data/vendor/pygments-main/pygments/lexers/stata.py +171 -0
- data/vendor/pygments-main/pygments/lexers/supercollider.py +95 -0
- data/vendor/pygments-main/pygments/lexers/tcl.py +145 -0
- data/vendor/pygments-main/pygments/lexers/templates.py +2264 -0
- data/vendor/pygments-main/pygments/lexers/teraterm.py +335 -0
- data/vendor/pygments-main/pygments/lexers/testing.py +207 -0
- data/vendor/pygments-main/pygments/lexers/text.py +26 -0
- data/vendor/pygments-main/pygments/lexers/textedit.py +169 -0
- data/vendor/pygments-main/pygments/lexers/textfmts.py +430 -0
- data/vendor/pygments-main/pygments/lexers/theorem.py +474 -0
- data/vendor/pygments-main/pygments/lexers/tnt.py +263 -0
- data/vendor/pygments-main/pygments/lexers/trafficscript.py +54 -0
- data/vendor/pygments-main/pygments/lexers/typoscript.py +219 -0
- data/vendor/pygments-main/pygments/lexers/unicon.py +412 -0
- data/vendor/pygments-main/pygments/lexers/urbi.py +146 -0
- data/vendor/pygments-main/pygments/lexers/usd.py +90 -0
- data/vendor/pygments-main/pygments/lexers/varnish.py +190 -0
- data/vendor/pygments-main/pygments/lexers/verification.py +114 -0
- data/vendor/pygments-main/pygments/lexers/web.py +24 -0
- data/vendor/pygments-main/pygments/lexers/webidl.py +299 -0
- data/vendor/pygments-main/pygments/lexers/webmisc.py +991 -0
- data/vendor/pygments-main/pygments/lexers/whiley.py +116 -0
- data/vendor/pygments-main/pygments/lexers/x10.py +69 -0
- data/vendor/pygments-main/pygments/lexers/xorg.py +37 -0
- data/vendor/pygments-main/pygments/lexers/yang.py +104 -0
- data/vendor/pygments-main/pygments/lexers/zig.py +124 -0
- data/vendor/pygments-main/pygments/modeline.py +1 -1
- data/vendor/pygments-main/pygments/plugin.py +4 -2
- data/vendor/pygments-main/pygments/regexopt.py +1 -1
- data/vendor/pygments-main/pygments/scanner.py +2 -2
- data/vendor/pygments-main/pygments/sphinxext.py +2 -4
- data/vendor/pygments-main/pygments/style.py +61 -24
- data/vendor/pygments-main/pygments/styles/__init__.py +10 -4
- data/vendor/pygments-main/pygments/styles/abap.py +1 -1
- data/vendor/pygments-main/pygments/styles/algol.py +1 -1
- data/vendor/pygments-main/pygments/styles/algol_nu.py +1 -1
- data/vendor/pygments-main/pygments/styles/arduino.py +2 -2
- data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
- data/vendor/pygments-main/pygments/styles/borland.py +1 -1
- data/vendor/pygments-main/pygments/styles/bw.py +1 -1
- data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
- data/vendor/pygments-main/pygments/styles/default.py +1 -1
- data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
- data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
- data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
- data/vendor/pygments-main/pygments/styles/igor.py +1 -1
- data/vendor/pygments-main/pygments/styles/inkpot.py +67 -0
- data/vendor/pygments-main/pygments/styles/lovelace.py +1 -1
- data/vendor/pygments-main/pygments/styles/manni.py +1 -1
- data/vendor/pygments-main/pygments/styles/monokai.py +4 -3
- data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
- data/vendor/pygments-main/pygments/styles/native.py +1 -1
- data/vendor/pygments-main/pygments/styles/paraiso_dark.py +1 -1
- data/vendor/pygments-main/pygments/styles/paraiso_light.py +1 -1
- data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
- data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
- data/vendor/pygments-main/pygments/styles/rainbow_dash.py +1 -1
- data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
- data/vendor/pygments-main/pygments/styles/sas.py +1 -1
- data/vendor/pygments-main/pygments/styles/solarized.py +134 -0
- data/vendor/pygments-main/pygments/styles/stata_dark.py +41 -0
- data/vendor/pygments-main/pygments/styles/{stata.py → stata_light.py} +14 -15
- data/vendor/pygments-main/pygments/styles/tango.py +1 -1
- data/vendor/pygments-main/pygments/styles/trac.py +1 -1
- data/vendor/pygments-main/pygments/styles/vim.py +1 -1
- data/vendor/pygments-main/pygments/styles/vs.py +1 -1
- data/vendor/pygments-main/pygments/styles/xcode.py +1 -1
- data/vendor/pygments-main/pygments/token.py +1 -1
- data/vendor/pygments-main/pygments/unistring.py +47 -108
- data/vendor/pygments-main/pygments/util.py +15 -92
- metadata +69 -136
- data/CHANGELOG.md +0 -111
- data/README.md +0 -121
- data/circle.yml +0 -20
- data/test/test_data.py +0 -514
- data/test/test_data_generated +0 -2582
- data/vendor/custom_lexers/github.py +0 -565
- data/vendor/pygments-main/CHANGES +0 -1186
- data/vendor/pygments-main/MANIFEST.in +0 -6
- data/vendor/pygments-main/Makefile +0 -65
- data/vendor/pygments-main/README.rst +0 -39
- data/vendor/pygments-main/REVISION +0 -1
- data/vendor/pygments-main/TODO +0 -12
- data/vendor/pygments-main/doc/Makefile +0 -153
- data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
- data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
- data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
- data/vendor/pygments-main/doc/_templates/docssidebar.html +0 -3
- data/vendor/pygments-main/doc/_templates/indexsidebar.html +0 -25
- data/vendor/pygments-main/doc/_themes/pygments14/layout.html +0 -98
- data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +0 -401
- data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +0 -15
- data/vendor/pygments-main/doc/conf.py +0 -241
- data/vendor/pygments-main/doc/docs/api.rst +0 -354
- data/vendor/pygments-main/doc/docs/authors.rst +0 -4
- data/vendor/pygments-main/doc/docs/changelog.rst +0 -1
- data/vendor/pygments-main/doc/docs/cmdline.rst +0 -166
- data/vendor/pygments-main/doc/docs/filterdevelopment.rst +0 -71
- data/vendor/pygments-main/doc/docs/filters.rst +0 -41
- data/vendor/pygments-main/doc/docs/formatterdevelopment.rst +0 -169
- data/vendor/pygments-main/doc/docs/formatters.rst +0 -48
- data/vendor/pygments-main/doc/docs/index.rst +0 -66
- data/vendor/pygments-main/doc/docs/integrate.rst +0 -40
- data/vendor/pygments-main/doc/docs/java.rst +0 -70
- data/vendor/pygments-main/doc/docs/lexerdevelopment.rst +0 -728
- data/vendor/pygments-main/doc/docs/lexers.rst +0 -69
- data/vendor/pygments-main/doc/docs/moinmoin.rst +0 -39
- data/vendor/pygments-main/doc/docs/plugins.rst +0 -93
- data/vendor/pygments-main/doc/docs/quickstart.rst +0 -205
- data/vendor/pygments-main/doc/docs/rstdirective.rst +0 -22
- data/vendor/pygments-main/doc/docs/styles.rst +0 -201
- data/vendor/pygments-main/doc/docs/tokens.rst +0 -372
- data/vendor/pygments-main/doc/docs/unicode.rst +0 -58
- data/vendor/pygments-main/doc/download.rst +0 -41
- data/vendor/pygments-main/doc/faq.rst +0 -139
- data/vendor/pygments-main/doc/index.rst +0 -54
- data/vendor/pygments-main/doc/languages.rst +0 -154
- data/vendor/pygments-main/doc/make.bat +0 -190
- data/vendor/pygments-main/doc/pygmentize.1 +0 -94
- data/vendor/pygments-main/external/autopygmentize +0 -101
- data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +0 -162
- data/vendor/pygments-main/external/markdown-processor.py +0 -67
- data/vendor/pygments-main/external/moin-parser.py +0 -112
- data/vendor/pygments-main/external/pygments.bashcomp +0 -38
- data/vendor/pygments-main/external/rst-directive.py +0 -82
- data/vendor/pygments-main/pygmentize +0 -8
- data/vendor/pygments-main/requirements.txt +0 -5
- data/vendor/pygments-main/scripts/check_sources.py +0 -211
- data/vendor/pygments-main/scripts/debug_lexer.py +0 -246
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +0 -33
- data/vendor/pygments-main/scripts/epydoc.css +0 -280
- data/vendor/pygments-main/scripts/get_vimkw.py +0 -74
- data/vendor/pygments-main/scripts/pylintrc +0 -301
- data/vendor/pygments-main/scripts/vim2pygments.py +0 -935
- data/vendor/pygments-main/setup.cfg +0 -10
- data/vendor/pygments-main/setup.py +0 -77
- data/vendor/pygments-main/tox.ini +0 -7
- data/vendor/simplejson/.gitignore +0 -10
- data/vendor/simplejson/.travis.yml +0 -5
- data/vendor/simplejson/CHANGES.txt +0 -291
- data/vendor/simplejson/LICENSE.txt +0 -19
- data/vendor/simplejson/MANIFEST.in +0 -5
- data/vendor/simplejson/README.rst +0 -19
- data/vendor/simplejson/conf.py +0 -179
- data/vendor/simplejson/index.rst +0 -628
- data/vendor/simplejson/scripts/make_docs.py +0 -18
- data/vendor/simplejson/setup.py +0 -104
- data/vendor/simplejson/simplejson/__init__.py +0 -510
- data/vendor/simplejson/simplejson/_speedups.c +0 -2745
- data/vendor/simplejson/simplejson/decoder.py +0 -425
- data/vendor/simplejson/simplejson/encoder.py +0 -567
- data/vendor/simplejson/simplejson/ordered_dict.py +0 -119
- data/vendor/simplejson/simplejson/scanner.py +0 -77
- data/vendor/simplejson/simplejson/tests/__init__.py +0 -67
- data/vendor/simplejson/simplejson/tests/test_bigint_as_string.py +0 -55
- data/vendor/simplejson/simplejson/tests/test_check_circular.py +0 -30
- data/vendor/simplejson/simplejson/tests/test_decimal.py +0 -66
- data/vendor/simplejson/simplejson/tests/test_decode.py +0 -83
- data/vendor/simplejson/simplejson/tests/test_default.py +0 -9
- data/vendor/simplejson/simplejson/tests/test_dump.py +0 -67
- data/vendor/simplejson/simplejson/tests/test_encode_basestring_ascii.py +0 -46
- data/vendor/simplejson/simplejson/tests/test_encode_for_html.py +0 -32
- data/vendor/simplejson/simplejson/tests/test_errors.py +0 -34
- data/vendor/simplejson/simplejson/tests/test_fail.py +0 -91
- data/vendor/simplejson/simplejson/tests/test_float.py +0 -19
- data/vendor/simplejson/simplejson/tests/test_indent.py +0 -86
- data/vendor/simplejson/simplejson/tests/test_item_sort_key.py +0 -20
- data/vendor/simplejson/simplejson/tests/test_namedtuple.py +0 -121
- data/vendor/simplejson/simplejson/tests/test_pass1.py +0 -76
- data/vendor/simplejson/simplejson/tests/test_pass2.py +0 -14
- data/vendor/simplejson/simplejson/tests/test_pass3.py +0 -20
- data/vendor/simplejson/simplejson/tests/test_recursion.py +0 -67
- data/vendor/simplejson/simplejson/tests/test_scanstring.py +0 -117
- data/vendor/simplejson/simplejson/tests/test_separators.py +0 -42
- data/vendor/simplejson/simplejson/tests/test_speedups.py +0 -20
- data/vendor/simplejson/simplejson/tests/test_tuple.py +0 -49
- data/vendor/simplejson/simplejson/tests/test_unicode.py +0 -109
- data/vendor/simplejson/simplejson/tool.py +0 -39
@@ -0,0 +1,61 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.sgf
|
4
|
+
~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexer for Smart Game Format (sgf) file format.
|
7
|
+
|
8
|
+
:copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
|
9
|
+
:license: BSD, see LICENSE for details.
|
10
|
+
"""
|
11
|
+
|
12
|
+
from pygments.lexer import RegexLexer, bygroups
|
13
|
+
from pygments.token import Name, Literal, String, Text, Punctuation
|
14
|
+
|
15
|
+
__all__ = ["SmartGameFormatLexer"]
|
16
|
+
|
17
|
+
|
18
|
+
class SmartGameFormatLexer(RegexLexer):
|
19
|
+
"""
|
20
|
+
Lexer for Smart Game Format (sgf) file format.
|
21
|
+
|
22
|
+
The format is used to store game records of board games for two players
|
23
|
+
(mainly Go game).
|
24
|
+
For more information about the definition of the format, see:
|
25
|
+
https://www.red-bean.com/sgf/
|
26
|
+
|
27
|
+
.. versionadded:: 2.4
|
28
|
+
"""
|
29
|
+
name = 'SmartGameFormat'
|
30
|
+
aliases = ['sgf']
|
31
|
+
filenames = ['*.sgf']
|
32
|
+
|
33
|
+
tokens = {
|
34
|
+
'root': [
|
35
|
+
(r'[\s():;]', Punctuation),
|
36
|
+
# tokens:
|
37
|
+
(r'(A[BW]|AE|AN|AP|AR|AS|[BW]L|BM|[BW]R|[BW]S|[BW]T|CA|CH|CP|CR|'
|
38
|
+
r'DD|DM|DO|DT|EL|EV|EX|FF|FG|G[BW]|GC|GM|GN|HA|HO|ID|IP|IT|IY|KM|'
|
39
|
+
r'KO|LB|LN|LT|L|MA|MN|M|N|OB|OM|ON|OP|OT|OV|P[BW]|PC|PL|PM|RE|RG|'
|
40
|
+
r'RO|RU|SO|SC|SE|SI|SL|SO|SQ|ST|SU|SZ|T[BW]|TC|TE|TM|TR|UC|US|VW|'
|
41
|
+
r'V|[BW]|C)',
|
42
|
+
Name.Builtin),
|
43
|
+
# number:
|
44
|
+
(r'(\[)([0-9.]+)(\])',
|
45
|
+
bygroups(Punctuation, Literal.Number, Punctuation)),
|
46
|
+
# date:
|
47
|
+
(r'(\[)([0-9]{4}-[0-9]{2}-[0-9]{2})(\])',
|
48
|
+
bygroups(Punctuation, Literal.Date, Punctuation)),
|
49
|
+
# point:
|
50
|
+
(r'(\[)([a-z]{2})(\])',
|
51
|
+
bygroups(Punctuation, String, Punctuation)),
|
52
|
+
# double points:
|
53
|
+
(r'(\[)([a-z]{2})(:)([a-z]{2})(\])',
|
54
|
+
bygroups(Punctuation, String, Punctuation, String, Punctuation)),
|
55
|
+
|
56
|
+
(r'(\[)([\w\s#()+,\-.:?]+)(\])',
|
57
|
+
bygroups(Punctuation, String, Punctuation)),
|
58
|
+
(r'(\[)(\s.*)(\])',
|
59
|
+
bygroups(Punctuation, Text, Punctuation)),
|
60
|
+
],
|
61
|
+
}
|
@@ -0,0 +1,914 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.shell
|
4
|
+
~~~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexers for various shells.
|
7
|
+
|
8
|
+
:copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
|
9
|
+
:license: BSD, see LICENSE for details.
|
10
|
+
"""
|
11
|
+
|
12
|
+
import re
|
13
|
+
|
14
|
+
from pygments.lexer import Lexer, RegexLexer, do_insertions, bygroups, \
|
15
|
+
include, default, this, using, words
|
16
|
+
from pygments.token import Punctuation, \
|
17
|
+
Text, Comment, Operator, Keyword, Name, String, Number, Generic
|
18
|
+
from pygments.util import shebang_matches
|
19
|
+
|
20
|
+
|
21
|
+
__all__ = ['BashLexer', 'BashSessionLexer', 'TcshLexer', 'BatchLexer',
|
22
|
+
'SlurmBashLexer', 'MSDOSSessionLexer', 'PowerShellLexer',
|
23
|
+
'PowerShellSessionLexer', 'TcshSessionLexer', 'FishShellLexer',
|
24
|
+
'ExeclineLexer']
|
25
|
+
|
26
|
+
line_re = re.compile('.*?\n')
|
27
|
+
|
28
|
+
|
29
|
+
class BashLexer(RegexLexer):
|
30
|
+
"""
|
31
|
+
Lexer for (ba|k|z|)sh shell scripts.
|
32
|
+
|
33
|
+
.. versionadded:: 0.6
|
34
|
+
"""
|
35
|
+
|
36
|
+
name = 'Bash'
|
37
|
+
aliases = ['bash', 'sh', 'ksh', 'zsh', 'shell']
|
38
|
+
filenames = ['*.sh', '*.ksh', '*.bash', '*.ebuild', '*.eclass',
|
39
|
+
'*.exheres-0', '*.exlib', '*.zsh',
|
40
|
+
'.bashrc', 'bashrc', '.bash_*', 'bash_*', 'zshrc', '.zshrc',
|
41
|
+
'PKGBUILD']
|
42
|
+
mimetypes = ['application/x-sh', 'application/x-shellscript', 'text/x-shellscript']
|
43
|
+
|
44
|
+
tokens = {
|
45
|
+
'root': [
|
46
|
+
include('basic'),
|
47
|
+
(r'`', String.Backtick, 'backticks'),
|
48
|
+
include('data'),
|
49
|
+
include('interp'),
|
50
|
+
],
|
51
|
+
'interp': [
|
52
|
+
(r'\$\(\(', Keyword, 'math'),
|
53
|
+
(r'\$\(', Keyword, 'paren'),
|
54
|
+
(r'\$\{#?', String.Interpol, 'curly'),
|
55
|
+
(r'\$[a-zA-Z_]\w*', Name.Variable), # user variable
|
56
|
+
(r'\$(?:\d+|[#$?!_*@-])', Name.Variable), # builtin
|
57
|
+
(r'\$', Text),
|
58
|
+
],
|
59
|
+
'basic': [
|
60
|
+
(r'\b(if|fi|else|while|do|done|for|then|return|function|case|'
|
61
|
+
r'select|continue|until|esac|elif)(\s*)\b',
|
62
|
+
bygroups(Keyword, Text)),
|
63
|
+
(r'\b(alias|bg|bind|break|builtin|caller|cd|command|compgen|'
|
64
|
+
r'complete|declare|dirs|disown|echo|enable|eval|exec|exit|'
|
65
|
+
r'export|false|fc|fg|getopts|hash|help|history|jobs|kill|let|'
|
66
|
+
r'local|logout|popd|printf|pushd|pwd|read|readonly|set|shift|'
|
67
|
+
r'shopt|source|suspend|test|time|times|trap|true|type|typeset|'
|
68
|
+
r'ulimit|umask|unalias|unset|wait)(?=[\s)`])',
|
69
|
+
Name.Builtin),
|
70
|
+
(r'\A#!.+\n', Comment.Hashbang),
|
71
|
+
(r'#.*\n', Comment.Single),
|
72
|
+
(r'\\[\w\W]', String.Escape),
|
73
|
+
(r'(\b\w+)(\s*)(\+?=)', bygroups(Name.Variable, Text, Operator)),
|
74
|
+
(r'[\[\]{}()=]', Operator),
|
75
|
+
(r'<<<', Operator), # here-string
|
76
|
+
(r'<<-?\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
|
77
|
+
(r'&&|\|\|', Operator),
|
78
|
+
],
|
79
|
+
'data': [
|
80
|
+
(r'(?s)\$?"(\\.|[^"\\$])*"', String.Double),
|
81
|
+
(r'"', String.Double, 'string'),
|
82
|
+
(r"(?s)\$'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
|
83
|
+
(r"(?s)'.*?'", String.Single),
|
84
|
+
(r';', Punctuation),
|
85
|
+
(r'&', Punctuation),
|
86
|
+
(r'\|', Punctuation),
|
87
|
+
(r'\s+', Text),
|
88
|
+
(r'\d+\b', Number),
|
89
|
+
(r'[^=\s\[\]{}()$"\'`\\<&|;]+', Text),
|
90
|
+
(r'<', Text),
|
91
|
+
],
|
92
|
+
'string': [
|
93
|
+
(r'"', String.Double, '#pop'),
|
94
|
+
(r'(?s)(\\\\|\\[0-7]+|\\.|[^"\\$])+', String.Double),
|
95
|
+
include('interp'),
|
96
|
+
],
|
97
|
+
'curly': [
|
98
|
+
(r'\}', String.Interpol, '#pop'),
|
99
|
+
(r':-', Keyword),
|
100
|
+
(r'\w+', Name.Variable),
|
101
|
+
(r'[^}:"\'`$\\]+', Punctuation),
|
102
|
+
(r':', Punctuation),
|
103
|
+
include('root'),
|
104
|
+
],
|
105
|
+
'paren': [
|
106
|
+
(r'\)', Keyword, '#pop'),
|
107
|
+
include('root'),
|
108
|
+
],
|
109
|
+
'math': [
|
110
|
+
(r'\)\)', Keyword, '#pop'),
|
111
|
+
(r'[-+*/%^|&]|\*\*|\|\|', Operator),
|
112
|
+
(r'\d+#\d+', Number),
|
113
|
+
(r'\d+#(?! )', Number),
|
114
|
+
(r'\d+', Number),
|
115
|
+
include('root'),
|
116
|
+
],
|
117
|
+
'backticks': [
|
118
|
+
(r'`', String.Backtick, '#pop'),
|
119
|
+
include('root'),
|
120
|
+
],
|
121
|
+
}
|
122
|
+
|
123
|
+
def analyse_text(text):
|
124
|
+
if shebang_matches(text, r'(ba|z|)sh'):
|
125
|
+
return 1
|
126
|
+
if text.startswith('$ '):
|
127
|
+
return 0.2
|
128
|
+
|
129
|
+
|
130
|
+
class SlurmBashLexer(BashLexer):
|
131
|
+
"""
|
132
|
+
Lexer for (ba|k|z|)sh Slurm scripts.
|
133
|
+
|
134
|
+
.. versionadded:: 2.4
|
135
|
+
"""
|
136
|
+
|
137
|
+
name = 'Slurm'
|
138
|
+
aliases = ['slurm', 'sbatch']
|
139
|
+
filenames = ['*.sl']
|
140
|
+
mimetypes = []
|
141
|
+
EXTRA_KEYWORDS = {'srun'}
|
142
|
+
|
143
|
+
def get_tokens_unprocessed(self, text):
|
144
|
+
for index, token, value in BashLexer.get_tokens_unprocessed(self, text):
|
145
|
+
if token is Text and value in self.EXTRA_KEYWORDS:
|
146
|
+
yield index, Name.Builtin, value
|
147
|
+
elif token is Comment.Single and 'SBATCH' in value:
|
148
|
+
yield index, Keyword.Pseudo, value
|
149
|
+
else:
|
150
|
+
yield index, token, value
|
151
|
+
|
152
|
+
|
153
|
+
class ShellSessionBaseLexer(Lexer):
|
154
|
+
"""
|
155
|
+
Base lexer for shell sessions.
|
156
|
+
|
157
|
+
.. versionadded:: 2.1
|
158
|
+
"""
|
159
|
+
|
160
|
+
_venv = re.compile(r'^(\([^)]*\))(\s*)')
|
161
|
+
|
162
|
+
def get_tokens_unprocessed(self, text):
|
163
|
+
innerlexer = self._innerLexerCls(**self.options)
|
164
|
+
|
165
|
+
pos = 0
|
166
|
+
curcode = ''
|
167
|
+
insertions = []
|
168
|
+
backslash_continuation = False
|
169
|
+
|
170
|
+
for match in line_re.finditer(text):
|
171
|
+
line = match.group()
|
172
|
+
if backslash_continuation:
|
173
|
+
curcode += line
|
174
|
+
backslash_continuation = curcode.endswith('\\\n')
|
175
|
+
continue
|
176
|
+
|
177
|
+
venv_match = self._venv.match(line)
|
178
|
+
if venv_match:
|
179
|
+
venv = venv_match.group(1)
|
180
|
+
venv_whitespace = venv_match.group(2)
|
181
|
+
insertions.append((len(curcode),
|
182
|
+
[(0, Generic.Prompt.VirtualEnv, venv)]))
|
183
|
+
if venv_whitespace:
|
184
|
+
insertions.append((len(curcode),
|
185
|
+
[(0, Text, venv_whitespace)]))
|
186
|
+
line = line[venv_match.end():]
|
187
|
+
|
188
|
+
m = self._ps1rgx.match(line)
|
189
|
+
if m:
|
190
|
+
# To support output lexers (say diff output), the output
|
191
|
+
# needs to be broken by prompts whenever the output lexer
|
192
|
+
# changes.
|
193
|
+
if not insertions:
|
194
|
+
pos = match.start()
|
195
|
+
|
196
|
+
insertions.append((len(curcode),
|
197
|
+
[(0, Generic.Prompt, m.group(1))]))
|
198
|
+
curcode += m.group(2)
|
199
|
+
backslash_continuation = curcode.endswith('\\\n')
|
200
|
+
elif line.startswith(self._ps2):
|
201
|
+
insertions.append((len(curcode),
|
202
|
+
[(0, Generic.Prompt, line[:len(self._ps2)])]))
|
203
|
+
curcode += line[len(self._ps2):]
|
204
|
+
backslash_continuation = curcode.endswith('\\\n')
|
205
|
+
else:
|
206
|
+
if insertions:
|
207
|
+
toks = innerlexer.get_tokens_unprocessed(curcode)
|
208
|
+
for i, t, v in do_insertions(insertions, toks):
|
209
|
+
yield pos+i, t, v
|
210
|
+
yield match.start(), Generic.Output, line
|
211
|
+
insertions = []
|
212
|
+
curcode = ''
|
213
|
+
if insertions:
|
214
|
+
for i, t, v in do_insertions(insertions,
|
215
|
+
innerlexer.get_tokens_unprocessed(curcode)):
|
216
|
+
yield pos+i, t, v
|
217
|
+
|
218
|
+
|
219
|
+
class BashSessionLexer(ShellSessionBaseLexer):
|
220
|
+
"""
|
221
|
+
Lexer for Bash shell sessions, i.e. command lines, including a
|
222
|
+
prompt, interspersed with output.
|
223
|
+
|
224
|
+
.. versionadded:: 1.1
|
225
|
+
"""
|
226
|
+
|
227
|
+
name = 'Bash Session'
|
228
|
+
aliases = ['console', 'shell-session']
|
229
|
+
filenames = ['*.sh-session', '*.shell-session']
|
230
|
+
mimetypes = ['application/x-shell-session', 'application/x-sh-session']
|
231
|
+
|
232
|
+
_innerLexerCls = BashLexer
|
233
|
+
_ps1rgx = re.compile(
|
234
|
+
r'^((?:(?:\[.*?\])|(?:\(\S+\))?(?:| |sh\S*?|\w+\S+[@:]\S+(?:\s+\S+)' \
|
235
|
+
r'?|\[\S+[@:][^\n]+\].+))\s*[$#%])(.*\n?)')
|
236
|
+
_ps2 = '>'
|
237
|
+
|
238
|
+
|
239
|
+
class BatchLexer(RegexLexer):
|
240
|
+
"""
|
241
|
+
Lexer for the DOS/Windows Batch file format.
|
242
|
+
|
243
|
+
.. versionadded:: 0.7
|
244
|
+
"""
|
245
|
+
name = 'Batchfile'
|
246
|
+
aliases = ['bat', 'batch', 'dosbatch', 'winbatch']
|
247
|
+
filenames = ['*.bat', '*.cmd']
|
248
|
+
mimetypes = ['application/x-dos-batch']
|
249
|
+
|
250
|
+
flags = re.MULTILINE | re.IGNORECASE
|
251
|
+
|
252
|
+
_nl = r'\n\x1a'
|
253
|
+
_punct = r'&<>|'
|
254
|
+
_ws = r'\t\v\f\r ,;=\xa0'
|
255
|
+
_nlws = r'\s\x1a\xa0,;='
|
256
|
+
_space = r'(?:(?:(?:\^[%s])?[%s])+)' % (_nl, _ws)
|
257
|
+
_keyword_terminator = (r'(?=(?:\^[%s]?)?[%s+./:[\\\]]|[%s%s(])' %
|
258
|
+
(_nl, _ws, _nl, _punct))
|
259
|
+
_token_terminator = r'(?=\^?[%s]|[%s%s])' % (_ws, _punct, _nl)
|
260
|
+
_start_label = r'((?:(?<=^[^:])|^[^:]?)[%s]*)(:)' % _ws
|
261
|
+
_label = r'(?:(?:[^%s%s+:^]|\^[%s]?[\w\W])*)' % (_nlws, _punct, _nl)
|
262
|
+
_label_compound = r'(?:(?:[^%s%s+:^)]|\^[%s]?[^)])*)' % (_nlws, _punct, _nl)
|
263
|
+
_number = r'(?:-?(?:0[0-7]+|0x[\da-f]+|\d+)%s)' % _token_terminator
|
264
|
+
_opword = r'(?:equ|geq|gtr|leq|lss|neq)'
|
265
|
+
_string = r'(?:"[^%s"]*(?:"|(?=[%s])))' % (_nl, _nl)
|
266
|
+
_variable = (r'(?:(?:%%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|'
|
267
|
+
r'[^%%:%s]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%%%s^]|'
|
268
|
+
r'\^[^%%%s])[^=%s]*=(?:[^%%%s^]|\^[^%%%s])*)?)?%%))|'
|
269
|
+
r'(?:\^?![^!:%s]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:'
|
270
|
+
r'[^!%s^]|\^[^!%s])[^=%s]*=(?:[^!%s^]|\^[^!%s])*)?)?\^?!))' %
|
271
|
+
(_nl, _nl, _nl, _nl, _nl, _nl, _nl, _nl, _nl, _nl, _nl, _nl))
|
272
|
+
_core_token = r'(?:(?:(?:\^[%s]?)?[^"%s%s])+)' % (_nl, _nlws, _punct)
|
273
|
+
_core_token_compound = r'(?:(?:(?:\^[%s]?)?[^"%s%s)])+)' % (_nl, _nlws, _punct)
|
274
|
+
_token = r'(?:[%s]+|%s)' % (_punct, _core_token)
|
275
|
+
_token_compound = r'(?:[%s]+|%s)' % (_punct, _core_token_compound)
|
276
|
+
_stoken = (r'(?:[%s]+|(?:%s|%s|%s)+)' %
|
277
|
+
(_punct, _string, _variable, _core_token))
|
278
|
+
|
279
|
+
def _make_begin_state(compound, _core_token=_core_token,
|
280
|
+
_core_token_compound=_core_token_compound,
|
281
|
+
_keyword_terminator=_keyword_terminator,
|
282
|
+
_nl=_nl, _punct=_punct, _string=_string,
|
283
|
+
_space=_space, _start_label=_start_label,
|
284
|
+
_stoken=_stoken, _token_terminator=_token_terminator,
|
285
|
+
_variable=_variable, _ws=_ws):
|
286
|
+
rest = '(?:%s|%s|[^"%%%s%s%s])*' % (_string, _variable, _nl, _punct,
|
287
|
+
')' if compound else '')
|
288
|
+
rest_of_line = r'(?:(?:[^%s^]|\^[%s]?[\w\W])*)' % (_nl, _nl)
|
289
|
+
rest_of_line_compound = r'(?:(?:[^%s^)]|\^[%s]?[^)])*)' % (_nl, _nl)
|
290
|
+
set_space = r'((?:(?:\^[%s]?)?[^\S\n])*)' % _nl
|
291
|
+
suffix = ''
|
292
|
+
if compound:
|
293
|
+
_keyword_terminator = r'(?:(?=\))|%s)' % _keyword_terminator
|
294
|
+
_token_terminator = r'(?:(?=\))|%s)' % _token_terminator
|
295
|
+
suffix = '/compound'
|
296
|
+
return [
|
297
|
+
((r'\)', Punctuation, '#pop') if compound else
|
298
|
+
(r'\)((?=\()|%s)%s' % (_token_terminator, rest_of_line),
|
299
|
+
Comment.Single)),
|
300
|
+
(r'(?=%s)' % _start_label, Text, 'follow%s' % suffix),
|
301
|
+
(_space, using(this, state='text')),
|
302
|
+
include('redirect%s' % suffix),
|
303
|
+
(r'[%s]+' % _nl, Text),
|
304
|
+
(r'\(', Punctuation, 'root/compound'),
|
305
|
+
(r'@+', Punctuation),
|
306
|
+
(r'((?:for|if|rem)(?:(?=(?:\^[%s]?)?/)|(?:(?!\^)|'
|
307
|
+
r'(?<=m))(?:(?=\()|%s)))(%s?%s?(?:\^[%s]?)?/(?:\^[%s]?)?\?)' %
|
308
|
+
(_nl, _token_terminator, _space,
|
309
|
+
_core_token_compound if compound else _core_token, _nl, _nl),
|
310
|
+
bygroups(Keyword, using(this, state='text')),
|
311
|
+
'follow%s' % suffix),
|
312
|
+
(r'(goto%s)(%s(?:\^[%s]?)?/(?:\^[%s]?)?\?%s)' %
|
313
|
+
(_keyword_terminator, rest, _nl, _nl, rest),
|
314
|
+
bygroups(Keyword, using(this, state='text')),
|
315
|
+
'follow%s' % suffix),
|
316
|
+
(words(('assoc', 'break', 'cd', 'chdir', 'cls', 'color', 'copy',
|
317
|
+
'date', 'del', 'dir', 'dpath', 'echo', 'endlocal', 'erase',
|
318
|
+
'exit', 'ftype', 'keys', 'md', 'mkdir', 'mklink', 'move',
|
319
|
+
'path', 'pause', 'popd', 'prompt', 'pushd', 'rd', 'ren',
|
320
|
+
'rename', 'rmdir', 'setlocal', 'shift', 'start', 'time',
|
321
|
+
'title', 'type', 'ver', 'verify', 'vol'),
|
322
|
+
suffix=_keyword_terminator), Keyword, 'follow%s' % suffix),
|
323
|
+
(r'(call)(%s?)(:)' % _space,
|
324
|
+
bygroups(Keyword, using(this, state='text'), Punctuation),
|
325
|
+
'call%s' % suffix),
|
326
|
+
(r'call%s' % _keyword_terminator, Keyword),
|
327
|
+
(r'(for%s(?!\^))(%s)(/f%s)' %
|
328
|
+
(_token_terminator, _space, _token_terminator),
|
329
|
+
bygroups(Keyword, using(this, state='text'), Keyword),
|
330
|
+
('for/f', 'for')),
|
331
|
+
(r'(for%s(?!\^))(%s)(/l%s)' %
|
332
|
+
(_token_terminator, _space, _token_terminator),
|
333
|
+
bygroups(Keyword, using(this, state='text'), Keyword),
|
334
|
+
('for/l', 'for')),
|
335
|
+
(r'for%s(?!\^)' % _token_terminator, Keyword, ('for2', 'for')),
|
336
|
+
(r'(goto%s)(%s?)(:?)' % (_keyword_terminator, _space),
|
337
|
+
bygroups(Keyword, using(this, state='text'), Punctuation),
|
338
|
+
'label%s' % suffix),
|
339
|
+
(r'(if(?:(?=\()|%s)(?!\^))(%s?)((?:/i%s)?)(%s?)((?:not%s)?)(%s?)' %
|
340
|
+
(_token_terminator, _space, _token_terminator, _space,
|
341
|
+
_token_terminator, _space),
|
342
|
+
bygroups(Keyword, using(this, state='text'), Keyword,
|
343
|
+
using(this, state='text'), Keyword,
|
344
|
+
using(this, state='text')), ('(?', 'if')),
|
345
|
+
(r'rem(((?=\()|%s)%s?%s?.*|%s%s)' %
|
346
|
+
(_token_terminator, _space, _stoken, _keyword_terminator,
|
347
|
+
rest_of_line_compound if compound else rest_of_line),
|
348
|
+
Comment.Single, 'follow%s' % suffix),
|
349
|
+
(r'(set%s)%s(/a)' % (_keyword_terminator, set_space),
|
350
|
+
bygroups(Keyword, using(this, state='text'), Keyword),
|
351
|
+
'arithmetic%s' % suffix),
|
352
|
+
(r'(set%s)%s((?:/p)?)%s((?:(?:(?:\^[%s]?)?[^"%s%s^=%s]|'
|
353
|
+
r'\^[%s]?[^"=])+)?)((?:(?:\^[%s]?)?=)?)' %
|
354
|
+
(_keyword_terminator, set_space, set_space, _nl, _nl, _punct,
|
355
|
+
')' if compound else '', _nl, _nl),
|
356
|
+
bygroups(Keyword, using(this, state='text'), Keyword,
|
357
|
+
using(this, state='text'), using(this, state='variable'),
|
358
|
+
Punctuation),
|
359
|
+
'follow%s' % suffix),
|
360
|
+
default('follow%s' % suffix)
|
361
|
+
]
|
362
|
+
|
363
|
+
def _make_follow_state(compound, _label=_label,
|
364
|
+
_label_compound=_label_compound, _nl=_nl,
|
365
|
+
_space=_space, _start_label=_start_label,
|
366
|
+
_token=_token, _token_compound=_token_compound,
|
367
|
+
_ws=_ws):
|
368
|
+
suffix = '/compound' if compound else ''
|
369
|
+
state = []
|
370
|
+
if compound:
|
371
|
+
state.append((r'(?=\))', Text, '#pop'))
|
372
|
+
state += [
|
373
|
+
(r'%s([%s]*)(%s)(.*)' %
|
374
|
+
(_start_label, _ws, _label_compound if compound else _label),
|
375
|
+
bygroups(Text, Punctuation, Text, Name.Label, Comment.Single)),
|
376
|
+
include('redirect%s' % suffix),
|
377
|
+
(r'(?=[%s])' % _nl, Text, '#pop'),
|
378
|
+
(r'\|\|?|&&?', Punctuation, '#pop'),
|
379
|
+
include('text')
|
380
|
+
]
|
381
|
+
return state
|
382
|
+
|
383
|
+
def _make_arithmetic_state(compound, _nl=_nl, _punct=_punct,
|
384
|
+
_string=_string, _variable=_variable,
|
385
|
+
_ws=_ws, _nlws=_nlws):
|
386
|
+
op = r'=+\-*/!~'
|
387
|
+
state = []
|
388
|
+
if compound:
|
389
|
+
state.append((r'(?=\))', Text, '#pop'))
|
390
|
+
state += [
|
391
|
+
(r'0[0-7]+', Number.Oct),
|
392
|
+
(r'0x[\da-f]+', Number.Hex),
|
393
|
+
(r'\d+', Number.Integer),
|
394
|
+
(r'[(),]+', Punctuation),
|
395
|
+
(r'([%s]|%%|\^\^)+' % op, Operator),
|
396
|
+
(r'(%s|%s|(\^[%s]?)?[^()%s%%\^"%s%s]|\^[%s]?%s)+' %
|
397
|
+
(_string, _variable, _nl, op, _nlws, _punct, _nlws,
|
398
|
+
r'[^)]' if compound else r'[\w\W]'),
|
399
|
+
using(this, state='variable')),
|
400
|
+
(r'(?=[\x00|&])', Text, '#pop'),
|
401
|
+
include('follow')
|
402
|
+
]
|
403
|
+
return state
|
404
|
+
|
405
|
+
def _make_call_state(compound, _label=_label,
|
406
|
+
_label_compound=_label_compound):
|
407
|
+
state = []
|
408
|
+
if compound:
|
409
|
+
state.append((r'(?=\))', Text, '#pop'))
|
410
|
+
state.append((r'(:?)(%s)' % (_label_compound if compound else _label),
|
411
|
+
bygroups(Punctuation, Name.Label), '#pop'))
|
412
|
+
return state
|
413
|
+
|
414
|
+
def _make_label_state(compound, _label=_label,
|
415
|
+
_label_compound=_label_compound, _nl=_nl,
|
416
|
+
_punct=_punct, _string=_string, _variable=_variable):
|
417
|
+
state = []
|
418
|
+
if compound:
|
419
|
+
state.append((r'(?=\))', Text, '#pop'))
|
420
|
+
state.append((r'(%s?)((?:%s|%s|\^[%s]?%s|[^"%%^%s%s%s])*)' %
|
421
|
+
(_label_compound if compound else _label, _string,
|
422
|
+
_variable, _nl, r'[^)]' if compound else r'[\w\W]', _nl,
|
423
|
+
_punct, r')' if compound else ''),
|
424
|
+
bygroups(Name.Label, Comment.Single), '#pop'))
|
425
|
+
return state
|
426
|
+
|
427
|
+
def _make_redirect_state(compound,
|
428
|
+
_core_token_compound=_core_token_compound,
|
429
|
+
_nl=_nl, _punct=_punct, _stoken=_stoken,
|
430
|
+
_string=_string, _space=_space,
|
431
|
+
_variable=_variable, _nlws=_nlws):
|
432
|
+
stoken_compound = (r'(?:[%s]+|(?:%s|%s|%s)+)' %
|
433
|
+
(_punct, _string, _variable, _core_token_compound))
|
434
|
+
return [
|
435
|
+
(r'((?:(?<=[%s])\d)?)(>>?&|<&)([%s]*)(\d)' %
|
436
|
+
(_nlws, _nlws),
|
437
|
+
bygroups(Number.Integer, Punctuation, Text, Number.Integer)),
|
438
|
+
(r'((?:(?<=[%s])(?<!\^[%s])\d)?)(>>?|<)(%s?%s)' %
|
439
|
+
(_nlws, _nl, _space, stoken_compound if compound else _stoken),
|
440
|
+
bygroups(Number.Integer, Punctuation, using(this, state='text')))
|
441
|
+
]
|
442
|
+
|
443
|
+
tokens = {
|
444
|
+
'root': _make_begin_state(False),
|
445
|
+
'follow': _make_follow_state(False),
|
446
|
+
'arithmetic': _make_arithmetic_state(False),
|
447
|
+
'call': _make_call_state(False),
|
448
|
+
'label': _make_label_state(False),
|
449
|
+
'redirect': _make_redirect_state(False),
|
450
|
+
'root/compound': _make_begin_state(True),
|
451
|
+
'follow/compound': _make_follow_state(True),
|
452
|
+
'arithmetic/compound': _make_arithmetic_state(True),
|
453
|
+
'call/compound': _make_call_state(True),
|
454
|
+
'label/compound': _make_label_state(True),
|
455
|
+
'redirect/compound': _make_redirect_state(True),
|
456
|
+
'variable-or-escape': [
|
457
|
+
(_variable, Name.Variable),
|
458
|
+
(r'%%%%|\^[%s]?(\^!|[\w\W])' % _nl, String.Escape)
|
459
|
+
],
|
460
|
+
'string': [
|
461
|
+
(r'"', String.Double, '#pop'),
|
462
|
+
(_variable, Name.Variable),
|
463
|
+
(r'\^!|%%', String.Escape),
|
464
|
+
(r'[^"%%^%s]+|[%%^]' % _nl, String.Double),
|
465
|
+
default('#pop')
|
466
|
+
],
|
467
|
+
'sqstring': [
|
468
|
+
include('variable-or-escape'),
|
469
|
+
(r'[^%]+|%', String.Single)
|
470
|
+
],
|
471
|
+
'bqstring': [
|
472
|
+
include('variable-or-escape'),
|
473
|
+
(r'[^%]+|%', String.Backtick)
|
474
|
+
],
|
475
|
+
'text': [
|
476
|
+
(r'"', String.Double, 'string'),
|
477
|
+
include('variable-or-escape'),
|
478
|
+
(r'[^"%%^%s%s\d)]+|.' % (_nlws, _punct), Text)
|
479
|
+
],
|
480
|
+
'variable': [
|
481
|
+
(r'"', String.Double, 'string'),
|
482
|
+
include('variable-or-escape'),
|
483
|
+
(r'[^"%%^%s]+|.' % _nl, Name.Variable)
|
484
|
+
],
|
485
|
+
'for': [
|
486
|
+
(r'(%s)(in)(%s)(\()' % (_space, _space),
|
487
|
+
bygroups(using(this, state='text'), Keyword,
|
488
|
+
using(this, state='text'), Punctuation), '#pop'),
|
489
|
+
include('follow')
|
490
|
+
],
|
491
|
+
'for2': [
|
492
|
+
(r'\)', Punctuation),
|
493
|
+
(r'(%s)(do%s)' % (_space, _token_terminator),
|
494
|
+
bygroups(using(this, state='text'), Keyword), '#pop'),
|
495
|
+
(r'[%s]+' % _nl, Text),
|
496
|
+
include('follow')
|
497
|
+
],
|
498
|
+
'for/f': [
|
499
|
+
(r'(")((?:%s|[^"])*?")([%s]*)(\))' % (_variable, _nlws),
|
500
|
+
bygroups(String.Double, using(this, state='string'), Text,
|
501
|
+
Punctuation)),
|
502
|
+
(r'"', String.Double, ('#pop', 'for2', 'string')),
|
503
|
+
(r"('(?:%%%%|%s|[\w\W])*?')([%s]*)(\))" % (_variable, _nlws),
|
504
|
+
bygroups(using(this, state='sqstring'), Text, Punctuation)),
|
505
|
+
(r'(`(?:%%%%|%s|[\w\W])*?`)([%s]*)(\))' % (_variable, _nlws),
|
506
|
+
bygroups(using(this, state='bqstring'), Text, Punctuation)),
|
507
|
+
include('for2')
|
508
|
+
],
|
509
|
+
'for/l': [
|
510
|
+
(r'-?\d+', Number.Integer),
|
511
|
+
include('for2')
|
512
|
+
],
|
513
|
+
'if': [
|
514
|
+
(r'((?:cmdextversion|errorlevel)%s)(%s)(\d+)' %
|
515
|
+
(_token_terminator, _space),
|
516
|
+
bygroups(Keyword, using(this, state='text'),
|
517
|
+
Number.Integer), '#pop'),
|
518
|
+
(r'(defined%s)(%s)(%s)' % (_token_terminator, _space, _stoken),
|
519
|
+
bygroups(Keyword, using(this, state='text'),
|
520
|
+
using(this, state='variable')), '#pop'),
|
521
|
+
(r'(exist%s)(%s%s)' % (_token_terminator, _space, _stoken),
|
522
|
+
bygroups(Keyword, using(this, state='text')), '#pop'),
|
523
|
+
(r'(%s%s)(%s)(%s%s)' % (_number, _space, _opword, _space, _number),
|
524
|
+
bygroups(using(this, state='arithmetic'), Operator.Word,
|
525
|
+
using(this, state='arithmetic')), '#pop'),
|
526
|
+
(_stoken, using(this, state='text'), ('#pop', 'if2')),
|
527
|
+
],
|
528
|
+
'if2': [
|
529
|
+
(r'(%s?)(==)(%s?%s)' % (_space, _space, _stoken),
|
530
|
+
bygroups(using(this, state='text'), Operator,
|
531
|
+
using(this, state='text')), '#pop'),
|
532
|
+
(r'(%s)(%s)(%s%s)' % (_space, _opword, _space, _stoken),
|
533
|
+
bygroups(using(this, state='text'), Operator.Word,
|
534
|
+
using(this, state='text')), '#pop')
|
535
|
+
],
|
536
|
+
'(?': [
|
537
|
+
(_space, using(this, state='text')),
|
538
|
+
(r'\(', Punctuation, ('#pop', 'else?', 'root/compound')),
|
539
|
+
default('#pop')
|
540
|
+
],
|
541
|
+
'else?': [
|
542
|
+
(_space, using(this, state='text')),
|
543
|
+
(r'else%s' % _token_terminator, Keyword, '#pop'),
|
544
|
+
default('#pop')
|
545
|
+
]
|
546
|
+
}
|
547
|
+
|
548
|
+
|
549
|
+
class MSDOSSessionLexer(ShellSessionBaseLexer):
|
550
|
+
"""
|
551
|
+
Lexer for MS DOS shell sessions, i.e. command lines, including a
|
552
|
+
prompt, interspersed with output.
|
553
|
+
|
554
|
+
.. versionadded:: 2.1
|
555
|
+
"""
|
556
|
+
|
557
|
+
name = 'MSDOS Session'
|
558
|
+
aliases = ['doscon']
|
559
|
+
filenames = []
|
560
|
+
mimetypes = []
|
561
|
+
|
562
|
+
_innerLexerCls = BatchLexer
|
563
|
+
_ps1rgx = re.compile(r'^([^>]*>)(.*\n?)')
|
564
|
+
_ps2 = 'More? '
|
565
|
+
|
566
|
+
|
567
|
+
class TcshLexer(RegexLexer):
|
568
|
+
"""
|
569
|
+
Lexer for tcsh scripts.
|
570
|
+
|
571
|
+
.. versionadded:: 0.10
|
572
|
+
"""
|
573
|
+
|
574
|
+
name = 'Tcsh'
|
575
|
+
aliases = ['tcsh', 'csh']
|
576
|
+
filenames = ['*.tcsh', '*.csh']
|
577
|
+
mimetypes = ['application/x-csh']
|
578
|
+
|
579
|
+
tokens = {
|
580
|
+
'root': [
|
581
|
+
include('basic'),
|
582
|
+
(r'\$\(', Keyword, 'paren'),
|
583
|
+
(r'\$\{#?', Keyword, 'curly'),
|
584
|
+
(r'`', String.Backtick, 'backticks'),
|
585
|
+
include('data'),
|
586
|
+
],
|
587
|
+
'basic': [
|
588
|
+
(r'\b(if|endif|else|while|then|foreach|case|default|'
|
589
|
+
r'continue|goto|breaksw|end|switch|endsw)\s*\b',
|
590
|
+
Keyword),
|
591
|
+
(r'\b(alias|alloc|bg|bindkey|break|builtins|bye|caller|cd|chdir|'
|
592
|
+
r'complete|dirs|echo|echotc|eval|exec|exit|fg|filetest|getxvers|'
|
593
|
+
r'glob|getspath|hashstat|history|hup|inlib|jobs|kill|'
|
594
|
+
r'limit|log|login|logout|ls-F|migrate|newgrp|nice|nohup|notify|'
|
595
|
+
r'onintr|popd|printenv|pushd|rehash|repeat|rootnode|popd|pushd|'
|
596
|
+
r'set|shift|sched|setenv|setpath|settc|setty|setxvers|shift|'
|
597
|
+
r'source|stop|suspend|source|suspend|telltc|time|'
|
598
|
+
r'umask|unalias|uncomplete|unhash|universe|unlimit|unset|unsetenv|'
|
599
|
+
r'ver|wait|warp|watchlog|where|which)\s*\b',
|
600
|
+
Name.Builtin),
|
601
|
+
(r'#.*', Comment),
|
602
|
+
(r'\\[\w\W]', String.Escape),
|
603
|
+
(r'(\b\w+)(\s*)(=)', bygroups(Name.Variable, Text, Operator)),
|
604
|
+
(r'[\[\]{}()=]+', Operator),
|
605
|
+
(r'<<\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
|
606
|
+
(r';', Punctuation),
|
607
|
+
],
|
608
|
+
'data': [
|
609
|
+
(r'(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double),
|
610
|
+
(r"(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
|
611
|
+
(r'\s+', Text),
|
612
|
+
(r'[^=\s\[\]{}()$"\'`\\;#]+', Text),
|
613
|
+
(r'\d+(?= |\Z)', Number),
|
614
|
+
(r'\$#?(\w+|.)', Name.Variable),
|
615
|
+
],
|
616
|
+
'curly': [
|
617
|
+
(r'\}', Keyword, '#pop'),
|
618
|
+
(r':-', Keyword),
|
619
|
+
(r'\w+', Name.Variable),
|
620
|
+
(r'[^}:"\'`$]+', Punctuation),
|
621
|
+
(r':', Punctuation),
|
622
|
+
include('root'),
|
623
|
+
],
|
624
|
+
'paren': [
|
625
|
+
(r'\)', Keyword, '#pop'),
|
626
|
+
include('root'),
|
627
|
+
],
|
628
|
+
'backticks': [
|
629
|
+
(r'`', String.Backtick, '#pop'),
|
630
|
+
include('root'),
|
631
|
+
],
|
632
|
+
}
|
633
|
+
|
634
|
+
|
635
|
+
class TcshSessionLexer(ShellSessionBaseLexer):
|
636
|
+
"""
|
637
|
+
Lexer for Tcsh sessions, i.e. command lines, including a
|
638
|
+
prompt, interspersed with output.
|
639
|
+
|
640
|
+
.. versionadded:: 2.1
|
641
|
+
"""
|
642
|
+
|
643
|
+
name = 'Tcsh Session'
|
644
|
+
aliases = ['tcshcon']
|
645
|
+
filenames = []
|
646
|
+
mimetypes = []
|
647
|
+
|
648
|
+
_innerLexerCls = TcshLexer
|
649
|
+
_ps1rgx = re.compile(r'^([^>]+>)(.*\n?)')
|
650
|
+
_ps2 = '? '
|
651
|
+
|
652
|
+
|
653
|
+
class PowerShellLexer(RegexLexer):
|
654
|
+
"""
|
655
|
+
For Windows PowerShell code.
|
656
|
+
|
657
|
+
.. versionadded:: 1.5
|
658
|
+
"""
|
659
|
+
name = 'PowerShell'
|
660
|
+
aliases = ['powershell', 'posh', 'ps1', 'psm1']
|
661
|
+
filenames = ['*.ps1', '*.psm1']
|
662
|
+
mimetypes = ['text/x-powershell']
|
663
|
+
|
664
|
+
flags = re.DOTALL | re.IGNORECASE | re.MULTILINE
|
665
|
+
|
666
|
+
keywords = (
|
667
|
+
'while validateset validaterange validatepattern validatelength '
|
668
|
+
'validatecount until trap switch return ref process param parameter in '
|
669
|
+
'if global: function foreach for finally filter end elseif else '
|
670
|
+
'dynamicparam do default continue cmdletbinding break begin alias \\? '
|
671
|
+
'% #script #private #local #global mandatory parametersetname position '
|
672
|
+
'valuefrompipeline valuefrompipelinebypropertyname '
|
673
|
+
'valuefromremainingarguments helpmessage try catch throw').split()
|
674
|
+
|
675
|
+
operators = (
|
676
|
+
'and as band bnot bor bxor casesensitive ccontains ceq cge cgt cle '
|
677
|
+
'clike clt cmatch cne cnotcontains cnotlike cnotmatch contains '
|
678
|
+
'creplace eq exact f file ge gt icontains ieq ige igt ile ilike ilt '
|
679
|
+
'imatch ine inotcontains inotlike inotmatch ireplace is isnot le like '
|
680
|
+
'lt match ne not notcontains notlike notmatch or regex replace '
|
681
|
+
'wildcard').split()
|
682
|
+
|
683
|
+
verbs = (
|
684
|
+
'write where watch wait use update unregister unpublish unprotect '
|
685
|
+
'unlock uninstall undo unblock trace test tee take sync switch '
|
686
|
+
'suspend submit stop step start split sort skip show set send select '
|
687
|
+
'search scroll save revoke resume restore restart resolve resize '
|
688
|
+
'reset request repair rename remove register redo receive read push '
|
689
|
+
'publish protect pop ping out optimize open new move mount merge '
|
690
|
+
'measure lock limit join invoke install initialize import hide group '
|
691
|
+
'grant get format foreach find export expand exit enter enable edit '
|
692
|
+
'dismount disconnect disable deny debug cxnew copy convertto '
|
693
|
+
'convertfrom convert connect confirm compress complete compare close '
|
694
|
+
'clear checkpoint block backup assert approve aggregate add').split()
|
695
|
+
|
696
|
+
aliases_ = (
|
697
|
+
'ac asnp cat cd cfs chdir clc clear clhy cli clp cls clv cnsn '
|
698
|
+
'compare copy cp cpi cpp curl cvpa dbp del diff dir dnsn ebp echo epal '
|
699
|
+
'epcsv epsn erase etsn exsn fc fhx fl foreach ft fw gal gbp gc gci gcm '
|
700
|
+
'gcs gdr ghy gi gjb gl gm gmo gp gps gpv group gsn gsnp gsv gu gv gwmi '
|
701
|
+
'h history icm iex ihy ii ipal ipcsv ipmo ipsn irm ise iwmi iwr kill lp '
|
702
|
+
'ls man md measure mi mount move mp mv nal ndr ni nmo npssc nsn nv ogv '
|
703
|
+
'oh popd ps pushd pwd r rbp rcjb rcsn rd rdr ren ri rjb rm rmdir rmo '
|
704
|
+
'rni rnp rp rsn rsnp rujb rv rvpa rwmi sajb sal saps sasv sbp sc select '
|
705
|
+
'set shcm si sl sleep sls sort sp spjb spps spsv start sujb sv swmi tee '
|
706
|
+
'trcm type wget where wjb write').split()
|
707
|
+
|
708
|
+
commenthelp = (
|
709
|
+
'component description example externalhelp forwardhelpcategory '
|
710
|
+
'forwardhelptargetname functionality inputs link '
|
711
|
+
'notes outputs parameter remotehelprunspace role synopsis').split()
|
712
|
+
|
713
|
+
tokens = {
|
714
|
+
'root': [
|
715
|
+
# we need to count pairs of parentheses for correct highlight
|
716
|
+
# of '$(...)' blocks in strings
|
717
|
+
(r'\(', Punctuation, 'child'),
|
718
|
+
(r'\s+', Text),
|
719
|
+
(r'^(\s*#[#\s]*)(\.(?:%s))([^\n]*$)' % '|'.join(commenthelp),
|
720
|
+
bygroups(Comment, String.Doc, Comment)),
|
721
|
+
(r'#[^\n]*?$', Comment),
|
722
|
+
(r'(<|<)#', Comment.Multiline, 'multline'),
|
723
|
+
(r'@"\n', String.Heredoc, 'heredoc-double'),
|
724
|
+
(r"@'\n.*?\n'@", String.Heredoc),
|
725
|
+
# escaped syntax
|
726
|
+
(r'`[\'"$@-]', Punctuation),
|
727
|
+
(r'"', String.Double, 'string'),
|
728
|
+
(r"'([^']|'')*'", String.Single),
|
729
|
+
(r'(\$|@@|@)((global|script|private|env):)?\w+',
|
730
|
+
Name.Variable),
|
731
|
+
(r'(%s)\b' % '|'.join(keywords), Keyword),
|
732
|
+
(r'-(%s)\b' % '|'.join(operators), Operator),
|
733
|
+
(r'(%s)-[a-z_]\w*\b' % '|'.join(verbs), Name.Builtin),
|
734
|
+
(r'(%s)\s' % '|'.join(aliases_), Name.Builtin),
|
735
|
+
(r'\[[a-z_\[][\w. `,\[\]]*\]', Name.Constant), # .net [type]s
|
736
|
+
(r'-[a-z_]\w*', Name),
|
737
|
+
(r'\w+', Name),
|
738
|
+
(r'[.,;@{}\[\]$()=+*/\\&%!~?^`|<>-]|::', Punctuation),
|
739
|
+
],
|
740
|
+
'child': [
|
741
|
+
(r'\)', Punctuation, '#pop'),
|
742
|
+
include('root'),
|
743
|
+
],
|
744
|
+
'multline': [
|
745
|
+
(r'[^#&.]+', Comment.Multiline),
|
746
|
+
(r'#(>|>)', Comment.Multiline, '#pop'),
|
747
|
+
(r'\.(%s)' % '|'.join(commenthelp), String.Doc),
|
748
|
+
(r'[#&.]', Comment.Multiline),
|
749
|
+
],
|
750
|
+
'string': [
|
751
|
+
(r"`[0abfnrtv'\"$`]", String.Escape),
|
752
|
+
(r'[^$`"]+', String.Double),
|
753
|
+
(r'\$\(', Punctuation, 'child'),
|
754
|
+
(r'""', String.Double),
|
755
|
+
(r'[`$]', String.Double),
|
756
|
+
(r'"', String.Double, '#pop'),
|
757
|
+
],
|
758
|
+
'heredoc-double': [
|
759
|
+
(r'\n"@', String.Heredoc, '#pop'),
|
760
|
+
(r'\$\(', Punctuation, 'child'),
|
761
|
+
(r'[^@\n]+"]', String.Heredoc),
|
762
|
+
(r".", String.Heredoc),
|
763
|
+
]
|
764
|
+
}
|
765
|
+
|
766
|
+
|
767
|
+
class PowerShellSessionLexer(ShellSessionBaseLexer):
|
768
|
+
"""
|
769
|
+
Lexer for PowerShell sessions, i.e. command lines, including a
|
770
|
+
prompt, interspersed with output.
|
771
|
+
|
772
|
+
.. versionadded:: 2.1
|
773
|
+
"""
|
774
|
+
|
775
|
+
name = 'PowerShell Session'
|
776
|
+
aliases = ['ps1con']
|
777
|
+
filenames = []
|
778
|
+
mimetypes = []
|
779
|
+
|
780
|
+
_innerLexerCls = PowerShellLexer
|
781
|
+
_ps1rgx = re.compile(r'^((?:\[[^]]+\]: )?PS[^>]*> ?)(.*\n?)')
|
782
|
+
_ps2 = '>> '
|
783
|
+
|
784
|
+
|
785
|
+
class FishShellLexer(RegexLexer):
|
786
|
+
"""
|
787
|
+
Lexer for Fish shell scripts.
|
788
|
+
|
789
|
+
.. versionadded:: 2.1
|
790
|
+
"""
|
791
|
+
|
792
|
+
name = 'Fish'
|
793
|
+
aliases = ['fish', 'fishshell']
|
794
|
+
filenames = ['*.fish', '*.load']
|
795
|
+
mimetypes = ['application/x-fish']
|
796
|
+
|
797
|
+
tokens = {
|
798
|
+
'root': [
|
799
|
+
include('basic'),
|
800
|
+
include('data'),
|
801
|
+
include('interp'),
|
802
|
+
],
|
803
|
+
'interp': [
|
804
|
+
(r'\$\(\(', Keyword, 'math'),
|
805
|
+
(r'\(', Keyword, 'paren'),
|
806
|
+
(r'\$#?(\w+|.)', Name.Variable),
|
807
|
+
],
|
808
|
+
'basic': [
|
809
|
+
(r'\b(begin|end|if|else|while|break|for|in|return|function|block|'
|
810
|
+
r'case|continue|switch|not|and|or|set|echo|exit|pwd|true|false|'
|
811
|
+
r'cd|count|test)(\s*)\b',
|
812
|
+
bygroups(Keyword, Text)),
|
813
|
+
(r'\b(alias|bg|bind|breakpoint|builtin|command|commandline|'
|
814
|
+
r'complete|contains|dirh|dirs|emit|eval|exec|fg|fish|fish_config|'
|
815
|
+
r'fish_indent|fish_pager|fish_prompt|fish_right_prompt|'
|
816
|
+
r'fish_update_completions|fishd|funced|funcsave|functions|help|'
|
817
|
+
r'history|isatty|jobs|math|mimedb|nextd|open|popd|prevd|psub|'
|
818
|
+
r'pushd|random|read|set_color|source|status|trap|type|ulimit|'
|
819
|
+
r'umask|vared|fc|getopts|hash|kill|printf|time|wait)\s*\b(?!\.)',
|
820
|
+
Name.Builtin),
|
821
|
+
(r'#.*\n', Comment),
|
822
|
+
(r'\\[\w\W]', String.Escape),
|
823
|
+
(r'(\b\w+)(\s*)(=)', bygroups(Name.Variable, Text, Operator)),
|
824
|
+
(r'[\[\]()=]', Operator),
|
825
|
+
(r'<<-?\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
|
826
|
+
],
|
827
|
+
'data': [
|
828
|
+
(r'(?s)\$?"(\\\\|\\[0-7]+|\\.|[^"\\$])*"', String.Double),
|
829
|
+
(r'"', String.Double, 'string'),
|
830
|
+
(r"(?s)\$'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
|
831
|
+
(r"(?s)'.*?'", String.Single),
|
832
|
+
(r';', Punctuation),
|
833
|
+
(r'&|\||\^|<|>', Operator),
|
834
|
+
(r'\s+', Text),
|
835
|
+
(r'\d+(?= |\Z)', Number),
|
836
|
+
(r'[^=\s\[\]{}()$"\'`\\<&|;]+', Text),
|
837
|
+
],
|
838
|
+
'string': [
|
839
|
+
(r'"', String.Double, '#pop'),
|
840
|
+
(r'(?s)(\\\\|\\[0-7]+|\\.|[^"\\$])+', String.Double),
|
841
|
+
include('interp'),
|
842
|
+
],
|
843
|
+
'paren': [
|
844
|
+
(r'\)', Keyword, '#pop'),
|
845
|
+
include('root'),
|
846
|
+
],
|
847
|
+
'math': [
|
848
|
+
(r'\)\)', Keyword, '#pop'),
|
849
|
+
(r'[-+*/%^|&]|\*\*|\|\|', Operator),
|
850
|
+
(r'\d+#\d+', Number),
|
851
|
+
(r'\d+#(?! )', Number),
|
852
|
+
(r'\d+', Number),
|
853
|
+
include('root'),
|
854
|
+
],
|
855
|
+
}
|
856
|
+
|
857
|
+
class ExeclineLexer(RegexLexer):
|
858
|
+
"""
|
859
|
+
Lexer for Laurent Bercot's execline language
|
860
|
+
(https://skarnet.org/software/execline).
|
861
|
+
|
862
|
+
.. versionadded:: 2.7
|
863
|
+
"""
|
864
|
+
|
865
|
+
name = 'execline'
|
866
|
+
aliases = ['execline']
|
867
|
+
filenames = ['*.exec']
|
868
|
+
|
869
|
+
tokens = {
|
870
|
+
'root': [
|
871
|
+
include('basic'),
|
872
|
+
include('data'),
|
873
|
+
include('interp')
|
874
|
+
],
|
875
|
+
'interp': [
|
876
|
+
(r'\$\{', String.Interpol, 'curly'),
|
877
|
+
(r'\$[\w@#]+', Name.Variable), # user variable
|
878
|
+
(r'\$', Text),
|
879
|
+
],
|
880
|
+
'basic': [
|
881
|
+
(r'\b(background|backtick|cd|define|dollarat|elgetopt|'
|
882
|
+
r'elgetpositionals|elglob|emptyenv|envfile|exec|execlineb|'
|
883
|
+
r'exit|export|fdblock|fdclose|fdmove|fdreserve|fdswap|'
|
884
|
+
r'forbacktickx|foreground|forstdin|forx|getcwd|getpid|heredoc|'
|
885
|
+
r'homeof|if|ifelse|ifte|ifthenelse|importas|loopwhilex|'
|
886
|
+
r'multidefine|multisubstitute|pipeline|piperw|posix-cd|'
|
887
|
+
r'redirfd|runblock|shift|trap|tryexec|umask|unexport|wait|'
|
888
|
+
r'withstdinas)\b', Name.Builtin),
|
889
|
+
(r'\A#!.+\n', Comment.Hashbang),
|
890
|
+
(r'#.*\n', Comment.Single),
|
891
|
+
(r'[{}]', Operator)
|
892
|
+
],
|
893
|
+
'data': [
|
894
|
+
(r'(?s)"(\\.|[^"\\$])*"', String.Double),
|
895
|
+
(r'"', String.Double, 'string'),
|
896
|
+
(r'\s+', Text),
|
897
|
+
(r'[^\s{}$"\\]+', Text)
|
898
|
+
],
|
899
|
+
'string': [
|
900
|
+
(r'"', String.Double, '#pop'),
|
901
|
+
(r'(?s)(\\\\|\\.|[^"\\$])+', String.Double),
|
902
|
+
include('interp'),
|
903
|
+
],
|
904
|
+
'curly': [
|
905
|
+
(r'\}', String.Interpol, '#pop'),
|
906
|
+
(r'[\w#@]+', Name.Variable),
|
907
|
+
include('root')
|
908
|
+
]
|
909
|
+
|
910
|
+
}
|
911
|
+
|
912
|
+
def analyse_text(text):
|
913
|
+
if shebang_matches(text, r'execlineb'):
|
914
|
+
return 1
|