pygments.rb 0.6.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +11 -0
- data/README.md +6 -6
- data/Rakefile +2 -1
- data/cache-lexers.rb +1 -1
- data/circle.yml +7 -0
- data/lib/pygments/lexer.rb +3 -3
- data/lib/pygments/popen.rb +67 -30
- data/lib/pygments/version.rb +1 -1
- data/pygments.rb.gemspec +2 -1
- data/test/test_pygments.rb +16 -16
- data/vendor/pygments-main/AUTHORS +54 -8
- data/vendor/pygments-main/CHANGES +247 -25
- data/vendor/pygments-main/LICENSE +1 -1
- data/vendor/pygments-main/Makefile +15 -6
- data/vendor/pygments-main/README.rst +39 -0
- data/vendor/pygments-main/REVISION +1 -1
- data/vendor/pygments-main/TODO +0 -3
- data/vendor/pygments-main/doc/_themes/pygments14/layout.html +1 -1
- data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +1 -1
- data/vendor/pygments-main/doc/conf.py +3 -11
- data/vendor/pygments-main/doc/docs/api.rst +15 -0
- data/vendor/pygments-main/doc/docs/cmdline.rst +6 -2
- data/vendor/pygments-main/doc/docs/filterdevelopment.rst +4 -3
- data/vendor/pygments-main/doc/docs/integrate.rst +11 -15
- data/vendor/pygments-main/doc/docs/java.rst +7 -7
- data/vendor/pygments-main/doc/docs/lexerdevelopment.rst +258 -171
- data/vendor/pygments-main/doc/docs/lexers.rst +2 -2
- data/vendor/pygments-main/doc/docs/styles.rst +58 -0
- data/vendor/pygments-main/doc/docs/tokens.rst +22 -2
- data/vendor/pygments-main/doc/docs/unicode.rst +15 -7
- data/vendor/pygments-main/doc/faq.rst +17 -21
- data/vendor/pygments-main/doc/index.rst +12 -11
- data/vendor/pygments-main/doc/languages.rst +10 -7
- data/vendor/pygments-main/external/autopygmentize +9 -6
- data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +70 -52
- data/vendor/pygments-main/external/markdown-processor.py +1 -1
- data/vendor/pygments-main/external/moin-parser.py +1 -1
- data/vendor/pygments-main/external/rst-directive.py +1 -1
- data/vendor/pygments-main/pygmentize +2 -1
- data/vendor/pygments-main/pygments/__init__.py +14 -15
- data/vendor/pygments-main/pygments/cmdline.py +188 -113
- data/vendor/pygments-main/pygments/console.py +13 -13
- data/vendor/pygments-main/pygments/filter.py +7 -7
- data/vendor/pygments-main/pygments/filters/__init__.py +24 -32
- data/vendor/pygments-main/pygments/formatter.py +5 -5
- data/vendor/pygments-main/pygments/formatters/__init__.py +92 -44
- data/vendor/pygments-main/pygments/formatters/_mapping.py +51 -69
- data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
- data/vendor/pygments-main/pygments/formatters/html.py +63 -51
- data/vendor/pygments-main/pygments/formatters/img.py +25 -22
- data/vendor/pygments-main/pygments/formatters/irc.py +182 -0
- data/vendor/pygments-main/pygments/formatters/latex.py +34 -22
- data/vendor/pygments-main/pygments/formatters/other.py +5 -7
- data/vendor/pygments-main/pygments/formatters/rtf.py +28 -31
- data/vendor/pygments-main/pygments/formatters/svg.py +1 -2
- data/vendor/pygments-main/pygments/formatters/terminal.py +29 -45
- data/vendor/pygments-main/pygments/formatters/terminal256.py +118 -31
- data/vendor/pygments-main/pygments/lexer.py +120 -34
- data/vendor/pygments-main/pygments/lexers/__init__.py +85 -53
- data/vendor/pygments-main/pygments/lexers/{_asybuiltins.py → _asy_builtins.py} +7 -7
- data/vendor/pygments-main/pygments/lexers/{_clbuiltins.py → _cl_builtins.py} +17 -17
- data/vendor/pygments-main/pygments/lexers/_cocoa_builtins.py +72 -0
- data/vendor/pygments-main/pygments/lexers/_csound_builtins.py +1346 -0
- data/vendor/pygments-main/pygments/lexers/{_lassobuiltins.py → _lasso_builtins.py} +4699 -4561
- data/vendor/pygments-main/pygments/lexers/{_luabuiltins.py → _lua_builtins.py} +91 -51
- data/vendor/pygments-main/pygments/lexers/_mapping.py +342 -242
- data/vendor/pygments-main/pygments/lexers/_mql_builtins.py +1172 -0
- data/vendor/pygments-main/pygments/lexers/_openedge_builtins.py +2547 -0
- data/vendor/pygments-main/pygments/lexers/{_phpbuiltins.py → _php_builtins.py} +350 -353
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +600 -212
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +3084 -30
- data/vendor/pygments-main/pygments/lexers/_sourcemod_builtins.py +1163 -0
- data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +91 -13
- data/vendor/pygments-main/pygments/lexers/_stata_builtins.py +419 -0
- data/vendor/pygments-main/pygments/lexers/_tsql_builtins.py +1004 -0
- data/vendor/pygments-main/pygments/lexers/_vim_builtins.py +1939 -0
- data/vendor/pygments-main/pygments/lexers/actionscript.py +240 -0
- data/vendor/pygments-main/pygments/lexers/agile.py +14 -2542
- data/vendor/pygments-main/pygments/lexers/algebra.py +221 -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/asm.py +276 -81
- data/vendor/pygments-main/pygments/lexers/automation.py +374 -0
- data/vendor/pygments-main/pygments/lexers/basic.py +500 -0
- data/vendor/pygments-main/pygments/lexers/bibtex.py +156 -0
- data/vendor/pygments-main/pygments/lexers/business.py +594 -0
- data/vendor/pygments-main/pygments/lexers/c_cpp.py +252 -0
- data/vendor/pygments-main/pygments/lexers/c_like.py +541 -0
- data/vendor/pygments-main/pygments/lexers/capnproto.py +79 -0
- data/vendor/pygments-main/pygments/lexers/chapel.py +101 -0
- data/vendor/pygments-main/pygments/lexers/clean.py +288 -0
- data/vendor/pygments-main/pygments/lexers/compiled.py +24 -5182
- data/vendor/pygments-main/pygments/lexers/configs.py +833 -0
- data/vendor/pygments-main/pygments/lexers/console.py +114 -0
- data/vendor/pygments-main/pygments/lexers/crystal.py +384 -0
- data/vendor/pygments-main/pygments/lexers/csound.py +366 -0
- data/vendor/pygments-main/pygments/lexers/css.py +689 -0
- data/vendor/pygments-main/pygments/lexers/d.py +251 -0
- data/vendor/pygments-main/pygments/lexers/dalvik.py +6 -6
- data/vendor/pygments-main/pygments/lexers/data.py +555 -0
- data/vendor/pygments-main/pygments/lexers/diff.py +165 -0
- data/vendor/pygments-main/pygments/lexers/dotnet.py +96 -88
- data/vendor/pygments-main/pygments/lexers/dsls.py +878 -0
- data/vendor/pygments-main/pygments/lexers/dylan.py +289 -0
- data/vendor/pygments-main/pygments/lexers/ecl.py +125 -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/erlang.py +533 -0
- data/vendor/pygments-main/pygments/lexers/esoteric.py +275 -0
- data/vendor/pygments-main/pygments/lexers/ezhil.py +68 -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/forth.py +177 -0
- data/vendor/pygments-main/pygments/lexers/fortran.py +205 -0
- data/vendor/pygments-main/pygments/lexers/foxpro.py +1 -1
- data/vendor/pygments-main/pygments/lexers/functional.py +11 -3661
- data/vendor/pygments-main/pygments/lexers/go.py +101 -0
- data/vendor/pygments-main/pygments/lexers/grammar_notation.py +213 -0
- data/vendor/pygments-main/pygments/lexers/graph.py +7 -8
- data/vendor/pygments-main/pygments/lexers/graphics.py +553 -0
- data/vendor/pygments-main/pygments/lexers/haskell.py +840 -0
- data/vendor/pygments-main/pygments/lexers/haxe.py +936 -0
- data/vendor/pygments-main/pygments/lexers/hdl.py +172 -145
- data/vendor/pygments-main/pygments/lexers/hexdump.py +97 -0
- data/vendor/pygments-main/pygments/lexers/html.py +602 -0
- data/vendor/pygments-main/pygments/lexers/idl.py +270 -0
- data/vendor/pygments-main/pygments/lexers/igor.py +288 -0
- data/vendor/pygments-main/pygments/lexers/inferno.py +3 -3
- data/vendor/pygments-main/pygments/lexers/installers.py +322 -0
- data/vendor/pygments-main/pygments/lexers/int_fiction.py +1343 -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 +1506 -0
- data/vendor/pygments-main/pygments/lexers/julia.py +333 -0
- data/vendor/pygments-main/pygments/lexers/jvm.py +232 -186
- data/vendor/pygments-main/pygments/lexers/lisp.py +2621 -0
- data/vendor/pygments-main/pygments/lexers/make.py +202 -0
- data/vendor/pygments-main/pygments/lexers/markup.py +595 -0
- data/vendor/pygments-main/pygments/lexers/math.py +11 -2276
- data/vendor/pygments-main/pygments/lexers/matlab.py +663 -0
- data/vendor/pygments-main/pygments/lexers/ml.py +769 -0
- data/vendor/pygments-main/pygments/lexers/modeling.py +358 -0
- data/vendor/pygments-main/pygments/lexers/modula2.py +1561 -0
- data/vendor/pygments-main/pygments/lexers/monte.py +203 -0
- data/vendor/pygments-main/pygments/lexers/ncl.py +1053 -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 +105 -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 +30 -4481
- data/vendor/pygments-main/pygments/lexers/parasail.py +79 -0
- data/vendor/pygments-main/pygments/lexers/parsers.py +171 -114
- data/vendor/pygments-main/pygments/lexers/pascal.py +644 -0
- data/vendor/pygments-main/pygments/lexers/pawn.py +199 -0
- data/vendor/pygments-main/pygments/lexers/perl.py +616 -0
- data/vendor/pygments-main/pygments/lexers/php.py +267 -0
- data/vendor/pygments-main/pygments/lexers/praat.py +294 -0
- data/vendor/pygments-main/pygments/lexers/prolog.py +306 -0
- data/vendor/pygments-main/pygments/lexers/python.py +938 -0
- data/vendor/pygments-main/pygments/lexers/qvt.py +152 -0
- data/vendor/pygments-main/pygments/lexers/r.py +453 -0
- data/vendor/pygments-main/pygments/lexers/rdf.py +195 -24
- 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/rnc.py +67 -0
- data/vendor/pygments-main/pygments/lexers/roboconf.py +82 -0
- data/vendor/pygments-main/pygments/lexers/{_robotframeworklexer.py → robotframework.py} +20 -18
- data/vendor/pygments-main/pygments/lexers/ruby.py +519 -0
- data/vendor/pygments-main/pygments/lexers/rust.py +209 -0
- data/vendor/pygments-main/pygments/lexers/sas.py +228 -0
- data/vendor/pygments-main/pygments/lexers/scripting.py +1222 -0
- data/vendor/pygments-main/pygments/lexers/shell.py +478 -115
- data/vendor/pygments-main/pygments/lexers/smalltalk.py +195 -0
- data/vendor/pygments-main/pygments/lexers/smv.py +75 -0
- data/vendor/pygments-main/pygments/lexers/snobol.py +83 -0
- data/vendor/pygments-main/pygments/lexers/special.py +6 -2
- data/vendor/pygments-main/pygments/lexers/sql.py +209 -120
- data/vendor/pygments-main/pygments/lexers/stata.py +106 -0
- data/vendor/pygments-main/pygments/lexers/supercollider.py +90 -0
- data/vendor/pygments-main/pygments/lexers/tcl.py +145 -0
- data/vendor/pygments-main/pygments/lexers/templates.py +282 -90
- data/vendor/pygments-main/pygments/lexers/testing.py +207 -0
- data/vendor/pygments-main/pygments/lexers/text.py +15 -2045
- data/vendor/pygments-main/pygments/lexers/textedit.py +169 -0
- data/vendor/pygments-main/pygments/lexers/textfmts.py +297 -0
- data/vendor/pygments-main/pygments/lexers/theorem.py +458 -0
- data/vendor/pygments-main/pygments/lexers/trafficscript.py +54 -0
- data/vendor/pygments-main/pygments/lexers/typoscript.py +225 -0
- data/vendor/pygments-main/pygments/lexers/urbi.py +133 -0
- data/vendor/pygments-main/pygments/lexers/varnish.py +190 -0
- data/vendor/pygments-main/pygments/lexers/verification.py +111 -0
- data/vendor/pygments-main/pygments/lexers/web.py +13 -4499
- data/vendor/pygments-main/pygments/lexers/webmisc.py +979 -0
- data/vendor/pygments-main/pygments/lexers/whiley.py +117 -0
- data/vendor/pygments-main/pygments/lexers/x10.py +69 -0
- data/vendor/pygments-main/pygments/modeline.py +5 -2
- data/vendor/pygments-main/pygments/plugin.py +1 -1
- data/vendor/pygments-main/pygments/regexopt.py +92 -0
- data/vendor/pygments-main/pygments/scanner.py +3 -2
- data/vendor/pygments-main/pygments/sphinxext.py +11 -6
- data/vendor/pygments-main/pygments/style.py +41 -4
- data/vendor/pygments-main/pygments/styles/__init__.py +5 -1
- data/vendor/pygments-main/pygments/styles/algol.py +63 -0
- data/vendor/pygments-main/pygments/styles/algol_nu.py +63 -0
- data/vendor/pygments-main/pygments/styles/arduino.py +98 -0
- 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/lovelace.py +97 -0
- data/vendor/pygments-main/pygments/styles/manni.py +1 -1
- data/vendor/pygments-main/pygments/styles/monokai.py +1 -1
- 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 +2 -2
- data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
- data/vendor/pygments-main/pygments/styles/sas.py +41 -0
- data/vendor/pygments-main/pygments/styles/stata.py +37 -0
- 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 +31 -16
- data/vendor/pygments-main/pygments/unistring.py +141 -65
- data/vendor/pygments-main/pygments/util.py +129 -33
- data/vendor/pygments-main/requirements.txt +5 -0
- data/vendor/pygments-main/scripts/check_sources.py +25 -40
- data/vendor/pygments-main/scripts/debug_lexer.py +246 -0
- data/vendor/pygments-main/scripts/find_error.py +1 -0
- data/vendor/pygments-main/scripts/get_vimkw.py +35 -4
- data/vendor/pygments-main/setup.cfg +3 -0
- data/vendor/pygments-main/setup.py +17 -30
- data/vendor/pygments-main/tox.ini +7 -0
- metadata +159 -387
- data/vendor/pygments-main/ez_setup.py +0 -382
- data/vendor/pygments-main/pygments/lexers/_cocoabuiltins.py +0 -73
- data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +0 -562
- data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +0 -1077
- data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +0 -13
- data/vendor/pygments-main/pygments/lexers/qbasic.py +0 -157
- data/vendor/pygments-main/scripts/find_codetags.py +0 -213
- data/vendor/pygments-main/scripts/find_error.py +0 -173
- data/vendor/pygments-main/tests/dtds/HTML4-f.dtd +0 -37
- data/vendor/pygments-main/tests/dtds/HTML4-s.dtd +0 -869
- data/vendor/pygments-main/tests/dtds/HTML4.dcl +0 -88
- data/vendor/pygments-main/tests/dtds/HTML4.dtd +0 -1092
- data/vendor/pygments-main/tests/dtds/HTML4.soc +0 -9
- data/vendor/pygments-main/tests/dtds/HTMLlat1.ent +0 -195
- data/vendor/pygments-main/tests/dtds/HTMLspec.ent +0 -77
- data/vendor/pygments-main/tests/dtds/HTMLsym.ent +0 -241
- data/vendor/pygments-main/tests/examplefiles/99_bottles_of_beer.chpl +0 -118
- data/vendor/pygments-main/tests/examplefiles/AcidStateAdvanced.hs +0 -209
- data/vendor/pygments-main/tests/examplefiles/AlternatingGroup.mu +0 -102
- data/vendor/pygments-main/tests/examplefiles/BOM.js +0 -1
- data/vendor/pygments-main/tests/examplefiles/CPDictionary.j +0 -611
- data/vendor/pygments-main/tests/examplefiles/Config.in.cache +0 -1973
- data/vendor/pygments-main/tests/examplefiles/Constants.mo +0 -158
- data/vendor/pygments-main/tests/examplefiles/DancingSudoku.lhs +0 -411
- data/vendor/pygments-main/tests/examplefiles/Deflate.fs +0 -578
- data/vendor/pygments-main/tests/examplefiles/Error.pmod +0 -38
- data/vendor/pygments-main/tests/examplefiles/Errors.scala +0 -18
- data/vendor/pygments-main/tests/examplefiles/FakeFile.pike +0 -360
- data/vendor/pygments-main/tests/examplefiles/Get-CommandDefinitionHtml.ps1 +0 -66
- data/vendor/pygments-main/tests/examplefiles/IPDispatchC.nc +0 -104
- data/vendor/pygments-main/tests/examplefiles/IPDispatchP.nc +0 -671
- data/vendor/pygments-main/tests/examplefiles/Intro.java +0 -1660
- data/vendor/pygments-main/tests/examplefiles/Makefile +0 -1131
- data/vendor/pygments-main/tests/examplefiles/Object.st +0 -4394
- data/vendor/pygments-main/tests/examplefiles/OrderedMap.hx +0 -584
- data/vendor/pygments-main/tests/examplefiles/RoleQ.pm6 +0 -23
- data/vendor/pygments-main/tests/examplefiles/SmallCheck.hs +0 -378
- data/vendor/pygments-main/tests/examplefiles/Sorting.mod +0 -470
- data/vendor/pygments-main/tests/examplefiles/Sudoku.lhs +0 -382
- data/vendor/pygments-main/tests/examplefiles/addressbook.proto +0 -30
- data/vendor/pygments-main/tests/examplefiles/antlr_ANTLRv3.g +0 -608
- data/vendor/pygments-main/tests/examplefiles/antlr_throws +0 -1
- data/vendor/pygments-main/tests/examplefiles/apache2.conf +0 -393
- data/vendor/pygments-main/tests/examplefiles/as3_test.as +0 -143
- data/vendor/pygments-main/tests/examplefiles/as3_test2.as +0 -46
- data/vendor/pygments-main/tests/examplefiles/as3_test3.as +0 -3
- data/vendor/pygments-main/tests/examplefiles/aspx-cs_example +0 -27
- data/vendor/pygments-main/tests/examplefiles/autoit_submit.au3 +0 -25
- data/vendor/pygments-main/tests/examplefiles/badcase.java +0 -2
- data/vendor/pygments-main/tests/examplefiles/batchfile.bat +0 -49
- data/vendor/pygments-main/tests/examplefiles/bigtest.nsi +0 -308
- data/vendor/pygments-main/tests/examplefiles/boot-9.scm +0 -1557
- data/vendor/pygments-main/tests/examplefiles/ca65_example +0 -284
- data/vendor/pygments-main/tests/examplefiles/cbmbas_example +0 -9
- data/vendor/pygments-main/tests/examplefiles/cells.ps +0 -515
- data/vendor/pygments-main/tests/examplefiles/ceval.c +0 -2604
- data/vendor/pygments-main/tests/examplefiles/cheetah_example.html +0 -13
- data/vendor/pygments-main/tests/examplefiles/classes.dylan +0 -125
- data/vendor/pygments-main/tests/examplefiles/clojure-weird-keywords.clj +0 -5
- data/vendor/pygments-main/tests/examplefiles/condensed_ruby.rb +0 -10
- data/vendor/pygments-main/tests/examplefiles/coq_RelationClasses +0 -447
- data/vendor/pygments-main/tests/examplefiles/core.cljs +0 -52
- data/vendor/pygments-main/tests/examplefiles/database.pytb +0 -20
- data/vendor/pygments-main/tests/examplefiles/de.MoinMoin.po +0 -2461
- data/vendor/pygments-main/tests/examplefiles/demo.ahk +0 -181
- data/vendor/pygments-main/tests/examplefiles/demo.cfm +0 -50
- data/vendor/pygments-main/tests/examplefiles/demo.hbs +0 -12
- data/vendor/pygments-main/tests/examplefiles/django_sample.html+django +0 -68
- data/vendor/pygments-main/tests/examplefiles/dwarf.cw +0 -17
- data/vendor/pygments-main/tests/examplefiles/ember.handlebars +0 -33
- data/vendor/pygments-main/tests/examplefiles/erl_session +0 -10
- data/vendor/pygments-main/tests/examplefiles/escape_semicolon.clj +0 -1
- data/vendor/pygments-main/tests/examplefiles/evil_regex.js +0 -48
- data/vendor/pygments-main/tests/examplefiles/example.Rd +0 -78
- data/vendor/pygments-main/tests/examplefiles/example.als +0 -217
- data/vendor/pygments-main/tests/examplefiles/example.bug +0 -54
- data/vendor/pygments-main/tests/examplefiles/example.c +0 -2080
- data/vendor/pygments-main/tests/examplefiles/example.ceylon +0 -52
- data/vendor/pygments-main/tests/examplefiles/example.chai +0 -6
- data/vendor/pygments-main/tests/examplefiles/example.clay +0 -33
- data/vendor/pygments-main/tests/examplefiles/example.cls +0 -15
- data/vendor/pygments-main/tests/examplefiles/example.cob +0 -3556
- data/vendor/pygments-main/tests/examplefiles/example.coffee +0 -27
- data/vendor/pygments-main/tests/examplefiles/example.cpp +0 -2363
- data/vendor/pygments-main/tests/examplefiles/example.e +0 -124
- data/vendor/pygments-main/tests/examplefiles/example.f90 +0 -8
- data/vendor/pygments-main/tests/examplefiles/example.feature +0 -16
- data/vendor/pygments-main/tests/examplefiles/example.gd +0 -23
- data/vendor/pygments-main/tests/examplefiles/example.gi +0 -64
- data/vendor/pygments-main/tests/examplefiles/example.groovy +0 -2
- data/vendor/pygments-main/tests/examplefiles/example.gs +0 -106
- data/vendor/pygments-main/tests/examplefiles/example.gst +0 -7
- data/vendor/pygments-main/tests/examplefiles/example.hs +0 -27
- data/vendor/pygments-main/tests/examplefiles/example.hx +0 -185
- data/vendor/pygments-main/tests/examplefiles/example.i6t +0 -32
- data/vendor/pygments-main/tests/examplefiles/example.i7x +0 -45
- data/vendor/pygments-main/tests/examplefiles/example.inf +0 -374
- data/vendor/pygments-main/tests/examplefiles/example.j +0 -564
- data/vendor/pygments-main/tests/examplefiles/example.jag +0 -48
- data/vendor/pygments-main/tests/examplefiles/example.java +0 -16
- data/vendor/pygments-main/tests/examplefiles/example.kal +0 -75
- data/vendor/pygments-main/tests/examplefiles/example.kt +0 -47
- data/vendor/pygments-main/tests/examplefiles/example.lagda +0 -19
- data/vendor/pygments-main/tests/examplefiles/example.liquid +0 -42
- data/vendor/pygments-main/tests/examplefiles/example.lua +0 -250
- data/vendor/pygments-main/tests/examplefiles/example.ma +0 -8
- data/vendor/pygments-main/tests/examplefiles/example.monkey +0 -152
- data/vendor/pygments-main/tests/examplefiles/example.moo +0 -26
- data/vendor/pygments-main/tests/examplefiles/example.moon +0 -629
- data/vendor/pygments-main/tests/examplefiles/example.mq4 +0 -187
- data/vendor/pygments-main/tests/examplefiles/example.mqh +0 -123
- data/vendor/pygments-main/tests/examplefiles/example.msc +0 -43
- data/vendor/pygments-main/tests/examplefiles/example.ni +0 -57
- data/vendor/pygments-main/tests/examplefiles/example.nim +0 -1010
- data/vendor/pygments-main/tests/examplefiles/example.nix +0 -80
- data/vendor/pygments-main/tests/examplefiles/example.ns2 +0 -69
- data/vendor/pygments-main/tests/examplefiles/example.pas +0 -2708
- data/vendor/pygments-main/tests/examplefiles/example.pp +0 -8
- data/vendor/pygments-main/tests/examplefiles/example.prg +0 -161
- data/vendor/pygments-main/tests/examplefiles/example.rb +0 -1852
- data/vendor/pygments-main/tests/examplefiles/example.red +0 -257
- data/vendor/pygments-main/tests/examplefiles/example.reds +0 -150
- data/vendor/pygments-main/tests/examplefiles/example.reg +0 -19
- data/vendor/pygments-main/tests/examplefiles/example.rexx +0 -50
- data/vendor/pygments-main/tests/examplefiles/example.rhtml +0 -561
- data/vendor/pygments-main/tests/examplefiles/example.rkt +0 -743
- data/vendor/pygments-main/tests/examplefiles/example.rpf +0 -4
- data/vendor/pygments-main/tests/examplefiles/example.sh +0 -22
- data/vendor/pygments-main/tests/examplefiles/example.sh-session +0 -19
- data/vendor/pygments-main/tests/examplefiles/example.shell-session +0 -45
- data/vendor/pygments-main/tests/examplefiles/example.slim +0 -31
- data/vendor/pygments-main/tests/examplefiles/example.sls +0 -51
- data/vendor/pygments-main/tests/examplefiles/example.sml +0 -156
- data/vendor/pygments-main/tests/examplefiles/example.snobol +0 -15
- data/vendor/pygments-main/tests/examplefiles/example.stan +0 -110
- data/vendor/pygments-main/tests/examplefiles/example.tea +0 -34
- data/vendor/pygments-main/tests/examplefiles/example.todotxt +0 -9
- data/vendor/pygments-main/tests/examplefiles/example.ts +0 -28
- data/vendor/pygments-main/tests/examplefiles/example.u +0 -548
- data/vendor/pygments-main/tests/examplefiles/example.weechatlog +0 -9
- data/vendor/pygments-main/tests/examplefiles/example.xhtml +0 -376
- data/vendor/pygments-main/tests/examplefiles/example.xtend +0 -34
- data/vendor/pygments-main/tests/examplefiles/example.yaml +0 -302
- data/vendor/pygments-main/tests/examplefiles/example2.aspx +0 -29
- data/vendor/pygments-main/tests/examplefiles/example2.msc +0 -79
- data/vendor/pygments-main/tests/examplefiles/exampleScript.cfc +0 -241
- data/vendor/pygments-main/tests/examplefiles/exampleTag.cfc +0 -18
- data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +0 -205
- data/vendor/pygments-main/tests/examplefiles/example_file.fy +0 -128
- data/vendor/pygments-main/tests/examplefiles/firefox.mak +0 -586
- data/vendor/pygments-main/tests/examplefiles/flipflop.sv +0 -19
- data/vendor/pygments-main/tests/examplefiles/foo.sce +0 -6
- data/vendor/pygments-main/tests/examplefiles/format.ml +0 -1213
- data/vendor/pygments-main/tests/examplefiles/fucked_up.rb +0 -77
- data/vendor/pygments-main/tests/examplefiles/function.mu +0 -1
- data/vendor/pygments-main/tests/examplefiles/functional.rst +0 -1472
- data/vendor/pygments-main/tests/examplefiles/garcia-wachs.kk +0 -133
- data/vendor/pygments-main/tests/examplefiles/genclass.clj +0 -510
- data/vendor/pygments-main/tests/examplefiles/genshi_example.xml+genshi +0 -193
- data/vendor/pygments-main/tests/examplefiles/genshitext_example.genshitext +0 -33
- data/vendor/pygments-main/tests/examplefiles/glsl.frag +0 -7
- data/vendor/pygments-main/tests/examplefiles/glsl.vert +0 -13
- data/vendor/pygments-main/tests/examplefiles/grammar-test.p6 +0 -22
- data/vendor/pygments-main/tests/examplefiles/hash_syntax.rb +0 -5
- data/vendor/pygments-main/tests/examplefiles/hello.at +0 -6
- data/vendor/pygments-main/tests/examplefiles/hello.golo +0 -5
- data/vendor/pygments-main/tests/examplefiles/hello.lsl +0 -12
- data/vendor/pygments-main/tests/examplefiles/hello.smali +0 -40
- data/vendor/pygments-main/tests/examplefiles/hello.sp +0 -9
- data/vendor/pygments-main/tests/examplefiles/html+php_faulty.php +0 -1
- data/vendor/pygments-main/tests/examplefiles/http_request_example +0 -15
- data/vendor/pygments-main/tests/examplefiles/http_response_example +0 -29
- data/vendor/pygments-main/tests/examplefiles/hybris_File.hy +0 -174
- data/vendor/pygments-main/tests/examplefiles/idl_sample.pro +0 -73
- data/vendor/pygments-main/tests/examplefiles/iex_example +0 -23
- data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +0 -71
- data/vendor/pygments-main/tests/examplefiles/intro.ik +0 -24
- data/vendor/pygments-main/tests/examplefiles/ints.php +0 -10
- data/vendor/pygments-main/tests/examplefiles/intsyn.fun +0 -675
- data/vendor/pygments-main/tests/examplefiles/intsyn.sig +0 -286
- data/vendor/pygments-main/tests/examplefiles/irb_heredoc +0 -8
- data/vendor/pygments-main/tests/examplefiles/irc.lsp +0 -214
- data/vendor/pygments-main/tests/examplefiles/java.properties +0 -16
- data/vendor/pygments-main/tests/examplefiles/jbst_example1.jbst +0 -28
- data/vendor/pygments-main/tests/examplefiles/jbst_example2.jbst +0 -45
- data/vendor/pygments-main/tests/examplefiles/jinjadesignerdoc.rst +0 -713
- data/vendor/pygments-main/tests/examplefiles/json.lasso +0 -301
- data/vendor/pygments-main/tests/examplefiles/json.lasso9 +0 -213
- data/vendor/pygments-main/tests/examplefiles/language.hy +0 -165
- data/vendor/pygments-main/tests/examplefiles/lighttpd_config.conf +0 -13
- data/vendor/pygments-main/tests/examplefiles/limbo.b +0 -456
- data/vendor/pygments-main/tests/examplefiles/linecontinuation.py +0 -47
- data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +0 -43
- data/vendor/pygments-main/tests/examplefiles/logos_example.xm +0 -28
- data/vendor/pygments-main/tests/examplefiles/ltmain.sh +0 -2849
- data/vendor/pygments-main/tests/examplefiles/main.cmake +0 -44
- data/vendor/pygments-main/tests/examplefiles/markdown.lsp +0 -679
- data/vendor/pygments-main/tests/examplefiles/matlab_noreturn +0 -3
- data/vendor/pygments-main/tests/examplefiles/matlab_sample +0 -30
- data/vendor/pygments-main/tests/examplefiles/matlabsession_sample.txt +0 -37
- data/vendor/pygments-main/tests/examplefiles/metagrammar.treetop +0 -455
- data/vendor/pygments-main/tests/examplefiles/minehunt.qml +0 -112
- data/vendor/pygments-main/tests/examplefiles/minimal.ns2 +0 -4
- data/vendor/pygments-main/tests/examplefiles/moin_SyntaxReference.txt +0 -340
- data/vendor/pygments-main/tests/examplefiles/multiline_regexes.rb +0 -38
- data/vendor/pygments-main/tests/examplefiles/nanomsg.intr +0 -95
- data/vendor/pygments-main/tests/examplefiles/nasm_aoutso.asm +0 -96
- data/vendor/pygments-main/tests/examplefiles/nasm_objexe.asm +0 -30
- data/vendor/pygments-main/tests/examplefiles/nemerle_sample.n +0 -87
- data/vendor/pygments-main/tests/examplefiles/nginx_nginx.conf +0 -118
- data/vendor/pygments-main/tests/examplefiles/numbers.c +0 -12
- data/vendor/pygments-main/tests/examplefiles/objc_example.m +0 -179
- data/vendor/pygments-main/tests/examplefiles/openedge_example +0 -34
- data/vendor/pygments-main/tests/examplefiles/pawn_example +0 -25
- data/vendor/pygments-main/tests/examplefiles/perl_misc +0 -62
- data/vendor/pygments-main/tests/examplefiles/perl_perl5db +0 -998
- data/vendor/pygments-main/tests/examplefiles/perl_regex-delims +0 -120
- data/vendor/pygments-main/tests/examplefiles/perlfunc.1 +0 -856
- data/vendor/pygments-main/tests/examplefiles/phpMyAdmin.spec +0 -163
- data/vendor/pygments-main/tests/examplefiles/phpcomplete.vim +0 -567
- data/vendor/pygments-main/tests/examplefiles/pleac.in.rb +0 -1223
- data/vendor/pygments-main/tests/examplefiles/postgresql_test.txt +0 -47
- data/vendor/pygments-main/tests/examplefiles/pppoe.applescript +0 -10
- data/vendor/pygments-main/tests/examplefiles/psql_session.txt +0 -122
- data/vendor/pygments-main/tests/examplefiles/py3_test.txt +0 -2
- data/vendor/pygments-main/tests/examplefiles/py3tb_test.py3tb +0 -4
- data/vendor/pygments-main/tests/examplefiles/pycon_test.pycon +0 -14
- data/vendor/pygments-main/tests/examplefiles/pytb_test2.pytb +0 -2
- data/vendor/pygments-main/tests/examplefiles/pytb_test3.pytb +0 -4
- data/vendor/pygments-main/tests/examplefiles/python25-bsd.mak +0 -234
- data/vendor/pygments-main/tests/examplefiles/qbasic_example +0 -2
- data/vendor/pygments-main/tests/examplefiles/qsort.prolog +0 -13
- data/vendor/pygments-main/tests/examplefiles/r-console-transcript.Rout +0 -38
- data/vendor/pygments-main/tests/examplefiles/r6rs-comments.scm +0 -23
- data/vendor/pygments-main/tests/examplefiles/ragel-cpp_rlscan +0 -280
- data/vendor/pygments-main/tests/examplefiles/ragel-cpp_snippet +0 -2
- data/vendor/pygments-main/tests/examplefiles/regex.js +0 -22
- data/vendor/pygments-main/tests/examplefiles/reversi.lsp +0 -427
- data/vendor/pygments-main/tests/examplefiles/robotframework_test.txt +0 -39
- data/vendor/pygments-main/tests/examplefiles/rql-queries.rql +0 -34
- data/vendor/pygments-main/tests/examplefiles/ruby_func_def.rb +0 -11
- data/vendor/pygments-main/tests/examplefiles/rust_example.rs +0 -233
- data/vendor/pygments-main/tests/examplefiles/scilab.sci +0 -30
- data/vendor/pygments-main/tests/examplefiles/scope.cirru +0 -43
- data/vendor/pygments-main/tests/examplefiles/session.dylan-console +0 -9
- data/vendor/pygments-main/tests/examplefiles/sibling.prolog +0 -19
- data/vendor/pygments-main/tests/examplefiles/simple.md +0 -747
- data/vendor/pygments-main/tests/examplefiles/smarty_example.html +0 -209
- data/vendor/pygments-main/tests/examplefiles/source.lgt +0 -343
- data/vendor/pygments-main/tests/examplefiles/sources.list +0 -62
- data/vendor/pygments-main/tests/examplefiles/sparql.rq +0 -23
- data/vendor/pygments-main/tests/examplefiles/sphere.pov +0 -18
- data/vendor/pygments-main/tests/examplefiles/sqlite3.sqlite3-console +0 -27
- data/vendor/pygments-main/tests/examplefiles/squid.conf +0 -30
- data/vendor/pygments-main/tests/examplefiles/string.jl +0 -1031
- data/vendor/pygments-main/tests/examplefiles/string_delimiters.d +0 -21
- data/vendor/pygments-main/tests/examplefiles/stripheredoc.sh +0 -3
- data/vendor/pygments-main/tests/examplefiles/swig_java.swg +0 -1329
- data/vendor/pygments-main/tests/examplefiles/swig_std_vector.i +0 -225
- data/vendor/pygments-main/tests/examplefiles/test.R +0 -185
- data/vendor/pygments-main/tests/examplefiles/test.adb +0 -211
- data/vendor/pygments-main/tests/examplefiles/test.agda +0 -102
- data/vendor/pygments-main/tests/examplefiles/test.apl +0 -26
- data/vendor/pygments-main/tests/examplefiles/test.asy +0 -131
- data/vendor/pygments-main/tests/examplefiles/test.awk +0 -121
- data/vendor/pygments-main/tests/examplefiles/test.bb +0 -95
- data/vendor/pygments-main/tests/examplefiles/test.bmx +0 -145
- data/vendor/pygments-main/tests/examplefiles/test.boo +0 -39
- data/vendor/pygments-main/tests/examplefiles/test.bro +0 -250
- data/vendor/pygments-main/tests/examplefiles/test.cs +0 -374
- data/vendor/pygments-main/tests/examplefiles/test.css +0 -54
- data/vendor/pygments-main/tests/examplefiles/test.cu +0 -36
- data/vendor/pygments-main/tests/examplefiles/test.cyp +0 -123
- data/vendor/pygments-main/tests/examplefiles/test.d +0 -135
- data/vendor/pygments-main/tests/examplefiles/test.dart +0 -23
- data/vendor/pygments-main/tests/examplefiles/test.dtd +0 -89
- data/vendor/pygments-main/tests/examplefiles/test.ebnf +0 -31
- data/vendor/pygments-main/tests/examplefiles/test.ec +0 -605
- data/vendor/pygments-main/tests/examplefiles/test.ecl +0 -58
- data/vendor/pygments-main/tests/examplefiles/test.eh +0 -315
- data/vendor/pygments-main/tests/examplefiles/test.erl +0 -169
- data/vendor/pygments-main/tests/examplefiles/test.evoque +0 -33
- data/vendor/pygments-main/tests/examplefiles/test.fan +0 -818
- data/vendor/pygments-main/tests/examplefiles/test.flx +0 -57
- data/vendor/pygments-main/tests/examplefiles/test.gdc +0 -13
- data/vendor/pygments-main/tests/examplefiles/test.groovy +0 -97
- data/vendor/pygments-main/tests/examplefiles/test.html +0 -339
- data/vendor/pygments-main/tests/examplefiles/test.idr +0 -93
- data/vendor/pygments-main/tests/examplefiles/test.ini +0 -10
- data/vendor/pygments-main/tests/examplefiles/test.java +0 -653
- data/vendor/pygments-main/tests/examplefiles/test.jsp +0 -24
- data/vendor/pygments-main/tests/examplefiles/test.maql +0 -45
- data/vendor/pygments-main/tests/examplefiles/test.mask +0 -41
- data/vendor/pygments-main/tests/examplefiles/test.mod +0 -374
- data/vendor/pygments-main/tests/examplefiles/test.moo +0 -51
- data/vendor/pygments-main/tests/examplefiles/test.myt +0 -166
- data/vendor/pygments-main/tests/examplefiles/test.nim +0 -93
- data/vendor/pygments-main/tests/examplefiles/test.opa +0 -10
- data/vendor/pygments-main/tests/examplefiles/test.p6 +0 -252
- data/vendor/pygments-main/tests/examplefiles/test.pan +0 -54
- data/vendor/pygments-main/tests/examplefiles/test.pas +0 -743
- data/vendor/pygments-main/tests/examplefiles/test.php +0 -507
- data/vendor/pygments-main/tests/examplefiles/test.pig +0 -148
- data/vendor/pygments-main/tests/examplefiles/test.plot +0 -333
- data/vendor/pygments-main/tests/examplefiles/test.ps1 +0 -108
- data/vendor/pygments-main/tests/examplefiles/test.pwn +0 -253
- data/vendor/pygments-main/tests/examplefiles/test.pypylog +0 -1839
- data/vendor/pygments-main/tests/examplefiles/test.r3 +0 -114
- data/vendor/pygments-main/tests/examplefiles/test.rb +0 -177
- data/vendor/pygments-main/tests/examplefiles/test.rhtml +0 -43
- data/vendor/pygments-main/tests/examplefiles/test.rsl +0 -111
- data/vendor/pygments-main/tests/examplefiles/test.scaml +0 -8
- data/vendor/pygments-main/tests/examplefiles/test.ssp +0 -12
- data/vendor/pygments-main/tests/examplefiles/test.swift +0 -65
- data/vendor/pygments-main/tests/examplefiles/test.tcsh +0 -830
- data/vendor/pygments-main/tests/examplefiles/test.vb +0 -407
- data/vendor/pygments-main/tests/examplefiles/test.vhdl +0 -161
- data/vendor/pygments-main/tests/examplefiles/test.xqy +0 -138
- data/vendor/pygments-main/tests/examplefiles/test.xsl +0 -23
- data/vendor/pygments-main/tests/examplefiles/test.zep +0 -33
- data/vendor/pygments-main/tests/examplefiles/test2.pypylog +0 -120
- data/vendor/pygments-main/tests/examplefiles/truncated.pytb +0 -15
- data/vendor/pygments-main/tests/examplefiles/type.lisp +0 -1218
- data/vendor/pygments-main/tests/examplefiles/underscore.coffee +0 -603
- data/vendor/pygments-main/tests/examplefiles/unicode.applescript +0 -5
- data/vendor/pygments-main/tests/examplefiles/unicode.go +0 -10
- data/vendor/pygments-main/tests/examplefiles/unicodedoc.py +0 -11
- data/vendor/pygments-main/tests/examplefiles/unix-io.lid +0 -37
- data/vendor/pygments-main/tests/examplefiles/vbnet_test.bas +0 -29
- data/vendor/pygments-main/tests/examplefiles/vctreestatus_hg +0 -4
- data/vendor/pygments-main/tests/examplefiles/vimrc +0 -21
- data/vendor/pygments-main/tests/examplefiles/webkit-transition.css +0 -3
- data/vendor/pygments-main/tests/examplefiles/while.pov +0 -13
- data/vendor/pygments-main/tests/examplefiles/wiki.factor +0 -384
- data/vendor/pygments-main/tests/examplefiles/xml_example +0 -1897
- data/vendor/pygments-main/tests/examplefiles/zmlrpc.f90 +0 -798
- data/vendor/pygments-main/tests/run.py +0 -44
- data/vendor/pygments-main/tests/string_asserts.py +0 -22
- data/vendor/pygments-main/tests/support.py +0 -15
- data/vendor/pygments-main/tests/support/tags +0 -36
- data/vendor/pygments-main/tests/test_basic_api.py +0 -309
- data/vendor/pygments-main/tests/test_cfm.py +0 -46
- data/vendor/pygments-main/tests/test_clexer.py +0 -236
- data/vendor/pygments-main/tests/test_cmdline.py +0 -106
- data/vendor/pygments-main/tests/test_examplefiles.py +0 -110
- data/vendor/pygments-main/tests/test_html_formatter.py +0 -180
- data/vendor/pygments-main/tests/test_latex_formatter.py +0 -57
- data/vendor/pygments-main/tests/test_lexers_other.py +0 -68
- data/vendor/pygments-main/tests/test_objectiveclexer.py +0 -81
- data/vendor/pygments-main/tests/test_perllexer.py +0 -137
- data/vendor/pygments-main/tests/test_qbasiclexer.py +0 -43
- data/vendor/pygments-main/tests/test_regexlexer.py +0 -54
- data/vendor/pygments-main/tests/test_rtf_formatter.py +0 -109
- data/vendor/pygments-main/tests/test_string_asserts.py +0 -39
- data/vendor/pygments-main/tests/test_token.py +0 -46
- data/vendor/pygments-main/tests/test_using_api.py +0 -40
- data/vendor/pygments-main/tests/test_util.py +0 -135
@@ -0,0 +1,306 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.prolog
|
4
|
+
~~~~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexers for Prolog and Prolog-like languages.
|
7
|
+
|
8
|
+
:copyright: Copyright 2006-2015 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, bygroups
|
15
|
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
16
|
+
Number, Punctuation
|
17
|
+
|
18
|
+
__all__ = ['PrologLexer', 'LogtalkLexer']
|
19
|
+
|
20
|
+
|
21
|
+
class PrologLexer(RegexLexer):
|
22
|
+
"""
|
23
|
+
Lexer for Prolog files.
|
24
|
+
"""
|
25
|
+
name = 'Prolog'
|
26
|
+
aliases = ['prolog']
|
27
|
+
filenames = ['*.ecl', '*.prolog', '*.pro', '*.pl']
|
28
|
+
mimetypes = ['text/x-prolog']
|
29
|
+
|
30
|
+
flags = re.UNICODE | re.MULTILINE
|
31
|
+
|
32
|
+
tokens = {
|
33
|
+
'root': [
|
34
|
+
(r'^#.*', Comment.Single),
|
35
|
+
(r'/\*', Comment.Multiline, 'nested-comment'),
|
36
|
+
(r'%.*', Comment.Single),
|
37
|
+
# character literal
|
38
|
+
(r'0\'.', String.Char),
|
39
|
+
(r'0b[01]+', Number.Bin),
|
40
|
+
(r'0o[0-7]+', Number.Oct),
|
41
|
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
42
|
+
# literal with prepended base
|
43
|
+
(r'\d\d?\'[a-zA-Z0-9]+', Number.Integer),
|
44
|
+
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
|
45
|
+
(r'\d+', Number.Integer),
|
46
|
+
(r'[\[\](){}|.,;!]', Punctuation),
|
47
|
+
(r':-|-->', Punctuation),
|
48
|
+
(r'"(?:\\x[0-9a-fA-F]+\\|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|'
|
49
|
+
r'\\[0-7]+\\|\\["\nabcefnrstv]|[^\\"])*"', String.Double),
|
50
|
+
(r"'(?:''|[^'])*'", String.Atom), # quoted atom
|
51
|
+
# Needs to not be followed by an atom.
|
52
|
+
# (r'=(?=\s|[a-zA-Z\[])', Operator),
|
53
|
+
(r'is\b', Operator),
|
54
|
+
(r'(<|>|=<|>=|==|=:=|=|/|//|\*|\+|-)(?=\s|[a-zA-Z0-9\[])',
|
55
|
+
Operator),
|
56
|
+
(r'(mod|div|not)\b', Operator),
|
57
|
+
(r'_', Keyword), # The don't-care variable
|
58
|
+
(r'([a-z]+)(:)', bygroups(Name.Namespace, Punctuation)),
|
59
|
+
(u'([a-z\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]'
|
60
|
+
u'[\w$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*)'
|
61
|
+
u'(\\s*)(:-|-->)',
|
62
|
+
bygroups(Name.Function, Text, Operator)), # function defn
|
63
|
+
(u'([a-z\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]'
|
64
|
+
u'[\w$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*)'
|
65
|
+
u'(\\s*)(\\()',
|
66
|
+
bygroups(Name.Function, Text, Punctuation)),
|
67
|
+
(u'[a-z\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]'
|
68
|
+
u'[\w$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*',
|
69
|
+
String.Atom), # atom, characters
|
70
|
+
# This one includes !
|
71
|
+
(u'[#&*+\\-./:<=>?@\\\\^~\u00a1-\u00bf\u2010-\u303f]+',
|
72
|
+
String.Atom), # atom, graphics
|
73
|
+
(r'[A-Z_]\w*', Name.Variable),
|
74
|
+
(u'\\s+|[\u2000-\u200f\ufff0-\ufffe\uffef]', Text),
|
75
|
+
],
|
76
|
+
'nested-comment': [
|
77
|
+
(r'\*/', Comment.Multiline, '#pop'),
|
78
|
+
(r'/\*', Comment.Multiline, '#push'),
|
79
|
+
(r'[^*/]+', Comment.Multiline),
|
80
|
+
(r'[*/]', Comment.Multiline),
|
81
|
+
],
|
82
|
+
}
|
83
|
+
|
84
|
+
def analyse_text(text):
|
85
|
+
return ':-' in text
|
86
|
+
|
87
|
+
|
88
|
+
class LogtalkLexer(RegexLexer):
|
89
|
+
"""
|
90
|
+
For `Logtalk <http://logtalk.org/>`_ source code.
|
91
|
+
|
92
|
+
.. versionadded:: 0.10
|
93
|
+
"""
|
94
|
+
|
95
|
+
name = 'Logtalk'
|
96
|
+
aliases = ['logtalk']
|
97
|
+
filenames = ['*.lgt', '*.logtalk']
|
98
|
+
mimetypes = ['text/x-logtalk']
|
99
|
+
|
100
|
+
tokens = {
|
101
|
+
'root': [
|
102
|
+
# Directives
|
103
|
+
(r'^\s*:-\s', Punctuation, 'directive'),
|
104
|
+
# Comments
|
105
|
+
(r'%.*?\n', Comment),
|
106
|
+
(r'/\*(.|\n)*?\*/', Comment),
|
107
|
+
# Whitespace
|
108
|
+
(r'\n', Text),
|
109
|
+
(r'\s+', Text),
|
110
|
+
# Numbers
|
111
|
+
(r"0'.", Number),
|
112
|
+
(r'0b[01]+', Number.Bin),
|
113
|
+
(r'0o[0-7]+', Number.Oct),
|
114
|
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
115
|
+
(r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
|
116
|
+
# Variables
|
117
|
+
(r'([A-Z_]\w*)', Name.Variable),
|
118
|
+
# Event handlers
|
119
|
+
(r'(after|before)(?=[(])', Keyword),
|
120
|
+
# Message forwarding handler
|
121
|
+
(r'forward(?=[(])', Keyword),
|
122
|
+
# Execution-context methods
|
123
|
+
(r'(parameter|this|se(lf|nder))(?=[(])', Keyword),
|
124
|
+
# Reflection
|
125
|
+
(r'(current_predicate|predicate_property)(?=[(])', Keyword),
|
126
|
+
# DCGs and term expansion
|
127
|
+
(r'(expand_(goal|term)|(goal|term)_expansion|phrase)(?=[(])', Keyword),
|
128
|
+
# Entity
|
129
|
+
(r'(abolish|c(reate|urrent))_(object|protocol|category)(?=[(])', Keyword),
|
130
|
+
(r'(object|protocol|category)_property(?=[(])', Keyword),
|
131
|
+
# Entity relations
|
132
|
+
(r'co(mplements_object|nforms_to_protocol)(?=[(])', Keyword),
|
133
|
+
(r'extends_(object|protocol|category)(?=[(])', Keyword),
|
134
|
+
(r'imp(lements_protocol|orts_category)(?=[(])', Keyword),
|
135
|
+
(r'(instantiat|specializ)es_class(?=[(])', Keyword),
|
136
|
+
# Events
|
137
|
+
(r'(current_event|(abolish|define)_events)(?=[(])', Keyword),
|
138
|
+
# Flags
|
139
|
+
(r'(current|set)_logtalk_flag(?=[(])', Keyword),
|
140
|
+
# Compiling, loading, and library paths
|
141
|
+
(r'logtalk_(compile|l(ibrary_path|oad|oad_context)|make)(?=[(])', Keyword),
|
142
|
+
(r'\blogtalk_make\b', Keyword),
|
143
|
+
# Database
|
144
|
+
(r'(clause|retract(all)?)(?=[(])', Keyword),
|
145
|
+
(r'a(bolish|ssert(a|z))(?=[(])', Keyword),
|
146
|
+
# Control constructs
|
147
|
+
(r'(ca(ll|tch)|throw)(?=[(])', Keyword),
|
148
|
+
(r'(fa(il|lse)|true)\b', Keyword),
|
149
|
+
# All solutions
|
150
|
+
(r'((bag|set)of|f(ind|or)all)(?=[(])', Keyword),
|
151
|
+
# Multi-threading meta-predicates
|
152
|
+
(r'threaded(_(call|once|ignore|exit|peek|wait|notify))?(?=[(])', Keyword),
|
153
|
+
# Term unification
|
154
|
+
(r'(subsumes_term|unify_with_occurs_check)(?=[(])', Keyword),
|
155
|
+
# Term creation and decomposition
|
156
|
+
(r'(functor|arg|copy_term|numbervars|term_variables)(?=[(])', Keyword),
|
157
|
+
# Evaluable functors
|
158
|
+
(r'(div|rem|m(ax|in|od)|abs|sign)(?=[(])', Keyword),
|
159
|
+
(r'float(_(integer|fractional)_part)?(?=[(])', Keyword),
|
160
|
+
(r'(floor|t(an|runcate)|round|ceiling)(?=[(])', Keyword),
|
161
|
+
# Other arithmetic functors
|
162
|
+
(r'(cos|a(cos|sin|tan|tan2)|exp|log|s(in|qrt)|xor)(?=[(])', Keyword),
|
163
|
+
# Term testing
|
164
|
+
(r'(var|atom(ic)?|integer|float|c(allable|ompound)|n(onvar|umber)|'
|
165
|
+
r'ground|acyclic_term)(?=[(])', Keyword),
|
166
|
+
# Term comparison
|
167
|
+
(r'compare(?=[(])', Keyword),
|
168
|
+
# Stream selection and control
|
169
|
+
(r'(curren|se)t_(in|out)put(?=[(])', Keyword),
|
170
|
+
(r'(open|close)(?=[(])', Keyword),
|
171
|
+
(r'flush_output(?=[(])', Keyword),
|
172
|
+
(r'(at_end_of_stream|flush_output)\b', Keyword),
|
173
|
+
(r'(stream_property|at_end_of_stream|set_stream_position)(?=[(])', Keyword),
|
174
|
+
# Character and byte input/output
|
175
|
+
(r'(nl|(get|peek|put)_(byte|c(har|ode)))(?=[(])', Keyword),
|
176
|
+
(r'\bnl\b', Keyword),
|
177
|
+
# Term input/output
|
178
|
+
(r'read(_term)?(?=[(])', Keyword),
|
179
|
+
(r'write(q|_(canonical|term))?(?=[(])', Keyword),
|
180
|
+
(r'(current_)?op(?=[(])', Keyword),
|
181
|
+
(r'(current_)?char_conversion(?=[(])', Keyword),
|
182
|
+
# Atomic term processing
|
183
|
+
(r'atom_(length|c(hars|o(ncat|des)))(?=[(])', Keyword),
|
184
|
+
(r'(char_code|sub_atom)(?=[(])', Keyword),
|
185
|
+
(r'number_c(har|ode)s(?=[(])', Keyword),
|
186
|
+
# Implementation defined hooks functions
|
187
|
+
(r'(se|curren)t_prolog_flag(?=[(])', Keyword),
|
188
|
+
(r'\bhalt\b', Keyword),
|
189
|
+
(r'halt(?=[(])', Keyword),
|
190
|
+
# Message sending operators
|
191
|
+
(r'(::|:|\^\^)', Operator),
|
192
|
+
# External call
|
193
|
+
(r'[{}]', Keyword),
|
194
|
+
# Logic and control
|
195
|
+
(r'(ignore|once)(?=[(])', Keyword),
|
196
|
+
(r'\brepeat\b', Keyword),
|
197
|
+
# Sorting
|
198
|
+
(r'(key)?sort(?=[(])', Keyword),
|
199
|
+
# Bitwise functors
|
200
|
+
(r'(>>|<<|/\\|\\\\|\\)', Operator),
|
201
|
+
# Predicate aliases
|
202
|
+
(r'\bas\b', Operator),
|
203
|
+
# Arithemtic evaluation
|
204
|
+
(r'\bis\b', Keyword),
|
205
|
+
# Arithemtic comparison
|
206
|
+
(r'(=:=|=\\=|<|=<|>=|>)', Operator),
|
207
|
+
# Term creation and decomposition
|
208
|
+
(r'=\.\.', Operator),
|
209
|
+
# Term unification
|
210
|
+
(r'(=|\\=)', Operator),
|
211
|
+
# Term comparison
|
212
|
+
(r'(==|\\==|@=<|@<|@>=|@>)', Operator),
|
213
|
+
# Evaluable functors
|
214
|
+
(r'(//|[-+*/])', Operator),
|
215
|
+
(r'\b(e|pi|div|mod|rem)\b', Operator),
|
216
|
+
# Other arithemtic functors
|
217
|
+
(r'\b\*\*\b', Operator),
|
218
|
+
# DCG rules
|
219
|
+
(r'-->', Operator),
|
220
|
+
# Control constructs
|
221
|
+
(r'([!;]|->)', Operator),
|
222
|
+
# Logic and control
|
223
|
+
(r'\\+', Operator),
|
224
|
+
# Mode operators
|
225
|
+
(r'[?@]', Operator),
|
226
|
+
# Existential quantifier
|
227
|
+
(r'\^', Operator),
|
228
|
+
# Strings
|
229
|
+
(r'"(\\\\|\\"|[^"])*"', String),
|
230
|
+
# Ponctuation
|
231
|
+
(r'[()\[\],.|]', Text),
|
232
|
+
# Atoms
|
233
|
+
(r"[a-z]\w*", Text),
|
234
|
+
(r"'", String, 'quoted_atom'),
|
235
|
+
],
|
236
|
+
|
237
|
+
'quoted_atom': [
|
238
|
+
(r"''", String),
|
239
|
+
(r"'", String, '#pop'),
|
240
|
+
(r'\\([\\abfnrtv"\']|(x[a-fA-F0-9]+|[0-7]+)\\)', String.Escape),
|
241
|
+
(r"[^\\'\n]+", String),
|
242
|
+
(r'\\', String),
|
243
|
+
],
|
244
|
+
|
245
|
+
'directive': [
|
246
|
+
# Conditional compilation directives
|
247
|
+
(r'(el)?if(?=[(])', Keyword, 'root'),
|
248
|
+
(r'(e(lse|ndif))[.]', Keyword, 'root'),
|
249
|
+
# Entity directives
|
250
|
+
(r'(category|object|protocol)(?=[(])', Keyword, 'entityrelations'),
|
251
|
+
(r'(end_(category|object|protocol))[.]', Keyword, 'root'),
|
252
|
+
# Predicate scope directives
|
253
|
+
(r'(public|protected|private)(?=[(])', Keyword, 'root'),
|
254
|
+
# Other directives
|
255
|
+
(r'e(n(coding|sure_loaded)|xport)(?=[(])', Keyword, 'root'),
|
256
|
+
(r'in(clude|itialization|fo)(?=[(])', Keyword, 'root'),
|
257
|
+
(r'(built_in|dynamic|synchronized|threaded)[.]', Keyword, 'root'),
|
258
|
+
(r'(alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|ode|ultifile)|'
|
259
|
+
r's(et_(logtalk|prolog)_flag|ynchronized))(?=[(])', Keyword, 'root'),
|
260
|
+
(r'op(?=[(])', Keyword, 'root'),
|
261
|
+
(r'(c(alls|oinductive)|module|reexport|use(s|_module))(?=[(])', Keyword, 'root'),
|
262
|
+
(r'[a-z]\w*(?=[(])', Text, 'root'),
|
263
|
+
(r'[a-z]\w*[.]', Text, 'root'),
|
264
|
+
],
|
265
|
+
|
266
|
+
'entityrelations': [
|
267
|
+
(r'(complements|extends|i(nstantiates|mp(lements|orts))|specializes)(?=[(])', Keyword),
|
268
|
+
# Numbers
|
269
|
+
(r"0'.", Number),
|
270
|
+
(r'0b[01]+', Number.Bin),
|
271
|
+
(r'0o[0-7]+', Number.Oct),
|
272
|
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
273
|
+
(r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
|
274
|
+
# Variables
|
275
|
+
(r'([A-Z_]\w*)', Name.Variable),
|
276
|
+
# Atoms
|
277
|
+
(r"[a-z]\w*", Text),
|
278
|
+
(r"'", String, 'quoted_atom'),
|
279
|
+
# Strings
|
280
|
+
(r'"(\\\\|\\"|[^"])*"', String),
|
281
|
+
# End of entity-opening directive
|
282
|
+
(r'([)]\.)', Text, 'root'),
|
283
|
+
# Scope operator
|
284
|
+
(r'(::)', Operator),
|
285
|
+
# Ponctuation
|
286
|
+
(r'[()\[\],.|]', Text),
|
287
|
+
# Comments
|
288
|
+
(r'%.*?\n', Comment),
|
289
|
+
(r'/\*(.|\n)*?\*/', Comment),
|
290
|
+
# Whitespace
|
291
|
+
(r'\n', Text),
|
292
|
+
(r'\s+', Text),
|
293
|
+
]
|
294
|
+
}
|
295
|
+
|
296
|
+
def analyse_text(text):
|
297
|
+
if ':- object(' in text:
|
298
|
+
return 1.0
|
299
|
+
elif ':- protocol(' in text:
|
300
|
+
return 1.0
|
301
|
+
elif ':- category(' in text:
|
302
|
+
return 1.0
|
303
|
+
elif re.search('^:-\s[a-z]', text, re.M):
|
304
|
+
return 0.9
|
305
|
+
else:
|
306
|
+
return 0.0
|
@@ -0,0 +1,938 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.python
|
4
|
+
~~~~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexers for Python and related languages.
|
7
|
+
|
8
|
+
:copyright: Copyright 2006-2015 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, include, bygroups, using, \
|
15
|
+
default, words, combined, do_insertions
|
16
|
+
from pygments.util import get_bool_opt, shebang_matches
|
17
|
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
18
|
+
Number, Punctuation, Generic, Other, Error
|
19
|
+
from pygments import unistring as uni
|
20
|
+
|
21
|
+
__all__ = ['PythonLexer', 'PythonConsoleLexer', 'PythonTracebackLexer',
|
22
|
+
'Python3Lexer', 'Python3TracebackLexer', 'CythonLexer',
|
23
|
+
'DgLexer', 'NumPyLexer']
|
24
|
+
|
25
|
+
line_re = re.compile('.*?\n')
|
26
|
+
|
27
|
+
|
28
|
+
class PythonLexer(RegexLexer):
|
29
|
+
"""
|
30
|
+
For `Python <http://www.python.org>`_ source code.
|
31
|
+
"""
|
32
|
+
|
33
|
+
name = 'Python'
|
34
|
+
aliases = ['python', 'py', 'sage']
|
35
|
+
filenames = ['*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac', '*.sage']
|
36
|
+
mimetypes = ['text/x-python', 'application/x-python']
|
37
|
+
|
38
|
+
def innerstring_rules(ttype):
|
39
|
+
return [
|
40
|
+
# the old style '%s' % (...) string formatting
|
41
|
+
(r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
|
42
|
+
'[hlL]?[E-GXc-giorsux%]', String.Interpol),
|
43
|
+
# backslashes, quotes and formatting signs must be parsed one at a time
|
44
|
+
(r'[^\\\'"%\n]+', ttype),
|
45
|
+
(r'[\'"\\]', ttype),
|
46
|
+
# unhandled string formatting sign
|
47
|
+
(r'%', ttype),
|
48
|
+
# newlines are an error (use "nl" state)
|
49
|
+
]
|
50
|
+
|
51
|
+
tokens = {
|
52
|
+
'root': [
|
53
|
+
(r'\n', Text),
|
54
|
+
(r'^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")',
|
55
|
+
bygroups(Text, String.Affix, String.Doc)),
|
56
|
+
(r"^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')",
|
57
|
+
bygroups(Text, String.Affix, String.Doc)),
|
58
|
+
(r'[^\S\n]+', Text),
|
59
|
+
(r'\A#!.+$', Comment.Hashbang),
|
60
|
+
(r'#.*$', Comment.Single),
|
61
|
+
(r'[]{}:(),;[]', Punctuation),
|
62
|
+
(r'\\\n', Text),
|
63
|
+
(r'\\', Text),
|
64
|
+
(r'(in|is|and|or|not)\b', Operator.Word),
|
65
|
+
(r'!=|==|<<|>>|[-~+/*%=<>&^|.]', Operator),
|
66
|
+
include('keywords'),
|
67
|
+
(r'(def)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'funcname'),
|
68
|
+
(r'(class)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'classname'),
|
69
|
+
(r'(from)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text),
|
70
|
+
'fromimport'),
|
71
|
+
(r'(import)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text),
|
72
|
+
'import'),
|
73
|
+
include('builtins'),
|
74
|
+
include('magicfuncs'),
|
75
|
+
include('magicvars'),
|
76
|
+
include('backtick'),
|
77
|
+
('([rR]|[uUbB][rR]|[rR][uUbB])(""")',
|
78
|
+
bygroups(String.Affix, String.Double), 'tdqs'),
|
79
|
+
("([rR]|[uUbB][rR]|[rR][uUbB])(''')",
|
80
|
+
bygroups(String.Affix, String.Single), 'tsqs'),
|
81
|
+
('([rR]|[uUbB][rR]|[rR][uUbB])(")',
|
82
|
+
bygroups(String.Affix, String.Double), 'dqs'),
|
83
|
+
("([rR]|[uUbB][rR]|[rR][uUbB])(')",
|
84
|
+
bygroups(String.Affix, String.Single), 'sqs'),
|
85
|
+
('([uUbB]?)(""")', bygroups(String.Affix, String.Double),
|
86
|
+
combined('stringescape', 'tdqs')),
|
87
|
+
("([uUbB]?)(''')", bygroups(String.Affix, String.Single),
|
88
|
+
combined('stringescape', 'tsqs')),
|
89
|
+
('([uUbB]?)(")', bygroups(String.Affix, String.Double),
|
90
|
+
combined('stringescape', 'dqs')),
|
91
|
+
("([uUbB]?)(')", bygroups(String.Affix, String.Single),
|
92
|
+
combined('stringescape', 'sqs')),
|
93
|
+
include('name'),
|
94
|
+
include('numbers'),
|
95
|
+
],
|
96
|
+
'keywords': [
|
97
|
+
(words((
|
98
|
+
'assert', 'break', 'continue', 'del', 'elif', 'else', 'except',
|
99
|
+
'exec', 'finally', 'for', 'global', 'if', 'lambda', 'pass',
|
100
|
+
'print', 'raise', 'return', 'try', 'while', 'yield',
|
101
|
+
'yield from', 'as', 'with'), suffix=r'\b'),
|
102
|
+
Keyword),
|
103
|
+
],
|
104
|
+
'builtins': [
|
105
|
+
(words((
|
106
|
+
'__import__', 'abs', 'all', 'any', 'apply', 'basestring', 'bin',
|
107
|
+
'bool', 'buffer', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod',
|
108
|
+
'cmp', 'coerce', 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod',
|
109
|
+
'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float',
|
110
|
+
'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'hex', 'id',
|
111
|
+
'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len',
|
112
|
+
'list', 'locals', 'long', 'map', 'max', 'min', 'next', 'object',
|
113
|
+
'oct', 'open', 'ord', 'pow', 'property', 'range', 'raw_input', 'reduce',
|
114
|
+
'reload', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice',
|
115
|
+
'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type',
|
116
|
+
'unichr', 'unicode', 'vars', 'xrange', 'zip'),
|
117
|
+
prefix=r'(?<!\.)', suffix=r'\b'),
|
118
|
+
Name.Builtin),
|
119
|
+
(r'(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|cls'
|
120
|
+
r')\b', Name.Builtin.Pseudo),
|
121
|
+
(words((
|
122
|
+
'ArithmeticError', 'AssertionError', 'AttributeError',
|
123
|
+
'BaseException', 'DeprecationWarning', 'EOFError', 'EnvironmentError',
|
124
|
+
'Exception', 'FloatingPointError', 'FutureWarning', 'GeneratorExit',
|
125
|
+
'IOError', 'ImportError', 'ImportWarning', 'IndentationError',
|
126
|
+
'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError',
|
127
|
+
'MemoryError', 'NameError', 'NotImplemented', 'NotImplementedError',
|
128
|
+
'OSError', 'OverflowError', 'OverflowWarning', 'PendingDeprecationWarning',
|
129
|
+
'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError',
|
130
|
+
'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError',
|
131
|
+
'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError',
|
132
|
+
'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError',
|
133
|
+
'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning',
|
134
|
+
'ValueError', 'VMSError', 'Warning', 'WindowsError',
|
135
|
+
'ZeroDivisionError'), prefix=r'(?<!\.)', suffix=r'\b'),
|
136
|
+
Name.Exception),
|
137
|
+
],
|
138
|
+
'magicfuncs': [
|
139
|
+
(words((
|
140
|
+
'__abs__', '__add__', '__and__', '__call__', '__cmp__', '__coerce__',
|
141
|
+
'__complex__', '__contains__', '__del__', '__delattr__', '__delete__',
|
142
|
+
'__delitem__', '__delslice__', '__div__', '__divmod__', '__enter__',
|
143
|
+
'__eq__', '__exit__', '__float__', '__floordiv__', '__ge__', '__get__',
|
144
|
+
'__getattr__', '__getattribute__', '__getitem__', '__getslice__', '__gt__',
|
145
|
+
'__hash__', '__hex__', '__iadd__', '__iand__', '__idiv__', '__ifloordiv__',
|
146
|
+
'__ilshift__', '__imod__', '__imul__', '__index__', '__init__',
|
147
|
+
'__instancecheck__', '__int__', '__invert__', '__iop__', '__ior__',
|
148
|
+
'__ipow__', '__irshift__', '__isub__', '__iter__', '__itruediv__',
|
149
|
+
'__ixor__', '__le__', '__len__', '__long__', '__lshift__', '__lt__',
|
150
|
+
'__missing__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__',
|
151
|
+
'__nonzero__', '__oct__', '__op__', '__or__', '__pos__', '__pow__',
|
152
|
+
'__radd__', '__rand__', '__rcmp__', '__rdiv__', '__rdivmod__', '__repr__',
|
153
|
+
'__reversed__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__',
|
154
|
+
'__rop__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__',
|
155
|
+
'__rtruediv__', '__rxor__', '__set__', '__setattr__', '__setitem__',
|
156
|
+
'__setslice__', '__str__', '__sub__', '__subclasscheck__', '__truediv__',
|
157
|
+
'__unicode__', '__xor__'), suffix=r'\b'),
|
158
|
+
Name.Function.Magic),
|
159
|
+
],
|
160
|
+
'magicvars': [
|
161
|
+
(words((
|
162
|
+
'__bases__', '__class__', '__closure__', '__code__', '__defaults__',
|
163
|
+
'__dict__', '__doc__', '__file__', '__func__', '__globals__',
|
164
|
+
'__metaclass__', '__module__', '__mro__', '__name__', '__self__',
|
165
|
+
'__slots__', '__weakref__'),
|
166
|
+
suffix=r'\b'),
|
167
|
+
Name.Variable.Magic),
|
168
|
+
],
|
169
|
+
'numbers': [
|
170
|
+
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float),
|
171
|
+
(r'\d+[eE][+-]?[0-9]+j?', Number.Float),
|
172
|
+
(r'0[0-7]+j?', Number.Oct),
|
173
|
+
(r'0[bB][01]+', Number.Bin),
|
174
|
+
(r'0[xX][a-fA-F0-9]+', Number.Hex),
|
175
|
+
(r'\d+L', Number.Integer.Long),
|
176
|
+
(r'\d+j?', Number.Integer)
|
177
|
+
],
|
178
|
+
'backtick': [
|
179
|
+
('`.*?`', String.Backtick),
|
180
|
+
],
|
181
|
+
'name': [
|
182
|
+
(r'@[\w.]+', Name.Decorator),
|
183
|
+
('[a-zA-Z_]\w*', Name),
|
184
|
+
],
|
185
|
+
'funcname': [
|
186
|
+
include('magicfuncs'),
|
187
|
+
('[a-zA-Z_]\w*', Name.Function, '#pop'),
|
188
|
+
default('#pop'),
|
189
|
+
],
|
190
|
+
'classname': [
|
191
|
+
('[a-zA-Z_]\w*', Name.Class, '#pop')
|
192
|
+
],
|
193
|
+
'import': [
|
194
|
+
(r'(?:[ \t]|\\\n)+', Text),
|
195
|
+
(r'as\b', Keyword.Namespace),
|
196
|
+
(r',', Operator),
|
197
|
+
(r'[a-zA-Z_][\w.]*', Name.Namespace),
|
198
|
+
default('#pop') # all else: go back
|
199
|
+
],
|
200
|
+
'fromimport': [
|
201
|
+
(r'(?:[ \t]|\\\n)+', Text),
|
202
|
+
(r'import\b', Keyword.Namespace, '#pop'),
|
203
|
+
# if None occurs here, it's "raise x from None", since None can
|
204
|
+
# never be a module name
|
205
|
+
(r'None\b', Name.Builtin.Pseudo, '#pop'),
|
206
|
+
# sadly, in "raise x from y" y will be highlighted as namespace too
|
207
|
+
(r'[a-zA-Z_.][\w.]*', Name.Namespace),
|
208
|
+
# anything else here also means "raise x from y" and is therefore
|
209
|
+
# not an error
|
210
|
+
default('#pop'),
|
211
|
+
],
|
212
|
+
'stringescape': [
|
213
|
+
(r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|'
|
214
|
+
r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
|
215
|
+
],
|
216
|
+
'strings-single': innerstring_rules(String.Single),
|
217
|
+
'strings-double': innerstring_rules(String.Double),
|
218
|
+
'dqs': [
|
219
|
+
(r'"', String.Double, '#pop'),
|
220
|
+
(r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings
|
221
|
+
include('strings-double')
|
222
|
+
],
|
223
|
+
'sqs': [
|
224
|
+
(r"'", String.Single, '#pop'),
|
225
|
+
(r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings
|
226
|
+
include('strings-single')
|
227
|
+
],
|
228
|
+
'tdqs': [
|
229
|
+
(r'"""', String.Double, '#pop'),
|
230
|
+
include('strings-double'),
|
231
|
+
(r'\n', String.Double)
|
232
|
+
],
|
233
|
+
'tsqs': [
|
234
|
+
(r"'''", String.Single, '#pop'),
|
235
|
+
include('strings-single'),
|
236
|
+
(r'\n', String.Single)
|
237
|
+
],
|
238
|
+
}
|
239
|
+
|
240
|
+
def analyse_text(text):
|
241
|
+
return shebang_matches(text, r'pythonw?(2(\.\d)?)?') or \
|
242
|
+
'import ' in text[:1000]
|
243
|
+
|
244
|
+
|
245
|
+
class Python3Lexer(RegexLexer):
|
246
|
+
"""
|
247
|
+
For `Python <http://www.python.org>`_ source code (version 3.0).
|
248
|
+
|
249
|
+
.. versionadded:: 0.10
|
250
|
+
"""
|
251
|
+
|
252
|
+
name = 'Python 3'
|
253
|
+
aliases = ['python3', 'py3']
|
254
|
+
filenames = [] # Nothing until Python 3 gets widespread
|
255
|
+
mimetypes = ['text/x-python3', 'application/x-python3']
|
256
|
+
|
257
|
+
flags = re.MULTILINE | re.UNICODE
|
258
|
+
|
259
|
+
uni_name = "[%s][%s]*" % (uni.xid_start, uni.xid_continue)
|
260
|
+
|
261
|
+
def innerstring_rules(ttype):
|
262
|
+
return [
|
263
|
+
# the old style '%s' % (...) string formatting (still valid in Py3)
|
264
|
+
(r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
|
265
|
+
'[hlL]?[E-GXc-giorsux%]', String.Interpol),
|
266
|
+
# the new style '{}'.format(...) string formatting
|
267
|
+
(r'\{'
|
268
|
+
'((\w+)((\.\w+)|(\[[^\]]+\]))*)?' # field name
|
269
|
+
'(\![sra])?' # conversion
|
270
|
+
'(\:(.?[<>=\^])?[-+ ]?#?0?(\d+)?,?(\.\d+)?[E-GXb-gnosx%]?)?'
|
271
|
+
'\}', String.Interpol),
|
272
|
+
|
273
|
+
# backslashes, quotes and formatting signs must be parsed one at a time
|
274
|
+
(r'[^\\\'"%{\n]+', ttype),
|
275
|
+
(r'[\'"\\]', ttype),
|
276
|
+
# unhandled string formatting sign
|
277
|
+
(r'%|(\{{1,2})', ttype)
|
278
|
+
# newlines are an error (use "nl" state)
|
279
|
+
]
|
280
|
+
|
281
|
+
tokens = PythonLexer.tokens.copy()
|
282
|
+
tokens['keywords'] = [
|
283
|
+
(words((
|
284
|
+
'assert', 'async', 'await', 'break', 'continue', 'del', 'elif',
|
285
|
+
'else', 'except', 'finally', 'for', 'global', 'if', 'lambda', 'pass',
|
286
|
+
'raise', 'nonlocal', 'return', 'try', 'while', 'yield', 'yield from',
|
287
|
+
'as', 'with'), suffix=r'\b'),
|
288
|
+
Keyword),
|
289
|
+
(words((
|
290
|
+
'True', 'False', 'None'), suffix=r'\b'),
|
291
|
+
Keyword.Constant),
|
292
|
+
]
|
293
|
+
tokens['builtins'] = [
|
294
|
+
(words((
|
295
|
+
'__import__', 'abs', 'all', 'any', 'bin', 'bool', 'bytearray', 'bytes',
|
296
|
+
'chr', 'classmethod', 'cmp', 'compile', 'complex', 'delattr', 'dict',
|
297
|
+
'dir', 'divmod', 'enumerate', 'eval', 'filter', 'float', 'format',
|
298
|
+
'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'hex', 'id',
|
299
|
+
'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'list',
|
300
|
+
'locals', 'map', 'max', 'memoryview', 'min', 'next', 'object', 'oct',
|
301
|
+
'open', 'ord', 'pow', 'print', 'property', 'range', 'repr', 'reversed',
|
302
|
+
'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str',
|
303
|
+
'sum', 'super', 'tuple', 'type', 'vars', 'zip'), prefix=r'(?<!\.)',
|
304
|
+
suffix=r'\b'),
|
305
|
+
Name.Builtin),
|
306
|
+
(r'(?<!\.)(self|Ellipsis|NotImplemented|cls)\b', Name.Builtin.Pseudo),
|
307
|
+
(words((
|
308
|
+
'ArithmeticError', 'AssertionError', 'AttributeError',
|
309
|
+
'BaseException', 'BufferError', 'BytesWarning', 'DeprecationWarning',
|
310
|
+
'EOFError', 'EnvironmentError', 'Exception', 'FloatingPointError',
|
311
|
+
'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError',
|
312
|
+
'ImportWarning', 'IndentationError', 'IndexError', 'KeyError',
|
313
|
+
'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError',
|
314
|
+
'NotImplementedError', 'OSError', 'OverflowError',
|
315
|
+
'PendingDeprecationWarning', 'ReferenceError', 'ResourceWarning',
|
316
|
+
'RuntimeError', 'RuntimeWarning', 'StopIteration',
|
317
|
+
'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError',
|
318
|
+
'TypeError', 'UnboundLocalError', 'UnicodeDecodeError',
|
319
|
+
'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError',
|
320
|
+
'UnicodeWarning', 'UserWarning', 'ValueError', 'VMSError', 'Warning',
|
321
|
+
'WindowsError', 'ZeroDivisionError',
|
322
|
+
# new builtin exceptions from PEP 3151
|
323
|
+
'BlockingIOError', 'ChildProcessError', 'ConnectionError',
|
324
|
+
'BrokenPipeError', 'ConnectionAbortedError', 'ConnectionRefusedError',
|
325
|
+
'ConnectionResetError', 'FileExistsError', 'FileNotFoundError',
|
326
|
+
'InterruptedError', 'IsADirectoryError', 'NotADirectoryError',
|
327
|
+
'PermissionError', 'ProcessLookupError', 'TimeoutError'),
|
328
|
+
prefix=r'(?<!\.)', suffix=r'\b'),
|
329
|
+
Name.Exception),
|
330
|
+
]
|
331
|
+
tokens['magicfuncs'] = [
|
332
|
+
(words((
|
333
|
+
'__abs__', '__add__', '__aenter__', '__aexit__', '__aiter__', '__and__',
|
334
|
+
'__anext__', '__await__', '__bool__', '__bytes__', '__call__',
|
335
|
+
'__complex__', '__contains__', '__del__', '__delattr__', '__delete__',
|
336
|
+
'__delitem__', '__dir__', '__divmod__', '__enter__', '__eq__', '__exit__',
|
337
|
+
'__float__', '__floordiv__', '__format__', '__ge__', '__get__',
|
338
|
+
'__getattr__', '__getattribute__', '__getitem__', '__gt__', '__hash__',
|
339
|
+
'__iadd__', '__iand__', '__ifloordiv__', '__ilshift__', '__imatmul__',
|
340
|
+
'__imod__', '__import__', '__imul__', '__index__', '__init__',
|
341
|
+
'__instancecheck__', '__int__', '__invert__', '__ior__', '__ipow__',
|
342
|
+
'__irshift__', '__isub__', '__iter__', '__itruediv__', '__ixor__',
|
343
|
+
'__le__', '__len__', '__length_hint__', '__lshift__', '__lt__',
|
344
|
+
'__matmul__', '__missing__', '__mod__', '__mul__', '__ne__', '__neg__',
|
345
|
+
'__new__', '__next__', '__or__', '__pos__', '__pow__', '__prepare__',
|
346
|
+
'__radd__', '__rand__', '__rdivmod__', '__repr__', '__reversed__',
|
347
|
+
'__rfloordiv__', '__rlshift__', '__rmatmul__', '__rmod__', '__rmul__',
|
348
|
+
'__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__',
|
349
|
+
'__rsub__', '__rtruediv__', '__rxor__', '__set__', '__setattr__',
|
350
|
+
'__setitem__', '__str__', '__sub__', '__subclasscheck__', '__truediv__',
|
351
|
+
'__xor__'), suffix=r'\b'),
|
352
|
+
Name.Function.Magic),
|
353
|
+
]
|
354
|
+
tokens['magicvars'] = [
|
355
|
+
(words((
|
356
|
+
'__annotations__', '__bases__', '__class__', '__closure__', '__code__',
|
357
|
+
'__defaults__', '__dict__', '__doc__', '__file__', '__func__',
|
358
|
+
'__globals__', '__kwdefaults__', '__module__', '__mro__', '__name__',
|
359
|
+
'__objclass__', '__qualname__', '__self__', '__slots__', '__weakref__'),
|
360
|
+
suffix=r'\b'),
|
361
|
+
Name.Variable.Magic),
|
362
|
+
]
|
363
|
+
tokens['numbers'] = [
|
364
|
+
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
|
365
|
+
(r'0[oO][0-7]+', Number.Oct),
|
366
|
+
(r'0[bB][01]+', Number.Bin),
|
367
|
+
(r'0[xX][a-fA-F0-9]+', Number.Hex),
|
368
|
+
(r'\d+', Number.Integer)
|
369
|
+
]
|
370
|
+
tokens['backtick'] = []
|
371
|
+
tokens['name'] = [
|
372
|
+
(r'@\w+', Name.Decorator),
|
373
|
+
(r'@', Operator), # new matrix multiplication operator
|
374
|
+
(uni_name, Name),
|
375
|
+
]
|
376
|
+
tokens['funcname'] = [
|
377
|
+
(uni_name, Name.Function, '#pop')
|
378
|
+
]
|
379
|
+
tokens['classname'] = [
|
380
|
+
(uni_name, Name.Class, '#pop')
|
381
|
+
]
|
382
|
+
tokens['import'] = [
|
383
|
+
(r'(\s+)(as)(\s+)', bygroups(Text, Keyword, Text)),
|
384
|
+
(r'\.', Name.Namespace),
|
385
|
+
(uni_name, Name.Namespace),
|
386
|
+
(r'(\s*)(,)(\s*)', bygroups(Text, Operator, Text)),
|
387
|
+
default('#pop') # all else: go back
|
388
|
+
]
|
389
|
+
tokens['fromimport'] = [
|
390
|
+
(r'(\s+)(import)\b', bygroups(Text, Keyword), '#pop'),
|
391
|
+
(r'\.', Name.Namespace),
|
392
|
+
(uni_name, Name.Namespace),
|
393
|
+
default('#pop'),
|
394
|
+
]
|
395
|
+
tokens['strings-single'] = innerstring_rules(String.Single)
|
396
|
+
tokens['strings-double'] = innerstring_rules(String.Double)
|
397
|
+
|
398
|
+
def analyse_text(text):
|
399
|
+
return shebang_matches(text, r'pythonw?3(\.\d)?')
|
400
|
+
|
401
|
+
|
402
|
+
class PythonConsoleLexer(Lexer):
|
403
|
+
"""
|
404
|
+
For Python console output or doctests, such as:
|
405
|
+
|
406
|
+
.. sourcecode:: pycon
|
407
|
+
|
408
|
+
>>> a = 'foo'
|
409
|
+
>>> print a
|
410
|
+
foo
|
411
|
+
>>> 1 / 0
|
412
|
+
Traceback (most recent call last):
|
413
|
+
File "<stdin>", line 1, in <module>
|
414
|
+
ZeroDivisionError: integer division or modulo by zero
|
415
|
+
|
416
|
+
Additional options:
|
417
|
+
|
418
|
+
`python3`
|
419
|
+
Use Python 3 lexer for code. Default is ``False``.
|
420
|
+
|
421
|
+
.. versionadded:: 1.0
|
422
|
+
"""
|
423
|
+
name = 'Python console session'
|
424
|
+
aliases = ['pycon']
|
425
|
+
mimetypes = ['text/x-python-doctest']
|
426
|
+
|
427
|
+
def __init__(self, **options):
|
428
|
+
self.python3 = get_bool_opt(options, 'python3', False)
|
429
|
+
Lexer.__init__(self, **options)
|
430
|
+
|
431
|
+
def get_tokens_unprocessed(self, text):
|
432
|
+
if self.python3:
|
433
|
+
pylexer = Python3Lexer(**self.options)
|
434
|
+
tblexer = Python3TracebackLexer(**self.options)
|
435
|
+
else:
|
436
|
+
pylexer = PythonLexer(**self.options)
|
437
|
+
tblexer = PythonTracebackLexer(**self.options)
|
438
|
+
|
439
|
+
curcode = ''
|
440
|
+
insertions = []
|
441
|
+
curtb = ''
|
442
|
+
tbindex = 0
|
443
|
+
tb = 0
|
444
|
+
for match in line_re.finditer(text):
|
445
|
+
line = match.group()
|
446
|
+
if line.startswith(u'>>> ') or line.startswith(u'... '):
|
447
|
+
tb = 0
|
448
|
+
insertions.append((len(curcode),
|
449
|
+
[(0, Generic.Prompt, line[:4])]))
|
450
|
+
curcode += line[4:]
|
451
|
+
elif line.rstrip() == u'...' and not tb:
|
452
|
+
# only a new >>> prompt can end an exception block
|
453
|
+
# otherwise an ellipsis in place of the traceback frames
|
454
|
+
# will be mishandled
|
455
|
+
insertions.append((len(curcode),
|
456
|
+
[(0, Generic.Prompt, u'...')]))
|
457
|
+
curcode += line[3:]
|
458
|
+
else:
|
459
|
+
if curcode:
|
460
|
+
for item in do_insertions(
|
461
|
+
insertions, pylexer.get_tokens_unprocessed(curcode)):
|
462
|
+
yield item
|
463
|
+
curcode = ''
|
464
|
+
insertions = []
|
465
|
+
if (line.startswith(u'Traceback (most recent call last):') or
|
466
|
+
re.match(u' File "[^"]+", line \\d+\\n$', line)):
|
467
|
+
tb = 1
|
468
|
+
curtb = line
|
469
|
+
tbindex = match.start()
|
470
|
+
elif line == 'KeyboardInterrupt\n':
|
471
|
+
yield match.start(), Name.Class, line
|
472
|
+
elif tb:
|
473
|
+
curtb += line
|
474
|
+
if not (line.startswith(' ') or line.strip() == u'...'):
|
475
|
+
tb = 0
|
476
|
+
for i, t, v in tblexer.get_tokens_unprocessed(curtb):
|
477
|
+
yield tbindex+i, t, v
|
478
|
+
curtb = ''
|
479
|
+
else:
|
480
|
+
yield match.start(), Generic.Output, line
|
481
|
+
if curcode:
|
482
|
+
for item in do_insertions(insertions,
|
483
|
+
pylexer.get_tokens_unprocessed(curcode)):
|
484
|
+
yield item
|
485
|
+
if curtb:
|
486
|
+
for i, t, v in tblexer.get_tokens_unprocessed(curtb):
|
487
|
+
yield tbindex+i, t, v
|
488
|
+
|
489
|
+
|
490
|
+
class PythonTracebackLexer(RegexLexer):
|
491
|
+
"""
|
492
|
+
For Python tracebacks.
|
493
|
+
|
494
|
+
.. versionadded:: 0.7
|
495
|
+
"""
|
496
|
+
|
497
|
+
name = 'Python Traceback'
|
498
|
+
aliases = ['pytb']
|
499
|
+
filenames = ['*.pytb']
|
500
|
+
mimetypes = ['text/x-python-traceback']
|
501
|
+
|
502
|
+
tokens = {
|
503
|
+
'root': [
|
504
|
+
# Cover both (most recent call last) and (innermost last)
|
505
|
+
# The optional ^C allows us to catch keyboard interrupt signals.
|
506
|
+
(r'^(\^C)?(Traceback.*\n)',
|
507
|
+
bygroups(Text, Generic.Traceback), 'intb'),
|
508
|
+
# SyntaxError starts with this.
|
509
|
+
(r'^(?= File "[^"]+", line \d+)', Generic.Traceback, 'intb'),
|
510
|
+
(r'^.*\n', Other),
|
511
|
+
],
|
512
|
+
'intb': [
|
513
|
+
(r'^( File )("[^"]+")(, line )(\d+)(, in )(.+)(\n)',
|
514
|
+
bygroups(Text, Name.Builtin, Text, Number, Text, Name, Text)),
|
515
|
+
(r'^( File )("[^"]+")(, line )(\d+)(\n)',
|
516
|
+
bygroups(Text, Name.Builtin, Text, Number, Text)),
|
517
|
+
(r'^( )(.+)(\n)',
|
518
|
+
bygroups(Text, using(PythonLexer), Text)),
|
519
|
+
(r'^([ \t]*)(\.\.\.)(\n)',
|
520
|
+
bygroups(Text, Comment, Text)), # for doctests...
|
521
|
+
(r'^([^:]+)(: )(.+)(\n)',
|
522
|
+
bygroups(Generic.Error, Text, Name, Text), '#pop'),
|
523
|
+
(r'^([a-zA-Z_]\w*)(:?\n)',
|
524
|
+
bygroups(Generic.Error, Text), '#pop')
|
525
|
+
],
|
526
|
+
}
|
527
|
+
|
528
|
+
|
529
|
+
class Python3TracebackLexer(RegexLexer):
|
530
|
+
"""
|
531
|
+
For Python 3.0 tracebacks, with support for chained exceptions.
|
532
|
+
|
533
|
+
.. versionadded:: 1.0
|
534
|
+
"""
|
535
|
+
|
536
|
+
name = 'Python 3.0 Traceback'
|
537
|
+
aliases = ['py3tb']
|
538
|
+
filenames = ['*.py3tb']
|
539
|
+
mimetypes = ['text/x-python3-traceback']
|
540
|
+
|
541
|
+
tokens = {
|
542
|
+
'root': [
|
543
|
+
(r'\n', Text),
|
544
|
+
(r'^Traceback \(most recent call last\):\n', Generic.Traceback, 'intb'),
|
545
|
+
(r'^During handling of the above exception, another '
|
546
|
+
r'exception occurred:\n\n', Generic.Traceback),
|
547
|
+
(r'^The above exception was the direct cause of the '
|
548
|
+
r'following exception:\n\n', Generic.Traceback),
|
549
|
+
(r'^(?= File "[^"]+", line \d+)', Generic.Traceback, 'intb'),
|
550
|
+
],
|
551
|
+
'intb': [
|
552
|
+
(r'^( File )("[^"]+")(, line )(\d+)(, in )(.+)(\n)',
|
553
|
+
bygroups(Text, Name.Builtin, Text, Number, Text, Name, Text)),
|
554
|
+
(r'^( File )("[^"]+")(, line )(\d+)(\n)',
|
555
|
+
bygroups(Text, Name.Builtin, Text, Number, Text)),
|
556
|
+
(r'^( )(.+)(\n)',
|
557
|
+
bygroups(Text, using(Python3Lexer), Text)),
|
558
|
+
(r'^([ \t]*)(\.\.\.)(\n)',
|
559
|
+
bygroups(Text, Comment, Text)), # for doctests...
|
560
|
+
(r'^([^:]+)(: )(.+)(\n)',
|
561
|
+
bygroups(Generic.Error, Text, Name, Text), '#pop'),
|
562
|
+
(r'^([a-zA-Z_]\w*)(:?\n)',
|
563
|
+
bygroups(Generic.Error, Text), '#pop')
|
564
|
+
],
|
565
|
+
}
|
566
|
+
|
567
|
+
|
568
|
+
class CythonLexer(RegexLexer):
|
569
|
+
"""
|
570
|
+
For Pyrex and `Cython <http://cython.org>`_ source code.
|
571
|
+
|
572
|
+
.. versionadded:: 1.1
|
573
|
+
"""
|
574
|
+
|
575
|
+
name = 'Cython'
|
576
|
+
aliases = ['cython', 'pyx', 'pyrex']
|
577
|
+
filenames = ['*.pyx', '*.pxd', '*.pxi']
|
578
|
+
mimetypes = ['text/x-cython', 'application/x-cython']
|
579
|
+
|
580
|
+
tokens = {
|
581
|
+
'root': [
|
582
|
+
(r'\n', Text),
|
583
|
+
(r'^(\s*)("""(?:.|\n)*?""")', bygroups(Text, String.Doc)),
|
584
|
+
(r"^(\s*)('''(?:.|\n)*?''')", bygroups(Text, String.Doc)),
|
585
|
+
(r'[^\S\n]+', Text),
|
586
|
+
(r'#.*$', Comment),
|
587
|
+
(r'[]{}:(),;[]', Punctuation),
|
588
|
+
(r'\\\n', Text),
|
589
|
+
(r'\\', Text),
|
590
|
+
(r'(in|is|and|or|not)\b', Operator.Word),
|
591
|
+
(r'(<)([a-zA-Z0-9.?]+)(>)',
|
592
|
+
bygroups(Punctuation, Keyword.Type, Punctuation)),
|
593
|
+
(r'!=|==|<<|>>|[-~+/*%=<>&^|.?]', Operator),
|
594
|
+
(r'(from)(\d+)(<=)(\s+)(<)(\d+)(:)',
|
595
|
+
bygroups(Keyword, Number.Integer, Operator, Name, Operator,
|
596
|
+
Name, Punctuation)),
|
597
|
+
include('keywords'),
|
598
|
+
(r'(def|property)(\s+)', bygroups(Keyword, Text), 'funcname'),
|
599
|
+
(r'(cp?def)(\s+)', bygroups(Keyword, Text), 'cdef'),
|
600
|
+
# (should actually start a block with only cdefs)
|
601
|
+
(r'(cdef)(:)', bygroups(Keyword, Punctuation)),
|
602
|
+
(r'(class|struct)(\s+)', bygroups(Keyword, Text), 'classname'),
|
603
|
+
(r'(from)(\s+)', bygroups(Keyword, Text), 'fromimport'),
|
604
|
+
(r'(c?import)(\s+)', bygroups(Keyword, Text), 'import'),
|
605
|
+
include('builtins'),
|
606
|
+
include('backtick'),
|
607
|
+
('(?:[rR]|[uU][rR]|[rR][uU])"""', String, 'tdqs'),
|
608
|
+
("(?:[rR]|[uU][rR]|[rR][uU])'''", String, 'tsqs'),
|
609
|
+
('(?:[rR]|[uU][rR]|[rR][uU])"', String, 'dqs'),
|
610
|
+
("(?:[rR]|[uU][rR]|[rR][uU])'", String, 'sqs'),
|
611
|
+
('[uU]?"""', String, combined('stringescape', 'tdqs')),
|
612
|
+
("[uU]?'''", String, combined('stringescape', 'tsqs')),
|
613
|
+
('[uU]?"', String, combined('stringescape', 'dqs')),
|
614
|
+
("[uU]?'", String, combined('stringescape', 'sqs')),
|
615
|
+
include('name'),
|
616
|
+
include('numbers'),
|
617
|
+
],
|
618
|
+
'keywords': [
|
619
|
+
(words((
|
620
|
+
'assert', 'break', 'by', 'continue', 'ctypedef', 'del', 'elif',
|
621
|
+
'else', 'except', 'except?', 'exec', 'finally', 'for', 'fused', 'gil',
|
622
|
+
'global', 'if', 'include', 'lambda', 'nogil', 'pass', 'print',
|
623
|
+
'raise', 'return', 'try', 'while', 'yield', 'as', 'with'), suffix=r'\b'),
|
624
|
+
Keyword),
|
625
|
+
(r'(DEF|IF|ELIF|ELSE)\b', Comment.Preproc),
|
626
|
+
],
|
627
|
+
'builtins': [
|
628
|
+
(words((
|
629
|
+
'__import__', 'abs', 'all', 'any', 'apply', 'basestring', 'bin',
|
630
|
+
'bool', 'buffer', 'bytearray', 'bytes', 'callable', 'chr',
|
631
|
+
'classmethod', 'cmp', 'coerce', 'compile', 'complex', 'delattr',
|
632
|
+
'dict', 'dir', 'divmod', 'enumerate', 'eval', 'execfile', 'exit',
|
633
|
+
'file', 'filter', 'float', 'frozenset', 'getattr', 'globals',
|
634
|
+
'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'intern', 'isinstance',
|
635
|
+
'issubclass', 'iter', 'len', 'list', 'locals', 'long', 'map', 'max',
|
636
|
+
'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'property',
|
637
|
+
'range', 'raw_input', 'reduce', 'reload', 'repr', 'reversed',
|
638
|
+
'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod',
|
639
|
+
'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'unsigned',
|
640
|
+
'vars', 'xrange', 'zip'), prefix=r'(?<!\.)', suffix=r'\b'),
|
641
|
+
Name.Builtin),
|
642
|
+
(r'(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|NULL'
|
643
|
+
r')\b', Name.Builtin.Pseudo),
|
644
|
+
(words((
|
645
|
+
'ArithmeticError', 'AssertionError', 'AttributeError',
|
646
|
+
'BaseException', 'DeprecationWarning', 'EOFError', 'EnvironmentError',
|
647
|
+
'Exception', 'FloatingPointError', 'FutureWarning', 'GeneratorExit',
|
648
|
+
'IOError', 'ImportError', 'ImportWarning', 'IndentationError',
|
649
|
+
'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError',
|
650
|
+
'MemoryError', 'NameError', 'NotImplemented', 'NotImplementedError',
|
651
|
+
'OSError', 'OverflowError', 'OverflowWarning',
|
652
|
+
'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError',
|
653
|
+
'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError',
|
654
|
+
'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError',
|
655
|
+
'TypeError', 'UnboundLocalError', 'UnicodeDecodeError',
|
656
|
+
'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError',
|
657
|
+
'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning',
|
658
|
+
'ZeroDivisionError'), prefix=r'(?<!\.)', suffix=r'\b'),
|
659
|
+
Name.Exception),
|
660
|
+
],
|
661
|
+
'numbers': [
|
662
|
+
(r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
|
663
|
+
(r'0\d+', Number.Oct),
|
664
|
+
(r'0[xX][a-fA-F0-9]+', Number.Hex),
|
665
|
+
(r'\d+L', Number.Integer.Long),
|
666
|
+
(r'\d+', Number.Integer)
|
667
|
+
],
|
668
|
+
'backtick': [
|
669
|
+
('`.*?`', String.Backtick),
|
670
|
+
],
|
671
|
+
'name': [
|
672
|
+
(r'@\w+', Name.Decorator),
|
673
|
+
('[a-zA-Z_]\w*', Name),
|
674
|
+
],
|
675
|
+
'funcname': [
|
676
|
+
('[a-zA-Z_]\w*', Name.Function, '#pop')
|
677
|
+
],
|
678
|
+
'cdef': [
|
679
|
+
(r'(public|readonly|extern|api|inline)\b', Keyword.Reserved),
|
680
|
+
(r'(struct|enum|union|class)\b', Keyword),
|
681
|
+
(r'([a-zA-Z_]\w*)(\s*)(?=[(:#=]|$)',
|
682
|
+
bygroups(Name.Function, Text), '#pop'),
|
683
|
+
(r'([a-zA-Z_]\w*)(\s*)(,)',
|
684
|
+
bygroups(Name.Function, Text, Punctuation)),
|
685
|
+
(r'from\b', Keyword, '#pop'),
|
686
|
+
(r'as\b', Keyword),
|
687
|
+
(r':', Punctuation, '#pop'),
|
688
|
+
(r'(?=["\'])', Text, '#pop'),
|
689
|
+
(r'[a-zA-Z_]\w*', Keyword.Type),
|
690
|
+
(r'.', Text),
|
691
|
+
],
|
692
|
+
'classname': [
|
693
|
+
('[a-zA-Z_]\w*', Name.Class, '#pop')
|
694
|
+
],
|
695
|
+
'import': [
|
696
|
+
(r'(\s+)(as)(\s+)', bygroups(Text, Keyword, Text)),
|
697
|
+
(r'[a-zA-Z_][\w.]*', Name.Namespace),
|
698
|
+
(r'(\s*)(,)(\s*)', bygroups(Text, Operator, Text)),
|
699
|
+
default('#pop') # all else: go back
|
700
|
+
],
|
701
|
+
'fromimport': [
|
702
|
+
(r'(\s+)(c?import)\b', bygroups(Text, Keyword), '#pop'),
|
703
|
+
(r'[a-zA-Z_.][\w.]*', Name.Namespace),
|
704
|
+
# ``cdef foo from "header"``, or ``for foo from 0 < i < 10``
|
705
|
+
default('#pop'),
|
706
|
+
],
|
707
|
+
'stringescape': [
|
708
|
+
(r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|'
|
709
|
+
r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
|
710
|
+
],
|
711
|
+
'strings': [
|
712
|
+
(r'%(\([a-zA-Z0-9]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
|
713
|
+
'[hlL]?[E-GXc-giorsux%]', String.Interpol),
|
714
|
+
(r'[^\\\'"%\n]+', String),
|
715
|
+
# quotes, percents and backslashes must be parsed one at a time
|
716
|
+
(r'[\'"\\]', String),
|
717
|
+
# unhandled string formatting sign
|
718
|
+
(r'%', String)
|
719
|
+
# newlines are an error (use "nl" state)
|
720
|
+
],
|
721
|
+
'nl': [
|
722
|
+
(r'\n', String)
|
723
|
+
],
|
724
|
+
'dqs': [
|
725
|
+
(r'"', String, '#pop'),
|
726
|
+
(r'\\\\|\\"|\\\n', String.Escape), # included here again for raw strings
|
727
|
+
include('strings')
|
728
|
+
],
|
729
|
+
'sqs': [
|
730
|
+
(r"'", String, '#pop'),
|
731
|
+
(r"\\\\|\\'|\\\n", String.Escape), # included here again for raw strings
|
732
|
+
include('strings')
|
733
|
+
],
|
734
|
+
'tdqs': [
|
735
|
+
(r'"""', String, '#pop'),
|
736
|
+
include('strings'),
|
737
|
+
include('nl')
|
738
|
+
],
|
739
|
+
'tsqs': [
|
740
|
+
(r"'''", String, '#pop'),
|
741
|
+
include('strings'),
|
742
|
+
include('nl')
|
743
|
+
],
|
744
|
+
}
|
745
|
+
|
746
|
+
|
747
|
+
class DgLexer(RegexLexer):
|
748
|
+
"""
|
749
|
+
Lexer for `dg <http://pyos.github.com/dg>`_,
|
750
|
+
a functional and object-oriented programming language
|
751
|
+
running on the CPython 3 VM.
|
752
|
+
|
753
|
+
.. versionadded:: 1.6
|
754
|
+
"""
|
755
|
+
name = 'dg'
|
756
|
+
aliases = ['dg']
|
757
|
+
filenames = ['*.dg']
|
758
|
+
mimetypes = ['text/x-dg']
|
759
|
+
|
760
|
+
tokens = {
|
761
|
+
'root': [
|
762
|
+
(r'\s+', Text),
|
763
|
+
(r'#.*?$', Comment.Single),
|
764
|
+
|
765
|
+
(r'(?i)0b[01]+', Number.Bin),
|
766
|
+
(r'(?i)0o[0-7]+', Number.Oct),
|
767
|
+
(r'(?i)0x[0-9a-f]+', Number.Hex),
|
768
|
+
(r'(?i)[+-]?[0-9]+\.[0-9]+(e[+-]?[0-9]+)?j?', Number.Float),
|
769
|
+
(r'(?i)[+-]?[0-9]+e[+-]?\d+j?', Number.Float),
|
770
|
+
(r'(?i)[+-]?[0-9]+j?', Number.Integer),
|
771
|
+
|
772
|
+
(r"(?i)(br|r?b?)'''", String, combined('stringescape', 'tsqs', 'string')),
|
773
|
+
(r'(?i)(br|r?b?)"""', String, combined('stringescape', 'tdqs', 'string')),
|
774
|
+
(r"(?i)(br|r?b?)'", String, combined('stringescape', 'sqs', 'string')),
|
775
|
+
(r'(?i)(br|r?b?)"', String, combined('stringescape', 'dqs', 'string')),
|
776
|
+
|
777
|
+
(r"`\w+'*`", Operator),
|
778
|
+
(r'\b(and|in|is|or|where)\b', Operator.Word),
|
779
|
+
(r'[!$%&*+\-./:<-@\\^|~;,]+', Operator),
|
780
|
+
|
781
|
+
(words((
|
782
|
+
'bool', 'bytearray', 'bytes', 'classmethod', 'complex', 'dict', 'dict\'',
|
783
|
+
'float', 'frozenset', 'int', 'list', 'list\'', 'memoryview', 'object',
|
784
|
+
'property', 'range', 'set', 'set\'', 'slice', 'staticmethod', 'str',
|
785
|
+
'super', 'tuple', 'tuple\'', 'type'),
|
786
|
+
prefix=r'(?<!\.)', suffix=r'(?![\'\w])'),
|
787
|
+
Name.Builtin),
|
788
|
+
(words((
|
789
|
+
'__import__', 'abs', 'all', 'any', 'bin', 'bind', 'chr', 'cmp', 'compile',
|
790
|
+
'complex', 'delattr', 'dir', 'divmod', 'drop', 'dropwhile', 'enumerate',
|
791
|
+
'eval', 'exhaust', 'filter', 'flip', 'foldl1?', 'format', 'fst',
|
792
|
+
'getattr', 'globals', 'hasattr', 'hash', 'head', 'hex', 'id', 'init',
|
793
|
+
'input', 'isinstance', 'issubclass', 'iter', 'iterate', 'last', 'len',
|
794
|
+
'locals', 'map', 'max', 'min', 'next', 'oct', 'open', 'ord', 'pow',
|
795
|
+
'print', 'repr', 'reversed', 'round', 'setattr', 'scanl1?', 'snd',
|
796
|
+
'sorted', 'sum', 'tail', 'take', 'takewhile', 'vars', 'zip'),
|
797
|
+
prefix=r'(?<!\.)', suffix=r'(?![\'\w])'),
|
798
|
+
Name.Builtin),
|
799
|
+
(r"(?<!\.)(self|Ellipsis|NotImplemented|None|True|False)(?!['\w])",
|
800
|
+
Name.Builtin.Pseudo),
|
801
|
+
|
802
|
+
(r"(?<!\.)[A-Z]\w*(Error|Exception|Warning)'*(?!['\w])",
|
803
|
+
Name.Exception),
|
804
|
+
(r"(?<!\.)(Exception|GeneratorExit|KeyboardInterrupt|StopIteration|"
|
805
|
+
r"SystemExit)(?!['\w])", Name.Exception),
|
806
|
+
|
807
|
+
(r"(?<![\w.])(except|finally|for|if|import|not|otherwise|raise|"
|
808
|
+
r"subclass|while|with|yield)(?!['\w])", Keyword.Reserved),
|
809
|
+
|
810
|
+
(r"[A-Z_]+'*(?!['\w])", Name),
|
811
|
+
(r"[A-Z]\w+'*(?!['\w])", Keyword.Type),
|
812
|
+
(r"\w+'*", Name),
|
813
|
+
|
814
|
+
(r'[()]', Punctuation),
|
815
|
+
(r'.', Error),
|
816
|
+
],
|
817
|
+
'stringescape': [
|
818
|
+
(r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|'
|
819
|
+
r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
|
820
|
+
],
|
821
|
+
'string': [
|
822
|
+
(r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
|
823
|
+
'[hlL]?[E-GXc-giorsux%]', String.Interpol),
|
824
|
+
(r'[^\\\'"%\n]+', String),
|
825
|
+
# quotes, percents and backslashes must be parsed one at a time
|
826
|
+
(r'[\'"\\]', String),
|
827
|
+
# unhandled string formatting sign
|
828
|
+
(r'%', String),
|
829
|
+
(r'\n', String)
|
830
|
+
],
|
831
|
+
'dqs': [
|
832
|
+
(r'"', String, '#pop')
|
833
|
+
],
|
834
|
+
'sqs': [
|
835
|
+
(r"'", String, '#pop')
|
836
|
+
],
|
837
|
+
'tdqs': [
|
838
|
+
(r'"""', String, '#pop')
|
839
|
+
],
|
840
|
+
'tsqs': [
|
841
|
+
(r"'''", String, '#pop')
|
842
|
+
],
|
843
|
+
}
|
844
|
+
|
845
|
+
|
846
|
+
class NumPyLexer(PythonLexer):
|
847
|
+
"""
|
848
|
+
A Python lexer recognizing Numerical Python builtins.
|
849
|
+
|
850
|
+
.. versionadded:: 0.10
|
851
|
+
"""
|
852
|
+
|
853
|
+
name = 'NumPy'
|
854
|
+
aliases = ['numpy']
|
855
|
+
|
856
|
+
# override the mimetypes to not inherit them from python
|
857
|
+
mimetypes = []
|
858
|
+
filenames = []
|
859
|
+
|
860
|
+
EXTRA_KEYWORDS = set((
|
861
|
+
'abs', 'absolute', 'accumulate', 'add', 'alen', 'all', 'allclose',
|
862
|
+
'alltrue', 'alterdot', 'amax', 'amin', 'angle', 'any', 'append',
|
863
|
+
'apply_along_axis', 'apply_over_axes', 'arange', 'arccos', 'arccosh',
|
864
|
+
'arcsin', 'arcsinh', 'arctan', 'arctan2', 'arctanh', 'argmax', 'argmin',
|
865
|
+
'argsort', 'argwhere', 'around', 'array', 'array2string', 'array_equal',
|
866
|
+
'array_equiv', 'array_repr', 'array_split', 'array_str', 'arrayrange',
|
867
|
+
'asanyarray', 'asarray', 'asarray_chkfinite', 'ascontiguousarray',
|
868
|
+
'asfarray', 'asfortranarray', 'asmatrix', 'asscalar', 'astype',
|
869
|
+
'atleast_1d', 'atleast_2d', 'atleast_3d', 'average', 'bartlett',
|
870
|
+
'base_repr', 'beta', 'binary_repr', 'bincount', 'binomial',
|
871
|
+
'bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'blackman',
|
872
|
+
'bmat', 'broadcast', 'byte_bounds', 'bytes', 'byteswap', 'c_',
|
873
|
+
'can_cast', 'ceil', 'choose', 'clip', 'column_stack', 'common_type',
|
874
|
+
'compare_chararrays', 'compress', 'concatenate', 'conj', 'conjugate',
|
875
|
+
'convolve', 'copy', 'corrcoef', 'correlate', 'cos', 'cosh', 'cov',
|
876
|
+
'cross', 'cumprod', 'cumproduct', 'cumsum', 'delete', 'deprecate',
|
877
|
+
'diag', 'diagflat', 'diagonal', 'diff', 'digitize', 'disp', 'divide',
|
878
|
+
'dot', 'dsplit', 'dstack', 'dtype', 'dump', 'dumps', 'ediff1d', 'empty',
|
879
|
+
'empty_like', 'equal', 'exp', 'expand_dims', 'expm1', 'extract', 'eye',
|
880
|
+
'fabs', 'fastCopyAndTranspose', 'fft', 'fftfreq', 'fftshift', 'fill',
|
881
|
+
'finfo', 'fix', 'flat', 'flatnonzero', 'flatten', 'fliplr', 'flipud',
|
882
|
+
'floor', 'floor_divide', 'fmod', 'frexp', 'fromarrays', 'frombuffer',
|
883
|
+
'fromfile', 'fromfunction', 'fromiter', 'frompyfunc', 'fromstring',
|
884
|
+
'generic', 'get_array_wrap', 'get_include', 'get_numarray_include',
|
885
|
+
'get_numpy_include', 'get_printoptions', 'getbuffer', 'getbufsize',
|
886
|
+
'geterr', 'geterrcall', 'geterrobj', 'getfield', 'gradient', 'greater',
|
887
|
+
'greater_equal', 'gumbel', 'hamming', 'hanning', 'histogram',
|
888
|
+
'histogram2d', 'histogramdd', 'hsplit', 'hstack', 'hypot', 'i0',
|
889
|
+
'identity', 'ifft', 'imag', 'index_exp', 'indices', 'inf', 'info',
|
890
|
+
'inner', 'insert', 'int_asbuffer', 'interp', 'intersect1d',
|
891
|
+
'intersect1d_nu', 'inv', 'invert', 'iscomplex', 'iscomplexobj',
|
892
|
+
'isfinite', 'isfortran', 'isinf', 'isnan', 'isneginf', 'isposinf',
|
893
|
+
'isreal', 'isrealobj', 'isscalar', 'issctype', 'issubclass_',
|
894
|
+
'issubdtype', 'issubsctype', 'item', 'itemset', 'iterable', 'ix_',
|
895
|
+
'kaiser', 'kron', 'ldexp', 'left_shift', 'less', 'less_equal', 'lexsort',
|
896
|
+
'linspace', 'load', 'loads', 'loadtxt', 'log', 'log10', 'log1p', 'log2',
|
897
|
+
'logical_and', 'logical_not', 'logical_or', 'logical_xor', 'logspace',
|
898
|
+
'lstsq', 'mat', 'matrix', 'max', 'maximum', 'maximum_sctype',
|
899
|
+
'may_share_memory', 'mean', 'median', 'meshgrid', 'mgrid', 'min',
|
900
|
+
'minimum', 'mintypecode', 'mod', 'modf', 'msort', 'multiply', 'nan',
|
901
|
+
'nan_to_num', 'nanargmax', 'nanargmin', 'nanmax', 'nanmin', 'nansum',
|
902
|
+
'ndenumerate', 'ndim', 'ndindex', 'negative', 'newaxis', 'newbuffer',
|
903
|
+
'newbyteorder', 'nonzero', 'not_equal', 'obj2sctype', 'ogrid', 'ones',
|
904
|
+
'ones_like', 'outer', 'permutation', 'piecewise', 'pinv', 'pkgload',
|
905
|
+
'place', 'poisson', 'poly', 'poly1d', 'polyadd', 'polyder', 'polydiv',
|
906
|
+
'polyfit', 'polyint', 'polymul', 'polysub', 'polyval', 'power', 'prod',
|
907
|
+
'product', 'ptp', 'put', 'putmask', 'r_', 'randint', 'random_integers',
|
908
|
+
'random_sample', 'ranf', 'rank', 'ravel', 'real', 'real_if_close',
|
909
|
+
'recarray', 'reciprocal', 'reduce', 'remainder', 'repeat', 'require',
|
910
|
+
'reshape', 'resize', 'restoredot', 'right_shift', 'rint', 'roll',
|
911
|
+
'rollaxis', 'roots', 'rot90', 'round', 'round_', 'row_stack', 's_',
|
912
|
+
'sample', 'savetxt', 'sctype2char', 'searchsorted', 'seed', 'select',
|
913
|
+
'set_numeric_ops', 'set_printoptions', 'set_string_function',
|
914
|
+
'setbufsize', 'setdiff1d', 'seterr', 'seterrcall', 'seterrobj',
|
915
|
+
'setfield', 'setflags', 'setmember1d', 'setxor1d', 'shape',
|
916
|
+
'show_config', 'shuffle', 'sign', 'signbit', 'sin', 'sinc', 'sinh',
|
917
|
+
'size', 'slice', 'solve', 'sometrue', 'sort', 'sort_complex', 'source',
|
918
|
+
'split', 'sqrt', 'square', 'squeeze', 'standard_normal', 'std',
|
919
|
+
'subtract', 'sum', 'svd', 'swapaxes', 'take', 'tan', 'tanh', 'tensordot',
|
920
|
+
'test', 'tile', 'tofile', 'tolist', 'tostring', 'trace', 'transpose',
|
921
|
+
'trapz', 'tri', 'tril', 'trim_zeros', 'triu', 'true_divide', 'typeDict',
|
922
|
+
'typename', 'uniform', 'union1d', 'unique', 'unique1d', 'unravel_index',
|
923
|
+
'unwrap', 'vander', 'var', 'vdot', 'vectorize', 'view', 'vonmises',
|
924
|
+
'vsplit', 'vstack', 'weibull', 'where', 'who', 'zeros', 'zeros_like'
|
925
|
+
))
|
926
|
+
|
927
|
+
def get_tokens_unprocessed(self, text):
|
928
|
+
for index, token, value in \
|
929
|
+
PythonLexer.get_tokens_unprocessed(self, text):
|
930
|
+
if token is Name and value in self.EXTRA_KEYWORDS:
|
931
|
+
yield index, Keyword.Pseudo, value
|
932
|
+
else:
|
933
|
+
yield index, token, value
|
934
|
+
|
935
|
+
def analyse_text(text):
|
936
|
+
return (shebang_matches(text, r'pythonw?(2(\.\d)?)?') or
|
937
|
+
'import ' in text[:1000]) \
|
938
|
+
and ('import numpy' in text or 'from numpy import' in text)
|