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,199 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.pawn
|
4
|
+
~~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexers for the Pawn languages.
|
7
|
+
|
8
|
+
:copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
|
9
|
+
:license: BSD, see LICENSE for details.
|
10
|
+
"""
|
11
|
+
|
12
|
+
from pygments.lexer import RegexLexer
|
13
|
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
14
|
+
Number, Punctuation, Error
|
15
|
+
from pygments.util import get_bool_opt
|
16
|
+
|
17
|
+
__all__ = ['SourcePawnLexer', 'PawnLexer']
|
18
|
+
|
19
|
+
|
20
|
+
class SourcePawnLexer(RegexLexer):
|
21
|
+
"""
|
22
|
+
For SourcePawn source code with preprocessor directives.
|
23
|
+
|
24
|
+
.. versionadded:: 1.6
|
25
|
+
"""
|
26
|
+
name = 'SourcePawn'
|
27
|
+
aliases = ['sp']
|
28
|
+
filenames = ['*.sp']
|
29
|
+
mimetypes = ['text/x-sourcepawn']
|
30
|
+
|
31
|
+
#: optional Comment or Whitespace
|
32
|
+
_ws = r'(?:\s|//.*?\n|/\*.*?\*/)+'
|
33
|
+
#: only one /* */ style comment
|
34
|
+
_ws1 = r'\s*(?:/[*].*?[*]/\s*)*'
|
35
|
+
|
36
|
+
tokens = {
|
37
|
+
'root': [
|
38
|
+
# preprocessor directives: without whitespace
|
39
|
+
('^#if\s+0', Comment.Preproc, 'if0'),
|
40
|
+
('^#', Comment.Preproc, 'macro'),
|
41
|
+
# or with whitespace
|
42
|
+
('^' + _ws1 + r'#if\s+0', Comment.Preproc, 'if0'),
|
43
|
+
('^' + _ws1 + '#', Comment.Preproc, 'macro'),
|
44
|
+
(r'\n', Text),
|
45
|
+
(r'\s+', Text),
|
46
|
+
(r'\\\n', Text), # line continuation
|
47
|
+
(r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
|
48
|
+
(r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment.Multiline),
|
49
|
+
(r'[{}]', Punctuation),
|
50
|
+
(r'L?"', String, 'string'),
|
51
|
+
(r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
|
52
|
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
|
53
|
+
(r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
54
|
+
(r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
|
55
|
+
(r'0[0-7]+[LlUu]*', Number.Oct),
|
56
|
+
(r'\d+[LlUu]*', Number.Integer),
|
57
|
+
(r'\*/', Error),
|
58
|
+
(r'[~!%^&*+=|?:<>/-]', Operator),
|
59
|
+
(r'[()\[\],.;]', Punctuation),
|
60
|
+
(r'(case|const|continue|native|'
|
61
|
+
r'default|else|enum|for|if|new|operator|'
|
62
|
+
r'public|return|sizeof|static|decl|struct|switch)\b', Keyword),
|
63
|
+
(r'(bool|Float)\b', Keyword.Type),
|
64
|
+
(r'(true|false)\b', Keyword.Constant),
|
65
|
+
('[a-zA-Z_]\w*', Name),
|
66
|
+
],
|
67
|
+
'string': [
|
68
|
+
(r'"', String, '#pop'),
|
69
|
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
|
70
|
+
(r'[^\\"\n]+', String), # all other characters
|
71
|
+
(r'\\\n', String), # line continuation
|
72
|
+
(r'\\', String), # stray backslash
|
73
|
+
],
|
74
|
+
'macro': [
|
75
|
+
(r'[^/\n]+', Comment.Preproc),
|
76
|
+
(r'/\*(.|\n)*?\*/', Comment.Multiline),
|
77
|
+
(r'//.*?\n', Comment.Single, '#pop'),
|
78
|
+
(r'/', Comment.Preproc),
|
79
|
+
(r'(?<=\\)\n', Comment.Preproc),
|
80
|
+
(r'\n', Comment.Preproc, '#pop'),
|
81
|
+
],
|
82
|
+
'if0': [
|
83
|
+
(r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
|
84
|
+
(r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
|
85
|
+
(r'.*?\n', Comment),
|
86
|
+
]
|
87
|
+
}
|
88
|
+
|
89
|
+
SM_TYPES = set(('Action', 'bool', 'Float', 'Plugin', 'String', 'any',
|
90
|
+
'AdminFlag', 'OverrideType', 'OverrideRule', 'ImmunityType',
|
91
|
+
'GroupId', 'AdminId', 'AdmAccessMode', 'AdminCachePart',
|
92
|
+
'CookieAccess', 'CookieMenu', 'CookieMenuAction', 'NetFlow',
|
93
|
+
'ConVarBounds', 'QueryCookie', 'ReplySource',
|
94
|
+
'ConVarQueryResult', 'ConVarQueryFinished', 'Function',
|
95
|
+
'Action', 'Identity', 'PluginStatus', 'PluginInfo', 'DBResult',
|
96
|
+
'DBBindType', 'DBPriority', 'PropType', 'PropFieldType',
|
97
|
+
'MoveType', 'RenderMode', 'RenderFx', 'EventHookMode',
|
98
|
+
'EventHook', 'FileType', 'FileTimeMode', 'PathType',
|
99
|
+
'ParamType', 'ExecType', 'DialogType', 'Handle', 'KvDataTypes',
|
100
|
+
'NominateResult', 'MapChange', 'MenuStyle', 'MenuAction',
|
101
|
+
'MenuSource', 'RegexError', 'SDKCallType', 'SDKLibrary',
|
102
|
+
'SDKFuncConfSource', 'SDKType', 'SDKPassMethod', 'RayType',
|
103
|
+
'TraceEntityFilter', 'ListenOverride', 'SortOrder', 'SortType',
|
104
|
+
'SortFunc2D', 'APLRes', 'FeatureType', 'FeatureStatus',
|
105
|
+
'SMCResult', 'SMCError', 'TFClassType', 'TFTeam', 'TFCond',
|
106
|
+
'TFResourceType', 'Timer', 'TopMenuAction', 'TopMenuObjectType',
|
107
|
+
'TopMenuPosition', 'TopMenuObject', 'UserMsg'))
|
108
|
+
|
109
|
+
def __init__(self, **options):
|
110
|
+
self.smhighlighting = get_bool_opt(options,
|
111
|
+
'sourcemod', True)
|
112
|
+
|
113
|
+
self._functions = set()
|
114
|
+
if self.smhighlighting:
|
115
|
+
from pygments.lexers._sourcemod_builtins import FUNCTIONS
|
116
|
+
self._functions.update(FUNCTIONS)
|
117
|
+
RegexLexer.__init__(self, **options)
|
118
|
+
|
119
|
+
def get_tokens_unprocessed(self, text):
|
120
|
+
for index, token, value in \
|
121
|
+
RegexLexer.get_tokens_unprocessed(self, text):
|
122
|
+
if token is Name:
|
123
|
+
if self.smhighlighting:
|
124
|
+
if value in self.SM_TYPES:
|
125
|
+
token = Keyword.Type
|
126
|
+
elif value in self._functions:
|
127
|
+
token = Name.Builtin
|
128
|
+
yield index, token, value
|
129
|
+
|
130
|
+
|
131
|
+
class PawnLexer(RegexLexer):
|
132
|
+
"""
|
133
|
+
For Pawn source code.
|
134
|
+
|
135
|
+
.. versionadded:: 2.0
|
136
|
+
"""
|
137
|
+
|
138
|
+
name = 'Pawn'
|
139
|
+
aliases = ['pawn']
|
140
|
+
filenames = ['*.p', '*.pwn', '*.inc']
|
141
|
+
mimetypes = ['text/x-pawn']
|
142
|
+
|
143
|
+
#: optional Comment or Whitespace
|
144
|
+
_ws = r'(?:\s|//.*?\n|/[*][\w\W]*?[*]/)+'
|
145
|
+
#: only one /* */ style comment
|
146
|
+
_ws1 = r'\s*(?:/[*].*?[*]/\s*)*'
|
147
|
+
|
148
|
+
tokens = {
|
149
|
+
'root': [
|
150
|
+
# preprocessor directives: without whitespace
|
151
|
+
('^#if\s+0', Comment.Preproc, 'if0'),
|
152
|
+
('^#', Comment.Preproc, 'macro'),
|
153
|
+
# or with whitespace
|
154
|
+
('^' + _ws1 + r'#if\s+0', Comment.Preproc, 'if0'),
|
155
|
+
('^' + _ws1 + '#', Comment.Preproc, 'macro'),
|
156
|
+
(r'\n', Text),
|
157
|
+
(r'\s+', Text),
|
158
|
+
(r'\\\n', Text), # line continuation
|
159
|
+
(r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
|
160
|
+
(r'/(\\\n)?\*[\w\W]*?\*(\\\n)?/', Comment.Multiline),
|
161
|
+
(r'[{}]', Punctuation),
|
162
|
+
(r'L?"', String, 'string'),
|
163
|
+
(r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
|
164
|
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
|
165
|
+
(r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
166
|
+
(r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
|
167
|
+
(r'0[0-7]+[LlUu]*', Number.Oct),
|
168
|
+
(r'\d+[LlUu]*', Number.Integer),
|
169
|
+
(r'\*/', Error),
|
170
|
+
(r'[~!%^&*+=|?:<>/-]', Operator),
|
171
|
+
(r'[()\[\],.;]', Punctuation),
|
172
|
+
(r'(switch|case|default|const|new|static|char|continue|break|'
|
173
|
+
r'if|else|for|while|do|operator|enum|'
|
174
|
+
r'public|return|sizeof|tagof|state|goto)\b', Keyword),
|
175
|
+
(r'(bool|Float)\b', Keyword.Type),
|
176
|
+
(r'(true|false)\b', Keyword.Constant),
|
177
|
+
('[a-zA-Z_]\w*', Name),
|
178
|
+
],
|
179
|
+
'string': [
|
180
|
+
(r'"', String, '#pop'),
|
181
|
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
|
182
|
+
(r'[^\\"\n]+', String), # all other characters
|
183
|
+
(r'\\\n', String), # line continuation
|
184
|
+
(r'\\', String), # stray backslash
|
185
|
+
],
|
186
|
+
'macro': [
|
187
|
+
(r'[^/\n]+', Comment.Preproc),
|
188
|
+
(r'/\*(.|\n)*?\*/', Comment.Multiline),
|
189
|
+
(r'//.*?\n', Comment.Single, '#pop'),
|
190
|
+
(r'/', Comment.Preproc),
|
191
|
+
(r'(?<=\\)\n', Comment.Preproc),
|
192
|
+
(r'\n', Comment.Preproc, '#pop'),
|
193
|
+
],
|
194
|
+
'if0': [
|
195
|
+
(r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
|
196
|
+
(r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
|
197
|
+
(r'.*?\n', Comment),
|
198
|
+
]
|
199
|
+
}
|
@@ -0,0 +1,616 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.perl
|
4
|
+
~~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexers for Perl and related languages.
|
7
|
+
|
8
|
+
:copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
|
9
|
+
:license: BSD, see LICENSE for details.
|
10
|
+
"""
|
11
|
+
|
12
|
+
import re
|
13
|
+
|
14
|
+
from pygments.lexer import RegexLexer, ExtendedRegexLexer, include, bygroups, \
|
15
|
+
using, this, default, words
|
16
|
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
17
|
+
Number, Punctuation
|
18
|
+
from pygments.util import shebang_matches
|
19
|
+
|
20
|
+
__all__ = ['PerlLexer', 'Perl6Lexer']
|
21
|
+
|
22
|
+
|
23
|
+
class PerlLexer(RegexLexer):
|
24
|
+
"""
|
25
|
+
For `Perl <http://www.perl.org>`_ source code.
|
26
|
+
"""
|
27
|
+
|
28
|
+
name = 'Perl'
|
29
|
+
aliases = ['perl', 'pl']
|
30
|
+
filenames = ['*.pl', '*.pm', '*.t']
|
31
|
+
mimetypes = ['text/x-perl', 'application/x-perl']
|
32
|
+
|
33
|
+
flags = re.DOTALL | re.MULTILINE
|
34
|
+
# TODO: give this to a perl guy who knows how to parse perl...
|
35
|
+
tokens = {
|
36
|
+
'balanced-regex': [
|
37
|
+
(r'/(\\\\|\\[^\\]|[^\\/])*/[egimosx]*', String.Regex, '#pop'),
|
38
|
+
(r'!(\\\\|\\[^\\]|[^\\!])*![egimosx]*', String.Regex, '#pop'),
|
39
|
+
(r'\\(\\\\|[^\\])*\\[egimosx]*', String.Regex, '#pop'),
|
40
|
+
(r'\{(\\\\|\\[^\\]|[^\\}])*\}[egimosx]*', String.Regex, '#pop'),
|
41
|
+
(r'<(\\\\|\\[^\\]|[^\\>])*>[egimosx]*', String.Regex, '#pop'),
|
42
|
+
(r'\[(\\\\|\\[^\\]|[^\\\]])*\][egimosx]*', String.Regex, '#pop'),
|
43
|
+
(r'\((\\\\|\\[^\\]|[^\\)])*\)[egimosx]*', String.Regex, '#pop'),
|
44
|
+
(r'@(\\\\|\\[^\\]|[^\\@])*@[egimosx]*', String.Regex, '#pop'),
|
45
|
+
(r'%(\\\\|\\[^\\]|[^\\%])*%[egimosx]*', String.Regex, '#pop'),
|
46
|
+
(r'\$(\\\\|\\[^\\]|[^\\$])*\$[egimosx]*', String.Regex, '#pop'),
|
47
|
+
],
|
48
|
+
'root': [
|
49
|
+
(r'\A\#!.+?$', Comment.Hashbang),
|
50
|
+
(r'\#.*?$', Comment.Single),
|
51
|
+
(r'^=[a-zA-Z0-9]+\s+.*?\n=cut', Comment.Multiline),
|
52
|
+
(words((
|
53
|
+
'case', 'continue', 'do', 'else', 'elsif', 'for', 'foreach',
|
54
|
+
'if', 'last', 'my', 'next', 'our', 'redo', 'reset', 'then',
|
55
|
+
'unless', 'until', 'while', 'use', 'print', 'new', 'BEGIN',
|
56
|
+
'CHECK', 'INIT', 'END', 'return'), suffix=r'\b'),
|
57
|
+
Keyword),
|
58
|
+
(r'(format)(\s+)(\w+)(\s*)(=)(\s*\n)',
|
59
|
+
bygroups(Keyword, Text, Name, Text, Punctuation, Text), 'format'),
|
60
|
+
(r'(eq|lt|gt|le|ge|ne|not|and|or|cmp)\b', Operator.Word),
|
61
|
+
# common delimiters
|
62
|
+
(r's/(\\\\|\\[^\\]|[^\\/])*/(\\\\|\\[^\\]|[^\\/])*/[egimosx]*',
|
63
|
+
String.Regex),
|
64
|
+
(r's!(\\\\|\\!|[^!])*!(\\\\|\\!|[^!])*![egimosx]*', String.Regex),
|
65
|
+
(r's\\(\\\\|[^\\])*\\(\\\\|[^\\])*\\[egimosx]*', String.Regex),
|
66
|
+
(r's@(\\\\|\\[^\\]|[^\\@])*@(\\\\|\\[^\\]|[^\\@])*@[egimosx]*',
|
67
|
+
String.Regex),
|
68
|
+
(r's%(\\\\|\\[^\\]|[^\\%])*%(\\\\|\\[^\\]|[^\\%])*%[egimosx]*',
|
69
|
+
String.Regex),
|
70
|
+
# balanced delimiters
|
71
|
+
(r's\{(\\\\|\\[^\\]|[^\\}])*\}\s*', String.Regex, 'balanced-regex'),
|
72
|
+
(r's<(\\\\|\\[^\\]|[^\\>])*>\s*', String.Regex, 'balanced-regex'),
|
73
|
+
(r's\[(\\\\|\\[^\\]|[^\\\]])*\]\s*', String.Regex,
|
74
|
+
'balanced-regex'),
|
75
|
+
(r's\((\\\\|\\[^\\]|[^\\)])*\)\s*', String.Regex,
|
76
|
+
'balanced-regex'),
|
77
|
+
|
78
|
+
(r'm?/(\\\\|\\[^\\]|[^\\/\n])*/[gcimosx]*', String.Regex),
|
79
|
+
(r'm(?=[/!\\{<\[(@%$])', String.Regex, 'balanced-regex'),
|
80
|
+
(r'((?<==~)|(?<=\())\s*/(\\\\|\\[^\\]|[^\\/])*/[gcimosx]*',
|
81
|
+
String.Regex),
|
82
|
+
(r'\s+', Text),
|
83
|
+
(words((
|
84
|
+
'abs', 'accept', 'alarm', 'atan2', 'bind', 'binmode', 'bless', 'caller', 'chdir',
|
85
|
+
'chmod', 'chomp', 'chop', 'chown', 'chr', 'chroot', 'close', 'closedir', 'connect',
|
86
|
+
'continue', 'cos', 'crypt', 'dbmclose', 'dbmopen', 'defined', 'delete', 'die',
|
87
|
+
'dump', 'each', 'endgrent', 'endhostent', 'endnetent', 'endprotoent',
|
88
|
+
'endpwent', 'endservent', 'eof', 'eval', 'exec', 'exists', 'exit', 'exp', 'fcntl',
|
89
|
+
'fileno', 'flock', 'fork', 'format', 'formline', 'getc', 'getgrent', 'getgrgid',
|
90
|
+
'getgrnam', 'gethostbyaddr', 'gethostbyname', 'gethostent', 'getlogin',
|
91
|
+
'getnetbyaddr', 'getnetbyname', 'getnetent', 'getpeername', 'getpgrp',
|
92
|
+
'getppid', 'getpriority', 'getprotobyname', 'getprotobynumber',
|
93
|
+
'getprotoent', 'getpwent', 'getpwnam', 'getpwuid', 'getservbyname',
|
94
|
+
'getservbyport', 'getservent', 'getsockname', 'getsockopt', 'glob', 'gmtime',
|
95
|
+
'goto', 'grep', 'hex', 'import', 'index', 'int', 'ioctl', 'join', 'keys', 'kill', 'last',
|
96
|
+
'lc', 'lcfirst', 'length', 'link', 'listen', 'local', 'localtime', 'log', 'lstat',
|
97
|
+
'map', 'mkdir', 'msgctl', 'msgget', 'msgrcv', 'msgsnd', 'my', 'next', 'no', 'oct', 'open',
|
98
|
+
'opendir', 'ord', 'our', 'pack', 'package', 'pipe', 'pop', 'pos', 'printf',
|
99
|
+
'prototype', 'push', 'quotemeta', 'rand', 'read', 'readdir',
|
100
|
+
'readline', 'readlink', 'readpipe', 'recv', 'redo', 'ref', 'rename', 'require',
|
101
|
+
'reverse', 'rewinddir', 'rindex', 'rmdir', 'scalar', 'seek', 'seekdir',
|
102
|
+
'select', 'semctl', 'semget', 'semop', 'send', 'setgrent', 'sethostent', 'setnetent',
|
103
|
+
'setpgrp', 'setpriority', 'setprotoent', 'setpwent', 'setservent',
|
104
|
+
'setsockopt', 'shift', 'shmctl', 'shmget', 'shmread', 'shmwrite', 'shutdown',
|
105
|
+
'sin', 'sleep', 'socket', 'socketpair', 'sort', 'splice', 'split', 'sprintf', 'sqrt',
|
106
|
+
'srand', 'stat', 'study', 'substr', 'symlink', 'syscall', 'sysopen', 'sysread',
|
107
|
+
'sysseek', 'system', 'syswrite', 'tell', 'telldir', 'tie', 'tied', 'time', 'times', 'tr',
|
108
|
+
'truncate', 'uc', 'ucfirst', 'umask', 'undef', 'unlink', 'unpack', 'unshift', 'untie',
|
109
|
+
'utime', 'values', 'vec', 'wait', 'waitpid', 'wantarray', 'warn', 'write'), suffix=r'\b'),
|
110
|
+
Name.Builtin),
|
111
|
+
(r'((__(DATA|DIE|WARN)__)|(STD(IN|OUT|ERR)))\b', Name.Builtin.Pseudo),
|
112
|
+
(r'(<<)([\'"]?)([a-zA-Z_]\w*)(\2;?\n.*?\n)(\3)(\n)',
|
113
|
+
bygroups(String, String, String.Delimiter, String, String.Delimiter, Text)),
|
114
|
+
(r'__END__', Comment.Preproc, 'end-part'),
|
115
|
+
(r'\$\^[ADEFHILMOPSTWX]', Name.Variable.Global),
|
116
|
+
(r"\$[\\\"\[\]'&`+*.,;=%~?@$!<>(^|/-](?!\w)", Name.Variable.Global),
|
117
|
+
(r'[$@%#]+', Name.Variable, 'varname'),
|
118
|
+
(r'0_?[0-7]+(_[0-7]+)*', Number.Oct),
|
119
|
+
(r'0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*', Number.Hex),
|
120
|
+
(r'0b[01]+(_[01]+)*', Number.Bin),
|
121
|
+
(r'(?i)(\d*(_\d*)*\.\d+(_\d*)*|\d+(_\d*)*\.\d+(_\d*)*)(e[+-]?\d+)?',
|
122
|
+
Number.Float),
|
123
|
+
(r'(?i)\d+(_\d*)*e[+-]?\d+(_\d*)*', Number.Float),
|
124
|
+
(r'\d+(_\d+)*', Number.Integer),
|
125
|
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String),
|
126
|
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
127
|
+
(r'`(\\\\|\\[^\\]|[^`\\])*`', String.Backtick),
|
128
|
+
(r'<([^\s>]+)>', String.Regex),
|
129
|
+
(r'(q|qq|qw|qr|qx)\{', String.Other, 'cb-string'),
|
130
|
+
(r'(q|qq|qw|qr|qx)\(', String.Other, 'rb-string'),
|
131
|
+
(r'(q|qq|qw|qr|qx)\[', String.Other, 'sb-string'),
|
132
|
+
(r'(q|qq|qw|qr|qx)\<', String.Other, 'lt-string'),
|
133
|
+
(r'(q|qq|qw|qr|qx)([\W_])(.|\n)*?\2', String.Other),
|
134
|
+
(r'package\s+', Keyword, 'modulename'),
|
135
|
+
(r'sub\s+', Keyword, 'funcname'),
|
136
|
+
(r'(\[\]|\*\*|::|<<|>>|>=|<=>|<=|={3}|!=|=~|'
|
137
|
+
r'!~|&&?|\|\||\.{1,3})', Operator),
|
138
|
+
(r'[-+/*%=<>&^|!\\~]=?', Operator),
|
139
|
+
(r'[()\[\]:;,<>/?{}]', Punctuation), # yes, there's no shortage
|
140
|
+
# of punctuation in Perl!
|
141
|
+
(r'(?=\w)', Name, 'name'),
|
142
|
+
],
|
143
|
+
'format': [
|
144
|
+
(r'\.\n', String.Interpol, '#pop'),
|
145
|
+
(r'[^\n]*\n', String.Interpol),
|
146
|
+
],
|
147
|
+
'varname': [
|
148
|
+
(r'\s+', Text),
|
149
|
+
(r'\{', Punctuation, '#pop'), # hash syntax?
|
150
|
+
(r'\)|,', Punctuation, '#pop'), # argument specifier
|
151
|
+
(r'\w+::', Name.Namespace),
|
152
|
+
(r'[\w:]+', Name.Variable, '#pop'),
|
153
|
+
],
|
154
|
+
'name': [
|
155
|
+
(r'\w+::', Name.Namespace),
|
156
|
+
(r'[\w:]+', Name, '#pop'),
|
157
|
+
(r'[A-Z_]+(?=\W)', Name.Constant, '#pop'),
|
158
|
+
(r'(?=\W)', Text, '#pop'),
|
159
|
+
],
|
160
|
+
'modulename': [
|
161
|
+
(r'[a-zA-Z_]\w*', Name.Namespace, '#pop')
|
162
|
+
],
|
163
|
+
'funcname': [
|
164
|
+
(r'[a-zA-Z_]\w*[!?]?', Name.Function),
|
165
|
+
(r'\s+', Text),
|
166
|
+
# argument declaration
|
167
|
+
(r'(\([$@%]*\))(\s*)', bygroups(Punctuation, Text)),
|
168
|
+
(r';', Punctuation, '#pop'),
|
169
|
+
(r'.*?\{', Punctuation, '#pop'),
|
170
|
+
],
|
171
|
+
'cb-string': [
|
172
|
+
(r'\\[{}\\]', String.Other),
|
173
|
+
(r'\\', String.Other),
|
174
|
+
(r'\{', String.Other, 'cb-string'),
|
175
|
+
(r'\}', String.Other, '#pop'),
|
176
|
+
(r'[^{}\\]+', String.Other)
|
177
|
+
],
|
178
|
+
'rb-string': [
|
179
|
+
(r'\\[()\\]', String.Other),
|
180
|
+
(r'\\', String.Other),
|
181
|
+
(r'\(', String.Other, 'rb-string'),
|
182
|
+
(r'\)', String.Other, '#pop'),
|
183
|
+
(r'[^()]+', String.Other)
|
184
|
+
],
|
185
|
+
'sb-string': [
|
186
|
+
(r'\\[\[\]\\]', String.Other),
|
187
|
+
(r'\\', String.Other),
|
188
|
+
(r'\[', String.Other, 'sb-string'),
|
189
|
+
(r'\]', String.Other, '#pop'),
|
190
|
+
(r'[^\[\]]+', String.Other)
|
191
|
+
],
|
192
|
+
'lt-string': [
|
193
|
+
(r'\\[<>\\]', String.Other),
|
194
|
+
(r'\\', String.Other),
|
195
|
+
(r'\<', String.Other, 'lt-string'),
|
196
|
+
(r'\>', String.Other, '#pop'),
|
197
|
+
(r'[^<>]+', String.Other)
|
198
|
+
],
|
199
|
+
'end-part': [
|
200
|
+
(r'.+', Comment.Preproc, '#pop')
|
201
|
+
]
|
202
|
+
}
|
203
|
+
|
204
|
+
def analyse_text(text):
|
205
|
+
if shebang_matches(text, r'perl'):
|
206
|
+
return True
|
207
|
+
if re.search('(?:my|our)\s+[$@%(]', text):
|
208
|
+
return 0.9
|
209
|
+
|
210
|
+
|
211
|
+
class Perl6Lexer(ExtendedRegexLexer):
|
212
|
+
"""
|
213
|
+
For `Perl 6 <http://www.perl6.org>`_ source code.
|
214
|
+
|
215
|
+
.. versionadded:: 2.0
|
216
|
+
"""
|
217
|
+
|
218
|
+
name = 'Perl6'
|
219
|
+
aliases = ['perl6', 'pl6']
|
220
|
+
filenames = ['*.pl', '*.pm', '*.nqp', '*.p6', '*.6pl', '*.p6l', '*.pl6',
|
221
|
+
'*.6pm', '*.p6m', '*.pm6', '*.t']
|
222
|
+
mimetypes = ['text/x-perl6', 'application/x-perl6']
|
223
|
+
flags = re.MULTILINE | re.DOTALL | re.UNICODE
|
224
|
+
|
225
|
+
PERL6_IDENTIFIER_RANGE = "['\w:-]"
|
226
|
+
|
227
|
+
PERL6_KEYWORDS = (
|
228
|
+
'BEGIN', 'CATCH', 'CHECK', 'CONTROL', 'END', 'ENTER', 'FIRST', 'INIT',
|
229
|
+
'KEEP', 'LAST', 'LEAVE', 'NEXT', 'POST', 'PRE', 'START', 'TEMP',
|
230
|
+
'UNDO', 'as', 'assoc', 'async', 'augment', 'binary', 'break', 'but',
|
231
|
+
'cached', 'category', 'class', 'constant', 'contend', 'continue',
|
232
|
+
'copy', 'deep', 'default', 'defequiv', 'defer', 'die', 'do', 'else',
|
233
|
+
'elsif', 'enum', 'equiv', 'exit', 'export', 'fail', 'fatal', 'for',
|
234
|
+
'gather', 'given', 'goto', 'grammar', 'handles', 'has', 'if', 'inline',
|
235
|
+
'irs', 'is', 'last', 'leave', 'let', 'lift', 'loop', 'looser', 'macro',
|
236
|
+
'make', 'maybe', 'method', 'module', 'multi', 'my', 'next', 'of',
|
237
|
+
'ofs', 'only', 'oo', 'ors', 'our', 'package', 'parsed', 'prec',
|
238
|
+
'proto', 'readonly', 'redo', 'ref', 'regex', 'reparsed', 'repeat',
|
239
|
+
'require', 'required', 'return', 'returns', 'role', 'rule', 'rw',
|
240
|
+
'self', 'slang', 'state', 'sub', 'submethod', 'subset', 'supersede',
|
241
|
+
'take', 'temp', 'tighter', 'token', 'trusts', 'try', 'unary',
|
242
|
+
'unless', 'until', 'use', 'warn', 'when', 'where', 'while', 'will',
|
243
|
+
)
|
244
|
+
|
245
|
+
PERL6_BUILTINS = (
|
246
|
+
'ACCEPTS', 'HOW', 'REJECTS', 'VAR', 'WHAT', 'WHENCE', 'WHERE', 'WHICH',
|
247
|
+
'WHO', 'abs', 'acos', 'acosec', 'acosech', 'acosh', 'acotan', 'acotanh',
|
248
|
+
'all', 'any', 'approx', 'arity', 'asec', 'asech', 'asin', 'asinh',
|
249
|
+
'assuming', 'atan', 'atan2', 'atanh', 'attr', 'bless', 'body', 'by',
|
250
|
+
'bytes', 'caller', 'callsame', 'callwith', 'can', 'capitalize', 'cat',
|
251
|
+
'ceiling', 'chars', 'chmod', 'chomp', 'chop', 'chr', 'chroot',
|
252
|
+
'circumfix', 'cis', 'classify', 'clone', 'close', 'cmp_ok', 'codes',
|
253
|
+
'comb', 'connect', 'contains', 'context', 'cos', 'cosec', 'cosech',
|
254
|
+
'cosh', 'cotan', 'cotanh', 'count', 'defined', 'delete', 'diag',
|
255
|
+
'dies_ok', 'does', 'e', 'each', 'eager', 'elems', 'end', 'eof', 'eval',
|
256
|
+
'eval_dies_ok', 'eval_elsewhere', 'eval_lives_ok', 'evalfile', 'exists',
|
257
|
+
'exp', 'first', 'flip', 'floor', 'flunk', 'flush', 'fmt', 'force_todo',
|
258
|
+
'fork', 'from', 'getc', 'gethost', 'getlogin', 'getpeername', 'getpw',
|
259
|
+
'gmtime', 'graphs', 'grep', 'hints', 'hyper', 'im', 'index', 'infix',
|
260
|
+
'invert', 'is_approx', 'is_deeply', 'isa', 'isa_ok', 'isnt', 'iterator',
|
261
|
+
'join', 'key', 'keys', 'kill', 'kv', 'lastcall', 'lazy', 'lc', 'lcfirst',
|
262
|
+
'like', 'lines', 'link', 'lives_ok', 'localtime', 'log', 'log10', 'map',
|
263
|
+
'max', 'min', 'minmax', 'name', 'new', 'nextsame', 'nextwith', 'nfc',
|
264
|
+
'nfd', 'nfkc', 'nfkd', 'nok_error', 'nonce', 'none', 'normalize', 'not',
|
265
|
+
'nothing', 'ok', 'once', 'one', 'open', 'opendir', 'operator', 'ord',
|
266
|
+
'p5chomp', 'p5chop', 'pack', 'pair', 'pairs', 'pass', 'perl', 'pi',
|
267
|
+
'pick', 'plan', 'plan_ok', 'polar', 'pop', 'pos', 'postcircumfix',
|
268
|
+
'postfix', 'pred', 'prefix', 'print', 'printf', 'push', 'quasi',
|
269
|
+
'quotemeta', 'rand', 're', 'read', 'readdir', 'readline', 'reduce',
|
270
|
+
'reverse', 'rewind', 'rewinddir', 'rindex', 'roots', 'round',
|
271
|
+
'roundrobin', 'run', 'runinstead', 'sameaccent', 'samecase', 'say',
|
272
|
+
'sec', 'sech', 'sech', 'seek', 'shape', 'shift', 'sign', 'signature',
|
273
|
+
'sin', 'sinh', 'skip', 'skip_rest', 'sleep', 'slurp', 'sort', 'splice',
|
274
|
+
'split', 'sprintf', 'sqrt', 'srand', 'strand', 'subst', 'substr', 'succ',
|
275
|
+
'sum', 'symlink', 'tan', 'tanh', 'throws_ok', 'time', 'times', 'to',
|
276
|
+
'todo', 'trim', 'trim_end', 'trim_start', 'true', 'truncate', 'uc',
|
277
|
+
'ucfirst', 'undef', 'undefine', 'uniq', 'unlike', 'unlink', 'unpack',
|
278
|
+
'unpolar', 'unshift', 'unwrap', 'use_ok', 'value', 'values', 'vec',
|
279
|
+
'version_lt', 'void', 'wait', 'want', 'wrap', 'write', 'zip',
|
280
|
+
)
|
281
|
+
|
282
|
+
PERL6_BUILTIN_CLASSES = (
|
283
|
+
'Abstraction', 'Any', 'AnyChar', 'Array', 'Associative', 'Bag', 'Bit',
|
284
|
+
'Blob', 'Block', 'Bool', 'Buf', 'Byte', 'Callable', 'Capture', 'Char', 'Class',
|
285
|
+
'Code', 'Codepoint', 'Comparator', 'Complex', 'Decreasing', 'Exception',
|
286
|
+
'Failure', 'False', 'Grammar', 'Grapheme', 'Hash', 'IO', 'Increasing',
|
287
|
+
'Int', 'Junction', 'KeyBag', 'KeyExtractor', 'KeyHash', 'KeySet',
|
288
|
+
'KitchenSink', 'List', 'Macro', 'Mapping', 'Match', 'Matcher', 'Method',
|
289
|
+
'Module', 'Num', 'Object', 'Ordered', 'Ordering', 'OrderingPair',
|
290
|
+
'Package', 'Pair', 'Positional', 'Proxy', 'Range', 'Rat', 'Regex',
|
291
|
+
'Role', 'Routine', 'Scalar', 'Seq', 'Set', 'Signature', 'Str', 'StrLen',
|
292
|
+
'StrPos', 'Sub', 'Submethod', 'True', 'UInt', 'Undef', 'Version', 'Void',
|
293
|
+
'Whatever', 'bit', 'bool', 'buf', 'buf1', 'buf16', 'buf2', 'buf32',
|
294
|
+
'buf4', 'buf64', 'buf8', 'complex', 'int', 'int1', 'int16', 'int2',
|
295
|
+
'int32', 'int4', 'int64', 'int8', 'num', 'rat', 'rat1', 'rat16', 'rat2',
|
296
|
+
'rat32', 'rat4', 'rat64', 'rat8', 'uint', 'uint1', 'uint16', 'uint2',
|
297
|
+
'uint32', 'uint4', 'uint64', 'uint8', 'utf16', 'utf32', 'utf8',
|
298
|
+
)
|
299
|
+
|
300
|
+
PERL6_OPERATORS = (
|
301
|
+
'X', 'Z', 'after', 'also', 'and', 'andthen', 'before', 'cmp', 'div',
|
302
|
+
'eq', 'eqv', 'extra', 'ff', 'fff', 'ge', 'gt', 'le', 'leg', 'lt', 'm',
|
303
|
+
'mm', 'mod', 'ne', 'or', 'orelse', 'rx', 's', 'tr', 'x', 'xor', 'xx',
|
304
|
+
'++', '--', '**', '!', '+', '-', '~', '?', '|', '||', '+^', '~^', '?^',
|
305
|
+
'^', '*', '/', '%', '%%', '+&', '+<', '+>', '~&', '~<', '~>', '?&',
|
306
|
+
'gcd', 'lcm', '+', '-', '+|', '+^', '~|', '~^', '?|', '?^',
|
307
|
+
'~', '&', '^', 'but', 'does', '<=>', '..', '..^', '^..', '^..^',
|
308
|
+
'!=', '==', '<', '<=', '>', '>=', '~~', '===', '!eqv',
|
309
|
+
'&&', '||', '^^', '//', 'min', 'max', '??', '!!', 'ff', 'fff', 'so',
|
310
|
+
'not', '<==', '==>', '<<==', '==>>',
|
311
|
+
)
|
312
|
+
|
313
|
+
# Perl 6 has a *lot* of possible bracketing characters
|
314
|
+
# this list was lifted from STD.pm6 (https://github.com/perl6/std)
|
315
|
+
PERL6_BRACKETS = {
|
316
|
+
u'\u0028': u'\u0029', u'\u003c': u'\u003e', u'\u005b': u'\u005d',
|
317
|
+
u'\u007b': u'\u007d', u'\u00ab': u'\u00bb', u'\u0f3a': u'\u0f3b',
|
318
|
+
u'\u0f3c': u'\u0f3d', u'\u169b': u'\u169c', u'\u2018': u'\u2019',
|
319
|
+
u'\u201a': u'\u2019', u'\u201b': u'\u2019', u'\u201c': u'\u201d',
|
320
|
+
u'\u201e': u'\u201d', u'\u201f': u'\u201d', u'\u2039': u'\u203a',
|
321
|
+
u'\u2045': u'\u2046', u'\u207d': u'\u207e', u'\u208d': u'\u208e',
|
322
|
+
u'\u2208': u'\u220b', u'\u2209': u'\u220c', u'\u220a': u'\u220d',
|
323
|
+
u'\u2215': u'\u29f5', u'\u223c': u'\u223d', u'\u2243': u'\u22cd',
|
324
|
+
u'\u2252': u'\u2253', u'\u2254': u'\u2255', u'\u2264': u'\u2265',
|
325
|
+
u'\u2266': u'\u2267', u'\u2268': u'\u2269', u'\u226a': u'\u226b',
|
326
|
+
u'\u226e': u'\u226f', u'\u2270': u'\u2271', u'\u2272': u'\u2273',
|
327
|
+
u'\u2274': u'\u2275', u'\u2276': u'\u2277', u'\u2278': u'\u2279',
|
328
|
+
u'\u227a': u'\u227b', u'\u227c': u'\u227d', u'\u227e': u'\u227f',
|
329
|
+
u'\u2280': u'\u2281', u'\u2282': u'\u2283', u'\u2284': u'\u2285',
|
330
|
+
u'\u2286': u'\u2287', u'\u2288': u'\u2289', u'\u228a': u'\u228b',
|
331
|
+
u'\u228f': u'\u2290', u'\u2291': u'\u2292', u'\u2298': u'\u29b8',
|
332
|
+
u'\u22a2': u'\u22a3', u'\u22a6': u'\u2ade', u'\u22a8': u'\u2ae4',
|
333
|
+
u'\u22a9': u'\u2ae3', u'\u22ab': u'\u2ae5', u'\u22b0': u'\u22b1',
|
334
|
+
u'\u22b2': u'\u22b3', u'\u22b4': u'\u22b5', u'\u22b6': u'\u22b7',
|
335
|
+
u'\u22c9': u'\u22ca', u'\u22cb': u'\u22cc', u'\u22d0': u'\u22d1',
|
336
|
+
u'\u22d6': u'\u22d7', u'\u22d8': u'\u22d9', u'\u22da': u'\u22db',
|
337
|
+
u'\u22dc': u'\u22dd', u'\u22de': u'\u22df', u'\u22e0': u'\u22e1',
|
338
|
+
u'\u22e2': u'\u22e3', u'\u22e4': u'\u22e5', u'\u22e6': u'\u22e7',
|
339
|
+
u'\u22e8': u'\u22e9', u'\u22ea': u'\u22eb', u'\u22ec': u'\u22ed',
|
340
|
+
u'\u22f0': u'\u22f1', u'\u22f2': u'\u22fa', u'\u22f3': u'\u22fb',
|
341
|
+
u'\u22f4': u'\u22fc', u'\u22f6': u'\u22fd', u'\u22f7': u'\u22fe',
|
342
|
+
u'\u2308': u'\u2309', u'\u230a': u'\u230b', u'\u2329': u'\u232a',
|
343
|
+
u'\u23b4': u'\u23b5', u'\u2768': u'\u2769', u'\u276a': u'\u276b',
|
344
|
+
u'\u276c': u'\u276d', u'\u276e': u'\u276f', u'\u2770': u'\u2771',
|
345
|
+
u'\u2772': u'\u2773', u'\u2774': u'\u2775', u'\u27c3': u'\u27c4',
|
346
|
+
u'\u27c5': u'\u27c6', u'\u27d5': u'\u27d6', u'\u27dd': u'\u27de',
|
347
|
+
u'\u27e2': u'\u27e3', u'\u27e4': u'\u27e5', u'\u27e6': u'\u27e7',
|
348
|
+
u'\u27e8': u'\u27e9', u'\u27ea': u'\u27eb', u'\u2983': u'\u2984',
|
349
|
+
u'\u2985': u'\u2986', u'\u2987': u'\u2988', u'\u2989': u'\u298a',
|
350
|
+
u'\u298b': u'\u298c', u'\u298d': u'\u298e', u'\u298f': u'\u2990',
|
351
|
+
u'\u2991': u'\u2992', u'\u2993': u'\u2994', u'\u2995': u'\u2996',
|
352
|
+
u'\u2997': u'\u2998', u'\u29c0': u'\u29c1', u'\u29c4': u'\u29c5',
|
353
|
+
u'\u29cf': u'\u29d0', u'\u29d1': u'\u29d2', u'\u29d4': u'\u29d5',
|
354
|
+
u'\u29d8': u'\u29d9', u'\u29da': u'\u29db', u'\u29f8': u'\u29f9',
|
355
|
+
u'\u29fc': u'\u29fd', u'\u2a2b': u'\u2a2c', u'\u2a2d': u'\u2a2e',
|
356
|
+
u'\u2a34': u'\u2a35', u'\u2a3c': u'\u2a3d', u'\u2a64': u'\u2a65',
|
357
|
+
u'\u2a79': u'\u2a7a', u'\u2a7d': u'\u2a7e', u'\u2a7f': u'\u2a80',
|
358
|
+
u'\u2a81': u'\u2a82', u'\u2a83': u'\u2a84', u'\u2a8b': u'\u2a8c',
|
359
|
+
u'\u2a91': u'\u2a92', u'\u2a93': u'\u2a94', u'\u2a95': u'\u2a96',
|
360
|
+
u'\u2a97': u'\u2a98', u'\u2a99': u'\u2a9a', u'\u2a9b': u'\u2a9c',
|
361
|
+
u'\u2aa1': u'\u2aa2', u'\u2aa6': u'\u2aa7', u'\u2aa8': u'\u2aa9',
|
362
|
+
u'\u2aaa': u'\u2aab', u'\u2aac': u'\u2aad', u'\u2aaf': u'\u2ab0',
|
363
|
+
u'\u2ab3': u'\u2ab4', u'\u2abb': u'\u2abc', u'\u2abd': u'\u2abe',
|
364
|
+
u'\u2abf': u'\u2ac0', u'\u2ac1': u'\u2ac2', u'\u2ac3': u'\u2ac4',
|
365
|
+
u'\u2ac5': u'\u2ac6', u'\u2acd': u'\u2ace', u'\u2acf': u'\u2ad0',
|
366
|
+
u'\u2ad1': u'\u2ad2', u'\u2ad3': u'\u2ad4', u'\u2ad5': u'\u2ad6',
|
367
|
+
u'\u2aec': u'\u2aed', u'\u2af7': u'\u2af8', u'\u2af9': u'\u2afa',
|
368
|
+
u'\u2e02': u'\u2e03', u'\u2e04': u'\u2e05', u'\u2e09': u'\u2e0a',
|
369
|
+
u'\u2e0c': u'\u2e0d', u'\u2e1c': u'\u2e1d', u'\u2e20': u'\u2e21',
|
370
|
+
u'\u3008': u'\u3009', u'\u300a': u'\u300b', u'\u300c': u'\u300d',
|
371
|
+
u'\u300e': u'\u300f', u'\u3010': u'\u3011', u'\u3014': u'\u3015',
|
372
|
+
u'\u3016': u'\u3017', u'\u3018': u'\u3019', u'\u301a': u'\u301b',
|
373
|
+
u'\u301d': u'\u301e', u'\ufd3e': u'\ufd3f', u'\ufe17': u'\ufe18',
|
374
|
+
u'\ufe35': u'\ufe36', u'\ufe37': u'\ufe38', u'\ufe39': u'\ufe3a',
|
375
|
+
u'\ufe3b': u'\ufe3c', u'\ufe3d': u'\ufe3e', u'\ufe3f': u'\ufe40',
|
376
|
+
u'\ufe41': u'\ufe42', u'\ufe43': u'\ufe44', u'\ufe47': u'\ufe48',
|
377
|
+
u'\ufe59': u'\ufe5a', u'\ufe5b': u'\ufe5c', u'\ufe5d': u'\ufe5e',
|
378
|
+
u'\uff08': u'\uff09', u'\uff1c': u'\uff1e', u'\uff3b': u'\uff3d',
|
379
|
+
u'\uff5b': u'\uff5d', u'\uff5f': u'\uff60', u'\uff62': u'\uff63',
|
380
|
+
}
|
381
|
+
|
382
|
+
def _build_word_match(words, boundary_regex_fragment=None, prefix='', suffix=''):
|
383
|
+
if boundary_regex_fragment is None:
|
384
|
+
return r'\b(' + prefix + r'|'.join(re.escape(x) for x in words) + \
|
385
|
+
suffix + r')\b'
|
386
|
+
else:
|
387
|
+
return r'(?<!' + boundary_regex_fragment + r')' + prefix + r'(' + \
|
388
|
+
r'|'.join(re.escape(x) for x in words) + r')' + suffix + r'(?!' + \
|
389
|
+
boundary_regex_fragment + r')'
|
390
|
+
|
391
|
+
def brackets_callback(token_class):
|
392
|
+
def callback(lexer, match, context):
|
393
|
+
groups = match.groupdict()
|
394
|
+
opening_chars = groups['delimiter']
|
395
|
+
n_chars = len(opening_chars)
|
396
|
+
adverbs = groups.get('adverbs')
|
397
|
+
|
398
|
+
closer = Perl6Lexer.PERL6_BRACKETS.get(opening_chars[0])
|
399
|
+
text = context.text
|
400
|
+
|
401
|
+
if closer is None: # it's not a mirrored character, which means we
|
402
|
+
# just need to look for the next occurrence
|
403
|
+
|
404
|
+
end_pos = text.find(opening_chars, match.start('delimiter') + n_chars)
|
405
|
+
else: # we need to look for the corresponding closing character,
|
406
|
+
# keep nesting in mind
|
407
|
+
closing_chars = closer * n_chars
|
408
|
+
nesting_level = 1
|
409
|
+
|
410
|
+
search_pos = match.start('delimiter')
|
411
|
+
|
412
|
+
while nesting_level > 0:
|
413
|
+
next_open_pos = text.find(opening_chars, search_pos + n_chars)
|
414
|
+
next_close_pos = text.find(closing_chars, search_pos + n_chars)
|
415
|
+
|
416
|
+
if next_close_pos == -1:
|
417
|
+
next_close_pos = len(text)
|
418
|
+
nesting_level = 0
|
419
|
+
elif next_open_pos != -1 and next_open_pos < next_close_pos:
|
420
|
+
nesting_level += 1
|
421
|
+
search_pos = next_open_pos
|
422
|
+
else: # next_close_pos < next_open_pos
|
423
|
+
nesting_level -= 1
|
424
|
+
search_pos = next_close_pos
|
425
|
+
|
426
|
+
end_pos = next_close_pos
|
427
|
+
|
428
|
+
if end_pos < 0: # if we didn't find a closer, just highlight the
|
429
|
+
# rest of the text in this class
|
430
|
+
end_pos = len(text)
|
431
|
+
|
432
|
+
if adverbs is not None and re.search(r':to\b', adverbs):
|
433
|
+
heredoc_terminator = text[match.start('delimiter') + n_chars:end_pos]
|
434
|
+
end_heredoc = re.search(r'^\s*' + re.escape(heredoc_terminator) +
|
435
|
+
r'\s*$', text[end_pos:], re.MULTILINE)
|
436
|
+
|
437
|
+
if end_heredoc:
|
438
|
+
end_pos += end_heredoc.end()
|
439
|
+
else:
|
440
|
+
end_pos = len(text)
|
441
|
+
|
442
|
+
yield match.start(), token_class, text[match.start():end_pos + n_chars]
|
443
|
+
context.pos = end_pos + n_chars
|
444
|
+
|
445
|
+
return callback
|
446
|
+
|
447
|
+
def opening_brace_callback(lexer, match, context):
|
448
|
+
stack = context.stack
|
449
|
+
|
450
|
+
yield match.start(), Text, context.text[match.start():match.end()]
|
451
|
+
context.pos = match.end()
|
452
|
+
|
453
|
+
# if we encounter an opening brace and we're one level
|
454
|
+
# below a token state, it means we need to increment
|
455
|
+
# the nesting level for braces so we know later when
|
456
|
+
# we should return to the token rules.
|
457
|
+
if len(stack) > 2 and stack[-2] == 'token':
|
458
|
+
context.perl6_token_nesting_level += 1
|
459
|
+
|
460
|
+
def closing_brace_callback(lexer, match, context):
|
461
|
+
stack = context.stack
|
462
|
+
|
463
|
+
yield match.start(), Text, context.text[match.start():match.end()]
|
464
|
+
context.pos = match.end()
|
465
|
+
|
466
|
+
# if we encounter a free closing brace and we're one level
|
467
|
+
# below a token state, it means we need to check the nesting
|
468
|
+
# level to see if we need to return to the token state.
|
469
|
+
if len(stack) > 2 and stack[-2] == 'token':
|
470
|
+
context.perl6_token_nesting_level -= 1
|
471
|
+
if context.perl6_token_nesting_level == 0:
|
472
|
+
stack.pop()
|
473
|
+
|
474
|
+
def embedded_perl6_callback(lexer, match, context):
|
475
|
+
context.perl6_token_nesting_level = 1
|
476
|
+
yield match.start(), Text, context.text[match.start():match.end()]
|
477
|
+
context.pos = match.end()
|
478
|
+
context.stack.append('root')
|
479
|
+
|
480
|
+
# If you're modifying these rules, be careful if you need to process '{' or '}'
|
481
|
+
# characters. We have special logic for processing these characters (due to the fact
|
482
|
+
# that you can nest Perl 6 code in regex blocks), so if you need to process one of
|
483
|
+
# them, make sure you also process the corresponding one!
|
484
|
+
tokens = {
|
485
|
+
'common': [
|
486
|
+
(r'#[`|=](?P<delimiter>(?P<first_char>[' + ''.join(PERL6_BRACKETS) + r'])(?P=first_char)*)',
|
487
|
+
brackets_callback(Comment.Multiline)),
|
488
|
+
(r'#[^\n]*$', Comment.Singleline),
|
489
|
+
(r'^(\s*)=begin\s+(\w+)\b.*?^\1=end\s+\2', Comment.Multiline),
|
490
|
+
(r'^(\s*)=for.*?\n\s*?\n', Comment.Multiline),
|
491
|
+
(r'^=.*?\n\s*?\n', Comment.Multiline),
|
492
|
+
(r'(regex|token|rule)(\s*' + PERL6_IDENTIFIER_RANGE + '+:sym)',
|
493
|
+
bygroups(Keyword, Name), 'token-sym-brackets'),
|
494
|
+
(r'(regex|token|rule)(?!' + PERL6_IDENTIFIER_RANGE + ')(\s*' + PERL6_IDENTIFIER_RANGE + '+)?',
|
495
|
+
bygroups(Keyword, Name), 'pre-token'),
|
496
|
+
# deal with a special case in the Perl 6 grammar (role q { ... })
|
497
|
+
(r'(role)(\s+)(q)(\s*)', bygroups(Keyword, Text, Name, Text)),
|
498
|
+
(_build_word_match(PERL6_KEYWORDS, PERL6_IDENTIFIER_RANGE), Keyword),
|
499
|
+
(_build_word_match(PERL6_BUILTIN_CLASSES, PERL6_IDENTIFIER_RANGE, suffix='(?::[UD])?'),
|
500
|
+
Name.Builtin),
|
501
|
+
(_build_word_match(PERL6_BUILTINS, PERL6_IDENTIFIER_RANGE), Name.Builtin),
|
502
|
+
# copied from PerlLexer
|
503
|
+
(r'[$@%&][.^:?=!~]?' + PERL6_IDENTIFIER_RANGE + u'+(?:<<.*?>>|<.*?>|«.*?»)*',
|
504
|
+
Name.Variable),
|
505
|
+
(r'\$[!/](?:<<.*?>>|<.*?>|«.*?»)*', Name.Variable.Global),
|
506
|
+
(r'::\?\w+', Name.Variable.Global),
|
507
|
+
(r'[$@%&]\*' + PERL6_IDENTIFIER_RANGE + u'+(?:<<.*?>>|<.*?>|«.*?»)*',
|
508
|
+
Name.Variable.Global),
|
509
|
+
(r'\$(?:<.*?>)+', Name.Variable),
|
510
|
+
(r'(?:q|qq|Q)[a-zA-Z]?\s*(?P<adverbs>:[\w\s:]+)?\s*(?P<delimiter>(?P<first_char>[^0-9a-zA-Z:\s])'
|
511
|
+
r'(?P=first_char)*)', brackets_callback(String)),
|
512
|
+
# copied from PerlLexer
|
513
|
+
(r'0_?[0-7]+(_[0-7]+)*', Number.Oct),
|
514
|
+
(r'0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*', Number.Hex),
|
515
|
+
(r'0b[01]+(_[01]+)*', Number.Bin),
|
516
|
+
(r'(?i)(\d*(_\d*)*\.\d+(_\d*)*|\d+(_\d*)*\.\d+(_\d*)*)(e[+-]?\d+)?',
|
517
|
+
Number.Float),
|
518
|
+
(r'(?i)\d+(_\d*)*e[+-]?\d+(_\d*)*', Number.Float),
|
519
|
+
(r'\d+(_\d+)*', Number.Integer),
|
520
|
+
(r'(?<=~~)\s*/(?:\\\\|\\/|.)*?/', String.Regex),
|
521
|
+
(r'(?<=[=(,])\s*/(?:\\\\|\\/|.)*?/', String.Regex),
|
522
|
+
(r'm\w+(?=\()', Name),
|
523
|
+
(r'(?:m|ms|rx)\s*(?P<adverbs>:[\w\s:]+)?\s*(?P<delimiter>(?P<first_char>[^\w:\s])'
|
524
|
+
r'(?P=first_char)*)', brackets_callback(String.Regex)),
|
525
|
+
(r'(?:s|ss|tr)\s*(?::[\w\s:]+)?\s*/(?:\\\\|\\/|.)*?/(?:\\\\|\\/|.)*?/',
|
526
|
+
String.Regex),
|
527
|
+
(r'<[^\s=].*?\S>', String),
|
528
|
+
(_build_word_match(PERL6_OPERATORS), Operator),
|
529
|
+
(r'\w' + PERL6_IDENTIFIER_RANGE + '*', Name),
|
530
|
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String),
|
531
|
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
532
|
+
],
|
533
|
+
'root': [
|
534
|
+
include('common'),
|
535
|
+
(r'\{', opening_brace_callback),
|
536
|
+
(r'\}', closing_brace_callback),
|
537
|
+
(r'.+?', Text),
|
538
|
+
],
|
539
|
+
'pre-token': [
|
540
|
+
include('common'),
|
541
|
+
(r'\{', Text, ('#pop', 'token')),
|
542
|
+
(r'.+?', Text),
|
543
|
+
],
|
544
|
+
'token-sym-brackets': [
|
545
|
+
(r'(?P<delimiter>(?P<first_char>[' + ''.join(PERL6_BRACKETS) + '])(?P=first_char)*)',
|
546
|
+
brackets_callback(Name), ('#pop', 'pre-token')),
|
547
|
+
default(('#pop', 'pre-token')),
|
548
|
+
],
|
549
|
+
'token': [
|
550
|
+
(r'\}', Text, '#pop'),
|
551
|
+
(r'(?<=:)(?:my|our|state|constant|temp|let).*?;', using(this)),
|
552
|
+
# make sure that quotes in character classes aren't treated as strings
|
553
|
+
(r'<(?:[-!?+.]\s*)?\[.*?\]>', String.Regex),
|
554
|
+
# make sure that '#' characters in quotes aren't treated as comments
|
555
|
+
(r"(?<!\\)'(\\\\|\\[^\\]|[^'\\])*'", String.Regex),
|
556
|
+
(r'(?<!\\)"(\\\\|\\[^\\]|[^"\\])*"', String.Regex),
|
557
|
+
(r'#.*?$', Comment.Singleline),
|
558
|
+
(r'\{', embedded_perl6_callback),
|
559
|
+
('.+?', String.Regex),
|
560
|
+
],
|
561
|
+
}
|
562
|
+
|
563
|
+
def analyse_text(text):
|
564
|
+
def strip_pod(lines):
|
565
|
+
in_pod = False
|
566
|
+
stripped_lines = []
|
567
|
+
|
568
|
+
for line in lines:
|
569
|
+
if re.match(r'^=(?:end|cut)', line):
|
570
|
+
in_pod = False
|
571
|
+
elif re.match(r'^=\w+', line):
|
572
|
+
in_pod = True
|
573
|
+
elif not in_pod:
|
574
|
+
stripped_lines.append(line)
|
575
|
+
|
576
|
+
return stripped_lines
|
577
|
+
|
578
|
+
# XXX handle block comments
|
579
|
+
lines = text.splitlines()
|
580
|
+
lines = strip_pod(lines)
|
581
|
+
text = '\n'.join(lines)
|
582
|
+
|
583
|
+
if shebang_matches(text, r'perl6|rakudo|niecza|pugs'):
|
584
|
+
return True
|
585
|
+
|
586
|
+
saw_perl_decl = False
|
587
|
+
rating = False
|
588
|
+
|
589
|
+
# check for my/our/has declarations
|
590
|
+
if re.search("(?:my|our|has)\s+(?:" + Perl6Lexer.PERL6_IDENTIFIER_RANGE +
|
591
|
+
"+\s+)?[$@%&(]", text):
|
592
|
+
rating = 0.8
|
593
|
+
saw_perl_decl = True
|
594
|
+
|
595
|
+
for line in lines:
|
596
|
+
line = re.sub('#.*', '', line)
|
597
|
+
if re.match('^\s*$', line):
|
598
|
+
continue
|
599
|
+
|
600
|
+
# match v6; use v6; use v6.0; use v6.0.0;
|
601
|
+
if re.match('^\s*(?:use\s+)?v6(?:\.\d(?:\.\d)?)?;', line):
|
602
|
+
return True
|
603
|
+
# match class, module, role, enum, grammar declarations
|
604
|
+
class_decl = re.match('^\s*(?:(?P<scope>my|our)\s+)?(?:module|class|role|enum|grammar)', line)
|
605
|
+
if class_decl:
|
606
|
+
if saw_perl_decl or class_decl.group('scope') is not None:
|
607
|
+
return True
|
608
|
+
rating = 0.05
|
609
|
+
continue
|
610
|
+
break
|
611
|
+
|
612
|
+
return rating
|
613
|
+
|
614
|
+
def __init__(self, **options):
|
615
|
+
super(Perl6Lexer, self).__init__(**options)
|
616
|
+
self.encoding = options.get('encoding', 'utf-8')
|