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,240 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.actionscript
|
4
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexers for ActionScript and MXML.
|
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, using, this, words, default
|
15
|
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
16
|
+
Number, Punctuation
|
17
|
+
|
18
|
+
__all__ = ['ActionScriptLexer', 'ActionScript3Lexer', 'MxmlLexer']
|
19
|
+
|
20
|
+
|
21
|
+
class ActionScriptLexer(RegexLexer):
|
22
|
+
"""
|
23
|
+
For ActionScript source code.
|
24
|
+
|
25
|
+
.. versionadded:: 0.9
|
26
|
+
"""
|
27
|
+
|
28
|
+
name = 'ActionScript'
|
29
|
+
aliases = ['as', 'actionscript']
|
30
|
+
filenames = ['*.as']
|
31
|
+
mimetypes = ['application/x-actionscript', 'text/x-actionscript',
|
32
|
+
'text/actionscript']
|
33
|
+
|
34
|
+
flags = re.DOTALL
|
35
|
+
tokens = {
|
36
|
+
'root': [
|
37
|
+
(r'\s+', Text),
|
38
|
+
(r'//.*?\n', Comment.Single),
|
39
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
40
|
+
(r'/(\\\\|\\/|[^/\n])*/[gim]*', String.Regex),
|
41
|
+
(r'[~^*!%&<>|+=:;,/?\\-]+', Operator),
|
42
|
+
(r'[{}\[\]();.]+', Punctuation),
|
43
|
+
(words((
|
44
|
+
'case', 'default', 'for', 'each', 'in', 'while', 'do', 'break',
|
45
|
+
'return', 'continue', 'if', 'else', 'throw', 'try', 'catch',
|
46
|
+
'var', 'with', 'new', 'typeof', 'arguments', 'instanceof', 'this',
|
47
|
+
'switch'), suffix=r'\b'),
|
48
|
+
Keyword),
|
49
|
+
(words((
|
50
|
+
'class', 'public', 'final', 'internal', 'native', 'override', 'private',
|
51
|
+
'protected', 'static', 'import', 'extends', 'implements', 'interface',
|
52
|
+
'intrinsic', 'return', 'super', 'dynamic', 'function', 'const', 'get',
|
53
|
+
'namespace', 'package', 'set'), suffix=r'\b'),
|
54
|
+
Keyword.Declaration),
|
55
|
+
(r'(true|false|null|NaN|Infinity|-Infinity|undefined|Void)\b',
|
56
|
+
Keyword.Constant),
|
57
|
+
(words((
|
58
|
+
'Accessibility', 'AccessibilityProperties', 'ActionScriptVersion',
|
59
|
+
'ActivityEvent', 'AntiAliasType', 'ApplicationDomain', 'AsBroadcaster', 'Array',
|
60
|
+
'AsyncErrorEvent', 'AVM1Movie', 'BevelFilter', 'Bitmap', 'BitmapData',
|
61
|
+
'BitmapDataChannel', 'BitmapFilter', 'BitmapFilterQuality', 'BitmapFilterType',
|
62
|
+
'BlendMode', 'BlurFilter', 'Boolean', 'ByteArray', 'Camera', 'Capabilities', 'CapsStyle',
|
63
|
+
'Class', 'Color', 'ColorMatrixFilter', 'ColorTransform', 'ContextMenu',
|
64
|
+
'ContextMenuBuiltInItems', 'ContextMenuEvent', 'ContextMenuItem',
|
65
|
+
'ConvultionFilter', 'CSMSettings', 'DataEvent', 'Date', 'DefinitionError',
|
66
|
+
'DeleteObjectSample', 'Dictionary', 'DisplacmentMapFilter', 'DisplayObject',
|
67
|
+
'DisplacmentMapFilterMode', 'DisplayObjectContainer', 'DropShadowFilter',
|
68
|
+
'Endian', 'EOFError', 'Error', 'ErrorEvent', 'EvalError', 'Event', 'EventDispatcher',
|
69
|
+
'EventPhase', 'ExternalInterface', 'FileFilter', 'FileReference',
|
70
|
+
'FileReferenceList', 'FocusDirection', 'FocusEvent', 'Font', 'FontStyle', 'FontType',
|
71
|
+
'FrameLabel', 'FullScreenEvent', 'Function', 'GlowFilter', 'GradientBevelFilter',
|
72
|
+
'GradientGlowFilter', 'GradientType', 'Graphics', 'GridFitType', 'HTTPStatusEvent',
|
73
|
+
'IBitmapDrawable', 'ID3Info', 'IDataInput', 'IDataOutput', 'IDynamicPropertyOutput'
|
74
|
+
'IDynamicPropertyWriter', 'IEventDispatcher', 'IExternalizable',
|
75
|
+
'IllegalOperationError', 'IME', 'IMEConversionMode', 'IMEEvent', 'int',
|
76
|
+
'InteractiveObject', 'InterpolationMethod', 'InvalidSWFError', 'InvokeEvent',
|
77
|
+
'IOError', 'IOErrorEvent', 'JointStyle', 'Key', 'Keyboard', 'KeyboardEvent', 'KeyLocation',
|
78
|
+
'LineScaleMode', 'Loader', 'LoaderContext', 'LoaderInfo', 'LoadVars', 'LocalConnection',
|
79
|
+
'Locale', 'Math', 'Matrix', 'MemoryError', 'Microphone', 'MorphShape', 'Mouse', 'MouseEvent',
|
80
|
+
'MovieClip', 'MovieClipLoader', 'Namespace', 'NetConnection', 'NetStatusEvent',
|
81
|
+
'NetStream', 'NewObjectSample', 'Number', 'Object', 'ObjectEncoding', 'PixelSnapping',
|
82
|
+
'Point', 'PrintJob', 'PrintJobOptions', 'PrintJobOrientation', 'ProgressEvent', 'Proxy',
|
83
|
+
'QName', 'RangeError', 'Rectangle', 'ReferenceError', 'RegExp', 'Responder', 'Sample',
|
84
|
+
'Scene', 'ScriptTimeoutError', 'Security', 'SecurityDomain', 'SecurityError',
|
85
|
+
'SecurityErrorEvent', 'SecurityPanel', 'Selection', 'Shape', 'SharedObject',
|
86
|
+
'SharedObjectFlushStatus', 'SimpleButton', 'Socket', 'Sound', 'SoundChannel',
|
87
|
+
'SoundLoaderContext', 'SoundMixer', 'SoundTransform', 'SpreadMethod', 'Sprite',
|
88
|
+
'StackFrame', 'StackOverflowError', 'Stage', 'StageAlign', 'StageDisplayState',
|
89
|
+
'StageQuality', 'StageScaleMode', 'StaticText', 'StatusEvent', 'String', 'StyleSheet',
|
90
|
+
'SWFVersion', 'SyncEvent', 'SyntaxError', 'System', 'TextColorType', 'TextField',
|
91
|
+
'TextFieldAutoSize', 'TextFieldType', 'TextFormat', 'TextFormatAlign',
|
92
|
+
'TextLineMetrics', 'TextRenderer', 'TextSnapshot', 'Timer', 'TimerEvent', 'Transform',
|
93
|
+
'TypeError', 'uint', 'URIError', 'URLLoader', 'URLLoaderDataFormat', 'URLRequest',
|
94
|
+
'URLRequestHeader', 'URLRequestMethod', 'URLStream', 'URLVariabeles', 'VerifyError',
|
95
|
+
'Video', 'XML', 'XMLDocument', 'XMLList', 'XMLNode', 'XMLNodeType', 'XMLSocket',
|
96
|
+
'XMLUI'), suffix=r'\b'),
|
97
|
+
Name.Builtin),
|
98
|
+
(words((
|
99
|
+
'decodeURI', 'decodeURIComponent', 'encodeURI', 'escape', 'eval', 'isFinite', 'isNaN',
|
100
|
+
'isXMLName', 'clearInterval', 'fscommand', 'getTimer', 'getURL', 'getVersion',
|
101
|
+
'parseFloat', 'parseInt', 'setInterval', 'trace', 'updateAfterEvent',
|
102
|
+
'unescape'), suffix=r'\b'),
|
103
|
+
Name.Function),
|
104
|
+
(r'[$a-zA-Z_]\w*', Name.Other),
|
105
|
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
106
|
+
(r'0x[0-9a-f]+', Number.Hex),
|
107
|
+
(r'[0-9]+', Number.Integer),
|
108
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
109
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
110
|
+
]
|
111
|
+
}
|
112
|
+
|
113
|
+
|
114
|
+
class ActionScript3Lexer(RegexLexer):
|
115
|
+
"""
|
116
|
+
For ActionScript 3 source code.
|
117
|
+
|
118
|
+
.. versionadded:: 0.11
|
119
|
+
"""
|
120
|
+
|
121
|
+
name = 'ActionScript 3'
|
122
|
+
aliases = ['as3', 'actionscript3']
|
123
|
+
filenames = ['*.as']
|
124
|
+
mimetypes = ['application/x-actionscript3', 'text/x-actionscript3',
|
125
|
+
'text/actionscript3']
|
126
|
+
|
127
|
+
identifier = r'[$a-zA-Z_]\w*'
|
128
|
+
typeidentifier = identifier + '(?:\.<\w+>)?'
|
129
|
+
|
130
|
+
flags = re.DOTALL | re.MULTILINE
|
131
|
+
tokens = {
|
132
|
+
'root': [
|
133
|
+
(r'\s+', Text),
|
134
|
+
(r'(function\s+)(' + identifier + r')(\s*)(\()',
|
135
|
+
bygroups(Keyword.Declaration, Name.Function, Text, Operator),
|
136
|
+
'funcparams'),
|
137
|
+
(r'(var|const)(\s+)(' + identifier + r')(\s*)(:)(\s*)(' +
|
138
|
+
typeidentifier + r')',
|
139
|
+
bygroups(Keyword.Declaration, Text, Name, Text, Punctuation, Text,
|
140
|
+
Keyword.Type)),
|
141
|
+
(r'(import|package)(\s+)((?:' + identifier + r'|\.)+)(\s*)',
|
142
|
+
bygroups(Keyword, Text, Name.Namespace, Text)),
|
143
|
+
(r'(new)(\s+)(' + typeidentifier + r')(\s*)(\()',
|
144
|
+
bygroups(Keyword, Text, Keyword.Type, Text, Operator)),
|
145
|
+
(r'//.*?\n', Comment.Single),
|
146
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
147
|
+
(r'/(\\\\|\\/|[^\n])*/[gisx]*', String.Regex),
|
148
|
+
(r'(\.)(' + identifier + r')', bygroups(Operator, Name.Attribute)),
|
149
|
+
(r'(case|default|for|each|in|while|do|break|return|continue|if|else|'
|
150
|
+
r'throw|try|catch|with|new|typeof|arguments|instanceof|this|'
|
151
|
+
r'switch|import|include|as|is)\b',
|
152
|
+
Keyword),
|
153
|
+
(r'(class|public|final|internal|native|override|private|protected|'
|
154
|
+
r'static|import|extends|implements|interface|intrinsic|return|super|'
|
155
|
+
r'dynamic|function|const|get|namespace|package|set)\b',
|
156
|
+
Keyword.Declaration),
|
157
|
+
(r'(true|false|null|NaN|Infinity|-Infinity|undefined|void)\b',
|
158
|
+
Keyword.Constant),
|
159
|
+
(r'(decodeURI|decodeURIComponent|encodeURI|escape|eval|isFinite|isNaN|'
|
160
|
+
r'isXMLName|clearInterval|fscommand|getTimer|getURL|getVersion|'
|
161
|
+
r'isFinite|parseFloat|parseInt|setInterval|trace|updateAfterEvent|'
|
162
|
+
r'unescape)\b', Name.Function),
|
163
|
+
(identifier, Name),
|
164
|
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
165
|
+
(r'0x[0-9a-f]+', Number.Hex),
|
166
|
+
(r'[0-9]+', Number.Integer),
|
167
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
168
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
169
|
+
(r'[~^*!%&<>|+=:;,/?\\{}\[\]().-]+', Operator),
|
170
|
+
],
|
171
|
+
'funcparams': [
|
172
|
+
(r'\s+', Text),
|
173
|
+
(r'(\s*)(\.\.\.)?(' + identifier + r')(\s*)(:)(\s*)(' +
|
174
|
+
typeidentifier + r'|\*)(\s*)',
|
175
|
+
bygroups(Text, Punctuation, Name, Text, Operator, Text,
|
176
|
+
Keyword.Type, Text), 'defval'),
|
177
|
+
(r'\)', Operator, 'type')
|
178
|
+
],
|
179
|
+
'type': [
|
180
|
+
(r'(\s*)(:)(\s*)(' + typeidentifier + r'|\*)',
|
181
|
+
bygroups(Text, Operator, Text, Keyword.Type), '#pop:2'),
|
182
|
+
(r'\s+', Text, '#pop:2'),
|
183
|
+
default('#pop:2')
|
184
|
+
],
|
185
|
+
'defval': [
|
186
|
+
(r'(=)(\s*)([^(),]+)(\s*)(,?)',
|
187
|
+
bygroups(Operator, Text, using(this), Text, Operator), '#pop'),
|
188
|
+
(r',', Operator, '#pop'),
|
189
|
+
default('#pop')
|
190
|
+
]
|
191
|
+
}
|
192
|
+
|
193
|
+
def analyse_text(text):
|
194
|
+
if re.match(r'\w+\s*:\s*\w', text):
|
195
|
+
return 0.3
|
196
|
+
return 0
|
197
|
+
|
198
|
+
|
199
|
+
class MxmlLexer(RegexLexer):
|
200
|
+
"""
|
201
|
+
For MXML markup.
|
202
|
+
Nested AS3 in <script> tags is highlighted by the appropriate lexer.
|
203
|
+
|
204
|
+
.. versionadded:: 1.1
|
205
|
+
"""
|
206
|
+
flags = re.MULTILINE | re.DOTALL
|
207
|
+
name = 'MXML'
|
208
|
+
aliases = ['mxml']
|
209
|
+
filenames = ['*.mxml']
|
210
|
+
mimetimes = ['text/xml', 'application/xml']
|
211
|
+
|
212
|
+
tokens = {
|
213
|
+
'root': [
|
214
|
+
('[^<&]+', Text),
|
215
|
+
(r'&\S*?;', Name.Entity),
|
216
|
+
(r'(\<\!\[CDATA\[)(.*?)(\]\]\>)',
|
217
|
+
bygroups(String, using(ActionScript3Lexer), String)),
|
218
|
+
('<!--', Comment, 'comment'),
|
219
|
+
(r'<\?.*?\?>', Comment.Preproc),
|
220
|
+
('<![^>]*>', Comment.Preproc),
|
221
|
+
(r'<\s*[\w:.-]+', Name.Tag, 'tag'),
|
222
|
+
(r'<\s*/\s*[\w:.-]+\s*>', Name.Tag),
|
223
|
+
],
|
224
|
+
'comment': [
|
225
|
+
('[^-]+', Comment),
|
226
|
+
('-->', Comment, '#pop'),
|
227
|
+
('-', Comment),
|
228
|
+
],
|
229
|
+
'tag': [
|
230
|
+
(r'\s+', Text),
|
231
|
+
(r'[\w.:-]+\s*=', Name.Attribute, 'attr'),
|
232
|
+
(r'/?\s*>', Name.Tag, '#pop'),
|
233
|
+
],
|
234
|
+
'attr': [
|
235
|
+
('\s+', Text),
|
236
|
+
('".*?"', String, '#pop'),
|
237
|
+
("'.*?'", String, '#pop'),
|
238
|
+
(r'[^\s>]+', String, '#pop'),
|
239
|
+
],
|
240
|
+
}
|
@@ -3,2550 +3,22 @@
|
|
3
3
|
pygments.lexers.agile
|
4
4
|
~~~~~~~~~~~~~~~~~~~~~
|
5
5
|
|
6
|
-
|
6
|
+
Just export lexer classes previously contained in this module.
|
7
7
|
|
8
|
-
:copyright: Copyright 2006-
|
8
|
+
:copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
|
9
9
|
:license: BSD, see LICENSE for details.
|
10
10
|
"""
|
11
11
|
|
12
|
-
import
|
13
|
-
|
14
|
-
from pygments.lexer import Lexer, RegexLexer, ExtendedRegexLexer, \
|
15
|
-
LexerContext, include, combined, do_insertions, bygroups, using, this, default
|
16
|
-
from pygments.token import Error, Text, Other, \
|
17
|
-
Comment, Operator, Keyword, Name, String, Number, Generic, Punctuation
|
18
|
-
from pygments.util import get_bool_opt, get_list_opt, shebang_matches, iteritems
|
19
|
-
from pygments import unistring as uni
|
20
|
-
|
21
|
-
|
22
|
-
__all__ = ['PythonLexer', 'PythonConsoleLexer', 'PythonTracebackLexer',
|
23
|
-
'Python3Lexer', 'Python3TracebackLexer', 'RubyLexer',
|
24
|
-
'RubyConsoleLexer', 'PerlLexer', 'LuaLexer', 'MoonScriptLexer',
|
25
|
-
'CrocLexer', 'MiniDLexer', 'IoLexer', 'TclLexer', 'FactorLexer',
|
26
|
-
'FancyLexer', 'DgLexer', 'Perl6Lexer', 'HyLexer',
|
27
|
-
'ChaiscriptLexer']
|
28
|
-
|
29
|
-
# b/w compatibility
|
30
|
-
from pygments.lexers.functional import SchemeLexer
|
12
|
+
from pygments.lexers.lisp import SchemeLexer
|
31
13
|
from pygments.lexers.jvm import IokeLexer, ClojureLexer
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
filenames = ['*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac', '*.sage']
|
44
|
-
mimetypes = ['text/x-python', 'application/x-python']
|
45
|
-
|
46
|
-
tokens = {
|
47
|
-
'root': [
|
48
|
-
(r'\n', Text),
|
49
|
-
(r'^(\s*)([rRuU]{,2}"""(?:.|\n)*?""")', bygroups(Text, String.Doc)),
|
50
|
-
(r"^(\s*)([rRuU]{,2}'''(?:.|\n)*?''')", bygroups(Text, String.Doc)),
|
51
|
-
(r'[^\S\n]+', Text),
|
52
|
-
(r'#.*$', Comment),
|
53
|
-
(r'[]{}:(),;[]', Punctuation),
|
54
|
-
(r'\\\n', Text),
|
55
|
-
(r'\\', Text),
|
56
|
-
(r'(in|is|and|or|not)\b', Operator.Word),
|
57
|
-
(r'!=|==|<<|>>|[-~+/*%=<>&^|.]', Operator),
|
58
|
-
include('keywords'),
|
59
|
-
(r'(def)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'funcname'),
|
60
|
-
(r'(class)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'classname'),
|
61
|
-
(r'(from)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text),
|
62
|
-
'fromimport'),
|
63
|
-
(r'(import)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text),
|
64
|
-
'import'),
|
65
|
-
include('builtins'),
|
66
|
-
include('backtick'),
|
67
|
-
('(?:[rR]|[uU][rR]|[rR][uU])"""', String, 'tdqs'),
|
68
|
-
("(?:[rR]|[uU][rR]|[rR][uU])'''", String, 'tsqs'),
|
69
|
-
('(?:[rR]|[uU][rR]|[rR][uU])"', String, 'dqs'),
|
70
|
-
("(?:[rR]|[uU][rR]|[rR][uU])'", String, 'sqs'),
|
71
|
-
('[uU]?"""', String, combined('stringescape', 'tdqs')),
|
72
|
-
("[uU]?'''", String, combined('stringescape', 'tsqs')),
|
73
|
-
('[uU]?"', String, combined('stringescape', 'dqs')),
|
74
|
-
("[uU]?'", String, combined('stringescape', 'sqs')),
|
75
|
-
include('name'),
|
76
|
-
include('numbers'),
|
77
|
-
],
|
78
|
-
'keywords': [
|
79
|
-
(r'(assert|break|continue|del|elif|else|except|exec|'
|
80
|
-
r'finally|for|global|if|lambda|pass|print|raise|'
|
81
|
-
r'return|try|while|yield(\s+from)?|as|with)\b', Keyword),
|
82
|
-
],
|
83
|
-
'builtins': [
|
84
|
-
(r'(?<!\.)(__import__|abs|all|any|apply|basestring|bin|bool|buffer|'
|
85
|
-
r'bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|'
|
86
|
-
r'complex|delattr|dict|dir|divmod|enumerate|eval|execfile|exit|'
|
87
|
-
r'file|filter|float|frozenset|getattr|globals|hasattr|hash|hex|id|'
|
88
|
-
r'input|int|intern|isinstance|issubclass|iter|len|list|locals|'
|
89
|
-
r'long|map|max|min|next|object|oct|open|ord|pow|property|range|'
|
90
|
-
r'raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|'
|
91
|
-
r'sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|'
|
92
|
-
r'vars|xrange|zip)\b', Name.Builtin),
|
93
|
-
(r'(?<!\.)(self|None|Ellipsis|NotImplemented|False|True'
|
94
|
-
r')\b', Name.Builtin.Pseudo),
|
95
|
-
(r'(?<!\.)(ArithmeticError|AssertionError|AttributeError|'
|
96
|
-
r'BaseException|DeprecationWarning|EOFError|EnvironmentError|'
|
97
|
-
r'Exception|FloatingPointError|FutureWarning|GeneratorExit|IOError|'
|
98
|
-
r'ImportError|ImportWarning|IndentationError|IndexError|KeyError|'
|
99
|
-
r'KeyboardInterrupt|LookupError|MemoryError|NameError|'
|
100
|
-
r'NotImplemented|NotImplementedError|OSError|OverflowError|'
|
101
|
-
r'OverflowWarning|PendingDeprecationWarning|ReferenceError|'
|
102
|
-
r'RuntimeError|RuntimeWarning|StandardError|StopIteration|'
|
103
|
-
r'SyntaxError|SyntaxWarning|SystemError|SystemExit|TabError|'
|
104
|
-
r'TypeError|UnboundLocalError|UnicodeDecodeError|'
|
105
|
-
r'UnicodeEncodeError|UnicodeError|UnicodeTranslateError|'
|
106
|
-
r'UnicodeWarning|UserWarning|ValueError|VMSError|Warning|'
|
107
|
-
r'WindowsError|ZeroDivisionError)\b', Name.Exception),
|
108
|
-
],
|
109
|
-
'numbers': [
|
110
|
-
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float),
|
111
|
-
(r'\d+[eE][+-]?[0-9]+j?', Number.Float),
|
112
|
-
(r'0[0-7]+j?', Number.Oct),
|
113
|
-
(r'0[bB][01]+', Number.Bin),
|
114
|
-
(r'0[xX][a-fA-F0-9]+', Number.Hex),
|
115
|
-
(r'\d+L', Number.Integer.Long),
|
116
|
-
(r'\d+j?', Number.Integer)
|
117
|
-
],
|
118
|
-
'backtick': [
|
119
|
-
('`.*?`', String.Backtick),
|
120
|
-
],
|
121
|
-
'name': [
|
122
|
-
(r'@[\w.]+', Name.Decorator),
|
123
|
-
('[a-zA-Z_]\w*', Name),
|
124
|
-
],
|
125
|
-
'funcname': [
|
126
|
-
('[a-zA-Z_]\w*', Name.Function, '#pop')
|
127
|
-
],
|
128
|
-
'classname': [
|
129
|
-
('[a-zA-Z_]\w*', Name.Class, '#pop')
|
130
|
-
],
|
131
|
-
'import': [
|
132
|
-
(r'(?:[ \t]|\\\n)+', Text),
|
133
|
-
(r'as\b', Keyword.Namespace),
|
134
|
-
(r',', Operator),
|
135
|
-
(r'[a-zA-Z_][\w.]*', Name.Namespace),
|
136
|
-
default('#pop') # all else: go back
|
137
|
-
],
|
138
|
-
'fromimport': [
|
139
|
-
(r'(?:[ \t]|\\\n)+', Text),
|
140
|
-
(r'import\b', Keyword.Namespace, '#pop'),
|
141
|
-
# if None occurs here, it's "raise x from None", since None can
|
142
|
-
# never be a module name
|
143
|
-
(r'None\b', Name.Builtin.Pseudo, '#pop'),
|
144
|
-
# sadly, in "raise x from y" y will be highlighted as namespace too
|
145
|
-
(r'[a-zA-Z_.][\w.]*', Name.Namespace),
|
146
|
-
# anything else here also means "raise x from y" and is therefore
|
147
|
-
# not an error
|
148
|
-
default('#pop'),
|
149
|
-
],
|
150
|
-
'stringescape': [
|
151
|
-
(r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|'
|
152
|
-
r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
|
153
|
-
],
|
154
|
-
'strings': [
|
155
|
-
(r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
|
156
|
-
'[hlL]?[diouxXeEfFgGcrs%]', String.Interpol),
|
157
|
-
(r'[^\\\'"%\n]+', String),
|
158
|
-
# quotes, percents and backslashes must be parsed one at a time
|
159
|
-
(r'[\'"\\]', String),
|
160
|
-
# unhandled string formatting sign
|
161
|
-
(r'%', String)
|
162
|
-
# newlines are an error (use "nl" state)
|
163
|
-
],
|
164
|
-
'nl': [
|
165
|
-
(r'\n', String)
|
166
|
-
],
|
167
|
-
'dqs': [
|
168
|
-
(r'"', String, '#pop'),
|
169
|
-
(r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings
|
170
|
-
include('strings')
|
171
|
-
],
|
172
|
-
'sqs': [
|
173
|
-
(r"'", String, '#pop'),
|
174
|
-
(r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings
|
175
|
-
include('strings')
|
176
|
-
],
|
177
|
-
'tdqs': [
|
178
|
-
(r'"""', String, '#pop'),
|
179
|
-
include('strings'),
|
180
|
-
include('nl')
|
181
|
-
],
|
182
|
-
'tsqs': [
|
183
|
-
(r"'''", String, '#pop'),
|
184
|
-
include('strings'),
|
185
|
-
include('nl')
|
186
|
-
],
|
187
|
-
}
|
188
|
-
|
189
|
-
def analyse_text(text):
|
190
|
-
return shebang_matches(text, r'pythonw?(2(\.\d)?)?') or \
|
191
|
-
'import ' in text[:1000]
|
192
|
-
|
193
|
-
|
194
|
-
class Python3Lexer(RegexLexer):
|
195
|
-
"""
|
196
|
-
For `Python <http://www.python.org>`_ source code (version 3.0).
|
197
|
-
|
198
|
-
.. versionadded:: 0.10
|
199
|
-
"""
|
200
|
-
|
201
|
-
name = 'Python 3'
|
202
|
-
aliases = ['python3', 'py3']
|
203
|
-
filenames = [] # Nothing until Python 3 gets widespread
|
204
|
-
mimetypes = ['text/x-python3', 'application/x-python3']
|
205
|
-
|
206
|
-
flags = re.MULTILINE | re.UNICODE
|
207
|
-
|
208
|
-
uni_name = "[%s][%s]*" % (uni.xid_start, uni.xid_continue)
|
209
|
-
|
210
|
-
tokens = PythonLexer.tokens.copy()
|
211
|
-
tokens['keywords'] = [
|
212
|
-
(r'(assert|break|continue|del|elif|else|except|'
|
213
|
-
r'finally|for|global|if|lambda|pass|raise|nonlocal|'
|
214
|
-
r'return|try|while|yield(\s+from)?|as|with|True|False|None)\b',
|
215
|
-
Keyword),
|
216
|
-
]
|
217
|
-
tokens['builtins'] = [
|
218
|
-
(r'(?<!\.)(__import__|abs|all|any|bin|bool|bytearray|bytes|'
|
219
|
-
r'chr|classmethod|cmp|compile|complex|delattr|dict|dir|'
|
220
|
-
r'divmod|enumerate|eval|filter|float|format|frozenset|getattr|'
|
221
|
-
r'globals|hasattr|hash|hex|id|input|int|isinstance|issubclass|'
|
222
|
-
r'iter|len|list|locals|map|max|memoryview|min|next|object|oct|'
|
223
|
-
r'open|ord|pow|print|property|range|repr|reversed|round|'
|
224
|
-
r'set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|'
|
225
|
-
r'vars|zip)\b', Name.Builtin),
|
226
|
-
(r'(?<!\.)(self|Ellipsis|NotImplemented)\b', Name.Builtin.Pseudo),
|
227
|
-
(r'(?<!\.)(ArithmeticError|AssertionError|AttributeError|'
|
228
|
-
r'BaseException|BufferError|BytesWarning|DeprecationWarning|'
|
229
|
-
r'EOFError|EnvironmentError|Exception|FloatingPointError|'
|
230
|
-
r'FutureWarning|GeneratorExit|IOError|ImportError|'
|
231
|
-
r'ImportWarning|IndentationError|IndexError|KeyError|'
|
232
|
-
r'KeyboardInterrupt|LookupError|MemoryError|NameError|'
|
233
|
-
r'NotImplementedError|OSError|OverflowError|'
|
234
|
-
r'PendingDeprecationWarning|ReferenceError|'
|
235
|
-
r'RuntimeError|RuntimeWarning|StopIteration|'
|
236
|
-
r'SyntaxError|SyntaxWarning|SystemError|SystemExit|TabError|'
|
237
|
-
r'TypeError|UnboundLocalError|UnicodeDecodeError|'
|
238
|
-
r'UnicodeEncodeError|UnicodeError|UnicodeTranslateError|'
|
239
|
-
r'UnicodeWarning|UserWarning|ValueError|VMSError|Warning|'
|
240
|
-
r'WindowsError|ZeroDivisionError|'
|
241
|
-
# new builtin exceptions from PEP 3151
|
242
|
-
r'BlockingIOError|ChildProcessError|ConnectionError|'
|
243
|
-
r'BrokenPipeError|ConnectionAbortedError|ConnectionRefusedError|'
|
244
|
-
r'ConnectionResetError|FileExistsError|FileNotFoundError|'
|
245
|
-
r'InterruptedError|IsADirectoryError|NotADirectoryError|'
|
246
|
-
r'PermissionError|ProcessLookupError|TimeoutError)\b',
|
247
|
-
Name.Exception),
|
248
|
-
]
|
249
|
-
tokens['numbers'] = [
|
250
|
-
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
|
251
|
-
(r'0[oO][0-7]+', Number.Oct),
|
252
|
-
(r'0[bB][01]+', Number.Bin),
|
253
|
-
(r'0[xX][a-fA-F0-9]+', Number.Hex),
|
254
|
-
(r'\d+', Number.Integer)
|
255
|
-
]
|
256
|
-
tokens['backtick'] = []
|
257
|
-
tokens['name'] = [
|
258
|
-
(r'@\w+', Name.Decorator),
|
259
|
-
(uni_name, Name),
|
260
|
-
]
|
261
|
-
tokens['funcname'] = [
|
262
|
-
(uni_name, Name.Function, '#pop')
|
263
|
-
]
|
264
|
-
tokens['classname'] = [
|
265
|
-
(uni_name, Name.Class, '#pop')
|
266
|
-
]
|
267
|
-
tokens['import'] = [
|
268
|
-
(r'(\s+)(as)(\s+)', bygroups(Text, Keyword, Text)),
|
269
|
-
(r'\.', Name.Namespace),
|
270
|
-
(uni_name, Name.Namespace),
|
271
|
-
(r'(\s*)(,)(\s*)', bygroups(Text, Operator, Text)),
|
272
|
-
default('#pop') # all else: go back
|
273
|
-
]
|
274
|
-
tokens['fromimport'] = [
|
275
|
-
(r'(\s+)(import)\b', bygroups(Text, Keyword), '#pop'),
|
276
|
-
(r'\.', Name.Namespace),
|
277
|
-
(uni_name, Name.Namespace),
|
278
|
-
default('#pop'),
|
279
|
-
]
|
280
|
-
# don't highlight "%s" substitutions
|
281
|
-
tokens['strings'] = [
|
282
|
-
(r'[^\\\'"%\n]+', String),
|
283
|
-
# quotes, percents and backslashes must be parsed one at a time
|
284
|
-
(r'[\'"\\]', String),
|
285
|
-
# unhandled string formatting sign
|
286
|
-
(r'%', String)
|
287
|
-
# newlines are an error (use "nl" state)
|
288
|
-
]
|
289
|
-
|
290
|
-
def analyse_text(text):
|
291
|
-
return shebang_matches(text, r'pythonw?3(\.\d)?')
|
292
|
-
|
293
|
-
|
294
|
-
class PythonConsoleLexer(Lexer):
|
295
|
-
"""
|
296
|
-
For Python console output or doctests, such as:
|
297
|
-
|
298
|
-
.. sourcecode:: pycon
|
299
|
-
|
300
|
-
>>> a = 'foo'
|
301
|
-
>>> print a
|
302
|
-
foo
|
303
|
-
>>> 1 / 0
|
304
|
-
Traceback (most recent call last):
|
305
|
-
File "<stdin>", line 1, in <module>
|
306
|
-
ZeroDivisionError: integer division or modulo by zero
|
307
|
-
|
308
|
-
Additional options:
|
309
|
-
|
310
|
-
`python3`
|
311
|
-
Use Python 3 lexer for code. Default is ``False``.
|
312
|
-
|
313
|
-
.. versionadded:: 1.0
|
314
|
-
"""
|
315
|
-
name = 'Python console session'
|
316
|
-
aliases = ['pycon']
|
317
|
-
mimetypes = ['text/x-python-doctest']
|
318
|
-
|
319
|
-
def __init__(self, **options):
|
320
|
-
self.python3 = get_bool_opt(options, 'python3', False)
|
321
|
-
Lexer.__init__(self, **options)
|
322
|
-
|
323
|
-
def get_tokens_unprocessed(self, text):
|
324
|
-
if self.python3:
|
325
|
-
pylexer = Python3Lexer(**self.options)
|
326
|
-
tblexer = Python3TracebackLexer(**self.options)
|
327
|
-
else:
|
328
|
-
pylexer = PythonLexer(**self.options)
|
329
|
-
tblexer = PythonTracebackLexer(**self.options)
|
330
|
-
|
331
|
-
curcode = ''
|
332
|
-
insertions = []
|
333
|
-
curtb = ''
|
334
|
-
tbindex = 0
|
335
|
-
tb = 0
|
336
|
-
for match in line_re.finditer(text):
|
337
|
-
line = match.group()
|
338
|
-
if line.startswith(u'>>> ') or line.startswith(u'... '):
|
339
|
-
tb = 0
|
340
|
-
insertions.append((len(curcode),
|
341
|
-
[(0, Generic.Prompt, line[:4])]))
|
342
|
-
curcode += line[4:]
|
343
|
-
elif line.rstrip() == u'...' and not tb:
|
344
|
-
# only a new >>> prompt can end an exception block
|
345
|
-
# otherwise an ellipsis in place of the traceback frames
|
346
|
-
# will be mishandled
|
347
|
-
insertions.append((len(curcode),
|
348
|
-
[(0, Generic.Prompt, u'...')]))
|
349
|
-
curcode += line[3:]
|
350
|
-
else:
|
351
|
-
if curcode:
|
352
|
-
for item in do_insertions(insertions,
|
353
|
-
pylexer.get_tokens_unprocessed(curcode)):
|
354
|
-
yield item
|
355
|
-
curcode = ''
|
356
|
-
insertions = []
|
357
|
-
if (line.startswith(u'Traceback (most recent call last):') or
|
358
|
-
re.match(u' File "[^"]+", line \\d+\\n$', line)):
|
359
|
-
tb = 1
|
360
|
-
curtb = line
|
361
|
-
tbindex = match.start()
|
362
|
-
elif line == 'KeyboardInterrupt\n':
|
363
|
-
yield match.start(), Name.Class, line
|
364
|
-
elif tb:
|
365
|
-
curtb += line
|
366
|
-
if not (line.startswith(' ') or line.strip() == u'...'):
|
367
|
-
tb = 0
|
368
|
-
for i, t, v in tblexer.get_tokens_unprocessed(curtb):
|
369
|
-
yield tbindex+i, t, v
|
370
|
-
else:
|
371
|
-
yield match.start(), Generic.Output, line
|
372
|
-
if curcode:
|
373
|
-
for item in do_insertions(insertions,
|
374
|
-
pylexer.get_tokens_unprocessed(curcode)):
|
375
|
-
yield item
|
376
|
-
|
377
|
-
|
378
|
-
class PythonTracebackLexer(RegexLexer):
|
379
|
-
"""
|
380
|
-
For Python tracebacks.
|
381
|
-
|
382
|
-
.. versionadded:: 0.7
|
383
|
-
"""
|
384
|
-
|
385
|
-
name = 'Python Traceback'
|
386
|
-
aliases = ['pytb']
|
387
|
-
filenames = ['*.pytb']
|
388
|
-
mimetypes = ['text/x-python-traceback']
|
389
|
-
|
390
|
-
tokens = {
|
391
|
-
'root': [
|
392
|
-
(r'^Traceback \(most recent call last\):\n',
|
393
|
-
Generic.Traceback, 'intb'),
|
394
|
-
# SyntaxError starts with this.
|
395
|
-
(r'^(?= File "[^"]+", line \d+)', Generic.Traceback, 'intb'),
|
396
|
-
(r'^.*\n', Other),
|
397
|
-
],
|
398
|
-
'intb': [
|
399
|
-
(r'^( File )("[^"]+")(, line )(\d+)(, in )(.+)(\n)',
|
400
|
-
bygroups(Text, Name.Builtin, Text, Number, Text, Name, Text)),
|
401
|
-
(r'^( File )("[^"]+")(, line )(\d+)(\n)',
|
402
|
-
bygroups(Text, Name.Builtin, Text, Number, Text)),
|
403
|
-
(r'^( )(.+)(\n)',
|
404
|
-
bygroups(Text, using(PythonLexer), Text)),
|
405
|
-
(r'^([ \t]*)(\.\.\.)(\n)',
|
406
|
-
bygroups(Text, Comment, Text)), # for doctests...
|
407
|
-
(r'^([^:]+)(: )(.+)(\n)',
|
408
|
-
bygroups(Generic.Error, Text, Name, Text), '#pop'),
|
409
|
-
(r'^([a-zA-Z_]\w*)(:?\n)',
|
410
|
-
bygroups(Generic.Error, Text), '#pop')
|
411
|
-
],
|
412
|
-
}
|
413
|
-
|
414
|
-
|
415
|
-
class Python3TracebackLexer(RegexLexer):
|
416
|
-
"""
|
417
|
-
For Python 3.0 tracebacks, with support for chained exceptions.
|
418
|
-
|
419
|
-
.. versionadded:: 1.0
|
420
|
-
"""
|
421
|
-
|
422
|
-
name = 'Python 3.0 Traceback'
|
423
|
-
aliases = ['py3tb']
|
424
|
-
filenames = ['*.py3tb']
|
425
|
-
mimetypes = ['text/x-python3-traceback']
|
426
|
-
|
427
|
-
tokens = {
|
428
|
-
'root': [
|
429
|
-
(r'\n', Text),
|
430
|
-
(r'^Traceback \(most recent call last\):\n', Generic.Traceback, 'intb'),
|
431
|
-
(r'^During handling of the above exception, another '
|
432
|
-
r'exception occurred:\n\n', Generic.Traceback),
|
433
|
-
(r'^The above exception was the direct cause of the '
|
434
|
-
r'following exception:\n\n', Generic.Traceback),
|
435
|
-
(r'^(?= File "[^"]+", line \d+)', Generic.Traceback, 'intb'),
|
436
|
-
],
|
437
|
-
'intb': [
|
438
|
-
(r'^( File )("[^"]+")(, line )(\d+)(, in )(.+)(\n)',
|
439
|
-
bygroups(Text, Name.Builtin, Text, Number, Text, Name, Text)),
|
440
|
-
(r'^( File )("[^"]+")(, line )(\d+)(\n)',
|
441
|
-
bygroups(Text, Name.Builtin, Text, Number, Text)),
|
442
|
-
(r'^( )(.+)(\n)',
|
443
|
-
bygroups(Text, using(Python3Lexer), Text)),
|
444
|
-
(r'^([ \t]*)(\.\.\.)(\n)',
|
445
|
-
bygroups(Text, Comment, Text)), # for doctests...
|
446
|
-
(r'^([^:]+)(: )(.+)(\n)',
|
447
|
-
bygroups(Generic.Error, Text, Name, Text), '#pop'),
|
448
|
-
(r'^([a-zA-Z_]\w*)(:?\n)',
|
449
|
-
bygroups(Generic.Error, Text), '#pop')
|
450
|
-
],
|
451
|
-
}
|
452
|
-
|
453
|
-
|
454
|
-
class RubyLexer(ExtendedRegexLexer):
|
455
|
-
"""
|
456
|
-
For `Ruby <http://www.ruby-lang.org>`_ source code.
|
457
|
-
"""
|
458
|
-
|
459
|
-
name = 'Ruby'
|
460
|
-
aliases = ['rb', 'ruby', 'duby']
|
461
|
-
filenames = ['*.rb', '*.rbw', 'Rakefile', '*.rake', '*.gemspec',
|
462
|
-
'*.rbx', '*.duby']
|
463
|
-
mimetypes = ['text/x-ruby', 'application/x-ruby']
|
464
|
-
|
465
|
-
flags = re.DOTALL | re.MULTILINE
|
466
|
-
|
467
|
-
def heredoc_callback(self, match, ctx):
|
468
|
-
# okay, this is the hardest part of parsing Ruby...
|
469
|
-
# match: 1 = <<-?, 2 = quote? 3 = name 4 = quote? 5 = rest of line
|
470
|
-
|
471
|
-
start = match.start(1)
|
472
|
-
yield start, Operator, match.group(1) # <<-?
|
473
|
-
yield match.start(2), String.Heredoc, match.group(2) # quote ", ', `
|
474
|
-
yield match.start(3), Name.Constant, match.group(3) # heredoc name
|
475
|
-
yield match.start(4), String.Heredoc, match.group(4) # quote again
|
476
|
-
|
477
|
-
heredocstack = ctx.__dict__.setdefault('heredocstack', [])
|
478
|
-
outermost = not bool(heredocstack)
|
479
|
-
heredocstack.append((match.group(1) == '<<-', match.group(3)))
|
480
|
-
|
481
|
-
ctx.pos = match.start(5)
|
482
|
-
ctx.end = match.end(5)
|
483
|
-
# this may find other heredocs
|
484
|
-
for i, t, v in self.get_tokens_unprocessed(context=ctx):
|
485
|
-
yield i, t, v
|
486
|
-
ctx.pos = match.end()
|
487
|
-
|
488
|
-
if outermost:
|
489
|
-
# this is the outer heredoc again, now we can process them all
|
490
|
-
for tolerant, hdname in heredocstack:
|
491
|
-
lines = []
|
492
|
-
for match in line_re.finditer(ctx.text, ctx.pos):
|
493
|
-
if tolerant:
|
494
|
-
check = match.group().strip()
|
495
|
-
else:
|
496
|
-
check = match.group().rstrip()
|
497
|
-
if check == hdname:
|
498
|
-
for amatch in lines:
|
499
|
-
yield amatch.start(), String.Heredoc, amatch.group()
|
500
|
-
yield match.start(), Name.Constant, match.group()
|
501
|
-
ctx.pos = match.end()
|
502
|
-
break
|
503
|
-
else:
|
504
|
-
lines.append(match)
|
505
|
-
else:
|
506
|
-
# end of heredoc not found -- error!
|
507
|
-
for amatch in lines:
|
508
|
-
yield amatch.start(), Error, amatch.group()
|
509
|
-
ctx.end = len(ctx.text)
|
510
|
-
del heredocstack[:]
|
511
|
-
|
512
|
-
|
513
|
-
def gen_rubystrings_rules():
|
514
|
-
def intp_regex_callback(self, match, ctx):
|
515
|
-
yield match.start(1), String.Regex, match.group(1) # begin
|
516
|
-
nctx = LexerContext(match.group(3), 0, ['interpolated-regex'])
|
517
|
-
for i, t, v in self.get_tokens_unprocessed(context=nctx):
|
518
|
-
yield match.start(3)+i, t, v
|
519
|
-
yield match.start(4), String.Regex, match.group(4) # end[mixounse]*
|
520
|
-
ctx.pos = match.end()
|
521
|
-
|
522
|
-
def intp_string_callback(self, match, ctx):
|
523
|
-
yield match.start(1), String.Other, match.group(1)
|
524
|
-
nctx = LexerContext(match.group(3), 0, ['interpolated-string'])
|
525
|
-
for i, t, v in self.get_tokens_unprocessed(context=nctx):
|
526
|
-
yield match.start(3)+i, t, v
|
527
|
-
yield match.start(4), String.Other, match.group(4) # end
|
528
|
-
ctx.pos = match.end()
|
529
|
-
|
530
|
-
states = {}
|
531
|
-
states['strings'] = [
|
532
|
-
# easy ones
|
533
|
-
(r'\:@{0,2}([a-zA-Z_]\w*[\!\?]?|\*\*?|[-+]@?|'
|
534
|
-
r'[/%&|^`~]|\[\]=?|<<|>>|<=?>|>=?|===?)', String.Symbol),
|
535
|
-
(r":'(\\\\|\\'|[^'])*'", String.Symbol),
|
536
|
-
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
537
|
-
(r':"', String.Symbol, 'simple-sym'),
|
538
|
-
(r'([a-zA-Z_]\w*)(:)(?!:)',
|
539
|
-
bygroups(String.Symbol, Punctuation)), # Since Ruby 1.9
|
540
|
-
(r'"', String.Double, 'simple-string'),
|
541
|
-
(r'(?<!\.)`', String.Backtick, 'simple-backtick'),
|
542
|
-
]
|
543
|
-
|
544
|
-
# double-quoted string and symbol
|
545
|
-
for name, ttype, end in ('string', String.Double, '"'), \
|
546
|
-
('sym', String.Symbol, '"'), \
|
547
|
-
('backtick', String.Backtick, '`'):
|
548
|
-
states['simple-'+name] = [
|
549
|
-
include('string-intp-escaped'),
|
550
|
-
(r'[^\\%s#]+' % end, ttype),
|
551
|
-
(r'[\\#]', ttype),
|
552
|
-
(end, ttype, '#pop'),
|
553
|
-
]
|
554
|
-
|
555
|
-
# braced quoted strings
|
556
|
-
for lbrace, rbrace, name in ('\\{', '\\}', 'cb'), \
|
557
|
-
('\\[', '\\]', 'sb'), \
|
558
|
-
('\\(', '\\)', 'pa'), \
|
559
|
-
('<', '>', 'ab'):
|
560
|
-
states[name+'-intp-string'] = [
|
561
|
-
(r'\\[\\' + lbrace + rbrace + ']', String.Other),
|
562
|
-
(r'(?<!\\)' + lbrace, String.Other, '#push'),
|
563
|
-
(r'(?<!\\)' + rbrace, String.Other, '#pop'),
|
564
|
-
include('string-intp-escaped'),
|
565
|
-
(r'[\\#' + lbrace + rbrace + ']', String.Other),
|
566
|
-
(r'[^\\#' + lbrace + rbrace + ']+', String.Other),
|
567
|
-
]
|
568
|
-
states['strings'].append((r'%[QWx]?' + lbrace, String.Other,
|
569
|
-
name+'-intp-string'))
|
570
|
-
states[name+'-string'] = [
|
571
|
-
(r'\\[\\' + lbrace + rbrace + ']', String.Other),
|
572
|
-
(r'(?<!\\)' + lbrace, String.Other, '#push'),
|
573
|
-
(r'(?<!\\)' + rbrace, String.Other, '#pop'),
|
574
|
-
(r'[\\#' + lbrace + rbrace + ']', String.Other),
|
575
|
-
(r'[^\\#' + lbrace + rbrace + ']+', String.Other),
|
576
|
-
]
|
577
|
-
states['strings'].append((r'%[qsw]' + lbrace, String.Other,
|
578
|
-
name+'-string'))
|
579
|
-
states[name+'-regex'] = [
|
580
|
-
(r'\\[\\' + lbrace + rbrace + ']', String.Regex),
|
581
|
-
(r'(?<!\\)' + lbrace, String.Regex, '#push'),
|
582
|
-
(r'(?<!\\)' + rbrace + '[mixounse]*', String.Regex, '#pop'),
|
583
|
-
include('string-intp'),
|
584
|
-
(r'[\\#' + lbrace + rbrace + ']', String.Regex),
|
585
|
-
(r'[^\\#' + lbrace + rbrace + ']+', String.Regex),
|
586
|
-
]
|
587
|
-
states['strings'].append((r'%r' + lbrace, String.Regex,
|
588
|
-
name+'-regex'))
|
589
|
-
|
590
|
-
# these must come after %<brace>!
|
591
|
-
states['strings'] += [
|
592
|
-
# %r regex
|
593
|
-
(r'(%r([^a-zA-Z0-9]))((?:\\\2|(?!\2).)*)(\2[mixounse]*)',
|
594
|
-
intp_regex_callback),
|
595
|
-
# regular fancy strings with qsw
|
596
|
-
(r'%[qsw]([^a-zA-Z0-9])((?:\\\1|(?!\1).)*)\1', String.Other),
|
597
|
-
(r'(%[QWx]([^a-zA-Z0-9]))((?:\\\2|(?!\2).)*)(\2)',
|
598
|
-
intp_string_callback),
|
599
|
-
# special forms of fancy strings after operators or
|
600
|
-
# in method calls with braces
|
601
|
-
(r'(?<=[-+/*%=<>&!^|~,(])(\s*)(%([\t ])(?:(?:\\\3|(?!\3).)*)\3)',
|
602
|
-
bygroups(Text, String.Other, None)),
|
603
|
-
# and because of fixed width lookbehinds the whole thing a
|
604
|
-
# second time for line startings...
|
605
|
-
(r'^(\s*)(%([\t ])(?:(?:\\\3|(?!\3).)*)\3)',
|
606
|
-
bygroups(Text, String.Other, None)),
|
607
|
-
# all regular fancy strings without qsw
|
608
|
-
(r'(%([^a-zA-Z0-9\s]))((?:\\\2|(?!\2).)*)(\2)',
|
609
|
-
intp_string_callback),
|
610
|
-
]
|
611
|
-
|
612
|
-
return states
|
613
|
-
|
614
|
-
tokens = {
|
615
|
-
'root': [
|
616
|
-
(r'#.*?$', Comment.Single),
|
617
|
-
(r'=begin\s.*?\n=end.*?$', Comment.Multiline),
|
618
|
-
# keywords
|
619
|
-
(r'(BEGIN|END|alias|begin|break|case|defined\?|'
|
620
|
-
r'do|else|elsif|end|ensure|for|if|in|next|redo|'
|
621
|
-
r'rescue|raise|retry|return|super|then|undef|unless|until|when|'
|
622
|
-
r'while|yield)\b', Keyword),
|
623
|
-
# start of function, class and module names
|
624
|
-
(r'(module)(\s+)([a-zA-Z_]\w*'
|
625
|
-
r'(?:::[a-zA-Z_]\w*)*)',
|
626
|
-
bygroups(Keyword, Text, Name.Namespace)),
|
627
|
-
(r'(def)(\s+)', bygroups(Keyword, Text), 'funcname'),
|
628
|
-
(r'def(?=[*%&^`~+-/\[<>=])', Keyword, 'funcname'),
|
629
|
-
(r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
|
630
|
-
# special methods
|
631
|
-
(r'(initialize|new|loop|include|extend|raise|attr_reader|'
|
632
|
-
r'attr_writer|attr_accessor|attr|catch|throw|private|'
|
633
|
-
r'module_function|public|protected|true|false|nil)\b',
|
634
|
-
Keyword.Pseudo),
|
635
|
-
(r'(not|and|or)\b', Operator.Word),
|
636
|
-
(r'(autoload|block_given|const_defined|eql|equal|frozen|include|'
|
637
|
-
r'instance_of|is_a|iterator|kind_of|method_defined|nil|'
|
638
|
-
r'private_method_defined|protected_method_defined|'
|
639
|
-
r'public_method_defined|respond_to|tainted)\?', Name.Builtin),
|
640
|
-
(r'(chomp|chop|exit|gsub|sub)!', Name.Builtin),
|
641
|
-
(r'(?<!\.)(Array|Float|Integer|String|__id__|__send__|abort|'
|
642
|
-
r'ancestors|at_exit|autoload|binding|callcc|caller|'
|
643
|
-
r'catch|chomp|chop|class_eval|class_variables|'
|
644
|
-
r'clone|const_defined\?|const_get|const_missing|const_set|'
|
645
|
-
r'constants|display|dup|eval|exec|exit|extend|fail|fork|'
|
646
|
-
r'format|freeze|getc|gets|global_variables|gsub|'
|
647
|
-
r'hash|id|included_modules|inspect|instance_eval|'
|
648
|
-
r'instance_method|instance_methods|'
|
649
|
-
r'instance_variable_get|instance_variable_set|instance_variables|'
|
650
|
-
r'lambda|load|local_variables|loop|'
|
651
|
-
r'method|method_missing|methods|module_eval|name|'
|
652
|
-
r'object_id|open|p|print|printf|private_class_method|'
|
653
|
-
r'private_instance_methods|'
|
654
|
-
r'private_methods|proc|protected_instance_methods|'
|
655
|
-
r'protected_methods|public_class_method|'
|
656
|
-
r'public_instance_methods|public_methods|'
|
657
|
-
r'putc|puts|raise|rand|readline|readlines|require|'
|
658
|
-
r'scan|select|self|send|set_trace_func|singleton_methods|sleep|'
|
659
|
-
r'split|sprintf|srand|sub|syscall|system|taint|'
|
660
|
-
r'test|throw|to_a|to_s|trace_var|trap|untaint|untrace_var|'
|
661
|
-
r'warn)\b', Name.Builtin),
|
662
|
-
(r'__(FILE|LINE)__\b', Name.Builtin.Pseudo),
|
663
|
-
# normal heredocs
|
664
|
-
(r'(?<!\w)(<<-?)(["`\']?)([a-zA-Z_]\w*)(\2)(.*?\n)',
|
665
|
-
heredoc_callback),
|
666
|
-
# empty string heredocs
|
667
|
-
(r'(<<-?)("|\')()(\2)(.*?\n)', heredoc_callback),
|
668
|
-
(r'__END__', Comment.Preproc, 'end-part'),
|
669
|
-
# multiline regex (after keywords or assignments)
|
670
|
-
(r'(?:^|(?<=[=<>~!:])|'
|
671
|
-
r'(?<=(?:\s|;)when\s)|'
|
672
|
-
r'(?<=(?:\s|;)or\s)|'
|
673
|
-
r'(?<=(?:\s|;)and\s)|'
|
674
|
-
r'(?<=(?:\s|;|\.)index\s)|'
|
675
|
-
r'(?<=(?:\s|;|\.)scan\s)|'
|
676
|
-
r'(?<=(?:\s|;|\.)sub\s)|'
|
677
|
-
r'(?<=(?:\s|;|\.)sub!\s)|'
|
678
|
-
r'(?<=(?:\s|;|\.)gsub\s)|'
|
679
|
-
r'(?<=(?:\s|;|\.)gsub!\s)|'
|
680
|
-
r'(?<=(?:\s|;|\.)match\s)|'
|
681
|
-
r'(?<=(?:\s|;)if\s)|'
|
682
|
-
r'(?<=(?:\s|;)elsif\s)|'
|
683
|
-
r'(?<=^when\s)|'
|
684
|
-
r'(?<=^index\s)|'
|
685
|
-
r'(?<=^scan\s)|'
|
686
|
-
r'(?<=^sub\s)|'
|
687
|
-
r'(?<=^gsub\s)|'
|
688
|
-
r'(?<=^sub!\s)|'
|
689
|
-
r'(?<=^gsub!\s)|'
|
690
|
-
r'(?<=^match\s)|'
|
691
|
-
r'(?<=^if\s)|'
|
692
|
-
r'(?<=^elsif\s)'
|
693
|
-
r')(\s*)(/)', bygroups(Text, String.Regex), 'multiline-regex'),
|
694
|
-
# multiline regex (in method calls or subscripts)
|
695
|
-
(r'(?<=\(|,|\[)/', String.Regex, 'multiline-regex'),
|
696
|
-
# multiline regex (this time the funny no whitespace rule)
|
697
|
-
(r'(\s+)(/)(?![\s=])', bygroups(Text, String.Regex),
|
698
|
-
'multiline-regex'),
|
699
|
-
# lex numbers and ignore following regular expressions which
|
700
|
-
# are division operators in fact (grrrr. i hate that. any
|
701
|
-
# better ideas?)
|
702
|
-
# since pygments 0.7 we also eat a "?" operator after numbers
|
703
|
-
# so that the char operator does not work. Chars are not allowed
|
704
|
-
# there so that you can use the ternary operator.
|
705
|
-
# stupid example:
|
706
|
-
# x>=0?n[x]:""
|
707
|
-
(r'(0_?[0-7]+(?:_[0-7]+)*)(\s*)([/?])?',
|
708
|
-
bygroups(Number.Oct, Text, Operator)),
|
709
|
-
(r'(0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*)(\s*)([/?])?',
|
710
|
-
bygroups(Number.Hex, Text, Operator)),
|
711
|
-
(r'(0b[01]+(?:_[01]+)*)(\s*)([/?])?',
|
712
|
-
bygroups(Number.Bin, Text, Operator)),
|
713
|
-
(r'([\d]+(?:_\d+)*)(\s*)([/?])?',
|
714
|
-
bygroups(Number.Integer, Text, Operator)),
|
715
|
-
# Names
|
716
|
-
(r'@@[a-zA-Z_]\w*', Name.Variable.Class),
|
717
|
-
(r'@[a-zA-Z_]\w*', Name.Variable.Instance),
|
718
|
-
(r'\$\w+', Name.Variable.Global),
|
719
|
-
(r'\$[!@&`\'+~=/\\,;.<>_*$?:"]', Name.Variable.Global),
|
720
|
-
(r'\$-[0adFiIlpvw]', Name.Variable.Global),
|
721
|
-
(r'::', Operator),
|
722
|
-
include('strings'),
|
723
|
-
# chars
|
724
|
-
(r'\?(\\[MC]-)*' # modifiers
|
725
|
-
r'(\\([\\abefnrstv#"\']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})|\S)'
|
726
|
-
r'(?!\w)',
|
727
|
-
String.Char),
|
728
|
-
(r'[A-Z]\w+', Name.Constant),
|
729
|
-
# this is needed because ruby attributes can look
|
730
|
-
# like keywords (class) or like this: ` ?!?
|
731
|
-
(r'(\.|::)([a-zA-Z_]\w*[\!\?]?|[*%&^`~+-/\[<>=])',
|
732
|
-
bygroups(Operator, Name)),
|
733
|
-
(r'[a-zA-Z_]\w*[\!\?]?', Name),
|
734
|
-
(r'(\[|\]|\*\*|<<?|>>?|>=|<=|<=>|=~|={3}|'
|
735
|
-
r'!~|&&?|\|\||\.{1,3})', Operator),
|
736
|
-
(r'[-+/*%=<>&!^|~]=?', Operator),
|
737
|
-
(r'[(){};,/?:\\]', Punctuation),
|
738
|
-
(r'\s+', Text)
|
739
|
-
],
|
740
|
-
'funcname': [
|
741
|
-
(r'\(', Punctuation, 'defexpr'),
|
742
|
-
(r'(?:([a-zA-Z_]\w*)(\.))?'
|
743
|
-
r'([a-zA-Z_]\w*[\!\?]?|\*\*?|[-+]@?|'
|
744
|
-
r'[/%&|^`~]|\[\]=?|<<|>>|<=?>|>=?|===?)',
|
745
|
-
bygroups(Name.Class, Operator, Name.Function), '#pop'),
|
746
|
-
default('#pop')
|
747
|
-
],
|
748
|
-
'classname': [
|
749
|
-
(r'\(', Punctuation, 'defexpr'),
|
750
|
-
(r'<<', Operator, '#pop'),
|
751
|
-
(r'[A-Z_]\w*', Name.Class, '#pop'),
|
752
|
-
default('#pop')
|
753
|
-
],
|
754
|
-
'defexpr': [
|
755
|
-
(r'(\))(\.|::)?', bygroups(Punctuation, Operator), '#pop'),
|
756
|
-
(r'\(', Operator, '#push'),
|
757
|
-
include('root')
|
758
|
-
],
|
759
|
-
'in-intp': [
|
760
|
-
('}', String.Interpol, '#pop'),
|
761
|
-
include('root'),
|
762
|
-
],
|
763
|
-
'string-intp': [
|
764
|
-
(r'#{', String.Interpol, 'in-intp'),
|
765
|
-
(r'#@@?[a-zA-Z_]\w*', String.Interpol),
|
766
|
-
(r'#\$[a-zA-Z_]\w*', String.Interpol)
|
767
|
-
],
|
768
|
-
'string-intp-escaped': [
|
769
|
-
include('string-intp'),
|
770
|
-
(r'\\([\\abefnrstv#"\']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})',
|
771
|
-
String.Escape)
|
772
|
-
],
|
773
|
-
'interpolated-regex': [
|
774
|
-
include('string-intp'),
|
775
|
-
(r'[\\#]', String.Regex),
|
776
|
-
(r'[^\\#]+', String.Regex),
|
777
|
-
],
|
778
|
-
'interpolated-string': [
|
779
|
-
include('string-intp'),
|
780
|
-
(r'[\\#]', String.Other),
|
781
|
-
(r'[^\\#]+', String.Other),
|
782
|
-
],
|
783
|
-
'multiline-regex': [
|
784
|
-
include('string-intp'),
|
785
|
-
(r'\\\\', String.Regex),
|
786
|
-
(r'\\/', String.Regex),
|
787
|
-
(r'[\\#]', String.Regex),
|
788
|
-
(r'[^\\/#]+', String.Regex),
|
789
|
-
(r'/[mixounse]*', String.Regex, '#pop'),
|
790
|
-
],
|
791
|
-
'end-part': [
|
792
|
-
(r'.+', Comment.Preproc, '#pop')
|
793
|
-
]
|
794
|
-
}
|
795
|
-
tokens.update(gen_rubystrings_rules())
|
796
|
-
|
797
|
-
def analyse_text(text):
|
798
|
-
return shebang_matches(text, r'ruby(1\.\d)?')
|
799
|
-
|
800
|
-
|
801
|
-
class RubyConsoleLexer(Lexer):
|
802
|
-
"""
|
803
|
-
For Ruby interactive console (**irb**) output like:
|
804
|
-
|
805
|
-
.. sourcecode:: rbcon
|
806
|
-
|
807
|
-
irb(main):001:0> a = 1
|
808
|
-
=> 1
|
809
|
-
irb(main):002:0> puts a
|
810
|
-
1
|
811
|
-
=> nil
|
812
|
-
"""
|
813
|
-
name = 'Ruby irb session'
|
814
|
-
aliases = ['rbcon', 'irb']
|
815
|
-
mimetypes = ['text/x-ruby-shellsession']
|
816
|
-
|
817
|
-
_prompt_re = re.compile('irb\([a-zA-Z_]\w*\):\d{3}:\d+[>*"\'] '
|
818
|
-
'|>> |\?> ')
|
819
|
-
|
820
|
-
def get_tokens_unprocessed(self, text):
|
821
|
-
rblexer = RubyLexer(**self.options)
|
822
|
-
|
823
|
-
curcode = ''
|
824
|
-
insertions = []
|
825
|
-
for match in line_re.finditer(text):
|
826
|
-
line = match.group()
|
827
|
-
m = self._prompt_re.match(line)
|
828
|
-
if m is not None:
|
829
|
-
end = m.end()
|
830
|
-
insertions.append((len(curcode),
|
831
|
-
[(0, Generic.Prompt, line[:end])]))
|
832
|
-
curcode += line[end:]
|
833
|
-
else:
|
834
|
-
if curcode:
|
835
|
-
for item in do_insertions(insertions,
|
836
|
-
rblexer.get_tokens_unprocessed(curcode)):
|
837
|
-
yield item
|
838
|
-
curcode = ''
|
839
|
-
insertions = []
|
840
|
-
yield match.start(), Generic.Output, line
|
841
|
-
if curcode:
|
842
|
-
for item in do_insertions(insertions,
|
843
|
-
rblexer.get_tokens_unprocessed(curcode)):
|
844
|
-
yield item
|
845
|
-
|
846
|
-
|
847
|
-
class PerlLexer(RegexLexer):
|
848
|
-
"""
|
849
|
-
For `Perl <http://www.perl.org>`_ source code.
|
850
|
-
"""
|
851
|
-
|
852
|
-
name = 'Perl'
|
853
|
-
aliases = ['perl', 'pl']
|
854
|
-
filenames = ['*.pl', '*.pm', '*.t']
|
855
|
-
mimetypes = ['text/x-perl', 'application/x-perl']
|
856
|
-
|
857
|
-
flags = re.DOTALL | re.MULTILINE
|
858
|
-
# TODO: give this to a perl guy who knows how to parse perl...
|
859
|
-
tokens = {
|
860
|
-
'balanced-regex': [
|
861
|
-
(r'/(\\\\|\\[^\\]|[^\\/])*/[egimosx]*', String.Regex, '#pop'),
|
862
|
-
(r'!(\\\\|\\[^\\]|[^\\!])*![egimosx]*', String.Regex, '#pop'),
|
863
|
-
(r'\\(\\\\|[^\\])*\\[egimosx]*', String.Regex, '#pop'),
|
864
|
-
(r'{(\\\\|\\[^\\]|[^\\}])*}[egimosx]*', String.Regex, '#pop'),
|
865
|
-
(r'<(\\\\|\\[^\\]|[^\\>])*>[egimosx]*', String.Regex, '#pop'),
|
866
|
-
(r'\[(\\\\|\\[^\\]|[^\\\]])*\][egimosx]*', String.Regex, '#pop'),
|
867
|
-
(r'\((\\\\|\\[^\\]|[^\\\)])*\)[egimosx]*', String.Regex, '#pop'),
|
868
|
-
(r'@(\\\\|\\[^\\]|[^\\\@])*@[egimosx]*', String.Regex, '#pop'),
|
869
|
-
(r'%(\\\\|\\[^\\]|[^\\\%])*%[egimosx]*', String.Regex, '#pop'),
|
870
|
-
(r'\$(\\\\|\\[^\\]|[^\\\$])*\$[egimosx]*', String.Regex, '#pop'),
|
871
|
-
],
|
872
|
-
'root': [
|
873
|
-
(r'\#.*?$', Comment.Single),
|
874
|
-
(r'^=[a-zA-Z0-9]+\s+.*?\n=cut', Comment.Multiline),
|
875
|
-
(r'(case|continue|do|else|elsif|for|foreach|if|last|my|'
|
876
|
-
r'next|our|redo|reset|then|unless|until|while|use|'
|
877
|
-
r'print|new|BEGIN|CHECK|INIT|END|return)\b', Keyword),
|
878
|
-
(r'(format)(\s+)(\w+)(\s*)(=)(\s*\n)',
|
879
|
-
bygroups(Keyword, Text, Name, Text, Punctuation, Text), 'format'),
|
880
|
-
(r'(eq|lt|gt|le|ge|ne|not|and|or|cmp)\b', Operator.Word),
|
881
|
-
# common delimiters
|
882
|
-
(r's/(\\\\|\\[^\\]|[^\\/])*/(\\\\|\\[^\\]|[^\\/])*/[egimosx]*',
|
883
|
-
String.Regex),
|
884
|
-
(r's!(\\\\|\\!|[^!])*!(\\\\|\\!|[^!])*![egimosx]*', String.Regex),
|
885
|
-
(r's\\(\\\\|[^\\])*\\(\\\\|[^\\])*\\[egimosx]*', String.Regex),
|
886
|
-
(r's@(\\\\|\\[^\\]|[^\\@])*@(\\\\|\\[^\\]|[^\\@])*@[egimosx]*',
|
887
|
-
String.Regex),
|
888
|
-
(r's%(\\\\|\\[^\\]|[^\\%])*%(\\\\|\\[^\\]|[^\\%])*%[egimosx]*',
|
889
|
-
String.Regex),
|
890
|
-
# balanced delimiters
|
891
|
-
(r's{(\\\\|\\[^\\]|[^\\}])*}\s*', String.Regex, 'balanced-regex'),
|
892
|
-
(r's<(\\\\|\\[^\\]|[^\\>])*>\s*', String.Regex, 'balanced-regex'),
|
893
|
-
(r's\[(\\\\|\\[^\\]|[^\\\]])*\]\s*', String.Regex,
|
894
|
-
'balanced-regex'),
|
895
|
-
(r's\((\\\\|\\[^\\]|[^\\\)])*\)\s*', String.Regex,
|
896
|
-
'balanced-regex'),
|
897
|
-
|
898
|
-
(r'm?/(\\\\|\\[^\\]|[^\\/\n])*/[gcimosx]*', String.Regex),
|
899
|
-
(r'm(?=[/!\\{<\[\(@%\$])', String.Regex, 'balanced-regex'),
|
900
|
-
(r'((?<==~)|(?<=\())\s*/(\\\\|\\[^\\]|[^\\/])*/[gcimosx]*',
|
901
|
-
String.Regex),
|
902
|
-
(r'\s+', Text),
|
903
|
-
(r'(abs|accept|alarm|atan2|bind|binmode|bless|caller|chdir|'
|
904
|
-
r'chmod|chomp|chop|chown|chr|chroot|close|closedir|connect|'
|
905
|
-
r'continue|cos|crypt|dbmclose|dbmopen|defined|delete|die|'
|
906
|
-
r'dump|each|endgrent|endhostent|endnetent|endprotoent|'
|
907
|
-
r'endpwent|endservent|eof|eval|exec|exists|exit|exp|fcntl|'
|
908
|
-
r'fileno|flock|fork|format|formline|getc|getgrent|getgrgid|'
|
909
|
-
r'getgrnam|gethostbyaddr|gethostbyname|gethostent|getlogin|'
|
910
|
-
r'getnetbyaddr|getnetbyname|getnetent|getpeername|getpgrp|'
|
911
|
-
r'getppid|getpriority|getprotobyname|getprotobynumber|'
|
912
|
-
r'getprotoent|getpwent|getpwnam|getpwuid|getservbyname|'
|
913
|
-
r'getservbyport|getservent|getsockname|getsockopt|glob|gmtime|'
|
914
|
-
r'goto|grep|hex|import|index|int|ioctl|join|keys|kill|last|'
|
915
|
-
r'lc|lcfirst|length|link|listen|local|localtime|log|lstat|'
|
916
|
-
r'map|mkdir|msgctl|msgget|msgrcv|msgsnd|my|next|no|oct|open|'
|
917
|
-
r'opendir|ord|our|pack|package|pipe|pop|pos|printf|'
|
918
|
-
r'prototype|push|quotemeta|rand|read|readdir|'
|
919
|
-
r'readline|readlink|readpipe|recv|redo|ref|rename|require|'
|
920
|
-
r'reverse|rewinddir|rindex|rmdir|scalar|seek|seekdir|'
|
921
|
-
r'select|semctl|semget|semop|send|setgrent|sethostent|setnetent|'
|
922
|
-
r'setpgrp|setpriority|setprotoent|setpwent|setservent|'
|
923
|
-
r'setsockopt|shift|shmctl|shmget|shmread|shmwrite|shutdown|'
|
924
|
-
r'sin|sleep|socket|socketpair|sort|splice|split|sprintf|sqrt|'
|
925
|
-
r'srand|stat|study|substr|symlink|syscall|sysopen|sysread|'
|
926
|
-
r'sysseek|system|syswrite|tell|telldir|tie|tied|time|times|tr|'
|
927
|
-
r'truncate|uc|ucfirst|umask|undef|unlink|unpack|unshift|untie|'
|
928
|
-
r'utime|values|vec|wait|waitpid|wantarray|warn|write'
|
929
|
-
r')\b', Name.Builtin),
|
930
|
-
(r'((__(DATA|DIE|WARN)__)|(STD(IN|OUT|ERR)))\b', Name.Builtin.Pseudo),
|
931
|
-
(r'<<([\'"]?)([a-zA-Z_]\w*)\1;?\n.*?\n\2\n', String),
|
932
|
-
(r'__END__', Comment.Preproc, 'end-part'),
|
933
|
-
(r'\$\^[ADEFHILMOPSTWX]', Name.Variable.Global),
|
934
|
-
(r"\$[\\\"\[\]'&`+*.,;=%~?@$!<>(^|/-](?!\w)", Name.Variable.Global),
|
935
|
-
(r'[$@%#]+', Name.Variable, 'varname'),
|
936
|
-
(r'0_?[0-7]+(_[0-7]+)*', Number.Oct),
|
937
|
-
(r'0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*', Number.Hex),
|
938
|
-
(r'0b[01]+(_[01]+)*', Number.Bin),
|
939
|
-
(r'(?i)(\d*(_\d*)*\.\d+(_\d*)*|\d+(_\d*)*\.\d+(_\d*)*)(e[+-]?\d+)?',
|
940
|
-
Number.Float),
|
941
|
-
(r'(?i)\d+(_\d*)*e[+-]?\d+(_\d*)*', Number.Float),
|
942
|
-
(r'\d+(_\d+)*', Number.Integer),
|
943
|
-
(r"'(\\\\|\\[^\\]|[^'\\])*'", String),
|
944
|
-
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
945
|
-
(r'`(\\\\|\\[^\\]|[^`\\])*`', String.Backtick),
|
946
|
-
(r'<([^\s>]+)>', String.Regex),
|
947
|
-
(r'(q|qq|qw|qr|qx)\{', String.Other, 'cb-string'),
|
948
|
-
(r'(q|qq|qw|qr|qx)\(', String.Other, 'rb-string'),
|
949
|
-
(r'(q|qq|qw|qr|qx)\[', String.Other, 'sb-string'),
|
950
|
-
(r'(q|qq|qw|qr|qx)\<', String.Other, 'lt-string'),
|
951
|
-
(r'(q|qq|qw|qr|qx)([^a-zA-Z0-9])(.|\n)*?\2', String.Other),
|
952
|
-
(r'package\s+', Keyword, 'modulename'),
|
953
|
-
(r'sub\s+', Keyword, 'funcname'),
|
954
|
-
(r'(\[\]|\*\*|::|<<|>>|>=|<=>|<=|={3}|!=|=~|'
|
955
|
-
r'!~|&&?|\|\||\.{1,3})', Operator),
|
956
|
-
(r'[-+/*%=<>&^|!\\~]=?', Operator),
|
957
|
-
(r'[\(\)\[\]:;,<>/\?\{\}]', Punctuation), # yes, there's no shortage
|
958
|
-
# of punctuation in Perl!
|
959
|
-
(r'(?=\w)', Name, 'name'),
|
960
|
-
],
|
961
|
-
'format': [
|
962
|
-
(r'\.\n', String.Interpol, '#pop'),
|
963
|
-
(r'[^\n]*\n', String.Interpol),
|
964
|
-
],
|
965
|
-
'varname': [
|
966
|
-
(r'\s+', Text),
|
967
|
-
(r'\{', Punctuation, '#pop'), # hash syntax?
|
968
|
-
(r'\)|,', Punctuation, '#pop'), # argument specifier
|
969
|
-
(r'\w+::', Name.Namespace),
|
970
|
-
(r'[\w:]+', Name.Variable, '#pop'),
|
971
|
-
],
|
972
|
-
'name': [
|
973
|
-
(r'\w+::', Name.Namespace),
|
974
|
-
(r'[\w:]+', Name, '#pop'),
|
975
|
-
(r'[A-Z_]+(?=\W)', Name.Constant, '#pop'),
|
976
|
-
(r'(?=\W)', Text, '#pop'),
|
977
|
-
],
|
978
|
-
'modulename': [
|
979
|
-
(r'[a-zA-Z_]\w*', Name.Namespace, '#pop')
|
980
|
-
],
|
981
|
-
'funcname': [
|
982
|
-
(r'[a-zA-Z_]\w*[\!\?]?', Name.Function),
|
983
|
-
(r'\s+', Text),
|
984
|
-
# argument declaration
|
985
|
-
(r'(\([$@%]*\))(\s*)', bygroups(Punctuation, Text)),
|
986
|
-
(r'.*?{', Punctuation, '#pop'),
|
987
|
-
(r';', Punctuation, '#pop'),
|
988
|
-
],
|
989
|
-
'cb-string': [
|
990
|
-
(r'\\[\{\}\\]', String.Other),
|
991
|
-
(r'\\', String.Other),
|
992
|
-
(r'\{', String.Other, 'cb-string'),
|
993
|
-
(r'\}', String.Other, '#pop'),
|
994
|
-
(r'[^\{\}\\]+', String.Other)
|
995
|
-
],
|
996
|
-
'rb-string': [
|
997
|
-
(r'\\[\(\)\\]', String.Other),
|
998
|
-
(r'\\', String.Other),
|
999
|
-
(r'\(', String.Other, 'rb-string'),
|
1000
|
-
(r'\)', String.Other, '#pop'),
|
1001
|
-
(r'[^\(\)]+', String.Other)
|
1002
|
-
],
|
1003
|
-
'sb-string': [
|
1004
|
-
(r'\\[\[\]\\]', String.Other),
|
1005
|
-
(r'\\', String.Other),
|
1006
|
-
(r'\[', String.Other, 'sb-string'),
|
1007
|
-
(r'\]', String.Other, '#pop'),
|
1008
|
-
(r'[^\[\]]+', String.Other)
|
1009
|
-
],
|
1010
|
-
'lt-string': [
|
1011
|
-
(r'\\[\<\>\\]', String.Other),
|
1012
|
-
(r'\\', String.Other),
|
1013
|
-
(r'\<', String.Other, 'lt-string'),
|
1014
|
-
(r'\>', String.Other, '#pop'),
|
1015
|
-
(r'[^\<\>]+', String.Other)
|
1016
|
-
],
|
1017
|
-
'end-part': [
|
1018
|
-
(r'.+', Comment.Preproc, '#pop')
|
1019
|
-
]
|
1020
|
-
}
|
1021
|
-
|
1022
|
-
def analyse_text(text):
|
1023
|
-
if shebang_matches(text, r'perl'):
|
1024
|
-
return True
|
1025
|
-
if re.search('(?:my|our)\s+[$@%(]', text):
|
1026
|
-
return 0.9
|
1027
|
-
|
1028
|
-
|
1029
|
-
class LuaLexer(RegexLexer):
|
1030
|
-
"""
|
1031
|
-
For `Lua <http://www.lua.org>`_ source code.
|
1032
|
-
|
1033
|
-
Additional options accepted:
|
1034
|
-
|
1035
|
-
`func_name_highlighting`
|
1036
|
-
If given and ``True``, highlight builtin function names
|
1037
|
-
(default: ``True``).
|
1038
|
-
`disabled_modules`
|
1039
|
-
If given, must be a list of module names whose function names
|
1040
|
-
should not be highlighted. By default all modules are highlighted.
|
1041
|
-
|
1042
|
-
To get a list of allowed modules have a look into the
|
1043
|
-
`_luabuiltins` module:
|
1044
|
-
|
1045
|
-
.. sourcecode:: pycon
|
1046
|
-
|
1047
|
-
>>> from pygments.lexers._luabuiltins import MODULES
|
1048
|
-
>>> MODULES.keys()
|
1049
|
-
['string', 'coroutine', 'modules', 'io', 'basic', ...]
|
1050
|
-
"""
|
1051
|
-
|
1052
|
-
name = 'Lua'
|
1053
|
-
aliases = ['lua']
|
1054
|
-
filenames = ['*.lua', '*.wlua']
|
1055
|
-
mimetypes = ['text/x-lua', 'application/x-lua']
|
1056
|
-
|
1057
|
-
tokens = {
|
1058
|
-
'root': [
|
1059
|
-
# lua allows a file to start with a shebang
|
1060
|
-
(r'#!(.*?)$', Comment.Preproc),
|
1061
|
-
default('base'),
|
1062
|
-
],
|
1063
|
-
'base': [
|
1064
|
-
(r'(?s)--\[(=*)\[.*?\]\1\]', Comment.Multiline),
|
1065
|
-
('--.*$', Comment.Single),
|
1066
|
-
|
1067
|
-
(r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float),
|
1068
|
-
(r'(?i)\d+e[+-]?\d+', Number.Float),
|
1069
|
-
('(?i)0x[0-9a-f]*', Number.Hex),
|
1070
|
-
(r'\d+', Number.Integer),
|
1071
|
-
|
1072
|
-
(r'\n', Text),
|
1073
|
-
(r'[^\S\n]', Text),
|
1074
|
-
# multiline strings
|
1075
|
-
(r'(?s)\[(=*)\[.*?\]\1\]', String),
|
1076
|
-
|
1077
|
-
(r'(==|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#])', Operator),
|
1078
|
-
(r'[\[\]\{\}\(\)\.,:;]', Punctuation),
|
1079
|
-
(r'(and|or|not)\b', Operator.Word),
|
1080
|
-
|
1081
|
-
('(break|do|else|elseif|end|for|if|in|repeat|return|then|until|'
|
1082
|
-
r'while)\b', Keyword),
|
1083
|
-
(r'(local)\b', Keyword.Declaration),
|
1084
|
-
(r'(true|false|nil)\b', Keyword.Constant),
|
1085
|
-
|
1086
|
-
(r'(function)\b', Keyword, 'funcname'),
|
1087
|
-
|
1088
|
-
(r'[A-Za-z_]\w*(\.[A-Za-z_]\w*)?', Name),
|
1089
|
-
|
1090
|
-
("'", String.Single, combined('stringescape', 'sqs')),
|
1091
|
-
('"', String.Double, combined('stringescape', 'dqs'))
|
1092
|
-
],
|
1093
|
-
|
1094
|
-
'funcname': [
|
1095
|
-
(r'\s+', Text),
|
1096
|
-
('(?:([A-Za-z_]\w*)(\.))?([A-Za-z_]\w*)',
|
1097
|
-
bygroups(Name.Class, Punctuation, Name.Function), '#pop'),
|
1098
|
-
# inline function
|
1099
|
-
('\(', Punctuation, '#pop'),
|
1100
|
-
],
|
1101
|
-
|
1102
|
-
# if I understand correctly, every character is valid in a lua string,
|
1103
|
-
# so this state is only for later corrections
|
1104
|
-
'string': [
|
1105
|
-
('.', String)
|
1106
|
-
],
|
1107
|
-
|
1108
|
-
'stringescape': [
|
1109
|
-
(r'''\\([abfnrtv\\"']|\d{1,3})''', String.Escape)
|
1110
|
-
],
|
1111
|
-
|
1112
|
-
'sqs': [
|
1113
|
-
("'", String, '#pop'),
|
1114
|
-
include('string')
|
1115
|
-
],
|
1116
|
-
|
1117
|
-
'dqs': [
|
1118
|
-
('"', String, '#pop'),
|
1119
|
-
include('string')
|
1120
|
-
]
|
1121
|
-
}
|
1122
|
-
|
1123
|
-
def __init__(self, **options):
|
1124
|
-
self.func_name_highlighting = get_bool_opt(
|
1125
|
-
options, 'func_name_highlighting', True)
|
1126
|
-
self.disabled_modules = get_list_opt(options, 'disabled_modules', [])
|
1127
|
-
|
1128
|
-
self._functions = set()
|
1129
|
-
if self.func_name_highlighting:
|
1130
|
-
from pygments.lexers._luabuiltins import MODULES
|
1131
|
-
for mod, func in iteritems(MODULES):
|
1132
|
-
if mod not in self.disabled_modules:
|
1133
|
-
self._functions.update(func)
|
1134
|
-
RegexLexer.__init__(self, **options)
|
1135
|
-
|
1136
|
-
def get_tokens_unprocessed(self, text):
|
1137
|
-
for index, token, value in \
|
1138
|
-
RegexLexer.get_tokens_unprocessed(self, text):
|
1139
|
-
if token is Name:
|
1140
|
-
if value in self._functions:
|
1141
|
-
yield index, Name.Builtin, value
|
1142
|
-
continue
|
1143
|
-
elif '.' in value:
|
1144
|
-
a, b = value.split('.')
|
1145
|
-
yield index, Name, a
|
1146
|
-
yield index + len(a), Punctuation, u'.'
|
1147
|
-
yield index + len(a) + 1, Name, b
|
1148
|
-
continue
|
1149
|
-
yield index, token, value
|
1150
|
-
|
1151
|
-
|
1152
|
-
class MoonScriptLexer(LuaLexer):
|
1153
|
-
"""
|
1154
|
-
For `MoonScript <http://moonscript.org.org>`_ source code.
|
1155
|
-
|
1156
|
-
.. versionadded:: 1.5
|
1157
|
-
"""
|
1158
|
-
|
1159
|
-
name = "MoonScript"
|
1160
|
-
aliases = ["moon", "moonscript"]
|
1161
|
-
filenames = ["*.moon"]
|
1162
|
-
mimetypes = ['text/x-moonscript', 'application/x-moonscript']
|
1163
|
-
|
1164
|
-
tokens = {
|
1165
|
-
'root': [
|
1166
|
-
(r'#!(.*?)$', Comment.Preproc),
|
1167
|
-
default('base'),
|
1168
|
-
],
|
1169
|
-
'base': [
|
1170
|
-
('--.*$', Comment.Single),
|
1171
|
-
(r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float),
|
1172
|
-
(r'(?i)\d+e[+-]?\d+', Number.Float),
|
1173
|
-
(r'(?i)0x[0-9a-f]*', Number.Hex),
|
1174
|
-
(r'\d+', Number.Integer),
|
1175
|
-
(r'\n', Text),
|
1176
|
-
(r'[^\S\n]+', Text),
|
1177
|
-
(r'(?s)\[(=*)\[.*?\]\1\]', String),
|
1178
|
-
(r'(->|=>)', Name.Function),
|
1179
|
-
(r':[a-zA-Z_]\w*', Name.Variable),
|
1180
|
-
(r'(==|!=|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#!.\\:])', Operator),
|
1181
|
-
(r'[;,]', Punctuation),
|
1182
|
-
(r'[\[\]\{\}\(\)]', Keyword.Type),
|
1183
|
-
(r'[a-zA-Z_]\w*:', Name.Variable),
|
1184
|
-
(r"(class|extends|if|then|super|do|with|import|export|"
|
1185
|
-
r"while|elseif|return|for|in|from|when|using|else|"
|
1186
|
-
r"and|or|not|switch|break)\b", Keyword),
|
1187
|
-
(r'(true|false|nil)\b', Keyword.Constant),
|
1188
|
-
(r'(and|or|not)\b', Operator.Word),
|
1189
|
-
(r'(self)\b', Name.Builtin.Pseudo),
|
1190
|
-
(r'@@?([a-zA-Z_]\w*)?', Name.Variable.Class),
|
1191
|
-
(r'[A-Z]\w*', Name.Class), # proper name
|
1192
|
-
(r'[A-Za-z_]\w*(\.[A-Za-z_]\w*)?', Name),
|
1193
|
-
("'", String.Single, combined('stringescape', 'sqs')),
|
1194
|
-
('"', String.Double, combined('stringescape', 'dqs'))
|
1195
|
-
],
|
1196
|
-
'stringescape': [
|
1197
|
-
(r'''\\([abfnrtv\\"']|\d{1,3})''', String.Escape)
|
1198
|
-
],
|
1199
|
-
'sqs': [
|
1200
|
-
("'", String.Single, '#pop'),
|
1201
|
-
(".", String)
|
1202
|
-
],
|
1203
|
-
'dqs': [
|
1204
|
-
('"', String.Double, '#pop'),
|
1205
|
-
(".", String)
|
1206
|
-
]
|
1207
|
-
}
|
1208
|
-
|
1209
|
-
def get_tokens_unprocessed(self, text):
|
1210
|
-
# set . as Operator instead of Punctuation
|
1211
|
-
for index, token, value in \
|
1212
|
-
LuaLexer.get_tokens_unprocessed(self, text):
|
1213
|
-
if token == Punctuation and value == ".":
|
1214
|
-
token = Operator
|
1215
|
-
yield index, token, value
|
1216
|
-
|
1217
|
-
|
1218
|
-
class CrocLexer(RegexLexer):
|
1219
|
-
"""
|
1220
|
-
For `Croc <http://jfbillingsley.com/croc>`_ source.
|
1221
|
-
"""
|
1222
|
-
name = 'Croc'
|
1223
|
-
filenames = ['*.croc']
|
1224
|
-
aliases = ['croc']
|
1225
|
-
mimetypes = ['text/x-crocsrc']
|
1226
|
-
|
1227
|
-
tokens = {
|
1228
|
-
'root': [
|
1229
|
-
(r'\n', Text),
|
1230
|
-
(r'\s+', Text),
|
1231
|
-
# Comments
|
1232
|
-
(r'//(.*?)\n', Comment.Single),
|
1233
|
-
(r'/\*', Comment.Multiline, 'nestedcomment'),
|
1234
|
-
# Keywords
|
1235
|
-
(r'(as|assert|break|case|catch|class|continue|default'
|
1236
|
-
r'|do|else|finally|for|foreach|function|global|namespace'
|
1237
|
-
r'|if|import|in|is|local|module|return|scope|super|switch'
|
1238
|
-
r'|this|throw|try|vararg|while|with|yield)\b', Keyword),
|
1239
|
-
(r'(false|true|null)\b', Keyword.Constant),
|
1240
|
-
# FloatLiteral
|
1241
|
-
(r'([0-9][0-9_]*)(?=[.eE])(\.[0-9][0-9_]*)?([eE][+\-]?[0-9_]+)?',
|
1242
|
-
Number.Float),
|
1243
|
-
# IntegerLiteral
|
1244
|
-
# -- Binary
|
1245
|
-
(r'0[bB][01][01_]*', Number.Bin),
|
1246
|
-
# -- Hexadecimal
|
1247
|
-
(r'0[xX][0-9a-fA-F][0-9a-fA-F_]*', Number.Hex),
|
1248
|
-
# -- Decimal
|
1249
|
-
(r'([0-9][0-9_]*)(?![.eE])', Number.Integer),
|
1250
|
-
# CharacterLiteral
|
1251
|
-
(r"""'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-9]{1,3}"""
|
1252
|
-
r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|.)'""",
|
1253
|
-
String.Char
|
1254
|
-
),
|
1255
|
-
# StringLiteral
|
1256
|
-
# -- WysiwygString
|
1257
|
-
(r'@"(""|[^"])*"', String),
|
1258
|
-
(r'@`(``|[^`])*`', String),
|
1259
|
-
(r"@'(''|[^'])*'", String),
|
1260
|
-
# -- DoubleQuotedString
|
1261
|
-
(r'"(\\\\|\\"|[^"])*"', String),
|
1262
|
-
# Tokens
|
1263
|
-
(
|
1264
|
-
r'(~=|\^=|%=|\*=|==|!=|>>>=|>>>|>>=|>>|>=|<=>|\?=|-\>'
|
1265
|
-
r'|<<=|<<|<=|\+\+|\+=|--|-=|\|\||\|=|&&|&=|\.\.|/=)'
|
1266
|
-
r'|[-/.&$@|\+<>!()\[\]{}?,;:=*%^~#\\]', Punctuation
|
1267
|
-
),
|
1268
|
-
# Identifier
|
1269
|
-
(r'[a-zA-Z_]\w*', Name),
|
1270
|
-
],
|
1271
|
-
'nestedcomment': [
|
1272
|
-
(r'[^*/]+', Comment.Multiline),
|
1273
|
-
(r'/\*', Comment.Multiline, '#push'),
|
1274
|
-
(r'\*/', Comment.Multiline, '#pop'),
|
1275
|
-
(r'[*/]', Comment.Multiline),
|
1276
|
-
],
|
1277
|
-
}
|
1278
|
-
|
1279
|
-
|
1280
|
-
class MiniDLexer(CrocLexer):
|
1281
|
-
"""
|
1282
|
-
For MiniD source. MiniD is now known as Croc.
|
1283
|
-
"""
|
1284
|
-
name = 'MiniD'
|
1285
|
-
filenames = ['*.md']
|
1286
|
-
aliases = ['minid']
|
1287
|
-
mimetypes = ['text/x-minidsrc']
|
1288
|
-
|
1289
|
-
|
1290
|
-
class IoLexer(RegexLexer):
|
1291
|
-
"""
|
1292
|
-
For `Io <http://iolanguage.com/>`_ (a small, prototype-based
|
1293
|
-
programming language) source.
|
1294
|
-
|
1295
|
-
.. versionadded:: 0.10
|
1296
|
-
"""
|
1297
|
-
name = 'Io'
|
1298
|
-
filenames = ['*.io']
|
1299
|
-
aliases = ['io']
|
1300
|
-
mimetypes = ['text/x-iosrc']
|
1301
|
-
tokens = {
|
1302
|
-
'root': [
|
1303
|
-
(r'\n', Text),
|
1304
|
-
(r'\s+', Text),
|
1305
|
-
# Comments
|
1306
|
-
(r'//(.*?)\n', Comment.Single),
|
1307
|
-
(r'#(.*?)\n', Comment.Single),
|
1308
|
-
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
1309
|
-
(r'/\+', Comment.Multiline, 'nestedcomment'),
|
1310
|
-
# DoubleQuotedString
|
1311
|
-
(r'"(\\\\|\\"|[^"])*"', String),
|
1312
|
-
# Operators
|
1313
|
-
(r'::=|:=|=|\(|\)|;|,|\*|-|\+|>|<|@|!|/|\||\^|\.|%|&|\[|\]|\{|\}',
|
1314
|
-
Operator),
|
1315
|
-
# keywords
|
1316
|
-
(r'(clone|do|doFile|doString|method|for|if|else|elseif|then)\b',
|
1317
|
-
Keyword),
|
1318
|
-
# constants
|
1319
|
-
(r'(nil|false|true)\b', Name.Constant),
|
1320
|
-
# names
|
1321
|
-
(r'(Object|list|List|Map|args|Sequence|Coroutine|File)\b',
|
1322
|
-
Name.Builtin),
|
1323
|
-
('[a-zA-Z_]\w*', Name),
|
1324
|
-
# numbers
|
1325
|
-
(r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
|
1326
|
-
(r'\d+', Number.Integer)
|
1327
|
-
],
|
1328
|
-
'nestedcomment': [
|
1329
|
-
(r'[^+/]+', Comment.Multiline),
|
1330
|
-
(r'/\+', Comment.Multiline, '#push'),
|
1331
|
-
(r'\+/', Comment.Multiline, '#pop'),
|
1332
|
-
(r'[+/]', Comment.Multiline),
|
1333
|
-
]
|
1334
|
-
}
|
1335
|
-
|
1336
|
-
|
1337
|
-
class TclLexer(RegexLexer):
|
1338
|
-
"""
|
1339
|
-
For Tcl source code.
|
1340
|
-
|
1341
|
-
.. versionadded:: 0.10
|
1342
|
-
"""
|
1343
|
-
|
1344
|
-
keyword_cmds_re = (
|
1345
|
-
r'\b(after|apply|array|break|catch|continue|elseif|else|error|'
|
1346
|
-
r'eval|expr|for|foreach|global|if|namespace|proc|rename|return|'
|
1347
|
-
r'set|switch|then|trace|unset|update|uplevel|upvar|variable|'
|
1348
|
-
r'vwait|while)\b'
|
1349
|
-
)
|
1350
|
-
|
1351
|
-
builtin_cmds_re = (
|
1352
|
-
r'\b(append|bgerror|binary|cd|chan|clock|close|concat|dde|dict|'
|
1353
|
-
r'encoding|eof|exec|exit|fblocked|fconfigure|fcopy|file|'
|
1354
|
-
r'fileevent|flush|format|gets|glob|history|http|incr|info|interp|'
|
1355
|
-
r'join|lappend|lassign|lindex|linsert|list|llength|load|loadTk|'
|
1356
|
-
r'lrange|lrepeat|lreplace|lreverse|lsearch|lset|lsort|mathfunc|'
|
1357
|
-
r'mathop|memory|msgcat|open|package|pid|pkg::create|pkg_mkIndex|'
|
1358
|
-
r'platform|platform::shell|puts|pwd|re_syntax|read|refchan|'
|
1359
|
-
r'regexp|registry|regsub|scan|seek|socket|source|split|string|'
|
1360
|
-
r'subst|tell|time|tm|unknown|unload)\b'
|
1361
|
-
)
|
1362
|
-
|
1363
|
-
name = 'Tcl'
|
1364
|
-
aliases = ['tcl']
|
1365
|
-
filenames = ['*.tcl']
|
1366
|
-
mimetypes = ['text/x-tcl', 'text/x-script.tcl', 'application/x-tcl']
|
1367
|
-
|
1368
|
-
def _gen_command_rules(keyword_cmds_re, builtin_cmds_re, context=""):
|
1369
|
-
return [
|
1370
|
-
(keyword_cmds_re, Keyword, 'params' + context),
|
1371
|
-
(builtin_cmds_re, Name.Builtin, 'params' + context),
|
1372
|
-
(r'([\w\.\-]+)', Name.Variable, 'params' + context),
|
1373
|
-
(r'#', Comment, 'comment'),
|
1374
|
-
]
|
1375
|
-
|
1376
|
-
tokens = {
|
1377
|
-
'root': [
|
1378
|
-
include('command'),
|
1379
|
-
include('basic'),
|
1380
|
-
include('data'),
|
1381
|
-
(r'}', Keyword), # HACK: somehow we miscounted our braces
|
1382
|
-
],
|
1383
|
-
'command': _gen_command_rules(keyword_cmds_re, builtin_cmds_re),
|
1384
|
-
'command-in-brace': _gen_command_rules(keyword_cmds_re,
|
1385
|
-
builtin_cmds_re,
|
1386
|
-
"-in-brace"),
|
1387
|
-
'command-in-bracket': _gen_command_rules(keyword_cmds_re,
|
1388
|
-
builtin_cmds_re,
|
1389
|
-
"-in-bracket"),
|
1390
|
-
'command-in-paren': _gen_command_rules(keyword_cmds_re,
|
1391
|
-
builtin_cmds_re,
|
1392
|
-
"-in-paren"),
|
1393
|
-
'basic': [
|
1394
|
-
(r'\(', Keyword, 'paren'),
|
1395
|
-
(r'\[', Keyword, 'bracket'),
|
1396
|
-
(r'\{', Keyword, 'brace'),
|
1397
|
-
(r'"', String.Double, 'string'),
|
1398
|
-
(r'(eq|ne|in|ni)\b', Operator.Word),
|
1399
|
-
(r'!=|==|<<|>>|<=|>=|&&|\|\||\*\*|[-+~!*/%<>&^|?:]', Operator),
|
1400
|
-
],
|
1401
|
-
'data': [
|
1402
|
-
(r'\s+', Text),
|
1403
|
-
(r'0x[a-fA-F0-9]+', Number.Hex),
|
1404
|
-
(r'0[0-7]+', Number.Oct),
|
1405
|
-
(r'\d+\.\d+', Number.Float),
|
1406
|
-
(r'\d+', Number.Integer),
|
1407
|
-
(r'\$([\w\.\-\:]+)', Name.Variable),
|
1408
|
-
(r'([\w\.\-\:]+)', Text),
|
1409
|
-
],
|
1410
|
-
'params': [
|
1411
|
-
(r';', Keyword, '#pop'),
|
1412
|
-
(r'\n', Text, '#pop'),
|
1413
|
-
(r'(else|elseif|then)\b', Keyword),
|
1414
|
-
include('basic'),
|
1415
|
-
include('data'),
|
1416
|
-
],
|
1417
|
-
'params-in-brace': [
|
1418
|
-
(r'}', Keyword, ('#pop', '#pop')),
|
1419
|
-
include('params')
|
1420
|
-
],
|
1421
|
-
'params-in-paren': [
|
1422
|
-
(r'\)', Keyword, ('#pop', '#pop')),
|
1423
|
-
include('params')
|
1424
|
-
],
|
1425
|
-
'params-in-bracket': [
|
1426
|
-
(r'\]', Keyword, ('#pop', '#pop')),
|
1427
|
-
include('params')
|
1428
|
-
],
|
1429
|
-
'string': [
|
1430
|
-
(r'\[', String.Double, 'string-square'),
|
1431
|
-
(r'(?s)(\\\\|\\[0-7]+|\\.|[^"\\])', String.Double),
|
1432
|
-
(r'"', String.Double, '#pop')
|
1433
|
-
],
|
1434
|
-
'string-square': [
|
1435
|
-
(r'\[', String.Double, 'string-square'),
|
1436
|
-
(r'(?s)(\\\\|\\[0-7]+|\\.|\\\n|[^\]\\])', String.Double),
|
1437
|
-
(r'\]', String.Double, '#pop')
|
1438
|
-
],
|
1439
|
-
'brace': [
|
1440
|
-
(r'}', Keyword, '#pop'),
|
1441
|
-
include('command-in-brace'),
|
1442
|
-
include('basic'),
|
1443
|
-
include('data'),
|
1444
|
-
],
|
1445
|
-
'paren': [
|
1446
|
-
(r'\)', Keyword, '#pop'),
|
1447
|
-
include('command-in-paren'),
|
1448
|
-
include('basic'),
|
1449
|
-
include('data'),
|
1450
|
-
],
|
1451
|
-
'bracket': [
|
1452
|
-
(r'\]', Keyword, '#pop'),
|
1453
|
-
include('command-in-bracket'),
|
1454
|
-
include('basic'),
|
1455
|
-
include('data'),
|
1456
|
-
],
|
1457
|
-
'comment': [
|
1458
|
-
(r'.*[^\\]\n', Comment, '#pop'),
|
1459
|
-
(r'.*\\\n', Comment),
|
1460
|
-
],
|
1461
|
-
}
|
1462
|
-
|
1463
|
-
def analyse_text(text):
|
1464
|
-
return shebang_matches(text, r'(tcl)')
|
1465
|
-
|
1466
|
-
|
1467
|
-
class FactorLexer(RegexLexer):
|
1468
|
-
"""
|
1469
|
-
Lexer for the `Factor <http://factorcode.org>`_ language.
|
1470
|
-
|
1471
|
-
.. versionadded:: 1.4
|
1472
|
-
"""
|
1473
|
-
name = 'Factor'
|
1474
|
-
aliases = ['factor']
|
1475
|
-
filenames = ['*.factor']
|
1476
|
-
mimetypes = ['text/x-factor']
|
1477
|
-
|
1478
|
-
flags = re.MULTILINE | re.UNICODE
|
1479
|
-
|
1480
|
-
builtin_kernel = (
|
1481
|
-
r'(?:-rot|2bi|2bi@|2bi\*|2curry|2dip|2drop|2dup|2keep|2nip|'
|
1482
|
-
r'2over|2tri|2tri@|2tri\*|3bi|3curry|3dip|3drop|3dup|3keep|'
|
1483
|
-
r'3tri|4dip|4drop|4dup|4keep|<wrapper>|=|>boolean|\(clone\)|'
|
1484
|
-
r'\?|\?execute|\?if|and|assert|assert=|assert\?|bi|bi-curry|'
|
1485
|
-
r'bi-curry@|bi-curry\*|bi@|bi\*|boa|boolean|boolean\?|both\?|'
|
1486
|
-
r'build|call|callstack|callstack>array|callstack\?|clear|clone|'
|
1487
|
-
r'compose|compose\?|curry|curry\?|datastack|die|dip|do|drop|'
|
1488
|
-
r'dup|dupd|either\?|eq\?|equal\?|execute|hashcode|hashcode\*|'
|
1489
|
-
r'identity-hashcode|identity-tuple|identity-tuple\?|if|if\*|'
|
1490
|
-
r'keep|loop|most|new|nip|not|null|object|or|over|pick|prepose|'
|
1491
|
-
r'retainstack|rot|same\?|swap|swapd|throw|tri|tri-curry|'
|
1492
|
-
r'tri-curry@|tri-curry\*|tri@|tri\*|tuple|tuple\?|unless|'
|
1493
|
-
r'unless\*|until|when|when\*|while|with|wrapper|wrapper\?|xor)\s'
|
1494
|
-
)
|
1495
|
-
|
1496
|
-
builtin_assocs = (
|
1497
|
-
r'(?:2cache|<enum>|>alist|\?at|\?of|assoc|assoc-all\?|'
|
1498
|
-
r'assoc-any\?|assoc-clone-like|assoc-combine|assoc-diff|'
|
1499
|
-
r'assoc-diff!|assoc-differ|assoc-each|assoc-empty\?|'
|
1500
|
-
r'assoc-filter|assoc-filter!|assoc-filter-as|assoc-find|'
|
1501
|
-
r'assoc-hashcode|assoc-intersect|assoc-like|assoc-map|'
|
1502
|
-
r'assoc-map-as|assoc-partition|assoc-refine|assoc-size|'
|
1503
|
-
r'assoc-stack|assoc-subset\?|assoc-union|assoc-union!|'
|
1504
|
-
r'assoc=|assoc>map|assoc\?|at|at+|at\*|cache|change-at|'
|
1505
|
-
r'clear-assoc|delete-at|delete-at\*|enum|enum\?|extract-keys|'
|
1506
|
-
r'inc-at|key\?|keys|map>assoc|maybe-set-at|new-assoc|of|'
|
1507
|
-
r'push-at|rename-at|set-at|sift-keys|sift-values|substitute|'
|
1508
|
-
r'unzip|value-at|value-at\*|value\?|values|zip)\s'
|
1509
|
-
)
|
1510
|
-
|
1511
|
-
builtin_combinators = (
|
1512
|
-
r'(?:2cleave|2cleave>quot|3cleave|3cleave>quot|4cleave|'
|
1513
|
-
r'4cleave>quot|alist>quot|call-effect|case|case-find|'
|
1514
|
-
r'case>quot|cleave|cleave>quot|cond|cond>quot|deep-spread>quot|'
|
1515
|
-
r'execute-effect|linear-case-quot|no-case|no-case\?|no-cond|'
|
1516
|
-
r'no-cond\?|recursive-hashcode|shallow-spread>quot|spread|'
|
1517
|
-
r'to-fixed-point|wrong-values|wrong-values\?)\s'
|
1518
|
-
)
|
1519
|
-
|
1520
|
-
builtin_math = (
|
1521
|
-
r'(?:-|/|/f|/i|/mod|2/|2\^|<|<=|<fp-nan>|>|>=|>bignum|'
|
1522
|
-
r'>fixnum|>float|>integer|\(all-integers\?\)|'
|
1523
|
-
r'\(each-integer\)|\(find-integer\)|\*|\+|\?1\+|'
|
1524
|
-
r'abs|align|all-integers\?|bignum|bignum\?|bit\?|bitand|'
|
1525
|
-
r'bitnot|bitor|bits>double|bits>float|bitxor|complex|'
|
1526
|
-
r'complex\?|denominator|double>bits|each-integer|even\?|'
|
1527
|
-
r'find-integer|find-last-integer|fixnum|fixnum\?|float|'
|
1528
|
-
r'float>bits|float\?|fp-bitwise=|fp-infinity\?|fp-nan-payload|'
|
1529
|
-
r'fp-nan\?|fp-qnan\?|fp-sign|fp-snan\?|fp-special\?|'
|
1530
|
-
r'if-zero|imaginary-part|integer|integer>fixnum|'
|
1531
|
-
r'integer>fixnum-strict|integer\?|log2|log2-expects-positive|'
|
1532
|
-
r'log2-expects-positive\?|mod|neg|neg\?|next-float|'
|
1533
|
-
r'next-power-of-2|number|number=|number\?|numerator|odd\?|'
|
1534
|
-
r'out-of-fixnum-range|out-of-fixnum-range\?|power-of-2\?|'
|
1535
|
-
r'prev-float|ratio|ratio\?|rational|rational\?|real|'
|
1536
|
-
r'real-part|real\?|recip|rem|sgn|shift|sq|times|u<|u<=|u>|'
|
1537
|
-
r'u>=|unless-zero|unordered\?|when-zero|zero\?)\s'
|
1538
|
-
)
|
1539
|
-
|
1540
|
-
builtin_sequences = (
|
1541
|
-
r'(?:1sequence|2all\?|2each|2map|2map-as|2map-reduce|2reduce|'
|
1542
|
-
r'2selector|2sequence|3append|3append-as|3each|3map|3map-as|'
|
1543
|
-
r'3sequence|4sequence|<repetition>|<reversed>|<slice>|\?first|'
|
1544
|
-
r'\?last|\?nth|\?second|\?set-nth|accumulate|accumulate!|'
|
1545
|
-
r'accumulate-as|all\?|any\?|append|append!|append-as|'
|
1546
|
-
r'assert-sequence|assert-sequence=|assert-sequence\?|'
|
1547
|
-
r'binary-reduce|bounds-check|bounds-check\?|bounds-error|'
|
1548
|
-
r'bounds-error\?|but-last|but-last-slice|cartesian-each|'
|
1549
|
-
r'cartesian-map|cartesian-product|change-nth|check-slice|'
|
1550
|
-
r'check-slice-error|clone-like|collapse-slice|collector|'
|
1551
|
-
r'collector-for|concat|concat-as|copy|count|cut|cut-slice|'
|
1552
|
-
r'cut\*|delete-all|delete-slice|drop-prefix|each|each-from|'
|
1553
|
-
r'each-index|empty\?|exchange|filter|filter!|filter-as|find|'
|
1554
|
-
r'find-from|find-index|find-index-from|find-last|find-last-from|'
|
1555
|
-
r'first|first2|first3|first4|flip|follow|fourth|glue|halves|'
|
1556
|
-
r'harvest|head|head-slice|head-slice\*|head\*|head\?|'
|
1557
|
-
r'if-empty|immutable|immutable-sequence|immutable-sequence\?|'
|
1558
|
-
r'immutable\?|index|index-from|indices|infimum|infimum-by|'
|
1559
|
-
r'insert-nth|interleave|iota|iota-tuple|iota-tuple\?|join|'
|
1560
|
-
r'join-as|last|last-index|last-index-from|length|lengthen|'
|
1561
|
-
r'like|longer|longer\?|longest|map|map!|map-as|map-find|'
|
1562
|
-
r'map-find-last|map-index|map-integers|map-reduce|map-sum|'
|
1563
|
-
r'max-length|member-eq\?|member\?|midpoint@|min-length|'
|
1564
|
-
r'mismatch|move|new-like|new-resizable|new-sequence|'
|
1565
|
-
r'non-negative-integer-expected|non-negative-integer-expected\?|'
|
1566
|
-
r'nth|nths|pad-head|pad-tail|padding|partition|pop|pop\*|'
|
1567
|
-
r'prefix|prepend|prepend-as|produce|produce-as|product|push|'
|
1568
|
-
r'push-all|push-either|push-if|reduce|reduce-index|remove|'
|
1569
|
-
r'remove!|remove-eq|remove-eq!|remove-nth|remove-nth!|repetition|'
|
1570
|
-
r'repetition\?|replace-slice|replicate|replicate-as|rest|'
|
1571
|
-
r'rest-slice|reverse|reverse!|reversed|reversed\?|second|'
|
1572
|
-
r'selector|selector-for|sequence|sequence-hashcode|sequence=|'
|
1573
|
-
r'sequence\?|set-first|set-fourth|set-last|set-length|set-nth|'
|
1574
|
-
r'set-second|set-third|short|shorten|shorter|shorter\?|'
|
1575
|
-
r'shortest|sift|slice|slice-error|slice-error\?|slice\?|'
|
1576
|
-
r'snip|snip-slice|start|start\*|subseq|subseq\?|suffix|'
|
1577
|
-
r'suffix!|sum|sum-lengths|supremum|supremum-by|surround|tail|'
|
1578
|
-
r'tail-slice|tail-slice\*|tail\*|tail\?|third|trim|'
|
1579
|
-
r'trim-head|trim-head-slice|trim-slice|trim-tail|trim-tail-slice|'
|
1580
|
-
r'unclip|unclip-last|unclip-last-slice|unclip-slice|unless-empty|'
|
1581
|
-
r'virtual-exemplar|virtual-sequence|virtual-sequence\?|virtual@|'
|
1582
|
-
r'when-empty)\s'
|
1583
|
-
)
|
1584
|
-
|
1585
|
-
builtin_namespaces = (
|
1586
|
-
r'(?:\+@|change|change-global|counter|dec|get|get-global|'
|
1587
|
-
r'global|inc|init-namespaces|initialize|is-global|make-assoc|'
|
1588
|
-
r'namespace|namestack|off|on|set|set-global|set-namestack|'
|
1589
|
-
r'toggle|with-global|with-scope|with-variable|with-variables)\s'
|
1590
|
-
)
|
1591
|
-
|
1592
|
-
builtin_arrays = (
|
1593
|
-
r'(?:1array|2array|3array|4array|<array>|>array|array|array\?|'
|
1594
|
-
r'pair|pair\?|resize-array)\s'
|
1595
|
-
)
|
1596
|
-
|
1597
|
-
builtin_io = (
|
1598
|
-
r'(?:\(each-stream-block-slice\)|\(each-stream-block\)|'
|
1599
|
-
r'\(stream-contents-by-block\)|\(stream-contents-by-element\)|'
|
1600
|
-
r'\(stream-contents-by-length-or-block\)|'
|
1601
|
-
r'\(stream-contents-by-length\)|\+byte\+|\+character\+|'
|
1602
|
-
r'bad-seek-type|bad-seek-type\?|bl|contents|each-block|'
|
1603
|
-
r'each-block-size|each-block-slice|each-line|each-morsel|'
|
1604
|
-
r'each-stream-block|each-stream-block-slice|each-stream-line|'
|
1605
|
-
r'error-stream|flush|input-stream|input-stream\?|'
|
1606
|
-
r'invalid-read-buffer|invalid-read-buffer\?|lines|nl|'
|
1607
|
-
r'output-stream|output-stream\?|print|read|read-into|'
|
1608
|
-
r'read-partial|read-partial-into|read-until|read1|readln|'
|
1609
|
-
r'seek-absolute|seek-absolute\?|seek-end|seek-end\?|'
|
1610
|
-
r'seek-input|seek-output|seek-relative|seek-relative\?|'
|
1611
|
-
r'stream-bl|stream-contents|stream-contents\*|stream-copy|'
|
1612
|
-
r'stream-copy\*|stream-element-type|stream-flush|'
|
1613
|
-
r'stream-length|stream-lines|stream-nl|stream-print|'
|
1614
|
-
r'stream-read|stream-read-into|stream-read-partial|'
|
1615
|
-
r'stream-read-partial-into|stream-read-partial-unsafe|'
|
1616
|
-
r'stream-read-unsafe|stream-read-until|stream-read1|'
|
1617
|
-
r'stream-readln|stream-seek|stream-seekable\?|stream-tell|'
|
1618
|
-
r'stream-write|stream-write1|tell-input|tell-output|'
|
1619
|
-
r'with-error-stream|with-error-stream\*|with-error>output|'
|
1620
|
-
r'with-input-output\+error-streams|'
|
1621
|
-
r'with-input-output\+error-streams\*|with-input-stream|'
|
1622
|
-
r'with-input-stream\*|with-output-stream|with-output-stream\*|'
|
1623
|
-
r'with-output>error|with-output\+error-stream|'
|
1624
|
-
r'with-output\+error-stream\*|with-streams|with-streams\*|'
|
1625
|
-
r'write|write1)\s'
|
1626
|
-
)
|
1627
|
-
|
1628
|
-
builtin_strings = (
|
1629
|
-
r'(?:1string|<string>|>string|resize-string|string|string\?)\s'
|
1630
|
-
)
|
1631
|
-
|
1632
|
-
builtin_vectors = (
|
1633
|
-
r'(?:1vector|<vector>|>vector|\?push|vector|vector\?)\s'
|
1634
|
-
)
|
1635
|
-
|
1636
|
-
builtin_continuations = (
|
1637
|
-
r'(?:<condition>|<continuation>|<restart>|attempt-all|'
|
1638
|
-
r'attempt-all-error|attempt-all-error\?|callback-error-hook|'
|
1639
|
-
r'callcc0|callcc1|cleanup|compute-restarts|condition|'
|
1640
|
-
r'condition\?|continuation|continuation\?|continue|'
|
1641
|
-
r'continue-restart|continue-with|current-continuation|'
|
1642
|
-
r'error|error-continuation|error-in-thread|error-thread|'
|
1643
|
-
r'ifcc|ignore-errors|in-callback\?|original-error|recover|'
|
1644
|
-
r'restart|restart\?|restarts|rethrow|rethrow-restarts|'
|
1645
|
-
r'return|return-continuation|thread-error-hook|throw-continue|'
|
1646
|
-
r'throw-restarts|with-datastack|with-return)\s'
|
1647
|
-
)
|
1648
|
-
|
1649
|
-
tokens = {
|
1650
|
-
'root': [
|
1651
|
-
# factor allows a file to start with a shebang
|
1652
|
-
(r'#!.*$', Comment.Preproc),
|
1653
|
-
default('base'),
|
1654
|
-
],
|
1655
|
-
'base': [
|
1656
|
-
(r'\s+', Text),
|
1657
|
-
|
1658
|
-
# defining words
|
1659
|
-
(r'((?:MACRO|MEMO|TYPED)?:[:]?)(\s+)(\S+)',
|
1660
|
-
bygroups(Keyword, Text, Name.Function)),
|
1661
|
-
(r'(M:[:]?)(\s+)(\S+)(\s+)(\S+)',
|
1662
|
-
bygroups(Keyword, Text, Name.Class, Text, Name.Function)),
|
1663
|
-
(r'(C:)(\s+)(\S+)(\s+)(\S+)',
|
1664
|
-
bygroups(Keyword, Text, Name.Function, Text, Name.Class)),
|
1665
|
-
(r'(GENERIC:)(\s+)(\S+)',
|
1666
|
-
bygroups(Keyword, Text, Name.Function)),
|
1667
|
-
(r'(HOOK:|GENERIC#)(\s+)(\S+)(\s+)(\S+)',
|
1668
|
-
bygroups(Keyword, Text, Name.Function, Text, Name.Function)),
|
1669
|
-
(r'\(\s', Name.Function, 'stackeffect'),
|
1670
|
-
(r';\s', Keyword),
|
1671
|
-
|
1672
|
-
# imports and namespaces
|
1673
|
-
(r'(USING:)(\s+)',
|
1674
|
-
bygroups(Keyword.Namespace, Text), 'vocabs'),
|
1675
|
-
(r'(USE:|UNUSE:|IN:|QUALIFIED:)(\s+)(\S+)',
|
1676
|
-
bygroups(Keyword.Namespace, Text, Name.Namespace)),
|
1677
|
-
(r'(QUALIFIED-WITH:)(\s+)(\S+)(\s+)(\S+)',
|
1678
|
-
bygroups(Keyword.Namespace, Text, Name.Namespace, Text, Name.Namespace)),
|
1679
|
-
(r'(FROM:|EXCLUDE:)(\s+)(\S+)(\s+=>\s)',
|
1680
|
-
bygroups(Keyword.Namespace, Text, Name.Namespace, Text), 'words'),
|
1681
|
-
(r'(RENAME:)(\s+)(\S+)(\s+)(\S+)(\s+=>\s+)(\S+)',
|
1682
|
-
bygroups(Keyword.Namespace, Text, Name.Function, Text, Name.Namespace, Text, Name.Function)),
|
1683
|
-
(r'(ALIAS:|TYPEDEF:)(\s+)(\S+)(\s+)(\S+)',
|
1684
|
-
bygroups(Keyword.Namespace, Text, Name.Function, Text, Name.Function)),
|
1685
|
-
(r'(DEFER:|FORGET:|POSTPONE:)(\s+)(\S+)',
|
1686
|
-
bygroups(Keyword.Namespace, Text, Name.Function)),
|
1687
|
-
|
1688
|
-
# tuples and classes
|
1689
|
-
(r'(TUPLE:|ERROR:)(\s+)(\S+)(\s+<\s+)(\S+)',
|
1690
|
-
bygroups(Keyword, Text, Name.Class, Text, Name.Class), 'slots'),
|
1691
|
-
(r'(TUPLE:|ERROR:|BUILTIN:)(\s+)(\S+)',
|
1692
|
-
bygroups(Keyword, Text, Name.Class), 'slots'),
|
1693
|
-
(r'(MIXIN:|UNION:|INTERSECTION:)(\s+)(\S+)',
|
1694
|
-
bygroups(Keyword, Text, Name.Class)),
|
1695
|
-
(r'(PREDICATE:)(\s+)(\S+)(\s+<\s+)(\S+)',
|
1696
|
-
bygroups(Keyword, Text, Name.Class, Text, Name.Class)),
|
1697
|
-
(r'(C:)(\s+)(\S+)(\s+)(\S+)',
|
1698
|
-
bygroups(Keyword, Text, Name.Function, Text, Name.Class)),
|
1699
|
-
(r'(INSTANCE:)(\s+)(\S+)(\s+)(\S+)',
|
1700
|
-
bygroups(Keyword, Text, Name.Class, Text, Name.Class)),
|
1701
|
-
(r'(SLOT:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Function)),
|
1702
|
-
(r'(SINGLETON:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Class)),
|
1703
|
-
(r'SINGLETONS:', Keyword, 'classes'),
|
1704
|
-
|
1705
|
-
# other syntax
|
1706
|
-
(r'(CONSTANT:|SYMBOL:|MAIN:|HELP:)(\s+)(\S+)',
|
1707
|
-
bygroups(Keyword, Text, Name.Function)),
|
1708
|
-
(r'SYMBOLS:\s', Keyword, 'words'),
|
1709
|
-
(r'SYNTAX:\s', Keyword),
|
1710
|
-
(r'ALIEN:\s', Keyword),
|
1711
|
-
(r'(STRUCT:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Class)),
|
1712
|
-
(r'(FUNCTION:)(\s+\S+\s+)(\S+)(\s+\(\s+[^\)]+\)\s)',
|
1713
|
-
bygroups(Keyword.Namespace, Text, Name.Function, Text)),
|
1714
|
-
(r'(FUNCTION-ALIAS:)(\s+)(\S+)(\s+\S+\s+)(\S+)(\s+\(\s+[^\)]+\)\s)',
|
1715
|
-
bygroups(Keyword.Namespace, Text, Name.Function, Text, Name.Function, Text)),
|
1716
|
-
|
1717
|
-
# vocab.private
|
1718
|
-
(r'(?:<PRIVATE|PRIVATE>)\s', Keyword.Namespace),
|
1719
|
-
|
1720
|
-
# strings
|
1721
|
-
(r'"""\s+(?:.|\n)*?\s+"""', String),
|
1722
|
-
(r'"(?:\\\\|\\"|[^"])*"', String),
|
1723
|
-
(r'\S+"\s+(?:\\\\|\\"|[^"])*"', String),
|
1724
|
-
(r'CHAR:\s+(?:\\[\\abfnrstv]|[^\\]\S*)\s', String.Char),
|
1725
|
-
|
1726
|
-
# comments
|
1727
|
-
(r'!\s+.*$', Comment),
|
1728
|
-
(r'#!\s+.*$', Comment),
|
1729
|
-
(r'/\*\s+(?:.|\n)*?\s\*/\s', Comment),
|
1730
|
-
|
1731
|
-
# boolean constants
|
1732
|
-
(r'[tf]\s', Name.Constant),
|
1733
|
-
|
1734
|
-
# symbols and literals
|
1735
|
-
(r'[\\$]\s+\S+', Name.Constant),
|
1736
|
-
(r'M\\\s+\S+\s+\S+', Name.Constant),
|
1737
|
-
|
1738
|
-
# numbers
|
1739
|
-
(r'[+-]?(?:[\d,]*\d)?\.(?:\d([\d,]*\d)?)?(?:[eE][+-]?\d+)?\s', Number),
|
1740
|
-
(r'[+-]?\d(?:[\d,]*\d)?(?:[eE][+-]?\d+)?\s', Number),
|
1741
|
-
(r'0x[a-fA-F\d](?:[a-fA-F\d,]*[a-fA-F\d])?(?:p\d([\d,]*\d)?)?\s', Number),
|
1742
|
-
(r'NAN:\s+[a-fA-F\d](?:[a-fA-F\d,]*[a-fA-F\d])?(?:p\d([\d,]*\d)?)?\s', Number),
|
1743
|
-
(r'0b[01]+\s', Number.Bin),
|
1744
|
-
(r'0o[0-7]+\s', Number.Oct),
|
1745
|
-
(r'(?:\d([\d,]*\d)?)?\+\d(?:[\d,]*\d)?/\d(?:[\d,]*\d)?\s', Number),
|
1746
|
-
(r'(?:\-\d([\d,]*\d)?)?\-\d(?:[\d,]*\d)?/\d(?:[\d,]*\d)?\s', Number),
|
1747
|
-
|
1748
|
-
# keywords
|
1749
|
-
(r'(?:deprecated|final|foldable|flushable|inline|recursive)\s',
|
1750
|
-
Keyword),
|
1751
|
-
|
1752
|
-
# builtins
|
1753
|
-
(builtin_kernel, Name.Builtin),
|
1754
|
-
(builtin_assocs, Name.Builtin),
|
1755
|
-
(builtin_combinators, Name.Builtin),
|
1756
|
-
(builtin_math, Name.Builtin),
|
1757
|
-
(builtin_sequences, Name.Builtin),
|
1758
|
-
(builtin_namespaces, Name.Builtin),
|
1759
|
-
(builtin_arrays, Name.Builtin),
|
1760
|
-
(builtin_io, Name.Builtin),
|
1761
|
-
(builtin_strings, Name.Builtin),
|
1762
|
-
(builtin_vectors, Name.Builtin),
|
1763
|
-
(builtin_continuations, Name.Builtin),
|
1764
|
-
|
1765
|
-
# everything else is text
|
1766
|
-
(r'\S+', Text),
|
1767
|
-
],
|
1768
|
-
'stackeffect': [
|
1769
|
-
(r'\s+', Text),
|
1770
|
-
(r'\(\s+', Name.Function, 'stackeffect'),
|
1771
|
-
(r'\)\s', Name.Function, '#pop'),
|
1772
|
-
(r'--\s', Name.Function),
|
1773
|
-
(r'\S+', Name.Variable),
|
1774
|
-
],
|
1775
|
-
'slots': [
|
1776
|
-
(r'\s+', Text),
|
1777
|
-
(r';\s', Keyword, '#pop'),
|
1778
|
-
(r'({\s+)(\S+)(\s+[^}]+\s+}\s)',
|
1779
|
-
bygroups(Text, Name.Variable, Text)),
|
1780
|
-
(r'\S+', Name.Variable),
|
1781
|
-
],
|
1782
|
-
'vocabs': [
|
1783
|
-
(r'\s+', Text),
|
1784
|
-
(r';\s', Keyword, '#pop'),
|
1785
|
-
(r'\S+', Name.Namespace),
|
1786
|
-
],
|
1787
|
-
'classes': [
|
1788
|
-
(r'\s+', Text),
|
1789
|
-
(r';\s', Keyword, '#pop'),
|
1790
|
-
(r'\S+', Name.Class),
|
1791
|
-
],
|
1792
|
-
'words': [
|
1793
|
-
(r'\s+', Text),
|
1794
|
-
(r';\s', Keyword, '#pop'),
|
1795
|
-
(r'\S+', Name.Function),
|
1796
|
-
],
|
1797
|
-
}
|
1798
|
-
|
1799
|
-
|
1800
|
-
class FancyLexer(RegexLexer):
|
1801
|
-
"""
|
1802
|
-
Pygments Lexer For `Fancy <http://www.fancy-lang.org/>`_.
|
1803
|
-
|
1804
|
-
Fancy is a self-hosted, pure object-oriented, dynamic,
|
1805
|
-
class-based, concurrent general-purpose programming language
|
1806
|
-
running on Rubinius, the Ruby VM.
|
1807
|
-
|
1808
|
-
.. versionadded:: 1.5
|
1809
|
-
"""
|
1810
|
-
name = 'Fancy'
|
1811
|
-
filenames = ['*.fy', '*.fancypack']
|
1812
|
-
aliases = ['fancy', 'fy']
|
1813
|
-
mimetypes = ['text/x-fancysrc']
|
1814
|
-
|
1815
|
-
tokens = {
|
1816
|
-
# copied from PerlLexer:
|
1817
|
-
'balanced-regex': [
|
1818
|
-
(r'/(\\\\|\\/|[^/])*/[egimosx]*', String.Regex, '#pop'),
|
1819
|
-
(r'!(\\\\|\\!|[^!])*![egimosx]*', String.Regex, '#pop'),
|
1820
|
-
(r'\\(\\\\|[^\\])*\\[egimosx]*', String.Regex, '#pop'),
|
1821
|
-
(r'{(\\\\|\\}|[^}])*}[egimosx]*', String.Regex, '#pop'),
|
1822
|
-
(r'<(\\\\|\\>|[^>])*>[egimosx]*', String.Regex, '#pop'),
|
1823
|
-
(r'\[(\\\\|\\\]|[^\]])*\][egimosx]*', String.Regex, '#pop'),
|
1824
|
-
(r'\((\\\\|\\\)|[^\)])*\)[egimosx]*', String.Regex, '#pop'),
|
1825
|
-
(r'@(\\\\|\\\@|[^\@])*@[egimosx]*', String.Regex, '#pop'),
|
1826
|
-
(r'%(\\\\|\\\%|[^\%])*%[egimosx]*', String.Regex, '#pop'),
|
1827
|
-
(r'\$(\\\\|\\\$|[^\$])*\$[egimosx]*', String.Regex, '#pop'),
|
1828
|
-
],
|
1829
|
-
'root': [
|
1830
|
-
(r'\s+', Text),
|
1831
|
-
|
1832
|
-
# balanced delimiters (copied from PerlLexer):
|
1833
|
-
(r's{(\\\\|\\}|[^}])*}\s*', String.Regex, 'balanced-regex'),
|
1834
|
-
(r's<(\\\\|\\>|[^>])*>\s*', String.Regex, 'balanced-regex'),
|
1835
|
-
(r's\[(\\\\|\\\]|[^\]])*\]\s*', String.Regex, 'balanced-regex'),
|
1836
|
-
(r's\((\\\\|\\\)|[^\)])*\)\s*', String.Regex, 'balanced-regex'),
|
1837
|
-
(r'm?/(\\\\|\\/|[^/\n])*/[gcimosx]*', String.Regex),
|
1838
|
-
(r'm(?=[/!\\{<\[\(@%\$])', String.Regex, 'balanced-regex'),
|
1839
|
-
|
1840
|
-
# Comments
|
1841
|
-
(r'#(.*?)\n', Comment.Single),
|
1842
|
-
# Symbols
|
1843
|
-
(r'\'([^\'\s\[\]\(\)\{\}]+|\[\])', String.Symbol),
|
1844
|
-
# Multi-line DoubleQuotedString
|
1845
|
-
(r'"""(\\\\|\\"|[^"])*"""', String),
|
1846
|
-
# DoubleQuotedString
|
1847
|
-
(r'"(\\\\|\\"|[^"])*"', String),
|
1848
|
-
# keywords
|
1849
|
-
(r'(def|class|try|catch|finally|retry|return|return_local|match|'
|
1850
|
-
r'case|->|=>)\b', Keyword),
|
1851
|
-
# constants
|
1852
|
-
(r'(self|super|nil|false|true)\b', Name.Constant),
|
1853
|
-
(r'[(){};,/?\|:\\]', Punctuation),
|
1854
|
-
# names
|
1855
|
-
(r'(Object|Array|Hash|Directory|File|Class|String|Number|'
|
1856
|
-
r'Enumerable|FancyEnumerable|Block|TrueClass|NilClass|'
|
1857
|
-
r'FalseClass|Tuple|Symbol|Stack|Set|FancySpec|Method|Package|'
|
1858
|
-
r'Range)\b', Name.Builtin),
|
1859
|
-
# functions
|
1860
|
-
(r'[a-zA-Z](\w|[-+?!=*/^><%])*:', Name.Function),
|
1861
|
-
# operators, must be below functions
|
1862
|
-
(r'[-+*/~,<>=&!?%^\[\]\.$]+', Operator),
|
1863
|
-
('[A-Z]\w*', Name.Constant),
|
1864
|
-
('@[a-zA-Z_]\w*', Name.Variable.Instance),
|
1865
|
-
('@@[a-zA-Z_]\w*', Name.Variable.Class),
|
1866
|
-
('@@?', Operator),
|
1867
|
-
('[a-zA-Z_]\w*', Name),
|
1868
|
-
# numbers - / checks are necessary to avoid mismarking regexes,
|
1869
|
-
# see comment in RubyLexer
|
1870
|
-
(r'(0[oO]?[0-7]+(?:_[0-7]+)*)(\s*)([/?])?',
|
1871
|
-
bygroups(Number.Oct, Text, Operator)),
|
1872
|
-
(r'(0[xX][0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*)(\s*)([/?])?',
|
1873
|
-
bygroups(Number.Hex, Text, Operator)),
|
1874
|
-
(r'(0[bB][01]+(?:_[01]+)*)(\s*)([/?])?',
|
1875
|
-
bygroups(Number.Bin, Text, Operator)),
|
1876
|
-
(r'([\d]+(?:_\d+)*)(\s*)([/?])?',
|
1877
|
-
bygroups(Number.Integer, Text, Operator)),
|
1878
|
-
(r'\d+([eE][+-]?[0-9]+)|\d+\.\d+([eE][+-]?[0-9]+)?', Number.Float),
|
1879
|
-
(r'\d+', Number.Integer)
|
1880
|
-
]
|
1881
|
-
}
|
1882
|
-
|
1883
|
-
|
1884
|
-
class DgLexer(RegexLexer):
|
1885
|
-
"""
|
1886
|
-
Lexer for `dg <http://pyos.github.com/dg>`_,
|
1887
|
-
a functional and object-oriented programming language
|
1888
|
-
running on the CPython 3 VM.
|
1889
|
-
|
1890
|
-
.. versionadded:: 1.6
|
1891
|
-
"""
|
1892
|
-
name = 'dg'
|
1893
|
-
aliases = ['dg']
|
1894
|
-
filenames = ['*.dg']
|
1895
|
-
mimetypes = ['text/x-dg']
|
1896
|
-
|
1897
|
-
tokens = {
|
1898
|
-
'root': [
|
1899
|
-
(r'\s+', Text),
|
1900
|
-
(r'#.*?$', Comment.Single),
|
1901
|
-
|
1902
|
-
(r'(?i)0b[01]+', Number.Bin),
|
1903
|
-
(r'(?i)0o[0-7]+', Number.Oct),
|
1904
|
-
(r'(?i)0x[0-9a-f]+', Number.Hex),
|
1905
|
-
(r'(?i)[+-]?[0-9]+\.[0-9]+(e[+-]?[0-9]+)?j?', Number.Float),
|
1906
|
-
(r'(?i)[+-]?[0-9]+e[+-]?\d+j?', Number.Float),
|
1907
|
-
(r'(?i)[+-]?[0-9]+j?', Number.Integer),
|
1908
|
-
|
1909
|
-
(r"(?i)(br|r?b?)'''", String, combined('stringescape', 'tsqs', 'string')),
|
1910
|
-
(r'(?i)(br|r?b?)"""', String, combined('stringescape', 'tdqs', 'string')),
|
1911
|
-
(r"(?i)(br|r?b?)'", String, combined('stringescape', 'sqs', 'string')),
|
1912
|
-
(r'(?i)(br|r?b?)"', String, combined('stringescape', 'dqs', 'string')),
|
1913
|
-
|
1914
|
-
(r"`\w+'*`", Operator),
|
1915
|
-
(r'\b(and|in|is|or|where)\b', Operator.Word),
|
1916
|
-
(r'[!$%&*+\-./:<-@\\^|~;,]+', Operator),
|
1917
|
-
|
1918
|
-
(r"(?<!\.)(bool|bytearray|bytes|classmethod|complex|dict'?|"
|
1919
|
-
r"float|frozenset|int|list'?|memoryview|object|property|range|"
|
1920
|
-
r"set'?|slice|staticmethod|str|super|tuple'?|type)"
|
1921
|
-
r"(?!['\w])", Name.Builtin),
|
1922
|
-
(r'(?<!\.)(__import__|abs|all|any|bin|bind|chr|cmp|compile|complex|'
|
1923
|
-
r'delattr|dir|divmod|drop|dropwhile|enumerate|eval|exhaust|'
|
1924
|
-
r'filter|flip|foldl1?|format|fst|getattr|globals|hasattr|hash|'
|
1925
|
-
r'head|hex|id|init|input|isinstance|issubclass|iter|iterate|last|'
|
1926
|
-
r'len|locals|map|max|min|next|oct|open|ord|pow|print|repr|'
|
1927
|
-
r'reversed|round|setattr|scanl1?|snd|sorted|sum|tail|take|'
|
1928
|
-
r"takewhile|vars|zip)(?!['\w])", Name.Builtin),
|
1929
|
-
(r"(?<!\.)(self|Ellipsis|NotImplemented|None|True|False)(?!['\w])",
|
1930
|
-
Name.Builtin.Pseudo),
|
1931
|
-
|
1932
|
-
(r"(?<!\.)[A-Z]\w*(Error|Exception|Warning)'*(?!['\w])",
|
1933
|
-
Name.Exception),
|
1934
|
-
(r"(?<!\.)(Exception|GeneratorExit|KeyboardInterrupt|StopIteration|"
|
1935
|
-
r"SystemExit)(?!['\w])", Name.Exception),
|
1936
|
-
|
1937
|
-
(r"(?<![\.\w])(except|finally|for|if|import|not|otherwise|raise|"
|
1938
|
-
r"subclass|while|with|yield)(?!['\w])", Keyword.Reserved),
|
1939
|
-
|
1940
|
-
(r"[A-Z_]+'*(?!['\w])", Name),
|
1941
|
-
(r"[A-Z]\w+'*(?!['\w])", Keyword.Type),
|
1942
|
-
(r"\w+'*", Name),
|
1943
|
-
|
1944
|
-
(r'[()]', Punctuation),
|
1945
|
-
(r'.', Error),
|
1946
|
-
],
|
1947
|
-
'stringescape': [
|
1948
|
-
(r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|'
|
1949
|
-
r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
|
1950
|
-
],
|
1951
|
-
'string': [
|
1952
|
-
(r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
|
1953
|
-
'[hlL]?[diouxXeEfFgGcrs%]', String.Interpol),
|
1954
|
-
(r'[^\\\'"%\n]+', String),
|
1955
|
-
# quotes, percents and backslashes must be parsed one at a time
|
1956
|
-
(r'[\'"\\]', String),
|
1957
|
-
# unhandled string formatting sign
|
1958
|
-
(r'%', String),
|
1959
|
-
(r'\n', String)
|
1960
|
-
],
|
1961
|
-
'dqs': [
|
1962
|
-
(r'"', String, '#pop')
|
1963
|
-
],
|
1964
|
-
'sqs': [
|
1965
|
-
(r"'", String, '#pop')
|
1966
|
-
],
|
1967
|
-
'tdqs': [
|
1968
|
-
(r'"""', String, '#pop')
|
1969
|
-
],
|
1970
|
-
'tsqs': [
|
1971
|
-
(r"'''", String, '#pop')
|
1972
|
-
],
|
1973
|
-
}
|
1974
|
-
|
1975
|
-
|
1976
|
-
class Perl6Lexer(ExtendedRegexLexer):
|
1977
|
-
"""
|
1978
|
-
For `Perl 6 <http://www.perl6.org>`_ source code.
|
1979
|
-
|
1980
|
-
.. versionadded:: 2.0
|
1981
|
-
"""
|
1982
|
-
|
1983
|
-
name = 'Perl6'
|
1984
|
-
aliases = ['perl6', 'pl6']
|
1985
|
-
filenames = ['*.pl', '*.pm', '*.nqp', '*.p6', '*.6pl', '*.p6l', '*.pl6',
|
1986
|
-
'*.6pm', '*.p6m', '*.pm6', '*.t']
|
1987
|
-
mimetypes = ['text/x-perl6', 'application/x-perl6']
|
1988
|
-
flags = re.MULTILINE | re.DOTALL | re.UNICODE
|
1989
|
-
|
1990
|
-
PERL6_IDENTIFIER_RANGE = "['\w:-]"
|
1991
|
-
|
1992
|
-
PERL6_KEYWORDS = (
|
1993
|
-
'BEGIN', 'CATCH', 'CHECK', 'CONTROL', 'END', 'ENTER', 'FIRST', 'INIT',
|
1994
|
-
'KEEP', 'LAST', 'LEAVE', 'NEXT', 'POST', 'PRE', 'START', 'TEMP',
|
1995
|
-
'UNDO', 'as', 'assoc', 'async', 'augment', 'binary', 'break', 'but',
|
1996
|
-
'cached', 'category', 'class', 'constant', 'contend', 'continue',
|
1997
|
-
'copy', 'deep', 'default', 'defequiv', 'defer', 'die', 'do', 'else',
|
1998
|
-
'elsif', 'enum', 'equiv', 'exit', 'export', 'fail', 'fatal', 'for',
|
1999
|
-
'gather', 'given', 'goto', 'grammar', 'handles', 'has', 'if', 'inline',
|
2000
|
-
'irs', 'is', 'last', 'leave', 'let', 'lift', 'loop', 'looser', 'macro',
|
2001
|
-
'make', 'maybe', 'method', 'module', 'multi', 'my', 'next', 'of',
|
2002
|
-
'ofs', 'only', 'oo', 'ors', 'our', 'package', 'parsed', 'prec',
|
2003
|
-
'proto', 'readonly', 'redo', 'ref', 'regex', 'reparsed', 'repeat',
|
2004
|
-
'require', 'required', 'return', 'returns', 'role', 'rule', 'rw',
|
2005
|
-
'self', 'slang', 'state', 'sub', 'submethod', 'subset', 'supersede',
|
2006
|
-
'take', 'temp', 'tighter', 'token', 'trusts', 'try', 'unary',
|
2007
|
-
'unless', 'until', 'use', 'warn', 'when', 'where', 'while', 'will',
|
2008
|
-
)
|
2009
|
-
|
2010
|
-
PERL6_BUILTINS = (
|
2011
|
-
'ACCEPTS', 'HOW', 'REJECTS', 'VAR', 'WHAT', 'WHENCE', 'WHERE', 'WHICH',
|
2012
|
-
'WHO', 'abs', 'acos', 'acosec', 'acosech', 'acosh', 'acotan', 'acotanh',
|
2013
|
-
'all', 'any', 'approx', 'arity', 'asec', 'asech', 'asin', 'asinh'
|
2014
|
-
'assuming', 'atan', 'atan2', 'atanh', 'attr', 'bless', 'body', 'by'
|
2015
|
-
'bytes', 'caller', 'callsame', 'callwith', 'can', 'capitalize', 'cat',
|
2016
|
-
'ceiling', 'chars', 'chmod', 'chomp', 'chop', 'chr', 'chroot',
|
2017
|
-
'circumfix', 'cis', 'classify', 'clone', 'close', 'cmp_ok', 'codes',
|
2018
|
-
'comb', 'connect', 'contains', 'context', 'cos', 'cosec', 'cosech',
|
2019
|
-
'cosh', 'cotan', 'cotanh', 'count', 'defined', 'delete', 'diag',
|
2020
|
-
'dies_ok', 'does', 'e', 'each', 'eager', 'elems', 'end', 'eof', 'eval',
|
2021
|
-
'eval_dies_ok', 'eval_elsewhere', 'eval_lives_ok', 'evalfile', 'exists',
|
2022
|
-
'exp', 'first', 'flip', 'floor', 'flunk', 'flush', 'fmt', 'force_todo',
|
2023
|
-
'fork', 'from', 'getc', 'gethost', 'getlogin', 'getpeername', 'getpw',
|
2024
|
-
'gmtime', 'graphs', 'grep', 'hints', 'hyper', 'im', 'index', 'infix',
|
2025
|
-
'invert', 'is_approx', 'is_deeply', 'isa', 'isa_ok', 'isnt', 'iterator',
|
2026
|
-
'join', 'key', 'keys', 'kill', 'kv', 'lastcall', 'lazy', 'lc', 'lcfirst',
|
2027
|
-
'like', 'lines', 'link', 'lives_ok', 'localtime', 'log', 'log10', 'map',
|
2028
|
-
'max', 'min', 'minmax', 'name', 'new', 'nextsame', 'nextwith', 'nfc',
|
2029
|
-
'nfd', 'nfkc', 'nfkd', 'nok_error', 'nonce', 'none', 'normalize', 'not',
|
2030
|
-
'nothing', 'ok', 'once', 'one', 'open', 'opendir', 'operator', 'ord',
|
2031
|
-
'p5chomp', 'p5chop', 'pack', 'pair', 'pairs', 'pass', 'perl', 'pi',
|
2032
|
-
'pick', 'plan', 'plan_ok', 'polar', 'pop', 'pos', 'postcircumfix',
|
2033
|
-
'postfix', 'pred', 'prefix', 'print', 'printf', 'push', 'quasi',
|
2034
|
-
'quotemeta', 'rand', 're', 'read', 'readdir', 'readline', 'reduce',
|
2035
|
-
'reverse', 'rewind', 'rewinddir', 'rindex', 'roots', 'round',
|
2036
|
-
'roundrobin', 'run', 'runinstead', 'sameaccent', 'samecase', 'say',
|
2037
|
-
'sec', 'sech', 'sech', 'seek', 'shape', 'shift', 'sign', 'signature',
|
2038
|
-
'sin', 'sinh', 'skip', 'skip_rest', 'sleep', 'slurp', 'sort', 'splice',
|
2039
|
-
'split', 'sprintf', 'sqrt', 'srand', 'strand', 'subst', 'substr', 'succ',
|
2040
|
-
'sum', 'symlink', 'tan', 'tanh', 'throws_ok', 'time', 'times', 'to',
|
2041
|
-
'todo', 'trim', 'trim_end', 'trim_start', 'true', 'truncate', 'uc',
|
2042
|
-
'ucfirst', 'undef', 'undefine', 'uniq', 'unlike', 'unlink', 'unpack',
|
2043
|
-
'unpolar', 'unshift', 'unwrap', 'use_ok', 'value', 'values', 'vec',
|
2044
|
-
'version_lt', 'void', 'wait', 'want', 'wrap', 'write', 'zip',
|
2045
|
-
)
|
2046
|
-
|
2047
|
-
PERL6_BUILTIN_CLASSES = (
|
2048
|
-
'Abstraction', 'Any', 'AnyChar', 'Array', 'Associative', 'Bag', 'Bit',
|
2049
|
-
'Blob', 'Block', 'Bool', 'Buf', 'Byte', 'Callable', 'Capture', 'Char', 'Class',
|
2050
|
-
'Code', 'Codepoint', 'Comparator', 'Complex', 'Decreasing', 'Exception',
|
2051
|
-
'Failure', 'False', 'Grammar', 'Grapheme', 'Hash', 'IO', 'Increasing',
|
2052
|
-
'Int', 'Junction', 'KeyBag', 'KeyExtractor', 'KeyHash', 'KeySet',
|
2053
|
-
'KitchenSink', 'List', 'Macro', 'Mapping', 'Match', 'Matcher', 'Method',
|
2054
|
-
'Module', 'Num', 'Object', 'Ordered', 'Ordering', 'OrderingPair',
|
2055
|
-
'Package', 'Pair', 'Positional', 'Proxy', 'Range', 'Rat', 'Regex',
|
2056
|
-
'Role', 'Routine', 'Scalar', 'Seq', 'Set', 'Signature', 'Str', 'StrLen',
|
2057
|
-
'StrPos', 'Sub', 'Submethod', 'True', 'UInt', 'Undef', 'Version', 'Void',
|
2058
|
-
'Whatever', 'bit', 'bool', 'buf', 'buf1', 'buf16', 'buf2', 'buf32',
|
2059
|
-
'buf4', 'buf64', 'buf8', 'complex', 'int', 'int1', 'int16', 'int2',
|
2060
|
-
'int32', 'int4', 'int64', 'int8', 'num', 'rat', 'rat1', 'rat16', 'rat2',
|
2061
|
-
'rat32', 'rat4', 'rat64', 'rat8', 'uint', 'uint1', 'uint16', 'uint2',
|
2062
|
-
'uint32', 'uint4', 'uint64', 'uint8', 'utf16', 'utf32', 'utf8',
|
2063
|
-
)
|
2064
|
-
|
2065
|
-
PERL6_OPERATORS = (
|
2066
|
-
'X', 'Z', 'after', 'also', 'and', 'andthen', 'before', 'cmp', 'div',
|
2067
|
-
'eq', 'eqv', 'extra', 'ff', 'fff', 'ge', 'gt', 'le', 'leg', 'lt', 'm',
|
2068
|
-
'mm', 'mod', 'ne', 'or', 'orelse', 'rx', 's', 'tr', 'x', 'xor', 'xx',
|
2069
|
-
'++', '--', '**', '!', '+', '-', '~', '?', '|', '||', '+^', '~^', '?^',
|
2070
|
-
'^', '*', '/', '%', '%%', '+&', '+<', '+>', '~&', '~<', '~>', '?&',
|
2071
|
-
'gcd', 'lcm', '+', '-', '+|', '+^', '~|', '~^', '?|', '?^',
|
2072
|
-
'~', '&', '^', 'but', 'does', '<=>', '..', '..^', '^..', '^..^',
|
2073
|
-
'!=', '==', '<', '<=', '>', '>=', '~~', '===', '!eqv',
|
2074
|
-
'&&', '||', '^^', '//', 'min', 'max', '??', '!!', 'ff', 'fff', 'so',
|
2075
|
-
'not', '<==', '==>', '<<==', '==>>',
|
2076
|
-
)
|
2077
|
-
|
2078
|
-
# Perl 6 has a *lot* of possible bracketing characters
|
2079
|
-
# this list was lifted from STD.pm6 (https://github.com/perl6/std)
|
2080
|
-
PERL6_BRACKETS = {
|
2081
|
-
u'\u0028' : u'\u0029', u'\u003c' : u'\u003e', u'\u005b' : u'\u005d',
|
2082
|
-
u'\u007b' : u'\u007d', u'\u00ab' : u'\u00bb', u'\u0f3a' : u'\u0f3b',
|
2083
|
-
u'\u0f3c' : u'\u0f3d', u'\u169b' : u'\u169c', u'\u2018' : u'\u2019',
|
2084
|
-
u'\u201a' : u'\u2019', u'\u201b' : u'\u2019', u'\u201c' : u'\u201d',
|
2085
|
-
u'\u201e' : u'\u201d', u'\u201f' : u'\u201d', u'\u2039' : u'\u203a',
|
2086
|
-
u'\u2045' : u'\u2046', u'\u207d' : u'\u207e', u'\u208d' : u'\u208e',
|
2087
|
-
u'\u2208' : u'\u220b', u'\u2209' : u'\u220c', u'\u220a' : u'\u220d',
|
2088
|
-
u'\u2215' : u'\u29f5', u'\u223c' : u'\u223d', u'\u2243' : u'\u22cd',
|
2089
|
-
u'\u2252' : u'\u2253', u'\u2254' : u'\u2255', u'\u2264' : u'\u2265',
|
2090
|
-
u'\u2266' : u'\u2267', u'\u2268' : u'\u2269', u'\u226a' : u'\u226b',
|
2091
|
-
u'\u226e' : u'\u226f', u'\u2270' : u'\u2271', u'\u2272' : u'\u2273',
|
2092
|
-
u'\u2274' : u'\u2275', u'\u2276' : u'\u2277', u'\u2278' : u'\u2279',
|
2093
|
-
u'\u227a' : u'\u227b', u'\u227c' : u'\u227d', u'\u227e' : u'\u227f',
|
2094
|
-
u'\u2280' : u'\u2281', u'\u2282' : u'\u2283', u'\u2284' : u'\u2285',
|
2095
|
-
u'\u2286' : u'\u2287', u'\u2288' : u'\u2289', u'\u228a' : u'\u228b',
|
2096
|
-
u'\u228f' : u'\u2290', u'\u2291' : u'\u2292', u'\u2298' : u'\u29b8',
|
2097
|
-
u'\u22a2' : u'\u22a3', u'\u22a6' : u'\u2ade', u'\u22a8' : u'\u2ae4',
|
2098
|
-
u'\u22a9' : u'\u2ae3', u'\u22ab' : u'\u2ae5', u'\u22b0' : u'\u22b1',
|
2099
|
-
u'\u22b2' : u'\u22b3', u'\u22b4' : u'\u22b5', u'\u22b6' : u'\u22b7',
|
2100
|
-
u'\u22c9' : u'\u22ca', u'\u22cb' : u'\u22cc', u'\u22d0' : u'\u22d1',
|
2101
|
-
u'\u22d6' : u'\u22d7', u'\u22d8' : u'\u22d9', u'\u22da' : u'\u22db',
|
2102
|
-
u'\u22dc' : u'\u22dd', u'\u22de' : u'\u22df', u'\u22e0' : u'\u22e1',
|
2103
|
-
u'\u22e2' : u'\u22e3', u'\u22e4' : u'\u22e5', u'\u22e6' : u'\u22e7',
|
2104
|
-
u'\u22e8' : u'\u22e9', u'\u22ea' : u'\u22eb', u'\u22ec' : u'\u22ed',
|
2105
|
-
u'\u22f0' : u'\u22f1', u'\u22f2' : u'\u22fa', u'\u22f3' : u'\u22fb',
|
2106
|
-
u'\u22f4' : u'\u22fc', u'\u22f6' : u'\u22fd', u'\u22f7' : u'\u22fe',
|
2107
|
-
u'\u2308' : u'\u2309', u'\u230a' : u'\u230b', u'\u2329' : u'\u232a',
|
2108
|
-
u'\u23b4' : u'\u23b5', u'\u2768' : u'\u2769', u'\u276a' : u'\u276b',
|
2109
|
-
u'\u276c' : u'\u276d', u'\u276e' : u'\u276f', u'\u2770' : u'\u2771',
|
2110
|
-
u'\u2772' : u'\u2773', u'\u2774' : u'\u2775', u'\u27c3' : u'\u27c4',
|
2111
|
-
u'\u27c5' : u'\u27c6', u'\u27d5' : u'\u27d6', u'\u27dd' : u'\u27de',
|
2112
|
-
u'\u27e2' : u'\u27e3', u'\u27e4' : u'\u27e5', u'\u27e6' : u'\u27e7',
|
2113
|
-
u'\u27e8' : u'\u27e9', u'\u27ea' : u'\u27eb', u'\u2983' : u'\u2984',
|
2114
|
-
u'\u2985' : u'\u2986', u'\u2987' : u'\u2988', u'\u2989' : u'\u298a',
|
2115
|
-
u'\u298b' : u'\u298c', u'\u298d' : u'\u298e', u'\u298f' : u'\u2990',
|
2116
|
-
u'\u2991' : u'\u2992', u'\u2993' : u'\u2994', u'\u2995' : u'\u2996',
|
2117
|
-
u'\u2997' : u'\u2998', u'\u29c0' : u'\u29c1', u'\u29c4' : u'\u29c5',
|
2118
|
-
u'\u29cf' : u'\u29d0', u'\u29d1' : u'\u29d2', u'\u29d4' : u'\u29d5',
|
2119
|
-
u'\u29d8' : u'\u29d9', u'\u29da' : u'\u29db', u'\u29f8' : u'\u29f9',
|
2120
|
-
u'\u29fc' : u'\u29fd', u'\u2a2b' : u'\u2a2c', u'\u2a2d' : u'\u2a2e',
|
2121
|
-
u'\u2a34' : u'\u2a35', u'\u2a3c' : u'\u2a3d', u'\u2a64' : u'\u2a65',
|
2122
|
-
u'\u2a79' : u'\u2a7a', u'\u2a7d' : u'\u2a7e', u'\u2a7f' : u'\u2a80',
|
2123
|
-
u'\u2a81' : u'\u2a82', u'\u2a83' : u'\u2a84', u'\u2a8b' : u'\u2a8c',
|
2124
|
-
u'\u2a91' : u'\u2a92', u'\u2a93' : u'\u2a94', u'\u2a95' : u'\u2a96',
|
2125
|
-
u'\u2a97' : u'\u2a98', u'\u2a99' : u'\u2a9a', u'\u2a9b' : u'\u2a9c',
|
2126
|
-
u'\u2aa1' : u'\u2aa2', u'\u2aa6' : u'\u2aa7', u'\u2aa8' : u'\u2aa9',
|
2127
|
-
u'\u2aaa' : u'\u2aab', u'\u2aac' : u'\u2aad', u'\u2aaf' : u'\u2ab0',
|
2128
|
-
u'\u2ab3' : u'\u2ab4', u'\u2abb' : u'\u2abc', u'\u2abd' : u'\u2abe',
|
2129
|
-
u'\u2abf' : u'\u2ac0', u'\u2ac1' : u'\u2ac2', u'\u2ac3' : u'\u2ac4',
|
2130
|
-
u'\u2ac5' : u'\u2ac6', u'\u2acd' : u'\u2ace', u'\u2acf' : u'\u2ad0',
|
2131
|
-
u'\u2ad1' : u'\u2ad2', u'\u2ad3' : u'\u2ad4', u'\u2ad5' : u'\u2ad6',
|
2132
|
-
u'\u2aec' : u'\u2aed', u'\u2af7' : u'\u2af8', u'\u2af9' : u'\u2afa',
|
2133
|
-
u'\u2e02' : u'\u2e03', u'\u2e04' : u'\u2e05', u'\u2e09' : u'\u2e0a',
|
2134
|
-
u'\u2e0c' : u'\u2e0d', u'\u2e1c' : u'\u2e1d', u'\u2e20' : u'\u2e21',
|
2135
|
-
u'\u3008' : u'\u3009', u'\u300a' : u'\u300b', u'\u300c' : u'\u300d',
|
2136
|
-
u'\u300e' : u'\u300f', u'\u3010' : u'\u3011', u'\u3014' : u'\u3015',
|
2137
|
-
u'\u3016' : u'\u3017', u'\u3018' : u'\u3019', u'\u301a' : u'\u301b',
|
2138
|
-
u'\u301d' : u'\u301e', u'\ufd3e' : u'\ufd3f', u'\ufe17' : u'\ufe18',
|
2139
|
-
u'\ufe35' : u'\ufe36', u'\ufe37' : u'\ufe38', u'\ufe39' : u'\ufe3a',
|
2140
|
-
u'\ufe3b' : u'\ufe3c', u'\ufe3d' : u'\ufe3e', u'\ufe3f' : u'\ufe40',
|
2141
|
-
u'\ufe41' : u'\ufe42', u'\ufe43' : u'\ufe44', u'\ufe47' : u'\ufe48',
|
2142
|
-
u'\ufe59' : u'\ufe5a', u'\ufe5b' : u'\ufe5c', u'\ufe5d' : u'\ufe5e',
|
2143
|
-
u'\uff08' : u'\uff09', u'\uff1c' : u'\uff1e', u'\uff3b' : u'\uff3d',
|
2144
|
-
u'\uff5b' : u'\uff5d', u'\uff5f' : u'\uff60', u'\uff62' : u'\uff63',
|
2145
|
-
}
|
2146
|
-
|
2147
|
-
def _build_word_match(words, boundary_regex_fragment = None, prefix = '', suffix = ''):
|
2148
|
-
if boundary_regex_fragment is None:
|
2149
|
-
return r'\b(' + prefix + r'|'.join([ re.escape(x) for x in words]) + \
|
2150
|
-
suffix + r')\b'
|
2151
|
-
else:
|
2152
|
-
return r'(?<!' + boundary_regex_fragment + r')' + prefix + r'(' + \
|
2153
|
-
r'|'.join([ re.escape(x) for x in words]) + r')' + suffix + r'(?!' + \
|
2154
|
-
boundary_regex_fragment + r')'
|
2155
|
-
|
2156
|
-
def brackets_callback(token_class):
|
2157
|
-
def callback(lexer, match, context):
|
2158
|
-
groups = match.groupdict()
|
2159
|
-
opening_chars = groups['delimiter']
|
2160
|
-
n_chars = len(opening_chars)
|
2161
|
-
adverbs = groups.get('adverbs')
|
2162
|
-
|
2163
|
-
closer = Perl6Lexer.PERL6_BRACKETS.get(opening_chars[0])
|
2164
|
-
text = context.text
|
2165
|
-
|
2166
|
-
if closer is None: # it's not a mirrored character, which means we
|
2167
|
-
# just need to look for the next occurrence
|
2168
|
-
|
2169
|
-
end_pos = text.find(opening_chars, match.start('delimiter') + n_chars)
|
2170
|
-
else: # we need to look for the corresponding closing character,
|
2171
|
-
# keep nesting in mind
|
2172
|
-
closing_chars = closer * n_chars
|
2173
|
-
nesting_level = 1
|
2174
|
-
|
2175
|
-
search_pos = match.start('delimiter')
|
2176
|
-
|
2177
|
-
while nesting_level > 0:
|
2178
|
-
next_open_pos = text.find(opening_chars, search_pos + n_chars)
|
2179
|
-
next_close_pos = text.find(closing_chars, search_pos + n_chars)
|
2180
|
-
|
2181
|
-
if next_close_pos == -1:
|
2182
|
-
next_close_pos = len(text)
|
2183
|
-
nesting_level = 0
|
2184
|
-
elif next_open_pos != -1 and next_open_pos < next_close_pos:
|
2185
|
-
nesting_level += 1
|
2186
|
-
search_pos = next_open_pos
|
2187
|
-
else: # next_close_pos < next_open_pos
|
2188
|
-
nesting_level -= 1
|
2189
|
-
search_pos = next_close_pos
|
2190
|
-
|
2191
|
-
end_pos = next_close_pos
|
2192
|
-
|
2193
|
-
if end_pos < 0: # if we didn't find a closer, just highlight the
|
2194
|
-
# rest of the text in this class
|
2195
|
-
end_pos = len(text)
|
2196
|
-
|
2197
|
-
if adverbs is not None and re.search(r':to\b', adverbs):
|
2198
|
-
heredoc_terminator = text[match.start('delimiter') + n_chars : end_pos]
|
2199
|
-
end_heredoc = re.search(r'^\s*' + re.escape(heredoc_terminator) + r'\s*$', text[ end_pos : ], re.MULTILINE)
|
2200
|
-
|
2201
|
-
if end_heredoc:
|
2202
|
-
end_pos += end_heredoc.end()
|
2203
|
-
else:
|
2204
|
-
end_pos = len(text)
|
2205
|
-
|
2206
|
-
yield match.start(), token_class, text[match.start() : end_pos + n_chars]
|
2207
|
-
context.pos = end_pos + n_chars
|
2208
|
-
|
2209
|
-
return callback
|
2210
|
-
|
2211
|
-
def opening_brace_callback(lexer, match, context):
|
2212
|
-
stack = context.stack
|
2213
|
-
|
2214
|
-
yield match.start(), Text, context.text[match.start() : match.end()]
|
2215
|
-
context.pos = match.end()
|
2216
|
-
|
2217
|
-
# if we encounter an opening brace and we're one level
|
2218
|
-
# below a token state, it means we need to increment
|
2219
|
-
# the nesting level for braces so we know later when
|
2220
|
-
# we should return to the token rules.
|
2221
|
-
if len(stack) > 2 and stack[-2] == 'token':
|
2222
|
-
context.perl6_token_nesting_level += 1
|
2223
|
-
|
2224
|
-
def closing_brace_callback(lexer, match, context):
|
2225
|
-
stack = context.stack
|
2226
|
-
|
2227
|
-
yield match.start(), Text, context.text[match.start() : match.end()]
|
2228
|
-
context.pos = match.end()
|
2229
|
-
|
2230
|
-
# if we encounter a free closing brace and we're one level
|
2231
|
-
# below a token state, it means we need to check the nesting
|
2232
|
-
# level to see if we need to return to the token state.
|
2233
|
-
if len(stack) > 2 and stack[-2] == 'token':
|
2234
|
-
context.perl6_token_nesting_level -= 1
|
2235
|
-
if context.perl6_token_nesting_level == 0:
|
2236
|
-
stack.pop()
|
2237
|
-
|
2238
|
-
def embedded_perl6_callback(lexer, match, context):
|
2239
|
-
context.perl6_token_nesting_level = 1
|
2240
|
-
yield match.start(), Text, context.text[match.start() : match.end()]
|
2241
|
-
context.pos = match.end()
|
2242
|
-
context.stack.append('root')
|
2243
|
-
|
2244
|
-
# If you're modifying these rules, be careful if you need to process '{' or '}'
|
2245
|
-
# characters. We have special logic for processing these characters (due to the fact
|
2246
|
-
# that you can nest Perl 6 code in regex blocks), so if you need to process one of
|
2247
|
-
# them, make sure you also process the corresponding one!
|
2248
|
-
tokens = {
|
2249
|
-
'common' : [
|
2250
|
-
(r'#[`|=](?P<delimiter>(?P<first_char>[' + ''.join(PERL6_BRACKETS) + r'])(?P=first_char)*)', brackets_callback(Comment.Multiline)),
|
2251
|
-
(r'#[^\n]*$', Comment.Singleline),
|
2252
|
-
(r'^(\s*)=begin\s+(\w+)\b.*?^\1=end\s+\2', Comment.Multiline),
|
2253
|
-
(r'^(\s*)=for.*?\n\s*?\n', Comment.Multiline),
|
2254
|
-
(r'^=.*?\n\s*?\n', Comment.Multiline),
|
2255
|
-
(r'(regex|token|rule)(\s*' + PERL6_IDENTIFIER_RANGE + '+:sym)',
|
2256
|
-
bygroups(Keyword, Name), 'token-sym-brackets'),
|
2257
|
-
(r'(regex|token|rule)(?!' + PERL6_IDENTIFIER_RANGE + ')(\s*' + PERL6_IDENTIFIER_RANGE + '+)?', bygroups(Keyword, Name), 'pre-token'),
|
2258
|
-
# deal with a special case in the Perl 6 grammar (role q { ... })
|
2259
|
-
(r'(role)(\s+)(q)(\s*)', bygroups(Keyword, Text, Name, Text)),
|
2260
|
-
(_build_word_match(PERL6_KEYWORDS, PERL6_IDENTIFIER_RANGE), Keyword),
|
2261
|
-
(_build_word_match(PERL6_BUILTIN_CLASSES, PERL6_IDENTIFIER_RANGE, suffix = '(?::[UD])?'), Name.Builtin),
|
2262
|
-
(_build_word_match(PERL6_BUILTINS, PERL6_IDENTIFIER_RANGE), Name.Builtin),
|
2263
|
-
# copied from PerlLexer
|
2264
|
-
(r'[$@%&][.^:?=!~]?' + PERL6_IDENTIFIER_RANGE + u'+(?:<<.*?>>|<.*?>|«.*?»)*',
|
2265
|
-
Name.Variable),
|
2266
|
-
(r'\$[!/](?:<<.*?>>|<.*?>|«.*?»)*', Name.Variable.Global),
|
2267
|
-
(r'::\?\w+', Name.Variable.Global),
|
2268
|
-
(r'[$@%&]\*' + PERL6_IDENTIFIER_RANGE + u'+(?:<<.*?>>|<.*?>|«.*?»)*',
|
2269
|
-
Name.Variable.Global),
|
2270
|
-
(r'\$(?:<.*?>)+', Name.Variable),
|
2271
|
-
(r'(?:q|qq|Q)[a-zA-Z]?\s*(?P<adverbs>:[\w\s:]+)?\s*(?P<delimiter>(?P<first_char>[^0-9a-zA-Z:\s])(?P=first_char)*)', brackets_callback(String)),
|
2272
|
-
# copied from PerlLexer
|
2273
|
-
(r'0_?[0-7]+(_[0-7]+)*', Number.Oct),
|
2274
|
-
(r'0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*', Number.Hex),
|
2275
|
-
(r'0b[01]+(_[01]+)*', Number.Bin),
|
2276
|
-
(r'(?i)(\d*(_\d*)*\.\d+(_\d*)*|\d+(_\d*)*\.\d+(_\d*)*)(e[+-]?\d+)?',
|
2277
|
-
Number.Float),
|
2278
|
-
(r'(?i)\d+(_\d*)*e[+-]?\d+(_\d*)*', Number.Float),
|
2279
|
-
(r'\d+(_\d+)*', Number.Integer),
|
2280
|
-
(r'(?<=~~)\s*/(?:\\\\|\\/|.)*?/', String.Regex),
|
2281
|
-
(r'(?<=[=(,])\s*/(?:\\\\|\\/|.)*?/', String.Regex),
|
2282
|
-
(r'm\w+(?=\()', Name),
|
2283
|
-
(r'(?:m|ms|rx)\s*(?P<adverbs>:[\w\s:]+)?\s*(?P<delimiter>(?P<first_char>[^0-9a-zA-Z_:\s])(?P=first_char)*)', brackets_callback(String.Regex)),
|
2284
|
-
(r'(?:s|ss|tr)\s*(?::[\w\s:]+)?\s*/(?:\\\\|\\/|.)*?/(?:\\\\|\\/|.)*?/',
|
2285
|
-
String.Regex),
|
2286
|
-
(r'<[^\s=].*?\S>', String),
|
2287
|
-
(_build_word_match(PERL6_OPERATORS), Operator),
|
2288
|
-
(r'[0-9a-zA-Z_]' + PERL6_IDENTIFIER_RANGE + '*', Name),
|
2289
|
-
(r"'(\\\\|\\[^\\]|[^'\\])*'", String),
|
2290
|
-
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
2291
|
-
],
|
2292
|
-
'root' : [
|
2293
|
-
include('common'),
|
2294
|
-
(r'\{', opening_brace_callback),
|
2295
|
-
(r'\}', closing_brace_callback),
|
2296
|
-
(r'.+?', Text),
|
2297
|
-
],
|
2298
|
-
'pre-token' : [
|
2299
|
-
include('common'),
|
2300
|
-
(r'\{', Text, ('#pop', 'token')),
|
2301
|
-
(r'.+?', Text),
|
2302
|
-
],
|
2303
|
-
'token-sym-brackets' : [
|
2304
|
-
(r'(?P<delimiter>(?P<first_char>[' + ''.join(PERL6_BRACKETS) + '])(?P=first_char)*)', brackets_callback(Name), ('#pop', 'pre-token')),
|
2305
|
-
default(('#pop', 'pre-token')),
|
2306
|
-
],
|
2307
|
-
'token': [
|
2308
|
-
(r'}', Text, '#pop'),
|
2309
|
-
(r'(?<=:)(?:my|our|state|constant|temp|let).*?;', using(this)),
|
2310
|
-
# make sure that quotes in character classes aren't treated as strings
|
2311
|
-
(r'<(?:[-!?+.]\s*)?\[.*?\]>', String.Regex),
|
2312
|
-
# make sure that '#' characters in quotes aren't treated as comments
|
2313
|
-
(r"(?<!\\)'(\\\\|\\[^\\]|[^'\\])*'", String.Regex),
|
2314
|
-
(r'(?<!\\)"(\\\\|\\[^\\]|[^"\\])*"', String.Regex),
|
2315
|
-
(r'#.*?$', Comment.Singleline),
|
2316
|
-
(r'\{', embedded_perl6_callback),
|
2317
|
-
('.+?', String.Regex),
|
2318
|
-
],
|
2319
|
-
}
|
2320
|
-
|
2321
|
-
def analyse_text(text):
|
2322
|
-
def strip_pod(lines):
|
2323
|
-
in_pod = False
|
2324
|
-
stripped_lines = []
|
2325
|
-
|
2326
|
-
for line in lines:
|
2327
|
-
if re.match(r'^=(?:end|cut)', line):
|
2328
|
-
in_pod = False
|
2329
|
-
elif re.match(r'^=\w+', line):
|
2330
|
-
in_pod = True
|
2331
|
-
elif not in_pod:
|
2332
|
-
stripped_lines.append(line)
|
2333
|
-
|
2334
|
-
return stripped_lines
|
2335
|
-
|
2336
|
-
# XXX handle block comments
|
2337
|
-
lines = text.splitlines()
|
2338
|
-
lines = strip_pod(lines)
|
2339
|
-
text = '\n'.join(lines)
|
2340
|
-
|
2341
|
-
if shebang_matches(text, r'perl6|rakudo|niecza|pugs'):
|
2342
|
-
return True
|
2343
|
-
|
2344
|
-
saw_perl_decl = False
|
2345
|
-
rating = False
|
2346
|
-
|
2347
|
-
# check for my/our/has declarations
|
2348
|
-
if re.search("(?:my|our|has)\s+(?:" + Perl6Lexer.PERL6_IDENTIFIER_RANGE + \
|
2349
|
-
"+\s+)?[$@%&(]", text):
|
2350
|
-
rating = 0.8
|
2351
|
-
saw_perl_decl = True
|
2352
|
-
|
2353
|
-
for line in lines:
|
2354
|
-
line = re.sub('#.*', '', line)
|
2355
|
-
if re.match('^\s*$', line):
|
2356
|
-
continue
|
2357
|
-
|
2358
|
-
# match v6; use v6; use v6.0; use v6.0.0;
|
2359
|
-
if re.match('^\s*(?:use\s+)?v6(?:\.\d(?:\.\d)?)?;', line):
|
2360
|
-
return True
|
2361
|
-
# match class, module, role, enum, grammar declarations
|
2362
|
-
class_decl = re.match('^\s*(?:(?P<scope>my|our)\s+)?(?:module|class|role|enum|grammar)', line)
|
2363
|
-
if class_decl:
|
2364
|
-
if saw_perl_decl or class_decl.group('scope') is not None:
|
2365
|
-
return True
|
2366
|
-
rating = 0.05
|
2367
|
-
continue
|
2368
|
-
break
|
2369
|
-
|
2370
|
-
return rating
|
2371
|
-
|
2372
|
-
def __init__(self, **options):
|
2373
|
-
super(Perl6Lexer, self).__init__(**options)
|
2374
|
-
self.encoding = options.get('encoding', 'utf-8')
|
2375
|
-
|
2376
|
-
|
2377
|
-
class HyLexer(RegexLexer):
|
2378
|
-
"""
|
2379
|
-
Lexer for `Hy <http://hylang.org/>`_ source code.
|
2380
|
-
|
2381
|
-
.. versionadded:: 2.0
|
2382
|
-
"""
|
2383
|
-
name = 'Hy'
|
2384
|
-
aliases = ['hylang']
|
2385
|
-
filenames = ['*.hy']
|
2386
|
-
mimetypes = ['text/x-hy', 'application/x-hy']
|
2387
|
-
|
2388
|
-
special_forms = [
|
2389
|
-
'cond', 'for', '->', '->>', 'car',
|
2390
|
-
'cdr', 'first', 'rest', 'let', 'when', 'unless',
|
2391
|
-
'import', 'do', 'progn', 'get', 'slice', 'assoc', 'with-decorator',
|
2392
|
-
',', 'list_comp', 'kwapply', '~', 'is', 'in', 'is-not', 'not-in',
|
2393
|
-
'quasiquote', 'unquote', 'unquote-splice', 'quote', '|', '<<=', '>>=',
|
2394
|
-
'foreach', 'while',
|
2395
|
-
'eval-and-compile', 'eval-when-compile'
|
2396
|
-
]
|
2397
|
-
|
2398
|
-
declarations = [
|
2399
|
-
'def' 'defn', 'defun', 'defmacro', 'defclass', 'lambda', 'fn', 'setv'
|
2400
|
-
]
|
2401
|
-
|
2402
|
-
hy_builtins = []
|
2403
|
-
|
2404
|
-
hy_core = [
|
2405
|
-
'cycle', 'dec', 'distinct', 'drop', 'even?', 'filter', 'inc',
|
2406
|
-
'instance?', 'iterable?', 'iterate', 'iterator?', 'neg?',
|
2407
|
-
'none?', 'nth', 'numeric?', 'odd?', 'pos?', 'remove', 'repeat',
|
2408
|
-
'repeatedly', 'take', 'take_nth', 'take_while', 'zero?'
|
2409
|
-
]
|
2410
|
-
|
2411
|
-
builtins = hy_builtins + hy_core
|
2412
|
-
|
2413
|
-
# valid names for identifiers
|
2414
|
-
# well, names can only not consist fully of numbers
|
2415
|
-
# but this should be good enough for now
|
2416
|
-
valid_name = r'(?!#)[\w!$%*+<=>?/.#-]+'
|
2417
|
-
|
2418
|
-
def _multi_escape(entries):
|
2419
|
-
return '(%s)' % ('|'.join(re.escape(entry) + ' ' for entry in entries))
|
2420
|
-
|
2421
|
-
tokens = {
|
2422
|
-
'root': [
|
2423
|
-
# the comments - always starting with semicolon
|
2424
|
-
# and going to the end of the line
|
2425
|
-
(r';.*$', Comment.Single),
|
2426
|
-
|
2427
|
-
# whitespaces - usually not relevant
|
2428
|
-
(r'[,\s]+', Text),
|
2429
|
-
|
2430
|
-
# numbers
|
2431
|
-
(r'-?\d+\.\d+', Number.Float),
|
2432
|
-
(r'-?\d+', Number.Integer),
|
2433
|
-
(r'0[0-7]+j?', Number.Oct),
|
2434
|
-
(r'0[xX][a-fA-F0-9]+', Number.Hex),
|
2435
|
-
|
2436
|
-
# strings, symbols and characters
|
2437
|
-
(r'"(\\\\|\\"|[^"])*"', String),
|
2438
|
-
(r"'" + valid_name, String.Symbol),
|
2439
|
-
(r"\\(.|[a-z]+)", String.Char),
|
2440
|
-
(r'^(\s*)([rRuU]{,2}"""(?:.|\n)*?""")', bygroups(Text, String.Doc)),
|
2441
|
-
(r"^(\s*)([rRuU]{,2}'''(?:.|\n)*?''')", bygroups(Text, String.Doc)),
|
2442
|
-
|
2443
|
-
# keywords
|
2444
|
-
(r'::?' + valid_name, String.Symbol),
|
2445
|
-
|
2446
|
-
# special operators
|
2447
|
-
(r'~@|[`\'#^~&@]', Operator),
|
2448
|
-
|
2449
|
-
include('py-keywords'),
|
2450
|
-
include('py-builtins'),
|
2451
|
-
|
2452
|
-
# highlight the special forms
|
2453
|
-
(_multi_escape(special_forms), Keyword),
|
2454
|
-
|
2455
|
-
# Technically, only the special forms are 'keywords'. The problem
|
2456
|
-
# is that only treating them as keywords means that things like
|
2457
|
-
# 'defn' and 'ns' need to be highlighted as builtins. This is ugly
|
2458
|
-
# and weird for most styles. So, as a compromise we're going to
|
2459
|
-
# highlight them as Keyword.Declarations.
|
2460
|
-
(_multi_escape(declarations), Keyword.Declaration),
|
2461
|
-
|
2462
|
-
# highlight the builtins
|
2463
|
-
(_multi_escape(builtins), Name.Builtin),
|
2464
|
-
|
2465
|
-
# the remaining functions
|
2466
|
-
(r'(?<=\()' + valid_name, Name.Function),
|
2467
|
-
|
2468
|
-
# find the remaining variables
|
2469
|
-
(valid_name, Name.Variable),
|
2470
|
-
|
2471
|
-
# Hy accepts vector notation
|
2472
|
-
(r'(\[|\])', Punctuation),
|
2473
|
-
|
2474
|
-
# Hy accepts map notation
|
2475
|
-
(r'(\{|\})', Punctuation),
|
2476
|
-
|
2477
|
-
# the famous parentheses!
|
2478
|
-
(r'(\(|\))', Punctuation),
|
2479
|
-
|
2480
|
-
],
|
2481
|
-
'py-keywords': PythonLexer.tokens['keywords'],
|
2482
|
-
'py-builtins': PythonLexer.tokens['builtins'],
|
2483
|
-
}
|
2484
|
-
|
2485
|
-
def analyse_text(text):
|
2486
|
-
if '(import ' in text or '(defn ' in text:
|
2487
|
-
return 0.9
|
2488
|
-
|
2489
|
-
|
2490
|
-
class ChaiscriptLexer(RegexLexer):
|
2491
|
-
"""
|
2492
|
-
For `ChaiScript <http://chaiscript.com/>`_ source code.
|
2493
|
-
|
2494
|
-
.. versionadded:: 2.0
|
2495
|
-
"""
|
2496
|
-
|
2497
|
-
name = 'ChaiScript'
|
2498
|
-
aliases = ['chai', 'chaiscript']
|
2499
|
-
filenames = ['*.chai']
|
2500
|
-
mimetypes = ['text/x-chaiscript', 'application/x-chaiscript']
|
2501
|
-
|
2502
|
-
flags = re.DOTALL
|
2503
|
-
tokens = {
|
2504
|
-
'commentsandwhitespace': [
|
2505
|
-
(r'\s+', Text),
|
2506
|
-
(r'//.*?\n', Comment.Single),
|
2507
|
-
(r'/\*.*?\*/', Comment.Multiline),
|
2508
|
-
(r'^\#.*?\n', Comment.Single)
|
2509
|
-
],
|
2510
|
-
'slashstartsregex': [
|
2511
|
-
include('commentsandwhitespace'),
|
2512
|
-
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
2513
|
-
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
2514
|
-
(r'(?=/)', Text, ('#pop', 'badregex')),
|
2515
|
-
default('#pop')
|
2516
|
-
],
|
2517
|
-
'badregex': [
|
2518
|
-
('\n', Text, '#pop')
|
2519
|
-
],
|
2520
|
-
'root': [
|
2521
|
-
include('commentsandwhitespace'),
|
2522
|
-
(r'\n', Text),
|
2523
|
-
(r'[^\S\n]+', Text),
|
2524
|
-
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|\.\.'
|
2525
|
-
r'(<<|>>>?|==?|!=?|[-<>+*%&\|\^/])=?', Operator, 'slashstartsregex'),
|
2526
|
-
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
2527
|
-
(r'[})\].]', Punctuation),
|
2528
|
-
(r'[=+\-*/]', Operator),
|
2529
|
-
(r'(for|in|while|do|break|return|continue|if|else|'
|
2530
|
-
r'throw|try|catch'
|
2531
|
-
r')\b', Keyword, 'slashstartsregex'),
|
2532
|
-
(r'(var)\b', Keyword.Declaration, 'slashstartsregex'),
|
2533
|
-
(r'(attr|def|fun)\b', Keyword.Reserved),
|
2534
|
-
(r'(true|false)\b', Keyword.Constant),
|
2535
|
-
(r'(eval|throw)\b', Name.Builtin),
|
2536
|
-
(r'`\S+`', Name.Builtin),
|
2537
|
-
(r'[$a-zA-Z_]\w*', Name.Other),
|
2538
|
-
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
2539
|
-
(r'0x[0-9a-fA-F]+', Number.Hex),
|
2540
|
-
(r'[0-9]+', Number.Integer),
|
2541
|
-
(r'"', String.Double, 'dqstring'),
|
2542
|
-
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
2543
|
-
],
|
2544
|
-
'dqstring': [
|
2545
|
-
(r'\${[^"}]+?}', String.Iterpol),
|
2546
|
-
(r'\$', String.Double),
|
2547
|
-
(r'\\\\', String.Double),
|
2548
|
-
(r'\\"', String.Double),
|
2549
|
-
(r'[^\\\\\\"$]+', String.Double),
|
2550
|
-
(r'"', String.Double, '#pop'),
|
2551
|
-
],
|
2552
|
-
}
|
14
|
+
from pygments.lexers.python import PythonLexer, PythonConsoleLexer, \
|
15
|
+
PythonTracebackLexer, Python3Lexer, Python3TracebackLexer, DgLexer
|
16
|
+
from pygments.lexers.ruby import RubyLexer, RubyConsoleLexer, FancyLexer
|
17
|
+
from pygments.lexers.perl import PerlLexer, Perl6Lexer
|
18
|
+
from pygments.lexers.d import CrocLexer, MiniDLexer
|
19
|
+
from pygments.lexers.iolang import IoLexer
|
20
|
+
from pygments.lexers.tcl import TclLexer
|
21
|
+
from pygments.lexers.factor import FactorLexer
|
22
|
+
from pygments.lexers.scripting import LuaLexer, MoonScriptLexer
|
23
|
+
|
24
|
+
__all__ = []
|