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,209 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.rust
|
4
|
+
~~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexers for the Rust language.
|
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, include, bygroups, words, default
|
13
|
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
14
|
+
Number, Punctuation, Whitespace
|
15
|
+
|
16
|
+
__all__ = ['RustLexer']
|
17
|
+
|
18
|
+
|
19
|
+
class RustLexer(RegexLexer):
|
20
|
+
"""
|
21
|
+
Lexer for the Rust programming language (version 1.10).
|
22
|
+
|
23
|
+
.. versionadded:: 1.6
|
24
|
+
"""
|
25
|
+
name = 'Rust'
|
26
|
+
filenames = ['*.rs', '*.rs.in']
|
27
|
+
aliases = ['rust']
|
28
|
+
mimetypes = ['text/rust']
|
29
|
+
|
30
|
+
tokens = {
|
31
|
+
'root': [
|
32
|
+
# rust allows a file to start with a shebang, but if the first line
|
33
|
+
# starts with #![ then it’s not a shebang but a crate attribute.
|
34
|
+
(r'#![^[\r\n].*$', Comment.Preproc),
|
35
|
+
default('base'),
|
36
|
+
],
|
37
|
+
'base': [
|
38
|
+
# Whitespace and Comments
|
39
|
+
(r'\n', Whitespace),
|
40
|
+
(r'\s+', Whitespace),
|
41
|
+
(r'//!.*?\n', String.Doc),
|
42
|
+
(r'///(\n|[^/].*?\n)', String.Doc),
|
43
|
+
(r'//(.*?)\n', Comment.Single),
|
44
|
+
(r'/\*\*(\n|[^/*])', String.Doc, 'doccomment'),
|
45
|
+
(r'/\*!', String.Doc, 'doccomment'),
|
46
|
+
(r'/\*', Comment.Multiline, 'comment'),
|
47
|
+
|
48
|
+
# Macro parameters
|
49
|
+
(r"""\$([a-zA-Z_]\w*|\(,?|\),?|,?)""", Comment.Preproc),
|
50
|
+
# Keywords
|
51
|
+
(words((
|
52
|
+
'as', 'box', 'const', 'crate', 'else', 'extern',
|
53
|
+
'for', 'if', 'impl', 'in', 'loop', 'match', 'move',
|
54
|
+
'mut', 'pub', 'ref', 'return', 'static', 'super',
|
55
|
+
'trait', 'unsafe', 'use', 'where', 'while'), suffix=r'\b'),
|
56
|
+
Keyword),
|
57
|
+
(words(('abstract', 'alignof', 'become', 'do', 'final', 'macro',
|
58
|
+
'offsetof', 'override', 'priv', 'proc', 'pure', 'sizeof',
|
59
|
+
'typeof', 'unsized', 'virtual', 'yield'), suffix=r'\b'),
|
60
|
+
Keyword.Reserved),
|
61
|
+
(r'(true|false)\b', Keyword.Constant),
|
62
|
+
(r'mod\b', Keyword, 'modname'),
|
63
|
+
(r'let\b', Keyword.Declaration),
|
64
|
+
(r'fn\b', Keyword, 'funcname'),
|
65
|
+
(r'(struct|enum|type|union)\b', Keyword, 'typename'),
|
66
|
+
(r'(default)(\s+)(type|fn)\b', bygroups(Keyword, Text, Keyword)),
|
67
|
+
(words(('u8', 'u16', 'u32', 'u64', 'i8', 'i16', 'i32', 'i64', 'usize',
|
68
|
+
'isize', 'f32', 'f64', 'str', 'bool'), suffix=r'\b'),
|
69
|
+
Keyword.Type),
|
70
|
+
(r'self\b', Name.Builtin.Pseudo),
|
71
|
+
# Prelude (taken from Rust’s src/libstd/prelude.rs)
|
72
|
+
(words((
|
73
|
+
# Reexported core operators
|
74
|
+
'Copy', 'Send', 'Sized', 'Sync',
|
75
|
+
'Drop', 'Fn', 'FnMut', 'FnOnce',
|
76
|
+
|
77
|
+
# Reexported functions
|
78
|
+
'drop',
|
79
|
+
|
80
|
+
# Reexported types and traits
|
81
|
+
'Box',
|
82
|
+
'ToOwned',
|
83
|
+
'Clone',
|
84
|
+
'PartialEq', 'PartialOrd', 'Eq', 'Ord',
|
85
|
+
'AsRef', 'AsMut', 'Into', 'From',
|
86
|
+
'Default',
|
87
|
+
'Iterator', 'Extend', 'IntoIterator',
|
88
|
+
'DoubleEndedIterator', 'ExactSizeIterator',
|
89
|
+
'Option',
|
90
|
+
'Some', 'None',
|
91
|
+
'Result',
|
92
|
+
'Ok', 'Err',
|
93
|
+
'SliceConcatExt',
|
94
|
+
'String', 'ToString',
|
95
|
+
'Vec'), suffix=r'\b'),
|
96
|
+
Name.Builtin),
|
97
|
+
# Labels
|
98
|
+
(r'(break|continue)(\s*)(\'[A-Za-z_]\w*)?',
|
99
|
+
bygroups(Keyword, Text.Whitespace, Name.Label)),
|
100
|
+
# Character Literal
|
101
|
+
(r"""'(\\['"\\nrt]|\\x[0-7][0-9a-fA-F]|\\0"""
|
102
|
+
r"""|\\u\{[0-9a-fA-F]{1,6}\}|.)'""",
|
103
|
+
String.Char),
|
104
|
+
(r"""b'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\0"""
|
105
|
+
r"""|\\u\{[0-9a-fA-F]{1,6}\}|.)'""",
|
106
|
+
String.Char),
|
107
|
+
# Binary Literal
|
108
|
+
(r'0b[01_]+', Number.Bin, 'number_lit'),
|
109
|
+
# Octal Literal
|
110
|
+
(r'0o[0-7_]+', Number.Oct, 'number_lit'),
|
111
|
+
# Hexadecimal Literal
|
112
|
+
(r'0[xX][0-9a-fA-F_]+', Number.Hex, 'number_lit'),
|
113
|
+
# Decimal Literal
|
114
|
+
(r'[0-9][0-9_]*(\.[0-9_]+[eE][+\-]?[0-9_]+|'
|
115
|
+
r'\.[0-9_]*(?!\.)|[eE][+\-]?[0-9_]+)', Number.Float, 'number_lit'),
|
116
|
+
(r'[0-9][0-9_]*', Number.Integer, 'number_lit'),
|
117
|
+
# String Literal
|
118
|
+
(r'b"', String, 'bytestring'),
|
119
|
+
(r'"', String, 'string'),
|
120
|
+
(r'b?r(#*)".*?"\1', String),
|
121
|
+
|
122
|
+
# Lifetime
|
123
|
+
(r"""'static""", Name.Builtin),
|
124
|
+
(r"""'[a-zA-Z_]\w*""", Name.Attribute),
|
125
|
+
|
126
|
+
# Operators and Punctuation
|
127
|
+
(r'[{}()\[\],.;]', Punctuation),
|
128
|
+
(r'[+\-*/%&|<>^!~@=:?]', Operator),
|
129
|
+
|
130
|
+
# Identifier
|
131
|
+
(r'[a-zA-Z_]\w*', Name),
|
132
|
+
|
133
|
+
# Attributes
|
134
|
+
(r'#!?\[', Comment.Preproc, 'attribute['),
|
135
|
+
# Macros
|
136
|
+
(r'([A-Za-z_]\w*)(!)(\s*)([A-Za-z_]\w*)?(\s*)(\{)',
|
137
|
+
bygroups(Comment.Preproc, Punctuation, Whitespace, Name,
|
138
|
+
Whitespace, Punctuation), 'macro{'),
|
139
|
+
(r'([A-Za-z_]\w*)(!)(\s*)([A-Za-z_]\w*)?(\()',
|
140
|
+
bygroups(Comment.Preproc, Punctuation, Whitespace, Name,
|
141
|
+
Punctuation), 'macro('),
|
142
|
+
],
|
143
|
+
'comment': [
|
144
|
+
(r'[^*/]+', Comment.Multiline),
|
145
|
+
(r'/\*', Comment.Multiline, '#push'),
|
146
|
+
(r'\*/', Comment.Multiline, '#pop'),
|
147
|
+
(r'[*/]', Comment.Multiline),
|
148
|
+
],
|
149
|
+
'doccomment': [
|
150
|
+
(r'[^*/]+', String.Doc),
|
151
|
+
(r'/\*', String.Doc, '#push'),
|
152
|
+
(r'\*/', String.Doc, '#pop'),
|
153
|
+
(r'[*/]', String.Doc),
|
154
|
+
],
|
155
|
+
'modname': [
|
156
|
+
(r'\s+', Text),
|
157
|
+
(r'[a-zA-Z_]\w*', Name.Namespace, '#pop'),
|
158
|
+
default('#pop'),
|
159
|
+
],
|
160
|
+
'funcname': [
|
161
|
+
(r'\s+', Text),
|
162
|
+
(r'[a-zA-Z_]\w*', Name.Function, '#pop'),
|
163
|
+
default('#pop'),
|
164
|
+
],
|
165
|
+
'typename': [
|
166
|
+
(r'\s+', Text),
|
167
|
+
(r'[a-zA-Z_]\w*', Name.Class, '#pop'),
|
168
|
+
default('#pop'),
|
169
|
+
],
|
170
|
+
'number_lit': [
|
171
|
+
(r'[ui](8|16|32|64|size)', Keyword, '#pop'),
|
172
|
+
(r'f(32|64)', Keyword, '#pop'),
|
173
|
+
default('#pop'),
|
174
|
+
],
|
175
|
+
'string': [
|
176
|
+
(r'"', String, '#pop'),
|
177
|
+
(r"""\\['"\\nrt]|\\x[0-7][0-9a-fA-F]|\\0"""
|
178
|
+
r"""|\\u\{[0-9a-fA-F]{1,6}\}""", String.Escape),
|
179
|
+
(r'[^\\"]+', String),
|
180
|
+
(r'\\', String),
|
181
|
+
],
|
182
|
+
'bytestring': [
|
183
|
+
(r"""\\x[89a-fA-F][0-9a-fA-F]""", String.Escape),
|
184
|
+
include('string'),
|
185
|
+
],
|
186
|
+
'macro{': [
|
187
|
+
(r'\{', Operator, '#push'),
|
188
|
+
(r'\}', Operator, '#pop'),
|
189
|
+
],
|
190
|
+
'macro(': [
|
191
|
+
(r'\(', Operator, '#push'),
|
192
|
+
(r'\)', Operator, '#pop'),
|
193
|
+
],
|
194
|
+
'attribute_common': [
|
195
|
+
(r'"', String, 'string'),
|
196
|
+
(r'\[', Comment.Preproc, 'attribute['),
|
197
|
+
(r'\(', Comment.Preproc, 'attribute('),
|
198
|
+
],
|
199
|
+
'attribute[': [
|
200
|
+
include('attribute_common'),
|
201
|
+
(r'\];?', Comment.Preproc, '#pop'),
|
202
|
+
(r'[^"\]]+', Comment.Preproc),
|
203
|
+
],
|
204
|
+
'attribute(': [
|
205
|
+
include('attribute_common'),
|
206
|
+
(r'\);?', Comment.Preproc, '#pop'),
|
207
|
+
(r'[^")]+', Comment.Preproc),
|
208
|
+
],
|
209
|
+
}
|
@@ -0,0 +1,228 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.sas
|
4
|
+
~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexer for SAS.
|
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
|
+
from pygments.lexer import RegexLexer, include, words
|
14
|
+
from pygments.token import Comment, Keyword, Name, Number, String, Text, \
|
15
|
+
Other, Generic
|
16
|
+
|
17
|
+
__all__ = ['SASLexer']
|
18
|
+
|
19
|
+
class SASLexer(RegexLexer):
|
20
|
+
"""
|
21
|
+
For `SAS <http://www.sas.com/>`_ files.
|
22
|
+
|
23
|
+
.. versionadded:: 2.2
|
24
|
+
"""
|
25
|
+
# Syntax from syntax/sas.vim by James Kidd <james.kidd@covance.com>
|
26
|
+
|
27
|
+
name = 'SAS'
|
28
|
+
aliases = ['sas']
|
29
|
+
filenames = ['*.SAS', '*.sas']
|
30
|
+
mimetypes = ['text/x-sas', 'text/sas', 'application/x-sas']
|
31
|
+
flags = re.IGNORECASE | re.MULTILINE
|
32
|
+
|
33
|
+
builtins_macros = (
|
34
|
+
"bquote", "nrbquote", "cmpres", "qcmpres", "compstor", "datatyp",
|
35
|
+
"display", "do", "else", "end", "eval", "global", "goto", "if",
|
36
|
+
"index", "input", "keydef", "label", "left", "length", "let",
|
37
|
+
"local", "lowcase", "macro", "mend", "nrquote",
|
38
|
+
"nrstr", "put", "qleft", "qlowcase", "qscan",
|
39
|
+
"qsubstr", "qsysfunc", "qtrim", "quote", "qupcase", "scan",
|
40
|
+
"str", "substr", "superq", "syscall", "sysevalf", "sysexec",
|
41
|
+
"sysfunc", "sysget", "syslput", "sysprod", "sysrc", "sysrput",
|
42
|
+
"then", "to", "trim", "unquote", "until", "upcase", "verify",
|
43
|
+
"while", "window"
|
44
|
+
)
|
45
|
+
|
46
|
+
builtins_conditionals = (
|
47
|
+
"do", "if", "then", "else", "end", "until", "while"
|
48
|
+
)
|
49
|
+
|
50
|
+
builtins_statements = (
|
51
|
+
"abort", "array", "attrib", "by", "call", "cards", "cards4",
|
52
|
+
"catname", "continue", "datalines", "datalines4", "delete", "delim",
|
53
|
+
"delimiter", "display", "dm", "drop", "endsas", "error", "file",
|
54
|
+
"filename", "footnote", "format", "goto", "in", "infile", "informat",
|
55
|
+
"input", "keep", "label", "leave", "length", "libname", "link",
|
56
|
+
"list", "lostcard", "merge", "missing", "modify", "options", "output",
|
57
|
+
"out", "page", "put", "redirect", "remove", "rename", "replace",
|
58
|
+
"retain", "return", "select", "set", "skip", "startsas", "stop",
|
59
|
+
"title", "update", "waitsas", "where", "window", "x", "systask"
|
60
|
+
)
|
61
|
+
|
62
|
+
builtins_sql = (
|
63
|
+
"add", "and", "alter", "as", "cascade", "check", "create",
|
64
|
+
"delete", "describe", "distinct", "drop", "foreign", "from",
|
65
|
+
"group", "having", "index", "insert", "into", "in", "key", "like",
|
66
|
+
"message", "modify", "msgtype", "not", "null", "on", "or",
|
67
|
+
"order", "primary", "references", "reset", "restrict", "select",
|
68
|
+
"set", "table", "unique", "update", "validate", "view", "where"
|
69
|
+
)
|
70
|
+
|
71
|
+
builtins_functions = (
|
72
|
+
"abs", "addr", "airy", "arcos", "arsin", "atan", "attrc",
|
73
|
+
"attrn", "band", "betainv", "blshift", "bnot", "bor",
|
74
|
+
"brshift", "bxor", "byte", "cdf", "ceil", "cexist", "cinv",
|
75
|
+
"close", "cnonct", "collate", "compbl", "compound",
|
76
|
+
"compress", "cos", "cosh", "css", "curobs", "cv", "daccdb",
|
77
|
+
"daccdbsl", "daccsl", "daccsyd", "dacctab", "dairy", "date",
|
78
|
+
"datejul", "datepart", "datetime", "day", "dclose", "depdb",
|
79
|
+
"depdbsl", "depsl", "depsyd",
|
80
|
+
"deptab", "dequote", "dhms", "dif", "digamma",
|
81
|
+
"dim", "dinfo", "dnum", "dopen", "doptname", "doptnum",
|
82
|
+
"dread", "dropnote", "dsname", "erf", "erfc", "exist", "exp",
|
83
|
+
"fappend", "fclose", "fcol", "fdelete", "fetch", "fetchobs",
|
84
|
+
"fexist", "fget", "fileexist", "filename", "fileref",
|
85
|
+
"finfo", "finv", "fipname", "fipnamel", "fipstate", "floor",
|
86
|
+
"fnonct", "fnote", "fopen", "foptname", "foptnum", "fpoint",
|
87
|
+
"fpos", "fput", "fread", "frewind", "frlen", "fsep", "fuzz",
|
88
|
+
"fwrite", "gaminv", "gamma", "getoption", "getvarc", "getvarn",
|
89
|
+
"hbound", "hms", "hosthelp", "hour", "ibessel", "index",
|
90
|
+
"indexc", "indexw", "input", "inputc", "inputn", "int",
|
91
|
+
"intck", "intnx", "intrr", "irr", "jbessel", "juldate",
|
92
|
+
"kurtosis", "lag", "lbound", "left", "length", "lgamma",
|
93
|
+
"libname", "libref", "log", "log10", "log2", "logpdf", "logpmf",
|
94
|
+
"logsdf", "lowcase", "max", "mdy", "mean", "min", "minute",
|
95
|
+
"mod", "month", "mopen", "mort", "n", "netpv", "nmiss",
|
96
|
+
"normal", "note", "npv", "open", "ordinal", "pathname",
|
97
|
+
"pdf", "peek", "peekc", "pmf", "point", "poisson", "poke",
|
98
|
+
"probbeta", "probbnml", "probchi", "probf", "probgam",
|
99
|
+
"probhypr", "probit", "probnegb", "probnorm", "probt",
|
100
|
+
"put", "putc", "putn", "qtr", "quote", "ranbin", "rancau",
|
101
|
+
"ranexp", "rangam", "range", "rank", "rannor", "ranpoi",
|
102
|
+
"rantbl", "rantri", "ranuni", "repeat", "resolve", "reverse",
|
103
|
+
"rewind", "right", "round", "saving", "scan", "sdf", "second",
|
104
|
+
"sign", "sin", "sinh", "skewness", "soundex", "spedis",
|
105
|
+
"sqrt", "std", "stderr", "stfips", "stname", "stnamel",
|
106
|
+
"substr", "sum", "symget", "sysget", "sysmsg", "sysprod",
|
107
|
+
"sysrc", "system", "tan", "tanh", "time", "timepart", "tinv",
|
108
|
+
"tnonct", "today", "translate", "tranwrd", "trigamma",
|
109
|
+
"trim", "trimn", "trunc", "uniform", "upcase", "uss", "var",
|
110
|
+
"varfmt", "varinfmt", "varlabel", "varlen", "varname",
|
111
|
+
"varnum", "varray", "varrayx", "vartype", "verify", "vformat",
|
112
|
+
"vformatd", "vformatdx", "vformatn", "vformatnx", "vformatw",
|
113
|
+
"vformatwx", "vformatx", "vinarray", "vinarrayx", "vinformat",
|
114
|
+
"vinformatd", "vinformatdx", "vinformatn", "vinformatnx",
|
115
|
+
"vinformatw", "vinformatwx", "vinformatx", "vlabel",
|
116
|
+
"vlabelx", "vlength", "vlengthx", "vname", "vnamex", "vtype",
|
117
|
+
"vtypex", "weekday", "year", "yyq", "zipfips", "zipname",
|
118
|
+
"zipnamel", "zipstate"
|
119
|
+
)
|
120
|
+
|
121
|
+
tokens = {
|
122
|
+
'root': [
|
123
|
+
include('comments'),
|
124
|
+
include('proc-data'),
|
125
|
+
include('cards-datalines'),
|
126
|
+
include('logs'),
|
127
|
+
include('general'),
|
128
|
+
(r'.', Text),
|
129
|
+
],
|
130
|
+
# SAS is multi-line regardless, but * is ended by ;
|
131
|
+
'comments': [
|
132
|
+
(r'^\s*\*.*?;', Comment),
|
133
|
+
(r'/\*.*?\*/', Comment),
|
134
|
+
(r'^\s*\*(.|\n)*?;', Comment.Multiline),
|
135
|
+
(r'/[*](.|\n)*?[*]/', Comment.Multiline),
|
136
|
+
],
|
137
|
+
# Special highlight for proc, data, quit, run
|
138
|
+
'proc-data': [
|
139
|
+
(r'(^|;)\s*(proc [a-zA-Z0-9_]+|data|run|quit)[\s;\n]',
|
140
|
+
Keyword.Reserved),
|
141
|
+
],
|
142
|
+
# Special highlight cards and datalines
|
143
|
+
'cards-datalines': [
|
144
|
+
(r'^\s*(datalines|cards)\s*;\s*$', Keyword, 'data'),
|
145
|
+
],
|
146
|
+
'data': [
|
147
|
+
(r'(.|\n)*^\s*;\s*$', Other, '#pop'),
|
148
|
+
],
|
149
|
+
# Special highlight for put NOTE|ERROR|WARNING (order matters)
|
150
|
+
'logs': [
|
151
|
+
(r'\n?^\s*%?put ', Keyword, 'log-messages'),
|
152
|
+
],
|
153
|
+
'log-messages': [
|
154
|
+
(r'NOTE(:|-).*', Generic, '#pop'),
|
155
|
+
(r'WARNING(:|-).*', Generic.Emph, '#pop'),
|
156
|
+
(r'ERROR(:|-).*', Generic.Error, '#pop'),
|
157
|
+
(r'(?!(WARNING|NOTE|ERROR))+', Text, '#pop'),
|
158
|
+
include('general'),
|
159
|
+
],
|
160
|
+
'general': [
|
161
|
+
include('keywords'),
|
162
|
+
include('vars-strings'),
|
163
|
+
include('special'),
|
164
|
+
include('numbers'),
|
165
|
+
],
|
166
|
+
# Keywords, statements, functions, macros
|
167
|
+
'keywords': [
|
168
|
+
(words(builtins_statements,
|
169
|
+
prefix = r'\b',
|
170
|
+
suffix = r'\b'),
|
171
|
+
Keyword),
|
172
|
+
(words(builtins_sql,
|
173
|
+
prefix = r'\b',
|
174
|
+
suffix = r'\b'),
|
175
|
+
Keyword),
|
176
|
+
(words(builtins_conditionals,
|
177
|
+
prefix = r'\b',
|
178
|
+
suffix = r'\b'),
|
179
|
+
Keyword),
|
180
|
+
(words(builtins_macros,
|
181
|
+
prefix = r'%',
|
182
|
+
suffix = r'\b'),
|
183
|
+
Name.Builtin),
|
184
|
+
(words(builtins_functions,
|
185
|
+
prefix = r'\b',
|
186
|
+
suffix = r'\('),
|
187
|
+
Name.Builtin),
|
188
|
+
],
|
189
|
+
# Strings and user-defined variables and macros (order matters)
|
190
|
+
'vars-strings': [
|
191
|
+
(r'&[a-zA-Z_][a-zA-Z0-9_]{0,31}\.?', Name.Variable),
|
192
|
+
(r'%[a-zA-Z_][a-zA-Z0-9_]{0,31}', Name.Function),
|
193
|
+
(r'\'', String, 'string_squote'),
|
194
|
+
(r'"', String, 'string_dquote'),
|
195
|
+
],
|
196
|
+
'string_squote': [
|
197
|
+
('\'', String, '#pop'),
|
198
|
+
(r'\\\\|\\"|\\\n', String.Escape),
|
199
|
+
# AFAIK, macro variables are not evaluated in single quotes
|
200
|
+
# (r'&', Name.Variable, 'validvar'),
|
201
|
+
(r'[^$\'\\]+', String),
|
202
|
+
(r'[$\'\\]', String),
|
203
|
+
],
|
204
|
+
'string_dquote': [
|
205
|
+
(r'"', String, '#pop'),
|
206
|
+
(r'\\\\|\\"|\\\n', String.Escape),
|
207
|
+
(r'&', Name.Variable, 'validvar'),
|
208
|
+
(r'[^$&"\\]+', String),
|
209
|
+
(r'[$"\\]', String),
|
210
|
+
],
|
211
|
+
'validvar': [
|
212
|
+
(r'[a-zA-Z_][a-zA-Z0-9_]{0,31}\.?', Name.Variable, '#pop'),
|
213
|
+
],
|
214
|
+
# SAS numbers and special variables
|
215
|
+
'numbers': [
|
216
|
+
(r'\b[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+|\.)([eE][+-]?[0-9]+)?[i]?\b',
|
217
|
+
Number),
|
218
|
+
],
|
219
|
+
'special': [
|
220
|
+
(r'(null|missing|_all_|_automatic_|_character_|_n_|'
|
221
|
+
r'_infile_|_name_|_null_|_numeric_|_user_|_webout_)',
|
222
|
+
Keyword.Constant),
|
223
|
+
],
|
224
|
+
# 'operators': [
|
225
|
+
# (r'(-|=|<=|>=|<|>|<>|&|!=|'
|
226
|
+
# r'\||\*|\+|\^|/|!|~|~=)', Operator)
|
227
|
+
# ],
|
228
|
+
}
|
@@ -0,0 +1,1222 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.scripting
|
4
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexer for scripting and embedded 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, include, bygroups, default, combined, \
|
15
|
+
words
|
16
|
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
17
|
+
Number, Punctuation, Error, Whitespace, Other
|
18
|
+
from pygments.util import get_bool_opt, get_list_opt, iteritems
|
19
|
+
|
20
|
+
__all__ = ['LuaLexer', 'MoonScriptLexer', 'ChaiscriptLexer', 'LSLLexer',
|
21
|
+
'AppleScriptLexer', 'RexxLexer', 'MOOCodeLexer', 'HybrisLexer',
|
22
|
+
'EasytrieveLexer', 'JclLexer']
|
23
|
+
|
24
|
+
|
25
|
+
class LuaLexer(RegexLexer):
|
26
|
+
"""
|
27
|
+
For `Lua <http://www.lua.org>`_ source code.
|
28
|
+
|
29
|
+
Additional options accepted:
|
30
|
+
|
31
|
+
`func_name_highlighting`
|
32
|
+
If given and ``True``, highlight builtin function names
|
33
|
+
(default: ``True``).
|
34
|
+
`disabled_modules`
|
35
|
+
If given, must be a list of module names whose function names
|
36
|
+
should not be highlighted. By default all modules are highlighted.
|
37
|
+
|
38
|
+
To get a list of allowed modules have a look into the
|
39
|
+
`_lua_builtins` module:
|
40
|
+
|
41
|
+
.. sourcecode:: pycon
|
42
|
+
|
43
|
+
>>> from pygments.lexers._lua_builtins import MODULES
|
44
|
+
>>> MODULES.keys()
|
45
|
+
['string', 'coroutine', 'modules', 'io', 'basic', ...]
|
46
|
+
"""
|
47
|
+
|
48
|
+
name = 'Lua'
|
49
|
+
aliases = ['lua']
|
50
|
+
filenames = ['*.lua', '*.wlua']
|
51
|
+
mimetypes = ['text/x-lua', 'application/x-lua']
|
52
|
+
|
53
|
+
_comment_multiline = r'(?:--\[(?P<level>=*)\[[\w\W]*?\](?P=level)\])'
|
54
|
+
_comment_single = r'(?:--.*$)'
|
55
|
+
_space = r'(?:\s+)'
|
56
|
+
_s = r'(?:%s|%s|%s)' % (_comment_multiline, _comment_single, _space)
|
57
|
+
_name = r'(?:[^\W\d]\w*)'
|
58
|
+
|
59
|
+
tokens = {
|
60
|
+
'root': [
|
61
|
+
# Lua allows a file to start with a shebang.
|
62
|
+
(r'#!.*', Comment.Preproc),
|
63
|
+
default('base'),
|
64
|
+
],
|
65
|
+
'ws': [
|
66
|
+
(_comment_multiline, Comment.Multiline),
|
67
|
+
(_comment_single, Comment.Single),
|
68
|
+
(_space, Text),
|
69
|
+
],
|
70
|
+
'base': [
|
71
|
+
include('ws'),
|
72
|
+
|
73
|
+
(r'(?i)0x[\da-f]*(\.[\da-f]*)?(p[+-]?\d+)?', Number.Hex),
|
74
|
+
(r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float),
|
75
|
+
(r'(?i)\d+e[+-]?\d+', Number.Float),
|
76
|
+
(r'\d+', Number.Integer),
|
77
|
+
|
78
|
+
# multiline strings
|
79
|
+
(r'(?s)\[(=*)\[.*?\]\1\]', String),
|
80
|
+
|
81
|
+
(r'::', Punctuation, 'label'),
|
82
|
+
(r'\.{3}', Punctuation),
|
83
|
+
(r'[=<>|~&+\-*/%#^]+|\.\.', Operator),
|
84
|
+
(r'[\[\]{}().,:;]', Punctuation),
|
85
|
+
(r'(and|or|not)\b', Operator.Word),
|
86
|
+
|
87
|
+
('(break|do|else|elseif|end|for|if|in|repeat|return|then|until|'
|
88
|
+
r'while)\b', Keyword.Reserved),
|
89
|
+
(r'goto\b', Keyword.Reserved, 'goto'),
|
90
|
+
(r'(local)\b', Keyword.Declaration),
|
91
|
+
(r'(true|false|nil)\b', Keyword.Constant),
|
92
|
+
|
93
|
+
(r'(function)\b', Keyword.Reserved, 'funcname'),
|
94
|
+
|
95
|
+
(r'[A-Za-z_]\w*(\.[A-Za-z_]\w*)?', Name),
|
96
|
+
|
97
|
+
("'", String.Single, combined('stringescape', 'sqs')),
|
98
|
+
('"', String.Double, combined('stringescape', 'dqs'))
|
99
|
+
],
|
100
|
+
|
101
|
+
'funcname': [
|
102
|
+
include('ws'),
|
103
|
+
(r'[.:]', Punctuation),
|
104
|
+
(r'%s(?=%s*[.:])' % (_name, _s), Name.Class),
|
105
|
+
(_name, Name.Function, '#pop'),
|
106
|
+
# inline function
|
107
|
+
('\(', Punctuation, '#pop'),
|
108
|
+
],
|
109
|
+
|
110
|
+
'goto': [
|
111
|
+
include('ws'),
|
112
|
+
(_name, Name.Label, '#pop'),
|
113
|
+
],
|
114
|
+
|
115
|
+
'label': [
|
116
|
+
include('ws'),
|
117
|
+
(r'::', Punctuation, '#pop'),
|
118
|
+
(_name, Name.Label),
|
119
|
+
],
|
120
|
+
|
121
|
+
'stringescape': [
|
122
|
+
(r'\\([abfnrtv\\"\']|[\r\n]{1,2}|z\s*|x[0-9a-fA-F]{2}|\d{1,3}|'
|
123
|
+
r'u\{[0-9a-fA-F]+\})', String.Escape),
|
124
|
+
],
|
125
|
+
|
126
|
+
'sqs': [
|
127
|
+
(r"'", String.Single, '#pop'),
|
128
|
+
(r"[^\\']+", String.Single),
|
129
|
+
],
|
130
|
+
|
131
|
+
'dqs': [
|
132
|
+
(r'"', String.Double, '#pop'),
|
133
|
+
(r'[^\\"]+', String.Double),
|
134
|
+
]
|
135
|
+
}
|
136
|
+
|
137
|
+
def __init__(self, **options):
|
138
|
+
self.func_name_highlighting = get_bool_opt(
|
139
|
+
options, 'func_name_highlighting', True)
|
140
|
+
self.disabled_modules = get_list_opt(options, 'disabled_modules', [])
|
141
|
+
|
142
|
+
self._functions = set()
|
143
|
+
if self.func_name_highlighting:
|
144
|
+
from pygments.lexers._lua_builtins import MODULES
|
145
|
+
for mod, func in iteritems(MODULES):
|
146
|
+
if mod not in self.disabled_modules:
|
147
|
+
self._functions.update(func)
|
148
|
+
RegexLexer.__init__(self, **options)
|
149
|
+
|
150
|
+
def get_tokens_unprocessed(self, text):
|
151
|
+
for index, token, value in \
|
152
|
+
RegexLexer.get_tokens_unprocessed(self, text):
|
153
|
+
if token is Name:
|
154
|
+
if value in self._functions:
|
155
|
+
yield index, Name.Builtin, value
|
156
|
+
continue
|
157
|
+
elif '.' in value:
|
158
|
+
a, b = value.split('.')
|
159
|
+
yield index, Name, a
|
160
|
+
yield index + len(a), Punctuation, u'.'
|
161
|
+
yield index + len(a) + 1, Name, b
|
162
|
+
continue
|
163
|
+
yield index, token, value
|
164
|
+
|
165
|
+
|
166
|
+
class MoonScriptLexer(LuaLexer):
|
167
|
+
"""
|
168
|
+
For `MoonScript <http://moonscript.org>`_ source code.
|
169
|
+
|
170
|
+
.. versionadded:: 1.5
|
171
|
+
"""
|
172
|
+
|
173
|
+
name = "MoonScript"
|
174
|
+
aliases = ["moon", "moonscript"]
|
175
|
+
filenames = ["*.moon"]
|
176
|
+
mimetypes = ['text/x-moonscript', 'application/x-moonscript']
|
177
|
+
|
178
|
+
tokens = {
|
179
|
+
'root': [
|
180
|
+
(r'#!(.*?)$', Comment.Preproc),
|
181
|
+
default('base'),
|
182
|
+
],
|
183
|
+
'base': [
|
184
|
+
('--.*$', Comment.Single),
|
185
|
+
(r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float),
|
186
|
+
(r'(?i)\d+e[+-]?\d+', Number.Float),
|
187
|
+
(r'(?i)0x[0-9a-f]*', Number.Hex),
|
188
|
+
(r'\d+', Number.Integer),
|
189
|
+
(r'\n', Text),
|
190
|
+
(r'[^\S\n]+', Text),
|
191
|
+
(r'(?s)\[(=*)\[.*?\]\1\]', String),
|
192
|
+
(r'(->|=>)', Name.Function),
|
193
|
+
(r':[a-zA-Z_]\w*', Name.Variable),
|
194
|
+
(r'(==|!=|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#!.\\:])', Operator),
|
195
|
+
(r'[;,]', Punctuation),
|
196
|
+
(r'[\[\]{}()]', Keyword.Type),
|
197
|
+
(r'[a-zA-Z_]\w*:', Name.Variable),
|
198
|
+
(words((
|
199
|
+
'class', 'extends', 'if', 'then', 'super', 'do', 'with',
|
200
|
+
'import', 'export', 'while', 'elseif', 'return', 'for', 'in',
|
201
|
+
'from', 'when', 'using', 'else', 'and', 'or', 'not', 'switch',
|
202
|
+
'break'), suffix=r'\b'),
|
203
|
+
Keyword),
|
204
|
+
(r'(true|false|nil)\b', Keyword.Constant),
|
205
|
+
(r'(and|or|not)\b', Operator.Word),
|
206
|
+
(r'(self)\b', Name.Builtin.Pseudo),
|
207
|
+
(r'@@?([a-zA-Z_]\w*)?', Name.Variable.Class),
|
208
|
+
(r'[A-Z]\w*', Name.Class), # proper name
|
209
|
+
(r'[A-Za-z_]\w*(\.[A-Za-z_]\w*)?', Name),
|
210
|
+
("'", String.Single, combined('stringescape', 'sqs')),
|
211
|
+
('"', String.Double, combined('stringescape', 'dqs'))
|
212
|
+
],
|
213
|
+
'stringescape': [
|
214
|
+
(r'''\\([abfnrtv\\"']|\d{1,3})''', String.Escape)
|
215
|
+
],
|
216
|
+
'sqs': [
|
217
|
+
("'", String.Single, '#pop'),
|
218
|
+
(".", String)
|
219
|
+
],
|
220
|
+
'dqs': [
|
221
|
+
('"', String.Double, '#pop'),
|
222
|
+
(".", String)
|
223
|
+
]
|
224
|
+
}
|
225
|
+
|
226
|
+
def get_tokens_unprocessed(self, text):
|
227
|
+
# set . as Operator instead of Punctuation
|
228
|
+
for index, token, value in LuaLexer.get_tokens_unprocessed(self, text):
|
229
|
+
if token == Punctuation and value == ".":
|
230
|
+
token = Operator
|
231
|
+
yield index, token, value
|
232
|
+
|
233
|
+
|
234
|
+
class ChaiscriptLexer(RegexLexer):
|
235
|
+
"""
|
236
|
+
For `ChaiScript <http://chaiscript.com/>`_ source code.
|
237
|
+
|
238
|
+
.. versionadded:: 2.0
|
239
|
+
"""
|
240
|
+
|
241
|
+
name = 'ChaiScript'
|
242
|
+
aliases = ['chai', 'chaiscript']
|
243
|
+
filenames = ['*.chai']
|
244
|
+
mimetypes = ['text/x-chaiscript', 'application/x-chaiscript']
|
245
|
+
|
246
|
+
flags = re.DOTALL | re.MULTILINE
|
247
|
+
|
248
|
+
tokens = {
|
249
|
+
'commentsandwhitespace': [
|
250
|
+
(r'\s+', Text),
|
251
|
+
(r'//.*?\n', Comment.Single),
|
252
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
253
|
+
(r'^\#.*?\n', Comment.Single)
|
254
|
+
],
|
255
|
+
'slashstartsregex': [
|
256
|
+
include('commentsandwhitespace'),
|
257
|
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
258
|
+
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
259
|
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
260
|
+
default('#pop')
|
261
|
+
],
|
262
|
+
'badregex': [
|
263
|
+
(r'\n', Text, '#pop')
|
264
|
+
],
|
265
|
+
'root': [
|
266
|
+
include('commentsandwhitespace'),
|
267
|
+
(r'\n', Text),
|
268
|
+
(r'[^\S\n]+', Text),
|
269
|
+
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|\.\.'
|
270
|
+
r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),
|
271
|
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
272
|
+
(r'[})\].]', Punctuation),
|
273
|
+
(r'[=+\-*/]', Operator),
|
274
|
+
(r'(for|in|while|do|break|return|continue|if|else|'
|
275
|
+
r'throw|try|catch'
|
276
|
+
r')\b', Keyword, 'slashstartsregex'),
|
277
|
+
(r'(var)\b', Keyword.Declaration, 'slashstartsregex'),
|
278
|
+
(r'(attr|def|fun)\b', Keyword.Reserved),
|
279
|
+
(r'(true|false)\b', Keyword.Constant),
|
280
|
+
(r'(eval|throw)\b', Name.Builtin),
|
281
|
+
(r'`\S+`', Name.Builtin),
|
282
|
+
(r'[$a-zA-Z_]\w*', Name.Other),
|
283
|
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
284
|
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
285
|
+
(r'[0-9]+', Number.Integer),
|
286
|
+
(r'"', String.Double, 'dqstring'),
|
287
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
288
|
+
],
|
289
|
+
'dqstring': [
|
290
|
+
(r'\$\{[^"}]+?\}', String.Interpol),
|
291
|
+
(r'\$', String.Double),
|
292
|
+
(r'\\\\', String.Double),
|
293
|
+
(r'\\"', String.Double),
|
294
|
+
(r'[^\\"$]+', String.Double),
|
295
|
+
(r'"', String.Double, '#pop'),
|
296
|
+
],
|
297
|
+
}
|
298
|
+
|
299
|
+
|
300
|
+
class LSLLexer(RegexLexer):
|
301
|
+
"""
|
302
|
+
For Second Life's Linden Scripting Language source code.
|
303
|
+
|
304
|
+
.. versionadded:: 2.0
|
305
|
+
"""
|
306
|
+
|
307
|
+
name = 'LSL'
|
308
|
+
aliases = ['lsl']
|
309
|
+
filenames = ['*.lsl']
|
310
|
+
mimetypes = ['text/x-lsl']
|
311
|
+
|
312
|
+
flags = re.MULTILINE
|
313
|
+
|
314
|
+
lsl_keywords = r'\b(?:do|else|for|if|jump|return|while)\b'
|
315
|
+
lsl_types = r'\b(?:float|integer|key|list|quaternion|rotation|string|vector)\b'
|
316
|
+
lsl_states = r'\b(?:(?:state)\s+\w+|default)\b'
|
317
|
+
lsl_events = r'\b(?:state_(?:entry|exit)|touch(?:_(?:start|end))?|(?:land_)?collision(?:_(?:start|end))?|timer|listen|(?:no_)?sensor|control|(?:not_)?at_(?:rot_)?target|money|email|run_time_permissions|changed|attach|dataserver|moving_(?:start|end)|link_message|(?:on|object)_rez|remote_data|http_re(?:sponse|quest)|path_update|transaction_result)\b'
|
318
|
+
lsl_functions_builtin = r'\b(?:ll(?:ReturnObjectsBy(?:ID|Owner)|Json(?:2List|[GS]etValue|ValueType)|Sin|Cos|Tan|Atan2|Sqrt|Pow|Abs|Fabs|Frand|Floor|Ceil|Round|Vec(?:Mag|Norm|Dist)|Rot(?:Between|2(?:Euler|Fwd|Left|Up))|(?:Euler|Axes)2Rot|Whisper|(?:Region|Owner)?Say|Shout|Listen(?:Control|Remove)?|Sensor(?:Repeat|Remove)?|Detected(?:Name|Key|Owner|Type|Pos|Vel|Grab|Rot|Group|LinkNumber)|Die|Ground|Wind|(?:[GS]et)(?:AnimationOverride|MemoryLimit|PrimMediaParams|ParcelMusicURL|Object(?:Desc|Name)|PhysicsMaterial|Status|Scale|Color|Alpha|Texture|Pos|Rot|Force|Torque)|ResetAnimationOverride|(?:Scale|Offset|Rotate)Texture|(?:Rot)?Target(?:Remove)?|(?:Stop)?MoveToTarget|Apply(?:Rotational)?Impulse|Set(?:KeyframedMotion|ContentType|RegionPos|(?:Angular)?Velocity|Buoyancy|HoverHeight|ForceAndTorque|TimerEvent|ScriptState|Damage|TextureAnim|Sound(?:Queueing|Radius)|Vehicle(?:Type|(?:Float|Vector|Rotation)Param)|(?:Touch|Sit)?Text|Camera(?:Eye|At)Offset|PrimitiveParams|ClickAction|Link(?:Alpha|Color|PrimitiveParams(?:Fast)?|Texture(?:Anim)?|Camera|Media)|RemoteScriptAccessPin|PayPrice|LocalRot)|ScaleByFactor|Get(?:(?:Max|Min)ScaleFactor|ClosestNavPoint|StaticPath|SimStats|Env|PrimitiveParams|Link(?:PrimitiveParams|Number(?:OfSides)?|Key|Name|Media)|HTTPHeader|FreeURLs|Object(?:Details|PermMask|PrimCount)|Parcel(?:MaxPrims|Details|Prim(?:Count|Owners))|Attached|(?:SPMax|Free|Used)Memory|Region(?:Name|TimeDilation|FPS|Corner|AgentCount)|Root(?:Position|Rotation)|UnixTime|(?:Parcel|Region)Flags|(?:Wall|GMT)clock|SimulatorHostname|BoundingBox|GeometricCenter|Creator|NumberOf(?:Prims|NotecardLines|Sides)|Animation(?:List)?|(?:Camera|Local)(?:Pos|Rot)|Vel|Accel|Omega|Time(?:stamp|OfDay)|(?:Object|CenterOf)?Mass|MassMKS|Energy|Owner|(?:Owner)?Key|SunDirection|Texture(?:Offset|Scale|Rot)|Inventory(?:Number|Name|Key|Type|Creator|PermMask)|Permissions(?:Key)?|StartParameter|List(?:Length|EntryType)|Date|Agent(?:Size|Info|Language|List)|LandOwnerAt|NotecardLine|Script(?:Name|State))|(?:Get|Reset|GetAndReset)Time|PlaySound(?:Slave)?|LoopSound(?:Master|Slave)?|(?:Trigger|Stop|Preload)Sound|(?:(?:Get|Delete)Sub|Insert)String|To(?:Upper|Lower)|Give(?:InventoryList|Money)|RezObject|(?:Stop)?LookAt|Sleep|CollisionFilter|(?:Take|Release)Controls|DetachFromAvatar|AttachToAvatar(?:Temp)?|InstantMessage|(?:GetNext)?Email|StopHover|MinEventDelay|RotLookAt|String(?:Length|Trim)|(?:Start|Stop)Animation|TargetOmega|RequestPermissions|(?:Create|Break)Link|BreakAllLinks|(?:Give|Remove)Inventory|Water|PassTouches|Request(?:Agent|Inventory)Data|TeleportAgent(?:Home|GlobalCoords)?|ModifyLand|CollisionSound|ResetScript|MessageLinked|PushObject|PassCollisions|AxisAngle2Rot|Rot2(?:Axis|Angle)|A(?:cos|sin)|AngleBetween|AllowInventoryDrop|SubStringIndex|List2(?:CSV|Integer|Json|Float|String|Key|Vector|Rot|List(?:Strided)?)|DeleteSubList|List(?:Statistics|Sort|Randomize|(?:Insert|Find|Replace)List)|EdgeOfWorld|AdjustSoundVolume|Key2Name|TriggerSoundLimited|EjectFromLand|(?:CSV|ParseString)2List|OverMyLand|SameGroup|UnSit|Ground(?:Slope|Normal|Contour)|GroundRepel|(?:Set|Remove)VehicleFlags|(?:AvatarOn)?(?:Link)?SitTarget|Script(?:Danger|Profiler)|Dialog|VolumeDetect|ResetOtherScript|RemoteLoadScriptPin|(?:Open|Close)RemoteDataChannel|SendRemoteData|RemoteDataReply|(?:Integer|String)ToBase64|XorBase64|Log(?:10)?|Base64To(?:String|Integer)|ParseStringKeepNulls|RezAtRoot|RequestSimulatorData|ForceMouselook|(?:Load|Release|(?:E|Une)scape)URL|ParcelMedia(?:CommandList|Query)|ModPow|MapDestination|(?:RemoveFrom|AddTo|Reset)Land(?:Pass|Ban)List|(?:Set|Clear)CameraParams|HTTP(?:Request|Response)|TextBox|DetectedTouch(?:UV|Face|Pos|(?:N|Bin)ormal|ST)|(?:MD5|SHA1|DumpList2)String|Request(?:Secure)?URL|Clear(?:Prim|Link)Media|(?:Link)?ParticleSystem|(?:Get|Request)(?:Username|DisplayName)|RegionSayTo|CastRay|GenerateKey|TransferLindenDollars|ManageEstateAccess|(?:Create|Delete)Character|ExecCharacterCmd|Evade|FleeFrom|NavigateTo|PatrolPoints|Pursue|UpdateCharacter|WanderWithin))\b'
|
319
|
+
lsl_constants_float = r'\b(?:DEG_TO_RAD|PI(?:_BY_TWO)?|RAD_TO_DEG|SQRT2|TWO_PI)\b'
|
320
|
+
lsl_constants_integer = r'\b(?:JSON_APPEND|STATUS_(?:PHYSICS|ROTATE_[XYZ]|PHANTOM|SANDBOX|BLOCK_GRAB(?:_OBJECT)?|(?:DIE|RETURN)_AT_EDGE|CAST_SHADOWS|OK|MALFORMED_PARAMS|TYPE_MISMATCH|BOUNDS_ERROR|NOT_(?:FOUND|SUPPORTED)|INTERNAL_ERROR|WHITELIST_FAILED)|AGENT(?:_(?:BY_(?:LEGACY_|USER)NAME|FLYING|ATTACHMENTS|SCRIPTED|MOUSELOOK|SITTING|ON_OBJECT|AWAY|WALKING|IN_AIR|TYPING|CROUCHING|BUSY|ALWAYS_RUN|AUTOPILOT|LIST_(?:PARCEL(?:_OWNER)?|REGION)))?|CAMERA_(?:PITCH|DISTANCE|BEHINDNESS_(?:ANGLE|LAG)|(?:FOCUS|POSITION)(?:_(?:THRESHOLD|LOCKED|LAG))?|FOCUS_OFFSET|ACTIVE)|ANIM_ON|LOOP|REVERSE|PING_PONG|SMOOTH|ROTATE|SCALE|ALL_SIDES|LINK_(?:ROOT|SET|ALL_(?:OTHERS|CHILDREN)|THIS)|ACTIVE|PASSIVE|SCRIPTED|CONTROL_(?:FWD|BACK|(?:ROT_)?(?:LEFT|RIGHT)|UP|DOWN|(?:ML_)?LBUTTON)|PERMISSION_(?:RETURN_OBJECTS|DEBIT|OVERRIDE_ANIMATIONS|SILENT_ESTATE_MANAGEMENT|TAKE_CONTROLS|TRIGGER_ANIMATION|ATTACH|CHANGE_LINKS|(?:CONTROL|TRACK)_CAMERA|TELEPORT)|INVENTORY_(?:TEXTURE|SOUND|OBJECT|SCRIPT|LANDMARK|CLOTHING|NOTECARD|BODYPART|ANIMATION|GESTURE|ALL|NONE)|CHANGED_(?:INVENTORY|COLOR|SHAPE|SCALE|TEXTURE|LINK|ALLOWED_DROP|OWNER|REGION(?:_START)?|TELEPORT|MEDIA)|OBJECT_(?:(?:PHYSICS|SERVER|STREAMING)_COST|UNKNOWN_DETAIL|CHARACTER_TIME|PHANTOM|PHYSICS|TEMP_ON_REZ|NAME|DESC|POS|PRIM_EQUIVALENCE|RETURN_(?:PARCEL(?:_OWNER)?|REGION)|ROO?T|VELOCITY|OWNER|GROUP|CREATOR|ATTACHED_POINT|RENDER_WEIGHT|PATHFINDING_TYPE|(?:RUNNING|TOTAL)_SCRIPT_COUNT|SCRIPT_(?:MEMORY|TIME))|TYPE_(?:INTEGER|FLOAT|STRING|KEY|VECTOR|ROTATION|INVALID)|(?:DEBUG|PUBLIC)_CHANNEL|ATTACH_(?:AVATAR_CENTER|CHEST|HEAD|BACK|PELVIS|MOUTH|CHIN|NECK|NOSE|BELLY|[LR](?:SHOULDER|HAND|FOOT|EAR|EYE|[UL](?:ARM|LEG)|HIP)|(?:LEFT|RIGHT)_PEC|HUD_(?:CENTER_[12]|TOP_(?:RIGHT|CENTER|LEFT)|BOTTOM(?:_(?:RIGHT|LEFT))?))|LAND_(?:LEVEL|RAISE|LOWER|SMOOTH|NOISE|REVERT)|DATA_(?:ONLINE|NAME|BORN|SIM_(?:POS|STATUS|RATING)|PAYINFO)|PAYMENT_INFO_(?:ON_FILE|USED)|REMOTE_DATA_(?:CHANNEL|REQUEST|REPLY)|PSYS_(?:PART_(?:BF_(?:ZERO|ONE(?:_MINUS_(?:DEST_COLOR|SOURCE_(ALPHA|COLOR)))?|DEST_COLOR|SOURCE_(ALPHA|COLOR))|BLEND_FUNC_(DEST|SOURCE)|FLAGS|(?:START|END)_(?:COLOR|ALPHA|SCALE|GLOW)|MAX_AGE|(?:RIBBON|WIND|INTERP_(?:COLOR|SCALE)|BOUNCE|FOLLOW_(?:SRC|VELOCITY)|TARGET_(?:POS|LINEAR)|EMISSIVE)_MASK)|SRC_(?:MAX_AGE|PATTERN|ANGLE_(?:BEGIN|END)|BURST_(?:RATE|PART_COUNT|RADIUS|SPEED_(?:MIN|MAX))|ACCEL|TEXTURE|TARGET_KEY|OMEGA|PATTERN_(?:DROP|EXPLODE|ANGLE(?:_CONE(?:_EMPTY)?)?)))|VEHICLE_(?:REFERENCE_FRAME|TYPE_(?:NONE|SLED|CAR|BOAT|AIRPLANE|BALLOON)|(?:LINEAR|ANGULAR)_(?:FRICTION_TIMESCALE|MOTOR_DIRECTION)|LINEAR_MOTOR_OFFSET|HOVER_(?:HEIGHT|EFFICIENCY|TIMESCALE)|BUOYANCY|(?:LINEAR|ANGULAR)_(?:DEFLECTION_(?:EFFICIENCY|TIMESCALE)|MOTOR_(?:DECAY_)?TIMESCALE)|VERTICAL_ATTRACTION_(?:EFFICIENCY|TIMESCALE)|BANKING_(?:EFFICIENCY|MIX|TIMESCALE)|FLAG_(?:NO_DEFLECTION_UP|LIMIT_(?:ROLL_ONLY|MOTOR_UP)|HOVER_(?:(?:WATER|TERRAIN|UP)_ONLY|GLOBAL_HEIGHT)|MOUSELOOK_(?:STEER|BANK)|CAMERA_DECOUPLED))|PRIM_(?:TYPE(?:_(?:BOX|CYLINDER|PRISM|SPHERE|TORUS|TUBE|RING|SCULPT))?|HOLE_(?:DEFAULT|CIRCLE|SQUARE|TRIANGLE)|MATERIAL(?:_(?:STONE|METAL|GLASS|WOOD|FLESH|PLASTIC|RUBBER))?|SHINY_(?:NONE|LOW|MEDIUM|HIGH)|BUMP_(?:NONE|BRIGHT|DARK|WOOD|BARK|BRICKS|CHECKER|CONCRETE|TILE|STONE|DISKS|GRAVEL|BLOBS|SIDING|LARGETILE|STUCCO|SUCTION|WEAVE)|TEXGEN_(?:DEFAULT|PLANAR)|SCULPT_(?:TYPE_(?:SPHERE|TORUS|PLANE|CYLINDER|MASK)|FLAG_(?:MIRROR|INVERT))|PHYSICS(?:_(?:SHAPE_(?:CONVEX|NONE|PRIM|TYPE)))?|(?:POS|ROT)_LOCAL|SLICE|TEXT|FLEXIBLE|POINT_LIGHT|TEMP_ON_REZ|PHANTOM|POSITION|SIZE|ROTATION|TEXTURE|NAME|OMEGA|DESC|LINK_TARGET|COLOR|BUMP_SHINY|FULLBRIGHT|TEXGEN|GLOW|MEDIA_(?:ALT_IMAGE_ENABLE|CONTROLS|(?:CURRENT|HOME)_URL|AUTO_(?:LOOP|PLAY|SCALE|ZOOM)|FIRST_CLICK_INTERACT|(?:WIDTH|HEIGHT)_PIXELS|WHITELIST(?:_ENABLE)?|PERMS_(?:INTERACT|CONTROL)|PARAM_MAX|CONTROLS_(?:STANDARD|MINI)|PERM_(?:NONE|OWNER|GROUP|ANYONE)|MAX_(?:URL_LENGTH|WHITELIST_(?:SIZE|COUNT)|(?:WIDTH|HEIGHT)_PIXELS)))|MASK_(?:BASE|OWNER|GROUP|EVERYONE|NEXT)|PERM_(?:TRANSFER|MODIFY|COPY|MOVE|ALL)|PARCEL_(?:MEDIA_COMMAND_(?:STOP|PAUSE|PLAY|LOOP|TEXTURE|URL|TIME|AGENT|UNLOAD|AUTO_ALIGN|TYPE|SIZE|DESC|LOOP_SET)|FLAG_(?:ALLOW_(?:FLY|(?:GROUP_)?SCRIPTS|LANDMARK|TERRAFORM|DAMAGE|CREATE_(?:GROUP_)?OBJECTS)|USE_(?:ACCESS_(?:GROUP|LIST)|BAN_LIST|LAND_PASS_LIST)|LOCAL_SOUND_ONLY|RESTRICT_PUSHOBJECT|ALLOW_(?:GROUP|ALL)_OBJECT_ENTRY)|COUNT_(?:TOTAL|OWNER|GROUP|OTHER|SELECTED|TEMP)|DETAILS_(?:NAME|DESC|OWNER|GROUP|AREA|ID|SEE_AVATARS))|LIST_STAT_(?:MAX|MIN|MEAN|MEDIAN|STD_DEV|SUM(?:_SQUARES)?|NUM_COUNT|GEOMETRIC_MEAN|RANGE)|PAY_(?:HIDE|DEFAULT)|REGION_FLAG_(?:ALLOW_DAMAGE|FIXED_SUN|BLOCK_TERRAFORM|SANDBOX|DISABLE_(?:COLLISIONS|PHYSICS)|BLOCK_FLY|ALLOW_DIRECT_TELEPORT|RESTRICT_PUSHOBJECT)|HTTP_(?:METHOD|MIMETYPE|BODY_(?:MAXLENGTH|TRUNCATED)|CUSTOM_HEADER|PRAGMA_NO_CACHE|VERBOSE_THROTTLE|VERIFY_CERT)|STRING_(?:TRIM(?:_(?:HEAD|TAIL))?)|CLICK_ACTION_(?:NONE|TOUCH|SIT|BUY|PAY|OPEN(?:_MEDIA)?|PLAY|ZOOM)|TOUCH_INVALID_FACE|PROFILE_(?:NONE|SCRIPT_MEMORY)|RC_(?:DATA_FLAGS|DETECT_PHANTOM|GET_(?:LINK_NUM|NORMAL|ROOT_KEY)|MAX_HITS|REJECT_(?:TYPES|AGENTS|(?:NON)?PHYSICAL|LAND))|RCERR_(?:CAST_TIME_EXCEEDED|SIM_PERF_LOW|UNKNOWN)|ESTATE_ACCESS_(?:ALLOWED_(?:AGENT|GROUP)_(?:ADD|REMOVE)|BANNED_AGENT_(?:ADD|REMOVE))|DENSITY|FRICTION|RESTITUTION|GRAVITY_MULTIPLIER|KFM_(?:COMMAND|CMD_(?:PLAY|STOP|PAUSE|SET_MODE)|MODE|FORWARD|LOOP|PING_PONG|REVERSE|DATA|ROTATION|TRANSLATION)|ERR_(?:GENERIC|PARCEL_PERMISSIONS|MALFORMED_PARAMS|RUNTIME_PERMISSIONS|THROTTLED)|CHARACTER_(?:CMD_(?:(?:SMOOTH_)?STOP|JUMP)|DESIRED_(?:TURN_)?SPEED|RADIUS|STAY_WITHIN_PARCEL|LENGTH|ORIENTATION|ACCOUNT_FOR_SKIPPED_FRAMES|AVOIDANCE_MODE|TYPE(?:_(?:[A-D]|NONE))?|MAX_(?:DECEL|TURN_RADIUS|(?:ACCEL|SPEED)))|PURSUIT_(?:OFFSET|FUZZ_FACTOR|GOAL_TOLERANCE|INTERCEPT)|REQUIRE_LINE_OF_SIGHT|FORCE_DIRECT_PATH|VERTICAL|HORIZONTAL|AVOID_(?:CHARACTERS|DYNAMIC_OBSTACLES|NONE)|PU_(?:EVADE_(?:HIDDEN|SPOTTED)|FAILURE_(?:DYNAMIC_PATHFINDING_DISABLED|INVALID_(?:GOAL|START)|NO_(?:NAVMESH|VALID_DESTINATION)|OTHER|TARGET_GONE|(?:PARCEL_)?UNREACHABLE)|(?:GOAL|SLOWDOWN_DISTANCE)_REACHED)|TRAVERSAL_TYPE(?:_(?:FAST|NONE|SLOW))?|CONTENT_TYPE_(?:ATOM|FORM|HTML|JSON|LLSD|RSS|TEXT|XHTML|XML)|GCNP_(?:RADIUS|STATIC)|(?:PATROL|WANDER)_PAUSE_AT_WAYPOINTS|OPT_(?:AVATAR|CHARACTER|EXCLUSION_VOLUME|LEGACY_LINKSET|MATERIAL_VOLUME|OTHER|STATIC_OBSTACLE|WALKABLE)|SIM_STAT_PCT_CHARS_STEPPED)\b'
|
321
|
+
lsl_constants_integer_boolean = r'\b(?:FALSE|TRUE)\b'
|
322
|
+
lsl_constants_rotation = r'\b(?:ZERO_ROTATION)\b'
|
323
|
+
lsl_constants_string = r'\b(?:EOF|JSON_(?:ARRAY|DELETE|FALSE|INVALID|NULL|NUMBER|OBJECT|STRING|TRUE)|NULL_KEY|TEXTURE_(?:BLANK|DEFAULT|MEDIA|PLYWOOD|TRANSPARENT)|URL_REQUEST_(?:GRANTED|DENIED))\b'
|
324
|
+
lsl_constants_vector = r'\b(?:TOUCH_INVALID_(?:TEXCOORD|VECTOR)|ZERO_VECTOR)\b'
|
325
|
+
lsl_invalid_broken = r'\b(?:LAND_(?:LARGE|MEDIUM|SMALL)_BRUSH)\b'
|
326
|
+
lsl_invalid_deprecated = r'\b(?:ATTACH_[LR]PEC|DATA_RATING|OBJECT_ATTACHMENT_(?:GEOMETRY_BYTES|SURFACE_AREA)|PRIM_(?:CAST_SHADOWS|MATERIAL_LIGHT|TYPE_LEGACY)|PSYS_SRC_(?:INNER|OUTER)ANGLE|VEHICLE_FLAG_NO_FLY_UP|ll(?:Cloud|Make(?:Explosion|Fountain|Smoke|Fire)|RemoteDataSetRegion|Sound(?:Preload)?|XorBase64Strings(?:Correct)?))\b'
|
327
|
+
lsl_invalid_illegal = r'\b(?:event)\b'
|
328
|
+
lsl_invalid_unimplemented = r'\b(?:CHARACTER_(?:MAX_ANGULAR_(?:ACCEL|SPEED)|TURN_SPEED_MULTIPLIER)|PERMISSION_(?:CHANGE_(?:JOINTS|PERMISSIONS)|RELEASE_OWNERSHIP|REMAP_CONTROLS)|PRIM_PHYSICS_MATERIAL|PSYS_SRC_OBJ_REL_MASK|ll(?:CollisionSprite|(?:Stop)?PointAt|(?:(?:Refresh|Set)Prim)URL|(?:Take|Release)Camera|RemoteLoadScript))\b'
|
329
|
+
lsl_reserved_godmode = r'\b(?:ll(?:GodLikeRezObject|Set(?:Inventory|Object)PermMask))\b'
|
330
|
+
lsl_reserved_log = r'\b(?:print)\b'
|
331
|
+
lsl_operators = r'\+\+|\-\-|<<|>>|&&?|\|\|?|\^|~|[!%<>=*+\-/]=?'
|
332
|
+
|
333
|
+
tokens = {
|
334
|
+
'root':
|
335
|
+
[
|
336
|
+
(r'//.*?\n', Comment.Single),
|
337
|
+
(r'/\*', Comment.Multiline, 'comment'),
|
338
|
+
(r'"', String.Double, 'string'),
|
339
|
+
(lsl_keywords, Keyword),
|
340
|
+
(lsl_types, Keyword.Type),
|
341
|
+
(lsl_states, Name.Class),
|
342
|
+
(lsl_events, Name.Builtin),
|
343
|
+
(lsl_functions_builtin, Name.Function),
|
344
|
+
(lsl_constants_float, Keyword.Constant),
|
345
|
+
(lsl_constants_integer, Keyword.Constant),
|
346
|
+
(lsl_constants_integer_boolean, Keyword.Constant),
|
347
|
+
(lsl_constants_rotation, Keyword.Constant),
|
348
|
+
(lsl_constants_string, Keyword.Constant),
|
349
|
+
(lsl_constants_vector, Keyword.Constant),
|
350
|
+
(lsl_invalid_broken, Error),
|
351
|
+
(lsl_invalid_deprecated, Error),
|
352
|
+
(lsl_invalid_illegal, Error),
|
353
|
+
(lsl_invalid_unimplemented, Error),
|
354
|
+
(lsl_reserved_godmode, Keyword.Reserved),
|
355
|
+
(lsl_reserved_log, Keyword.Reserved),
|
356
|
+
(r'\b([a-zA-Z_]\w*)\b', Name.Variable),
|
357
|
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d*', Number.Float),
|
358
|
+
(r'(\d+\.\d*|\.\d+)', Number.Float),
|
359
|
+
(r'0[xX][0-9a-fA-F]+', Number.Hex),
|
360
|
+
(r'\d+', Number.Integer),
|
361
|
+
(lsl_operators, Operator),
|
362
|
+
(r':=?', Error),
|
363
|
+
(r'[,;{}()\[\]]', Punctuation),
|
364
|
+
(r'\n+', Whitespace),
|
365
|
+
(r'\s+', Whitespace)
|
366
|
+
],
|
367
|
+
'comment':
|
368
|
+
[
|
369
|
+
(r'[^*/]+', Comment.Multiline),
|
370
|
+
(r'/\*', Comment.Multiline, '#push'),
|
371
|
+
(r'\*/', Comment.Multiline, '#pop'),
|
372
|
+
(r'[*/]', Comment.Multiline)
|
373
|
+
],
|
374
|
+
'string':
|
375
|
+
[
|
376
|
+
(r'\\([nt"\\])', String.Escape),
|
377
|
+
(r'"', String.Double, '#pop'),
|
378
|
+
(r'\\.', Error),
|
379
|
+
(r'[^"\\]+', String.Double),
|
380
|
+
]
|
381
|
+
}
|
382
|
+
|
383
|
+
|
384
|
+
class AppleScriptLexer(RegexLexer):
|
385
|
+
"""
|
386
|
+
For `AppleScript source code
|
387
|
+
<http://developer.apple.com/documentation/AppleScript/
|
388
|
+
Conceptual/AppleScriptLangGuide>`_,
|
389
|
+
including `AppleScript Studio
|
390
|
+
<http://developer.apple.com/documentation/AppleScript/
|
391
|
+
Reference/StudioReference>`_.
|
392
|
+
Contributed by Andreas Amann <aamann@mac.com>.
|
393
|
+
|
394
|
+
.. versionadded:: 1.0
|
395
|
+
"""
|
396
|
+
|
397
|
+
name = 'AppleScript'
|
398
|
+
aliases = ['applescript']
|
399
|
+
filenames = ['*.applescript']
|
400
|
+
|
401
|
+
flags = re.MULTILINE | re.DOTALL
|
402
|
+
|
403
|
+
Identifiers = r'[a-zA-Z]\w*'
|
404
|
+
|
405
|
+
# XXX: use words() for all of these
|
406
|
+
Literals = ('AppleScript', 'current application', 'false', 'linefeed',
|
407
|
+
'missing value', 'pi', 'quote', 'result', 'return', 'space',
|
408
|
+
'tab', 'text item delimiters', 'true', 'version')
|
409
|
+
Classes = ('alias ', 'application ', 'boolean ', 'class ', 'constant ',
|
410
|
+
'date ', 'file ', 'integer ', 'list ', 'number ', 'POSIX file ',
|
411
|
+
'real ', 'record ', 'reference ', 'RGB color ', 'script ',
|
412
|
+
'text ', 'unit types', '(?:Unicode )?text', 'string')
|
413
|
+
BuiltIn = ('attachment', 'attribute run', 'character', 'day', 'month',
|
414
|
+
'paragraph', 'word', 'year')
|
415
|
+
HandlerParams = ('about', 'above', 'against', 'apart from', 'around',
|
416
|
+
'aside from', 'at', 'below', 'beneath', 'beside',
|
417
|
+
'between', 'for', 'given', 'instead of', 'on', 'onto',
|
418
|
+
'out of', 'over', 'since')
|
419
|
+
Commands = ('ASCII (character|number)', 'activate', 'beep', 'choose URL',
|
420
|
+
'choose application', 'choose color', 'choose file( name)?',
|
421
|
+
'choose folder', 'choose from list',
|
422
|
+
'choose remote application', 'clipboard info',
|
423
|
+
'close( access)?', 'copy', 'count', 'current date', 'delay',
|
424
|
+
'delete', 'display (alert|dialog)', 'do shell script',
|
425
|
+
'duplicate', 'exists', 'get eof', 'get volume settings',
|
426
|
+
'info for', 'launch', 'list (disks|folder)', 'load script',
|
427
|
+
'log', 'make', 'mount volume', 'new', 'offset',
|
428
|
+
'open( (for access|location))?', 'path to', 'print', 'quit',
|
429
|
+
'random number', 'read', 'round', 'run( script)?',
|
430
|
+
'say', 'scripting components',
|
431
|
+
'set (eof|the clipboard to|volume)', 'store script',
|
432
|
+
'summarize', 'system attribute', 'system info',
|
433
|
+
'the clipboard', 'time to GMT', 'write', 'quoted form')
|
434
|
+
References = ('(in )?back of', '(in )?front of', '[0-9]+(st|nd|rd|th)',
|
435
|
+
'first', 'second', 'third', 'fourth', 'fifth', 'sixth',
|
436
|
+
'seventh', 'eighth', 'ninth', 'tenth', 'after', 'back',
|
437
|
+
'before', 'behind', 'every', 'front', 'index', 'last',
|
438
|
+
'middle', 'some', 'that', 'through', 'thru', 'where', 'whose')
|
439
|
+
Operators = ("and", "or", "is equal", "equals", "(is )?equal to", "is not",
|
440
|
+
"isn't", "isn't equal( to)?", "is not equal( to)?",
|
441
|
+
"doesn't equal", "does not equal", "(is )?greater than",
|
442
|
+
"comes after", "is not less than or equal( to)?",
|
443
|
+
"isn't less than or equal( to)?", "(is )?less than",
|
444
|
+
"comes before", "is not greater than or equal( to)?",
|
445
|
+
"isn't greater than or equal( to)?",
|
446
|
+
"(is )?greater than or equal( to)?", "is not less than",
|
447
|
+
"isn't less than", "does not come before",
|
448
|
+
"doesn't come before", "(is )?less than or equal( to)?",
|
449
|
+
"is not greater than", "isn't greater than",
|
450
|
+
"does not come after", "doesn't come after", "starts? with",
|
451
|
+
"begins? with", "ends? with", "contains?", "does not contain",
|
452
|
+
"doesn't contain", "is in", "is contained by", "is not in",
|
453
|
+
"is not contained by", "isn't contained by", "div", "mod",
|
454
|
+
"not", "(a )?(ref( to)?|reference to)", "is", "does")
|
455
|
+
Control = ('considering', 'else', 'error', 'exit', 'from', 'if',
|
456
|
+
'ignoring', 'in', 'repeat', 'tell', 'then', 'times', 'to',
|
457
|
+
'try', 'until', 'using terms from', 'while', 'whith',
|
458
|
+
'with timeout( of)?', 'with transaction', 'by', 'continue',
|
459
|
+
'end', 'its?', 'me', 'my', 'return', 'of', 'as')
|
460
|
+
Declarations = ('global', 'local', 'prop(erty)?', 'set', 'get')
|
461
|
+
Reserved = ('but', 'put', 'returning', 'the')
|
462
|
+
StudioClasses = ('action cell', 'alert reply', 'application', 'box',
|
463
|
+
'browser( cell)?', 'bundle', 'button( cell)?', 'cell',
|
464
|
+
'clip view', 'color well', 'color-panel',
|
465
|
+
'combo box( item)?', 'control',
|
466
|
+
'data( (cell|column|item|row|source))?', 'default entry',
|
467
|
+
'dialog reply', 'document', 'drag info', 'drawer',
|
468
|
+
'event', 'font(-panel)?', 'formatter',
|
469
|
+
'image( (cell|view))?', 'matrix', 'menu( item)?', 'item',
|
470
|
+
'movie( view)?', 'open-panel', 'outline view', 'panel',
|
471
|
+
'pasteboard', 'plugin', 'popup button',
|
472
|
+
'progress indicator', 'responder', 'save-panel',
|
473
|
+
'scroll view', 'secure text field( cell)?', 'slider',
|
474
|
+
'sound', 'split view', 'stepper', 'tab view( item)?',
|
475
|
+
'table( (column|header cell|header view|view))',
|
476
|
+
'text( (field( cell)?|view))?', 'toolbar( item)?',
|
477
|
+
'user-defaults', 'view', 'window')
|
478
|
+
StudioEvents = ('accept outline drop', 'accept table drop', 'action',
|
479
|
+
'activated', 'alert ended', 'awake from nib', 'became key',
|
480
|
+
'became main', 'begin editing', 'bounds changed',
|
481
|
+
'cell value', 'cell value changed', 'change cell value',
|
482
|
+
'change item value', 'changed', 'child of item',
|
483
|
+
'choose menu item', 'clicked', 'clicked toolbar item',
|
484
|
+
'closed', 'column clicked', 'column moved',
|
485
|
+
'column resized', 'conclude drop', 'data representation',
|
486
|
+
'deminiaturized', 'dialog ended', 'document nib name',
|
487
|
+
'double clicked', 'drag( (entered|exited|updated))?',
|
488
|
+
'drop', 'end editing', 'exposed', 'idle', 'item expandable',
|
489
|
+
'item value', 'item value changed', 'items changed',
|
490
|
+
'keyboard down', 'keyboard up', 'launched',
|
491
|
+
'load data representation', 'miniaturized', 'mouse down',
|
492
|
+
'mouse dragged', 'mouse entered', 'mouse exited',
|
493
|
+
'mouse moved', 'mouse up', 'moved',
|
494
|
+
'number of browser rows', 'number of items',
|
495
|
+
'number of rows', 'open untitled', 'opened', 'panel ended',
|
496
|
+
'parameters updated', 'plugin loaded', 'prepare drop',
|
497
|
+
'prepare outline drag', 'prepare outline drop',
|
498
|
+
'prepare table drag', 'prepare table drop',
|
499
|
+
'read from file', 'resigned active', 'resigned key',
|
500
|
+
'resigned main', 'resized( sub views)?',
|
501
|
+
'right mouse down', 'right mouse dragged',
|
502
|
+
'right mouse up', 'rows changed', 'scroll wheel',
|
503
|
+
'selected tab view item', 'selection changed',
|
504
|
+
'selection changing', 'should begin editing',
|
505
|
+
'should close', 'should collapse item',
|
506
|
+
'should end editing', 'should expand item',
|
507
|
+
'should open( untitled)?',
|
508
|
+
'should quit( after last window closed)?',
|
509
|
+
'should select column', 'should select item',
|
510
|
+
'should select row', 'should select tab view item',
|
511
|
+
'should selection change', 'should zoom', 'shown',
|
512
|
+
'update menu item', 'update parameters',
|
513
|
+
'update toolbar item', 'was hidden', 'was miniaturized',
|
514
|
+
'will become active', 'will close', 'will dismiss',
|
515
|
+
'will display browser cell', 'will display cell',
|
516
|
+
'will display item cell', 'will display outline cell',
|
517
|
+
'will finish launching', 'will hide', 'will miniaturize',
|
518
|
+
'will move', 'will open', 'will pop up', 'will quit',
|
519
|
+
'will resign active', 'will resize( sub views)?',
|
520
|
+
'will select tab view item', 'will show', 'will zoom',
|
521
|
+
'write to file', 'zoomed')
|
522
|
+
StudioCommands = ('animate', 'append', 'call method', 'center',
|
523
|
+
'close drawer', 'close panel', 'display',
|
524
|
+
'display alert', 'display dialog', 'display panel', 'go',
|
525
|
+
'hide', 'highlight', 'increment', 'item for',
|
526
|
+
'load image', 'load movie', 'load nib', 'load panel',
|
527
|
+
'load sound', 'localized string', 'lock focus', 'log',
|
528
|
+
'open drawer', 'path for', 'pause', 'perform action',
|
529
|
+
'play', 'register', 'resume', 'scroll', 'select( all)?',
|
530
|
+
'show', 'size to fit', 'start', 'step back',
|
531
|
+
'step forward', 'stop', 'synchronize', 'unlock focus',
|
532
|
+
'update')
|
533
|
+
StudioProperties = ('accepts arrow key', 'action method', 'active',
|
534
|
+
'alignment', 'allowed identifiers',
|
535
|
+
'allows branch selection', 'allows column reordering',
|
536
|
+
'allows column resizing', 'allows column selection',
|
537
|
+
'allows customization',
|
538
|
+
'allows editing text attributes',
|
539
|
+
'allows empty selection', 'allows mixed state',
|
540
|
+
'allows multiple selection', 'allows reordering',
|
541
|
+
'allows undo', 'alpha( value)?', 'alternate image',
|
542
|
+
'alternate increment value', 'alternate title',
|
543
|
+
'animation delay', 'associated file name',
|
544
|
+
'associated object', 'auto completes', 'auto display',
|
545
|
+
'auto enables items', 'auto repeat',
|
546
|
+
'auto resizes( outline column)?',
|
547
|
+
'auto save expanded items', 'auto save name',
|
548
|
+
'auto save table columns', 'auto saves configuration',
|
549
|
+
'auto scroll', 'auto sizes all columns to fit',
|
550
|
+
'auto sizes cells', 'background color', 'bezel state',
|
551
|
+
'bezel style', 'bezeled', 'border rect', 'border type',
|
552
|
+
'bordered', 'bounds( rotation)?', 'box type',
|
553
|
+
'button returned', 'button type',
|
554
|
+
'can choose directories', 'can choose files',
|
555
|
+
'can draw', 'can hide',
|
556
|
+
'cell( (background color|size|type))?', 'characters',
|
557
|
+
'class', 'click count', 'clicked( data)? column',
|
558
|
+
'clicked data item', 'clicked( data)? row',
|
559
|
+
'closeable', 'collating', 'color( (mode|panel))',
|
560
|
+
'command key down', 'configuration',
|
561
|
+
'content(s| (size|view( margins)?))?', 'context',
|
562
|
+
'continuous', 'control key down', 'control size',
|
563
|
+
'control tint', 'control view',
|
564
|
+
'controller visible', 'coordinate system',
|
565
|
+
'copies( on scroll)?', 'corner view', 'current cell',
|
566
|
+
'current column', 'current( field)? editor',
|
567
|
+
'current( menu)? item', 'current row',
|
568
|
+
'current tab view item', 'data source',
|
569
|
+
'default identifiers', 'delta (x|y|z)',
|
570
|
+
'destination window', 'directory', 'display mode',
|
571
|
+
'displayed cell', 'document( (edited|rect|view))?',
|
572
|
+
'double value', 'dragged column', 'dragged distance',
|
573
|
+
'dragged items', 'draws( cell)? background',
|
574
|
+
'draws grid', 'dynamically scrolls', 'echos bullets',
|
575
|
+
'edge', 'editable', 'edited( data)? column',
|
576
|
+
'edited data item', 'edited( data)? row', 'enabled',
|
577
|
+
'enclosing scroll view', 'ending page',
|
578
|
+
'error handling', 'event number', 'event type',
|
579
|
+
'excluded from windows menu', 'executable path',
|
580
|
+
'expanded', 'fax number', 'field editor', 'file kind',
|
581
|
+
'file name', 'file type', 'first responder',
|
582
|
+
'first visible column', 'flipped', 'floating',
|
583
|
+
'font( panel)?', 'formatter', 'frameworks path',
|
584
|
+
'frontmost', 'gave up', 'grid color', 'has data items',
|
585
|
+
'has horizontal ruler', 'has horizontal scroller',
|
586
|
+
'has parent data item', 'has resize indicator',
|
587
|
+
'has shadow', 'has sub menu', 'has vertical ruler',
|
588
|
+
'has vertical scroller', 'header cell', 'header view',
|
589
|
+
'hidden', 'hides when deactivated', 'highlights by',
|
590
|
+
'horizontal line scroll', 'horizontal page scroll',
|
591
|
+
'horizontal ruler view', 'horizontally resizable',
|
592
|
+
'icon image', 'id', 'identifier',
|
593
|
+
'ignores multiple clicks',
|
594
|
+
'image( (alignment|dims when disabled|frame style|scaling))?',
|
595
|
+
'imports graphics', 'increment value',
|
596
|
+
'indentation per level', 'indeterminate', 'index',
|
597
|
+
'integer value', 'intercell spacing', 'item height',
|
598
|
+
'key( (code|equivalent( modifier)?|window))?',
|
599
|
+
'knob thickness', 'label', 'last( visible)? column',
|
600
|
+
'leading offset', 'leaf', 'level', 'line scroll',
|
601
|
+
'loaded', 'localized sort', 'location', 'loop mode',
|
602
|
+
'main( (bunde|menu|window))?', 'marker follows cell',
|
603
|
+
'matrix mode', 'maximum( content)? size',
|
604
|
+
'maximum visible columns',
|
605
|
+
'menu( form representation)?', 'miniaturizable',
|
606
|
+
'miniaturized', 'minimized image', 'minimized title',
|
607
|
+
'minimum column width', 'minimum( content)? size',
|
608
|
+
'modal', 'modified', 'mouse down state',
|
609
|
+
'movie( (controller|file|rect))?', 'muted', 'name',
|
610
|
+
'needs display', 'next state', 'next text',
|
611
|
+
'number of tick marks', 'only tick mark values',
|
612
|
+
'opaque', 'open panel', 'option key down',
|
613
|
+
'outline table column', 'page scroll', 'pages across',
|
614
|
+
'pages down', 'palette label', 'pane splitter',
|
615
|
+
'parent data item', 'parent window', 'pasteboard',
|
616
|
+
'path( (names|separator))?', 'playing',
|
617
|
+
'plays every frame', 'plays selection only', 'position',
|
618
|
+
'preferred edge', 'preferred type', 'pressure',
|
619
|
+
'previous text', 'prompt', 'properties',
|
620
|
+
'prototype cell', 'pulls down', 'rate',
|
621
|
+
'released when closed', 'repeated',
|
622
|
+
'requested print time', 'required file type',
|
623
|
+
'resizable', 'resized column', 'resource path',
|
624
|
+
'returns records', 'reuses columns', 'rich text',
|
625
|
+
'roll over', 'row height', 'rulers visible',
|
626
|
+
'save panel', 'scripts path', 'scrollable',
|
627
|
+
'selectable( identifiers)?', 'selected cell',
|
628
|
+
'selected( data)? columns?', 'selected data items?',
|
629
|
+
'selected( data)? rows?', 'selected item identifier',
|
630
|
+
'selection by rect', 'send action on arrow key',
|
631
|
+
'sends action when done editing', 'separates columns',
|
632
|
+
'separator item', 'sequence number', 'services menu',
|
633
|
+
'shared frameworks path', 'shared support path',
|
634
|
+
'sheet', 'shift key down', 'shows alpha',
|
635
|
+
'shows state by', 'size( mode)?',
|
636
|
+
'smart insert delete enabled', 'sort case sensitivity',
|
637
|
+
'sort column', 'sort order', 'sort type',
|
638
|
+
'sorted( data rows)?', 'sound', 'source( mask)?',
|
639
|
+
'spell checking enabled', 'starting page', 'state',
|
640
|
+
'string value', 'sub menu', 'super menu', 'super view',
|
641
|
+
'tab key traverses cells', 'tab state', 'tab type',
|
642
|
+
'tab view', 'table view', 'tag', 'target( printer)?',
|
643
|
+
'text color', 'text container insert',
|
644
|
+
'text container origin', 'text returned',
|
645
|
+
'tick mark position', 'time stamp',
|
646
|
+
'title(d| (cell|font|height|position|rect))?',
|
647
|
+
'tool tip', 'toolbar', 'trailing offset', 'transparent',
|
648
|
+
'treat packages as directories', 'truncated labels',
|
649
|
+
'types', 'unmodified characters', 'update views',
|
650
|
+
'use sort indicator', 'user defaults',
|
651
|
+
'uses data source', 'uses ruler',
|
652
|
+
'uses threaded animation',
|
653
|
+
'uses title from previous column', 'value wraps',
|
654
|
+
'version',
|
655
|
+
'vertical( (line scroll|page scroll|ruler view))?',
|
656
|
+
'vertically resizable', 'view',
|
657
|
+
'visible( document rect)?', 'volume', 'width', 'window',
|
658
|
+
'windows menu', 'wraps', 'zoomable', 'zoomed')
|
659
|
+
|
660
|
+
tokens = {
|
661
|
+
'root': [
|
662
|
+
(r'\s+', Text),
|
663
|
+
(u'¬\\n', String.Escape),
|
664
|
+
(r"'s\s+", Text), # This is a possessive, consider moving
|
665
|
+
(r'(--|#).*?$', Comment),
|
666
|
+
(r'\(\*', Comment.Multiline, 'comment'),
|
667
|
+
(r'[(){}!,.:]', Punctuation),
|
668
|
+
(u'(«)([^»]+)(»)',
|
669
|
+
bygroups(Text, Name.Builtin, Text)),
|
670
|
+
(r'\b((?:considering|ignoring)\s*)'
|
671
|
+
r'(application responses|case|diacriticals|hyphens|'
|
672
|
+
r'numeric strings|punctuation|white space)',
|
673
|
+
bygroups(Keyword, Name.Builtin)),
|
674
|
+
(u'(-|\\*|\\+|&|≠|>=?|<=?|=|≥|≤|/|÷|\\^)', Operator),
|
675
|
+
(r"\b(%s)\b" % '|'.join(Operators), Operator.Word),
|
676
|
+
(r'^(\s*(?:on|end)\s+)'
|
677
|
+
r'(%s)' % '|'.join(StudioEvents[::-1]),
|
678
|
+
bygroups(Keyword, Name.Function)),
|
679
|
+
(r'^(\s*)(in|on|script|to)(\s+)', bygroups(Text, Keyword, Text)),
|
680
|
+
(r'\b(as )(%s)\b' % '|'.join(Classes),
|
681
|
+
bygroups(Keyword, Name.Class)),
|
682
|
+
(r'\b(%s)\b' % '|'.join(Literals), Name.Constant),
|
683
|
+
(r'\b(%s)\b' % '|'.join(Commands), Name.Builtin),
|
684
|
+
(r'\b(%s)\b' % '|'.join(Control), Keyword),
|
685
|
+
(r'\b(%s)\b' % '|'.join(Declarations), Keyword),
|
686
|
+
(r'\b(%s)\b' % '|'.join(Reserved), Name.Builtin),
|
687
|
+
(r'\b(%s)s?\b' % '|'.join(BuiltIn), Name.Builtin),
|
688
|
+
(r'\b(%s)\b' % '|'.join(HandlerParams), Name.Builtin),
|
689
|
+
(r'\b(%s)\b' % '|'.join(StudioProperties), Name.Attribute),
|
690
|
+
(r'\b(%s)s?\b' % '|'.join(StudioClasses), Name.Builtin),
|
691
|
+
(r'\b(%s)\b' % '|'.join(StudioCommands), Name.Builtin),
|
692
|
+
(r'\b(%s)\b' % '|'.join(References), Name.Builtin),
|
693
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
694
|
+
(r'\b(%s)\b' % Identifiers, Name.Variable),
|
695
|
+
(r'[-+]?(\d+\.\d*|\d*\.\d+)(E[-+][0-9]+)?', Number.Float),
|
696
|
+
(r'[-+]?\d+', Number.Integer),
|
697
|
+
],
|
698
|
+
'comment': [
|
699
|
+
('\(\*', Comment.Multiline, '#push'),
|
700
|
+
('\*\)', Comment.Multiline, '#pop'),
|
701
|
+
('[^*(]+', Comment.Multiline),
|
702
|
+
('[*(]', Comment.Multiline),
|
703
|
+
],
|
704
|
+
}
|
705
|
+
|
706
|
+
|
707
|
+
class RexxLexer(RegexLexer):
|
708
|
+
"""
|
709
|
+
`Rexx <http://www.rexxinfo.org/>`_ is a scripting language available for
|
710
|
+
a wide range of different platforms with its roots found on mainframe
|
711
|
+
systems. It is popular for I/O- and data based tasks and can act as glue
|
712
|
+
language to bind different applications together.
|
713
|
+
|
714
|
+
.. versionadded:: 2.0
|
715
|
+
"""
|
716
|
+
name = 'Rexx'
|
717
|
+
aliases = ['rexx', 'arexx']
|
718
|
+
filenames = ['*.rexx', '*.rex', '*.rx', '*.arexx']
|
719
|
+
mimetypes = ['text/x-rexx']
|
720
|
+
flags = re.IGNORECASE
|
721
|
+
|
722
|
+
tokens = {
|
723
|
+
'root': [
|
724
|
+
(r'\s', Whitespace),
|
725
|
+
(r'/\*', Comment.Multiline, 'comment'),
|
726
|
+
(r'"', String, 'string_double'),
|
727
|
+
(r"'", String, 'string_single'),
|
728
|
+
(r'[0-9]+(\.[0-9]+)?(e[+-]?[0-9])?', Number),
|
729
|
+
(r'([a-z_]\w*)(\s*)(:)(\s*)(procedure)\b',
|
730
|
+
bygroups(Name.Function, Whitespace, Operator, Whitespace,
|
731
|
+
Keyword.Declaration)),
|
732
|
+
(r'([a-z_]\w*)(\s*)(:)',
|
733
|
+
bygroups(Name.Label, Whitespace, Operator)),
|
734
|
+
include('function'),
|
735
|
+
include('keyword'),
|
736
|
+
include('operator'),
|
737
|
+
(r'[a-z_]\w*', Text),
|
738
|
+
],
|
739
|
+
'function': [
|
740
|
+
(words((
|
741
|
+
'abbrev', 'abs', 'address', 'arg', 'b2x', 'bitand', 'bitor', 'bitxor',
|
742
|
+
'c2d', 'c2x', 'center', 'charin', 'charout', 'chars', 'compare',
|
743
|
+
'condition', 'copies', 'd2c', 'd2x', 'datatype', 'date', 'delstr',
|
744
|
+
'delword', 'digits', 'errortext', 'form', 'format', 'fuzz', 'insert',
|
745
|
+
'lastpos', 'left', 'length', 'linein', 'lineout', 'lines', 'max',
|
746
|
+
'min', 'overlay', 'pos', 'queued', 'random', 'reverse', 'right', 'sign',
|
747
|
+
'sourceline', 'space', 'stream', 'strip', 'substr', 'subword', 'symbol',
|
748
|
+
'time', 'trace', 'translate', 'trunc', 'value', 'verify', 'word',
|
749
|
+
'wordindex', 'wordlength', 'wordpos', 'words', 'x2b', 'x2c', 'x2d',
|
750
|
+
'xrange'), suffix=r'(\s*)(\()'),
|
751
|
+
bygroups(Name.Builtin, Whitespace, Operator)),
|
752
|
+
],
|
753
|
+
'keyword': [
|
754
|
+
(r'(address|arg|by|call|do|drop|else|end|exit|for|forever|if|'
|
755
|
+
r'interpret|iterate|leave|nop|numeric|off|on|options|parse|'
|
756
|
+
r'pull|push|queue|return|say|select|signal|to|then|trace|until|'
|
757
|
+
r'while)\b', Keyword.Reserved),
|
758
|
+
],
|
759
|
+
'operator': [
|
760
|
+
(r'(-|//|/|\(|\)|\*\*|\*|\\<<|\\<|\\==|\\=|\\>>|\\>|\\|\|\||\||'
|
761
|
+
r'&&|&|%|\+|<<=|<<|<=|<>|<|==|=|><|>=|>>=|>>|>|¬<<|¬<|¬==|¬=|'
|
762
|
+
r'¬>>|¬>|¬|\.|,)', Operator),
|
763
|
+
],
|
764
|
+
'string_double': [
|
765
|
+
(r'[^"\n]+', String),
|
766
|
+
(r'""', String),
|
767
|
+
(r'"', String, '#pop'),
|
768
|
+
(r'\n', Text, '#pop'), # Stray linefeed also terminates strings.
|
769
|
+
],
|
770
|
+
'string_single': [
|
771
|
+
(r'[^\'\n]', String),
|
772
|
+
(r'\'\'', String),
|
773
|
+
(r'\'', String, '#pop'),
|
774
|
+
(r'\n', Text, '#pop'), # Stray linefeed also terminates strings.
|
775
|
+
],
|
776
|
+
'comment': [
|
777
|
+
(r'[^*]+', Comment.Multiline),
|
778
|
+
(r'\*/', Comment.Multiline, '#pop'),
|
779
|
+
(r'\*', Comment.Multiline),
|
780
|
+
]
|
781
|
+
}
|
782
|
+
|
783
|
+
_c = lambda s: re.compile(s, re.MULTILINE)
|
784
|
+
_ADDRESS_COMMAND_PATTERN = _c(r'^\s*address\s+command\b')
|
785
|
+
_ADDRESS_PATTERN = _c(r'^\s*address\s+')
|
786
|
+
_DO_WHILE_PATTERN = _c(r'^\s*do\s+while\b')
|
787
|
+
_IF_THEN_DO_PATTERN = _c(r'^\s*if\b.+\bthen\s+do\s*$')
|
788
|
+
_PROCEDURE_PATTERN = _c(r'^\s*([a-z_]\w*)(\s*)(:)(\s*)(procedure)\b')
|
789
|
+
_ELSE_DO_PATTERN = _c(r'\belse\s+do\s*$')
|
790
|
+
_PARSE_ARG_PATTERN = _c(r'^\s*parse\s+(upper\s+)?(arg|value)\b')
|
791
|
+
PATTERNS_AND_WEIGHTS = (
|
792
|
+
(_ADDRESS_COMMAND_PATTERN, 0.2),
|
793
|
+
(_ADDRESS_PATTERN, 0.05),
|
794
|
+
(_DO_WHILE_PATTERN, 0.1),
|
795
|
+
(_ELSE_DO_PATTERN, 0.1),
|
796
|
+
(_IF_THEN_DO_PATTERN, 0.1),
|
797
|
+
(_PROCEDURE_PATTERN, 0.5),
|
798
|
+
(_PARSE_ARG_PATTERN, 0.2),
|
799
|
+
)
|
800
|
+
|
801
|
+
def analyse_text(text):
|
802
|
+
"""
|
803
|
+
Check for inital comment and patterns that distinguish Rexx from other
|
804
|
+
C-like languages.
|
805
|
+
"""
|
806
|
+
if re.search(r'/\*\**\s*rexx', text, re.IGNORECASE):
|
807
|
+
# Header matches MVS Rexx requirements, this is certainly a Rexx
|
808
|
+
# script.
|
809
|
+
return 1.0
|
810
|
+
elif text.startswith('/*'):
|
811
|
+
# Header matches general Rexx requirements; the source code might
|
812
|
+
# still be any language using C comments such as C++, C# or Java.
|
813
|
+
lowerText = text.lower()
|
814
|
+
result = sum(weight
|
815
|
+
for (pattern, weight) in RexxLexer.PATTERNS_AND_WEIGHTS
|
816
|
+
if pattern.search(lowerText)) + 0.01
|
817
|
+
return min(result, 1.0)
|
818
|
+
|
819
|
+
|
820
|
+
class MOOCodeLexer(RegexLexer):
|
821
|
+
"""
|
822
|
+
For `MOOCode <http://www.moo.mud.org/>`_ (the MOO scripting
|
823
|
+
language).
|
824
|
+
|
825
|
+
.. versionadded:: 0.9
|
826
|
+
"""
|
827
|
+
name = 'MOOCode'
|
828
|
+
filenames = ['*.moo']
|
829
|
+
aliases = ['moocode', 'moo']
|
830
|
+
mimetypes = ['text/x-moocode']
|
831
|
+
|
832
|
+
tokens = {
|
833
|
+
'root': [
|
834
|
+
# Numbers
|
835
|
+
(r'(0|[1-9][0-9_]*)', Number.Integer),
|
836
|
+
# Strings
|
837
|
+
(r'"(\\\\|\\"|[^"])*"', String),
|
838
|
+
# exceptions
|
839
|
+
(r'(E_PERM|E_DIV)', Name.Exception),
|
840
|
+
# db-refs
|
841
|
+
(r'((#[-0-9]+)|(\$\w+))', Name.Entity),
|
842
|
+
# Keywords
|
843
|
+
(r'\b(if|else|elseif|endif|for|endfor|fork|endfork|while'
|
844
|
+
r'|endwhile|break|continue|return|try'
|
845
|
+
r'|except|endtry|finally|in)\b', Keyword),
|
846
|
+
# builtins
|
847
|
+
(r'(random|length)', Name.Builtin),
|
848
|
+
# special variables
|
849
|
+
(r'(player|caller|this|args)', Name.Variable.Instance),
|
850
|
+
# skip whitespace
|
851
|
+
(r'\s+', Text),
|
852
|
+
(r'\n', Text),
|
853
|
+
# other operators
|
854
|
+
(r'([!;=,{}&|:.\[\]@()<>?]+)', Operator),
|
855
|
+
# function call
|
856
|
+
(r'(\w+)(\()', bygroups(Name.Function, Operator)),
|
857
|
+
# variables
|
858
|
+
(r'(\w+)', Text),
|
859
|
+
]
|
860
|
+
}
|
861
|
+
|
862
|
+
|
863
|
+
class HybrisLexer(RegexLexer):
|
864
|
+
"""
|
865
|
+
For `Hybris <http://www.hybris-lang.org>`_ source code.
|
866
|
+
|
867
|
+
.. versionadded:: 1.4
|
868
|
+
"""
|
869
|
+
|
870
|
+
name = 'Hybris'
|
871
|
+
aliases = ['hybris', 'hy']
|
872
|
+
filenames = ['*.hy', '*.hyb']
|
873
|
+
mimetypes = ['text/x-hybris', 'application/x-hybris']
|
874
|
+
|
875
|
+
flags = re.MULTILINE | re.DOTALL
|
876
|
+
|
877
|
+
tokens = {
|
878
|
+
'root': [
|
879
|
+
# method names
|
880
|
+
(r'^(\s*(?:function|method|operator\s+)+?)'
|
881
|
+
r'([a-zA-Z_]\w*)'
|
882
|
+
r'(\s*)(\()', bygroups(Keyword, Name.Function, Text, Operator)),
|
883
|
+
(r'[^\S\n]+', Text),
|
884
|
+
(r'//.*?\n', Comment.Single),
|
885
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
886
|
+
(r'@[a-zA-Z_][\w.]*', Name.Decorator),
|
887
|
+
(r'(break|case|catch|next|default|do|else|finally|for|foreach|of|'
|
888
|
+
r'unless|if|new|return|switch|me|throw|try|while)\b', Keyword),
|
889
|
+
(r'(extends|private|protected|public|static|throws|function|method|'
|
890
|
+
r'operator)\b', Keyword.Declaration),
|
891
|
+
(r'(true|false|null|__FILE__|__LINE__|__VERSION__|__LIB_PATH__|'
|
892
|
+
r'__INC_PATH__)\b', Keyword.Constant),
|
893
|
+
(r'(class|struct)(\s+)',
|
894
|
+
bygroups(Keyword.Declaration, Text), 'class'),
|
895
|
+
(r'(import|include)(\s+)',
|
896
|
+
bygroups(Keyword.Namespace, Text), 'import'),
|
897
|
+
(words((
|
898
|
+
'gc_collect', 'gc_mm_items', 'gc_mm_usage', 'gc_collect_threshold',
|
899
|
+
'urlencode', 'urldecode', 'base64encode', 'base64decode', 'sha1', 'crc32',
|
900
|
+
'sha2', 'md5', 'md5_file', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos',
|
901
|
+
'cosh', 'exp', 'fabs', 'floor', 'fmod', 'log', 'log10', 'pow', 'sin',
|
902
|
+
'sinh', 'sqrt', 'tan', 'tanh', 'isint', 'isfloat', 'ischar', 'isstring',
|
903
|
+
'isarray', 'ismap', 'isalias', 'typeof', 'sizeof', 'toint', 'tostring',
|
904
|
+
'fromxml', 'toxml', 'binary', 'pack', 'load', 'eval', 'var_names',
|
905
|
+
'var_values', 'user_functions', 'dyn_functions', 'methods', 'call',
|
906
|
+
'call_method', 'mknod', 'mkfifo', 'mount', 'umount2', 'umount', 'ticks',
|
907
|
+
'usleep', 'sleep', 'time', 'strtime', 'strdate', 'dllopen', 'dlllink',
|
908
|
+
'dllcall', 'dllcall_argv', 'dllclose', 'env', 'exec', 'fork', 'getpid',
|
909
|
+
'wait', 'popen', 'pclose', 'exit', 'kill', 'pthread_create',
|
910
|
+
'pthread_create_argv', 'pthread_exit', 'pthread_join', 'pthread_kill',
|
911
|
+
'smtp_send', 'http_get', 'http_post', 'http_download', 'socket', 'bind',
|
912
|
+
'listen', 'accept', 'getsockname', 'getpeername', 'settimeout', 'connect',
|
913
|
+
'server', 'recv', 'send', 'close', 'print', 'println', 'printf', 'input',
|
914
|
+
'readline', 'serial_open', 'serial_fcntl', 'serial_get_attr',
|
915
|
+
'serial_get_ispeed', 'serial_get_ospeed', 'serial_set_attr',
|
916
|
+
'serial_set_ispeed', 'serial_set_ospeed', 'serial_write', 'serial_read',
|
917
|
+
'serial_close', 'xml_load', 'xml_parse', 'fopen', 'fseek', 'ftell',
|
918
|
+
'fsize', 'fread', 'fwrite', 'fgets', 'fclose', 'file', 'readdir',
|
919
|
+
'pcre_replace', 'size', 'pop', 'unmap', 'has', 'keys', 'values',
|
920
|
+
'length', 'find', 'substr', 'replace', 'split', 'trim', 'remove',
|
921
|
+
'contains', 'join'), suffix=r'\b'),
|
922
|
+
Name.Builtin),
|
923
|
+
(words((
|
924
|
+
'MethodReference', 'Runner', 'Dll', 'Thread', 'Pipe', 'Process',
|
925
|
+
'Runnable', 'CGI', 'ClientSocket', 'Socket', 'ServerSocket',
|
926
|
+
'File', 'Console', 'Directory', 'Exception'), suffix=r'\b'),
|
927
|
+
Keyword.Type),
|
928
|
+
(r'"(\\\\|\\"|[^"])*"', String),
|
929
|
+
(r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char),
|
930
|
+
(r'(\.)([a-zA-Z_]\w*)',
|
931
|
+
bygroups(Operator, Name.Attribute)),
|
932
|
+
(r'[a-zA-Z_]\w*:', Name.Label),
|
933
|
+
(r'[a-zA-Z_$]\w*', Name),
|
934
|
+
(r'[~^*!%&\[\](){}<>|+=:;,./?\-@]+', Operator),
|
935
|
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
936
|
+
(r'0x[0-9a-f]+', Number.Hex),
|
937
|
+
(r'[0-9]+L?', Number.Integer),
|
938
|
+
(r'\n', Text),
|
939
|
+
],
|
940
|
+
'class': [
|
941
|
+
(r'[a-zA-Z_]\w*', Name.Class, '#pop')
|
942
|
+
],
|
943
|
+
'import': [
|
944
|
+
(r'[\w.]+\*?', Name.Namespace, '#pop')
|
945
|
+
],
|
946
|
+
}
|
947
|
+
|
948
|
+
|
949
|
+
class EasytrieveLexer(RegexLexer):
|
950
|
+
"""
|
951
|
+
Easytrieve Plus is a programming language for extracting, filtering and
|
952
|
+
converting sequential data. Furthermore it can layout data for reports.
|
953
|
+
It is mainly used on mainframe platforms and can access several of the
|
954
|
+
mainframe's native file formats. It is somewhat comparable to awk.
|
955
|
+
|
956
|
+
.. versionadded:: 2.1
|
957
|
+
"""
|
958
|
+
name = 'Easytrieve'
|
959
|
+
aliases = ['easytrieve']
|
960
|
+
filenames = ['*.ezt', '*.mac']
|
961
|
+
mimetypes = ['text/x-easytrieve']
|
962
|
+
flags = 0
|
963
|
+
|
964
|
+
# Note: We cannot use r'\b' at the start and end of keywords because
|
965
|
+
# Easytrieve Plus delimiter characters are:
|
966
|
+
#
|
967
|
+
# * space ( )
|
968
|
+
# * apostrophe (')
|
969
|
+
# * period (.)
|
970
|
+
# * comma (,)
|
971
|
+
# * paranthesis ( and )
|
972
|
+
# * colon (:)
|
973
|
+
#
|
974
|
+
# Additionally words end once a '*' appears, indicatins a comment.
|
975
|
+
_DELIMITERS = r' \'.,():\n'
|
976
|
+
_DELIMITERS_OR_COMENT = _DELIMITERS + '*'
|
977
|
+
_DELIMITER_PATTERN = '[' + _DELIMITERS + ']'
|
978
|
+
_DELIMITER_PATTERN_CAPTURE = '(' + _DELIMITER_PATTERN + ')'
|
979
|
+
_NON_DELIMITER_OR_COMMENT_PATTERN = '[^' + _DELIMITERS_OR_COMENT + ']'
|
980
|
+
_OPERATORS_PATTERN = u'[.+\\-/=\\[\\](){}<>;,&%¬]'
|
981
|
+
_KEYWORDS = [
|
982
|
+
'AFTER-BREAK', 'AFTER-LINE', 'AFTER-SCREEN', 'AIM', 'AND', 'ATTR',
|
983
|
+
'BEFORE', 'BEFORE-BREAK', 'BEFORE-LINE', 'BEFORE-SCREEN', 'BUSHU',
|
984
|
+
'BY', 'CALL', 'CASE', 'CHECKPOINT', 'CHKP', 'CHKP-STATUS', 'CLEAR',
|
985
|
+
'CLOSE', 'COL', 'COLOR', 'COMMIT', 'CONTROL', 'COPY', 'CURSOR', 'D',
|
986
|
+
'DECLARE', 'DEFAULT', 'DEFINE', 'DELETE', 'DENWA', 'DISPLAY', 'DLI',
|
987
|
+
'DO', 'DUPLICATE', 'E', 'ELSE', 'ELSE-IF', 'END', 'END-CASE',
|
988
|
+
'END-DO', 'END-IF', 'END-PROC', 'ENDPAGE', 'ENDTABLE', 'ENTER', 'EOF',
|
989
|
+
'EQ', 'ERROR', 'EXIT', 'EXTERNAL', 'EZLIB', 'F1', 'F10', 'F11', 'F12',
|
990
|
+
'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F2', 'F20', 'F21',
|
991
|
+
'F22', 'F23', 'F24', 'F25', 'F26', 'F27', 'F28', 'F29', 'F3', 'F30',
|
992
|
+
'F31', 'F32', 'F33', 'F34', 'F35', 'F36', 'F4', 'F5', 'F6', 'F7',
|
993
|
+
'F8', 'F9', 'FETCH', 'FILE-STATUS', 'FILL', 'FINAL', 'FIRST',
|
994
|
+
'FIRST-DUP', 'FOR', 'GE', 'GET', 'GO', 'GOTO', 'GQ', 'GR', 'GT',
|
995
|
+
'HEADING', 'HEX', 'HIGH-VALUES', 'IDD', 'IDMS', 'IF', 'IN', 'INSERT',
|
996
|
+
'JUSTIFY', 'KANJI-DATE', 'KANJI-DATE-LONG', 'KANJI-TIME', 'KEY',
|
997
|
+
'KEY-PRESSED', 'KOKUGO', 'KUN', 'LAST-DUP', 'LE', 'LEVEL', 'LIKE',
|
998
|
+
'LINE', 'LINE-COUNT', 'LINE-NUMBER', 'LINK', 'LIST', 'LOW-VALUES',
|
999
|
+
'LQ', 'LS', 'LT', 'MACRO', 'MASK', 'MATCHED', 'MEND', 'MESSAGE',
|
1000
|
+
'MOVE', 'MSTART', 'NE', 'NEWPAGE', 'NOMASK', 'NOPRINT', 'NOT',
|
1001
|
+
'NOTE', 'NOVERIFY', 'NQ', 'NULL', 'OF', 'OR', 'OTHERWISE', 'PA1',
|
1002
|
+
'PA2', 'PA3', 'PAGE-COUNT', 'PAGE-NUMBER', 'PARM-REGISTER',
|
1003
|
+
'PATH-ID', 'PATTERN', 'PERFORM', 'POINT', 'POS', 'PRIMARY', 'PRINT',
|
1004
|
+
'PROCEDURE', 'PROGRAM', 'PUT', 'READ', 'RECORD', 'RECORD-COUNT',
|
1005
|
+
'RECORD-LENGTH', 'REFRESH', 'RELEASE', 'RENUM', 'REPEAT', 'REPORT',
|
1006
|
+
'REPORT-INPUT', 'RESHOW', 'RESTART', 'RETRIEVE', 'RETURN-CODE',
|
1007
|
+
'ROLLBACK', 'ROW', 'S', 'SCREEN', 'SEARCH', 'SECONDARY', 'SELECT',
|
1008
|
+
'SEQUENCE', 'SIZE', 'SKIP', 'SOKAKU', 'SORT', 'SQL', 'STOP', 'SUM',
|
1009
|
+
'SYSDATE', 'SYSDATE-LONG', 'SYSIN', 'SYSIPT', 'SYSLST', 'SYSPRINT',
|
1010
|
+
'SYSSNAP', 'SYSTIME', 'TALLY', 'TERM-COLUMNS', 'TERM-NAME',
|
1011
|
+
'TERM-ROWS', 'TERMINATION', 'TITLE', 'TO', 'TRANSFER', 'TRC',
|
1012
|
+
'UNIQUE', 'UNTIL', 'UPDATE', 'UPPERCASE', 'USER', 'USERID', 'VALUE',
|
1013
|
+
'VERIFY', 'W', 'WHEN', 'WHILE', 'WORK', 'WRITE', 'X', 'XDM', 'XRST'
|
1014
|
+
]
|
1015
|
+
|
1016
|
+
tokens = {
|
1017
|
+
'root': [
|
1018
|
+
(r'\*.*\n', Comment.Single),
|
1019
|
+
(r'\n+', Whitespace),
|
1020
|
+
# Macro argument
|
1021
|
+
(r'&' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+\.', Name.Variable,
|
1022
|
+
'after_macro_argument'),
|
1023
|
+
# Macro call
|
1024
|
+
(r'%' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name.Variable),
|
1025
|
+
(r'(FILE|MACRO|REPORT)(\s+)',
|
1026
|
+
bygroups(Keyword.Declaration, Whitespace), 'after_declaration'),
|
1027
|
+
(r'(JOB|PARM)' + r'(' + _DELIMITER_PATTERN + r')',
|
1028
|
+
bygroups(Keyword.Declaration, Operator)),
|
1029
|
+
(words(_KEYWORDS, suffix=_DELIMITER_PATTERN_CAPTURE),
|
1030
|
+
bygroups(Keyword.Reserved, Operator)),
|
1031
|
+
(_OPERATORS_PATTERN, Operator),
|
1032
|
+
# Procedure declaration
|
1033
|
+
(r'(' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+)(\s*)(\.?)(\s*)(PROC)(\s*\n)',
|
1034
|
+
bygroups(Name.Function, Whitespace, Operator, Whitespace,
|
1035
|
+
Keyword.Declaration, Whitespace)),
|
1036
|
+
(r'[0-9]+\.[0-9]*', Number.Float),
|
1037
|
+
(r'[0-9]+', Number.Integer),
|
1038
|
+
(r"'(''|[^'])*'", String),
|
1039
|
+
(r'\s+', Whitespace),
|
1040
|
+
# Everything else just belongs to a name
|
1041
|
+
(_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name),
|
1042
|
+
],
|
1043
|
+
'after_declaration': [
|
1044
|
+
(_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name.Function),
|
1045
|
+
default('#pop'),
|
1046
|
+
],
|
1047
|
+
'after_macro_argument': [
|
1048
|
+
(r'\*.*\n', Comment.Single, '#pop'),
|
1049
|
+
(r'\s+', Whitespace, '#pop'),
|
1050
|
+
(_OPERATORS_PATTERN, Operator, '#pop'),
|
1051
|
+
(r"'(''|[^'])*'", String, '#pop'),
|
1052
|
+
# Everything else just belongs to a name
|
1053
|
+
(_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name),
|
1054
|
+
],
|
1055
|
+
}
|
1056
|
+
_COMMENT_LINE_REGEX = re.compile(r'^\s*\*')
|
1057
|
+
_MACRO_HEADER_REGEX = re.compile(r'^\s*MACRO')
|
1058
|
+
|
1059
|
+
def analyse_text(text):
|
1060
|
+
"""
|
1061
|
+
Perform a structural analysis for basic Easytrieve constructs.
|
1062
|
+
"""
|
1063
|
+
result = 0.0
|
1064
|
+
lines = text.split('\n')
|
1065
|
+
hasEndProc = False
|
1066
|
+
hasHeaderComment = False
|
1067
|
+
hasFile = False
|
1068
|
+
hasJob = False
|
1069
|
+
hasProc = False
|
1070
|
+
hasParm = False
|
1071
|
+
hasReport = False
|
1072
|
+
|
1073
|
+
def isCommentLine(line):
|
1074
|
+
return EasytrieveLexer._COMMENT_LINE_REGEX.match(lines[0]) is not None
|
1075
|
+
|
1076
|
+
def isEmptyLine(line):
|
1077
|
+
return not bool(line.strip())
|
1078
|
+
|
1079
|
+
# Remove possible empty lines and header comments.
|
1080
|
+
while lines and (isEmptyLine(lines[0]) or isCommentLine(lines[0])):
|
1081
|
+
if not isEmptyLine(lines[0]):
|
1082
|
+
hasHeaderComment = True
|
1083
|
+
del lines[0]
|
1084
|
+
|
1085
|
+
if EasytrieveLexer._MACRO_HEADER_REGEX.match(lines[0]):
|
1086
|
+
# Looks like an Easytrieve macro.
|
1087
|
+
result = 0.4
|
1088
|
+
if hasHeaderComment:
|
1089
|
+
result += 0.4
|
1090
|
+
else:
|
1091
|
+
# Scan the source for lines starting with indicators.
|
1092
|
+
for line in lines:
|
1093
|
+
words = line.split()
|
1094
|
+
if (len(words) >= 2):
|
1095
|
+
firstWord = words[0]
|
1096
|
+
if not hasReport:
|
1097
|
+
if not hasJob:
|
1098
|
+
if not hasFile:
|
1099
|
+
if not hasParm:
|
1100
|
+
if firstWord == 'PARM':
|
1101
|
+
hasParm = True
|
1102
|
+
if firstWord == 'FILE':
|
1103
|
+
hasFile = True
|
1104
|
+
if firstWord == 'JOB':
|
1105
|
+
hasJob = True
|
1106
|
+
elif firstWord == 'PROC':
|
1107
|
+
hasProc = True
|
1108
|
+
elif firstWord == 'END-PROC':
|
1109
|
+
hasEndProc = True
|
1110
|
+
elif firstWord == 'REPORT':
|
1111
|
+
hasReport = True
|
1112
|
+
|
1113
|
+
# Weight the findings.
|
1114
|
+
if hasJob and (hasProc == hasEndProc):
|
1115
|
+
if hasHeaderComment:
|
1116
|
+
result += 0.1
|
1117
|
+
if hasParm:
|
1118
|
+
if hasProc:
|
1119
|
+
# Found PARM, JOB and PROC/END-PROC:
|
1120
|
+
# pretty sure this is Easytrieve.
|
1121
|
+
result += 0.8
|
1122
|
+
else:
|
1123
|
+
# Found PARAM and JOB: probably this is Easytrieve
|
1124
|
+
result += 0.5
|
1125
|
+
else:
|
1126
|
+
# Found JOB and possibly other keywords: might be Easytrieve
|
1127
|
+
result += 0.11
|
1128
|
+
if hasParm:
|
1129
|
+
# Note: PARAM is not a proper English word, so this is
|
1130
|
+
# regarded a much better indicator for Easytrieve than
|
1131
|
+
# the other words.
|
1132
|
+
result += 0.2
|
1133
|
+
if hasFile:
|
1134
|
+
result += 0.01
|
1135
|
+
if hasReport:
|
1136
|
+
result += 0.01
|
1137
|
+
assert 0.0 <= result <= 1.0
|
1138
|
+
return result
|
1139
|
+
|
1140
|
+
|
1141
|
+
class JclLexer(RegexLexer):
|
1142
|
+
"""
|
1143
|
+
`Job Control Language (JCL)
|
1144
|
+
<http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IEA2B570/CCONTENTS>`_
|
1145
|
+
is a scripting language used on mainframe platforms to instruct the system
|
1146
|
+
on how to run a batch job or start a subsystem. It is somewhat
|
1147
|
+
comparable to MS DOS batch and Unix shell scripts.
|
1148
|
+
|
1149
|
+
.. versionadded:: 2.1
|
1150
|
+
"""
|
1151
|
+
name = 'JCL'
|
1152
|
+
aliases = ['jcl']
|
1153
|
+
filenames = ['*.jcl']
|
1154
|
+
mimetypes = ['text/x-jcl']
|
1155
|
+
flags = re.IGNORECASE
|
1156
|
+
|
1157
|
+
tokens = {
|
1158
|
+
'root': [
|
1159
|
+
(r'//\*.*\n', Comment.Single),
|
1160
|
+
(r'//', Keyword.Pseudo, 'statement'),
|
1161
|
+
(r'/\*', Keyword.Pseudo, 'jes2_statement'),
|
1162
|
+
# TODO: JES3 statement
|
1163
|
+
(r'.*\n', Other) # Input text or inline code in any language.
|
1164
|
+
],
|
1165
|
+
'statement': [
|
1166
|
+
(r'\s*\n', Whitespace, '#pop'),
|
1167
|
+
(r'([a-z]\w*)(\s+)(exec|job)(\s*)',
|
1168
|
+
bygroups(Name.Label, Whitespace, Keyword.Reserved, Whitespace),
|
1169
|
+
'option'),
|
1170
|
+
(r'[a-z]\w*', Name.Variable, 'statement_command'),
|
1171
|
+
(r'\s+', Whitespace, 'statement_command'),
|
1172
|
+
],
|
1173
|
+
'statement_command': [
|
1174
|
+
(r'\s+(command|cntl|dd|endctl|endif|else|include|jcllib|'
|
1175
|
+
r'output|pend|proc|set|then|xmit)\s+', Keyword.Reserved, 'option'),
|
1176
|
+
include('option')
|
1177
|
+
],
|
1178
|
+
'jes2_statement': [
|
1179
|
+
(r'\s*\n', Whitespace, '#pop'),
|
1180
|
+
(r'\$', Keyword, 'option'),
|
1181
|
+
(r'\b(jobparam|message|netacct|notify|output|priority|route|'
|
1182
|
+
r'setup|signoff|xeq|xmit)\b', Keyword, 'option'),
|
1183
|
+
],
|
1184
|
+
'option': [
|
1185
|
+
# (r'\n', Text, 'root'),
|
1186
|
+
(r'\*', Name.Builtin),
|
1187
|
+
(r'[\[\](){}<>;,]', Punctuation),
|
1188
|
+
(r'[-+*/=&%]', Operator),
|
1189
|
+
(r'[a-z_]\w*', Name),
|
1190
|
+
(r'\d+\.\d*', Number.Float),
|
1191
|
+
(r'\.\d+', Number.Float),
|
1192
|
+
(r'\d+', Number.Integer),
|
1193
|
+
(r"'", String, 'option_string'),
|
1194
|
+
(r'[ \t]+', Whitespace, 'option_comment'),
|
1195
|
+
(r'\.', Punctuation),
|
1196
|
+
],
|
1197
|
+
'option_string': [
|
1198
|
+
(r"(\n)(//)", bygroups(Text, Keyword.Pseudo)),
|
1199
|
+
(r"''", String),
|
1200
|
+
(r"[^']", String),
|
1201
|
+
(r"'", String, '#pop'),
|
1202
|
+
],
|
1203
|
+
'option_comment': [
|
1204
|
+
# (r'\n', Text, 'root'),
|
1205
|
+
(r'.+', Comment.Single),
|
1206
|
+
]
|
1207
|
+
}
|
1208
|
+
|
1209
|
+
_JOB_HEADER_PATTERN = re.compile(r'^//[a-z#$@][a-z0-9#$@]{0,7}\s+job(\s+.*)?$',
|
1210
|
+
re.IGNORECASE)
|
1211
|
+
|
1212
|
+
def analyse_text(text):
|
1213
|
+
"""
|
1214
|
+
Recognize JCL job by header.
|
1215
|
+
"""
|
1216
|
+
result = 0.0
|
1217
|
+
lines = text.split('\n')
|
1218
|
+
if len(lines) > 0:
|
1219
|
+
if JclLexer._JOB_HEADER_PATTERN.match(lines[0]):
|
1220
|
+
result = 1.0
|
1221
|
+
assert 0.0 <= result <= 1.0
|
1222
|
+
return result
|