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,78 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.capnproto
|
4
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexers for the Cap'n Proto schema language.
|
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 RegexLexer, default
|
15
|
+
from pygments.token import Text, Comment, Keyword, Name, Literal
|
16
|
+
|
17
|
+
__all__ = ['CapnProtoLexer']
|
18
|
+
|
19
|
+
|
20
|
+
class CapnProtoLexer(RegexLexer):
|
21
|
+
"""
|
22
|
+
For `Cap'n Proto <https://capnproto.org>`_ source.
|
23
|
+
|
24
|
+
.. versionadded:: 2.2
|
25
|
+
"""
|
26
|
+
name = 'Cap\'n Proto'
|
27
|
+
filenames = ['*.capnp']
|
28
|
+
aliases = ['capnp']
|
29
|
+
|
30
|
+
flags = re.MULTILINE | re.UNICODE
|
31
|
+
|
32
|
+
tokens = {
|
33
|
+
'root': [
|
34
|
+
(r'#.*?$', Comment.Single),
|
35
|
+
(r'@[0-9a-zA-Z]*', Name.Decorator),
|
36
|
+
(r'=', Literal, 'expression'),
|
37
|
+
(r':', Name.Class, 'type'),
|
38
|
+
(r'\$', Name.Attribute, 'annotation'),
|
39
|
+
(r'(struct|enum|interface|union|import|using|const|annotation|'
|
40
|
+
r'extends|in|of|on|as|with|from|fixed)\b',
|
41
|
+
Keyword),
|
42
|
+
(r'[\w.]+', Name),
|
43
|
+
(r'[^#@=:$\w]+', Text),
|
44
|
+
],
|
45
|
+
'type': [
|
46
|
+
(r'[^][=;,(){}$]+', Name.Class),
|
47
|
+
(r'[\[(]', Name.Class, 'parentype'),
|
48
|
+
default('#pop'),
|
49
|
+
],
|
50
|
+
'parentype': [
|
51
|
+
(r'[^][;()]+', Name.Class),
|
52
|
+
(r'[\[(]', Name.Class, '#push'),
|
53
|
+
(r'[])]', Name.Class, '#pop'),
|
54
|
+
default('#pop'),
|
55
|
+
],
|
56
|
+
'expression': [
|
57
|
+
(r'[^][;,(){}$]+', Literal),
|
58
|
+
(r'[\[(]', Literal, 'parenexp'),
|
59
|
+
default('#pop'),
|
60
|
+
],
|
61
|
+
'parenexp': [
|
62
|
+
(r'[^][;()]+', Literal),
|
63
|
+
(r'[\[(]', Literal, '#push'),
|
64
|
+
(r'[])]', Literal, '#pop'),
|
65
|
+
default('#pop'),
|
66
|
+
],
|
67
|
+
'annotation': [
|
68
|
+
(r'[^][;,(){}=:]+', Name.Attribute),
|
69
|
+
(r'[\[(]', Name.Attribute, 'annexp'),
|
70
|
+
default('#pop'),
|
71
|
+
],
|
72
|
+
'annexp': [
|
73
|
+
(r'[^][;()]+', Name.Attribute),
|
74
|
+
(r'[\[(]', Name.Attribute, '#push'),
|
75
|
+
(r'[])]', Name.Attribute, '#pop'),
|
76
|
+
default('#pop'),
|
77
|
+
],
|
78
|
+
}
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.chapel
|
4
|
+
~~~~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexer for the Chapel language.
|
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, words
|
13
|
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
14
|
+
Number, Punctuation
|
15
|
+
|
16
|
+
__all__ = ['ChapelLexer']
|
17
|
+
|
18
|
+
|
19
|
+
class ChapelLexer(RegexLexer):
|
20
|
+
"""
|
21
|
+
For `Chapel <https://chapel-lang.org/>`_ source.
|
22
|
+
|
23
|
+
.. versionadded:: 2.0
|
24
|
+
"""
|
25
|
+
name = 'Chapel'
|
26
|
+
filenames = ['*.chpl']
|
27
|
+
aliases = ['chapel', 'chpl']
|
28
|
+
# mimetypes = ['text/x-chapel']
|
29
|
+
|
30
|
+
tokens = {
|
31
|
+
'root': [
|
32
|
+
(r'\n', Text),
|
33
|
+
(r'\s+', Text),
|
34
|
+
(r'\\\n', Text),
|
35
|
+
|
36
|
+
(r'//(.*?)\n', Comment.Single),
|
37
|
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
38
|
+
|
39
|
+
(r'(config|const|in|inout|out|param|ref|type|var)\b',
|
40
|
+
Keyword.Declaration),
|
41
|
+
(r'(false|nil|none|true)\b', Keyword.Constant),
|
42
|
+
(r'(bool|bytes|complex|imag|int|nothing|opaque|range|real|string|uint|void)\b',
|
43
|
+
Keyword.Type),
|
44
|
+
(words((
|
45
|
+
'align', 'as', 'atomic',
|
46
|
+
'begin', 'borrowed', 'break', 'by',
|
47
|
+
'catch', 'cobegin', 'coforall', 'continue',
|
48
|
+
'defer', 'delete', 'dmapped', 'do', 'domain',
|
49
|
+
'else', 'enum', 'except', 'export', 'extern',
|
50
|
+
'for', 'forall', 'forwarding',
|
51
|
+
'if', 'import', 'index', 'init', 'inline',
|
52
|
+
'label', 'lambda', 'let', 'lifetime', 'local', 'locale'
|
53
|
+
'new', 'noinit',
|
54
|
+
'on', 'only', 'otherwise', 'override', 'owned',
|
55
|
+
'pragma', 'private', 'prototype', 'public',
|
56
|
+
'reduce', 'require', 'return',
|
57
|
+
'scan', 'select', 'serial', 'shared', 'single', 'sparse', 'subdomain', 'sync',
|
58
|
+
'then', 'this', 'throw', 'throws', 'try',
|
59
|
+
'unmanaged', 'use',
|
60
|
+
'when', 'where', 'while', 'with',
|
61
|
+
'yield',
|
62
|
+
'zip'), suffix=r'\b'),
|
63
|
+
Keyword),
|
64
|
+
(r'(iter)((?:\s)+)', bygroups(Keyword, Text), 'procname'),
|
65
|
+
(r'(proc)((?:\s)+)', bygroups(Keyword, Text), 'procname'),
|
66
|
+
(r'(class|module|record|union)(\s+)', bygroups(Keyword, Text),
|
67
|
+
'classname'),
|
68
|
+
|
69
|
+
# imaginary integers
|
70
|
+
(r'\d+i', Number),
|
71
|
+
(r'\d+\.\d*([Ee][-+]\d+)?i', Number),
|
72
|
+
(r'\.\d+([Ee][-+]\d+)?i', Number),
|
73
|
+
(r'\d+[Ee][-+]\d+i', Number),
|
74
|
+
|
75
|
+
# reals cannot end with a period due to lexical ambiguity with
|
76
|
+
# .. operator. See reference for rationale.
|
77
|
+
(r'(\d*\.\d+)([eE][+-]?[0-9]+)?i?', Number.Float),
|
78
|
+
(r'\d+[eE][+-]?[0-9]+i?', Number.Float),
|
79
|
+
|
80
|
+
# integer literals
|
81
|
+
# -- binary
|
82
|
+
(r'0[bB][01]+', Number.Bin),
|
83
|
+
# -- hex
|
84
|
+
(r'0[xX][0-9a-fA-F]+', Number.Hex),
|
85
|
+
# -- octal
|
86
|
+
(r'0[oO][0-7]+', Number.Oct),
|
87
|
+
# -- decimal
|
88
|
+
(r'[0-9]+', Number.Integer),
|
89
|
+
|
90
|
+
# strings
|
91
|
+
(r'"(\\\\|\\"|[^"])*"', String),
|
92
|
+
(r"'(\\\\|\\'|[^'])*'", String),
|
93
|
+
|
94
|
+
# tokens
|
95
|
+
(r'(=|\+=|-=|\*=|/=|\*\*=|%=|&=|\|=|\^=|&&=|\|\|=|<<=|>>=|'
|
96
|
+
r'<=>|<~>|\.\.|by|#|\.\.\.|'
|
97
|
+
r'&&|\|\||!|&|\||\^|~|<<|>>|'
|
98
|
+
r'==|!=|<=|>=|<|>|'
|
99
|
+
r'[+\-*/%]|\*\*)', Operator),
|
100
|
+
(r'[:;,.?()\[\]{}]', Punctuation),
|
101
|
+
|
102
|
+
# identifiers
|
103
|
+
(r'[a-zA-Z_][\w$]*', Name.Other),
|
104
|
+
],
|
105
|
+
'classname': [
|
106
|
+
(r'[a-zA-Z_][\w$]*', Name.Class, '#pop'),
|
107
|
+
],
|
108
|
+
'procname': [
|
109
|
+
(r'([a-zA-Z_][.\w$]*|\~[a-zA-Z_][.\w$]*|[+*/!~%<>=&^|\-]{1,2})',
|
110
|
+
Name.Function, '#pop'),
|
111
|
+
],
|
112
|
+
}
|
@@ -0,0 +1,179 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.clean
|
4
|
+
~~~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexer for the Clean language.
|
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 ExtendedRegexLexer, words, default, include, bygroups
|
13
|
+
from pygments.token import Comment, Error, Keyword, Literal, Name, Number, \
|
14
|
+
Operator, Punctuation, String, Whitespace
|
15
|
+
|
16
|
+
__all__ = ['CleanLexer']
|
17
|
+
|
18
|
+
|
19
|
+
class CleanLexer(ExtendedRegexLexer):
|
20
|
+
"""
|
21
|
+
Lexer for the general purpose, state-of-the-art, pure and lazy functional
|
22
|
+
programming language Clean (http://clean.cs.ru.nl/Clean).
|
23
|
+
|
24
|
+
.. versionadded: 2.2
|
25
|
+
"""
|
26
|
+
name = 'Clean'
|
27
|
+
aliases = ['clean']
|
28
|
+
filenames = ['*.icl', '*.dcl']
|
29
|
+
|
30
|
+
keywords = (
|
31
|
+
'case', 'ccall', 'class', 'code', 'code inline', 'derive', 'export',
|
32
|
+
'foreign', 'generic', 'if', 'in', 'infix', 'infixl', 'infixr',
|
33
|
+
'instance', 'let', 'of', 'otherwise', 'special', 'stdcall', 'where',
|
34
|
+
'with')
|
35
|
+
|
36
|
+
modulewords = ('implementation', 'definition', 'system')
|
37
|
+
|
38
|
+
lowerId = r'[a-z`][\w`]*'
|
39
|
+
upperId = r'[A-Z`][\w`]*'
|
40
|
+
funnyId = r'[~@#$%\^?!+\-*<>\\/|&=:]+'
|
41
|
+
scoreUpperId = r'_' + upperId
|
42
|
+
scoreLowerId = r'_' + lowerId
|
43
|
+
moduleId = r'[a-zA-Z_][a-zA-Z0-9_.`]+'
|
44
|
+
classId = '|'.join([lowerId, upperId, funnyId])
|
45
|
+
|
46
|
+
tokens = {
|
47
|
+
'root': [
|
48
|
+
include('comments'),
|
49
|
+
include('keywords'),
|
50
|
+
include('module'),
|
51
|
+
include('import'),
|
52
|
+
include('whitespace'),
|
53
|
+
include('literals'),
|
54
|
+
include('operators'),
|
55
|
+
include('delimiters'),
|
56
|
+
include('names'),
|
57
|
+
],
|
58
|
+
'whitespace': [
|
59
|
+
(r'\s+', Whitespace),
|
60
|
+
],
|
61
|
+
'comments': [
|
62
|
+
(r'//.*\n', Comment.Single),
|
63
|
+
(r'/\*', Comment.Multi, 'comments.in'),
|
64
|
+
(r'/\*\*', Comment.Special, 'comments.in'),
|
65
|
+
],
|
66
|
+
'comments.in': [
|
67
|
+
(r'\*\/', Comment.Multi, '#pop'),
|
68
|
+
(r'/\*', Comment.Multi, '#push'),
|
69
|
+
(r'[^*/]+', Comment.Multi),
|
70
|
+
(r'\*(?!/)', Comment.Multi),
|
71
|
+
(r'/', Comment.Multi),
|
72
|
+
],
|
73
|
+
'keywords': [
|
74
|
+
(words(keywords, prefix=r'\b', suffix=r'\b'), Keyword),
|
75
|
+
],
|
76
|
+
'module': [
|
77
|
+
(words(modulewords, prefix=r'\b', suffix=r'\b'), Keyword.Namespace),
|
78
|
+
(r'\bmodule\b', Keyword.Namespace, 'module.name'),
|
79
|
+
],
|
80
|
+
'module.name': [
|
81
|
+
include('whitespace'),
|
82
|
+
(moduleId, Name.Class, '#pop'),
|
83
|
+
],
|
84
|
+
'import': [
|
85
|
+
(r'\b(import)\b(\s*)', bygroups(Keyword, Whitespace), 'import.module'),
|
86
|
+
(r'\b(from)\b(\s*)\b(' + moduleId + r')\b(\s*)\b(import)\b',
|
87
|
+
bygroups(Keyword, Whitespace, Name.Class, Whitespace, Keyword),
|
88
|
+
'import.what'),
|
89
|
+
],
|
90
|
+
'import.module': [
|
91
|
+
(r'\b(qualified)\b(\s*)', bygroups(Keyword, Whitespace)),
|
92
|
+
(r'(\s*)\b(as)\b', bygroups(Whitespace, Keyword), ('#pop', 'import.module.as')),
|
93
|
+
(moduleId, Name.Class),
|
94
|
+
(r'(\s*)(,)(\s*)', bygroups(Whitespace, Punctuation, Whitespace)),
|
95
|
+
(r'\s+', Whitespace),
|
96
|
+
default('#pop'),
|
97
|
+
],
|
98
|
+
'import.module.as': [
|
99
|
+
include('whitespace'),
|
100
|
+
(lowerId, Name.Class, '#pop'),
|
101
|
+
(upperId, Name.Class, '#pop'),
|
102
|
+
],
|
103
|
+
'import.what': [
|
104
|
+
(r'\b(class)\b(\s+)(' + classId + r')',
|
105
|
+
bygroups(Keyword, Whitespace, Name.Class), 'import.what.class'),
|
106
|
+
(r'\b(instance)(\s+)(' + classId + r')(\s+)',
|
107
|
+
bygroups(Keyword, Whitespace, Name.Class, Whitespace), 'import.what.instance'),
|
108
|
+
(r'(::)(\s*)\b(' + upperId + r')\b',
|
109
|
+
bygroups(Punctuation, Whitespace, Name.Class), 'import.what.type'),
|
110
|
+
(r'\b(generic)\b(\s+)\b(' + lowerId + '|' + upperId + r')\b',
|
111
|
+
bygroups(Keyword, Whitespace, Name)),
|
112
|
+
include('names'),
|
113
|
+
(r'(,)(\s+)', bygroups(Punctuation, Whitespace)),
|
114
|
+
(r'$', Whitespace, '#pop'),
|
115
|
+
include('whitespace'),
|
116
|
+
],
|
117
|
+
'import.what.class': [
|
118
|
+
(r',', Punctuation, '#pop'),
|
119
|
+
(r'\(', Punctuation, 'import.what.class.members'),
|
120
|
+
(r'$', Whitespace, '#pop:2'),
|
121
|
+
include('whitespace'),
|
122
|
+
],
|
123
|
+
'import.what.class.members': [
|
124
|
+
(r',', Punctuation),
|
125
|
+
(r'\.\.', Punctuation),
|
126
|
+
(r'\)', Punctuation, '#pop'),
|
127
|
+
include('names'),
|
128
|
+
],
|
129
|
+
'import.what.instance': [
|
130
|
+
(r'[,)]', Punctuation, '#pop'),
|
131
|
+
(r'\(', Punctuation, 'import.what.instance'),
|
132
|
+
(r'$', Whitespace, '#pop:2'),
|
133
|
+
include('whitespace'),
|
134
|
+
include('names'),
|
135
|
+
],
|
136
|
+
'import.what.type': [
|
137
|
+
(r',', Punctuation, '#pop'),
|
138
|
+
(r'[({]', Punctuation, 'import.what.type.consesandfields'),
|
139
|
+
(r'$', Whitespace, '#pop:2'),
|
140
|
+
include('whitespace'),
|
141
|
+
],
|
142
|
+
'import.what.type.consesandfields': [
|
143
|
+
(r',', Punctuation),
|
144
|
+
(r'\.\.', Punctuation),
|
145
|
+
(r'[)}]', Punctuation, '#pop'),
|
146
|
+
include('names'),
|
147
|
+
],
|
148
|
+
'literals': [
|
149
|
+
(r'\'([^\'\\]|\\(x[\da-fA-F]+|\d+|.))\'', Literal.Char),
|
150
|
+
(r'[+~-]?0[0-7]+\b', Number.Oct),
|
151
|
+
(r'[+~-]?\d+\.\d+(E[+-]?\d+)?', Number.Float),
|
152
|
+
(r'[+~-]?\d+\b', Number.Integer),
|
153
|
+
(r'[+~-]?0x[\da-fA-F]+\b', Number.Hex),
|
154
|
+
(r'True|False', Literal),
|
155
|
+
(r'"', String.Double, 'literals.stringd'),
|
156
|
+
],
|
157
|
+
'literals.stringd': [
|
158
|
+
(r'[^\\"\n]+', String.Double),
|
159
|
+
(r'"', String.Double, '#pop'),
|
160
|
+
(r'\\.', String.Double),
|
161
|
+
(r'[$\n]', Error, '#pop'),
|
162
|
+
],
|
163
|
+
'operators': [
|
164
|
+
(r'[-~@#$%\^?!+*<>\\/|&=:.]+', Operator),
|
165
|
+
(r'\b_+\b', Operator),
|
166
|
+
],
|
167
|
+
'delimiters': [
|
168
|
+
(r'[,;(){}\[\]]', Punctuation),
|
169
|
+
(r'(\')([\w`.]+)(\')',
|
170
|
+
bygroups(Punctuation, Name.Class, Punctuation)),
|
171
|
+
],
|
172
|
+
'names': [
|
173
|
+
(lowerId, Name),
|
174
|
+
(scoreLowerId, Name),
|
175
|
+
(funnyId, Name.Function),
|
176
|
+
(upperId, Name.Class),
|
177
|
+
(scoreUpperId, Name.Class),
|
178
|
+
]
|
179
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.compiled
|
4
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Just export lexer classes previously contained in this module.
|
7
|
+
|
8
|
+
:copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
|
9
|
+
:license: BSD, see LICENSE for details.
|
10
|
+
"""
|
11
|
+
|
12
|
+
from pygments.lexers.jvm import JavaLexer, ScalaLexer
|
13
|
+
from pygments.lexers.c_cpp import CLexer, CppLexer
|
14
|
+
from pygments.lexers.d import DLexer
|
15
|
+
from pygments.lexers.objective import ObjectiveCLexer, \
|
16
|
+
ObjectiveCppLexer, LogosLexer
|
17
|
+
from pygments.lexers.go import GoLexer
|
18
|
+
from pygments.lexers.rust import RustLexer
|
19
|
+
from pygments.lexers.c_like import ECLexer, ValaLexer, CudaLexer
|
20
|
+
from pygments.lexers.pascal import DelphiLexer, Modula2Lexer, AdaLexer
|
21
|
+
from pygments.lexers.business import CobolLexer, CobolFreeformatLexer
|
22
|
+
from pygments.lexers.fortran import FortranLexer
|
23
|
+
from pygments.lexers.prolog import PrologLexer
|
24
|
+
from pygments.lexers.python import CythonLexer
|
25
|
+
from pygments.lexers.graphics import GLShaderLexer
|
26
|
+
from pygments.lexers.ml import OcamlLexer
|
27
|
+
from pygments.lexers.basic import BlitzBasicLexer, BlitzMaxLexer, MonkeyLexer
|
28
|
+
from pygments.lexers.dylan import DylanLexer, DylanLidLexer, DylanConsoleLexer
|
29
|
+
from pygments.lexers.ooc import OocLexer
|
30
|
+
from pygments.lexers.felix import FelixLexer
|
31
|
+
from pygments.lexers.nimrod import NimrodLexer
|
32
|
+
from pygments.lexers.crystal import CrystalLexer
|
33
|
+
|
34
|
+
__all__ = []
|
@@ -0,0 +1,984 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.configs
|
4
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexers for configuration file formats.
|
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 RegexLexer, default, words, bygroups, include, using
|
15
|
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
16
|
+
Number, Punctuation, Whitespace, Literal, Generic
|
17
|
+
from pygments.lexers.shell import BashLexer
|
18
|
+
from pygments.lexers.data import JsonLexer
|
19
|
+
|
20
|
+
__all__ = ['IniLexer', 'RegeditLexer', 'PropertiesLexer', 'KconfigLexer',
|
21
|
+
'Cfengine3Lexer', 'ApacheConfLexer', 'SquidConfLexer',
|
22
|
+
'NginxConfLexer', 'LighttpdConfLexer', 'DockerLexer',
|
23
|
+
'TerraformLexer', 'TermcapLexer', 'TerminfoLexer',
|
24
|
+
'PkgConfigLexer', 'PacmanConfLexer', 'AugeasLexer', 'TOMLLexer',
|
25
|
+
'SingularityLexer']
|
26
|
+
|
27
|
+
|
28
|
+
class IniLexer(RegexLexer):
|
29
|
+
"""
|
30
|
+
Lexer for configuration files in INI style.
|
31
|
+
"""
|
32
|
+
|
33
|
+
name = 'INI'
|
34
|
+
aliases = ['ini', 'cfg', 'dosini']
|
35
|
+
filenames = ['*.ini', '*.cfg', '*.inf']
|
36
|
+
mimetypes = ['text/x-ini', 'text/inf']
|
37
|
+
|
38
|
+
tokens = {
|
39
|
+
'root': [
|
40
|
+
(r'\s+', Text),
|
41
|
+
(r'[;#].*', Comment.Single),
|
42
|
+
(r'\[.*?\]$', Keyword),
|
43
|
+
(r'(.*?)([ \t]*)(=)([ \t]*)(.*(?:\n[ \t].+)*)',
|
44
|
+
bygroups(Name.Attribute, Text, Operator, Text, String)),
|
45
|
+
# standalone option, supported by some INI parsers
|
46
|
+
(r'(.+?)$', Name.Attribute),
|
47
|
+
],
|
48
|
+
}
|
49
|
+
|
50
|
+
def analyse_text(text):
|
51
|
+
npos = text.find('\n')
|
52
|
+
if npos < 3:
|
53
|
+
return False
|
54
|
+
return text[0] == '[' and text[npos-1] == ']'
|
55
|
+
|
56
|
+
|
57
|
+
class RegeditLexer(RegexLexer):
|
58
|
+
"""
|
59
|
+
Lexer for `Windows Registry
|
60
|
+
<http://en.wikipedia.org/wiki/Windows_Registry#.REG_files>`_ files produced
|
61
|
+
by regedit.
|
62
|
+
|
63
|
+
.. versionadded:: 1.6
|
64
|
+
"""
|
65
|
+
|
66
|
+
name = 'reg'
|
67
|
+
aliases = ['registry']
|
68
|
+
filenames = ['*.reg']
|
69
|
+
mimetypes = ['text/x-windows-registry']
|
70
|
+
|
71
|
+
tokens = {
|
72
|
+
'root': [
|
73
|
+
(r'Windows Registry Editor.*', Text),
|
74
|
+
(r'\s+', Text),
|
75
|
+
(r'[;#].*', Comment.Single),
|
76
|
+
(r'(\[)(-?)(HKEY_[A-Z_]+)(.*?\])$',
|
77
|
+
bygroups(Keyword, Operator, Name.Builtin, Keyword)),
|
78
|
+
# String keys, which obey somewhat normal escaping
|
79
|
+
(r'("(?:\\"|\\\\|[^"])+")([ \t]*)(=)([ \t]*)',
|
80
|
+
bygroups(Name.Attribute, Text, Operator, Text),
|
81
|
+
'value'),
|
82
|
+
# Bare keys (includes @)
|
83
|
+
(r'(.*?)([ \t]*)(=)([ \t]*)',
|
84
|
+
bygroups(Name.Attribute, Text, Operator, Text),
|
85
|
+
'value'),
|
86
|
+
],
|
87
|
+
'value': [
|
88
|
+
(r'-', Operator, '#pop'), # delete value
|
89
|
+
(r'(dword|hex(?:\([0-9a-fA-F]\))?)(:)([0-9a-fA-F,]+)',
|
90
|
+
bygroups(Name.Variable, Punctuation, Number), '#pop'),
|
91
|
+
# As far as I know, .reg files do not support line continuation.
|
92
|
+
(r'.+', String, '#pop'),
|
93
|
+
default('#pop'),
|
94
|
+
]
|
95
|
+
}
|
96
|
+
|
97
|
+
def analyse_text(text):
|
98
|
+
return text.startswith('Windows Registry Editor')
|
99
|
+
|
100
|
+
|
101
|
+
class PropertiesLexer(RegexLexer):
|
102
|
+
"""
|
103
|
+
Lexer for configuration files in Java's properties format.
|
104
|
+
|
105
|
+
Note: trailing whitespace counts as part of the value as per spec
|
106
|
+
|
107
|
+
.. versionadded:: 1.4
|
108
|
+
"""
|
109
|
+
|
110
|
+
name = 'Properties'
|
111
|
+
aliases = ['properties', 'jproperties']
|
112
|
+
filenames = ['*.properties']
|
113
|
+
mimetypes = ['text/x-java-properties']
|
114
|
+
|
115
|
+
tokens = {
|
116
|
+
'root': [
|
117
|
+
(r'^(\w+)([ \t])(\w+\s*)$', bygroups(Name.Attribute, Text, String)),
|
118
|
+
(r'^\w+(\\[ \t]\w*)*$', Name.Attribute),
|
119
|
+
(r'(^ *)([#!].*)', bygroups(Text, Comment)),
|
120
|
+
# More controversial comments
|
121
|
+
(r'(^ *)((?:;|//).*)', bygroups(Text, Comment)),
|
122
|
+
(r'(.*?)([ \t]*)([=:])([ \t]*)(.*(?:(?<=\\)\n.*)*)',
|
123
|
+
bygroups(Name.Attribute, Text, Operator, Text, String)),
|
124
|
+
(r'\s', Text),
|
125
|
+
],
|
126
|
+
}
|
127
|
+
|
128
|
+
|
129
|
+
def _rx_indent(level):
|
130
|
+
# Kconfig *always* interprets a tab as 8 spaces, so this is the default.
|
131
|
+
# Edit this if you are in an environment where KconfigLexer gets expanded
|
132
|
+
# input (tabs expanded to spaces) and the expansion tab width is != 8,
|
133
|
+
# e.g. in connection with Trac (trac.ini, [mimeviewer], tab_width).
|
134
|
+
# Value range here is 2 <= {tab_width} <= 8.
|
135
|
+
tab_width = 8
|
136
|
+
# Regex matching a given indentation {level}, assuming that indentation is
|
137
|
+
# a multiple of {tab_width}. In other cases there might be problems.
|
138
|
+
if tab_width == 2:
|
139
|
+
space_repeat = '+'
|
140
|
+
else:
|
141
|
+
space_repeat = '{1,%d}' % (tab_width - 1)
|
142
|
+
if level == 1:
|
143
|
+
level_repeat = ''
|
144
|
+
else:
|
145
|
+
level_repeat = '{%s}' % level
|
146
|
+
return r'(?:\t| %s\t| {%s})%s.*\n' % (space_repeat, tab_width, level_repeat)
|
147
|
+
|
148
|
+
|
149
|
+
class KconfigLexer(RegexLexer):
|
150
|
+
"""
|
151
|
+
For Linux-style Kconfig files.
|
152
|
+
|
153
|
+
.. versionadded:: 1.6
|
154
|
+
"""
|
155
|
+
|
156
|
+
name = 'Kconfig'
|
157
|
+
aliases = ['kconfig', 'menuconfig', 'linux-config', 'kernel-config']
|
158
|
+
# Adjust this if new kconfig file names appear in your environment
|
159
|
+
filenames = ['Kconfig*', '*Config.in*', 'external.in*',
|
160
|
+
'standard-modules.in']
|
161
|
+
mimetypes = ['text/x-kconfig']
|
162
|
+
# No re.MULTILINE, indentation-aware help text needs line-by-line handling
|
163
|
+
flags = 0
|
164
|
+
|
165
|
+
def call_indent(level):
|
166
|
+
# If indentation >= {level} is detected, enter state 'indent{level}'
|
167
|
+
return (_rx_indent(level), String.Doc, 'indent%s' % level)
|
168
|
+
|
169
|
+
def do_indent(level):
|
170
|
+
# Print paragraphs of indentation level >= {level} as String.Doc,
|
171
|
+
# ignoring blank lines. Then return to 'root' state.
|
172
|
+
return [
|
173
|
+
(_rx_indent(level), String.Doc),
|
174
|
+
(r'\s*\n', Text),
|
175
|
+
default('#pop:2')
|
176
|
+
]
|
177
|
+
|
178
|
+
tokens = {
|
179
|
+
'root': [
|
180
|
+
(r'\s+', Text),
|
181
|
+
(r'#.*?\n', Comment.Single),
|
182
|
+
(words((
|
183
|
+
'mainmenu', 'config', 'menuconfig', 'choice', 'endchoice',
|
184
|
+
'comment', 'menu', 'endmenu', 'visible if', 'if', 'endif',
|
185
|
+
'source', 'prompt', 'select', 'depends on', 'default',
|
186
|
+
'range', 'option'), suffix=r'\b'),
|
187
|
+
Keyword),
|
188
|
+
(r'(---help---|help)[\t ]*\n', Keyword, 'help'),
|
189
|
+
(r'(bool|tristate|string|hex|int|defconfig_list|modules|env)\b',
|
190
|
+
Name.Builtin),
|
191
|
+
(r'[!=&|]', Operator),
|
192
|
+
(r'[()]', Punctuation),
|
193
|
+
(r'[0-9]+', Number.Integer),
|
194
|
+
(r"'(''|[^'])*'", String.Single),
|
195
|
+
(r'"(""|[^"])*"', String.Double),
|
196
|
+
(r'\S+', Text),
|
197
|
+
],
|
198
|
+
# Help text is indented, multi-line and ends when a lower indentation
|
199
|
+
# level is detected.
|
200
|
+
'help': [
|
201
|
+
# Skip blank lines after help token, if any
|
202
|
+
(r'\s*\n', Text),
|
203
|
+
# Determine the first help line's indentation level heuristically(!).
|
204
|
+
# Attention: this is not perfect, but works for 99% of "normal"
|
205
|
+
# indentation schemes up to a max. indentation level of 7.
|
206
|
+
call_indent(7),
|
207
|
+
call_indent(6),
|
208
|
+
call_indent(5),
|
209
|
+
call_indent(4),
|
210
|
+
call_indent(3),
|
211
|
+
call_indent(2),
|
212
|
+
call_indent(1),
|
213
|
+
default('#pop'), # for incomplete help sections without text
|
214
|
+
],
|
215
|
+
# Handle text for indentation levels 7 to 1
|
216
|
+
'indent7': do_indent(7),
|
217
|
+
'indent6': do_indent(6),
|
218
|
+
'indent5': do_indent(5),
|
219
|
+
'indent4': do_indent(4),
|
220
|
+
'indent3': do_indent(3),
|
221
|
+
'indent2': do_indent(2),
|
222
|
+
'indent1': do_indent(1),
|
223
|
+
}
|
224
|
+
|
225
|
+
|
226
|
+
class Cfengine3Lexer(RegexLexer):
|
227
|
+
"""
|
228
|
+
Lexer for `CFEngine3 <http://cfengine.org>`_ policy files.
|
229
|
+
|
230
|
+
.. versionadded:: 1.5
|
231
|
+
"""
|
232
|
+
|
233
|
+
name = 'CFEngine3'
|
234
|
+
aliases = ['cfengine3', 'cf3']
|
235
|
+
filenames = ['*.cf']
|
236
|
+
mimetypes = []
|
237
|
+
|
238
|
+
tokens = {
|
239
|
+
'root': [
|
240
|
+
(r'#.*?\n', Comment),
|
241
|
+
(r'(body)(\s+)(\S+)(\s+)(control)',
|
242
|
+
bygroups(Keyword, Text, Keyword, Text, Keyword)),
|
243
|
+
(r'(body|bundle)(\s+)(\S+)(\s+)(\w+)(\()',
|
244
|
+
bygroups(Keyword, Text, Keyword, Text, Name.Function, Punctuation),
|
245
|
+
'arglist'),
|
246
|
+
(r'(body|bundle)(\s+)(\S+)(\s+)(\w+)',
|
247
|
+
bygroups(Keyword, Text, Keyword, Text, Name.Function)),
|
248
|
+
(r'(")([^"]+)(")(\s+)(string|slist|int|real)(\s*)(=>)(\s*)',
|
249
|
+
bygroups(Punctuation, Name.Variable, Punctuation,
|
250
|
+
Text, Keyword.Type, Text, Operator, Text)),
|
251
|
+
(r'(\S+)(\s*)(=>)(\s*)',
|
252
|
+
bygroups(Keyword.Reserved, Text, Operator, Text)),
|
253
|
+
(r'"', String, 'string'),
|
254
|
+
(r'(\w+)(\()', bygroups(Name.Function, Punctuation)),
|
255
|
+
(r'([\w.!&|()]+)(::)', bygroups(Name.Class, Punctuation)),
|
256
|
+
(r'(\w+)(:)', bygroups(Keyword.Declaration, Punctuation)),
|
257
|
+
(r'@[{(][^)}]+[})]', Name.Variable),
|
258
|
+
(r'[(){},;]', Punctuation),
|
259
|
+
(r'=>', Operator),
|
260
|
+
(r'->', Operator),
|
261
|
+
(r'\d+\.\d+', Number.Float),
|
262
|
+
(r'\d+', Number.Integer),
|
263
|
+
(r'\w+', Name.Function),
|
264
|
+
(r'\s+', Text),
|
265
|
+
],
|
266
|
+
'string': [
|
267
|
+
(r'\$[{(]', String.Interpol, 'interpol'),
|
268
|
+
(r'\\.', String.Escape),
|
269
|
+
(r'"', String, '#pop'),
|
270
|
+
(r'\n', String),
|
271
|
+
(r'.', String),
|
272
|
+
],
|
273
|
+
'interpol': [
|
274
|
+
(r'\$[{(]', String.Interpol, '#push'),
|
275
|
+
(r'[})]', String.Interpol, '#pop'),
|
276
|
+
(r'[^${()}]+', String.Interpol),
|
277
|
+
],
|
278
|
+
'arglist': [
|
279
|
+
(r'\)', Punctuation, '#pop'),
|
280
|
+
(r',', Punctuation),
|
281
|
+
(r'\w+', Name.Variable),
|
282
|
+
(r'\s+', Text),
|
283
|
+
],
|
284
|
+
}
|
285
|
+
|
286
|
+
|
287
|
+
class ApacheConfLexer(RegexLexer):
|
288
|
+
"""
|
289
|
+
Lexer for configuration files following the Apache config file
|
290
|
+
format.
|
291
|
+
|
292
|
+
.. versionadded:: 0.6
|
293
|
+
"""
|
294
|
+
|
295
|
+
name = 'ApacheConf'
|
296
|
+
aliases = ['apacheconf', 'aconf', 'apache']
|
297
|
+
filenames = ['.htaccess', 'apache.conf', 'apache2.conf']
|
298
|
+
mimetypes = ['text/x-apacheconf']
|
299
|
+
flags = re.MULTILINE | re.IGNORECASE
|
300
|
+
|
301
|
+
tokens = {
|
302
|
+
'root': [
|
303
|
+
(r'\s+', Text),
|
304
|
+
(r'#(.*\\\n)+.*$|(#.*?)$', Comment),
|
305
|
+
(r'(<[^\s>]+)(?:(\s+)(.*))?(>)',
|
306
|
+
bygroups(Name.Tag, Text, String, Name.Tag)),
|
307
|
+
(r'[a-z]\w*', Name.Builtin, 'value'),
|
308
|
+
(r'\.+', Text),
|
309
|
+
],
|
310
|
+
'value': [
|
311
|
+
(r'\\\n', Text),
|
312
|
+
(r'$', Text, '#pop'),
|
313
|
+
(r'\\', Text),
|
314
|
+
(r'[^\S\n]+', Text),
|
315
|
+
(r'\d+\.\d+\.\d+\.\d+(?:/\d+)?', Number),
|
316
|
+
(r'\d+', Number),
|
317
|
+
(r'/([*a-z0-9][*\w./-]+)', String.Other),
|
318
|
+
(r'(on|off|none|any|all|double|email|dns|min|minimal|'
|
319
|
+
r'os|productonly|full|emerg|alert|crit|error|warn|'
|
320
|
+
r'notice|info|debug|registry|script|inetd|standalone|'
|
321
|
+
r'user|group)\b', Keyword),
|
322
|
+
(r'"([^"\\]*(?:\\(.|\n)[^"\\]*)*)"', String.Double),
|
323
|
+
(r'[^\s"\\]+', Text)
|
324
|
+
],
|
325
|
+
}
|
326
|
+
|
327
|
+
|
328
|
+
class SquidConfLexer(RegexLexer):
|
329
|
+
"""
|
330
|
+
Lexer for `squid <http://www.squid-cache.org/>`_ configuration files.
|
331
|
+
|
332
|
+
.. versionadded:: 0.9
|
333
|
+
"""
|
334
|
+
|
335
|
+
name = 'SquidConf'
|
336
|
+
aliases = ['squidconf', 'squid.conf', 'squid']
|
337
|
+
filenames = ['squid.conf']
|
338
|
+
mimetypes = ['text/x-squidconf']
|
339
|
+
flags = re.IGNORECASE
|
340
|
+
|
341
|
+
keywords = (
|
342
|
+
"access_log", "acl", "always_direct", "announce_host",
|
343
|
+
"announce_period", "announce_port", "announce_to", "anonymize_headers",
|
344
|
+
"append_domain", "as_whois_server", "auth_param_basic",
|
345
|
+
"authenticate_children", "authenticate_program", "authenticate_ttl",
|
346
|
+
"broken_posts", "buffered_logs", "cache_access_log", "cache_announce",
|
347
|
+
"cache_dir", "cache_dns_program", "cache_effective_group",
|
348
|
+
"cache_effective_user", "cache_host", "cache_host_acl",
|
349
|
+
"cache_host_domain", "cache_log", "cache_mem", "cache_mem_high",
|
350
|
+
"cache_mem_low", "cache_mgr", "cachemgr_passwd", "cache_peer",
|
351
|
+
"cache_peer_access", "cahce_replacement_policy", "cache_stoplist",
|
352
|
+
"cache_stoplist_pattern", "cache_store_log", "cache_swap",
|
353
|
+
"cache_swap_high", "cache_swap_log", "cache_swap_low", "client_db",
|
354
|
+
"client_lifetime", "client_netmask", "connect_timeout", "coredump_dir",
|
355
|
+
"dead_peer_timeout", "debug_options", "delay_access", "delay_class",
|
356
|
+
"delay_initial_bucket_level", "delay_parameters", "delay_pools",
|
357
|
+
"deny_info", "dns_children", "dns_defnames", "dns_nameservers",
|
358
|
+
"dns_testnames", "emulate_httpd_log", "err_html_text",
|
359
|
+
"fake_user_agent", "firewall_ip", "forwarded_for", "forward_snmpd_port",
|
360
|
+
"fqdncache_size", "ftpget_options", "ftpget_program", "ftp_list_width",
|
361
|
+
"ftp_passive", "ftp_user", "half_closed_clients", "header_access",
|
362
|
+
"header_replace", "hierarchy_stoplist", "high_response_time_warning",
|
363
|
+
"high_page_fault_warning", "hosts_file", "htcp_port", "http_access",
|
364
|
+
"http_anonymizer", "httpd_accel", "httpd_accel_host",
|
365
|
+
"httpd_accel_port", "httpd_accel_uses_host_header",
|
366
|
+
"httpd_accel_with_proxy", "http_port", "http_reply_access",
|
367
|
+
"icp_access", "icp_hit_stale", "icp_port", "icp_query_timeout",
|
368
|
+
"ident_lookup", "ident_lookup_access", "ident_timeout",
|
369
|
+
"incoming_http_average", "incoming_icp_average", "inside_firewall",
|
370
|
+
"ipcache_high", "ipcache_low", "ipcache_size", "local_domain",
|
371
|
+
"local_ip", "logfile_rotate", "log_fqdn", "log_icp_queries",
|
372
|
+
"log_mime_hdrs", "maximum_object_size", "maximum_single_addr_tries",
|
373
|
+
"mcast_groups", "mcast_icp_query_timeout", "mcast_miss_addr",
|
374
|
+
"mcast_miss_encode_key", "mcast_miss_port", "memory_pools",
|
375
|
+
"memory_pools_limit", "memory_replacement_policy", "mime_table",
|
376
|
+
"min_http_poll_cnt", "min_icp_poll_cnt", "minimum_direct_hops",
|
377
|
+
"minimum_object_size", "minimum_retry_timeout", "miss_access",
|
378
|
+
"negative_dns_ttl", "negative_ttl", "neighbor_timeout",
|
379
|
+
"neighbor_type_domain", "netdb_high", "netdb_low", "netdb_ping_period",
|
380
|
+
"netdb_ping_rate", "never_direct", "no_cache", "passthrough_proxy",
|
381
|
+
"pconn_timeout", "pid_filename", "pinger_program", "positive_dns_ttl",
|
382
|
+
"prefer_direct", "proxy_auth", "proxy_auth_realm", "query_icmp",
|
383
|
+
"quick_abort", "quick_abort_max", "quick_abort_min",
|
384
|
+
"quick_abort_pct", "range_offset_limit", "read_timeout",
|
385
|
+
"redirect_children", "redirect_program",
|
386
|
+
"redirect_rewrites_host_header", "reference_age",
|
387
|
+
"refresh_pattern", "reload_into_ims", "request_body_max_size",
|
388
|
+
"request_size", "request_timeout", "shutdown_lifetime",
|
389
|
+
"single_parent_bypass", "siteselect_timeout", "snmp_access",
|
390
|
+
"snmp_incoming_address", "snmp_port", "source_ping", "ssl_proxy",
|
391
|
+
"store_avg_object_size", "store_objects_per_bucket",
|
392
|
+
"strip_query_terms", "swap_level1_dirs", "swap_level2_dirs",
|
393
|
+
"tcp_incoming_address", "tcp_outgoing_address", "tcp_recv_bufsize",
|
394
|
+
"test_reachability", "udp_hit_obj", "udp_hit_obj_size",
|
395
|
+
"udp_incoming_address", "udp_outgoing_address", "unique_hostname",
|
396
|
+
"unlinkd_program", "uri_whitespace", "useragent_log",
|
397
|
+
"visible_hostname", "wais_relay", "wais_relay_host", "wais_relay_port",
|
398
|
+
)
|
399
|
+
|
400
|
+
opts = (
|
401
|
+
"proxy-only", "weight", "ttl", "no-query", "default", "round-robin",
|
402
|
+
"multicast-responder", "on", "off", "all", "deny", "allow", "via",
|
403
|
+
"parent", "no-digest", "heap", "lru", "realm", "children", "q1", "q2",
|
404
|
+
"credentialsttl", "none", "disable", "offline_toggle", "diskd",
|
405
|
+
)
|
406
|
+
|
407
|
+
actions = (
|
408
|
+
"shutdown", "info", "parameter", "server_list", "client_list",
|
409
|
+
r'squid.conf',
|
410
|
+
)
|
411
|
+
|
412
|
+
actions_stats = (
|
413
|
+
"objects", "vm_objects", "utilization", "ipcache", "fqdncache", "dns",
|
414
|
+
"redirector", "io", "reply_headers", "filedescriptors", "netdb",
|
415
|
+
)
|
416
|
+
|
417
|
+
actions_log = ("status", "enable", "disable", "clear")
|
418
|
+
|
419
|
+
acls = (
|
420
|
+
"url_regex", "urlpath_regex", "referer_regex", "port", "proto",
|
421
|
+
"req_mime_type", "rep_mime_type", "method", "browser", "user", "src",
|
422
|
+
"dst", "time", "dstdomain", "ident", "snmp_community",
|
423
|
+
)
|
424
|
+
|
425
|
+
ip_re = (
|
426
|
+
r'(?:(?:(?:[3-9]\d?|2(?:5[0-5]|[0-4]?\d)?|1\d{0,2}|0x0*[0-9a-f]{1,2}|'
|
427
|
+
r'0+[1-3]?[0-7]{0,2})(?:\.(?:[3-9]\d?|2(?:5[0-5]|[0-4]?\d)?|1\d{0,2}|'
|
428
|
+
r'0x0*[0-9a-f]{1,2}|0+[1-3]?[0-7]{0,2})){3})|(?!.*::.*::)(?:(?!:)|'
|
429
|
+
r':(?=:))(?:[0-9a-f]{0,4}(?:(?<=::)|(?<!::):)){6}(?:[0-9a-f]{0,4}'
|
430
|
+
r'(?:(?<=::)|(?<!::):)[0-9a-f]{0,4}(?:(?<=::)|(?<!:)|(?<=:)(?<!::):)|'
|
431
|
+
r'(?:25[0-4]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-4]|2[0-4]\d|1\d\d|'
|
432
|
+
r'[1-9]?\d)){3}))'
|
433
|
+
)
|
434
|
+
|
435
|
+
tokens = {
|
436
|
+
'root': [
|
437
|
+
(r'\s+', Whitespace),
|
438
|
+
(r'#', Comment, 'comment'),
|
439
|
+
(words(keywords, prefix=r'\b', suffix=r'\b'), Keyword),
|
440
|
+
(words(opts, prefix=r'\b', suffix=r'\b'), Name.Constant),
|
441
|
+
# Actions
|
442
|
+
(words(actions, prefix=r'\b', suffix=r'\b'), String),
|
443
|
+
(words(actions_stats, prefix=r'stats/', suffix=r'\b'), String),
|
444
|
+
(words(actions_log, prefix=r'log/', suffix=r'='), String),
|
445
|
+
(words(acls, prefix=r'\b', suffix=r'\b'), Keyword),
|
446
|
+
(ip_re + r'(?:/(?:' + ip_re + r'|\b\d+\b))?', Number.Float),
|
447
|
+
(r'(?:\b\d+\b(?:-\b\d+|%)?)', Number),
|
448
|
+
(r'\S+', Text),
|
449
|
+
],
|
450
|
+
'comment': [
|
451
|
+
(r'\s*TAG:.*', String.Escape, '#pop'),
|
452
|
+
(r'.+', Comment, '#pop'),
|
453
|
+
default('#pop'),
|
454
|
+
],
|
455
|
+
}
|
456
|
+
|
457
|
+
|
458
|
+
class NginxConfLexer(RegexLexer):
|
459
|
+
"""
|
460
|
+
Lexer for `Nginx <http://nginx.net/>`_ configuration files.
|
461
|
+
|
462
|
+
.. versionadded:: 0.11
|
463
|
+
"""
|
464
|
+
name = 'Nginx configuration file'
|
465
|
+
aliases = ['nginx']
|
466
|
+
filenames = ['nginx.conf']
|
467
|
+
mimetypes = ['text/x-nginx-conf']
|
468
|
+
|
469
|
+
tokens = {
|
470
|
+
'root': [
|
471
|
+
(r'(include)(\s+)([^\s;]+)', bygroups(Keyword, Text, Name)),
|
472
|
+
(r'[^\s;#]+', Keyword, 'stmt'),
|
473
|
+
include('base'),
|
474
|
+
],
|
475
|
+
'block': [
|
476
|
+
(r'\}', Punctuation, '#pop:2'),
|
477
|
+
(r'[^\s;#]+', Keyword.Namespace, 'stmt'),
|
478
|
+
include('base'),
|
479
|
+
],
|
480
|
+
'stmt': [
|
481
|
+
(r'\{', Punctuation, 'block'),
|
482
|
+
(r';', Punctuation, '#pop'),
|
483
|
+
include('base'),
|
484
|
+
],
|
485
|
+
'base': [
|
486
|
+
(r'#.*\n', Comment.Single),
|
487
|
+
(r'on|off', Name.Constant),
|
488
|
+
(r'\$[^\s;#()]+', Name.Variable),
|
489
|
+
(r'([a-z0-9.-]+)(:)([0-9]+)',
|
490
|
+
bygroups(Name, Punctuation, Number.Integer)),
|
491
|
+
(r'[a-z-]+/[a-z-+]+', String), # mimetype
|
492
|
+
# (r'[a-zA-Z._-]+', Keyword),
|
493
|
+
(r'[0-9]+[km]?\b', Number.Integer),
|
494
|
+
(r'(~)(\s*)([^\s{]+)', bygroups(Punctuation, Text, String.Regex)),
|
495
|
+
(r'[:=~]', Punctuation),
|
496
|
+
(r'[^\s;#{}$]+', String), # catch all
|
497
|
+
(r'/[^\s;#]*', Name), # pathname
|
498
|
+
(r'\s+', Text),
|
499
|
+
(r'[$;]', Text), # leftover characters
|
500
|
+
],
|
501
|
+
}
|
502
|
+
|
503
|
+
|
504
|
+
class LighttpdConfLexer(RegexLexer):
|
505
|
+
"""
|
506
|
+
Lexer for `Lighttpd <http://lighttpd.net/>`_ configuration files.
|
507
|
+
|
508
|
+
.. versionadded:: 0.11
|
509
|
+
"""
|
510
|
+
name = 'Lighttpd configuration file'
|
511
|
+
aliases = ['lighty', 'lighttpd']
|
512
|
+
filenames = []
|
513
|
+
mimetypes = ['text/x-lighttpd-conf']
|
514
|
+
|
515
|
+
tokens = {
|
516
|
+
'root': [
|
517
|
+
(r'#.*\n', Comment.Single),
|
518
|
+
(r'/\S*', Name), # pathname
|
519
|
+
(r'[a-zA-Z._-]+', Keyword),
|
520
|
+
(r'\d+\.\d+\.\d+\.\d+(?:/\d+)?', Number),
|
521
|
+
(r'[0-9]+', Number),
|
522
|
+
(r'=>|=~|\+=|==|=|\+', Operator),
|
523
|
+
(r'\$[A-Z]+', Name.Builtin),
|
524
|
+
(r'[(){}\[\],]', Punctuation),
|
525
|
+
(r'"([^"\\]*(?:\\.[^"\\]*)*)"', String.Double),
|
526
|
+
(r'\s+', Text),
|
527
|
+
],
|
528
|
+
|
529
|
+
}
|
530
|
+
|
531
|
+
|
532
|
+
class DockerLexer(RegexLexer):
|
533
|
+
"""
|
534
|
+
Lexer for `Docker <http://docker.io>`_ configuration files.
|
535
|
+
|
536
|
+
.. versionadded:: 2.0
|
537
|
+
"""
|
538
|
+
name = 'Docker'
|
539
|
+
aliases = ['docker', 'dockerfile']
|
540
|
+
filenames = ['Dockerfile', '*.docker']
|
541
|
+
mimetypes = ['text/x-dockerfile-config']
|
542
|
+
|
543
|
+
_keywords = (r'(?:MAINTAINER|EXPOSE|WORKDIR|USER|STOPSIGNAL)')
|
544
|
+
_bash_keywords = (r'(?:RUN|CMD|ENTRYPOINT|ENV|ARG|LABEL|ADD|COPY)')
|
545
|
+
_lb = r'(?:\s*\\?\s*)' # dockerfile line break regex
|
546
|
+
flags = re.IGNORECASE | re.MULTILINE
|
547
|
+
|
548
|
+
tokens = {
|
549
|
+
'root': [
|
550
|
+
(r'#.*', Comment),
|
551
|
+
(r'(FROM)([ \t]*)(\S*)([ \t]*)(?:(AS)([ \t]*)(\S*))?',
|
552
|
+
bygroups(Keyword, Text, String, Text, Keyword, Text, String)),
|
553
|
+
(r'(ONBUILD)(%s)' % (_lb,), bygroups(Keyword, using(BashLexer))),
|
554
|
+
(r'(HEALTHCHECK)((%s--\w+=\w+%s)*)' % (_lb, _lb),
|
555
|
+
bygroups(Keyword, using(BashLexer))),
|
556
|
+
(r'(VOLUME|ENTRYPOINT|CMD|SHELL)(%s)(\[.*?\])' % (_lb,),
|
557
|
+
bygroups(Keyword, using(BashLexer), using(JsonLexer))),
|
558
|
+
(r'(LABEL|ENV|ARG)((%s\w+=\w+%s)*)' % (_lb, _lb),
|
559
|
+
bygroups(Keyword, using(BashLexer))),
|
560
|
+
(r'(%s|VOLUME)\b(.*)' % (_keywords), bygroups(Keyword, String)),
|
561
|
+
(r'(%s)' % (_bash_keywords,), Keyword),
|
562
|
+
(r'(.*\\\n)*.+', using(BashLexer)),
|
563
|
+
]
|
564
|
+
}
|
565
|
+
|
566
|
+
|
567
|
+
class TerraformLexer(RegexLexer):
|
568
|
+
"""
|
569
|
+
Lexer for `terraformi .tf files <https://www.terraform.io/>`_.
|
570
|
+
|
571
|
+
.. versionadded:: 2.1
|
572
|
+
"""
|
573
|
+
|
574
|
+
name = 'Terraform'
|
575
|
+
aliases = ['terraform', 'tf']
|
576
|
+
filenames = ['*.tf']
|
577
|
+
mimetypes = ['application/x-tf', 'application/x-terraform']
|
578
|
+
|
579
|
+
embedded_keywords = ('ingress', 'egress', 'listener', 'default',
|
580
|
+
'connection', 'alias', 'terraform', 'tags', 'vars',
|
581
|
+
'config', 'lifecycle', 'timeouts')
|
582
|
+
|
583
|
+
tokens = {
|
584
|
+
'root': [
|
585
|
+
include('string'),
|
586
|
+
include('punctuation'),
|
587
|
+
include('curly'),
|
588
|
+
include('basic'),
|
589
|
+
include('whitespace'),
|
590
|
+
(r'[0-9]+', Number),
|
591
|
+
],
|
592
|
+
'basic': [
|
593
|
+
(words(('true', 'false'), prefix=r'\b', suffix=r'\b'), Keyword.Type),
|
594
|
+
(r'\s*/\*', Comment.Multiline, 'comment'),
|
595
|
+
(r'\s*#.*\n', Comment.Single),
|
596
|
+
(r'(.*?)(\s*)(=)', bygroups(Name.Attribute, Text, Operator)),
|
597
|
+
(words(('variable', 'resource', 'provider', 'provisioner', 'module',
|
598
|
+
'backend', 'data', 'output'), prefix=r'\b', suffix=r'\b'),
|
599
|
+
Keyword.Reserved, 'function'),
|
600
|
+
(words(embedded_keywords, prefix=r'\b', suffix=r'\b'),
|
601
|
+
Keyword.Declaration),
|
602
|
+
(r'\$\{', String.Interpol, 'var_builtin'),
|
603
|
+
],
|
604
|
+
'function': [
|
605
|
+
(r'(\s+)(".*")(\s+)', bygroups(Text, String, Text)),
|
606
|
+
include('punctuation'),
|
607
|
+
include('curly'),
|
608
|
+
],
|
609
|
+
'var_builtin': [
|
610
|
+
(r'\$\{', String.Interpol, '#push'),
|
611
|
+
(words(('concat', 'file', 'join', 'lookup', 'element'),
|
612
|
+
prefix=r'\b', suffix=r'\b'), Name.Builtin),
|
613
|
+
include('string'),
|
614
|
+
include('punctuation'),
|
615
|
+
(r'\s+', Text),
|
616
|
+
(r'\}', String.Interpol, '#pop'),
|
617
|
+
],
|
618
|
+
'string': [
|
619
|
+
(r'(".*")', bygroups(String.Double)),
|
620
|
+
],
|
621
|
+
'punctuation': [
|
622
|
+
(r'[\[\](),.]', Punctuation),
|
623
|
+
],
|
624
|
+
# Keep this seperate from punctuation - we sometimes want to use different
|
625
|
+
# Tokens for { }
|
626
|
+
'curly': [
|
627
|
+
(r'\{', Text.Punctuation),
|
628
|
+
(r'\}', Text.Punctuation),
|
629
|
+
],
|
630
|
+
'comment': [
|
631
|
+
(r'[^*/]', Comment.Multiline),
|
632
|
+
(r'/\*', Comment.Multiline, '#push'),
|
633
|
+
(r'\*/', Comment.Multiline, '#pop'),
|
634
|
+
(r'[*/]', Comment.Multiline)
|
635
|
+
],
|
636
|
+
'whitespace': [
|
637
|
+
(r'\n', Text),
|
638
|
+
(r'\s+', Text),
|
639
|
+
(r'\\\n', Text),
|
640
|
+
],
|
641
|
+
}
|
642
|
+
|
643
|
+
|
644
|
+
class TermcapLexer(RegexLexer):
|
645
|
+
"""
|
646
|
+
Lexer for termcap database source.
|
647
|
+
|
648
|
+
This is very simple and minimal.
|
649
|
+
|
650
|
+
.. versionadded:: 2.1
|
651
|
+
"""
|
652
|
+
name = 'Termcap'
|
653
|
+
aliases = ['termcap']
|
654
|
+
filenames = ['termcap', 'termcap.src']
|
655
|
+
mimetypes = []
|
656
|
+
|
657
|
+
# NOTE:
|
658
|
+
# * multiline with trailing backslash
|
659
|
+
# * separator is ':'
|
660
|
+
# * to embed colon as data, we must use \072
|
661
|
+
# * space after separator is not allowed (mayve)
|
662
|
+
tokens = {
|
663
|
+
'root': [
|
664
|
+
(r'^#.*$', Comment),
|
665
|
+
(r'^[^\s#:|]+', Name.Tag, 'names'),
|
666
|
+
],
|
667
|
+
'names': [
|
668
|
+
(r'\n', Text, '#pop'),
|
669
|
+
(r':', Punctuation, 'defs'),
|
670
|
+
(r'\|', Punctuation),
|
671
|
+
(r'[^:|]+', Name.Attribute),
|
672
|
+
],
|
673
|
+
'defs': [
|
674
|
+
(r'\\\n[ \t]*', Text),
|
675
|
+
(r'\n[ \t]*', Text, '#pop:2'),
|
676
|
+
(r'(#)([0-9]+)', bygroups(Operator, Number)),
|
677
|
+
(r'=', Operator, 'data'),
|
678
|
+
(r':', Punctuation),
|
679
|
+
(r'[^\s:=#]+', Name.Class),
|
680
|
+
],
|
681
|
+
'data': [
|
682
|
+
(r'\\072', Literal),
|
683
|
+
(r':', Punctuation, '#pop'),
|
684
|
+
(r'[^:\\]+', Literal), # for performance
|
685
|
+
(r'.', Literal),
|
686
|
+
],
|
687
|
+
}
|
688
|
+
|
689
|
+
|
690
|
+
class TerminfoLexer(RegexLexer):
|
691
|
+
"""
|
692
|
+
Lexer for terminfo database source.
|
693
|
+
|
694
|
+
This is very simple and minimal.
|
695
|
+
|
696
|
+
.. versionadded:: 2.1
|
697
|
+
"""
|
698
|
+
name = 'Terminfo'
|
699
|
+
aliases = ['terminfo']
|
700
|
+
filenames = ['terminfo', 'terminfo.src']
|
701
|
+
mimetypes = []
|
702
|
+
|
703
|
+
# NOTE:
|
704
|
+
# * multiline with leading whitespace
|
705
|
+
# * separator is ','
|
706
|
+
# * to embed comma as data, we can use \,
|
707
|
+
# * space after separator is allowed
|
708
|
+
tokens = {
|
709
|
+
'root': [
|
710
|
+
(r'^#.*$', Comment),
|
711
|
+
(r'^[^\s#,|]+', Name.Tag, 'names'),
|
712
|
+
],
|
713
|
+
'names': [
|
714
|
+
(r'\n', Text, '#pop'),
|
715
|
+
(r'(,)([ \t]*)', bygroups(Punctuation, Text), 'defs'),
|
716
|
+
(r'\|', Punctuation),
|
717
|
+
(r'[^,|]+', Name.Attribute),
|
718
|
+
],
|
719
|
+
'defs': [
|
720
|
+
(r'\n[ \t]+', Text),
|
721
|
+
(r'\n', Text, '#pop:2'),
|
722
|
+
(r'(#)([0-9]+)', bygroups(Operator, Number)),
|
723
|
+
(r'=', Operator, 'data'),
|
724
|
+
(r'(,)([ \t]*)', bygroups(Punctuation, Text)),
|
725
|
+
(r'[^\s,=#]+', Name.Class),
|
726
|
+
],
|
727
|
+
'data': [
|
728
|
+
(r'\\[,\\]', Literal),
|
729
|
+
(r'(,)([ \t]*)', bygroups(Punctuation, Text), '#pop'),
|
730
|
+
(r'[^\\,]+', Literal), # for performance
|
731
|
+
(r'.', Literal),
|
732
|
+
],
|
733
|
+
}
|
734
|
+
|
735
|
+
|
736
|
+
class PkgConfigLexer(RegexLexer):
|
737
|
+
"""
|
738
|
+
Lexer for `pkg-config
|
739
|
+
<http://www.freedesktop.org/wiki/Software/pkg-config/>`_
|
740
|
+
(see also `manual page <http://linux.die.net/man/1/pkg-config>`_).
|
741
|
+
|
742
|
+
.. versionadded:: 2.1
|
743
|
+
"""
|
744
|
+
|
745
|
+
name = 'PkgConfig'
|
746
|
+
aliases = ['pkgconfig']
|
747
|
+
filenames = ['*.pc']
|
748
|
+
mimetypes = []
|
749
|
+
|
750
|
+
tokens = {
|
751
|
+
'root': [
|
752
|
+
(r'#.*$', Comment.Single),
|
753
|
+
|
754
|
+
# variable definitions
|
755
|
+
(r'^(\w+)(=)', bygroups(Name.Attribute, Operator)),
|
756
|
+
|
757
|
+
# keyword lines
|
758
|
+
(r'^([\w.]+)(:)',
|
759
|
+
bygroups(Name.Tag, Punctuation), 'spvalue'),
|
760
|
+
|
761
|
+
# variable references
|
762
|
+
include('interp'),
|
763
|
+
|
764
|
+
# fallback
|
765
|
+
(r'[^${}#=:\n.]+', Text),
|
766
|
+
(r'.', Text),
|
767
|
+
],
|
768
|
+
'interp': [
|
769
|
+
# you can escape literal "$" as "$$"
|
770
|
+
(r'\$\$', Text),
|
771
|
+
|
772
|
+
# variable references
|
773
|
+
(r'\$\{', String.Interpol, 'curly'),
|
774
|
+
],
|
775
|
+
'curly': [
|
776
|
+
(r'\}', String.Interpol, '#pop'),
|
777
|
+
(r'\w+', Name.Attribute),
|
778
|
+
],
|
779
|
+
'spvalue': [
|
780
|
+
include('interp'),
|
781
|
+
|
782
|
+
(r'#.*$', Comment.Single, '#pop'),
|
783
|
+
(r'\n', Text, '#pop'),
|
784
|
+
|
785
|
+
# fallback
|
786
|
+
(r'[^${}#\n]+', Text),
|
787
|
+
(r'.', Text),
|
788
|
+
],
|
789
|
+
}
|
790
|
+
|
791
|
+
|
792
|
+
class PacmanConfLexer(RegexLexer):
|
793
|
+
"""
|
794
|
+
Lexer for `pacman.conf
|
795
|
+
<https://www.archlinux.org/pacman/pacman.conf.5.html>`_.
|
796
|
+
|
797
|
+
Actually, IniLexer works almost fine for this format,
|
798
|
+
but it yield error token. It is because pacman.conf has
|
799
|
+
a form without assignment like:
|
800
|
+
|
801
|
+
UseSyslog
|
802
|
+
Color
|
803
|
+
TotalDownload
|
804
|
+
CheckSpace
|
805
|
+
VerbosePkgLists
|
806
|
+
|
807
|
+
These are flags to switch on.
|
808
|
+
|
809
|
+
.. versionadded:: 2.1
|
810
|
+
"""
|
811
|
+
|
812
|
+
name = 'PacmanConf'
|
813
|
+
aliases = ['pacmanconf']
|
814
|
+
filenames = ['pacman.conf']
|
815
|
+
mimetypes = []
|
816
|
+
|
817
|
+
tokens = {
|
818
|
+
'root': [
|
819
|
+
# comment
|
820
|
+
(r'#.*$', Comment.Single),
|
821
|
+
|
822
|
+
# section header
|
823
|
+
(r'^\s*\[.*?\]\s*$', Keyword),
|
824
|
+
|
825
|
+
# variable definitions
|
826
|
+
# (Leading space is allowed...)
|
827
|
+
(r'(\w+)(\s*)(=)',
|
828
|
+
bygroups(Name.Attribute, Text, Operator)),
|
829
|
+
|
830
|
+
# flags to on
|
831
|
+
(r'^(\s*)(\w+)(\s*)$',
|
832
|
+
bygroups(Text, Name.Attribute, Text)),
|
833
|
+
|
834
|
+
# built-in special values
|
835
|
+
(words((
|
836
|
+
'$repo', # repository
|
837
|
+
'$arch', # architecture
|
838
|
+
'%o', # outfile
|
839
|
+
'%u', # url
|
840
|
+
), suffix=r'\b'),
|
841
|
+
Name.Variable),
|
842
|
+
|
843
|
+
# fallback
|
844
|
+
(r'.', Text),
|
845
|
+
],
|
846
|
+
}
|
847
|
+
|
848
|
+
|
849
|
+
class AugeasLexer(RegexLexer):
|
850
|
+
"""
|
851
|
+
Lexer for `Augeas <http://augeas.net>`_.
|
852
|
+
|
853
|
+
.. versionadded:: 2.4
|
854
|
+
"""
|
855
|
+
name = 'Augeas'
|
856
|
+
aliases = ['augeas']
|
857
|
+
filenames = ['*.aug']
|
858
|
+
|
859
|
+
tokens = {
|
860
|
+
'root': [
|
861
|
+
(r'(module)(\s*)([^\s=]+)', bygroups(Keyword.Namespace, Text, Name.Namespace)),
|
862
|
+
(r'(let)(\s*)([^\s=]+)', bygroups(Keyword.Declaration, Text, Name.Variable)),
|
863
|
+
(r'(del|store|value|counter|seq|key|label|autoload|incl|excl|transform|test|get|put)(\s+)', bygroups(Name.Builtin, Text)),
|
864
|
+
(r'(\()([^:]+)(\:)(unit|string|regexp|lens|tree|filter)(\))', bygroups(Punctuation, Name.Variable, Punctuation, Keyword.Type, Punctuation)),
|
865
|
+
(r'\(\*', Comment.Multiline, 'comment'),
|
866
|
+
(r'[*+\-.;=?|]', Operator),
|
867
|
+
(r'[()\[\]{}]', Operator),
|
868
|
+
(r'"', String.Double, 'string'),
|
869
|
+
(r'\/', String.Regex, 'regex'),
|
870
|
+
(r'([A-Z]\w*)(\.)(\w+)', bygroups(Name.Namespace, Punctuation, Name.Variable)),
|
871
|
+
(r'.', Name.Variable),
|
872
|
+
(r'\s', Text),
|
873
|
+
],
|
874
|
+
'string': [
|
875
|
+
(r'\\.', String.Escape),
|
876
|
+
(r'[^"]', String.Double),
|
877
|
+
(r'"', String.Double, '#pop'),
|
878
|
+
],
|
879
|
+
'regex': [
|
880
|
+
(r'\\.', String.Escape),
|
881
|
+
(r'[^/]', String.Regex),
|
882
|
+
(r'\/', String.Regex, '#pop'),
|
883
|
+
],
|
884
|
+
'comment': [
|
885
|
+
(r'[^*)]', Comment.Multiline),
|
886
|
+
(r'\(\*', Comment.Multiline, '#push'),
|
887
|
+
(r'\*\)', Comment.Multiline, '#pop'),
|
888
|
+
(r'[)*]', Comment.Multiline)
|
889
|
+
],
|
890
|
+
}
|
891
|
+
|
892
|
+
|
893
|
+
class TOMLLexer(RegexLexer):
|
894
|
+
"""
|
895
|
+
Lexer for `TOML <https://github.com/toml-lang/toml>`_, a simple language
|
896
|
+
for config files.
|
897
|
+
|
898
|
+
.. versionadded:: 2.4
|
899
|
+
"""
|
900
|
+
|
901
|
+
name = 'TOML'
|
902
|
+
aliases = ['toml']
|
903
|
+
filenames = ['*.toml', 'Pipfile', 'poetry.lock']
|
904
|
+
|
905
|
+
tokens = {
|
906
|
+
'root': [
|
907
|
+
|
908
|
+
# Basics, comments, strings
|
909
|
+
(r'\s+', Text),
|
910
|
+
(r'#.*?$', Comment.Single),
|
911
|
+
# Basic string
|
912
|
+
(r'"(\\\\|\\"|[^"])*"', String),
|
913
|
+
# Literal string
|
914
|
+
(r'\'\'\'(.*)\'\'\'', String),
|
915
|
+
(r'\'[^\']*\'', String),
|
916
|
+
(r'(true|false)$', Keyword.Constant),
|
917
|
+
(r'[a-zA-Z_][\w\-]*', Name),
|
918
|
+
|
919
|
+
(r'\[.*?\]$', Keyword),
|
920
|
+
# Datetime
|
921
|
+
# TODO this needs to be expanded, as TOML is rather flexible:
|
922
|
+
# https://github.com/toml-lang/toml#offset-date-time
|
923
|
+
(r'\d{4}-\d{2}-\d{2}(?:T| )\d{2}:\d{2}:\d{2}(?:Z|[-+]\d{2}:\d{2})', Number.Integer),
|
924
|
+
|
925
|
+
# Numbers
|
926
|
+
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float),
|
927
|
+
(r'\d+[eE][+-]?[0-9]+j?', Number.Float),
|
928
|
+
# Handle +-inf, +-infinity, +-nan
|
929
|
+
(r'[+-]?(?:(inf(?:inity)?)|nan)', Number.Float),
|
930
|
+
(r'[+-]?\d+', Number.Integer),
|
931
|
+
|
932
|
+
# Punctuation
|
933
|
+
(r'[]{}:(),;[]', Punctuation),
|
934
|
+
(r'\.', Punctuation),
|
935
|
+
|
936
|
+
# Operators
|
937
|
+
(r'=', Operator)
|
938
|
+
|
939
|
+
]
|
940
|
+
}
|
941
|
+
|
942
|
+
|
943
|
+
class SingularityLexer(RegexLexer):
|
944
|
+
"""
|
945
|
+
Lexer for `Singularity definition files
|
946
|
+
<https://www.sylabs.io/guides/3.0/user-guide/definition_files.html>`_.
|
947
|
+
|
948
|
+
.. versionadded:: 2.6
|
949
|
+
"""
|
950
|
+
|
951
|
+
name = 'Singularity'
|
952
|
+
aliases = ['singularity']
|
953
|
+
filenames = ['*.def', 'Singularity']
|
954
|
+
flags = re.IGNORECASE | re.MULTILINE | re.DOTALL
|
955
|
+
|
956
|
+
_headers = r'^(\s*)(bootstrap|from|osversion|mirrorurl|include|registry|namespace|includecmd)(:)'
|
957
|
+
_section = r'^%(?:pre|post|setup|environment|help|labels|test|runscript|files|startscript)\b'
|
958
|
+
_appsect = r'^%app(?:install|help|run|labels|env|test|files)\b'
|
959
|
+
|
960
|
+
tokens = {
|
961
|
+
'root': [
|
962
|
+
(_section, Generic.Heading, 'script'),
|
963
|
+
(_appsect, Generic.Heading, 'script'),
|
964
|
+
(_headers, bygroups(Text, Keyword, Text)),
|
965
|
+
(r'\s*#.*?\n', Comment),
|
966
|
+
(r'\b(([0-9]+\.?[0-9]*)|(\.[0-9]+))\b', Number),
|
967
|
+
(r'(?!^\s*%).', Text),
|
968
|
+
],
|
969
|
+
'script': [
|
970
|
+
(r'(.+?(?=^\s*%))|(.*)', using(BashLexer), '#pop'),
|
971
|
+
],
|
972
|
+
}
|
973
|
+
|
974
|
+
def analyse_text(text):
|
975
|
+
"""This is a quite simple script file, but there are a few keywords
|
976
|
+
which seem unique to this language."""
|
977
|
+
result = 0
|
978
|
+
if re.search(r'\b(?:osversion|includecmd|mirrorurl)\b', text, re.IGNORECASE):
|
979
|
+
result += 0.5
|
980
|
+
|
981
|
+
if re.search(SingularityLexer._section[1:], text):
|
982
|
+
result += 0.49
|
983
|
+
|
984
|
+
return result
|