pygments.rb-jruby 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/CHANGELOG.md +71 -0
- data/Gemfile +2 -0
- data/LICENSE +17 -0
- data/README.md +118 -0
- data/Rakefile +66 -0
- data/bench.rb +22 -0
- data/cache-lexers.rb +8 -0
- data/lexers +0 -0
- data/lib/pygments.rb +8 -0
- data/lib/pygments/lexer.rb +148 -0
- data/lib/pygments/mentos.py +351 -0
- data/lib/pygments/popen.rb +404 -0
- data/lib/pygments/version.rb +3 -0
- data/pygments.rb.gemspec +24 -0
- data/test/test_data.c +2581 -0
- data/test/test_data.py +514 -0
- data/test/test_data_generated +2582 -0
- data/test/test_pygments.rb +287 -0
- data/vendor/custom_lexers/github.py +565 -0
- data/vendor/pygments-main/AUTHORS +153 -0
- data/vendor/pygments-main/CHANGES +889 -0
- data/vendor/pygments-main/LICENSE +25 -0
- data/vendor/pygments-main/MANIFEST.in +6 -0
- data/vendor/pygments-main/Makefile +59 -0
- data/vendor/pygments-main/REVISION +1 -0
- data/vendor/pygments-main/TODO +15 -0
- data/vendor/pygments-main/docs/generate.py +472 -0
- data/vendor/pygments-main/docs/pygmentize.1 +94 -0
- data/vendor/pygments-main/docs/src/api.txt +270 -0
- data/vendor/pygments-main/docs/src/authors.txt +5 -0
- data/vendor/pygments-main/docs/src/changelog.txt +5 -0
- data/vendor/pygments-main/docs/src/cmdline.txt +147 -0
- data/vendor/pygments-main/docs/src/filterdevelopment.txt +70 -0
- data/vendor/pygments-main/docs/src/filters.txt +42 -0
- data/vendor/pygments-main/docs/src/formatterdevelopment.txt +169 -0
- data/vendor/pygments-main/docs/src/formatters.txt +48 -0
- data/vendor/pygments-main/docs/src/index.txt +69 -0
- data/vendor/pygments-main/docs/src/installation.txt +71 -0
- data/vendor/pygments-main/docs/src/integrate.txt +48 -0
- data/vendor/pygments-main/docs/src/java.txt +70 -0
- data/vendor/pygments-main/docs/src/lexerdevelopment.txt +603 -0
- data/vendor/pygments-main/docs/src/lexers.txt +67 -0
- data/vendor/pygments-main/docs/src/moinmoin.txt +39 -0
- data/vendor/pygments-main/docs/src/plugins.txt +93 -0
- data/vendor/pygments-main/docs/src/quickstart.txt +202 -0
- data/vendor/pygments-main/docs/src/rstdirective.txt +22 -0
- data/vendor/pygments-main/docs/src/styles.txt +143 -0
- data/vendor/pygments-main/docs/src/tokens.txt +349 -0
- data/vendor/pygments-main/docs/src/unicode.txt +49 -0
- data/vendor/pygments-main/external/autopygmentize +64 -0
- data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +144 -0
- data/vendor/pygments-main/external/markdown-processor.py +67 -0
- data/vendor/pygments-main/external/moin-parser.py +112 -0
- data/vendor/pygments-main/external/pygments.bashcomp +38 -0
- data/vendor/pygments-main/external/rst-directive-old.py +77 -0
- data/vendor/pygments-main/external/rst-directive.py +83 -0
- data/vendor/pygments-main/ez_setup.py +276 -0
- data/vendor/pygments-main/pygmentize +7 -0
- data/vendor/pygments-main/pygments/__init__.py +91 -0
- data/vendor/pygments-main/pygments/cmdline.py +441 -0
- data/vendor/pygments-main/pygments/console.py +74 -0
- data/vendor/pygments-main/pygments/filter.py +74 -0
- data/vendor/pygments-main/pygments/filters/__init__.py +356 -0
- data/vendor/pygments-main/pygments/formatter.py +95 -0
- data/vendor/pygments-main/pygments/formatters/__init__.py +68 -0
- data/vendor/pygments-main/pygments/formatters/_mapping.py +92 -0
- data/vendor/pygments-main/pygments/formatters/bbcode.py +109 -0
- data/vendor/pygments-main/pygments/formatters/html.py +821 -0
- data/vendor/pygments-main/pygments/formatters/img.py +553 -0
- data/vendor/pygments-main/pygments/formatters/latex.py +378 -0
- data/vendor/pygments-main/pygments/formatters/other.py +115 -0
- data/vendor/pygments-main/pygments/formatters/rtf.py +136 -0
- data/vendor/pygments-main/pygments/formatters/svg.py +154 -0
- data/vendor/pygments-main/pygments/formatters/terminal.py +112 -0
- data/vendor/pygments-main/pygments/formatters/terminal256.py +222 -0
- data/vendor/pygments-main/pygments/lexer.py +765 -0
- data/vendor/pygments-main/pygments/lexers/__init__.py +240 -0
- data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1645 -0
- data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +232 -0
- data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +5172 -0
- data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +249 -0
- data/vendor/pygments-main/pygments/lexers/_mapping.py +354 -0
- data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +562 -0
- data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +3787 -0
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +233 -0
- data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +557 -0
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +40 -0
- data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +1072 -0
- data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +360 -0
- data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +13 -0
- data/vendor/pygments-main/pygments/lexers/agile.py +2290 -0
- data/vendor/pygments-main/pygments/lexers/asm.py +398 -0
- data/vendor/pygments-main/pygments/lexers/compiled.py +3723 -0
- data/vendor/pygments-main/pygments/lexers/dalvik.py +104 -0
- data/vendor/pygments-main/pygments/lexers/dotnet.py +671 -0
- data/vendor/pygments-main/pygments/lexers/foxpro.py +428 -0
- data/vendor/pygments-main/pygments/lexers/functional.py +2731 -0
- data/vendor/pygments-main/pygments/lexers/github.py +565 -0
- data/vendor/pygments-main/pygments/lexers/hdl.py +356 -0
- data/vendor/pygments-main/pygments/lexers/jvm.py +1112 -0
- data/vendor/pygments-main/pygments/lexers/math.py +1918 -0
- data/vendor/pygments-main/pygments/lexers/other.py +3778 -0
- data/vendor/pygments-main/pygments/lexers/parsers.py +778 -0
- data/vendor/pygments-main/pygments/lexers/shell.py +424 -0
- data/vendor/pygments-main/pygments/lexers/special.py +100 -0
- data/vendor/pygments-main/pygments/lexers/sql.py +559 -0
- data/vendor/pygments-main/pygments/lexers/templates.py +1742 -0
- data/vendor/pygments-main/pygments/lexers/text.py +1893 -0
- data/vendor/pygments-main/pygments/lexers/web.py +4045 -0
- data/vendor/pygments-main/pygments/modeline.py +40 -0
- data/vendor/pygments-main/pygments/plugin.py +74 -0
- data/vendor/pygments-main/pygments/scanner.py +104 -0
- data/vendor/pygments-main/pygments/style.py +117 -0
- data/vendor/pygments-main/pygments/styles/__init__.py +70 -0
- data/vendor/pygments-main/pygments/styles/autumn.py +65 -0
- data/vendor/pygments-main/pygments/styles/borland.py +51 -0
- data/vendor/pygments-main/pygments/styles/bw.py +49 -0
- data/vendor/pygments-main/pygments/styles/colorful.py +81 -0
- data/vendor/pygments-main/pygments/styles/default.py +73 -0
- data/vendor/pygments-main/pygments/styles/emacs.py +72 -0
- data/vendor/pygments-main/pygments/styles/friendly.py +72 -0
- data/vendor/pygments-main/pygments/styles/fruity.py +42 -0
- data/vendor/pygments-main/pygments/styles/manni.py +75 -0
- data/vendor/pygments-main/pygments/styles/monokai.py +106 -0
- data/vendor/pygments-main/pygments/styles/murphy.py +80 -0
- data/vendor/pygments-main/pygments/styles/native.py +65 -0
- data/vendor/pygments-main/pygments/styles/pastie.py +75 -0
- data/vendor/pygments-main/pygments/styles/perldoc.py +69 -0
- data/vendor/pygments-main/pygments/styles/rrt.py +33 -0
- data/vendor/pygments-main/pygments/styles/tango.py +141 -0
- data/vendor/pygments-main/pygments/styles/trac.py +63 -0
- data/vendor/pygments-main/pygments/styles/vim.py +63 -0
- data/vendor/pygments-main/pygments/styles/vs.py +38 -0
- data/vendor/pygments-main/pygments/token.py +195 -0
- data/vendor/pygments-main/pygments/unistring.py +140 -0
- data/vendor/pygments-main/pygments/util.py +277 -0
- data/vendor/pygments-main/scripts/check_sources.py +242 -0
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +32 -0
- data/vendor/pygments-main/scripts/epydoc.css +280 -0
- data/vendor/pygments-main/scripts/find_codetags.py +205 -0
- data/vendor/pygments-main/scripts/find_error.py +170 -0
- data/vendor/pygments-main/scripts/get_vimkw.py +43 -0
- data/vendor/pygments-main/scripts/pylintrc +301 -0
- data/vendor/pygments-main/scripts/reindent.py +291 -0
- data/vendor/pygments-main/scripts/vim2pygments.py +933 -0
- data/vendor/pygments-main/setup.cfg +7 -0
- data/vendor/pygments-main/setup.py +90 -0
- data/vendor/pygments-main/tests/dtds/HTML4-f.dtd +37 -0
- data/vendor/pygments-main/tests/dtds/HTML4-s.dtd +869 -0
- data/vendor/pygments-main/tests/dtds/HTML4.dcl +88 -0
- data/vendor/pygments-main/tests/dtds/HTML4.dtd +1092 -0
- data/vendor/pygments-main/tests/dtds/HTML4.soc +9 -0
- data/vendor/pygments-main/tests/dtds/HTMLlat1.ent +195 -0
- data/vendor/pygments-main/tests/dtds/HTMLspec.ent +77 -0
- data/vendor/pygments-main/tests/dtds/HTMLsym.ent +241 -0
- data/vendor/pygments-main/tests/examplefiles/ANTLRv3.g +608 -0
- data/vendor/pygments-main/tests/examplefiles/AcidStateAdvanced.hs +209 -0
- data/vendor/pygments-main/tests/examplefiles/AlternatingGroup.mu +102 -0
- data/vendor/pygments-main/tests/examplefiles/BOM.js +1 -0
- data/vendor/pygments-main/tests/examplefiles/CPDictionary.j +611 -0
- data/vendor/pygments-main/tests/examplefiles/Config.in.cache +1973 -0
- data/vendor/pygments-main/tests/examplefiles/Constants.mo +158 -0
- data/vendor/pygments-main/tests/examplefiles/DancingSudoku.lhs +411 -0
- data/vendor/pygments-main/tests/examplefiles/Deflate.fs +578 -0
- data/vendor/pygments-main/tests/examplefiles/Errors.scala +18 -0
- data/vendor/pygments-main/tests/examplefiles/File.hy +174 -0
- data/vendor/pygments-main/tests/examplefiles/Get-CommandDefinitionHtml.ps1 +66 -0
- data/vendor/pygments-main/tests/examplefiles/IPDispatchC.nc +104 -0
- data/vendor/pygments-main/tests/examplefiles/IPDispatchP.nc +671 -0
- data/vendor/pygments-main/tests/examplefiles/Intro.java +1660 -0
- data/vendor/pygments-main/tests/examplefiles/Makefile +1131 -0
- data/vendor/pygments-main/tests/examplefiles/Object.st +4394 -0
- data/vendor/pygments-main/tests/examplefiles/OrderedMap.hx +584 -0
- data/vendor/pygments-main/tests/examplefiles/RoleQ.pm6 +23 -0
- data/vendor/pygments-main/tests/examplefiles/SmallCheck.hs +378 -0
- data/vendor/pygments-main/tests/examplefiles/Sorting.mod +470 -0
- data/vendor/pygments-main/tests/examplefiles/Sudoku.lhs +382 -0
- data/vendor/pygments-main/tests/examplefiles/addressbook.proto +30 -0
- data/vendor/pygments-main/tests/examplefiles/antlr_throws +1 -0
- data/vendor/pygments-main/tests/examplefiles/apache2.conf +393 -0
- data/vendor/pygments-main/tests/examplefiles/as3_test.as +143 -0
- data/vendor/pygments-main/tests/examplefiles/as3_test2.as +46 -0
- data/vendor/pygments-main/tests/examplefiles/as3_test3.as +3 -0
- data/vendor/pygments-main/tests/examplefiles/aspx-cs_example +27 -0
- data/vendor/pygments-main/tests/examplefiles/autoit_submit.au3 +25 -0
- data/vendor/pygments-main/tests/examplefiles/badcase.java +2 -0
- data/vendor/pygments-main/tests/examplefiles/batchfile.bat +49 -0
- data/vendor/pygments-main/tests/examplefiles/bigtest.nsi +308 -0
- data/vendor/pygments-main/tests/examplefiles/boot-9.scm +1557 -0
- data/vendor/pygments-main/tests/examplefiles/ca65_example +284 -0
- data/vendor/pygments-main/tests/examplefiles/cbmbas_example +9 -0
- data/vendor/pygments-main/tests/examplefiles/cells.ps +515 -0
- data/vendor/pygments-main/tests/examplefiles/ceval.c +2604 -0
- data/vendor/pygments-main/tests/examplefiles/cheetah_example.html +13 -0
- data/vendor/pygments-main/tests/examplefiles/classes.dylan +125 -0
- data/vendor/pygments-main/tests/examplefiles/condensed_ruby.rb +10 -0
- data/vendor/pygments-main/tests/examplefiles/coq_RelationClasses +447 -0
- data/vendor/pygments-main/tests/examplefiles/database.pytb +20 -0
- data/vendor/pygments-main/tests/examplefiles/de.MoinMoin.po +2461 -0
- data/vendor/pygments-main/tests/examplefiles/demo.ahk +181 -0
- data/vendor/pygments-main/tests/examplefiles/demo.cfm +38 -0
- data/vendor/pygments-main/tests/examplefiles/django_sample.html+django +68 -0
- data/vendor/pygments-main/tests/examplefiles/dwarf.cw +17 -0
- data/vendor/pygments-main/tests/examplefiles/erl_session +10 -0
- data/vendor/pygments-main/tests/examplefiles/escape_semicolon.clj +1 -0
- data/vendor/pygments-main/tests/examplefiles/evil_regex.js +48 -0
- data/vendor/pygments-main/tests/examplefiles/example.Rd +78 -0
- data/vendor/pygments-main/tests/examplefiles/example.bug +54 -0
- data/vendor/pygments-main/tests/examplefiles/example.c +2080 -0
- data/vendor/pygments-main/tests/examplefiles/example.ceylon +52 -0
- data/vendor/pygments-main/tests/examplefiles/example.clay +33 -0
- data/vendor/pygments-main/tests/examplefiles/example.cls +15 -0
- data/vendor/pygments-main/tests/examplefiles/example.cob +3556 -0
- data/vendor/pygments-main/tests/examplefiles/example.cpp +2363 -0
- data/vendor/pygments-main/tests/examplefiles/example.gs +106 -0
- data/vendor/pygments-main/tests/examplefiles/example.gst +7 -0
- data/vendor/pygments-main/tests/examplefiles/example.hx +142 -0
- data/vendor/pygments-main/tests/examplefiles/example.jag +48 -0
- data/vendor/pygments-main/tests/examplefiles/example.kt +47 -0
- data/vendor/pygments-main/tests/examplefiles/example.lagda +19 -0
- data/vendor/pygments-main/tests/examplefiles/example.lua +250 -0
- data/vendor/pygments-main/tests/examplefiles/example.monkey +152 -0
- data/vendor/pygments-main/tests/examplefiles/example.moo +26 -0
- data/vendor/pygments-main/tests/examplefiles/example.moon +629 -0
- data/vendor/pygments-main/tests/examplefiles/example.msc +43 -0
- data/vendor/pygments-main/tests/examplefiles/example.nim +1010 -0
- data/vendor/pygments-main/tests/examplefiles/example.ns2 +69 -0
- data/vendor/pygments-main/tests/examplefiles/example.p +34 -0
- data/vendor/pygments-main/tests/examplefiles/example.pas +2708 -0
- data/vendor/pygments-main/tests/examplefiles/example.prg +161 -0
- data/vendor/pygments-main/tests/examplefiles/example.rb +1852 -0
- data/vendor/pygments-main/tests/examplefiles/example.reg +19 -0
- data/vendor/pygments-main/tests/examplefiles/example.rexx +50 -0
- data/vendor/pygments-main/tests/examplefiles/example.rhtml +561 -0
- data/vendor/pygments-main/tests/examplefiles/example.rkt +95 -0
- data/vendor/pygments-main/tests/examplefiles/example.rpf +4 -0
- data/vendor/pygments-main/tests/examplefiles/example.sh-session +19 -0
- data/vendor/pygments-main/tests/examplefiles/example.shell-session +45 -0
- data/vendor/pygments-main/tests/examplefiles/example.sml +156 -0
- data/vendor/pygments-main/tests/examplefiles/example.snobol +15 -0
- data/vendor/pygments-main/tests/examplefiles/example.stan +108 -0
- data/vendor/pygments-main/tests/examplefiles/example.tea +34 -0
- data/vendor/pygments-main/tests/examplefiles/example.ts +28 -0
- data/vendor/pygments-main/tests/examplefiles/example.u +548 -0
- data/vendor/pygments-main/tests/examplefiles/example.weechatlog +9 -0
- data/vendor/pygments-main/tests/examplefiles/example.xhtml +376 -0
- data/vendor/pygments-main/tests/examplefiles/example.xtend +34 -0
- data/vendor/pygments-main/tests/examplefiles/example.yaml +302 -0
- data/vendor/pygments-main/tests/examplefiles/example2.aspx +29 -0
- data/vendor/pygments-main/tests/examplefiles/example2.msc +79 -0
- data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +363 -0
- data/vendor/pygments-main/tests/examplefiles/example_file.fy +128 -0
- data/vendor/pygments-main/tests/examplefiles/firefox.mak +586 -0
- data/vendor/pygments-main/tests/examplefiles/flipflop.sv +19 -0
- data/vendor/pygments-main/tests/examplefiles/foo.sce +6 -0
- data/vendor/pygments-main/tests/examplefiles/format.ml +1213 -0
- data/vendor/pygments-main/tests/examplefiles/fucked_up.rb +77 -0
- data/vendor/pygments-main/tests/examplefiles/function.mu +1 -0
- data/vendor/pygments-main/tests/examplefiles/functional.rst +1472 -0
- data/vendor/pygments-main/tests/examplefiles/garcia-wachs.kk +133 -0
- data/vendor/pygments-main/tests/examplefiles/genclass.clj +510 -0
- data/vendor/pygments-main/tests/examplefiles/genshi_example.xml+genshi +193 -0
- data/vendor/pygments-main/tests/examplefiles/genshitext_example.genshitext +33 -0
- data/vendor/pygments-main/tests/examplefiles/glsl.frag +7 -0
- data/vendor/pygments-main/tests/examplefiles/glsl.vert +13 -0
- data/vendor/pygments-main/tests/examplefiles/grammar-test.p6 +22 -0
- data/vendor/pygments-main/tests/examplefiles/hello.smali +40 -0
- data/vendor/pygments-main/tests/examplefiles/hello.sp +9 -0
- data/vendor/pygments-main/tests/examplefiles/html+php_faulty.php +1 -0
- data/vendor/pygments-main/tests/examplefiles/http_request_example +15 -0
- data/vendor/pygments-main/tests/examplefiles/http_response_example +29 -0
- data/vendor/pygments-main/tests/examplefiles/import.hs +4 -0
- data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +71 -0
- data/vendor/pygments-main/tests/examplefiles/intro.ik +24 -0
- data/vendor/pygments-main/tests/examplefiles/ints.php +10 -0
- data/vendor/pygments-main/tests/examplefiles/intsyn.fun +675 -0
- data/vendor/pygments-main/tests/examplefiles/intsyn.sig +286 -0
- data/vendor/pygments-main/tests/examplefiles/irb_heredoc +8 -0
- data/vendor/pygments-main/tests/examplefiles/irc.lsp +214 -0
- data/vendor/pygments-main/tests/examplefiles/java.properties +16 -0
- data/vendor/pygments-main/tests/examplefiles/jbst_example1.jbst +28 -0
- data/vendor/pygments-main/tests/examplefiles/jbst_example2.jbst +45 -0
- data/vendor/pygments-main/tests/examplefiles/jinjadesignerdoc.rst +713 -0
- data/vendor/pygments-main/tests/examplefiles/json.lasso +301 -0
- data/vendor/pygments-main/tests/examplefiles/json.lasso9 +213 -0
- data/vendor/pygments-main/tests/examplefiles/lighttpd_config.conf +13 -0
- data/vendor/pygments-main/tests/examplefiles/linecontinuation.py +47 -0
- data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +41 -0
- data/vendor/pygments-main/tests/examplefiles/logos_example.xm +28 -0
- data/vendor/pygments-main/tests/examplefiles/ltmain.sh +2849 -0
- data/vendor/pygments-main/tests/examplefiles/main.cmake +42 -0
- data/vendor/pygments-main/tests/examplefiles/markdown.lsp +679 -0
- data/vendor/pygments-main/tests/examplefiles/matlab_noreturn +3 -0
- data/vendor/pygments-main/tests/examplefiles/matlab_sample +30 -0
- data/vendor/pygments-main/tests/examplefiles/matlabsession_sample.txt +37 -0
- data/vendor/pygments-main/tests/examplefiles/metagrammar.treetop +455 -0
- data/vendor/pygments-main/tests/examplefiles/mg_sample.pro +73 -0
- data/vendor/pygments-main/tests/examplefiles/minehunt.qml +112 -0
- data/vendor/pygments-main/tests/examplefiles/minimal.ns2 +4 -0
- data/vendor/pygments-main/tests/examplefiles/moin_SyntaxReference.txt +340 -0
- data/vendor/pygments-main/tests/examplefiles/multiline_regexes.rb +38 -0
- data/vendor/pygments-main/tests/examplefiles/nanomsg.intr +95 -0
- data/vendor/pygments-main/tests/examplefiles/nasm_aoutso.asm +96 -0
- data/vendor/pygments-main/tests/examplefiles/nasm_objexe.asm +30 -0
- data/vendor/pygments-main/tests/examplefiles/nemerle_sample.n +87 -0
- data/vendor/pygments-main/tests/examplefiles/nginx_nginx.conf +118 -0
- data/vendor/pygments-main/tests/examplefiles/numbers.c +12 -0
- data/vendor/pygments-main/tests/examplefiles/objc_example.m +32 -0
- data/vendor/pygments-main/tests/examplefiles/objc_example2.m +24 -0
- data/vendor/pygments-main/tests/examplefiles/perl_misc +62 -0
- data/vendor/pygments-main/tests/examplefiles/perl_perl5db +998 -0
- data/vendor/pygments-main/tests/examplefiles/perl_regex-delims +120 -0
- data/vendor/pygments-main/tests/examplefiles/perlfunc.1 +856 -0
- data/vendor/pygments-main/tests/examplefiles/phpMyAdmin.spec +163 -0
- data/vendor/pygments-main/tests/examplefiles/phpcomplete.vim +567 -0
- data/vendor/pygments-main/tests/examplefiles/pleac.in.rb +1223 -0
- data/vendor/pygments-main/tests/examplefiles/postgresql_test.txt +47 -0
- data/vendor/pygments-main/tests/examplefiles/pppoe.applescript +10 -0
- data/vendor/pygments-main/tests/examplefiles/psql_session.txt +122 -0
- data/vendor/pygments-main/tests/examplefiles/py3_test.txt +2 -0
- data/vendor/pygments-main/tests/examplefiles/py3tb_test.py3tb +4 -0
- data/vendor/pygments-main/tests/examplefiles/pycon_test.pycon +14 -0
- data/vendor/pygments-main/tests/examplefiles/pytb_test2.pytb +2 -0
- data/vendor/pygments-main/tests/examplefiles/pytb_test3.pytb +4 -0
- data/vendor/pygments-main/tests/examplefiles/python25-bsd.mak +234 -0
- data/vendor/pygments-main/tests/examplefiles/qsort.prolog +13 -0
- data/vendor/pygments-main/tests/examplefiles/r-console-transcript.Rout +38 -0
- data/vendor/pygments-main/tests/examplefiles/ragel-cpp_rlscan +280 -0
- data/vendor/pygments-main/tests/examplefiles/ragel-cpp_snippet +2 -0
- data/vendor/pygments-main/tests/examplefiles/regex.js +22 -0
- data/vendor/pygments-main/tests/examplefiles/reversi.lsp +427 -0
- data/vendor/pygments-main/tests/examplefiles/robotframework.txt +39 -0
- data/vendor/pygments-main/tests/examplefiles/ruby_func_def.rb +11 -0
- data/vendor/pygments-main/tests/examplefiles/rust_example.rs +233 -0
- data/vendor/pygments-main/tests/examplefiles/scilab.sci +30 -0
- data/vendor/pygments-main/tests/examplefiles/session.dylan-console +9 -0
- data/vendor/pygments-main/tests/examplefiles/sibling.prolog +19 -0
- data/vendor/pygments-main/tests/examplefiles/simple.md +747 -0
- data/vendor/pygments-main/tests/examplefiles/smarty_example.html +209 -0
- data/vendor/pygments-main/tests/examplefiles/source.lgt +343 -0
- data/vendor/pygments-main/tests/examplefiles/sources.list +62 -0
- data/vendor/pygments-main/tests/examplefiles/sphere.pov +18 -0
- data/vendor/pygments-main/tests/examplefiles/sqlite3.sqlite3-console +27 -0
- data/vendor/pygments-main/tests/examplefiles/squid.conf +30 -0
- data/vendor/pygments-main/tests/examplefiles/string.jl +1031 -0
- data/vendor/pygments-main/tests/examplefiles/string_delimiters.d +21 -0
- data/vendor/pygments-main/tests/examplefiles/stripheredoc.sh +3 -0
- data/vendor/pygments-main/tests/examplefiles/swig_java.swg +1329 -0
- data/vendor/pygments-main/tests/examplefiles/swig_std_vector.i +225 -0
- data/vendor/pygments-main/tests/examplefiles/test.R +153 -0
- data/vendor/pygments-main/tests/examplefiles/test.adb +211 -0
- data/vendor/pygments-main/tests/examplefiles/test.agda +102 -0
- data/vendor/pygments-main/tests/examplefiles/test.asy +131 -0
- data/vendor/pygments-main/tests/examplefiles/test.awk +121 -0
- data/vendor/pygments-main/tests/examplefiles/test.bas +29 -0
- data/vendor/pygments-main/tests/examplefiles/test.bb +95 -0
- data/vendor/pygments-main/tests/examplefiles/test.bmx +145 -0
- data/vendor/pygments-main/tests/examplefiles/test.boo +39 -0
- data/vendor/pygments-main/tests/examplefiles/test.bro +250 -0
- data/vendor/pygments-main/tests/examplefiles/test.cs +374 -0
- data/vendor/pygments-main/tests/examplefiles/test.css +54 -0
- data/vendor/pygments-main/tests/examplefiles/test.cu +36 -0
- data/vendor/pygments-main/tests/examplefiles/test.d +135 -0
- data/vendor/pygments-main/tests/examplefiles/test.dart +23 -0
- data/vendor/pygments-main/tests/examplefiles/test.dtd +89 -0
- data/vendor/pygments-main/tests/examplefiles/test.ebnf +31 -0
- data/vendor/pygments-main/tests/examplefiles/test.ec +605 -0
- data/vendor/pygments-main/tests/examplefiles/test.ecl +58 -0
- data/vendor/pygments-main/tests/examplefiles/test.eh +315 -0
- data/vendor/pygments-main/tests/examplefiles/test.erl +169 -0
- data/vendor/pygments-main/tests/examplefiles/test.evoque +33 -0
- data/vendor/pygments-main/tests/examplefiles/test.fan +818 -0
- data/vendor/pygments-main/tests/examplefiles/test.flx +57 -0
- data/vendor/pygments-main/tests/examplefiles/test.gdc +13 -0
- data/vendor/pygments-main/tests/examplefiles/test.groovy +97 -0
- data/vendor/pygments-main/tests/examplefiles/test.html +339 -0
- data/vendor/pygments-main/tests/examplefiles/test.ini +10 -0
- data/vendor/pygments-main/tests/examplefiles/test.java +653 -0
- data/vendor/pygments-main/tests/examplefiles/test.jsp +24 -0
- data/vendor/pygments-main/tests/examplefiles/test.maql +45 -0
- data/vendor/pygments-main/tests/examplefiles/test.mod +374 -0
- data/vendor/pygments-main/tests/examplefiles/test.moo +51 -0
- data/vendor/pygments-main/tests/examplefiles/test.myt +166 -0
- data/vendor/pygments-main/tests/examplefiles/test.nim +93 -0
- data/vendor/pygments-main/tests/examplefiles/test.opa +10 -0
- data/vendor/pygments-main/tests/examplefiles/test.p6 +252 -0
- data/vendor/pygments-main/tests/examplefiles/test.pas +743 -0
- data/vendor/pygments-main/tests/examplefiles/test.php +505 -0
- data/vendor/pygments-main/tests/examplefiles/test.plot +333 -0
- data/vendor/pygments-main/tests/examplefiles/test.ps1 +108 -0
- data/vendor/pygments-main/tests/examplefiles/test.pypylog +1839 -0
- data/vendor/pygments-main/tests/examplefiles/test.r3 +94 -0
- data/vendor/pygments-main/tests/examplefiles/test.rb +177 -0
- data/vendor/pygments-main/tests/examplefiles/test.rhtml +43 -0
- data/vendor/pygments-main/tests/examplefiles/test.scaml +8 -0
- data/vendor/pygments-main/tests/examplefiles/test.ssp +12 -0
- data/vendor/pygments-main/tests/examplefiles/test.tcsh +830 -0
- data/vendor/pygments-main/tests/examplefiles/test.vb +407 -0
- data/vendor/pygments-main/tests/examplefiles/test.vhdl +161 -0
- data/vendor/pygments-main/tests/examplefiles/test.xqy +138 -0
- data/vendor/pygments-main/tests/examplefiles/test.xsl +23 -0
- data/vendor/pygments-main/tests/examplefiles/test2.pypylog +120 -0
- data/vendor/pygments-main/tests/examplefiles/truncated.pytb +15 -0
- data/vendor/pygments-main/tests/examplefiles/type.lisp +1218 -0
- data/vendor/pygments-main/tests/examplefiles/underscore.coffee +603 -0
- data/vendor/pygments-main/tests/examplefiles/unicode.applescript +5 -0
- data/vendor/pygments-main/tests/examplefiles/unicodedoc.py +11 -0
- data/vendor/pygments-main/tests/examplefiles/unix-io.lid +37 -0
- data/vendor/pygments-main/tests/examplefiles/webkit-transition.css +3 -0
- data/vendor/pygments-main/tests/examplefiles/while.pov +13 -0
- data/vendor/pygments-main/tests/examplefiles/wiki.factor +384 -0
- data/vendor/pygments-main/tests/examplefiles/xml_example +1897 -0
- data/vendor/pygments-main/tests/examplefiles/zmlrpc.f90 +798 -0
- data/vendor/pygments-main/tests/old_run.py +138 -0
- data/vendor/pygments-main/tests/run.py +49 -0
- data/vendor/pygments-main/tests/support.py +15 -0
- data/vendor/pygments-main/tests/support/tags +36 -0
- data/vendor/pygments-main/tests/test_basic_api.py +295 -0
- data/vendor/pygments-main/tests/test_clexer.py +31 -0
- data/vendor/pygments-main/tests/test_cmdline.py +105 -0
- data/vendor/pygments-main/tests/test_examplefiles.py +99 -0
- data/vendor/pygments-main/tests/test_html_formatter.py +178 -0
- data/vendor/pygments-main/tests/test_latex_formatter.py +55 -0
- data/vendor/pygments-main/tests/test_lexers_other.py +68 -0
- data/vendor/pygments-main/tests/test_perllexer.py +137 -0
- data/vendor/pygments-main/tests/test_regexlexer.py +47 -0
- data/vendor/pygments-main/tests/test_token.py +46 -0
- data/vendor/pygments-main/tests/test_using_api.py +40 -0
- data/vendor/pygments-main/tests/test_util.py +135 -0
- data/vendor/simplejson/.gitignore +10 -0
- data/vendor/simplejson/.travis.yml +5 -0
- data/vendor/simplejson/CHANGES.txt +291 -0
- data/vendor/simplejson/LICENSE.txt +19 -0
- data/vendor/simplejson/MANIFEST.in +5 -0
- data/vendor/simplejson/README.rst +19 -0
- data/vendor/simplejson/conf.py +179 -0
- data/vendor/simplejson/index.rst +628 -0
- data/vendor/simplejson/scripts/make_docs.py +18 -0
- data/vendor/simplejson/setup.py +104 -0
- data/vendor/simplejson/simplejson/__init__.py +510 -0
- data/vendor/simplejson/simplejson/_speedups.c +2745 -0
- data/vendor/simplejson/simplejson/decoder.py +425 -0
- data/vendor/simplejson/simplejson/encoder.py +567 -0
- data/vendor/simplejson/simplejson/ordered_dict.py +119 -0
- data/vendor/simplejson/simplejson/scanner.py +77 -0
- data/vendor/simplejson/simplejson/tests/__init__.py +67 -0
- data/vendor/simplejson/simplejson/tests/test_bigint_as_string.py +55 -0
- data/vendor/simplejson/simplejson/tests/test_check_circular.py +30 -0
- data/vendor/simplejson/simplejson/tests/test_decimal.py +66 -0
- data/vendor/simplejson/simplejson/tests/test_decode.py +83 -0
- data/vendor/simplejson/simplejson/tests/test_default.py +9 -0
- data/vendor/simplejson/simplejson/tests/test_dump.py +67 -0
- data/vendor/simplejson/simplejson/tests/test_encode_basestring_ascii.py +46 -0
- data/vendor/simplejson/simplejson/tests/test_encode_for_html.py +32 -0
- data/vendor/simplejson/simplejson/tests/test_errors.py +34 -0
- data/vendor/simplejson/simplejson/tests/test_fail.py +91 -0
- data/vendor/simplejson/simplejson/tests/test_float.py +19 -0
- data/vendor/simplejson/simplejson/tests/test_indent.py +86 -0
- data/vendor/simplejson/simplejson/tests/test_item_sort_key.py +20 -0
- data/vendor/simplejson/simplejson/tests/test_namedtuple.py +121 -0
- data/vendor/simplejson/simplejson/tests/test_pass1.py +76 -0
- data/vendor/simplejson/simplejson/tests/test_pass2.py +14 -0
- data/vendor/simplejson/simplejson/tests/test_pass3.py +20 -0
- data/vendor/simplejson/simplejson/tests/test_recursion.py +67 -0
- data/vendor/simplejson/simplejson/tests/test_scanstring.py +117 -0
- data/vendor/simplejson/simplejson/tests/test_separators.py +42 -0
- data/vendor/simplejson/simplejson/tests/test_speedups.py +20 -0
- data/vendor/simplejson/simplejson/tests/test_tuple.py +49 -0
- data/vendor/simplejson/simplejson/tests/test_unicode.py +109 -0
- data/vendor/simplejson/simplejson/tool.py +39 -0
- metadata +557 -0
@@ -0,0 +1,4045 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.web
|
4
|
+
~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexers for web-related languages and markup.
|
7
|
+
|
8
|
+
:copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
|
9
|
+
:license: BSD, see LICENSE for details.
|
10
|
+
"""
|
11
|
+
|
12
|
+
import re
|
13
|
+
import copy
|
14
|
+
|
15
|
+
from pygments.lexer import RegexLexer, ExtendedRegexLexer, bygroups, using, \
|
16
|
+
include, this
|
17
|
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
18
|
+
Number, Other, Punctuation, Literal
|
19
|
+
from pygments.util import get_bool_opt, get_list_opt, looks_like_xml, \
|
20
|
+
html_doctype_matches, unirange
|
21
|
+
from pygments.lexers.agile import RubyLexer
|
22
|
+
from pygments.lexers.compiled import ScalaLexer
|
23
|
+
|
24
|
+
|
25
|
+
__all__ = ['HtmlLexer', 'XmlLexer', 'JavascriptLexer', 'JsonLexer', 'CssLexer',
|
26
|
+
'PhpLexer', 'ActionScriptLexer', 'XsltLexer', 'ActionScript3Lexer',
|
27
|
+
'MxmlLexer', 'HaxeLexer', 'HamlLexer', 'SassLexer', 'ScssLexer',
|
28
|
+
'ObjectiveJLexer', 'CoffeeScriptLexer', 'LiveScriptLexer',
|
29
|
+
'DuelLexer', 'ScamlLexer', 'JadeLexer', 'XQueryLexer',
|
30
|
+
'DtdLexer', 'DartLexer', 'LassoLexer', 'QmlLexer', 'TypeScriptLexer']
|
31
|
+
|
32
|
+
|
33
|
+
class JavascriptLexer(RegexLexer):
|
34
|
+
"""
|
35
|
+
For JavaScript source code.
|
36
|
+
"""
|
37
|
+
|
38
|
+
name = 'JavaScript'
|
39
|
+
aliases = ['js', 'javascript']
|
40
|
+
filenames = ['*.js', ]
|
41
|
+
mimetypes = ['application/javascript', 'application/x-javascript',
|
42
|
+
'text/x-javascript', 'text/javascript', ]
|
43
|
+
|
44
|
+
flags = re.DOTALL
|
45
|
+
tokens = {
|
46
|
+
'commentsandwhitespace': [
|
47
|
+
(r'\s+', Text),
|
48
|
+
(r'<!--', Comment),
|
49
|
+
(r'//.*?\n', Comment.Single),
|
50
|
+
(r'/\*.*?\*/', Comment.Multiline)
|
51
|
+
],
|
52
|
+
'slashstartsregex': [
|
53
|
+
include('commentsandwhitespace'),
|
54
|
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
55
|
+
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
56
|
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
57
|
+
(r'', Text, '#pop')
|
58
|
+
],
|
59
|
+
'badregex': [
|
60
|
+
(r'\n', Text, '#pop')
|
61
|
+
],
|
62
|
+
'root': [
|
63
|
+
(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
|
64
|
+
include('commentsandwhitespace'),
|
65
|
+
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
|
66
|
+
r'(<<|>>>?|==?|!=?|[-<>+*%&\|\^/])=?', Operator, 'slashstartsregex'),
|
67
|
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
68
|
+
(r'[})\].]', Punctuation),
|
69
|
+
(r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
|
70
|
+
r'throw|try|catch|finally|new|delete|typeof|instanceof|void|yield|'
|
71
|
+
r'this)\b', Keyword, 'slashstartsregex'),
|
72
|
+
(r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
|
73
|
+
(r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|'
|
74
|
+
r'extends|final|float|goto|implements|import|int|interface|long|native|'
|
75
|
+
r'package|private|protected|public|short|static|super|synchronized|throws|'
|
76
|
+
r'transient|volatile)\b', Keyword.Reserved),
|
77
|
+
(r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
|
78
|
+
(r'(Array|Boolean|Date|Error|Function|Math|netscape|'
|
79
|
+
r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
|
80
|
+
r'decodeURIComponent|encodeURI|encodeURIComponent|'
|
81
|
+
r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
|
82
|
+
r'window)\b', Name.Builtin),
|
83
|
+
(r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
|
84
|
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
85
|
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
86
|
+
(r'[0-9]+', Number.Integer),
|
87
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
88
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
89
|
+
]
|
90
|
+
}
|
91
|
+
|
92
|
+
|
93
|
+
class JsonLexer(RegexLexer):
|
94
|
+
"""
|
95
|
+
For JSON data structures.
|
96
|
+
|
97
|
+
*New in Pygments 1.5.*
|
98
|
+
"""
|
99
|
+
|
100
|
+
name = 'JSON'
|
101
|
+
aliases = ['json']
|
102
|
+
filenames = ['*.json']
|
103
|
+
mimetypes = [ 'application/json', ]
|
104
|
+
|
105
|
+
# integer part of a number
|
106
|
+
int_part = r'-?(0|[1-9]\d*)'
|
107
|
+
|
108
|
+
# fractional part of a number
|
109
|
+
frac_part = r'\.\d+'
|
110
|
+
|
111
|
+
# exponential part of a number
|
112
|
+
exp_part = r'[eE](\+|-)?\d+'
|
113
|
+
|
114
|
+
|
115
|
+
flags = re.DOTALL
|
116
|
+
tokens = {
|
117
|
+
'whitespace': [
|
118
|
+
(r'\s+', Text),
|
119
|
+
],
|
120
|
+
|
121
|
+
# represents a simple terminal value
|
122
|
+
'simplevalue': [
|
123
|
+
(r'(true|false|null)\b', Keyword.Constant),
|
124
|
+
(('%(int_part)s(%(frac_part)s%(exp_part)s|'
|
125
|
+
'%(exp_part)s|%(frac_part)s)') % vars(),
|
126
|
+
Number.Float),
|
127
|
+
(int_part, Number.Integer),
|
128
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
129
|
+
],
|
130
|
+
|
131
|
+
|
132
|
+
# the right hand side of an object, after the attribute name
|
133
|
+
'objectattribute': [
|
134
|
+
include('value'),
|
135
|
+
(r':', Punctuation),
|
136
|
+
# comma terminates the attribute but expects more
|
137
|
+
(r',', Punctuation, '#pop'),
|
138
|
+
# a closing bracket terminates the entire object, so pop twice
|
139
|
+
(r'}', Punctuation, ('#pop', '#pop')),
|
140
|
+
],
|
141
|
+
|
142
|
+
# a json object - { attr, attr, ... }
|
143
|
+
'objectvalue': [
|
144
|
+
include('whitespace'),
|
145
|
+
(r'"(\\\\|\\"|[^"])*"', Name.Tag, 'objectattribute'),
|
146
|
+
(r'}', Punctuation, '#pop'),
|
147
|
+
],
|
148
|
+
|
149
|
+
# json array - [ value, value, ... }
|
150
|
+
'arrayvalue': [
|
151
|
+
include('whitespace'),
|
152
|
+
include('value'),
|
153
|
+
(r',', Punctuation),
|
154
|
+
(r']', Punctuation, '#pop'),
|
155
|
+
],
|
156
|
+
|
157
|
+
# a json value - either a simple value or a complex value (object or array)
|
158
|
+
'value': [
|
159
|
+
include('whitespace'),
|
160
|
+
include('simplevalue'),
|
161
|
+
(r'{', Punctuation, 'objectvalue'),
|
162
|
+
(r'\[', Punctuation, 'arrayvalue'),
|
163
|
+
],
|
164
|
+
|
165
|
+
|
166
|
+
# the root of a json document whould be a value
|
167
|
+
'root': [
|
168
|
+
include('value'),
|
169
|
+
],
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
JSONLexer = JsonLexer # for backwards compatibility with Pygments 1.5
|
174
|
+
|
175
|
+
|
176
|
+
class ActionScriptLexer(RegexLexer):
|
177
|
+
"""
|
178
|
+
For ActionScript source code.
|
179
|
+
|
180
|
+
*New in Pygments 0.9.*
|
181
|
+
"""
|
182
|
+
|
183
|
+
name = 'ActionScript'
|
184
|
+
aliases = ['as', 'actionscript']
|
185
|
+
filenames = ['*.as']
|
186
|
+
mimetypes = ['application/x-actionscript3', 'text/x-actionscript3',
|
187
|
+
'text/actionscript3']
|
188
|
+
|
189
|
+
flags = re.DOTALL
|
190
|
+
tokens = {
|
191
|
+
'root': [
|
192
|
+
(r'\s+', Text),
|
193
|
+
(r'//.*?\n', Comment.Single),
|
194
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
195
|
+
(r'/(\\\\|\\/|[^/\n])*/[gim]*', String.Regex),
|
196
|
+
(r'[~\^\*!%&<>\|+=:;,/?\\-]+', Operator),
|
197
|
+
(r'[{}\[\]();.]+', Punctuation),
|
198
|
+
(r'(case|default|for|each|in|while|do|break|return|continue|if|else|'
|
199
|
+
r'throw|try|catch|var|with|new|typeof|arguments|instanceof|this|'
|
200
|
+
r'switch)\b', Keyword),
|
201
|
+
(r'(class|public|final|internal|native|override|private|protected|'
|
202
|
+
r'static|import|extends|implements|interface|intrinsic|return|super|'
|
203
|
+
r'dynamic|function|const|get|namespace|package|set)\b',
|
204
|
+
Keyword.Declaration),
|
205
|
+
(r'(true|false|null|NaN|Infinity|-Infinity|undefined|Void)\b',
|
206
|
+
Keyword.Constant),
|
207
|
+
(r'(Accessibility|AccessibilityProperties|ActionScriptVersion|'
|
208
|
+
r'ActivityEvent|AntiAliasType|ApplicationDomain|AsBroadcaster|Array|'
|
209
|
+
r'AsyncErrorEvent|AVM1Movie|BevelFilter|Bitmap|BitmapData|'
|
210
|
+
r'BitmapDataChannel|BitmapFilter|BitmapFilterQuality|BitmapFilterType|'
|
211
|
+
r'BlendMode|BlurFilter|Boolean|ByteArray|Camera|Capabilities|CapsStyle|'
|
212
|
+
r'Class|Color|ColorMatrixFilter|ColorTransform|ContextMenu|'
|
213
|
+
r'ContextMenuBuiltInItems|ContextMenuEvent|ContextMenuItem|'
|
214
|
+
r'ConvultionFilter|CSMSettings|DataEvent|Date|DefinitionError|'
|
215
|
+
r'DeleteObjectSample|Dictionary|DisplacmentMapFilter|DisplayObject|'
|
216
|
+
r'DisplacmentMapFilterMode|DisplayObjectContainer|DropShadowFilter|'
|
217
|
+
r'Endian|EOFError|Error|ErrorEvent|EvalError|Event|EventDispatcher|'
|
218
|
+
r'EventPhase|ExternalInterface|FileFilter|FileReference|'
|
219
|
+
r'FileReferenceList|FocusDirection|FocusEvent|Font|FontStyle|FontType|'
|
220
|
+
r'FrameLabel|FullScreenEvent|Function|GlowFilter|GradientBevelFilter|'
|
221
|
+
r'GradientGlowFilter|GradientType|Graphics|GridFitType|HTTPStatusEvent|'
|
222
|
+
r'IBitmapDrawable|ID3Info|IDataInput|IDataOutput|IDynamicPropertyOutput'
|
223
|
+
r'IDynamicPropertyWriter|IEventDispatcher|IExternalizable|'
|
224
|
+
r'IllegalOperationError|IME|IMEConversionMode|IMEEvent|int|'
|
225
|
+
r'InteractiveObject|InterpolationMethod|InvalidSWFError|InvokeEvent|'
|
226
|
+
r'IOError|IOErrorEvent|JointStyle|Key|Keyboard|KeyboardEvent|KeyLocation|'
|
227
|
+
r'LineScaleMode|Loader|LoaderContext|LoaderInfo|LoadVars|LocalConnection|'
|
228
|
+
r'Locale|Math|Matrix|MemoryError|Microphone|MorphShape|Mouse|MouseEvent|'
|
229
|
+
r'MovieClip|MovieClipLoader|Namespace|NetConnection|NetStatusEvent|'
|
230
|
+
r'NetStream|NewObjectSample|Number|Object|ObjectEncoding|PixelSnapping|'
|
231
|
+
r'Point|PrintJob|PrintJobOptions|PrintJobOrientation|ProgressEvent|Proxy|'
|
232
|
+
r'QName|RangeError|Rectangle|ReferenceError|RegExp|Responder|Sample|Scene|'
|
233
|
+
r'ScriptTimeoutError|Security|SecurityDomain|SecurityError|'
|
234
|
+
r'SecurityErrorEvent|SecurityPanel|Selection|Shape|SharedObject|'
|
235
|
+
r'SharedObjectFlushStatus|SimpleButton|Socket|Sound|SoundChannel|'
|
236
|
+
r'SoundLoaderContext|SoundMixer|SoundTransform|SpreadMethod|Sprite|'
|
237
|
+
r'StackFrame|StackOverflowError|Stage|StageAlign|StageDisplayState|'
|
238
|
+
r'StageQuality|StageScaleMode|StaticText|StatusEvent|String|StyleSheet|'
|
239
|
+
r'SWFVersion|SyncEvent|SyntaxError|System|TextColorType|TextField|'
|
240
|
+
r'TextFieldAutoSize|TextFieldType|TextFormat|TextFormatAlign|'
|
241
|
+
r'TextLineMetrics|TextRenderer|TextSnapshot|Timer|TimerEvent|Transform|'
|
242
|
+
r'TypeError|uint|URIError|URLLoader|URLLoaderDataFormat|URLRequest|'
|
243
|
+
r'URLRequestHeader|URLRequestMethod|URLStream|URLVariabeles|VerifyError|'
|
244
|
+
r'Video|XML|XMLDocument|XMLList|XMLNode|XMLNodeType|XMLSocket|XMLUI)\b',
|
245
|
+
Name.Builtin),
|
246
|
+
(r'(decodeURI|decodeURIComponent|encodeURI|escape|eval|isFinite|isNaN|'
|
247
|
+
r'isXMLName|clearInterval|fscommand|getTimer|getURL|getVersion|'
|
248
|
+
r'isFinite|parseFloat|parseInt|setInterval|trace|updateAfterEvent|'
|
249
|
+
r'unescape)\b',Name.Function),
|
250
|
+
(r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
|
251
|
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
252
|
+
(r'0x[0-9a-f]+', Number.Hex),
|
253
|
+
(r'[0-9]+', Number.Integer),
|
254
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
255
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
256
|
+
]
|
257
|
+
}
|
258
|
+
|
259
|
+
|
260
|
+
class ActionScript3Lexer(RegexLexer):
|
261
|
+
"""
|
262
|
+
For ActionScript 3 source code.
|
263
|
+
|
264
|
+
*New in Pygments 0.11.*
|
265
|
+
"""
|
266
|
+
|
267
|
+
name = 'ActionScript 3'
|
268
|
+
aliases = ['as3', 'actionscript3']
|
269
|
+
filenames = ['*.as']
|
270
|
+
mimetypes = ['application/x-actionscript', 'text/x-actionscript',
|
271
|
+
'text/actionscript']
|
272
|
+
|
273
|
+
identifier = r'[$a-zA-Z_][a-zA-Z0-9_]*'
|
274
|
+
typeidentifier = identifier + '(?:\.<\w+>)?'
|
275
|
+
|
276
|
+
flags = re.DOTALL | re.MULTILINE
|
277
|
+
tokens = {
|
278
|
+
'root': [
|
279
|
+
(r'\s+', Text),
|
280
|
+
(r'(function\s+)(' + identifier + r')(\s*)(\()',
|
281
|
+
bygroups(Keyword.Declaration, Name.Function, Text, Operator),
|
282
|
+
'funcparams'),
|
283
|
+
(r'(var|const)(\s+)(' + identifier + r')(\s*)(:)(\s*)(' +
|
284
|
+
typeidentifier + r')',
|
285
|
+
bygroups(Keyword.Declaration, Text, Name, Text, Punctuation, Text,
|
286
|
+
Keyword.Type)),
|
287
|
+
(r'(import|package)(\s+)((?:' + identifier + r'|\.)+)(\s*)',
|
288
|
+
bygroups(Keyword, Text, Name.Namespace, Text)),
|
289
|
+
(r'(new)(\s+)(' + typeidentifier + r')(\s*)(\()',
|
290
|
+
bygroups(Keyword, Text, Keyword.Type, Text, Operator)),
|
291
|
+
(r'//.*?\n', Comment.Single),
|
292
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
293
|
+
(r'/(\\\\|\\/|[^\n])*/[gisx]*', String.Regex),
|
294
|
+
(r'(\.)(' + identifier + r')', bygroups(Operator, Name.Attribute)),
|
295
|
+
(r'(case|default|for|each|in|while|do|break|return|continue|if|else|'
|
296
|
+
r'throw|try|catch|with|new|typeof|arguments|instanceof|this|'
|
297
|
+
r'switch|import|include|as|is)\b',
|
298
|
+
Keyword),
|
299
|
+
(r'(class|public|final|internal|native|override|private|protected|'
|
300
|
+
r'static|import|extends|implements|interface|intrinsic|return|super|'
|
301
|
+
r'dynamic|function|const|get|namespace|package|set)\b',
|
302
|
+
Keyword.Declaration),
|
303
|
+
(r'(true|false|null|NaN|Infinity|-Infinity|undefined|void)\b',
|
304
|
+
Keyword.Constant),
|
305
|
+
(r'(decodeURI|decodeURIComponent|encodeURI|escape|eval|isFinite|isNaN|'
|
306
|
+
r'isXMLName|clearInterval|fscommand|getTimer|getURL|getVersion|'
|
307
|
+
r'isFinite|parseFloat|parseInt|setInterval|trace|updateAfterEvent|'
|
308
|
+
r'unescape)\b', Name.Function),
|
309
|
+
(identifier, Name),
|
310
|
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
311
|
+
(r'0x[0-9a-f]+', Number.Hex),
|
312
|
+
(r'[0-9]+', Number.Integer),
|
313
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
314
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
315
|
+
(r'[~\^\*!%&<>\|+=:;,/?\\{}\[\]().-]+', Operator),
|
316
|
+
],
|
317
|
+
'funcparams': [
|
318
|
+
(r'\s+', Text),
|
319
|
+
(r'(\s*)(\.\.\.)?(' + identifier + r')(\s*)(:)(\s*)(' +
|
320
|
+
typeidentifier + r'|\*)(\s*)',
|
321
|
+
bygroups(Text, Punctuation, Name, Text, Operator, Text,
|
322
|
+
Keyword.Type, Text), 'defval'),
|
323
|
+
(r'\)', Operator, 'type')
|
324
|
+
],
|
325
|
+
'type': [
|
326
|
+
(r'(\s*)(:)(\s*)(' + typeidentifier + r'|\*)',
|
327
|
+
bygroups(Text, Operator, Text, Keyword.Type), '#pop:2'),
|
328
|
+
(r'\s*', Text, '#pop:2')
|
329
|
+
],
|
330
|
+
'defval': [
|
331
|
+
(r'(=)(\s*)([^(),]+)(\s*)(,?)',
|
332
|
+
bygroups(Operator, Text, using(this), Text, Operator), '#pop'),
|
333
|
+
(r',?', Operator, '#pop')
|
334
|
+
]
|
335
|
+
}
|
336
|
+
|
337
|
+
def analyse_text(text):
|
338
|
+
if re.match(r'\w+\s*:\s*\w', text):
|
339
|
+
return 0.3
|
340
|
+
return 0
|
341
|
+
|
342
|
+
|
343
|
+
class CssLexer(RegexLexer):
|
344
|
+
"""
|
345
|
+
For CSS (Cascading Style Sheets).
|
346
|
+
"""
|
347
|
+
|
348
|
+
name = 'CSS'
|
349
|
+
aliases = ['css']
|
350
|
+
filenames = ['*.css']
|
351
|
+
mimetypes = ['text/css']
|
352
|
+
|
353
|
+
tokens = {
|
354
|
+
'root': [
|
355
|
+
include('basics'),
|
356
|
+
],
|
357
|
+
'basics': [
|
358
|
+
(r'\s+', Text),
|
359
|
+
(r'/\*(?:.|\n)*?\*/', Comment),
|
360
|
+
(r'{', Punctuation, 'content'),
|
361
|
+
(r'\:[a-zA-Z0-9_-]+', Name.Decorator),
|
362
|
+
(r'\.[a-zA-Z0-9_-]+', Name.Class),
|
363
|
+
(r'\#[a-zA-Z0-9_-]+', Name.Function),
|
364
|
+
(r'@[a-zA-Z0-9_-]+', Keyword, 'atrule'),
|
365
|
+
(r'[a-zA-Z0-9_-]+', Name.Tag),
|
366
|
+
(r'[~\^\*!%&\[\]\(\)<>\|+=@:;,./?-]', Operator),
|
367
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
368
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single)
|
369
|
+
],
|
370
|
+
'atrule': [
|
371
|
+
(r'{', Punctuation, 'atcontent'),
|
372
|
+
(r';', Punctuation, '#pop'),
|
373
|
+
include('basics'),
|
374
|
+
],
|
375
|
+
'atcontent': [
|
376
|
+
include('basics'),
|
377
|
+
(r'}', Punctuation, '#pop:2'),
|
378
|
+
],
|
379
|
+
'content': [
|
380
|
+
(r'\s+', Text),
|
381
|
+
(r'}', Punctuation, '#pop'),
|
382
|
+
(r'url\(.*?\)', String.Other),
|
383
|
+
(r'^@.*?$', Comment.Preproc),
|
384
|
+
(r'(azimuth|background-attachment|background-color|'
|
385
|
+
r'background-image|background-position|background-repeat|'
|
386
|
+
r'background|border-bottom-color|border-bottom-style|'
|
387
|
+
r'border-bottom-width|border-left-color|border-left-style|'
|
388
|
+
r'border-left-width|border-right|border-right-color|'
|
389
|
+
r'border-right-style|border-right-width|border-top-color|'
|
390
|
+
r'border-top-style|border-top-width|border-bottom|'
|
391
|
+
r'border-collapse|border-left|border-width|border-color|'
|
392
|
+
r'border-spacing|border-style|border-top|border|caption-side|'
|
393
|
+
r'clear|clip|color|content|counter-increment|counter-reset|'
|
394
|
+
r'cue-after|cue-before|cue|cursor|direction|display|'
|
395
|
+
r'elevation|empty-cells|float|font-family|font-size|'
|
396
|
+
r'font-size-adjust|font-stretch|font-style|font-variant|'
|
397
|
+
r'font-weight|font|height|letter-spacing|line-height|'
|
398
|
+
r'list-style-type|list-style-image|list-style-position|'
|
399
|
+
r'list-style|margin-bottom|margin-left|margin-right|'
|
400
|
+
r'margin-top|margin|marker-offset|marks|max-height|max-width|'
|
401
|
+
r'min-height|min-width|opacity|orphans|outline|outline-color|'
|
402
|
+
r'outline-style|outline-width|overflow(?:-x|-y)?|padding-bottom|'
|
403
|
+
r'padding-left|padding-right|padding-top|padding|page|'
|
404
|
+
r'page-break-after|page-break-before|page-break-inside|'
|
405
|
+
r'pause-after|pause-before|pause|pitch|pitch-range|'
|
406
|
+
r'play-during|position|quotes|richness|right|size|'
|
407
|
+
r'speak-header|speak-numeral|speak-punctuation|speak|'
|
408
|
+
r'speech-rate|stress|table-layout|text-align|text-decoration|'
|
409
|
+
r'text-indent|text-shadow|text-transform|top|unicode-bidi|'
|
410
|
+
r'vertical-align|visibility|voice-family|volume|white-space|'
|
411
|
+
r'widows|width|word-spacing|z-index|bottom|left|'
|
412
|
+
r'above|absolute|always|armenian|aural|auto|avoid|baseline|'
|
413
|
+
r'behind|below|bidi-override|blink|block|bold|bolder|both|'
|
414
|
+
r'capitalize|center-left|center-right|center|circle|'
|
415
|
+
r'cjk-ideographic|close-quote|collapse|condensed|continuous|'
|
416
|
+
r'crop|crosshair|cross|cursive|dashed|decimal-leading-zero|'
|
417
|
+
r'decimal|default|digits|disc|dotted|double|e-resize|embed|'
|
418
|
+
r'extra-condensed|extra-expanded|expanded|fantasy|far-left|'
|
419
|
+
r'far-right|faster|fast|fixed|georgian|groove|hebrew|help|'
|
420
|
+
r'hidden|hide|higher|high|hiragana-iroha|hiragana|icon|'
|
421
|
+
r'inherit|inline-table|inline|inset|inside|invert|italic|'
|
422
|
+
r'justify|katakana-iroha|katakana|landscape|larger|large|'
|
423
|
+
r'left-side|leftwards|level|lighter|line-through|list-item|'
|
424
|
+
r'loud|lower-alpha|lower-greek|lower-roman|lowercase|ltr|'
|
425
|
+
r'lower|low|medium|message-box|middle|mix|monospace|'
|
426
|
+
r'n-resize|narrower|ne-resize|no-close-quote|no-open-quote|'
|
427
|
+
r'no-repeat|none|normal|nowrap|nw-resize|oblique|once|'
|
428
|
+
r'open-quote|outset|outside|overline|pointer|portrait|px|'
|
429
|
+
r'relative|repeat-x|repeat-y|repeat|rgb|ridge|right-side|'
|
430
|
+
r'rightwards|s-resize|sans-serif|scroll|se-resize|'
|
431
|
+
r'semi-condensed|semi-expanded|separate|serif|show|silent|'
|
432
|
+
r'slow|slower|small-caps|small-caption|smaller|soft|solid|'
|
433
|
+
r'spell-out|square|static|status-bar|super|sw-resize|'
|
434
|
+
r'table-caption|table-cell|table-column|table-column-group|'
|
435
|
+
r'table-footer-group|table-header-group|table-row|'
|
436
|
+
r'table-row-group|text|text-bottom|text-top|thick|thin|'
|
437
|
+
r'transparent|ultra-condensed|ultra-expanded|underline|'
|
438
|
+
r'upper-alpha|upper-latin|upper-roman|uppercase|url|'
|
439
|
+
r'visible|w-resize|wait|wider|x-fast|x-high|x-large|x-loud|'
|
440
|
+
r'x-low|x-small|x-soft|xx-large|xx-small|yes)\b', Keyword),
|
441
|
+
(r'(indigo|gold|firebrick|indianred|yellow|darkolivegreen|'
|
442
|
+
r'darkseagreen|mediumvioletred|mediumorchid|chartreuse|'
|
443
|
+
r'mediumslateblue|black|springgreen|crimson|lightsalmon|brown|'
|
444
|
+
r'turquoise|olivedrab|cyan|silver|skyblue|gray|darkturquoise|'
|
445
|
+
r'goldenrod|darkgreen|darkviolet|darkgray|lightpink|teal|'
|
446
|
+
r'darkmagenta|lightgoldenrodyellow|lavender|yellowgreen|thistle|'
|
447
|
+
r'violet|navy|orchid|blue|ghostwhite|honeydew|cornflowerblue|'
|
448
|
+
r'darkblue|darkkhaki|mediumpurple|cornsilk|red|bisque|slategray|'
|
449
|
+
r'darkcyan|khaki|wheat|deepskyblue|darkred|steelblue|aliceblue|'
|
450
|
+
r'gainsboro|mediumturquoise|floralwhite|coral|purple|lightgrey|'
|
451
|
+
r'lightcyan|darksalmon|beige|azure|lightsteelblue|oldlace|'
|
452
|
+
r'greenyellow|royalblue|lightseagreen|mistyrose|sienna|'
|
453
|
+
r'lightcoral|orangered|navajowhite|lime|palegreen|burlywood|'
|
454
|
+
r'seashell|mediumspringgreen|fuchsia|papayawhip|blanchedalmond|'
|
455
|
+
r'peru|aquamarine|white|darkslategray|ivory|dodgerblue|'
|
456
|
+
r'lemonchiffon|chocolate|orange|forestgreen|slateblue|olive|'
|
457
|
+
r'mintcream|antiquewhite|darkorange|cadetblue|moccasin|'
|
458
|
+
r'limegreen|saddlebrown|darkslateblue|lightskyblue|deeppink|'
|
459
|
+
r'plum|aqua|darkgoldenrod|maroon|sandybrown|magenta|tan|'
|
460
|
+
r'rosybrown|pink|lightblue|palevioletred|mediumseagreen|'
|
461
|
+
r'dimgray|powderblue|seagreen|snow|mediumblue|midnightblue|'
|
462
|
+
r'paleturquoise|palegoldenrod|whitesmoke|darkorchid|salmon|'
|
463
|
+
r'lightslategray|lawngreen|lightgreen|tomato|hotpink|'
|
464
|
+
r'lightyellow|lavenderblush|linen|mediumaquamarine|green|'
|
465
|
+
r'blueviolet|peachpuff)\b', Name.Builtin),
|
466
|
+
(r'\!important', Comment.Preproc),
|
467
|
+
(r'/\*(?:.|\n)*?\*/', Comment),
|
468
|
+
(r'\#[a-zA-Z0-9]{1,6}', Number),
|
469
|
+
(r'[\.-]?[0-9]*[\.]?[0-9]+(em|px|\%|pt|pc|in|mm|cm|ex|s)\b', Number),
|
470
|
+
(r'-?[0-9]+', Number),
|
471
|
+
(r'[~\^\*!%&<>\|+=@:,./?-]+', Operator),
|
472
|
+
(r'[\[\]();]+', Punctuation),
|
473
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
474
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
475
|
+
(r'[a-zA-Z_][a-zA-Z0-9_]*', Name)
|
476
|
+
]
|
477
|
+
}
|
478
|
+
|
479
|
+
|
480
|
+
class ObjectiveJLexer(RegexLexer):
|
481
|
+
"""
|
482
|
+
For Objective-J source code with preprocessor directives.
|
483
|
+
|
484
|
+
*New in Pygments 1.3.*
|
485
|
+
"""
|
486
|
+
|
487
|
+
name = 'Objective-J'
|
488
|
+
aliases = ['objective-j', 'objectivej', 'obj-j', 'objj']
|
489
|
+
filenames = ['*.j']
|
490
|
+
mimetypes = ['text/x-objective-j']
|
491
|
+
|
492
|
+
#: optional Comment or Whitespace
|
493
|
+
_ws = r'(?:\s|//.*?\n|/[*].*?[*]/)*'
|
494
|
+
|
495
|
+
flags = re.DOTALL | re.MULTILINE
|
496
|
+
|
497
|
+
tokens = {
|
498
|
+
'root': [
|
499
|
+
include('whitespace'),
|
500
|
+
|
501
|
+
# function definition
|
502
|
+
(r'^(' + _ws + r'[\+-]' + _ws + r')([\(a-zA-Z_].*?[^\(])(' + _ws + '{)',
|
503
|
+
bygroups(using(this), using(this, state='function_signature'),
|
504
|
+
using(this))),
|
505
|
+
|
506
|
+
# class definition
|
507
|
+
(r'(@interface|@implementation)(\s+)', bygroups(Keyword, Text),
|
508
|
+
'classname'),
|
509
|
+
(r'(@class|@protocol)(\s*)', bygroups(Keyword, Text),
|
510
|
+
'forward_classname'),
|
511
|
+
(r'(\s*)(@end)(\s*)', bygroups(Text, Keyword, Text)),
|
512
|
+
|
513
|
+
include('statements'),
|
514
|
+
('[{\(\)}]', Punctuation),
|
515
|
+
(';', Punctuation),
|
516
|
+
],
|
517
|
+
'whitespace': [
|
518
|
+
(r'(@import)(\s+)("(?:\\\\|\\"|[^"])*")',
|
519
|
+
bygroups(Comment.Preproc, Text, String.Double)),
|
520
|
+
(r'(@import)(\s+)(<(?:\\\\|\\>|[^>])*>)',
|
521
|
+
bygroups(Comment.Preproc, Text, String.Double)),
|
522
|
+
(r'(#(?:include|import))(\s+)("(?:\\\\|\\"|[^"])*")',
|
523
|
+
bygroups(Comment.Preproc, Text, String.Double)),
|
524
|
+
(r'(#(?:include|import))(\s+)(<(?:\\\\|\\>|[^>])*>)',
|
525
|
+
bygroups(Comment.Preproc, Text, String.Double)),
|
526
|
+
|
527
|
+
(r'#if\s+0', Comment.Preproc, 'if0'),
|
528
|
+
(r'#', Comment.Preproc, 'macro'),
|
529
|
+
|
530
|
+
(r'\n', Text),
|
531
|
+
(r'\s+', Text),
|
532
|
+
(r'\\\n', Text), # line continuation
|
533
|
+
(r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
|
534
|
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
535
|
+
(r'<!--', Comment),
|
536
|
+
],
|
537
|
+
'slashstartsregex': [
|
538
|
+
include('whitespace'),
|
539
|
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
540
|
+
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
541
|
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
542
|
+
(r'', Text, '#pop'),
|
543
|
+
],
|
544
|
+
'badregex': [
|
545
|
+
(r'\n', Text, '#pop'),
|
546
|
+
],
|
547
|
+
'statements': [
|
548
|
+
(r'(L|@)?"', String, 'string'),
|
549
|
+
(r"(L|@)?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'",
|
550
|
+
String.Char),
|
551
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
552
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
553
|
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
|
554
|
+
(r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
555
|
+
(r'0x[0-9a-fA-F]+[Ll]?', Number.Hex),
|
556
|
+
(r'0[0-7]+[Ll]?', Number.Oct),
|
557
|
+
(r'\d+[Ll]?', Number.Integer),
|
558
|
+
|
559
|
+
(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
|
560
|
+
|
561
|
+
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
|
562
|
+
r'(<<|>>>?|==?|!=?|[-<>+*%&\|\^/])=?',
|
563
|
+
Operator, 'slashstartsregex'),
|
564
|
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
565
|
+
(r'[})\].]', Punctuation),
|
566
|
+
|
567
|
+
(r'(for|in|while|do|break|return|continue|switch|case|default|if|'
|
568
|
+
r'else|throw|try|catch|finally|new|delete|typeof|instanceof|void|'
|
569
|
+
r'prototype|__proto__)\b', Keyword, 'slashstartsregex'),
|
570
|
+
|
571
|
+
(r'(var|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
|
572
|
+
|
573
|
+
(r'(@selector|@private|@protected|@public|@encode|'
|
574
|
+
r'@synchronized|@try|@throw|@catch|@finally|@end|@property|'
|
575
|
+
r'@synthesize|@dynamic|@for|@accessors|new)\b', Keyword),
|
576
|
+
|
577
|
+
(r'(int|long|float|short|double|char|unsigned|signed|void|'
|
578
|
+
r'id|BOOL|bool|boolean|IBOutlet|IBAction|SEL|@outlet|@action)\b',
|
579
|
+
Keyword.Type),
|
580
|
+
|
581
|
+
(r'(self|super)\b', Name.Builtin),
|
582
|
+
|
583
|
+
(r'(TRUE|YES|FALSE|NO|Nil|nil|NULL)\b', Keyword.Constant),
|
584
|
+
(r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
|
585
|
+
(r'(ABS|ASIN|ACOS|ATAN|ATAN2|SIN|COS|TAN|EXP|POW|CEIL|FLOOR|ROUND|'
|
586
|
+
r'MIN|MAX|RAND|SQRT|E|LN2|LN10|LOG2E|LOG10E|PI|PI2|PI_2|SQRT1_2|'
|
587
|
+
r'SQRT2)\b', Keyword.Constant),
|
588
|
+
|
589
|
+
(r'(Array|Boolean|Date|Error|Function|Math|netscape|'
|
590
|
+
r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
|
591
|
+
r'decodeURIComponent|encodeURI|encodeURIComponent|'
|
592
|
+
r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
|
593
|
+
r'window)\b', Name.Builtin),
|
594
|
+
|
595
|
+
(r'([$a-zA-Z_][a-zA-Z0-9_]*)(' + _ws + r')(?=\()',
|
596
|
+
bygroups(Name.Function, using(this))),
|
597
|
+
|
598
|
+
(r'[$a-zA-Z_][a-zA-Z0-9_]*', Name),
|
599
|
+
],
|
600
|
+
'classname' : [
|
601
|
+
# interface definition that inherits
|
602
|
+
(r'([a-zA-Z_][a-zA-Z0-9_]*)(' + _ws + r':' + _ws +
|
603
|
+
r')([a-zA-Z_][a-zA-Z0-9_]*)?',
|
604
|
+
bygroups(Name.Class, using(this), Name.Class), '#pop'),
|
605
|
+
# interface definition for a category
|
606
|
+
(r'([a-zA-Z_][a-zA-Z0-9_]*)(' + _ws + r'\()([a-zA-Z_][a-zA-Z0-9_]*)(\))',
|
607
|
+
bygroups(Name.Class, using(this), Name.Label, Text), '#pop'),
|
608
|
+
# simple interface / implementation
|
609
|
+
(r'([a-zA-Z_][a-zA-Z0-9_]*)', Name.Class, '#pop'),
|
610
|
+
],
|
611
|
+
'forward_classname' : [
|
612
|
+
(r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*,\s*)',
|
613
|
+
bygroups(Name.Class, Text), '#push'),
|
614
|
+
(r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*;?)',
|
615
|
+
bygroups(Name.Class, Text), '#pop'),
|
616
|
+
],
|
617
|
+
'function_signature': [
|
618
|
+
include('whitespace'),
|
619
|
+
|
620
|
+
# start of a selector w/ parameters
|
621
|
+
(r'(\(' + _ws + r')' # open paren
|
622
|
+
r'([a-zA-Z_][a-zA-Z0-9_]+)' # return type
|
623
|
+
r'(' + _ws + r'\)' + _ws + r')' # close paren
|
624
|
+
r'([$a-zA-Z_][a-zA-Z0-9_]+' + _ws + r':)', # function name
|
625
|
+
bygroups(using(this), Keyword.Type, using(this),
|
626
|
+
Name.Function), 'function_parameters'),
|
627
|
+
|
628
|
+
# no-param function
|
629
|
+
(r'(\(' + _ws + r')' # open paren
|
630
|
+
r'([a-zA-Z_][a-zA-Z0-9_]+)' # return type
|
631
|
+
r'(' + _ws + r'\)' + _ws + r')' # close paren
|
632
|
+
r'([$a-zA-Z_][a-zA-Z0-9_]+)', # function name
|
633
|
+
bygroups(using(this), Keyword.Type, using(this),
|
634
|
+
Name.Function), "#pop"),
|
635
|
+
|
636
|
+
# no return type given, start of a selector w/ parameters
|
637
|
+
(r'([$a-zA-Z_][a-zA-Z0-9_]+' + _ws + r':)', # function name
|
638
|
+
bygroups (Name.Function), 'function_parameters'),
|
639
|
+
|
640
|
+
# no return type given, no-param function
|
641
|
+
(r'([$a-zA-Z_][a-zA-Z0-9_]+)', # function name
|
642
|
+
bygroups(Name.Function), "#pop"),
|
643
|
+
|
644
|
+
('', Text, '#pop'),
|
645
|
+
],
|
646
|
+
'function_parameters': [
|
647
|
+
include('whitespace'),
|
648
|
+
|
649
|
+
# parameters
|
650
|
+
(r'(\(' + _ws + ')' # open paren
|
651
|
+
r'([^\)]+)' # type
|
652
|
+
r'(' + _ws + r'\)' + _ws + r')' # close paren
|
653
|
+
r'([$a-zA-Z_][a-zA-Z0-9_]+)', # param name
|
654
|
+
bygroups(using(this), Keyword.Type, using(this), Text)),
|
655
|
+
|
656
|
+
# one piece of a selector name
|
657
|
+
(r'([$a-zA-Z_][a-zA-Z0-9_]+' + _ws + r':)', # function name
|
658
|
+
Name.Function),
|
659
|
+
|
660
|
+
# smallest possible selector piece
|
661
|
+
(r'(:)', Name.Function),
|
662
|
+
|
663
|
+
# var args
|
664
|
+
(r'(,' + _ws + r'\.\.\.)', using(this)),
|
665
|
+
|
666
|
+
# param name
|
667
|
+
(r'([$a-zA-Z_][a-zA-Z0-9_]+)', Text),
|
668
|
+
],
|
669
|
+
'expression' : [
|
670
|
+
(r'([$a-zA-Z_][a-zA-Z0-9_]*)(\()', bygroups(Name.Function,
|
671
|
+
Punctuation)),
|
672
|
+
(r'(\))', Punctuation, "#pop"),
|
673
|
+
],
|
674
|
+
'string': [
|
675
|
+
(r'"', String, '#pop'),
|
676
|
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
|
677
|
+
(r'[^\\"\n]+', String), # all other characters
|
678
|
+
(r'\\\n', String), # line continuation
|
679
|
+
(r'\\', String), # stray backslash
|
680
|
+
],
|
681
|
+
'macro': [
|
682
|
+
(r'[^/\n]+', Comment.Preproc),
|
683
|
+
(r'/[*](.|\n)*?[*]/', Comment.Multiline),
|
684
|
+
(r'//.*?\n', Comment.Single, '#pop'),
|
685
|
+
(r'/', Comment.Preproc),
|
686
|
+
(r'(?<=\\)\n', Comment.Preproc),
|
687
|
+
(r'\n', Comment.Preproc, '#pop'),
|
688
|
+
],
|
689
|
+
'if0': [
|
690
|
+
(r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
|
691
|
+
(r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
|
692
|
+
(r'.*?\n', Comment),
|
693
|
+
]
|
694
|
+
}
|
695
|
+
|
696
|
+
def analyse_text(text):
|
697
|
+
if re.search('^\s*@import\s+[<"]', text, re.MULTILINE):
|
698
|
+
# special directive found in most Objective-J files
|
699
|
+
return True
|
700
|
+
return False
|
701
|
+
|
702
|
+
|
703
|
+
class HtmlLexer(RegexLexer):
|
704
|
+
"""
|
705
|
+
For HTML 4 and XHTML 1 markup. Nested JavaScript and CSS is highlighted
|
706
|
+
by the appropriate lexer.
|
707
|
+
"""
|
708
|
+
|
709
|
+
name = 'HTML'
|
710
|
+
aliases = ['html']
|
711
|
+
filenames = ['*.html', '*.htm', '*.xhtml', '*.xslt']
|
712
|
+
mimetypes = ['text/html', 'application/xhtml+xml']
|
713
|
+
|
714
|
+
flags = re.IGNORECASE | re.DOTALL
|
715
|
+
tokens = {
|
716
|
+
'root': [
|
717
|
+
('[^<&]+', Text),
|
718
|
+
(r'&\S*?;', Name.Entity),
|
719
|
+
(r'\<\!\[CDATA\[.*?\]\]\>', Comment.Preproc),
|
720
|
+
('<!--', Comment, 'comment'),
|
721
|
+
(r'<\?.*?\?>', Comment.Preproc),
|
722
|
+
('<![^>]*>', Comment.Preproc),
|
723
|
+
(r'<\s*script\s*', Name.Tag, ('script-content', 'tag')),
|
724
|
+
(r'<\s*style\s*', Name.Tag, ('style-content', 'tag')),
|
725
|
+
# note: this allows tag names not used in HTML like <x:with-dash>,
|
726
|
+
# this is to support yet-unknown template engines and the like
|
727
|
+
(r'<\s*[\w:.-]+', Name.Tag, 'tag'),
|
728
|
+
(r'<\s*/\s*[\w:.-]+\s*>', Name.Tag),
|
729
|
+
],
|
730
|
+
'comment': [
|
731
|
+
('[^-]+', Comment),
|
732
|
+
('-->', Comment, '#pop'),
|
733
|
+
('-', Comment),
|
734
|
+
],
|
735
|
+
'tag': [
|
736
|
+
(r'\s+', Text),
|
737
|
+
(r'[a-zA-Z0-9_:-]+\s*=', Name.Attribute, 'attr'),
|
738
|
+
(r'[a-zA-Z0-9_:-]+', Name.Attribute),
|
739
|
+
(r'/?\s*>', Name.Tag, '#pop'),
|
740
|
+
],
|
741
|
+
'script-content': [
|
742
|
+
(r'<\s*/\s*script\s*>', Name.Tag, '#pop'),
|
743
|
+
(r'.+?(?=<\s*/\s*script\s*>)', using(JavascriptLexer)),
|
744
|
+
],
|
745
|
+
'style-content': [
|
746
|
+
(r'<\s*/\s*style\s*>', Name.Tag, '#pop'),
|
747
|
+
(r'.+?(?=<\s*/\s*style\s*>)', using(CssLexer)),
|
748
|
+
],
|
749
|
+
'attr': [
|
750
|
+
('".*?"', String, '#pop'),
|
751
|
+
("'.*?'", String, '#pop'),
|
752
|
+
(r'[^\s>]+', String, '#pop'),
|
753
|
+
],
|
754
|
+
}
|
755
|
+
|
756
|
+
def analyse_text(text):
|
757
|
+
if html_doctype_matches(text):
|
758
|
+
return 0.5
|
759
|
+
|
760
|
+
|
761
|
+
class PhpLexer(RegexLexer):
|
762
|
+
"""
|
763
|
+
For `PHP <http://www.php.net/>`_ source code.
|
764
|
+
For PHP embedded in HTML, use the `HtmlPhpLexer`.
|
765
|
+
|
766
|
+
Additional options accepted:
|
767
|
+
|
768
|
+
`startinline`
|
769
|
+
If given and ``True`` the lexer starts highlighting with
|
770
|
+
php code (i.e.: no starting ``<?php`` required). The default
|
771
|
+
is ``False``.
|
772
|
+
`funcnamehighlighting`
|
773
|
+
If given and ``True``, highlight builtin function names
|
774
|
+
(default: ``True``).
|
775
|
+
`disabledmodules`
|
776
|
+
If given, must be a list of module names whose function names
|
777
|
+
should not be highlighted. By default all modules are highlighted
|
778
|
+
except the special ``'unknown'`` module that includes functions
|
779
|
+
that are known to php but are undocumented.
|
780
|
+
|
781
|
+
To get a list of allowed modules have a look into the
|
782
|
+
`_phpbuiltins` module:
|
783
|
+
|
784
|
+
.. sourcecode:: pycon
|
785
|
+
|
786
|
+
>>> from pygments.lexers._phpbuiltins import MODULES
|
787
|
+
>>> MODULES.keys()
|
788
|
+
['PHP Options/Info', 'Zip', 'dba', ...]
|
789
|
+
|
790
|
+
In fact the names of those modules match the module names from
|
791
|
+
the php documentation.
|
792
|
+
"""
|
793
|
+
|
794
|
+
name = 'PHP'
|
795
|
+
aliases = ['php', 'php3', 'php4', 'php5']
|
796
|
+
filenames = ['*.php', '*.php[345]', '*.inc']
|
797
|
+
mimetypes = ['text/x-php']
|
798
|
+
|
799
|
+
flags = re.IGNORECASE | re.DOTALL | re.MULTILINE
|
800
|
+
tokens = {
|
801
|
+
'root': [
|
802
|
+
(r'<\?(php)?', Comment.Preproc, 'php'),
|
803
|
+
(r'[^<]+', Other),
|
804
|
+
(r'<', Other)
|
805
|
+
],
|
806
|
+
'php': [
|
807
|
+
(r'\?>', Comment.Preproc, '#pop'),
|
808
|
+
(r'<<<(\'?)([a-zA-Z_][a-zA-Z0-9_]*)\1\n.*?\n\2\;?\n', String),
|
809
|
+
(r'\s+', Text),
|
810
|
+
(r'#.*?\n', Comment.Single),
|
811
|
+
(r'//.*?\n', Comment.Single),
|
812
|
+
# put the empty comment here, it is otherwise seen as
|
813
|
+
# the start of a docstring
|
814
|
+
(r'/\*\*/', Comment.Multiline),
|
815
|
+
(r'/\*\*.*?\*/', String.Doc),
|
816
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
817
|
+
(r'(->|::)(\s*)([a-zA-Z_][a-zA-Z0-9_]*)',
|
818
|
+
bygroups(Operator, Text, Name.Attribute)),
|
819
|
+
(r'[~!%^&*+=|:.<>/?@-]+', Operator),
|
820
|
+
(r'[\[\]{}();,]+', Punctuation),
|
821
|
+
(r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
|
822
|
+
(r'(function)(\s*)(?=\()', bygroups(Keyword, Text)),
|
823
|
+
(r'(function)(\s+)(&?)(\s*)',
|
824
|
+
bygroups(Keyword, Text, Operator, Text), 'functionname'),
|
825
|
+
(r'(const)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
|
826
|
+
bygroups(Keyword, Text, Name.Constant)),
|
827
|
+
(r'(and|E_PARSE|old_function|E_ERROR|or|as|E_WARNING|parent|'
|
828
|
+
r'eval|PHP_OS|break|exit|case|extends|PHP_VERSION|cfunction|'
|
829
|
+
r'FALSE|print|for|require|continue|foreach|require_once|'
|
830
|
+
r'declare|return|default|static|do|switch|die|stdClass|'
|
831
|
+
r'echo|else|TRUE|elseif|var|empty|if|xor|enddeclare|include|'
|
832
|
+
r'virtual|endfor|include_once|while|endforeach|global|__FILE__|'
|
833
|
+
r'endif|list|__LINE__|endswitch|new|__sleep|endwhile|not|'
|
834
|
+
r'array|__wakeup|E_ALL|NULL|final|php_user_filter|interface|'
|
835
|
+
r'implements|public|private|protected|abstract|clone|try|'
|
836
|
+
r'catch|throw|this|use|namespace|trait)\b', Keyword),
|
837
|
+
(r'(true|false|null)\b', Keyword.Constant),
|
838
|
+
(r'\$\{\$+[a-zA-Z_][a-zA-Z0-9_]*\}', Name.Variable),
|
839
|
+
(r'\$+[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable),
|
840
|
+
(r'[\\a-zA-Z_][\\a-zA-Z0-9_]*', Name.Other),
|
841
|
+
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
|
842
|
+
(r'\d+[eE][+-]?[0-9]+', Number.Float),
|
843
|
+
(r'0[0-7]+', Number.Oct),
|
844
|
+
(r'0[xX][a-fA-F0-9]+', Number.Hex),
|
845
|
+
(r'\d+', Number.Integer),
|
846
|
+
(r"'([^'\\]*(?:\\.[^'\\]*)*)'", String.Single),
|
847
|
+
(r'`([^`\\]*(?:\\.[^`\\]*)*)`', String.Backtick),
|
848
|
+
(r'"', String.Double, 'string'),
|
849
|
+
],
|
850
|
+
'classname': [
|
851
|
+
(r'[a-zA-Z_][\\a-zA-Z0-9_]*', Name.Class, '#pop')
|
852
|
+
],
|
853
|
+
'functionname': [
|
854
|
+
(r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Function, '#pop')
|
855
|
+
],
|
856
|
+
'string': [
|
857
|
+
(r'"', String.Double, '#pop'),
|
858
|
+
(r'[^{$"\\]+', String.Double),
|
859
|
+
(r'\\([nrt\"$\\]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})', String.Escape),
|
860
|
+
(r'\$[a-zA-Z_][a-zA-Z0-9_]*(\[\S+\]|->[a-zA-Z_][a-zA-Z0-9_]*)?',
|
861
|
+
String.Interpol),
|
862
|
+
(r'(\{\$\{)(.*?)(\}\})',
|
863
|
+
bygroups(String.Interpol, using(this, _startinline=True),
|
864
|
+
String.Interpol)),
|
865
|
+
(r'(\{)(\$.*?)(\})',
|
866
|
+
bygroups(String.Interpol, using(this, _startinline=True),
|
867
|
+
String.Interpol)),
|
868
|
+
(r'(\$\{)(\S+)(\})',
|
869
|
+
bygroups(String.Interpol, Name.Variable, String.Interpol)),
|
870
|
+
(r'[${\\]+', String.Double)
|
871
|
+
],
|
872
|
+
}
|
873
|
+
|
874
|
+
def __init__(self, **options):
|
875
|
+
self.funcnamehighlighting = get_bool_opt(
|
876
|
+
options, 'funcnamehighlighting', True)
|
877
|
+
self.disabledmodules = get_list_opt(
|
878
|
+
options, 'disabledmodules', ['unknown'])
|
879
|
+
self.startinline = get_bool_opt(options, 'startinline', False)
|
880
|
+
|
881
|
+
# private option argument for the lexer itself
|
882
|
+
if '_startinline' in options:
|
883
|
+
self.startinline = options.pop('_startinline')
|
884
|
+
|
885
|
+
# collect activated functions in a set
|
886
|
+
self._functions = set()
|
887
|
+
if self.funcnamehighlighting:
|
888
|
+
from pygments.lexers._phpbuiltins import MODULES
|
889
|
+
for key, value in MODULES.iteritems():
|
890
|
+
if key not in self.disabledmodules:
|
891
|
+
self._functions.update(value)
|
892
|
+
RegexLexer.__init__(self, **options)
|
893
|
+
|
894
|
+
def get_tokens_unprocessed(self, text):
|
895
|
+
stack = ['root']
|
896
|
+
if self.startinline:
|
897
|
+
stack.append('php')
|
898
|
+
for index, token, value in \
|
899
|
+
RegexLexer.get_tokens_unprocessed(self, text, stack):
|
900
|
+
if token is Name.Other:
|
901
|
+
if value in self._functions:
|
902
|
+
yield index, Name.Builtin, value
|
903
|
+
continue
|
904
|
+
yield index, token, value
|
905
|
+
|
906
|
+
def analyse_text(text):
|
907
|
+
rv = 0.0
|
908
|
+
if re.search(r'<\?(?!xml)', text):
|
909
|
+
rv += 0.3
|
910
|
+
if '?>' in text:
|
911
|
+
rv += 0.1
|
912
|
+
return rv
|
913
|
+
|
914
|
+
|
915
|
+
class DtdLexer(RegexLexer):
|
916
|
+
"""
|
917
|
+
A lexer for DTDs (Document Type Definitions).
|
918
|
+
|
919
|
+
*New in Pygments 1.5.*
|
920
|
+
"""
|
921
|
+
|
922
|
+
flags = re.MULTILINE | re.DOTALL
|
923
|
+
|
924
|
+
name = 'DTD'
|
925
|
+
aliases = ['dtd']
|
926
|
+
filenames = ['*.dtd']
|
927
|
+
mimetypes = ['application/xml-dtd']
|
928
|
+
|
929
|
+
tokens = {
|
930
|
+
'root': [
|
931
|
+
include('common'),
|
932
|
+
|
933
|
+
(r'(<!ELEMENT)(\s+)(\S+)',
|
934
|
+
bygroups(Keyword, Text, Name.Tag), 'element'),
|
935
|
+
(r'(<!ATTLIST)(\s+)(\S+)',
|
936
|
+
bygroups(Keyword, Text, Name.Tag), 'attlist'),
|
937
|
+
(r'(<!ENTITY)(\s+)(\S+)',
|
938
|
+
bygroups(Keyword, Text, Name.Entity), 'entity'),
|
939
|
+
(r'(<!NOTATION)(\s+)(\S+)',
|
940
|
+
bygroups(Keyword, Text, Name.Tag), 'notation'),
|
941
|
+
(r'(<!\[)([^\[\s]+)(\s*)(\[)', # conditional sections
|
942
|
+
bygroups(Keyword, Name.Entity, Text, Keyword)),
|
943
|
+
|
944
|
+
(r'(<!DOCTYPE)(\s+)([^>\s]+)',
|
945
|
+
bygroups(Keyword, Text, Name.Tag)),
|
946
|
+
(r'PUBLIC|SYSTEM', Keyword.Constant),
|
947
|
+
(r'[\[\]>]', Keyword),
|
948
|
+
],
|
949
|
+
|
950
|
+
'common': [
|
951
|
+
(r'\s+', Text),
|
952
|
+
(r'(%|&)[^;]*;', Name.Entity),
|
953
|
+
('<!--', Comment, 'comment'),
|
954
|
+
(r'[(|)*,?+]', Operator),
|
955
|
+
(r'"[^"]*"', String.Double),
|
956
|
+
(r'\'[^\']*\'', String.Single),
|
957
|
+
],
|
958
|
+
|
959
|
+
'comment': [
|
960
|
+
('[^-]+', Comment),
|
961
|
+
('-->', Comment, '#pop'),
|
962
|
+
('-', Comment),
|
963
|
+
],
|
964
|
+
|
965
|
+
'element': [
|
966
|
+
include('common'),
|
967
|
+
(r'EMPTY|ANY|#PCDATA', Keyword.Constant),
|
968
|
+
(r'[^>\s\|()?+*,]+', Name.Tag),
|
969
|
+
(r'>', Keyword, '#pop'),
|
970
|
+
],
|
971
|
+
|
972
|
+
'attlist': [
|
973
|
+
include('common'),
|
974
|
+
(r'CDATA|IDREFS|IDREF|ID|NMTOKENS|NMTOKEN|ENTITIES|ENTITY|NOTATION',
|
975
|
+
Keyword.Constant),
|
976
|
+
(r'#REQUIRED|#IMPLIED|#FIXED', Keyword.Constant),
|
977
|
+
(r'xml:space|xml:lang', Keyword.Reserved),
|
978
|
+
(r'[^>\s\|()?+*,]+', Name.Attribute),
|
979
|
+
(r'>', Keyword, '#pop'),
|
980
|
+
],
|
981
|
+
|
982
|
+
'entity': [
|
983
|
+
include('common'),
|
984
|
+
(r'SYSTEM|PUBLIC|NDATA', Keyword.Constant),
|
985
|
+
(r'[^>\s\|()?+*,]+', Name.Entity),
|
986
|
+
(r'>', Keyword, '#pop'),
|
987
|
+
],
|
988
|
+
|
989
|
+
'notation': [
|
990
|
+
include('common'),
|
991
|
+
(r'SYSTEM|PUBLIC', Keyword.Constant),
|
992
|
+
(r'[^>\s\|()?+*,]+', Name.Attribute),
|
993
|
+
(r'>', Keyword, '#pop'),
|
994
|
+
],
|
995
|
+
}
|
996
|
+
|
997
|
+
def analyse_text(text):
|
998
|
+
if not looks_like_xml(text) and \
|
999
|
+
('<!ELEMENT' in text or '<!ATTLIST' in text or '<!ENTITY' in text):
|
1000
|
+
return 0.8
|
1001
|
+
|
1002
|
+
class XmlLexer(RegexLexer):
|
1003
|
+
"""
|
1004
|
+
Generic lexer for XML (eXtensible Markup Language).
|
1005
|
+
"""
|
1006
|
+
|
1007
|
+
flags = re.MULTILINE | re.DOTALL | re.UNICODE
|
1008
|
+
|
1009
|
+
name = 'XML'
|
1010
|
+
aliases = ['xml']
|
1011
|
+
filenames = ['*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd',
|
1012
|
+
'*.wsdl', '*.wsf']
|
1013
|
+
mimetypes = ['text/xml', 'application/xml', 'image/svg+xml',
|
1014
|
+
'application/rss+xml', 'application/atom+xml']
|
1015
|
+
|
1016
|
+
tokens = {
|
1017
|
+
'root': [
|
1018
|
+
('[^<&]+', Text),
|
1019
|
+
(r'&\S*?;', Name.Entity),
|
1020
|
+
(r'\<\!\[CDATA\[.*?\]\]\>', Comment.Preproc),
|
1021
|
+
('<!--', Comment, 'comment'),
|
1022
|
+
(r'<\?.*?\?>', Comment.Preproc),
|
1023
|
+
('<![^>]*>', Comment.Preproc),
|
1024
|
+
(r'<\s*[\w:.-]+', Name.Tag, 'tag'),
|
1025
|
+
(r'<\s*/\s*[\w:.-]+\s*>', Name.Tag),
|
1026
|
+
],
|
1027
|
+
'comment': [
|
1028
|
+
('[^-]+', Comment),
|
1029
|
+
('-->', Comment, '#pop'),
|
1030
|
+
('-', Comment),
|
1031
|
+
],
|
1032
|
+
'tag': [
|
1033
|
+
(r'\s+', Text),
|
1034
|
+
(r'[\w.:-]+\s*=', Name.Attribute, 'attr'),
|
1035
|
+
(r'/?\s*>', Name.Tag, '#pop'),
|
1036
|
+
],
|
1037
|
+
'attr': [
|
1038
|
+
('\s+', Text),
|
1039
|
+
('".*?"', String, '#pop'),
|
1040
|
+
("'.*?'", String, '#pop'),
|
1041
|
+
(r'[^\s>]+', String, '#pop'),
|
1042
|
+
],
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
def analyse_text(text):
|
1046
|
+
if looks_like_xml(text):
|
1047
|
+
return 0.5
|
1048
|
+
|
1049
|
+
|
1050
|
+
class XsltLexer(XmlLexer):
|
1051
|
+
'''
|
1052
|
+
A lexer for XSLT.
|
1053
|
+
|
1054
|
+
*New in Pygments 0.10.*
|
1055
|
+
'''
|
1056
|
+
|
1057
|
+
name = 'XSLT'
|
1058
|
+
aliases = ['xslt']
|
1059
|
+
filenames = ['*.xsl', '*.xslt', '*.xpl'] # xpl is XProc
|
1060
|
+
mimetypes = ['application/xsl+xml', 'application/xslt+xml']
|
1061
|
+
|
1062
|
+
EXTRA_KEYWORDS = set([
|
1063
|
+
'apply-imports', 'apply-templates', 'attribute',
|
1064
|
+
'attribute-set', 'call-template', 'choose', 'comment',
|
1065
|
+
'copy', 'copy-of', 'decimal-format', 'element', 'fallback',
|
1066
|
+
'for-each', 'if', 'import', 'include', 'key', 'message',
|
1067
|
+
'namespace-alias', 'number', 'otherwise', 'output', 'param',
|
1068
|
+
'preserve-space', 'processing-instruction', 'sort',
|
1069
|
+
'strip-space', 'stylesheet', 'template', 'text', 'transform',
|
1070
|
+
'value-of', 'variable', 'when', 'with-param'
|
1071
|
+
])
|
1072
|
+
|
1073
|
+
def get_tokens_unprocessed(self, text):
|
1074
|
+
for index, token, value in XmlLexer.get_tokens_unprocessed(self, text):
|
1075
|
+
m = re.match('</?xsl:([^>]*)/?>?', value)
|
1076
|
+
|
1077
|
+
if token is Name.Tag and m and m.group(1) in self.EXTRA_KEYWORDS:
|
1078
|
+
yield index, Keyword, value
|
1079
|
+
else:
|
1080
|
+
yield index, token, value
|
1081
|
+
|
1082
|
+
def analyse_text(text):
|
1083
|
+
if looks_like_xml(text) and '<xsl' in text:
|
1084
|
+
return 0.8
|
1085
|
+
|
1086
|
+
|
1087
|
+
class MxmlLexer(RegexLexer):
|
1088
|
+
"""
|
1089
|
+
For MXML markup.
|
1090
|
+
Nested AS3 in <script> tags is highlighted by the appropriate lexer.
|
1091
|
+
|
1092
|
+
*New in Pygments 1.1.*
|
1093
|
+
"""
|
1094
|
+
flags = re.MULTILINE | re.DOTALL
|
1095
|
+
name = 'MXML'
|
1096
|
+
aliases = ['mxml']
|
1097
|
+
filenames = ['*.mxml']
|
1098
|
+
mimetimes = ['text/xml', 'application/xml']
|
1099
|
+
|
1100
|
+
tokens = {
|
1101
|
+
'root': [
|
1102
|
+
('[^<&]+', Text),
|
1103
|
+
(r'&\S*?;', Name.Entity),
|
1104
|
+
(r'(\<\!\[CDATA\[)(.*?)(\]\]\>)',
|
1105
|
+
bygroups(String, using(ActionScript3Lexer), String)),
|
1106
|
+
('<!--', Comment, 'comment'),
|
1107
|
+
(r'<\?.*?\?>', Comment.Preproc),
|
1108
|
+
('<![^>]*>', Comment.Preproc),
|
1109
|
+
(r'<\s*[a-zA-Z0-9:._-]+', Name.Tag, 'tag'),
|
1110
|
+
(r'<\s*/\s*[a-zA-Z0-9:._-]+\s*>', Name.Tag),
|
1111
|
+
],
|
1112
|
+
'comment': [
|
1113
|
+
('[^-]+', Comment),
|
1114
|
+
('-->', Comment, '#pop'),
|
1115
|
+
('-', Comment),
|
1116
|
+
],
|
1117
|
+
'tag': [
|
1118
|
+
(r'\s+', Text),
|
1119
|
+
(r'[a-zA-Z0-9_.:-]+\s*=', Name.Attribute, 'attr'),
|
1120
|
+
(r'/?\s*>', Name.Tag, '#pop'),
|
1121
|
+
],
|
1122
|
+
'attr': [
|
1123
|
+
('\s+', Text),
|
1124
|
+
('".*?"', String, '#pop'),
|
1125
|
+
("'.*?'", String, '#pop'),
|
1126
|
+
(r'[^\s>]+', String, '#pop'),
|
1127
|
+
],
|
1128
|
+
}
|
1129
|
+
|
1130
|
+
|
1131
|
+
class HaxeLexer(ExtendedRegexLexer):
|
1132
|
+
"""
|
1133
|
+
For Haxe source code (http://haxe.org/).
|
1134
|
+
|
1135
|
+
*New in Pygments 1.3.*
|
1136
|
+
"""
|
1137
|
+
|
1138
|
+
name = 'Haxe'
|
1139
|
+
aliases = ['hx', 'Haxe', 'haxe', 'haXe', 'hxsl']
|
1140
|
+
filenames = ['*.hx', '*.hxsl']
|
1141
|
+
mimetypes = ['text/haxe', 'text/x-haxe', 'text/x-hx']
|
1142
|
+
|
1143
|
+
# keywords extracted from lexer.mll in the haxe compiler source
|
1144
|
+
keyword = (r'(?:function|class|static|var|if|else|while|do|for|'
|
1145
|
+
r'break|return|continue|extends|implements|import|'
|
1146
|
+
r'switch|case|default|public|private|try|untyped|'
|
1147
|
+
r'catch|new|this|throw|extern|enum|in|interface|'
|
1148
|
+
r'cast|override|dynamic|typedef|package|'
|
1149
|
+
r'inline|using|null|true|false|abstract)\b')
|
1150
|
+
|
1151
|
+
# idtype in lexer.mll
|
1152
|
+
typeid = r'_*[A-Z][_a-zA-Z0-9]*'
|
1153
|
+
|
1154
|
+
# combined ident and dollar and idtype
|
1155
|
+
ident = r'(?:_*[a-z][_a-zA-Z0-9]*|_+[0-9][_a-zA-Z0-9]*|' + typeid + \
|
1156
|
+
'|_+|\$[_a-zA-Z0-9]+)'
|
1157
|
+
|
1158
|
+
binop = (r'(?:%=|&=|\|=|\^=|\+=|\-=|\*=|/=|<<=|>\s*>\s*=|>\s*>\s*>\s*=|==|'
|
1159
|
+
r'!=|<=|>\s*=|&&|\|\||<<|>>>|>\s*>|\.\.\.|<|>|%|&|\||\^|\+|\*|'
|
1160
|
+
r'/|\-|=>|=)')
|
1161
|
+
|
1162
|
+
# ident except keywords
|
1163
|
+
ident_no_keyword = r'(?!' + keyword + ')' + ident
|
1164
|
+
|
1165
|
+
flags = re.DOTALL | re.MULTILINE
|
1166
|
+
|
1167
|
+
preproc_stack = []
|
1168
|
+
|
1169
|
+
def preproc_callback(self, match, ctx):
|
1170
|
+
proc = match.group(2)
|
1171
|
+
|
1172
|
+
if proc == 'if':
|
1173
|
+
# store the current stack
|
1174
|
+
self.preproc_stack.append(ctx.stack[:])
|
1175
|
+
elif proc in ['else', 'elseif']:
|
1176
|
+
# restore the stack back to right before #if
|
1177
|
+
if self.preproc_stack: ctx.stack = self.preproc_stack[-1][:]
|
1178
|
+
elif proc == 'end':
|
1179
|
+
# remove the saved stack of previous #if
|
1180
|
+
if self.preproc_stack: self.preproc_stack.pop()
|
1181
|
+
|
1182
|
+
# #if and #elseif should follow by an expr
|
1183
|
+
if proc in ['if', 'elseif']:
|
1184
|
+
ctx.stack.append('preproc-expr')
|
1185
|
+
|
1186
|
+
# #error can be optionally follow by the error msg
|
1187
|
+
if proc in ['error']:
|
1188
|
+
ctx.stack.append('preproc-error')
|
1189
|
+
|
1190
|
+
yield match.start(), Comment.Preproc, '#' + proc
|
1191
|
+
ctx.pos = match.end()
|
1192
|
+
|
1193
|
+
|
1194
|
+
tokens = {
|
1195
|
+
'root': [
|
1196
|
+
include('spaces'),
|
1197
|
+
include('meta'),
|
1198
|
+
(r'(?:package)\b', Keyword.Namespace, ('semicolon', 'package')),
|
1199
|
+
(r'(?:import)\b', Keyword.Namespace, ('semicolon', 'import')),
|
1200
|
+
(r'(?:using)\b', Keyword.Namespace, ('semicolon', 'using')),
|
1201
|
+
(r'(?:extern|private)\b', Keyword.Declaration),
|
1202
|
+
(r'(?:abstract)\b', Keyword.Declaration, 'abstract'),
|
1203
|
+
(r'(?:class|interface)\b', Keyword.Declaration, 'class'),
|
1204
|
+
(r'(?:enum)\b', Keyword.Declaration, 'enum'),
|
1205
|
+
(r'(?:typedef)\b', Keyword.Declaration, 'typedef'),
|
1206
|
+
|
1207
|
+
# top-level expression
|
1208
|
+
# although it is not supported in haxe, but it is common to write
|
1209
|
+
# expression in web pages the positive lookahead here is to prevent
|
1210
|
+
# an infinite loop at the EOF
|
1211
|
+
(r'(?=.)', Text, 'expr-statement'),
|
1212
|
+
],
|
1213
|
+
|
1214
|
+
# space/tab/comment/preproc
|
1215
|
+
'spaces': [
|
1216
|
+
(r'\s+', Text),
|
1217
|
+
(r'//[^\n\r]*', Comment.Single),
|
1218
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
1219
|
+
(r'(#)(if|elseif|else|end|error)\b', preproc_callback),
|
1220
|
+
],
|
1221
|
+
|
1222
|
+
'string-single-interpol': [
|
1223
|
+
(r'\$\{', String.Interpol, ('string-interpol-close', 'expr')),
|
1224
|
+
(r'\$\$', String.Escape),
|
1225
|
+
(r'\$(?=' + ident + ')', String.Interpol, 'ident'),
|
1226
|
+
include('string-single'),
|
1227
|
+
],
|
1228
|
+
|
1229
|
+
'string-single': [
|
1230
|
+
(r"'", String.Single, '#pop'),
|
1231
|
+
(r'\\.', String.Escape),
|
1232
|
+
(r'.', String.Single),
|
1233
|
+
],
|
1234
|
+
|
1235
|
+
'string-double': [
|
1236
|
+
(r'"', String.Double, '#pop'),
|
1237
|
+
(r'\\.', String.Escape),
|
1238
|
+
(r'.', String.Double),
|
1239
|
+
],
|
1240
|
+
|
1241
|
+
'string-interpol-close': [
|
1242
|
+
(r'\$'+ident, String.Interpol),
|
1243
|
+
(r'\}', String.Interpol, '#pop'),
|
1244
|
+
],
|
1245
|
+
|
1246
|
+
'package': [
|
1247
|
+
include('spaces'),
|
1248
|
+
(ident, Name.Namespace),
|
1249
|
+
(r'\.', Punctuation, 'import-ident'),
|
1250
|
+
(r'', Text, '#pop'),
|
1251
|
+
],
|
1252
|
+
|
1253
|
+
'import': [
|
1254
|
+
include('spaces'),
|
1255
|
+
(ident, Name.Namespace),
|
1256
|
+
(r'\*', Keyword), # wildcard import
|
1257
|
+
(r'\.', Punctuation, 'import-ident'),
|
1258
|
+
(r'in', Keyword.Namespace, 'ident'),
|
1259
|
+
(r'', Text, '#pop'),
|
1260
|
+
],
|
1261
|
+
|
1262
|
+
'import-ident': [
|
1263
|
+
include('spaces'),
|
1264
|
+
(r'\*', Keyword, '#pop'), # wildcard import
|
1265
|
+
(ident, Name.Namespace, '#pop'),
|
1266
|
+
],
|
1267
|
+
|
1268
|
+
'using': [
|
1269
|
+
include('spaces'),
|
1270
|
+
(ident, Name.Namespace),
|
1271
|
+
(r'\.', Punctuation, 'import-ident'),
|
1272
|
+
(r'', Text, '#pop'),
|
1273
|
+
],
|
1274
|
+
|
1275
|
+
'preproc-error': [
|
1276
|
+
(r'\s+', Comment.Preproc),
|
1277
|
+
(r"'", String.Single, ('#pop', 'string-single')),
|
1278
|
+
(r'"', String.Double, ('#pop', 'string-double')),
|
1279
|
+
(r'', Text, '#pop'),
|
1280
|
+
],
|
1281
|
+
|
1282
|
+
'preproc-expr': [
|
1283
|
+
(r'\s+', Comment.Preproc),
|
1284
|
+
(r'\!', Comment.Preproc),
|
1285
|
+
(r'\(', Comment.Preproc, ('#pop', 'preproc-parenthesis')),
|
1286
|
+
|
1287
|
+
(ident, Comment.Preproc, '#pop'),
|
1288
|
+
(r"'", String.Single, ('#pop', 'string-single')),
|
1289
|
+
(r'"', String.Double, ('#pop', 'string-double')),
|
1290
|
+
],
|
1291
|
+
|
1292
|
+
'preproc-parenthesis': [
|
1293
|
+
(r'\s+', Comment.Preproc),
|
1294
|
+
(r'\)', Comment.Preproc, '#pop'),
|
1295
|
+
('', Text, 'preproc-expr-in-parenthesis'),
|
1296
|
+
],
|
1297
|
+
|
1298
|
+
'preproc-expr-chain': [
|
1299
|
+
(r'\s+', Comment.Preproc),
|
1300
|
+
(binop, Comment.Preproc, ('#pop', 'preproc-expr-in-parenthesis')),
|
1301
|
+
(r'', Text, '#pop'),
|
1302
|
+
],
|
1303
|
+
|
1304
|
+
# same as 'preproc-expr' but able to chain 'preproc-expr-chain'
|
1305
|
+
'preproc-expr-in-parenthesis': [
|
1306
|
+
(r'\s+', Comment.Preproc),
|
1307
|
+
(r'\!', Comment.Preproc),
|
1308
|
+
(r'\(', Comment.Preproc,
|
1309
|
+
('#pop', 'preproc-expr-chain', 'preproc-parenthesis')),
|
1310
|
+
|
1311
|
+
(ident, Comment.Preproc, ('#pop', 'preproc-expr-chain')),
|
1312
|
+
(r"'", String.Single,
|
1313
|
+
('#pop', 'preproc-expr-chain', 'string-single')),
|
1314
|
+
(r'"', String.Double,
|
1315
|
+
('#pop', 'preproc-expr-chain', 'string-double')),
|
1316
|
+
],
|
1317
|
+
|
1318
|
+
'abstract' : [
|
1319
|
+
include('spaces'),
|
1320
|
+
(r'', Text, ('#pop', 'abstract-body', 'abstract-relation',
|
1321
|
+
'abstract-opaque', 'type-param-constraint', 'type-name')),
|
1322
|
+
],
|
1323
|
+
|
1324
|
+
'abstract-body' : [
|
1325
|
+
include('spaces'),
|
1326
|
+
(r'\{', Punctuation, ('#pop', 'class-body')),
|
1327
|
+
],
|
1328
|
+
|
1329
|
+
'abstract-opaque' : [
|
1330
|
+
include('spaces'),
|
1331
|
+
(r'\(', Punctuation, ('#pop', 'parenthesis-close', 'type')),
|
1332
|
+
(r'', Text, '#pop'),
|
1333
|
+
],
|
1334
|
+
|
1335
|
+
'abstract-relation': [
|
1336
|
+
include('spaces'),
|
1337
|
+
(r'(?:to|from)', Keyword.Declaration, 'type'),
|
1338
|
+
(r',', Punctuation),
|
1339
|
+
(r'', Text, '#pop'),
|
1340
|
+
],
|
1341
|
+
|
1342
|
+
'meta': [
|
1343
|
+
include('spaces'),
|
1344
|
+
(r'@', Name.Decorator, ('meta-body', 'meta-ident', 'meta-colon')),
|
1345
|
+
],
|
1346
|
+
|
1347
|
+
# optional colon
|
1348
|
+
'meta-colon': [
|
1349
|
+
include('spaces'),
|
1350
|
+
(r':', Name.Decorator, '#pop'),
|
1351
|
+
(r'', Text, '#pop'),
|
1352
|
+
],
|
1353
|
+
|
1354
|
+
# same as 'ident' but set token as Name.Decorator instead of Name
|
1355
|
+
'meta-ident': [
|
1356
|
+
include('spaces'),
|
1357
|
+
(ident, Name.Decorator, '#pop'),
|
1358
|
+
],
|
1359
|
+
|
1360
|
+
'meta-body': [
|
1361
|
+
include('spaces'),
|
1362
|
+
(r'\(', Name.Decorator, ('#pop', 'meta-call')),
|
1363
|
+
(r'', Text, '#pop'),
|
1364
|
+
],
|
1365
|
+
|
1366
|
+
'meta-call': [
|
1367
|
+
include('spaces'),
|
1368
|
+
(r'\)', Name.Decorator, '#pop'),
|
1369
|
+
(r'', Text, ('#pop', 'meta-call-sep', 'expr')),
|
1370
|
+
],
|
1371
|
+
|
1372
|
+
'meta-call-sep': [
|
1373
|
+
include('spaces'),
|
1374
|
+
(r'\)', Name.Decorator, '#pop'),
|
1375
|
+
(r',', Punctuation, ('#pop', 'meta-call')),
|
1376
|
+
],
|
1377
|
+
|
1378
|
+
'typedef': [
|
1379
|
+
include('spaces'),
|
1380
|
+
(r'', Text, ('#pop', 'typedef-body', 'type-param-constraint',
|
1381
|
+
'type-name')),
|
1382
|
+
],
|
1383
|
+
|
1384
|
+
'typedef-body': [
|
1385
|
+
include('spaces'),
|
1386
|
+
(r'=', Operator, ('#pop', 'optional-semicolon', 'type')),
|
1387
|
+
],
|
1388
|
+
|
1389
|
+
'enum': [
|
1390
|
+
include('spaces'),
|
1391
|
+
(r'', Text, ('#pop', 'enum-body', 'bracket-open',
|
1392
|
+
'type-param-constraint', 'type-name')),
|
1393
|
+
],
|
1394
|
+
|
1395
|
+
'enum-body': [
|
1396
|
+
include('spaces'),
|
1397
|
+
include('meta'),
|
1398
|
+
(r'\}', Punctuation, '#pop'),
|
1399
|
+
(ident_no_keyword, Name, ('enum-member', 'type-param-constraint')),
|
1400
|
+
],
|
1401
|
+
|
1402
|
+
'enum-member': [
|
1403
|
+
include('spaces'),
|
1404
|
+
(r'\(', Punctuation,
|
1405
|
+
('#pop', 'semicolon', 'flag', 'function-param')),
|
1406
|
+
(r'', Punctuation, ('#pop', 'semicolon', 'flag')),
|
1407
|
+
],
|
1408
|
+
|
1409
|
+
'class': [
|
1410
|
+
include('spaces'),
|
1411
|
+
(r'', Text, ('#pop', 'class-body', 'bracket-open', 'extends',
|
1412
|
+
'type-param-constraint', 'type-name')),
|
1413
|
+
],
|
1414
|
+
|
1415
|
+
'extends': [
|
1416
|
+
include('spaces'),
|
1417
|
+
(r'(?:extends|implements)\b', Keyword.Declaration, 'type'),
|
1418
|
+
(r',', Punctuation), # the comma is made optional here, since haxe2
|
1419
|
+
# requires the comma but haxe3 does not allow it
|
1420
|
+
(r'', Text, '#pop'),
|
1421
|
+
],
|
1422
|
+
|
1423
|
+
'bracket-open': [
|
1424
|
+
include('spaces'),
|
1425
|
+
(r'\{', Punctuation, '#pop'),
|
1426
|
+
],
|
1427
|
+
|
1428
|
+
'bracket-close': [
|
1429
|
+
include('spaces'),
|
1430
|
+
(r'\}', Punctuation, '#pop'),
|
1431
|
+
],
|
1432
|
+
|
1433
|
+
'class-body': [
|
1434
|
+
include('spaces'),
|
1435
|
+
include('meta'),
|
1436
|
+
(r'\}', Punctuation, '#pop'),
|
1437
|
+
(r'(?:static|public|private|override|dynamic|inline|macro)\b',
|
1438
|
+
Keyword.Declaration),
|
1439
|
+
(r'', Text, 'class-member'),
|
1440
|
+
],
|
1441
|
+
|
1442
|
+
'class-member': [
|
1443
|
+
include('spaces'),
|
1444
|
+
(r'(var)\b', Keyword.Declaration,
|
1445
|
+
('#pop', 'optional-semicolon', 'prop')),
|
1446
|
+
(r'(function)\b', Keyword.Declaration,
|
1447
|
+
('#pop', 'optional-semicolon', 'class-method')),
|
1448
|
+
],
|
1449
|
+
|
1450
|
+
# local function, anonymous or not
|
1451
|
+
'function-local': [
|
1452
|
+
include('spaces'),
|
1453
|
+
(r'(' + ident_no_keyword + ')?', Name.Function,
|
1454
|
+
('#pop', 'expr', 'flag', 'function-param',
|
1455
|
+
'parenthesis-open', 'type-param-constraint')),
|
1456
|
+
],
|
1457
|
+
|
1458
|
+
'optional-expr': [
|
1459
|
+
include('spaces'),
|
1460
|
+
include('expr'),
|
1461
|
+
(r'', Text, '#pop'),
|
1462
|
+
],
|
1463
|
+
|
1464
|
+
'class-method': [
|
1465
|
+
include('spaces'),
|
1466
|
+
(ident, Name.Function, ('#pop', 'optional-expr', 'flag',
|
1467
|
+
'function-param', 'parenthesis-open',
|
1468
|
+
'type-param-constraint')),
|
1469
|
+
],
|
1470
|
+
|
1471
|
+
# function arguments
|
1472
|
+
'function-param': [
|
1473
|
+
include('spaces'),
|
1474
|
+
(r'\)', Punctuation, '#pop'),
|
1475
|
+
(r'\?', Punctuation),
|
1476
|
+
(ident_no_keyword, Name,
|
1477
|
+
('#pop', 'function-param-sep', 'assign', 'flag')),
|
1478
|
+
],
|
1479
|
+
|
1480
|
+
'function-param-sep': [
|
1481
|
+
include('spaces'),
|
1482
|
+
(r'\)', Punctuation, '#pop'),
|
1483
|
+
(r',', Punctuation, ('#pop', 'function-param')),
|
1484
|
+
],
|
1485
|
+
|
1486
|
+
# class property
|
1487
|
+
# eg. var prop(default, null):String;
|
1488
|
+
'prop': [
|
1489
|
+
include('spaces'),
|
1490
|
+
(ident_no_keyword, Name, ('#pop', 'assign', 'flag', 'prop-get-set')),
|
1491
|
+
],
|
1492
|
+
|
1493
|
+
'prop-get-set': [
|
1494
|
+
include('spaces'),
|
1495
|
+
(r'\(', Punctuation, ('#pop', 'parenthesis-close',
|
1496
|
+
'prop-get-set-opt', 'comma', 'prop-get-set-opt')),
|
1497
|
+
(r'', Text, '#pop'),
|
1498
|
+
],
|
1499
|
+
|
1500
|
+
'prop-get-set-opt': [
|
1501
|
+
include('spaces'),
|
1502
|
+
(r'(?:default|null|never|dynamic|get|set)\b', Keyword, '#pop'),
|
1503
|
+
(ident_no_keyword, Text, '#pop'), #custom getter/setter
|
1504
|
+
],
|
1505
|
+
|
1506
|
+
'expr-statement': [
|
1507
|
+
include('spaces'),
|
1508
|
+
# makes semicolon optional here, just to avoid checking the last
|
1509
|
+
# one is bracket or not.
|
1510
|
+
(r'', Text, ('#pop', 'optional-semicolon', 'expr')),
|
1511
|
+
],
|
1512
|
+
|
1513
|
+
'expr': [
|
1514
|
+
include('spaces'),
|
1515
|
+
(r'@', Name.Decorator, ('#pop', 'optional-expr', 'meta-body',
|
1516
|
+
'meta-ident', 'meta-colon')),
|
1517
|
+
(r'(?:\+\+|\-\-|~(?!/)|!|\-)', Operator),
|
1518
|
+
(r'\(', Punctuation, ('#pop', 'expr-chain', 'parenthesis')),
|
1519
|
+
(r'(?:inline)\b', Keyword.Declaration),
|
1520
|
+
(r'(?:function)\b', Keyword.Declaration, ('#pop', 'expr-chain',
|
1521
|
+
'function-local')),
|
1522
|
+
(r'\{', Punctuation, ('#pop', 'expr-chain', 'bracket')),
|
1523
|
+
(r'(?:true|false|null)\b', Keyword.Constant, ('#pop', 'expr-chain')),
|
1524
|
+
(r'(?:this)\b', Keyword, ('#pop', 'expr-chain')),
|
1525
|
+
(r'(?:cast)\b', Keyword, ('#pop', 'expr-chain', 'cast')),
|
1526
|
+
(r'(?:try)\b', Keyword, ('#pop', 'catch', 'expr')),
|
1527
|
+
(r'(?:var)\b', Keyword.Declaration, ('#pop', 'var')),
|
1528
|
+
(r'(?:new)\b', Keyword, ('#pop', 'expr-chain', 'new')),
|
1529
|
+
(r'(?:switch)\b', Keyword, ('#pop', 'switch')),
|
1530
|
+
(r'(?:if)\b', Keyword, ('#pop', 'if')),
|
1531
|
+
(r'(?:do)\b', Keyword, ('#pop', 'do')),
|
1532
|
+
(r'(?:while)\b', Keyword, ('#pop', 'while')),
|
1533
|
+
(r'(?:for)\b', Keyword, ('#pop', 'for')),
|
1534
|
+
(r'(?:untyped|throw)\b', Keyword),
|
1535
|
+
(r'(?:return)\b', Keyword, ('#pop', 'optional-expr')),
|
1536
|
+
(r'(?:macro)\b', Keyword, ('#pop', 'macro')),
|
1537
|
+
(r'(?:continue|break)\b', Keyword, '#pop'),
|
1538
|
+
(r'(?:\$\s*[a-z]\b|\$(?!'+ident+'))', Name, ('#pop', 'dollar')),
|
1539
|
+
(ident_no_keyword, Name, ('#pop', 'expr-chain')),
|
1540
|
+
|
1541
|
+
# Float
|
1542
|
+
(r'\.[0-9]+', Number.Float, ('#pop', 'expr-chain')),
|
1543
|
+
(r'[0-9]+[eE][\+\-]?[0-9]+', Number.Float, ('#pop', 'expr-chain')),
|
1544
|
+
(r'[0-9]+\.[0-9]*[eE][\+\-]?[0-9]+', Number.Float, ('#pop', 'expr-chain')),
|
1545
|
+
(r'[0-9]+\.[0-9]+', Number.Float, ('#pop', 'expr-chain')),
|
1546
|
+
(r'[0-9]+\.(?!' + ident + '|\.\.)', Number.Float, ('#pop', 'expr-chain')),
|
1547
|
+
|
1548
|
+
# Int
|
1549
|
+
(r'0x[0-9a-fA-F]+', Number.Hex, ('#pop', 'expr-chain')),
|
1550
|
+
(r'[0-9]+', Number.Integer, ('#pop', 'expr-chain')),
|
1551
|
+
|
1552
|
+
# String
|
1553
|
+
(r"'", String.Single, ('#pop', 'expr-chain', 'string-single-interpol')),
|
1554
|
+
(r'"', String.Double, ('#pop', 'expr-chain', 'string-double')),
|
1555
|
+
|
1556
|
+
# EReg
|
1557
|
+
(r'~/(\\\\|\\/|[^/\n])*/[gimsu]*', String.Regex, ('#pop', 'expr-chain')),
|
1558
|
+
|
1559
|
+
# Array
|
1560
|
+
(r'\[', Punctuation, ('#pop', 'expr-chain', 'array-decl')),
|
1561
|
+
],
|
1562
|
+
|
1563
|
+
'expr-chain': [
|
1564
|
+
include('spaces'),
|
1565
|
+
(r'(?:\+\+|\-\-)', Operator),
|
1566
|
+
(binop, Operator, ('#pop', 'expr')),
|
1567
|
+
(r'(?:in)\b', Keyword, ('#pop', 'expr')),
|
1568
|
+
(r'\?', Operator, ('#pop', 'expr', 'ternary', 'expr')),
|
1569
|
+
(r'(\.)(' + ident_no_keyword + ')', bygroups(Punctuation, Name)),
|
1570
|
+
(r'\[', Punctuation, 'array-access'),
|
1571
|
+
(r'\(', Punctuation, 'call'),
|
1572
|
+
(r'', Text, '#pop'),
|
1573
|
+
],
|
1574
|
+
|
1575
|
+
# macro reification
|
1576
|
+
'macro': [
|
1577
|
+
include('spaces'),
|
1578
|
+
(r':', Punctuation, ('#pop', 'type')),
|
1579
|
+
(r'', Text, ('#pop', 'expr')),
|
1580
|
+
],
|
1581
|
+
|
1582
|
+
# cast can be written as "cast expr" or "cast(expr, type)"
|
1583
|
+
'cast': [
|
1584
|
+
include('spaces'),
|
1585
|
+
(r'\(', Punctuation, ('#pop', 'parenthesis-close',
|
1586
|
+
'cast-type', 'expr')),
|
1587
|
+
(r'', Text, ('#pop', 'expr')),
|
1588
|
+
],
|
1589
|
+
|
1590
|
+
# optionally give a type as the 2nd argument of cast()
|
1591
|
+
'cast-type': [
|
1592
|
+
include('spaces'),
|
1593
|
+
(r',', Punctuation, ('#pop', 'type')),
|
1594
|
+
(r'', Text, '#pop'),
|
1595
|
+
],
|
1596
|
+
|
1597
|
+
'catch': [
|
1598
|
+
include('spaces'),
|
1599
|
+
(r'(?:catch)\b', Keyword, ('expr', 'function-param',
|
1600
|
+
'parenthesis-open')),
|
1601
|
+
(r'', Text, '#pop'),
|
1602
|
+
],
|
1603
|
+
|
1604
|
+
# do-while loop
|
1605
|
+
'do': [
|
1606
|
+
include('spaces'),
|
1607
|
+
(r'', Punctuation, ('#pop', 'do-while', 'expr')),
|
1608
|
+
],
|
1609
|
+
|
1610
|
+
# the while after do
|
1611
|
+
'do-while': [
|
1612
|
+
include('spaces'),
|
1613
|
+
(r'(?:while)\b', Keyword, ('#pop', 'parenthesis',
|
1614
|
+
'parenthesis-open')),
|
1615
|
+
],
|
1616
|
+
|
1617
|
+
'while': [
|
1618
|
+
include('spaces'),
|
1619
|
+
(r'\(', Punctuation, ('#pop', 'expr', 'parenthesis')),
|
1620
|
+
],
|
1621
|
+
|
1622
|
+
'for': [
|
1623
|
+
include('spaces'),
|
1624
|
+
(r'\(', Punctuation, ('#pop', 'expr', 'parenthesis')),
|
1625
|
+
],
|
1626
|
+
|
1627
|
+
'if': [
|
1628
|
+
include('spaces'),
|
1629
|
+
(r'\(', Punctuation, ('#pop', 'else', 'optional-semicolon', 'expr',
|
1630
|
+
'parenthesis')),
|
1631
|
+
],
|
1632
|
+
|
1633
|
+
'else': [
|
1634
|
+
include('spaces'),
|
1635
|
+
(r'(?:else)\b', Keyword, ('#pop', 'expr')),
|
1636
|
+
(r'', Text, '#pop'),
|
1637
|
+
],
|
1638
|
+
|
1639
|
+
'switch': [
|
1640
|
+
include('spaces'),
|
1641
|
+
(r'', Text, ('#pop', 'switch-body', 'bracket-open', 'expr')),
|
1642
|
+
],
|
1643
|
+
|
1644
|
+
'switch-body': [
|
1645
|
+
include('spaces'),
|
1646
|
+
(r'(?:case|default)\b', Keyword, ('case-block', 'case')),
|
1647
|
+
(r'\}', Punctuation, '#pop'),
|
1648
|
+
],
|
1649
|
+
|
1650
|
+
'case': [
|
1651
|
+
include('spaces'),
|
1652
|
+
(r':', Punctuation, '#pop'),
|
1653
|
+
(r'', Text, ('#pop', 'case-sep', 'case-guard', 'expr')),
|
1654
|
+
],
|
1655
|
+
|
1656
|
+
'case-sep': [
|
1657
|
+
include('spaces'),
|
1658
|
+
(r':', Punctuation, '#pop'),
|
1659
|
+
(r',', Punctuation, ('#pop', 'case')),
|
1660
|
+
],
|
1661
|
+
|
1662
|
+
'case-guard': [
|
1663
|
+
include('spaces'),
|
1664
|
+
(r'(?:if)\b', Keyword, ('#pop', 'parenthesis', 'parenthesis-open')),
|
1665
|
+
(r'', Text, '#pop'),
|
1666
|
+
],
|
1667
|
+
|
1668
|
+
# optional multiple expr under a case
|
1669
|
+
'case-block': [
|
1670
|
+
include('spaces'),
|
1671
|
+
(r'(?!(?:case|default)\b|\})', Keyword, 'expr-statement'),
|
1672
|
+
(r'', Text, '#pop'),
|
1673
|
+
],
|
1674
|
+
|
1675
|
+
'new': [
|
1676
|
+
include('spaces'),
|
1677
|
+
(r'', Text, ('#pop', 'call', 'parenthesis-open', 'type')),
|
1678
|
+
],
|
1679
|
+
|
1680
|
+
'array-decl': [
|
1681
|
+
include('spaces'),
|
1682
|
+
(r'\]', Punctuation, '#pop'),
|
1683
|
+
(r'', Text, ('#pop', 'array-decl-sep', 'expr')),
|
1684
|
+
],
|
1685
|
+
|
1686
|
+
'array-decl-sep': [
|
1687
|
+
include('spaces'),
|
1688
|
+
(r'\]', Punctuation, '#pop'),
|
1689
|
+
(r',', Punctuation, ('#pop', 'array-decl')),
|
1690
|
+
],
|
1691
|
+
|
1692
|
+
'array-access': [
|
1693
|
+
include('spaces'),
|
1694
|
+
(r'', Text, ('#pop', 'array-access-close', 'expr')),
|
1695
|
+
],
|
1696
|
+
|
1697
|
+
'array-access-close': [
|
1698
|
+
include('spaces'),
|
1699
|
+
(r'\]', Punctuation, '#pop'),
|
1700
|
+
],
|
1701
|
+
|
1702
|
+
'comma': [
|
1703
|
+
include('spaces'),
|
1704
|
+
(r',', Punctuation, '#pop'),
|
1705
|
+
],
|
1706
|
+
|
1707
|
+
'colon': [
|
1708
|
+
include('spaces'),
|
1709
|
+
(r':', Punctuation, '#pop'),
|
1710
|
+
],
|
1711
|
+
|
1712
|
+
'semicolon': [
|
1713
|
+
include('spaces'),
|
1714
|
+
(r';', Punctuation, '#pop'),
|
1715
|
+
],
|
1716
|
+
|
1717
|
+
'optional-semicolon': [
|
1718
|
+
include('spaces'),
|
1719
|
+
(r';', Punctuation, '#pop'),
|
1720
|
+
(r'', Text, '#pop'),
|
1721
|
+
],
|
1722
|
+
|
1723
|
+
# identity that CAN be a Haxe keyword
|
1724
|
+
'ident': [
|
1725
|
+
include('spaces'),
|
1726
|
+
(ident, Name, '#pop'),
|
1727
|
+
],
|
1728
|
+
|
1729
|
+
'dollar': [
|
1730
|
+
include('spaces'),
|
1731
|
+
(r'\{', Keyword, ('#pop', 'bracket-close', 'expr')),
|
1732
|
+
(r'', Text, ('#pop', 'expr-chain')),
|
1733
|
+
],
|
1734
|
+
|
1735
|
+
'type-name': [
|
1736
|
+
include('spaces'),
|
1737
|
+
(typeid, Name, '#pop'),
|
1738
|
+
],
|
1739
|
+
|
1740
|
+
'type-full-name': [
|
1741
|
+
include('spaces'),
|
1742
|
+
(r'\.', Punctuation, 'ident'),
|
1743
|
+
(r'', Text, '#pop'),
|
1744
|
+
],
|
1745
|
+
|
1746
|
+
'type': [
|
1747
|
+
include('spaces'),
|
1748
|
+
(r'\?', Punctuation),
|
1749
|
+
(ident, Name, ('#pop', 'type-check', 'type-full-name')),
|
1750
|
+
(r'\{', Punctuation, ('#pop', 'type-check', 'type-struct')),
|
1751
|
+
(r'\(', Punctuation, ('#pop', 'type-check', 'type-parenthesis')),
|
1752
|
+
],
|
1753
|
+
|
1754
|
+
'type-parenthesis': [
|
1755
|
+
include('spaces'),
|
1756
|
+
(r'', Text, ('#pop', 'parenthesis-close', 'type')),
|
1757
|
+
],
|
1758
|
+
|
1759
|
+
'type-check': [
|
1760
|
+
include('spaces'),
|
1761
|
+
(r'->', Punctuation, ('#pop', 'type')),
|
1762
|
+
(r'<(?!=)', Punctuation, 'type-param'),
|
1763
|
+
(r'', Text, '#pop'),
|
1764
|
+
],
|
1765
|
+
|
1766
|
+
'type-struct': [
|
1767
|
+
include('spaces'),
|
1768
|
+
(r'\}', Punctuation, '#pop'),
|
1769
|
+
(r'\?', Punctuation),
|
1770
|
+
(r'>', Punctuation, ('comma', 'type')),
|
1771
|
+
(ident_no_keyword, Name, ('#pop', 'type-struct-sep', 'type', 'colon')),
|
1772
|
+
include('class-body'),
|
1773
|
+
],
|
1774
|
+
|
1775
|
+
'type-struct-sep': [
|
1776
|
+
include('spaces'),
|
1777
|
+
(r'\}', Punctuation, '#pop'),
|
1778
|
+
(r',', Punctuation, ('#pop', 'type-struct')),
|
1779
|
+
],
|
1780
|
+
|
1781
|
+
# type-param can be a normal type or a constant literal...
|
1782
|
+
'type-param-type': [
|
1783
|
+
# Float
|
1784
|
+
(r'\.[0-9]+', Number.Float, '#pop'),
|
1785
|
+
(r'[0-9]+[eE][\+\-]?[0-9]+', Number.Float, '#pop'),
|
1786
|
+
(r'[0-9]+\.[0-9]*[eE][\+\-]?[0-9]+', Number.Float, '#pop'),
|
1787
|
+
(r'[0-9]+\.[0-9]+', Number.Float, '#pop'),
|
1788
|
+
(r'[0-9]+\.(?!' + ident + '|\.\.)', Number.Float, '#pop'),
|
1789
|
+
|
1790
|
+
# Int
|
1791
|
+
(r'0x[0-9a-fA-F]+', Number.Hex, '#pop'),
|
1792
|
+
(r'[0-9]+', Number.Integer, '#pop'),
|
1793
|
+
|
1794
|
+
# String
|
1795
|
+
(r"'", String.Single, ('#pop', 'string-single')),
|
1796
|
+
(r'"', String.Double, ('#pop', 'string-double')),
|
1797
|
+
|
1798
|
+
# EReg
|
1799
|
+
(r'~/(\\\\|\\/|[^/\n])*/[gim]*', String.Regex, '#pop'),
|
1800
|
+
|
1801
|
+
# Array
|
1802
|
+
(r'\[', Operator, ('#pop', 'array-decl')),
|
1803
|
+
|
1804
|
+
include('type'),
|
1805
|
+
],
|
1806
|
+
|
1807
|
+
# type-param part of a type
|
1808
|
+
# ie. the <A,B> path in Map<A,B>
|
1809
|
+
'type-param': [
|
1810
|
+
include('spaces'),
|
1811
|
+
(r'', Text, ('#pop', 'type-param-sep', 'type-param-type')),
|
1812
|
+
],
|
1813
|
+
|
1814
|
+
'type-param-sep': [
|
1815
|
+
include('spaces'),
|
1816
|
+
(r'>', Punctuation, '#pop'),
|
1817
|
+
(r',', Punctuation, ('#pop', 'type-param')),
|
1818
|
+
],
|
1819
|
+
|
1820
|
+
# optional type-param that may include constraint
|
1821
|
+
# ie. <T:Constraint, T2:(ConstraintA,ConstraintB)>
|
1822
|
+
'type-param-constraint': [
|
1823
|
+
include('spaces'),
|
1824
|
+
(r'<(?!=)', Punctuation, ('#pop', 'type-param-constraint-sep',
|
1825
|
+
'type-param-constraint-flag', 'type-name')),
|
1826
|
+
(r'', Text, '#pop'),
|
1827
|
+
],
|
1828
|
+
|
1829
|
+
'type-param-constraint-sep': [
|
1830
|
+
include('spaces'),
|
1831
|
+
(r'>', Punctuation, '#pop'),
|
1832
|
+
(r',', Punctuation, ('#pop', 'type-param-constraint-sep',
|
1833
|
+
'type-param-constraint-flag', 'type-name')),
|
1834
|
+
],
|
1835
|
+
|
1836
|
+
# the optional constraint inside type-param
|
1837
|
+
'type-param-constraint-flag': [
|
1838
|
+
include('spaces'),
|
1839
|
+
(r':', Punctuation, ('#pop', 'type-param-constraint-flag-type')),
|
1840
|
+
(r'', Text, '#pop'),
|
1841
|
+
],
|
1842
|
+
|
1843
|
+
'type-param-constraint-flag-type': [
|
1844
|
+
include('spaces'),
|
1845
|
+
(r'\(', Punctuation, ('#pop', 'type-param-constraint-flag-type-sep',
|
1846
|
+
'type')),
|
1847
|
+
(r'', Text, ('#pop', 'type')),
|
1848
|
+
],
|
1849
|
+
|
1850
|
+
'type-param-constraint-flag-type-sep': [
|
1851
|
+
include('spaces'),
|
1852
|
+
(r'\)', Punctuation, '#pop'),
|
1853
|
+
(r',', Punctuation, 'type'),
|
1854
|
+
],
|
1855
|
+
|
1856
|
+
# a parenthesis expr that contain exactly one expr
|
1857
|
+
'parenthesis': [
|
1858
|
+
include('spaces'),
|
1859
|
+
(r'', Text, ('#pop', 'parenthesis-close', 'expr')),
|
1860
|
+
],
|
1861
|
+
|
1862
|
+
'parenthesis-open': [
|
1863
|
+
include('spaces'),
|
1864
|
+
(r'\(', Punctuation, '#pop'),
|
1865
|
+
],
|
1866
|
+
|
1867
|
+
'parenthesis-close': [
|
1868
|
+
include('spaces'),
|
1869
|
+
(r'\)', Punctuation, '#pop'),
|
1870
|
+
],
|
1871
|
+
|
1872
|
+
'var': [
|
1873
|
+
include('spaces'),
|
1874
|
+
(ident_no_keyword, Text, ('#pop', 'var-sep', 'assign', 'flag')),
|
1875
|
+
],
|
1876
|
+
|
1877
|
+
# optional more var decl.
|
1878
|
+
'var-sep': [
|
1879
|
+
include('spaces'),
|
1880
|
+
(r',', Punctuation, ('#pop', 'var')),
|
1881
|
+
(r'', Text, '#pop'),
|
1882
|
+
],
|
1883
|
+
|
1884
|
+
# optional assignment
|
1885
|
+
'assign': [
|
1886
|
+
include('spaces'),
|
1887
|
+
(r'=', Operator, ('#pop', 'expr')),
|
1888
|
+
(r'', Text, '#pop'),
|
1889
|
+
],
|
1890
|
+
|
1891
|
+
# optional type flag
|
1892
|
+
'flag': [
|
1893
|
+
include('spaces'),
|
1894
|
+
(r':', Punctuation, ('#pop', 'type')),
|
1895
|
+
(r'', Text, '#pop'),
|
1896
|
+
],
|
1897
|
+
|
1898
|
+
# colon as part of a ternary operator (?:)
|
1899
|
+
'ternary': [
|
1900
|
+
include('spaces'),
|
1901
|
+
(r':', Operator, '#pop'),
|
1902
|
+
],
|
1903
|
+
|
1904
|
+
# function call
|
1905
|
+
'call': [
|
1906
|
+
include('spaces'),
|
1907
|
+
(r'\)', Punctuation, '#pop'),
|
1908
|
+
(r'', Text, ('#pop', 'call-sep', 'expr')),
|
1909
|
+
],
|
1910
|
+
|
1911
|
+
# after a call param
|
1912
|
+
'call-sep': [
|
1913
|
+
include('spaces'),
|
1914
|
+
(r'\)', Punctuation, '#pop'),
|
1915
|
+
(r',', Punctuation, ('#pop', 'call')),
|
1916
|
+
],
|
1917
|
+
|
1918
|
+
# bracket can be block or object
|
1919
|
+
'bracket': [
|
1920
|
+
include('spaces'),
|
1921
|
+
(r'(?!(?:\$\s*[a-z]\b|\$(?!'+ident+')))' + ident_no_keyword, Name,
|
1922
|
+
('#pop', 'bracket-check')),
|
1923
|
+
(r"'", String.Single, ('#pop', 'bracket-check', 'string-single')),
|
1924
|
+
(r'"', String.Double, ('#pop', 'bracket-check', 'string-double')),
|
1925
|
+
(r'', Text, ('#pop', 'block')),
|
1926
|
+
],
|
1927
|
+
|
1928
|
+
'bracket-check': [
|
1929
|
+
include('spaces'),
|
1930
|
+
(r':', Punctuation, ('#pop', 'object-sep', 'expr')), #is object
|
1931
|
+
(r'', Text, ('#pop', 'block', 'optional-semicolon', 'expr-chain')), #is block
|
1932
|
+
],
|
1933
|
+
|
1934
|
+
# code block
|
1935
|
+
'block': [
|
1936
|
+
include('spaces'),
|
1937
|
+
(r'\}', Punctuation, '#pop'),
|
1938
|
+
(r'', Text, 'expr-statement'),
|
1939
|
+
],
|
1940
|
+
|
1941
|
+
# object in key-value pairs
|
1942
|
+
'object': [
|
1943
|
+
include('spaces'),
|
1944
|
+
(r'\}', Punctuation, '#pop'),
|
1945
|
+
(r'', Text, ('#pop', 'object-sep', 'expr', 'colon', 'ident-or-string'))
|
1946
|
+
],
|
1947
|
+
|
1948
|
+
# a key of an object
|
1949
|
+
'ident-or-string': [
|
1950
|
+
include('spaces'),
|
1951
|
+
(ident_no_keyword, Name, '#pop'),
|
1952
|
+
(r"'", String.Single, ('#pop', 'string-single')),
|
1953
|
+
(r'"', String.Double, ('#pop', 'string-double')),
|
1954
|
+
],
|
1955
|
+
|
1956
|
+
# after a key-value pair in object
|
1957
|
+
'object-sep': [
|
1958
|
+
include('spaces'),
|
1959
|
+
(r'\}', Punctuation, '#pop'),
|
1960
|
+
(r',', Punctuation, ('#pop', 'object')),
|
1961
|
+
],
|
1962
|
+
|
1963
|
+
|
1964
|
+
|
1965
|
+
}
|
1966
|
+
|
1967
|
+
def analyse_text(text):
|
1968
|
+
if re.match(r'\w+\s*:\s*\w', text): return 0.3
|
1969
|
+
|
1970
|
+
|
1971
|
+
def _indentation(lexer, match, ctx):
|
1972
|
+
indentation = match.group(0)
|
1973
|
+
yield match.start(), Text, indentation
|
1974
|
+
ctx.last_indentation = indentation
|
1975
|
+
ctx.pos = match.end()
|
1976
|
+
|
1977
|
+
if hasattr(ctx, 'block_state') and ctx.block_state and \
|
1978
|
+
indentation.startswith(ctx.block_indentation) and \
|
1979
|
+
indentation != ctx.block_indentation:
|
1980
|
+
ctx.stack.append(ctx.block_state)
|
1981
|
+
else:
|
1982
|
+
ctx.block_state = None
|
1983
|
+
ctx.block_indentation = None
|
1984
|
+
ctx.stack.append('content')
|
1985
|
+
|
1986
|
+
def _starts_block(token, state):
|
1987
|
+
def callback(lexer, match, ctx):
|
1988
|
+
yield match.start(), token, match.group(0)
|
1989
|
+
|
1990
|
+
if hasattr(ctx, 'last_indentation'):
|
1991
|
+
ctx.block_indentation = ctx.last_indentation
|
1992
|
+
else:
|
1993
|
+
ctx.block_indentation = ''
|
1994
|
+
|
1995
|
+
ctx.block_state = state
|
1996
|
+
ctx.pos = match.end()
|
1997
|
+
|
1998
|
+
return callback
|
1999
|
+
|
2000
|
+
|
2001
|
+
class HamlLexer(ExtendedRegexLexer):
|
2002
|
+
"""
|
2003
|
+
For Haml markup.
|
2004
|
+
|
2005
|
+
*New in Pygments 1.3.*
|
2006
|
+
"""
|
2007
|
+
|
2008
|
+
name = 'Haml'
|
2009
|
+
aliases = ['haml', 'HAML']
|
2010
|
+
filenames = ['*.haml']
|
2011
|
+
mimetypes = ['text/x-haml']
|
2012
|
+
|
2013
|
+
flags = re.IGNORECASE
|
2014
|
+
# Haml can include " |\n" anywhere,
|
2015
|
+
# which is ignored and used to wrap long lines.
|
2016
|
+
# To accomodate this, use this custom faux dot instead.
|
2017
|
+
_dot = r'(?: \|\n(?=.* \|)|.)'
|
2018
|
+
|
2019
|
+
# In certain places, a comma at the end of the line
|
2020
|
+
# allows line wrapping as well.
|
2021
|
+
_comma_dot = r'(?:,\s*\n|' + _dot + ')'
|
2022
|
+
tokens = {
|
2023
|
+
'root': [
|
2024
|
+
(r'[ \t]*\n', Text),
|
2025
|
+
(r'[ \t]*', _indentation),
|
2026
|
+
],
|
2027
|
+
|
2028
|
+
'css': [
|
2029
|
+
(r'\.[a-z0-9_:-]+', Name.Class, 'tag'),
|
2030
|
+
(r'\#[a-z0-9_:-]+', Name.Function, 'tag'),
|
2031
|
+
],
|
2032
|
+
|
2033
|
+
'eval-or-plain': [
|
2034
|
+
(r'[&!]?==', Punctuation, 'plain'),
|
2035
|
+
(r'([&!]?[=~])(' + _comma_dot + r'*\n)',
|
2036
|
+
bygroups(Punctuation, using(RubyLexer)),
|
2037
|
+
'root'),
|
2038
|
+
(r'', Text, 'plain'),
|
2039
|
+
],
|
2040
|
+
|
2041
|
+
'content': [
|
2042
|
+
include('css'),
|
2043
|
+
(r'%[a-z0-9_:-]+', Name.Tag, 'tag'),
|
2044
|
+
(r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'),
|
2045
|
+
(r'(/)(\[' + _dot + '*?\])(' + _dot + r'*\n)',
|
2046
|
+
bygroups(Comment, Comment.Special, Comment),
|
2047
|
+
'#pop'),
|
2048
|
+
(r'/' + _dot + r'*\n', _starts_block(Comment, 'html-comment-block'),
|
2049
|
+
'#pop'),
|
2050
|
+
(r'-#' + _dot + r'*\n', _starts_block(Comment.Preproc,
|
2051
|
+
'haml-comment-block'), '#pop'),
|
2052
|
+
(r'(-)(' + _comma_dot + r'*\n)',
|
2053
|
+
bygroups(Punctuation, using(RubyLexer)),
|
2054
|
+
'#pop'),
|
2055
|
+
(r':' + _dot + r'*\n', _starts_block(Name.Decorator, 'filter-block'),
|
2056
|
+
'#pop'),
|
2057
|
+
include('eval-or-plain'),
|
2058
|
+
],
|
2059
|
+
|
2060
|
+
'tag': [
|
2061
|
+
include('css'),
|
2062
|
+
(r'\{(,\n|' + _dot + ')*?\}', using(RubyLexer)),
|
2063
|
+
(r'\[' + _dot + '*?\]', using(RubyLexer)),
|
2064
|
+
(r'\(', Text, 'html-attributes'),
|
2065
|
+
(r'/[ \t]*\n', Punctuation, '#pop:2'),
|
2066
|
+
(r'[<>]{1,2}(?=[ \t=])', Punctuation),
|
2067
|
+
include('eval-or-plain'),
|
2068
|
+
],
|
2069
|
+
|
2070
|
+
'plain': [
|
2071
|
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text),
|
2072
|
+
(r'(#\{)(' + _dot + '*?)(\})',
|
2073
|
+
bygroups(String.Interpol, using(RubyLexer), String.Interpol)),
|
2074
|
+
(r'\n', Text, 'root'),
|
2075
|
+
],
|
2076
|
+
|
2077
|
+
'html-attributes': [
|
2078
|
+
(r'\s+', Text),
|
2079
|
+
(r'[a-z0-9_:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
|
2080
|
+
(r'[a-z0-9_:-]+', Name.Attribute),
|
2081
|
+
(r'\)', Text, '#pop'),
|
2082
|
+
],
|
2083
|
+
|
2084
|
+
'html-attribute-value': [
|
2085
|
+
(r'[ \t]+', Text),
|
2086
|
+
(r'[a-z0-9_]+', Name.Variable, '#pop'),
|
2087
|
+
(r'@[a-z0-9_]+', Name.Variable.Instance, '#pop'),
|
2088
|
+
(r'\$[a-z0-9_]+', Name.Variable.Global, '#pop'),
|
2089
|
+
(r"'(\\\\|\\'|[^'\n])*'", String, '#pop'),
|
2090
|
+
(r'"(\\\\|\\"|[^"\n])*"', String, '#pop'),
|
2091
|
+
],
|
2092
|
+
|
2093
|
+
'html-comment-block': [
|
2094
|
+
(_dot + '+', Comment),
|
2095
|
+
(r'\n', Text, 'root'),
|
2096
|
+
],
|
2097
|
+
|
2098
|
+
'haml-comment-block': [
|
2099
|
+
(_dot + '+', Comment.Preproc),
|
2100
|
+
(r'\n', Text, 'root'),
|
2101
|
+
],
|
2102
|
+
|
2103
|
+
'filter-block': [
|
2104
|
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Name.Decorator),
|
2105
|
+
(r'(#\{)(' + _dot + '*?)(\})',
|
2106
|
+
bygroups(String.Interpol, using(RubyLexer), String.Interpol)),
|
2107
|
+
(r'\n', Text, 'root'),
|
2108
|
+
],
|
2109
|
+
}
|
2110
|
+
|
2111
|
+
|
2112
|
+
common_sass_tokens = {
|
2113
|
+
'value': [
|
2114
|
+
(r'[ \t]+', Text),
|
2115
|
+
(r'[!$][\w-]+', Name.Variable),
|
2116
|
+
(r'url\(', String.Other, 'string-url'),
|
2117
|
+
(r'[a-z_-][\w-]*(?=\()', Name.Function),
|
2118
|
+
(r'(azimuth|background-attachment|background-color|'
|
2119
|
+
r'background-image|background-position|background-repeat|'
|
2120
|
+
r'background|border-bottom-color|border-bottom-style|'
|
2121
|
+
r'border-bottom-width|border-left-color|border-left-style|'
|
2122
|
+
r'border-left-width|border-right|border-right-color|'
|
2123
|
+
r'border-right-style|border-right-width|border-top-color|'
|
2124
|
+
r'border-top-style|border-top-width|border-bottom|'
|
2125
|
+
r'border-collapse|border-left|border-width|border-color|'
|
2126
|
+
r'border-spacing|border-style|border-top|border|caption-side|'
|
2127
|
+
r'clear|clip|color|content|counter-increment|counter-reset|'
|
2128
|
+
r'cue-after|cue-before|cue|cursor|direction|display|'
|
2129
|
+
r'elevation|empty-cells|float|font-family|font-size|'
|
2130
|
+
r'font-size-adjust|font-stretch|font-style|font-variant|'
|
2131
|
+
r'font-weight|font|height|letter-spacing|line-height|'
|
2132
|
+
r'list-style-type|list-style-image|list-style-position|'
|
2133
|
+
r'list-style|margin-bottom|margin-left|margin-right|'
|
2134
|
+
r'margin-top|margin|marker-offset|marks|max-height|max-width|'
|
2135
|
+
r'min-height|min-width|opacity|orphans|outline|outline-color|'
|
2136
|
+
r'outline-style|outline-width|overflow|padding-bottom|'
|
2137
|
+
r'padding-left|padding-right|padding-top|padding|page|'
|
2138
|
+
r'page-break-after|page-break-before|page-break-inside|'
|
2139
|
+
r'pause-after|pause-before|pause|pitch|pitch-range|'
|
2140
|
+
r'play-during|position|quotes|richness|right|size|'
|
2141
|
+
r'speak-header|speak-numeral|speak-punctuation|speak|'
|
2142
|
+
r'speech-rate|stress|table-layout|text-align|text-decoration|'
|
2143
|
+
r'text-indent|text-shadow|text-transform|top|unicode-bidi|'
|
2144
|
+
r'vertical-align|visibility|voice-family|volume|white-space|'
|
2145
|
+
r'widows|width|word-spacing|z-index|bottom|left|'
|
2146
|
+
r'above|absolute|always|armenian|aural|auto|avoid|baseline|'
|
2147
|
+
r'behind|below|bidi-override|blink|block|bold|bolder|both|'
|
2148
|
+
r'capitalize|center-left|center-right|center|circle|'
|
2149
|
+
r'cjk-ideographic|close-quote|collapse|condensed|continuous|'
|
2150
|
+
r'crop|crosshair|cross|cursive|dashed|decimal-leading-zero|'
|
2151
|
+
r'decimal|default|digits|disc|dotted|double|e-resize|embed|'
|
2152
|
+
r'extra-condensed|extra-expanded|expanded|fantasy|far-left|'
|
2153
|
+
r'far-right|faster|fast|fixed|georgian|groove|hebrew|help|'
|
2154
|
+
r'hidden|hide|higher|high|hiragana-iroha|hiragana|icon|'
|
2155
|
+
r'inherit|inline-table|inline|inset|inside|invert|italic|'
|
2156
|
+
r'justify|katakana-iroha|katakana|landscape|larger|large|'
|
2157
|
+
r'left-side|leftwards|level|lighter|line-through|list-item|'
|
2158
|
+
r'loud|lower-alpha|lower-greek|lower-roman|lowercase|ltr|'
|
2159
|
+
r'lower|low|medium|message-box|middle|mix|monospace|'
|
2160
|
+
r'n-resize|narrower|ne-resize|no-close-quote|no-open-quote|'
|
2161
|
+
r'no-repeat|none|normal|nowrap|nw-resize|oblique|once|'
|
2162
|
+
r'open-quote|outset|outside|overline|pointer|portrait|px|'
|
2163
|
+
r'relative|repeat-x|repeat-y|repeat|rgb|ridge|right-side|'
|
2164
|
+
r'rightwards|s-resize|sans-serif|scroll|se-resize|'
|
2165
|
+
r'semi-condensed|semi-expanded|separate|serif|show|silent|'
|
2166
|
+
r'slow|slower|small-caps|small-caption|smaller|soft|solid|'
|
2167
|
+
r'spell-out|square|static|status-bar|super|sw-resize|'
|
2168
|
+
r'table-caption|table-cell|table-column|table-column-group|'
|
2169
|
+
r'table-footer-group|table-header-group|table-row|'
|
2170
|
+
r'table-row-group|text|text-bottom|text-top|thick|thin|'
|
2171
|
+
r'transparent|ultra-condensed|ultra-expanded|underline|'
|
2172
|
+
r'upper-alpha|upper-latin|upper-roman|uppercase|url|'
|
2173
|
+
r'visible|w-resize|wait|wider|x-fast|x-high|x-large|x-loud|'
|
2174
|
+
r'x-low|x-small|x-soft|xx-large|xx-small|yes)\b', Name.Constant),
|
2175
|
+
(r'(indigo|gold|firebrick|indianred|darkolivegreen|'
|
2176
|
+
r'darkseagreen|mediumvioletred|mediumorchid|chartreuse|'
|
2177
|
+
r'mediumslateblue|springgreen|crimson|lightsalmon|brown|'
|
2178
|
+
r'turquoise|olivedrab|cyan|skyblue|darkturquoise|'
|
2179
|
+
r'goldenrod|darkgreen|darkviolet|darkgray|lightpink|'
|
2180
|
+
r'darkmagenta|lightgoldenrodyellow|lavender|yellowgreen|thistle|'
|
2181
|
+
r'violet|orchid|ghostwhite|honeydew|cornflowerblue|'
|
2182
|
+
r'darkblue|darkkhaki|mediumpurple|cornsilk|bisque|slategray|'
|
2183
|
+
r'darkcyan|khaki|wheat|deepskyblue|darkred|steelblue|aliceblue|'
|
2184
|
+
r'gainsboro|mediumturquoise|floralwhite|coral|lightgrey|'
|
2185
|
+
r'lightcyan|darksalmon|beige|azure|lightsteelblue|oldlace|'
|
2186
|
+
r'greenyellow|royalblue|lightseagreen|mistyrose|sienna|'
|
2187
|
+
r'lightcoral|orangered|navajowhite|palegreen|burlywood|'
|
2188
|
+
r'seashell|mediumspringgreen|papayawhip|blanchedalmond|'
|
2189
|
+
r'peru|aquamarine|darkslategray|ivory|dodgerblue|'
|
2190
|
+
r'lemonchiffon|chocolate|orange|forestgreen|slateblue|'
|
2191
|
+
r'mintcream|antiquewhite|darkorange|cadetblue|moccasin|'
|
2192
|
+
r'limegreen|saddlebrown|darkslateblue|lightskyblue|deeppink|'
|
2193
|
+
r'plum|darkgoldenrod|sandybrown|magenta|tan|'
|
2194
|
+
r'rosybrown|pink|lightblue|palevioletred|mediumseagreen|'
|
2195
|
+
r'dimgray|powderblue|seagreen|snow|mediumblue|midnightblue|'
|
2196
|
+
r'paleturquoise|palegoldenrod|whitesmoke|darkorchid|salmon|'
|
2197
|
+
r'lightslategray|lawngreen|lightgreen|tomato|hotpink|'
|
2198
|
+
r'lightyellow|lavenderblush|linen|mediumaquamarine|'
|
2199
|
+
r'blueviolet|peachpuff)\b', Name.Entity),
|
2200
|
+
(r'(black|silver|gray|white|maroon|red|purple|fuchsia|green|'
|
2201
|
+
r'lime|olive|yellow|navy|blue|teal|aqua)\b', Name.Builtin),
|
2202
|
+
(r'\!(important|default)', Name.Exception),
|
2203
|
+
(r'(true|false)', Name.Pseudo),
|
2204
|
+
(r'(and|or|not)', Operator.Word),
|
2205
|
+
(r'/\*', Comment.Multiline, 'inline-comment'),
|
2206
|
+
(r'//[^\n]*', Comment.Single),
|
2207
|
+
(r'\#[a-z0-9]{1,6}', Number.Hex),
|
2208
|
+
(r'(-?\d+)(\%|[a-z]+)?', bygroups(Number.Integer, Keyword.Type)),
|
2209
|
+
(r'(-?\d*\.\d+)(\%|[a-z]+)?', bygroups(Number.Float, Keyword.Type)),
|
2210
|
+
(r'#{', String.Interpol, 'interpolation'),
|
2211
|
+
(r'[~\^\*!&%<>\|+=@:,./?-]+', Operator),
|
2212
|
+
(r'[\[\]()]+', Punctuation),
|
2213
|
+
(r'"', String.Double, 'string-double'),
|
2214
|
+
(r"'", String.Single, 'string-single'),
|
2215
|
+
(r'[a-z_-][\w-]*', Name),
|
2216
|
+
],
|
2217
|
+
|
2218
|
+
'interpolation': [
|
2219
|
+
(r'\}', String.Interpol, '#pop'),
|
2220
|
+
include('value'),
|
2221
|
+
],
|
2222
|
+
|
2223
|
+
'selector': [
|
2224
|
+
(r'[ \t]+', Text),
|
2225
|
+
(r'\:', Name.Decorator, 'pseudo-class'),
|
2226
|
+
(r'\.', Name.Class, 'class'),
|
2227
|
+
(r'\#', Name.Namespace, 'id'),
|
2228
|
+
(r'[a-zA-Z0-9_-]+', Name.Tag),
|
2229
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
2230
|
+
(r'&', Keyword),
|
2231
|
+
(r'[~\^\*!&\[\]\(\)<>\|+=@:;,./?-]', Operator),
|
2232
|
+
(r'"', String.Double, 'string-double'),
|
2233
|
+
(r"'", String.Single, 'string-single'),
|
2234
|
+
],
|
2235
|
+
|
2236
|
+
'string-double': [
|
2237
|
+
(r'(\\.|#(?=[^\n{])|[^\n"#])+', String.Double),
|
2238
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
2239
|
+
(r'"', String.Double, '#pop'),
|
2240
|
+
],
|
2241
|
+
|
2242
|
+
'string-single': [
|
2243
|
+
(r"(\\.|#(?=[^\n{])|[^\n'#])+", String.Double),
|
2244
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
2245
|
+
(r"'", String.Double, '#pop'),
|
2246
|
+
],
|
2247
|
+
|
2248
|
+
'string-url': [
|
2249
|
+
(r'(\\#|#(?=[^\n{])|[^\n#)])+', String.Other),
|
2250
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
2251
|
+
(r'\)', String.Other, '#pop'),
|
2252
|
+
],
|
2253
|
+
|
2254
|
+
'pseudo-class': [
|
2255
|
+
(r'[\w-]+', Name.Decorator),
|
2256
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
2257
|
+
(r'', Text, '#pop'),
|
2258
|
+
],
|
2259
|
+
|
2260
|
+
'class': [
|
2261
|
+
(r'[\w-]+', Name.Class),
|
2262
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
2263
|
+
(r'', Text, '#pop'),
|
2264
|
+
],
|
2265
|
+
|
2266
|
+
'id': [
|
2267
|
+
(r'[\w-]+', Name.Namespace),
|
2268
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
2269
|
+
(r'', Text, '#pop'),
|
2270
|
+
],
|
2271
|
+
|
2272
|
+
'for': [
|
2273
|
+
(r'(from|to|through)', Operator.Word),
|
2274
|
+
include('value'),
|
2275
|
+
],
|
2276
|
+
}
|
2277
|
+
|
2278
|
+
class SassLexer(ExtendedRegexLexer):
|
2279
|
+
"""
|
2280
|
+
For Sass stylesheets.
|
2281
|
+
|
2282
|
+
*New in Pygments 1.3.*
|
2283
|
+
"""
|
2284
|
+
|
2285
|
+
name = 'Sass'
|
2286
|
+
aliases = ['sass', 'SASS']
|
2287
|
+
filenames = ['*.sass']
|
2288
|
+
mimetypes = ['text/x-sass']
|
2289
|
+
|
2290
|
+
flags = re.IGNORECASE
|
2291
|
+
tokens = {
|
2292
|
+
'root': [
|
2293
|
+
(r'[ \t]*\n', Text),
|
2294
|
+
(r'[ \t]*', _indentation),
|
2295
|
+
],
|
2296
|
+
|
2297
|
+
'content': [
|
2298
|
+
(r'//[^\n]*', _starts_block(Comment.Single, 'single-comment'),
|
2299
|
+
'root'),
|
2300
|
+
(r'/\*[^\n]*', _starts_block(Comment.Multiline, 'multi-comment'),
|
2301
|
+
'root'),
|
2302
|
+
(r'@import', Keyword, 'import'),
|
2303
|
+
(r'@for', Keyword, 'for'),
|
2304
|
+
(r'@(debug|warn|if|while)', Keyword, 'value'),
|
2305
|
+
(r'(@mixin)( [\w-]+)', bygroups(Keyword, Name.Function), 'value'),
|
2306
|
+
(r'(@include)( [\w-]+)', bygroups(Keyword, Name.Decorator), 'value'),
|
2307
|
+
(r'@extend', Keyword, 'selector'),
|
2308
|
+
(r'@[a-z0-9_-]+', Keyword, 'selector'),
|
2309
|
+
(r'=[\w-]+', Name.Function, 'value'),
|
2310
|
+
(r'\+[\w-]+', Name.Decorator, 'value'),
|
2311
|
+
(r'([!$][\w-]\w*)([ \t]*(?:(?:\|\|)?=|:))',
|
2312
|
+
bygroups(Name.Variable, Operator), 'value'),
|
2313
|
+
(r':', Name.Attribute, 'old-style-attr'),
|
2314
|
+
(r'(?=.+?[=:]([^a-z]|$))', Name.Attribute, 'new-style-attr'),
|
2315
|
+
(r'', Text, 'selector'),
|
2316
|
+
],
|
2317
|
+
|
2318
|
+
'single-comment': [
|
2319
|
+
(r'.+', Comment.Single),
|
2320
|
+
(r'\n', Text, 'root'),
|
2321
|
+
],
|
2322
|
+
|
2323
|
+
'multi-comment': [
|
2324
|
+
(r'.+', Comment.Multiline),
|
2325
|
+
(r'\n', Text, 'root'),
|
2326
|
+
],
|
2327
|
+
|
2328
|
+
'import': [
|
2329
|
+
(r'[ \t]+', Text),
|
2330
|
+
(r'\S+', String),
|
2331
|
+
(r'\n', Text, 'root'),
|
2332
|
+
],
|
2333
|
+
|
2334
|
+
'old-style-attr': [
|
2335
|
+
(r'[^\s:="\[]+', Name.Attribute),
|
2336
|
+
(r'#{', String.Interpol, 'interpolation'),
|
2337
|
+
(r'[ \t]*=', Operator, 'value'),
|
2338
|
+
(r'', Text, 'value'),
|
2339
|
+
],
|
2340
|
+
|
2341
|
+
'new-style-attr': [
|
2342
|
+
(r'[^\s:="\[]+', Name.Attribute),
|
2343
|
+
(r'#{', String.Interpol, 'interpolation'),
|
2344
|
+
(r'[ \t]*[=:]', Operator, 'value'),
|
2345
|
+
],
|
2346
|
+
|
2347
|
+
'inline-comment': [
|
2348
|
+
(r"(\\#|#(?=[^\n{])|\*(?=[^\n/])|[^\n#*])+", Comment.Multiline),
|
2349
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
2350
|
+
(r"\*/", Comment, '#pop'),
|
2351
|
+
],
|
2352
|
+
}
|
2353
|
+
for group, common in common_sass_tokens.iteritems():
|
2354
|
+
tokens[group] = copy.copy(common)
|
2355
|
+
tokens['value'].append((r'\n', Text, 'root'))
|
2356
|
+
tokens['selector'].append((r'\n', Text, 'root'))
|
2357
|
+
|
2358
|
+
|
2359
|
+
class ScssLexer(RegexLexer):
|
2360
|
+
"""
|
2361
|
+
For SCSS stylesheets.
|
2362
|
+
"""
|
2363
|
+
|
2364
|
+
name = 'SCSS'
|
2365
|
+
aliases = ['scss']
|
2366
|
+
filenames = ['*.scss']
|
2367
|
+
mimetypes = ['text/x-scss']
|
2368
|
+
|
2369
|
+
flags = re.IGNORECASE | re.DOTALL
|
2370
|
+
tokens = {
|
2371
|
+
'root': [
|
2372
|
+
(r'\s+', Text),
|
2373
|
+
(r'//.*?\n', Comment.Single),
|
2374
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
2375
|
+
(r'@import', Keyword, 'value'),
|
2376
|
+
(r'@for', Keyword, 'for'),
|
2377
|
+
(r'@(debug|warn|if|while)', Keyword, 'value'),
|
2378
|
+
(r'(@mixin)( [\w-]+)', bygroups(Keyword, Name.Function), 'value'),
|
2379
|
+
(r'(@include)( [\w-]+)', bygroups(Keyword, Name.Decorator), 'value'),
|
2380
|
+
(r'@extend', Keyword, 'selector'),
|
2381
|
+
(r'@[a-z0-9_-]+', Keyword, 'selector'),
|
2382
|
+
(r'(\$[\w-]*\w)([ \t]*:)', bygroups(Name.Variable, Operator), 'value'),
|
2383
|
+
(r'(?=[^;{}][;}])', Name.Attribute, 'attr'),
|
2384
|
+
(r'(?=[^;{}:]+:[^a-z])', Name.Attribute, 'attr'),
|
2385
|
+
(r'', Text, 'selector'),
|
2386
|
+
],
|
2387
|
+
|
2388
|
+
'attr': [
|
2389
|
+
(r'[^\s:="\[]+', Name.Attribute),
|
2390
|
+
(r'#{', String.Interpol, 'interpolation'),
|
2391
|
+
(r'[ \t]*:', Operator, 'value'),
|
2392
|
+
],
|
2393
|
+
|
2394
|
+
'inline-comment': [
|
2395
|
+
(r"(\\#|#(?=[^{])|\*(?=[^/])|[^#*])+", Comment.Multiline),
|
2396
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
2397
|
+
(r"\*/", Comment, '#pop'),
|
2398
|
+
],
|
2399
|
+
}
|
2400
|
+
for group, common in common_sass_tokens.iteritems():
|
2401
|
+
tokens[group] = copy.copy(common)
|
2402
|
+
tokens['value'].extend([(r'\n', Text), (r'[;{}]', Punctuation, 'root')])
|
2403
|
+
tokens['selector'].extend([(r'\n', Text), (r'[;{}]', Punctuation, 'root')])
|
2404
|
+
|
2405
|
+
|
2406
|
+
class CoffeeScriptLexer(RegexLexer):
|
2407
|
+
"""
|
2408
|
+
For `CoffeeScript`_ source code.
|
2409
|
+
|
2410
|
+
.. _CoffeeScript: http://coffeescript.org
|
2411
|
+
|
2412
|
+
*New in Pygments 1.3.*
|
2413
|
+
"""
|
2414
|
+
|
2415
|
+
name = 'CoffeeScript'
|
2416
|
+
aliases = ['coffee-script', 'coffeescript', 'coffee']
|
2417
|
+
filenames = ['*.coffee']
|
2418
|
+
mimetypes = ['text/coffeescript']
|
2419
|
+
|
2420
|
+
flags = re.DOTALL
|
2421
|
+
tokens = {
|
2422
|
+
'commentsandwhitespace': [
|
2423
|
+
(r'\s+', Text),
|
2424
|
+
(r'###[^#].*?###', Comment.Multiline),
|
2425
|
+
(r'#(?!##[^#]).*?\n', Comment.Single),
|
2426
|
+
],
|
2427
|
+
'multilineregex': [
|
2428
|
+
(r'[^/#]+', String.Regex),
|
2429
|
+
(r'///([gim]+\b|\B)', String.Regex, '#pop'),
|
2430
|
+
(r'#{', String.Interpol, 'interpoling_string'),
|
2431
|
+
(r'[/#]', String.Regex),
|
2432
|
+
],
|
2433
|
+
'slashstartsregex': [
|
2434
|
+
include('commentsandwhitespace'),
|
2435
|
+
(r'///', String.Regex, ('#pop', 'multilineregex')),
|
2436
|
+
(r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
2437
|
+
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
2438
|
+
(r'', Text, '#pop'),
|
2439
|
+
],
|
2440
|
+
'root': [
|
2441
|
+
# this next expr leads to infinite loops root -> slashstartsregex
|
2442
|
+
#(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
|
2443
|
+
include('commentsandwhitespace'),
|
2444
|
+
(r'\+\+|~|&&|\band\b|\bor\b|\bis\b|\bisnt\b|\bnot\b|\?|:|'
|
2445
|
+
r'\|\||\\(?=\n)|(<<|>>>?|==?|!=?|'
|
2446
|
+
r'=(?!>)|-(?!>)|[<>+*`%&\|\^/])=?',
|
2447
|
+
Operator, 'slashstartsregex'),
|
2448
|
+
(r'(?:\([^()]+\))?\s*[=-]>', Name.Function),
|
2449
|
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
2450
|
+
(r'[})\].]', Punctuation),
|
2451
|
+
(r'(?<![\.\$])(for|own|in|of|while|until|'
|
2452
|
+
r'loop|break|return|continue|'
|
2453
|
+
r'switch|when|then|if|unless|else|'
|
2454
|
+
r'throw|try|catch|finally|new|delete|typeof|instanceof|super|'
|
2455
|
+
r'extends|this|class|by)\b', Keyword, 'slashstartsregex'),
|
2456
|
+
(r'(?<![\.\$])(true|false|yes|no|on|off|null|'
|
2457
|
+
r'NaN|Infinity|undefined)\b',
|
2458
|
+
Keyword.Constant),
|
2459
|
+
(r'(Array|Boolean|Date|Error|Function|Math|netscape|'
|
2460
|
+
r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
|
2461
|
+
r'decodeURIComponent|encodeURI|encodeURIComponent|'
|
2462
|
+
r'eval|isFinite|isNaN|parseFloat|parseInt|document|window)\b',
|
2463
|
+
Name.Builtin),
|
2464
|
+
(r'[$a-zA-Z_][a-zA-Z0-9_\.:\$]*\s*[:=]\s', Name.Variable,
|
2465
|
+
'slashstartsregex'),
|
2466
|
+
(r'@[$a-zA-Z_][a-zA-Z0-9_\.:\$]*\s*[:=]\s', Name.Variable.Instance,
|
2467
|
+
'slashstartsregex'),
|
2468
|
+
(r'@', Name.Other, 'slashstartsregex'),
|
2469
|
+
(r'@?[$a-zA-Z_][a-zA-Z0-9_\$]*', Name.Other, 'slashstartsregex'),
|
2470
|
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
2471
|
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
2472
|
+
(r'[0-9]+', Number.Integer),
|
2473
|
+
('"""', String, 'tdqs'),
|
2474
|
+
("'''", String, 'tsqs'),
|
2475
|
+
('"', String, 'dqs'),
|
2476
|
+
("'", String, 'sqs'),
|
2477
|
+
],
|
2478
|
+
'strings': [
|
2479
|
+
(r'[^#\\\'"]+', String),
|
2480
|
+
# note that all coffee script strings are multi-line.
|
2481
|
+
# hashmarks, quotes and backslashes must be parsed one at a time
|
2482
|
+
],
|
2483
|
+
'interpoling_string' : [
|
2484
|
+
(r'}', String.Interpol, "#pop"),
|
2485
|
+
include('root')
|
2486
|
+
],
|
2487
|
+
'dqs': [
|
2488
|
+
(r'"', String, '#pop'),
|
2489
|
+
(r'\\.|\'', String), # double-quoted string don't need ' escapes
|
2490
|
+
(r'#{', String.Interpol, "interpoling_string"),
|
2491
|
+
include('strings')
|
2492
|
+
],
|
2493
|
+
'sqs': [
|
2494
|
+
(r"'", String, '#pop'),
|
2495
|
+
(r'#|\\.|"', String), # single quoted strings don't need " escapses
|
2496
|
+
include('strings')
|
2497
|
+
],
|
2498
|
+
'tdqs': [
|
2499
|
+
(r'"""', String, '#pop'),
|
2500
|
+
(r'\\.|\'|"', String), # no need to escape quotes in triple-string
|
2501
|
+
(r'#{', String.Interpol, "interpoling_string"),
|
2502
|
+
include('strings'),
|
2503
|
+
],
|
2504
|
+
'tsqs': [
|
2505
|
+
(r"'''", String, '#pop'),
|
2506
|
+
(r'#|\\.|\'|"', String), # no need to escape quotes in triple-strings
|
2507
|
+
include('strings')
|
2508
|
+
],
|
2509
|
+
}
|
2510
|
+
|
2511
|
+
|
2512
|
+
class LiveScriptLexer(RegexLexer):
|
2513
|
+
"""
|
2514
|
+
For `LiveScript`_ source code.
|
2515
|
+
|
2516
|
+
.. _LiveScript: http://gkz.github.com/LiveScript/
|
2517
|
+
|
2518
|
+
New in Pygments 1.6.
|
2519
|
+
"""
|
2520
|
+
|
2521
|
+
name = 'LiveScript'
|
2522
|
+
aliases = ['live-script', 'livescript']
|
2523
|
+
filenames = ['*.ls']
|
2524
|
+
mimetypes = ['text/livescript']
|
2525
|
+
|
2526
|
+
flags = re.DOTALL
|
2527
|
+
tokens = {
|
2528
|
+
'commentsandwhitespace': [
|
2529
|
+
(r'\s+', Text),
|
2530
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
2531
|
+
(r'#.*?\n', Comment.Single),
|
2532
|
+
],
|
2533
|
+
'multilineregex': [
|
2534
|
+
include('commentsandwhitespace'),
|
2535
|
+
(r'//([gim]+\b|\B)', String.Regex, '#pop'),
|
2536
|
+
(r'/', String.Regex),
|
2537
|
+
(r'[^/#]+', String.Regex)
|
2538
|
+
],
|
2539
|
+
'slashstartsregex': [
|
2540
|
+
include('commentsandwhitespace'),
|
2541
|
+
(r'//', String.Regex, ('#pop', 'multilineregex')),
|
2542
|
+
(r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
2543
|
+
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
2544
|
+
(r'', Text, '#pop'),
|
2545
|
+
],
|
2546
|
+
'root': [
|
2547
|
+
# this next expr leads to infinite loops root -> slashstartsregex
|
2548
|
+
#(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
|
2549
|
+
include('commentsandwhitespace'),
|
2550
|
+
(r'(?:\([^()]+\))?[ ]*[~-]{1,2}>|'
|
2551
|
+
r'(?:\(?[^()\n]+\)?)?[ ]*<[~-]{1,2}', Name.Function),
|
2552
|
+
(r'\+\+|&&|(?<![\.\$])\b(?:and|x?or|is|isnt|not)\b|\?|:|=|'
|
2553
|
+
r'\|\||\\(?=\n)|(<<|>>>?|==?|!=?|'
|
2554
|
+
r'~(?!\~?>)|-(?!\-?>)|<(?!\[)|(?<!\])>|'
|
2555
|
+
r'[+*`%&\|\^/])=?',
|
2556
|
+
Operator, 'slashstartsregex'),
|
2557
|
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
2558
|
+
(r'[})\].]', Punctuation),
|
2559
|
+
(r'(?<![\.\$])(for|own|in|of|while|until|loop|break|'
|
2560
|
+
r'return|continue|switch|when|then|if|unless|else|'
|
2561
|
+
r'throw|try|catch|finally|new|delete|typeof|instanceof|super|'
|
2562
|
+
r'extends|this|class|by|const|var|to|til)\b', Keyword,
|
2563
|
+
'slashstartsregex'),
|
2564
|
+
(r'(?<![\.\$])(true|false|yes|no|on|off|'
|
2565
|
+
r'null|NaN|Infinity|undefined|void)\b',
|
2566
|
+
Keyword.Constant),
|
2567
|
+
(r'(Array|Boolean|Date|Error|Function|Math|netscape|'
|
2568
|
+
r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
|
2569
|
+
r'decodeURIComponent|encodeURI|encodeURIComponent|'
|
2570
|
+
r'eval|isFinite|isNaN|parseFloat|parseInt|document|window)\b',
|
2571
|
+
Name.Builtin),
|
2572
|
+
(r'[$a-zA-Z_][a-zA-Z0-9_\.\-:\$]*\s*[:=]\s', Name.Variable,
|
2573
|
+
'slashstartsregex'),
|
2574
|
+
(r'@[$a-zA-Z_][a-zA-Z0-9_\.\-:\$]*\s*[:=]\s', Name.Variable.Instance,
|
2575
|
+
'slashstartsregex'),
|
2576
|
+
(r'@', Name.Other, 'slashstartsregex'),
|
2577
|
+
(r'@?[$a-zA-Z_][a-zA-Z0-9_\-]*', Name.Other, 'slashstartsregex'),
|
2578
|
+
(r'[0-9]+\.[0-9]+([eE][0-9]+)?[fd]?(?:[a-zA-Z_]+)?', Number.Float),
|
2579
|
+
(r'[0-9]+(~[0-9a-z]+)?(?:[a-zA-Z_]+)?', Number.Integer),
|
2580
|
+
('"""', String, 'tdqs'),
|
2581
|
+
("'''", String, 'tsqs'),
|
2582
|
+
('"', String, 'dqs'),
|
2583
|
+
("'", String, 'sqs'),
|
2584
|
+
(r'\\[\w$-]+', String),
|
2585
|
+
(r'<\[.*\]>', String),
|
2586
|
+
],
|
2587
|
+
'strings': [
|
2588
|
+
(r'[^#\\\'"]+', String),
|
2589
|
+
# note that all coffee script strings are multi-line.
|
2590
|
+
# hashmarks, quotes and backslashes must be parsed one at a time
|
2591
|
+
],
|
2592
|
+
'interpoling_string' : [
|
2593
|
+
(r'}', String.Interpol, "#pop"),
|
2594
|
+
include('root')
|
2595
|
+
],
|
2596
|
+
'dqs': [
|
2597
|
+
(r'"', String, '#pop'),
|
2598
|
+
(r'\\.|\'', String), # double-quoted string don't need ' escapes
|
2599
|
+
(r'#{', String.Interpol, "interpoling_string"),
|
2600
|
+
(r'#', String),
|
2601
|
+
include('strings')
|
2602
|
+
],
|
2603
|
+
'sqs': [
|
2604
|
+
(r"'", String, '#pop'),
|
2605
|
+
(r'#|\\.|"', String), # single quoted strings don't need " escapses
|
2606
|
+
include('strings')
|
2607
|
+
],
|
2608
|
+
'tdqs': [
|
2609
|
+
(r'"""', String, '#pop'),
|
2610
|
+
(r'\\.|\'|"', String), # no need to escape quotes in triple-string
|
2611
|
+
(r'#{', String.Interpol, "interpoling_string"),
|
2612
|
+
(r'#', String),
|
2613
|
+
include('strings'),
|
2614
|
+
],
|
2615
|
+
'tsqs': [
|
2616
|
+
(r"'''", String, '#pop'),
|
2617
|
+
(r'#|\\.|\'|"', String), # no need to escape quotes in triple-strings
|
2618
|
+
include('strings')
|
2619
|
+
],
|
2620
|
+
}
|
2621
|
+
|
2622
|
+
|
2623
|
+
class DuelLexer(RegexLexer):
|
2624
|
+
"""
|
2625
|
+
Lexer for Duel Views Engine (formerly JBST) markup with JavaScript code blocks.
|
2626
|
+
See http://duelengine.org/.
|
2627
|
+
See http://jsonml.org/jbst/.
|
2628
|
+
|
2629
|
+
*New in Pygments 1.4.*
|
2630
|
+
"""
|
2631
|
+
|
2632
|
+
name = 'Duel'
|
2633
|
+
aliases = ['duel', 'Duel Engine', 'Duel View', 'JBST', 'jbst', 'JsonML+BST']
|
2634
|
+
filenames = ['*.duel','*.jbst']
|
2635
|
+
mimetypes = ['text/x-duel','text/x-jbst']
|
2636
|
+
|
2637
|
+
flags = re.DOTALL
|
2638
|
+
|
2639
|
+
tokens = {
|
2640
|
+
'root': [
|
2641
|
+
(r'(<%[@=#!:]?)(.*?)(%>)',
|
2642
|
+
bygroups(Name.Tag, using(JavascriptLexer), Name.Tag)),
|
2643
|
+
(r'(<%\$)(.*?)(:)(.*?)(%>)',
|
2644
|
+
bygroups(Name.Tag, Name.Function, Punctuation, String, Name.Tag)),
|
2645
|
+
(r'(<%--)(.*?)(--%>)',
|
2646
|
+
bygroups(Name.Tag, Comment.Multiline, Name.Tag)),
|
2647
|
+
(r'(<script.*?>)(.*?)(</script>)',
|
2648
|
+
bygroups(using(HtmlLexer),
|
2649
|
+
using(JavascriptLexer), using(HtmlLexer))),
|
2650
|
+
(r'(.+?)(?=<)', using(HtmlLexer)),
|
2651
|
+
(r'.+', using(HtmlLexer)),
|
2652
|
+
],
|
2653
|
+
}
|
2654
|
+
|
2655
|
+
|
2656
|
+
class ScamlLexer(ExtendedRegexLexer):
|
2657
|
+
"""
|
2658
|
+
For `Scaml markup <http://scalate.fusesource.org/>`_. Scaml is Haml for Scala.
|
2659
|
+
|
2660
|
+
*New in Pygments 1.4.*
|
2661
|
+
"""
|
2662
|
+
|
2663
|
+
name = 'Scaml'
|
2664
|
+
aliases = ['scaml', 'SCAML']
|
2665
|
+
filenames = ['*.scaml']
|
2666
|
+
mimetypes = ['text/x-scaml']
|
2667
|
+
|
2668
|
+
flags = re.IGNORECASE
|
2669
|
+
# Scaml does not yet support the " |\n" notation to
|
2670
|
+
# wrap long lines. Once it does, use the custom faux
|
2671
|
+
# dot instead.
|
2672
|
+
# _dot = r'(?: \|\n(?=.* \|)|.)'
|
2673
|
+
_dot = r'.'
|
2674
|
+
|
2675
|
+
tokens = {
|
2676
|
+
'root': [
|
2677
|
+
(r'[ \t]*\n', Text),
|
2678
|
+
(r'[ \t]*', _indentation),
|
2679
|
+
],
|
2680
|
+
|
2681
|
+
'css': [
|
2682
|
+
(r'\.[a-z0-9_:-]+', Name.Class, 'tag'),
|
2683
|
+
(r'\#[a-z0-9_:-]+', Name.Function, 'tag'),
|
2684
|
+
],
|
2685
|
+
|
2686
|
+
'eval-or-plain': [
|
2687
|
+
(r'[&!]?==', Punctuation, 'plain'),
|
2688
|
+
(r'([&!]?[=~])(' + _dot + r'*\n)',
|
2689
|
+
bygroups(Punctuation, using(ScalaLexer)),
|
2690
|
+
'root'),
|
2691
|
+
(r'', Text, 'plain'),
|
2692
|
+
],
|
2693
|
+
|
2694
|
+
'content': [
|
2695
|
+
include('css'),
|
2696
|
+
(r'%[a-z0-9_:-]+', Name.Tag, 'tag'),
|
2697
|
+
(r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'),
|
2698
|
+
(r'(/)(\[' + _dot + '*?\])(' + _dot + r'*\n)',
|
2699
|
+
bygroups(Comment, Comment.Special, Comment),
|
2700
|
+
'#pop'),
|
2701
|
+
(r'/' + _dot + r'*\n', _starts_block(Comment, 'html-comment-block'),
|
2702
|
+
'#pop'),
|
2703
|
+
(r'-#' + _dot + r'*\n', _starts_block(Comment.Preproc,
|
2704
|
+
'scaml-comment-block'), '#pop'),
|
2705
|
+
(r'(-@\s*)(import)?(' + _dot + r'*\n)',
|
2706
|
+
bygroups(Punctuation, Keyword, using(ScalaLexer)),
|
2707
|
+
'#pop'),
|
2708
|
+
(r'(-)(' + _dot + r'*\n)',
|
2709
|
+
bygroups(Punctuation, using(ScalaLexer)),
|
2710
|
+
'#pop'),
|
2711
|
+
(r':' + _dot + r'*\n', _starts_block(Name.Decorator, 'filter-block'),
|
2712
|
+
'#pop'),
|
2713
|
+
include('eval-or-plain'),
|
2714
|
+
],
|
2715
|
+
|
2716
|
+
'tag': [
|
2717
|
+
include('css'),
|
2718
|
+
(r'\{(,\n|' + _dot + ')*?\}', using(ScalaLexer)),
|
2719
|
+
(r'\[' + _dot + '*?\]', using(ScalaLexer)),
|
2720
|
+
(r'\(', Text, 'html-attributes'),
|
2721
|
+
(r'/[ \t]*\n', Punctuation, '#pop:2'),
|
2722
|
+
(r'[<>]{1,2}(?=[ \t=])', Punctuation),
|
2723
|
+
include('eval-or-plain'),
|
2724
|
+
],
|
2725
|
+
|
2726
|
+
'plain': [
|
2727
|
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text),
|
2728
|
+
(r'(#\{)(' + _dot + '*?)(\})',
|
2729
|
+
bygroups(String.Interpol, using(ScalaLexer), String.Interpol)),
|
2730
|
+
(r'\n', Text, 'root'),
|
2731
|
+
],
|
2732
|
+
|
2733
|
+
'html-attributes': [
|
2734
|
+
(r'\s+', Text),
|
2735
|
+
(r'[a-z0-9_:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
|
2736
|
+
(r'[a-z0-9_:-]+', Name.Attribute),
|
2737
|
+
(r'\)', Text, '#pop'),
|
2738
|
+
],
|
2739
|
+
|
2740
|
+
'html-attribute-value': [
|
2741
|
+
(r'[ \t]+', Text),
|
2742
|
+
(r'[a-z0-9_]+', Name.Variable, '#pop'),
|
2743
|
+
(r'@[a-z0-9_]+', Name.Variable.Instance, '#pop'),
|
2744
|
+
(r'\$[a-z0-9_]+', Name.Variable.Global, '#pop'),
|
2745
|
+
(r"'(\\\\|\\'|[^'\n])*'", String, '#pop'),
|
2746
|
+
(r'"(\\\\|\\"|[^"\n])*"', String, '#pop'),
|
2747
|
+
],
|
2748
|
+
|
2749
|
+
'html-comment-block': [
|
2750
|
+
(_dot + '+', Comment),
|
2751
|
+
(r'\n', Text, 'root'),
|
2752
|
+
],
|
2753
|
+
|
2754
|
+
'scaml-comment-block': [
|
2755
|
+
(_dot + '+', Comment.Preproc),
|
2756
|
+
(r'\n', Text, 'root'),
|
2757
|
+
],
|
2758
|
+
|
2759
|
+
'filter-block': [
|
2760
|
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Name.Decorator),
|
2761
|
+
(r'(#\{)(' + _dot + '*?)(\})',
|
2762
|
+
bygroups(String.Interpol, using(ScalaLexer), String.Interpol)),
|
2763
|
+
(r'\n', Text, 'root'),
|
2764
|
+
],
|
2765
|
+
}
|
2766
|
+
|
2767
|
+
|
2768
|
+
class JadeLexer(ExtendedRegexLexer):
|
2769
|
+
"""
|
2770
|
+
For Jade markup.
|
2771
|
+
Jade is a variant of Scaml, see:
|
2772
|
+
http://scalate.fusesource.org/documentation/scaml-reference.html
|
2773
|
+
|
2774
|
+
*New in Pygments 1.4.*
|
2775
|
+
"""
|
2776
|
+
|
2777
|
+
name = 'Jade'
|
2778
|
+
aliases = ['jade', 'JADE']
|
2779
|
+
filenames = ['*.jade']
|
2780
|
+
mimetypes = ['text/x-jade']
|
2781
|
+
|
2782
|
+
flags = re.IGNORECASE
|
2783
|
+
_dot = r'.'
|
2784
|
+
|
2785
|
+
tokens = {
|
2786
|
+
'root': [
|
2787
|
+
(r'[ \t]*\n', Text),
|
2788
|
+
(r'[ \t]*', _indentation),
|
2789
|
+
],
|
2790
|
+
|
2791
|
+
'css': [
|
2792
|
+
(r'\.[a-z0-9_:-]+', Name.Class, 'tag'),
|
2793
|
+
(r'\#[a-z0-9_:-]+', Name.Function, 'tag'),
|
2794
|
+
],
|
2795
|
+
|
2796
|
+
'eval-or-plain': [
|
2797
|
+
(r'[&!]?==', Punctuation, 'plain'),
|
2798
|
+
(r'([&!]?[=~])(' + _dot + r'*\n)',
|
2799
|
+
bygroups(Punctuation, using(ScalaLexer)), 'root'),
|
2800
|
+
(r'', Text, 'plain'),
|
2801
|
+
],
|
2802
|
+
|
2803
|
+
'content': [
|
2804
|
+
include('css'),
|
2805
|
+
(r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'),
|
2806
|
+
(r'(/)(\[' + _dot + '*?\])(' + _dot + r'*\n)',
|
2807
|
+
bygroups(Comment, Comment.Special, Comment),
|
2808
|
+
'#pop'),
|
2809
|
+
(r'/' + _dot + r'*\n', _starts_block(Comment, 'html-comment-block'),
|
2810
|
+
'#pop'),
|
2811
|
+
(r'-#' + _dot + r'*\n', _starts_block(Comment.Preproc,
|
2812
|
+
'scaml-comment-block'), '#pop'),
|
2813
|
+
(r'(-@\s*)(import)?(' + _dot + r'*\n)',
|
2814
|
+
bygroups(Punctuation, Keyword, using(ScalaLexer)),
|
2815
|
+
'#pop'),
|
2816
|
+
(r'(-)(' + _dot + r'*\n)',
|
2817
|
+
bygroups(Punctuation, using(ScalaLexer)),
|
2818
|
+
'#pop'),
|
2819
|
+
(r':' + _dot + r'*\n', _starts_block(Name.Decorator, 'filter-block'),
|
2820
|
+
'#pop'),
|
2821
|
+
(r'[a-z0-9_:-]+', Name.Tag, 'tag'),
|
2822
|
+
(r'\|', Text, 'eval-or-plain'),
|
2823
|
+
],
|
2824
|
+
|
2825
|
+
'tag': [
|
2826
|
+
include('css'),
|
2827
|
+
(r'\{(,\n|' + _dot + ')*?\}', using(ScalaLexer)),
|
2828
|
+
(r'\[' + _dot + '*?\]', using(ScalaLexer)),
|
2829
|
+
(r'\(', Text, 'html-attributes'),
|
2830
|
+
(r'/[ \t]*\n', Punctuation, '#pop:2'),
|
2831
|
+
(r'[<>]{1,2}(?=[ \t=])', Punctuation),
|
2832
|
+
include('eval-or-plain'),
|
2833
|
+
],
|
2834
|
+
|
2835
|
+
'plain': [
|
2836
|
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text),
|
2837
|
+
(r'(#\{)(' + _dot + '*?)(\})',
|
2838
|
+
bygroups(String.Interpol, using(ScalaLexer), String.Interpol)),
|
2839
|
+
(r'\n', Text, 'root'),
|
2840
|
+
],
|
2841
|
+
|
2842
|
+
'html-attributes': [
|
2843
|
+
(r'\s+', Text),
|
2844
|
+
(r'[a-z0-9_:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
|
2845
|
+
(r'[a-z0-9_:-]+', Name.Attribute),
|
2846
|
+
(r'\)', Text, '#pop'),
|
2847
|
+
],
|
2848
|
+
|
2849
|
+
'html-attribute-value': [
|
2850
|
+
(r'[ \t]+', Text),
|
2851
|
+
(r'[a-z0-9_]+', Name.Variable, '#pop'),
|
2852
|
+
(r'@[a-z0-9_]+', Name.Variable.Instance, '#pop'),
|
2853
|
+
(r'\$[a-z0-9_]+', Name.Variable.Global, '#pop'),
|
2854
|
+
(r"'(\\\\|\\'|[^'\n])*'", String, '#pop'),
|
2855
|
+
(r'"(\\\\|\\"|[^"\n])*"', String, '#pop'),
|
2856
|
+
],
|
2857
|
+
|
2858
|
+
'html-comment-block': [
|
2859
|
+
(_dot + '+', Comment),
|
2860
|
+
(r'\n', Text, 'root'),
|
2861
|
+
],
|
2862
|
+
|
2863
|
+
'scaml-comment-block': [
|
2864
|
+
(_dot + '+', Comment.Preproc),
|
2865
|
+
(r'\n', Text, 'root'),
|
2866
|
+
],
|
2867
|
+
|
2868
|
+
'filter-block': [
|
2869
|
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Name.Decorator),
|
2870
|
+
(r'(#\{)(' + _dot + '*?)(\})',
|
2871
|
+
bygroups(String.Interpol, using(ScalaLexer), String.Interpol)),
|
2872
|
+
(r'\n', Text, 'root'),
|
2873
|
+
],
|
2874
|
+
}
|
2875
|
+
|
2876
|
+
|
2877
|
+
class XQueryLexer(ExtendedRegexLexer):
|
2878
|
+
"""
|
2879
|
+
An XQuery lexer, parsing a stream and outputting the tokens needed to
|
2880
|
+
highlight xquery code.
|
2881
|
+
|
2882
|
+
*New in Pygments 1.4.*
|
2883
|
+
"""
|
2884
|
+
name = 'XQuery'
|
2885
|
+
aliases = ['xquery', 'xqy', 'xq', 'xql', 'xqm']
|
2886
|
+
filenames = ['*.xqy', '*.xquery', '*.xq', '*.xql', '*.xqm']
|
2887
|
+
mimetypes = ['text/xquery', 'application/xquery']
|
2888
|
+
|
2889
|
+
xquery_parse_state = []
|
2890
|
+
|
2891
|
+
# FIX UNICODE LATER
|
2892
|
+
#ncnamestartchar = (
|
2893
|
+
# ur"[A-Z]|_|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|"
|
2894
|
+
# ur"[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|"
|
2895
|
+
# ur"[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|"
|
2896
|
+
# ur"[\u10000-\uEFFFF]"
|
2897
|
+
#)
|
2898
|
+
ncnamestartchar = r"(?:[A-Z]|_|[a-z])"
|
2899
|
+
# FIX UNICODE LATER
|
2900
|
+
#ncnamechar = ncnamestartchar + (ur"|-|\.|[0-9]|\u00B7|[\u0300-\u036F]|"
|
2901
|
+
# ur"[\u203F-\u2040]")
|
2902
|
+
ncnamechar = r"(?:" + ncnamestartchar + r"|-|\.|[0-9])"
|
2903
|
+
ncname = "(?:%s+%s*)" % (ncnamestartchar, ncnamechar)
|
2904
|
+
pitarget_namestartchar = r"(?:[A-KN-WY-Z]|_|:|[a-kn-wy-z])"
|
2905
|
+
pitarget_namechar = r"(?:" + pitarget_namestartchar + r"|-|\.|[0-9])"
|
2906
|
+
pitarget = "%s+%s*" % (pitarget_namestartchar, pitarget_namechar)
|
2907
|
+
prefixedname = "%s:%s" % (ncname, ncname)
|
2908
|
+
unprefixedname = ncname
|
2909
|
+
qname = "(?:%s|%s)" % (prefixedname, unprefixedname)
|
2910
|
+
|
2911
|
+
entityref = r'(?:&(?:lt|gt|amp|quot|apos|nbsp);)'
|
2912
|
+
charref = r'(?:&#[0-9]+;|&#x[0-9a-fA-F]+;)'
|
2913
|
+
|
2914
|
+
stringdouble = r'(?:"(?:' + entityref + r'|' + charref + r'|""|[^&"])*")'
|
2915
|
+
stringsingle = r"(?:'(?:" + entityref + r"|" + charref + r"|''|[^&'])*')"
|
2916
|
+
|
2917
|
+
# FIX UNICODE LATER
|
2918
|
+
#elementcontentchar = (ur'\t|\r|\n|[\u0020-\u0025]|[\u0028-\u003b]|'
|
2919
|
+
# ur'[\u003d-\u007a]|\u007c|[\u007e-\u007F]')
|
2920
|
+
elementcontentchar = r'[A-Za-z]|\s|\d|[!"#$%\(\)\*\+,\-\./\:;=\?\@\[\\\]^_\'`\|~]'
|
2921
|
+
#quotattrcontentchar = (ur'\t|\r|\n|[\u0020-\u0021]|[\u0023-\u0025]|'
|
2922
|
+
# ur'[\u0027-\u003b]|[\u003d-\u007a]|\u007c|[\u007e-\u007F]')
|
2923
|
+
quotattrcontentchar = r'[A-Za-z]|\s|\d|[!#$%\(\)\*\+,\-\./\:;=\?\@\[\\\]^_\'`\|~]'
|
2924
|
+
#aposattrcontentchar = (ur'\t|\r|\n|[\u0020-\u0025]|[\u0028-\u003b]|'
|
2925
|
+
# ur'[\u003d-\u007a]|\u007c|[\u007e-\u007F]')
|
2926
|
+
aposattrcontentchar = r'[A-Za-z]|\s|\d|[!"#$%\(\)\*\+,\-\./\:;=\?\@\[\\\]^_`\|~]'
|
2927
|
+
|
2928
|
+
|
2929
|
+
# CHAR elements - fix the above elementcontentchar, quotattrcontentchar,
|
2930
|
+
# aposattrcontentchar
|
2931
|
+
#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
|
2932
|
+
|
2933
|
+
flags = re.DOTALL | re.MULTILINE | re.UNICODE
|
2934
|
+
|
2935
|
+
def punctuation_root_callback(lexer, match, ctx):
|
2936
|
+
yield match.start(), Punctuation, match.group(1)
|
2937
|
+
# transition to root always - don't pop off stack
|
2938
|
+
ctx.stack = ['root']
|
2939
|
+
ctx.pos = match.end()
|
2940
|
+
|
2941
|
+
def operator_root_callback(lexer, match, ctx):
|
2942
|
+
yield match.start(), Operator, match.group(1)
|
2943
|
+
# transition to root always - don't pop off stack
|
2944
|
+
ctx.stack = ['root']
|
2945
|
+
ctx.pos = match.end()
|
2946
|
+
|
2947
|
+
def popstate_tag_callback(lexer, match, ctx):
|
2948
|
+
yield match.start(), Name.Tag, match.group(1)
|
2949
|
+
ctx.stack.append(lexer.xquery_parse_state.pop())
|
2950
|
+
ctx.pos = match.end()
|
2951
|
+
|
2952
|
+
def popstate_xmlcomment_callback(lexer, match, ctx):
|
2953
|
+
yield match.start(), String.Doc, match.group(1)
|
2954
|
+
ctx.stack.append(lexer.xquery_parse_state.pop())
|
2955
|
+
ctx.pos = match.end()
|
2956
|
+
|
2957
|
+
def popstate_kindtest_callback(lexer, match, ctx):
|
2958
|
+
yield match.start(), Punctuation, match.group(1)
|
2959
|
+
next_state = lexer.xquery_parse_state.pop()
|
2960
|
+
if next_state == 'occurrenceindicator':
|
2961
|
+
if re.match("[?*+]+", match.group(2)):
|
2962
|
+
yield match.start(), Punctuation, match.group(2)
|
2963
|
+
ctx.stack.append('operator')
|
2964
|
+
ctx.pos = match.end()
|
2965
|
+
else:
|
2966
|
+
ctx.stack.append('operator')
|
2967
|
+
ctx.pos = match.end(1)
|
2968
|
+
else:
|
2969
|
+
ctx.stack.append(next_state)
|
2970
|
+
ctx.pos = match.end(1)
|
2971
|
+
|
2972
|
+
def popstate_callback(lexer, match, ctx):
|
2973
|
+
yield match.start(), Punctuation, match.group(1)
|
2974
|
+
# if we have run out of our state stack, pop whatever is on the pygments
|
2975
|
+
# state stack
|
2976
|
+
if len(lexer.xquery_parse_state) == 0:
|
2977
|
+
ctx.stack.pop()
|
2978
|
+
elif len(ctx.stack) > 1:
|
2979
|
+
ctx.stack.append(lexer.xquery_parse_state.pop())
|
2980
|
+
else:
|
2981
|
+
# i don't know if i'll need this, but in case, default back to root
|
2982
|
+
ctx.stack = ['root']
|
2983
|
+
ctx.pos = match.end()
|
2984
|
+
|
2985
|
+
def pushstate_element_content_starttag_callback(lexer, match, ctx):
|
2986
|
+
yield match.start(), Name.Tag, match.group(1)
|
2987
|
+
lexer.xquery_parse_state.append('element_content')
|
2988
|
+
ctx.stack.append('start_tag')
|
2989
|
+
ctx.pos = match.end()
|
2990
|
+
|
2991
|
+
def pushstate_cdata_section_callback(lexer, match, ctx):
|
2992
|
+
yield match.start(), String.Doc, match.group(1)
|
2993
|
+
ctx.stack.append('cdata_section')
|
2994
|
+
lexer.xquery_parse_state.append(ctx.state.pop)
|
2995
|
+
ctx.pos = match.end()
|
2996
|
+
|
2997
|
+
def pushstate_starttag_callback(lexer, match, ctx):
|
2998
|
+
yield match.start(), Name.Tag, match.group(1)
|
2999
|
+
lexer.xquery_parse_state.append(ctx.state.pop)
|
3000
|
+
ctx.stack.append('start_tag')
|
3001
|
+
ctx.pos = match.end()
|
3002
|
+
|
3003
|
+
def pushstate_operator_order_callback(lexer, match, ctx):
|
3004
|
+
yield match.start(), Keyword, match.group(1)
|
3005
|
+
yield match.start(), Text, match.group(2)
|
3006
|
+
yield match.start(), Punctuation, match.group(3)
|
3007
|
+
ctx.stack = ['root']
|
3008
|
+
lexer.xquery_parse_state.append('operator')
|
3009
|
+
ctx.pos = match.end()
|
3010
|
+
|
3011
|
+
def pushstate_operator_root_validate(lexer, match, ctx):
|
3012
|
+
yield match.start(), Keyword, match.group(1)
|
3013
|
+
yield match.start(), Text, match.group(2)
|
3014
|
+
yield match.start(), Punctuation, match.group(3)
|
3015
|
+
ctx.stack = ['root']
|
3016
|
+
lexer.xquery_parse_state.append('operator')
|
3017
|
+
ctx.pos = match.end()
|
3018
|
+
|
3019
|
+
def pushstate_operator_root_validate_withmode(lexer, match, ctx):
|
3020
|
+
yield match.start(), Keyword, match.group(1)
|
3021
|
+
yield match.start(), Text, match.group(2)
|
3022
|
+
yield match.start(), Keyword, match.group(3)
|
3023
|
+
ctx.stack = ['root']
|
3024
|
+
lexer.xquery_parse_state.append('operator')
|
3025
|
+
ctx.pos = match.end()
|
3026
|
+
|
3027
|
+
def pushstate_operator_processing_instruction_callback(lexer, match, ctx):
|
3028
|
+
yield match.start(), String.Doc, match.group(1)
|
3029
|
+
ctx.stack.append('processing_instruction')
|
3030
|
+
lexer.xquery_parse_state.append('operator')
|
3031
|
+
ctx.pos = match.end()
|
3032
|
+
|
3033
|
+
def pushstate_element_content_processing_instruction_callback(lexer, match, ctx):
|
3034
|
+
yield match.start(), String.Doc, match.group(1)
|
3035
|
+
ctx.stack.append('processing_instruction')
|
3036
|
+
lexer.xquery_parse_state.append('element_content')
|
3037
|
+
ctx.pos = match.end()
|
3038
|
+
|
3039
|
+
def pushstate_element_content_cdata_section_callback(lexer, match, ctx):
|
3040
|
+
yield match.start(), String.Doc, match.group(1)
|
3041
|
+
ctx.stack.append('cdata_section')
|
3042
|
+
lexer.xquery_parse_state.append('element_content')
|
3043
|
+
ctx.pos = match.end()
|
3044
|
+
|
3045
|
+
def pushstate_operator_cdata_section_callback(lexer, match, ctx):
|
3046
|
+
yield match.start(), String.Doc, match.group(1)
|
3047
|
+
ctx.stack.append('cdata_section')
|
3048
|
+
lexer.xquery_parse_state.append('operator')
|
3049
|
+
ctx.pos = match.end()
|
3050
|
+
|
3051
|
+
def pushstate_element_content_xmlcomment_callback(lexer, match, ctx):
|
3052
|
+
yield match.start(), String.Doc, match.group(1)
|
3053
|
+
ctx.stack.append('xml_comment')
|
3054
|
+
lexer.xquery_parse_state.append('element_content')
|
3055
|
+
ctx.pos = match.end()
|
3056
|
+
|
3057
|
+
def pushstate_operator_xmlcomment_callback(lexer, match, ctx):
|
3058
|
+
yield match.start(), String.Doc, match.group(1)
|
3059
|
+
ctx.stack.append('xml_comment')
|
3060
|
+
lexer.xquery_parse_state.append('operator')
|
3061
|
+
ctx.pos = match.end()
|
3062
|
+
|
3063
|
+
def pushstate_kindtest_callback(lexer, match, ctx):
|
3064
|
+
yield match.start(), Keyword, match.group(1)
|
3065
|
+
yield match.start(), Text, match.group(2)
|
3066
|
+
yield match.start(), Punctuation, match.group(3)
|
3067
|
+
lexer.xquery_parse_state.append('kindtest')
|
3068
|
+
ctx.stack.append('kindtest')
|
3069
|
+
ctx.pos = match.end()
|
3070
|
+
|
3071
|
+
def pushstate_operator_kindtestforpi_callback(lexer, match, ctx):
|
3072
|
+
yield match.start(), Keyword, match.group(1)
|
3073
|
+
yield match.start(), Text, match.group(2)
|
3074
|
+
yield match.start(), Punctuation, match.group(3)
|
3075
|
+
lexer.xquery_parse_state.append('operator')
|
3076
|
+
ctx.stack.append('kindtestforpi')
|
3077
|
+
ctx.pos = match.end()
|
3078
|
+
|
3079
|
+
def pushstate_operator_kindtest_callback(lexer, match, ctx):
|
3080
|
+
yield match.start(), Keyword, match.group(1)
|
3081
|
+
yield match.start(), Text, match.group(2)
|
3082
|
+
yield match.start(), Punctuation, match.group(3)
|
3083
|
+
lexer.xquery_parse_state.append('operator')
|
3084
|
+
ctx.stack.append('kindtest')
|
3085
|
+
ctx.pos = match.end()
|
3086
|
+
|
3087
|
+
def pushstate_occurrenceindicator_kindtest_callback(lexer, match, ctx):
|
3088
|
+
yield match.start(), Name.Tag, match.group(1)
|
3089
|
+
yield match.start(), Text, match.group(2)
|
3090
|
+
yield match.start(), Punctuation, match.group(3)
|
3091
|
+
lexer.xquery_parse_state.append('occurrenceindicator')
|
3092
|
+
ctx.stack.append('kindtest')
|
3093
|
+
ctx.pos = match.end()
|
3094
|
+
|
3095
|
+
def pushstate_operator_starttag_callback(lexer, match, ctx):
|
3096
|
+
yield match.start(), Name.Tag, match.group(1)
|
3097
|
+
lexer.xquery_parse_state.append('operator')
|
3098
|
+
ctx.stack.append('start_tag')
|
3099
|
+
ctx.pos = match.end()
|
3100
|
+
|
3101
|
+
def pushstate_operator_root_callback(lexer, match, ctx):
|
3102
|
+
yield match.start(), Punctuation, match.group(1)
|
3103
|
+
lexer.xquery_parse_state.append('operator')
|
3104
|
+
ctx.stack = ['root']#.append('root')
|
3105
|
+
ctx.pos = match.end()
|
3106
|
+
|
3107
|
+
def pushstate_operator_root_construct_callback(lexer, match, ctx):
|
3108
|
+
yield match.start(), Keyword, match.group(1)
|
3109
|
+
yield match.start(), Text, match.group(2)
|
3110
|
+
yield match.start(), Punctuation, match.group(3)
|
3111
|
+
lexer.xquery_parse_state.append('operator')
|
3112
|
+
ctx.stack = ['root']
|
3113
|
+
ctx.pos = match.end()
|
3114
|
+
|
3115
|
+
def pushstate_root_callback(lexer, match, ctx):
|
3116
|
+
yield match.start(), Punctuation, match.group(1)
|
3117
|
+
cur_state = ctx.stack.pop()
|
3118
|
+
lexer.xquery_parse_state.append(cur_state)
|
3119
|
+
ctx.stack = ['root']#.append('root')
|
3120
|
+
ctx.pos = match.end()
|
3121
|
+
|
3122
|
+
def pushstate_operator_attribute_callback(lexer, match, ctx):
|
3123
|
+
yield match.start(), Name.Attribute, match.group(1)
|
3124
|
+
ctx.stack.append('operator')
|
3125
|
+
ctx.pos = match.end()
|
3126
|
+
|
3127
|
+
def pushstate_operator_callback(lexer, match, ctx):
|
3128
|
+
yield match.start(), Keyword, match.group(1)
|
3129
|
+
yield match.start(), Text, match.group(2)
|
3130
|
+
yield match.start(), Punctuation, match.group(3)
|
3131
|
+
lexer.xquery_parse_state.append('operator')
|
3132
|
+
ctx.pos = match.end()
|
3133
|
+
|
3134
|
+
tokens = {
|
3135
|
+
'comment': [
|
3136
|
+
# xquery comments
|
3137
|
+
(r'(:\))', Comment, '#pop'),
|
3138
|
+
(r'(\(:)', Comment, '#push'),
|
3139
|
+
(r'[^:)]', Comment),
|
3140
|
+
(r'([^:)]|:|\))', Comment),
|
3141
|
+
],
|
3142
|
+
'whitespace': [
|
3143
|
+
(r'\s+', Text),
|
3144
|
+
],
|
3145
|
+
'operator': [
|
3146
|
+
include('whitespace'),
|
3147
|
+
(r'(\})', popstate_callback),
|
3148
|
+
(r'\(:', Comment, 'comment'),
|
3149
|
+
|
3150
|
+
(r'(\{)', pushstate_root_callback),
|
3151
|
+
(r'then|else|external|at|div|except', Keyword, 'root'),
|
3152
|
+
(r'order by', Keyword, 'root'),
|
3153
|
+
(r'is|mod|order\s+by|stable\s+order\s+by', Keyword, 'root'),
|
3154
|
+
(r'and|or', Operator.Word, 'root'),
|
3155
|
+
(r'(eq|ge|gt|le|lt|ne|idiv|intersect|in)(?=\b)',
|
3156
|
+
Operator.Word, 'root'),
|
3157
|
+
(r'return|satisfies|to|union|where|preserve\s+strip',
|
3158
|
+
Keyword, 'root'),
|
3159
|
+
(r'(>=|>>|>|<=|<<|<|-|\*|!=|\+|\||:=|=)',
|
3160
|
+
operator_root_callback),
|
3161
|
+
(r'(::|;|\[|//|/|,)',
|
3162
|
+
punctuation_root_callback),
|
3163
|
+
(r'(castable|cast)(\s+)(as)\b',
|
3164
|
+
bygroups(Keyword, Text, Keyword), 'singletype'),
|
3165
|
+
(r'(instance)(\s+)(of)\b',
|
3166
|
+
bygroups(Keyword, Text, Keyword), 'itemtype'),
|
3167
|
+
(r'(treat)(\s+)(as)\b',
|
3168
|
+
bygroups(Keyword, Text, Keyword), 'itemtype'),
|
3169
|
+
(r'(case|as)\b', Keyword, 'itemtype'),
|
3170
|
+
(r'(\))(\s*)(as)',
|
3171
|
+
bygroups(Punctuation, Text, Keyword), 'itemtype'),
|
3172
|
+
(r'\$', Name.Variable, 'varname'),
|
3173
|
+
(r'(for|let)(\s+)(\$)',
|
3174
|
+
bygroups(Keyword, Text, Name.Variable), 'varname'),
|
3175
|
+
#(r'\)|\?|\]', Punctuation, '#push'),
|
3176
|
+
(r'\)|\?|\]', Punctuation),
|
3177
|
+
(r'(empty)(\s+)(greatest|least)', bygroups(Keyword, Text, Keyword)),
|
3178
|
+
(r'ascending|descending|default', Keyword, '#push'),
|
3179
|
+
(r'external', Keyword),
|
3180
|
+
(r'collation', Keyword, 'uritooperator'),
|
3181
|
+
# finally catch all string literals and stay in operator state
|
3182
|
+
(stringdouble, String.Double),
|
3183
|
+
(stringsingle, String.Single),
|
3184
|
+
|
3185
|
+
(r'(catch)(\s*)', bygroups(Keyword, Text), 'root'),
|
3186
|
+
],
|
3187
|
+
'uritooperator': [
|
3188
|
+
(stringdouble, String.Double, '#pop'),
|
3189
|
+
(stringsingle, String.Single, '#pop'),
|
3190
|
+
],
|
3191
|
+
'namespacedecl': [
|
3192
|
+
include('whitespace'),
|
3193
|
+
(r'\(:', Comment, 'comment'),
|
3194
|
+
(r'(at)(\s+)('+stringdouble+')', bygroups(Keyword, Text, String.Double)),
|
3195
|
+
(r"(at)(\s+)("+stringsingle+')', bygroups(Keyword, Text, String.Single)),
|
3196
|
+
(stringdouble, String.Double),
|
3197
|
+
(stringsingle, String.Single),
|
3198
|
+
(r',', Punctuation),
|
3199
|
+
(r'=', Operator),
|
3200
|
+
(r';', Punctuation, 'root'),
|
3201
|
+
(ncname, Name.Namespace),
|
3202
|
+
],
|
3203
|
+
'namespacekeyword': [
|
3204
|
+
include('whitespace'),
|
3205
|
+
(r'\(:', Comment, 'comment'),
|
3206
|
+
(stringdouble, String.Double, 'namespacedecl'),
|
3207
|
+
(stringsingle, String.Single, 'namespacedecl'),
|
3208
|
+
(r'inherit|no-inherit', Keyword, 'root'),
|
3209
|
+
(r'namespace', Keyword, 'namespacedecl'),
|
3210
|
+
(r'(default)(\s+)(element)', bygroups(Keyword, Text, Keyword)),
|
3211
|
+
(r'preserve|no-preserve', Keyword),
|
3212
|
+
(r',', Punctuation),
|
3213
|
+
],
|
3214
|
+
'varname': [
|
3215
|
+
(r'\(:', Comment, 'comment'),
|
3216
|
+
(qname, Name.Variable, 'operator'),
|
3217
|
+
],
|
3218
|
+
'singletype': [
|
3219
|
+
(r'\(:', Comment, 'comment'),
|
3220
|
+
(ncname + r'(:\*)', Name.Variable, 'operator'),
|
3221
|
+
(qname, Name.Variable, 'operator'),
|
3222
|
+
],
|
3223
|
+
'itemtype': [
|
3224
|
+
include('whitespace'),
|
3225
|
+
(r'\(:', Comment, 'comment'),
|
3226
|
+
(r'\$', Punctuation, 'varname'),
|
3227
|
+
(r'(void)(\s*)(\()(\s*)(\))',
|
3228
|
+
bygroups(Keyword, Text, Punctuation, Text, Punctuation), 'operator'),
|
3229
|
+
(r'(element|attribute|schema-element|schema-attribute|comment|text|'
|
3230
|
+
r'node|binary|document-node|empty-sequence)(\s*)(\()',
|
3231
|
+
pushstate_occurrenceindicator_kindtest_callback),
|
3232
|
+
# Marklogic specific type?
|
3233
|
+
(r'(processing-instruction)(\s*)(\()',
|
3234
|
+
bygroups(Keyword, Text, Punctuation),
|
3235
|
+
('occurrenceindicator', 'kindtestforpi')),
|
3236
|
+
(r'(item)(\s*)(\()(\s*)(\))(?=[*+?])',
|
3237
|
+
bygroups(Keyword, Text, Punctuation, Text, Punctuation),
|
3238
|
+
'occurrenceindicator'),
|
3239
|
+
(r'\(\#', Punctuation, 'pragma'),
|
3240
|
+
(r';', Punctuation, '#pop'),
|
3241
|
+
(r'then|else', Keyword, '#pop'),
|
3242
|
+
(r'(at)(\s+)(' + stringdouble + ')',
|
3243
|
+
bygroups(Keyword, Text, String.Double), 'namespacedecl'),
|
3244
|
+
(r'(at)(\s+)(' + stringsingle + ')',
|
3245
|
+
bygroups(Keyword, Text, String.Single), 'namespacedecl'),
|
3246
|
+
(r'except|intersect|in|is|return|satisfies|to|union|where',
|
3247
|
+
Keyword, 'root'),
|
3248
|
+
(r'and|div|eq|ge|gt|le|lt|ne|idiv|mod|or', Operator.Word, 'root'),
|
3249
|
+
(r':=|=|,|>=|>>|>|\[|\(|<=|<<|<|-|!=|\|', Operator, 'root'),
|
3250
|
+
(r'external|at', Keyword, 'root'),
|
3251
|
+
(r'(stable)(\s+)(order)(\s+)(by)',
|
3252
|
+
bygroups(Keyword, Text, Keyword, Text, Keyword), 'root'),
|
3253
|
+
(r'(castable|cast)(\s+)(as)',
|
3254
|
+
bygroups(Keyword, Text, Keyword), 'singletype'),
|
3255
|
+
(r'(treat)(\s+)(as)', bygroups(Keyword, Text, Keyword)),
|
3256
|
+
(r'(instance)(\s+)(of)', bygroups(Keyword, Text, Keyword)),
|
3257
|
+
(r'case|as', Keyword, 'itemtype'),
|
3258
|
+
(r'(\))(\s*)(as)', bygroups(Operator, Text, Keyword), 'itemtype'),
|
3259
|
+
(ncname + r':\*', Keyword.Type, 'operator'),
|
3260
|
+
(qname, Keyword.Type, 'occurrenceindicator'),
|
3261
|
+
],
|
3262
|
+
'kindtest': [
|
3263
|
+
(r'\(:', Comment, 'comment'),
|
3264
|
+
(r'{', Punctuation, 'root'),
|
3265
|
+
(r'(\))([*+?]?)', popstate_kindtest_callback),
|
3266
|
+
(r'\*', Name, 'closekindtest'),
|
3267
|
+
(qname, Name, 'closekindtest'),
|
3268
|
+
(r'(element|schema-element)(\s*)(\()', pushstate_kindtest_callback),
|
3269
|
+
],
|
3270
|
+
'kindtestforpi': [
|
3271
|
+
(r'\(:', Comment, 'comment'),
|
3272
|
+
(r'\)', Punctuation, '#pop'),
|
3273
|
+
(ncname, Name.Variable),
|
3274
|
+
(stringdouble, String.Double),
|
3275
|
+
(stringsingle, String.Single),
|
3276
|
+
],
|
3277
|
+
'closekindtest': [
|
3278
|
+
(r'\(:', Comment, 'comment'),
|
3279
|
+
(r'(\))', popstate_callback),
|
3280
|
+
(r',', Punctuation),
|
3281
|
+
(r'(\{)', pushstate_operator_root_callback),
|
3282
|
+
(r'\?', Punctuation),
|
3283
|
+
],
|
3284
|
+
'xml_comment': [
|
3285
|
+
(r'(-->)', popstate_xmlcomment_callback),
|
3286
|
+
(r'[^-]{1,2}', Literal),
|
3287
|
+
(ur'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' +
|
3288
|
+
unirange(0x10000, 0x10ffff), Literal),
|
3289
|
+
],
|
3290
|
+
'processing_instruction': [
|
3291
|
+
(r'\s+', Text, 'processing_instruction_content'),
|
3292
|
+
(r'\?>', String.Doc, '#pop'),
|
3293
|
+
(pitarget, Name),
|
3294
|
+
],
|
3295
|
+
'processing_instruction_content': [
|
3296
|
+
(r'\?>', String.Doc, '#pop'),
|
3297
|
+
(ur'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' +
|
3298
|
+
unirange(0x10000, 0x10ffff), Literal),
|
3299
|
+
],
|
3300
|
+
'cdata_section': [
|
3301
|
+
(r']]>', String.Doc, '#pop'),
|
3302
|
+
(ur'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' +
|
3303
|
+
unirange(0x10000, 0x10ffff), Literal),
|
3304
|
+
],
|
3305
|
+
'start_tag': [
|
3306
|
+
include('whitespace'),
|
3307
|
+
(r'(/>)', popstate_tag_callback),
|
3308
|
+
(r'>', Name.Tag, 'element_content'),
|
3309
|
+
(r'"', Punctuation, 'quot_attribute_content'),
|
3310
|
+
(r"'", Punctuation, 'apos_attribute_content'),
|
3311
|
+
(r'=', Operator),
|
3312
|
+
(qname, Name.Tag),
|
3313
|
+
],
|
3314
|
+
'quot_attribute_content': [
|
3315
|
+
(r'"', Punctuation, 'start_tag'),
|
3316
|
+
(r'(\{)', pushstate_root_callback),
|
3317
|
+
(r'""', Name.Attribute),
|
3318
|
+
(quotattrcontentchar, Name.Attribute),
|
3319
|
+
(entityref, Name.Attribute),
|
3320
|
+
(charref, Name.Attribute),
|
3321
|
+
(r'\{\{|\}\}', Name.Attribute),
|
3322
|
+
],
|
3323
|
+
'apos_attribute_content': [
|
3324
|
+
(r"'", Punctuation, 'start_tag'),
|
3325
|
+
(r'\{', Punctuation, 'root'),
|
3326
|
+
(r"''", Name.Attribute),
|
3327
|
+
(aposattrcontentchar, Name.Attribute),
|
3328
|
+
(entityref, Name.Attribute),
|
3329
|
+
(charref, Name.Attribute),
|
3330
|
+
(r'\{\{|\}\}', Name.Attribute),
|
3331
|
+
],
|
3332
|
+
'element_content': [
|
3333
|
+
(r'</', Name.Tag, 'end_tag'),
|
3334
|
+
(r'(\{)', pushstate_root_callback),
|
3335
|
+
(r'(<!--)', pushstate_element_content_xmlcomment_callback),
|
3336
|
+
(r'(<\?)', pushstate_element_content_processing_instruction_callback),
|
3337
|
+
(r'(<!\[CDATA\[)', pushstate_element_content_cdata_section_callback),
|
3338
|
+
(r'(<)', pushstate_element_content_starttag_callback),
|
3339
|
+
(elementcontentchar, Literal),
|
3340
|
+
(entityref, Literal),
|
3341
|
+
(charref, Literal),
|
3342
|
+
(r'\{\{|\}\}', Literal),
|
3343
|
+
],
|
3344
|
+
'end_tag': [
|
3345
|
+
include('whitespace'),
|
3346
|
+
(r'(>)', popstate_tag_callback),
|
3347
|
+
(qname, Name.Tag),
|
3348
|
+
],
|
3349
|
+
'xmlspace_decl': [
|
3350
|
+
(r'\(:', Comment, 'comment'),
|
3351
|
+
(r'preserve|strip', Keyword, '#pop'),
|
3352
|
+
],
|
3353
|
+
'declareordering': [
|
3354
|
+
(r'\(:', Comment, 'comment'),
|
3355
|
+
include('whitespace'),
|
3356
|
+
(r'ordered|unordered', Keyword, '#pop'),
|
3357
|
+
],
|
3358
|
+
'xqueryversion': [
|
3359
|
+
include('whitespace'),
|
3360
|
+
(r'\(:', Comment, 'comment'),
|
3361
|
+
(stringdouble, String.Double),
|
3362
|
+
(stringsingle, String.Single),
|
3363
|
+
(r'encoding', Keyword),
|
3364
|
+
(r';', Punctuation, '#pop'),
|
3365
|
+
],
|
3366
|
+
'pragma': [
|
3367
|
+
(qname, Name.Variable, 'pragmacontents'),
|
3368
|
+
],
|
3369
|
+
'pragmacontents': [
|
3370
|
+
(r'#\)', Punctuation, 'operator'),
|
3371
|
+
(ur'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' +
|
3372
|
+
unirange(0x10000, 0x10ffff), Literal),
|
3373
|
+
(r'(\s+)', Text),
|
3374
|
+
],
|
3375
|
+
'occurrenceindicator': [
|
3376
|
+
include('whitespace'),
|
3377
|
+
(r'\(:', Comment, 'comment'),
|
3378
|
+
(r'\*|\?|\+', Operator, 'operator'),
|
3379
|
+
(r':=', Operator, 'root'),
|
3380
|
+
(r'', Text, 'operator'),
|
3381
|
+
],
|
3382
|
+
'option': [
|
3383
|
+
include('whitespace'),
|
3384
|
+
(qname, Name.Variable, '#pop'),
|
3385
|
+
],
|
3386
|
+
'qname_braren': [
|
3387
|
+
include('whitespace'),
|
3388
|
+
(r'(\{)', pushstate_operator_root_callback),
|
3389
|
+
(r'(\()', Punctuation, 'root'),
|
3390
|
+
],
|
3391
|
+
'element_qname': [
|
3392
|
+
(qname, Name.Variable, 'root'),
|
3393
|
+
],
|
3394
|
+
'attribute_qname': [
|
3395
|
+
(qname, Name.Variable, 'root'),
|
3396
|
+
],
|
3397
|
+
'root': [
|
3398
|
+
include('whitespace'),
|
3399
|
+
(r'\(:', Comment, 'comment'),
|
3400
|
+
|
3401
|
+
# handle operator state
|
3402
|
+
# order on numbers matters - handle most complex first
|
3403
|
+
(r'\d+(\.\d*)?[eE][\+\-]?\d+', Number.Double, 'operator'),
|
3404
|
+
(r'(\.\d+)[eE][\+\-]?\d+', Number.Double, 'operator'),
|
3405
|
+
(r'(\.\d+|\d+\.\d*)', Number, 'operator'),
|
3406
|
+
(r'(\d+)', Number.Integer, 'operator'),
|
3407
|
+
(r'(\.\.|\.|\))', Punctuation, 'operator'),
|
3408
|
+
(r'(declare)(\s+)(construction)',
|
3409
|
+
bygroups(Keyword, Text, Keyword), 'operator'),
|
3410
|
+
(r'(declare)(\s+)(default)(\s+)(order)',
|
3411
|
+
bygroups(Keyword, Text, Keyword, Text, Keyword), 'operator'),
|
3412
|
+
(ncname + ':\*', Name, 'operator'),
|
3413
|
+
('\*:'+ncname, Name.Tag, 'operator'),
|
3414
|
+
('\*', Name.Tag, 'operator'),
|
3415
|
+
(stringdouble, String.Double, 'operator'),
|
3416
|
+
(stringsingle, String.Single, 'operator'),
|
3417
|
+
|
3418
|
+
(r'(\})', popstate_callback),
|
3419
|
+
|
3420
|
+
#NAMESPACE DECL
|
3421
|
+
(r'(declare)(\s+)(default)(\s+)(collation)',
|
3422
|
+
bygroups(Keyword, Text, Keyword, Text, Keyword)),
|
3423
|
+
(r'(module|declare)(\s+)(namespace)',
|
3424
|
+
bygroups(Keyword, Text, Keyword), 'namespacedecl'),
|
3425
|
+
(r'(declare)(\s+)(base-uri)',
|
3426
|
+
bygroups(Keyword, Text, Keyword), 'namespacedecl'),
|
3427
|
+
|
3428
|
+
#NAMESPACE KEYWORD
|
3429
|
+
(r'(declare)(\s+)(default)(\s+)(element|function)',
|
3430
|
+
bygroups(Keyword, Text, Keyword, Text, Keyword), 'namespacekeyword'),
|
3431
|
+
(r'(import)(\s+)(schema|module)',
|
3432
|
+
bygroups(Keyword.Pseudo, Text, Keyword.Pseudo), 'namespacekeyword'),
|
3433
|
+
(r'(declare)(\s+)(copy-namespaces)',
|
3434
|
+
bygroups(Keyword, Text, Keyword), 'namespacekeyword'),
|
3435
|
+
|
3436
|
+
#VARNAMEs
|
3437
|
+
(r'(for|let|some|every)(\s+)(\$)',
|
3438
|
+
bygroups(Keyword, Text, Name.Variable), 'varname'),
|
3439
|
+
(r'\$', Name.Variable, 'varname'),
|
3440
|
+
(r'(declare)(\s+)(variable)(\s+)(\$)',
|
3441
|
+
bygroups(Keyword, Text, Keyword, Text, Name.Variable), 'varname'),
|
3442
|
+
|
3443
|
+
#ITEMTYPE
|
3444
|
+
(r'(\))(\s+)(as)', bygroups(Operator, Text, Keyword), 'itemtype'),
|
3445
|
+
|
3446
|
+
(r'(element|attribute|schema-element|schema-attribute|comment|'
|
3447
|
+
r'text|node|document-node|empty-sequence)(\s+)(\()',
|
3448
|
+
pushstate_operator_kindtest_callback),
|
3449
|
+
|
3450
|
+
(r'(processing-instruction)(\s+)(\()',
|
3451
|
+
pushstate_operator_kindtestforpi_callback),
|
3452
|
+
|
3453
|
+
(r'(<!--)', pushstate_operator_xmlcomment_callback),
|
3454
|
+
|
3455
|
+
(r'(<\?)', pushstate_operator_processing_instruction_callback),
|
3456
|
+
|
3457
|
+
(r'(<!\[CDATA\[)', pushstate_operator_cdata_section_callback),
|
3458
|
+
|
3459
|
+
# (r'</', Name.Tag, 'end_tag'),
|
3460
|
+
(r'(<)', pushstate_operator_starttag_callback),
|
3461
|
+
|
3462
|
+
(r'(declare)(\s+)(boundary-space)',
|
3463
|
+
bygroups(Keyword, Text, Keyword), 'xmlspace_decl'),
|
3464
|
+
|
3465
|
+
(r'(validate)(\s+)(lax|strict)',
|
3466
|
+
pushstate_operator_root_validate_withmode),
|
3467
|
+
(r'(validate)(\s*)(\{)', pushstate_operator_root_validate),
|
3468
|
+
(r'(typeswitch)(\s*)(\()', bygroups(Keyword, Text, Punctuation)),
|
3469
|
+
(r'(element|attribute)(\s*)(\{)',
|
3470
|
+
pushstate_operator_root_construct_callback),
|
3471
|
+
|
3472
|
+
(r'(document|text|processing-instruction|comment)(\s*)(\{)',
|
3473
|
+
pushstate_operator_root_construct_callback),
|
3474
|
+
#ATTRIBUTE
|
3475
|
+
(r'(attribute)(\s+)(?=' + qname + r')',
|
3476
|
+
bygroups(Keyword, Text), 'attribute_qname'),
|
3477
|
+
#ELEMENT
|
3478
|
+
(r'(element)(\s+)(?=' +qname+ r')',
|
3479
|
+
bygroups(Keyword, Text), 'element_qname'),
|
3480
|
+
#PROCESSING_INSTRUCTION
|
3481
|
+
(r'(processing-instruction)(\s+)(' + ncname + r')(\s*)(\{)',
|
3482
|
+
bygroups(Keyword, Text, Name.Variable, Text, Punctuation),
|
3483
|
+
'operator'),
|
3484
|
+
|
3485
|
+
(r'(declare|define)(\s+)(function)',
|
3486
|
+
bygroups(Keyword, Text, Keyword)),
|
3487
|
+
|
3488
|
+
(r'(\{)', pushstate_operator_root_callback),
|
3489
|
+
|
3490
|
+
(r'(unordered|ordered)(\s*)(\{)',
|
3491
|
+
pushstate_operator_order_callback),
|
3492
|
+
|
3493
|
+
(r'(declare)(\s+)(ordering)',
|
3494
|
+
bygroups(Keyword, Text, Keyword), 'declareordering'),
|
3495
|
+
|
3496
|
+
(r'(xquery)(\s+)(version)',
|
3497
|
+
bygroups(Keyword.Pseudo, Text, Keyword.Pseudo), 'xqueryversion'),
|
3498
|
+
|
3499
|
+
(r'(\(#)', Punctuation, 'pragma'),
|
3500
|
+
|
3501
|
+
# sometimes return can occur in root state
|
3502
|
+
(r'return', Keyword),
|
3503
|
+
|
3504
|
+
(r'(declare)(\s+)(option)', bygroups(Keyword, Text, Keyword),
|
3505
|
+
'option'),
|
3506
|
+
|
3507
|
+
#URI LITERALS - single and double quoted
|
3508
|
+
(r'(at)(\s+)('+stringdouble+')', String.Double, 'namespacedecl'),
|
3509
|
+
(r'(at)(\s+)('+stringsingle+')', String.Single, 'namespacedecl'),
|
3510
|
+
|
3511
|
+
(r'(ancestor-or-self|ancestor|attribute|child|descendant-or-self)(::)',
|
3512
|
+
bygroups(Keyword, Punctuation)),
|
3513
|
+
(r'(descendant|following-sibling|following|parent|preceding-sibling'
|
3514
|
+
r'|preceding|self)(::)', bygroups(Keyword, Punctuation)),
|
3515
|
+
|
3516
|
+
(r'(if)(\s*)(\()', bygroups(Keyword, Text, Punctuation)),
|
3517
|
+
|
3518
|
+
(r'then|else', Keyword),
|
3519
|
+
|
3520
|
+
# ML specific
|
3521
|
+
(r'(try)(\s*)', bygroups(Keyword, Text), 'root'),
|
3522
|
+
(r'(catch)(\s*)(\()(\$)',
|
3523
|
+
bygroups(Keyword, Text, Punctuation, Name.Variable), 'varname'),
|
3524
|
+
|
3525
|
+
(r'(@'+qname+')', Name.Attribute),
|
3526
|
+
(r'(@'+ncname+')', Name.Attribute),
|
3527
|
+
(r'@\*:'+ncname, Name.Attribute),
|
3528
|
+
(r'(@)', Name.Attribute),
|
3529
|
+
|
3530
|
+
(r'//|/|\+|-|;|,|\(|\)', Punctuation),
|
3531
|
+
|
3532
|
+
# STANDALONE QNAMES
|
3533
|
+
(qname + r'(?=\s*{)', Name.Tag, 'qname_braren'),
|
3534
|
+
(qname + r'(?=\s*\([^:])', Name.Function, 'qname_braren'),
|
3535
|
+
(qname, Name.Tag, 'operator'),
|
3536
|
+
]
|
3537
|
+
}
|
3538
|
+
|
3539
|
+
|
3540
|
+
class DartLexer(RegexLexer):
|
3541
|
+
"""
|
3542
|
+
For `Dart <http://dartlang.org/>`_ source code.
|
3543
|
+
|
3544
|
+
*New in Pygments 1.5.*
|
3545
|
+
"""
|
3546
|
+
|
3547
|
+
name = 'Dart'
|
3548
|
+
aliases = ['dart']
|
3549
|
+
filenames = ['*.dart']
|
3550
|
+
mimetypes = ['text/x-dart']
|
3551
|
+
|
3552
|
+
flags = re.MULTILINE | re.DOTALL
|
3553
|
+
|
3554
|
+
tokens = {
|
3555
|
+
'root': [
|
3556
|
+
include('string_literal'),
|
3557
|
+
(r'#!(.*?)$', Comment.Preproc),
|
3558
|
+
(r'\b(import|export)\b', Keyword, 'import_decl'),
|
3559
|
+
(r'\b(library|source|part of|part)\b', Keyword),
|
3560
|
+
(r'[^\S\n]+', Text),
|
3561
|
+
(r'//.*?\n', Comment.Single),
|
3562
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
3563
|
+
(r'\b(class)\b(\s+)',
|
3564
|
+
bygroups(Keyword.Declaration, Text), 'class'),
|
3565
|
+
(r'\b(assert|break|case|catch|continue|default|do|else|finally|for|'
|
3566
|
+
r'if|in|is|new|return|super|switch|this|throw|try|while)\b',
|
3567
|
+
Keyword),
|
3568
|
+
(r'\b(abstract|const|extends|factory|final|get|implements|'
|
3569
|
+
r'native|operator|set|static|typedef|var)\b', Keyword.Declaration),
|
3570
|
+
(r'\b(bool|double|Dynamic|int|num|Object|String|void)\b', Keyword.Type),
|
3571
|
+
(r'\b(false|null|true)\b', Keyword.Constant),
|
3572
|
+
(r'[~!%^&*+=|?:<>/-]|as', Operator),
|
3573
|
+
(r'[a-zA-Z_$][a-zA-Z0-9_]*:', Name.Label),
|
3574
|
+
(r'[a-zA-Z_$][a-zA-Z0-9_]*', Name),
|
3575
|
+
(r'[(){}\[\],.;]', Punctuation),
|
3576
|
+
(r'0[xX][0-9a-fA-F]+', Number.Hex),
|
3577
|
+
# DIGIT+ (‘.’ DIGIT*)? EXPONENT?
|
3578
|
+
(r'\d+(\.\d*)?([eE][+-]?\d+)?', Number),
|
3579
|
+
(r'\.\d+([eE][+-]?\d+)?', Number), # ‘.’ DIGIT+ EXPONENT?
|
3580
|
+
(r'\n', Text)
|
3581
|
+
# pseudo-keyword negate intentionally left out
|
3582
|
+
],
|
3583
|
+
'class': [
|
3584
|
+
(r'[a-zA-Z_$][a-zA-Z0-9_]*', Name.Class, '#pop')
|
3585
|
+
],
|
3586
|
+
'import_decl': [
|
3587
|
+
include('string_literal'),
|
3588
|
+
(r'\s+', Text),
|
3589
|
+
(r'\b(as|show|hide)\b', Keyword),
|
3590
|
+
(r'[a-zA-Z_$][a-zA-Z0-9_]*', Name),
|
3591
|
+
(r'\,', Punctuation),
|
3592
|
+
(r'\;', Punctuation, '#pop')
|
3593
|
+
],
|
3594
|
+
'string_literal': [
|
3595
|
+
# Raw strings.
|
3596
|
+
(r'r"""([\s|\S]*?)"""', String.Double),
|
3597
|
+
(r"r'''([\s|\S]*?)'''", String.Single),
|
3598
|
+
(r'r"(.*?)"', String.Double),
|
3599
|
+
(r"r'(.*?)'", String.Single),
|
3600
|
+
# Normal Strings.
|
3601
|
+
(r'"""', String.Double, 'string_double_multiline'),
|
3602
|
+
(r"'''", String.Single, 'string_single_multiline'),
|
3603
|
+
(r'"', String.Double, 'string_double'),
|
3604
|
+
(r"'", String.Single, 'string_single')
|
3605
|
+
],
|
3606
|
+
'string_common': [
|
3607
|
+
(r"\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\{[0-9A-Fa-f]*\}|[a-z\'\"$\\])",
|
3608
|
+
String.Escape),
|
3609
|
+
(r'(\$)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(String.Interpol, Name)),
|
3610
|
+
(r'(\$\{)(.*?)(\})',
|
3611
|
+
bygroups(String.Interpol, using(this), String.Interpol))
|
3612
|
+
],
|
3613
|
+
'string_double': [
|
3614
|
+
(r'"', String.Double, '#pop'),
|
3615
|
+
(r'[^\"$\\\n]+', String.Double),
|
3616
|
+
include('string_common'),
|
3617
|
+
(r'\$+', String.Double)
|
3618
|
+
],
|
3619
|
+
'string_double_multiline': [
|
3620
|
+
(r'"""', String.Double, '#pop'),
|
3621
|
+
(r'[^\"$\\]+', String.Double),
|
3622
|
+
include('string_common'),
|
3623
|
+
(r'(\$|\")+', String.Double)
|
3624
|
+
],
|
3625
|
+
'string_single': [
|
3626
|
+
(r"'", String.Single, '#pop'),
|
3627
|
+
(r"[^\'$\\\n]+", String.Single),
|
3628
|
+
include('string_common'),
|
3629
|
+
(r'\$+', String.Single)
|
3630
|
+
],
|
3631
|
+
'string_single_multiline': [
|
3632
|
+
(r"'''", String.Single, '#pop'),
|
3633
|
+
(r'[^\'$\\]+', String.Single),
|
3634
|
+
include('string_common'),
|
3635
|
+
(r'(\$|\')+', String.Single)
|
3636
|
+
]
|
3637
|
+
}
|
3638
|
+
|
3639
|
+
|
3640
|
+
class TypeScriptLexer(RegexLexer):
|
3641
|
+
"""
|
3642
|
+
For `TypeScript <http://www.python.org>`_ source code.
|
3643
|
+
|
3644
|
+
*New in Pygments 1.6.*
|
3645
|
+
"""
|
3646
|
+
|
3647
|
+
name = 'TypeScript'
|
3648
|
+
aliases = ['ts']
|
3649
|
+
filenames = ['*.ts']
|
3650
|
+
mimetypes = ['text/x-typescript']
|
3651
|
+
|
3652
|
+
flags = re.DOTALL
|
3653
|
+
tokens = {
|
3654
|
+
'commentsandwhitespace': [
|
3655
|
+
(r'\s+', Text),
|
3656
|
+
(r'<!--', Comment),
|
3657
|
+
(r'//.*?\n', Comment.Single),
|
3658
|
+
(r'/\*.*?\*/', Comment.Multiline)
|
3659
|
+
],
|
3660
|
+
'slashstartsregex': [
|
3661
|
+
include('commentsandwhitespace'),
|
3662
|
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
3663
|
+
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
3664
|
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
3665
|
+
(r'', Text, '#pop')
|
3666
|
+
],
|
3667
|
+
'badregex': [
|
3668
|
+
(r'\n', Text, '#pop')
|
3669
|
+
],
|
3670
|
+
'root': [
|
3671
|
+
(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
|
3672
|
+
include('commentsandwhitespace'),
|
3673
|
+
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
|
3674
|
+
r'(<<|>>>?|==?|!=?|[-<>+*%&\|\^/])=?', Operator, 'slashstartsregex'),
|
3675
|
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
3676
|
+
(r'[})\].]', Punctuation),
|
3677
|
+
(r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
|
3678
|
+
r'throw|try|catch|finally|new|delete|typeof|instanceof|void|'
|
3679
|
+
r'this)\b', Keyword, 'slashstartsregex'),
|
3680
|
+
(r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
|
3681
|
+
(r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|'
|
3682
|
+
r'extends|final|float|goto|implements|import|int|interface|long|native|'
|
3683
|
+
r'package|private|protected|public|short|static|super|synchronized|throws|'
|
3684
|
+
r'transient|volatile)\b', Keyword.Reserved),
|
3685
|
+
(r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
|
3686
|
+
(r'(Array|Boolean|Date|Error|Function|Math|netscape|'
|
3687
|
+
r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
|
3688
|
+
r'decodeURIComponent|encodeURI|encodeURIComponent|'
|
3689
|
+
r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
|
3690
|
+
r'window)\b', Name.Builtin),
|
3691
|
+
# Match stuff like: module name {...}
|
3692
|
+
(r'\b(module)(\s*)(\s*[a-zA-Z0-9_?.$][\w?.$]*)(\s*)',
|
3693
|
+
bygroups(Keyword.Reserved, Text, Name.Other, Text), 'slashstartsregex'),
|
3694
|
+
# Match variable type keywords
|
3695
|
+
(r'\b(string|bool|number)\b', Keyword.Type),
|
3696
|
+
# Match stuff like: constructor
|
3697
|
+
(r'\b(constructor|declare|interface|as|AS)\b', Keyword.Reserved),
|
3698
|
+
# Match stuff like: super(argument, list)
|
3699
|
+
(r'(super)(\s*)(\([a-zA-Z0-9,_?.$\s]+\s*\))',
|
3700
|
+
bygroups(Keyword.Reserved, Text), 'slashstartsregex'),
|
3701
|
+
# Match stuff like: function() {...}
|
3702
|
+
(r'([a-zA-Z_?.$][\w?.$]*)\(\) \{', Name.Other, 'slashstartsregex'),
|
3703
|
+
# Match stuff like: (function: return type)
|
3704
|
+
(r'([a-zA-Z0-9_?.$][\w?.$]*)(\s*:\s*)([a-zA-Z0-9_?.$][\w?.$]*)',
|
3705
|
+
bygroups(Name.Other, Text, Keyword.Type)),
|
3706
|
+
(r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
|
3707
|
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
3708
|
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
3709
|
+
(r'[0-9]+', Number.Integer),
|
3710
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
3711
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
3712
|
+
]
|
3713
|
+
}
|
3714
|
+
|
3715
|
+
|
3716
|
+
class LassoLexer(RegexLexer):
|
3717
|
+
"""
|
3718
|
+
For `Lasso <http://www.lassosoft.com/>`_ source code, covering both Lasso 9
|
3719
|
+
syntax and LassoScript for Lasso 8.6 and earlier. For Lasso embedded in
|
3720
|
+
HTML, use the `LassoHtmlLexer`.
|
3721
|
+
|
3722
|
+
Additional options accepted:
|
3723
|
+
|
3724
|
+
`builtinshighlighting`
|
3725
|
+
If given and ``True``, highlight builtin types, traits, methods, and
|
3726
|
+
members (default: ``True``).
|
3727
|
+
`requiredelimiters`
|
3728
|
+
If given and ``True``, only highlight code between delimiters as Lasso
|
3729
|
+
(default: ``False``).
|
3730
|
+
|
3731
|
+
*New in Pygments 1.6.*
|
3732
|
+
"""
|
3733
|
+
|
3734
|
+
name = 'Lasso'
|
3735
|
+
aliases = ['lasso', 'lassoscript']
|
3736
|
+
filenames = ['*.lasso', '*.lasso[89]']
|
3737
|
+
alias_filenames = ['*.incl', '*.inc', '*.las']
|
3738
|
+
mimetypes = ['text/x-lasso']
|
3739
|
+
flags = re.IGNORECASE | re.DOTALL | re.MULTILINE
|
3740
|
+
|
3741
|
+
tokens = {
|
3742
|
+
'root': [
|
3743
|
+
(r'^#!.+lasso9\b', Comment.Preproc, 'lasso'),
|
3744
|
+
(r'\[no_square_brackets\]', Comment.Preproc, 'nosquarebrackets'),
|
3745
|
+
(r'\[noprocess\]', Comment.Preproc, ('delimiters', 'noprocess')),
|
3746
|
+
(r'\[', Comment.Preproc, ('delimiters', 'squarebrackets')),
|
3747
|
+
(r'<\?(LassoScript|lasso|=)', Comment.Preproc,
|
3748
|
+
('delimiters', 'anglebrackets')),
|
3749
|
+
(r'<', Other, 'delimiters'),
|
3750
|
+
(r'\s+', Other),
|
3751
|
+
(r'', Other, ('delimiters', 'lassofile')),
|
3752
|
+
],
|
3753
|
+
'delimiters': [
|
3754
|
+
(r'\[no_square_brackets\]', Comment.Preproc, 'nosquarebrackets'),
|
3755
|
+
(r'\[noprocess\]', Comment.Preproc, 'noprocess'),
|
3756
|
+
(r'\[', Comment.Preproc, 'squarebrackets'),
|
3757
|
+
(r'<\?(LassoScript|lasso|=)', Comment.Preproc, 'anglebrackets'),
|
3758
|
+
(r'<', Other),
|
3759
|
+
(r'[^[<]+', Other),
|
3760
|
+
],
|
3761
|
+
'nosquarebrackets': [
|
3762
|
+
(r'<\?(LassoScript|lasso|=)', Comment.Preproc, 'anglebrackets'),
|
3763
|
+
(r'<', Other),
|
3764
|
+
(r'[^<]+', Other),
|
3765
|
+
],
|
3766
|
+
'noprocess': [
|
3767
|
+
(r'\[/noprocess\]', Comment.Preproc, '#pop'),
|
3768
|
+
(r'\[', Other),
|
3769
|
+
(r'[^[]', Other),
|
3770
|
+
],
|
3771
|
+
'squarebrackets': [
|
3772
|
+
(r'\]', Comment.Preproc, '#pop'),
|
3773
|
+
include('lasso'),
|
3774
|
+
],
|
3775
|
+
'anglebrackets': [
|
3776
|
+
(r'\?>', Comment.Preproc, '#pop'),
|
3777
|
+
include('lasso'),
|
3778
|
+
],
|
3779
|
+
'lassofile': [
|
3780
|
+
(r'\]', Comment.Preproc, '#pop'),
|
3781
|
+
(r'\?>', Comment.Preproc, '#pop'),
|
3782
|
+
include('lasso'),
|
3783
|
+
],
|
3784
|
+
'whitespacecomments': [
|
3785
|
+
(r'\s+', Text),
|
3786
|
+
(r'//.*?\n', Comment.Single),
|
3787
|
+
(r'/\*\*!.*?\*/', String.Doc),
|
3788
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
3789
|
+
],
|
3790
|
+
'lasso': [
|
3791
|
+
# whitespace/comments
|
3792
|
+
include('whitespacecomments'),
|
3793
|
+
|
3794
|
+
# literals
|
3795
|
+
(r'\d*\.\d+(e[+-]?\d+)?', Number.Float),
|
3796
|
+
(r'0x[\da-f]+', Number.Hex),
|
3797
|
+
(r'\d+', Number.Integer),
|
3798
|
+
(r'([+-]?)(infinity|NaN)\b', bygroups(Operator, Number)),
|
3799
|
+
(r"'", String.Single, 'singlestring'),
|
3800
|
+
(r'"', String.Double, 'doublestring'),
|
3801
|
+
(r'`[^`]*`', String.Backtick),
|
3802
|
+
|
3803
|
+
# names
|
3804
|
+
(r'\$[a-z_][\w.]*', Name.Variable),
|
3805
|
+
(r'#([a-z_][\w.]*|\d+)', Name.Variable.Instance),
|
3806
|
+
(r"(\.)('[a-z_][\w.]*')",
|
3807
|
+
bygroups(Name.Builtin.Pseudo, Name.Variable.Class)),
|
3808
|
+
(r"(self)(\s*->\s*)('[a-z_][\w.]*')",
|
3809
|
+
bygroups(Name.Builtin.Pseudo, Operator, Name.Variable.Class)),
|
3810
|
+
(r'(\.\.?)([a-z_][\w.]*)',
|
3811
|
+
bygroups(Name.Builtin.Pseudo, Name.Other.Member)),
|
3812
|
+
(r'(->\\?\s*|&\s*)([a-z_][\w.]*)',
|
3813
|
+
bygroups(Operator, Name.Other.Member)),
|
3814
|
+
(r'(self|inherited|global|void)\b', Name.Builtin.Pseudo),
|
3815
|
+
(r'-[a-z_][\w.]*', Name.Attribute),
|
3816
|
+
(r'(::\s*)([a-z_][\w.]*)', bygroups(Punctuation, Name.Label)),
|
3817
|
+
(r'(error_(code|msg)_\w+|Error_AddError|Error_ColumnRestriction|'
|
3818
|
+
r'Error_DatabaseConnectionUnavailable|Error_DatabaseTimeout|'
|
3819
|
+
r'Error_DeleteError|Error_FieldRestriction|Error_FileNotFound|'
|
3820
|
+
r'Error_InvalidDatabase|Error_InvalidPassword|'
|
3821
|
+
r'Error_InvalidUsername|Error_ModuleNotFound|'
|
3822
|
+
r'Error_NoError|Error_NoPermission|Error_OutOfMemory|'
|
3823
|
+
r'Error_ReqColumnMissing|Error_ReqFieldMissing|'
|
3824
|
+
r'Error_RequiredColumnMissing|Error_RequiredFieldMissing|'
|
3825
|
+
r'Error_UpdateError)\b', Name.Exception),
|
3826
|
+
|
3827
|
+
# definitions
|
3828
|
+
(r'(define)(\s+)([a-z_][\w.]*)(\s*=>\s*)(type|trait|thread)\b',
|
3829
|
+
bygroups(Keyword.Declaration, Text, Name.Class, Operator, Keyword)),
|
3830
|
+
(r'(define)(\s+)([a-z_][\w.]*)(\s*->\s*)([a-z_][\w.]*=?|[-+*/%<>]|==)',
|
3831
|
+
bygroups(Keyword.Declaration, Text, Name.Class, Operator,
|
3832
|
+
Name.Function), 'signature'),
|
3833
|
+
(r'(define)(\s+)([a-z_][\w.]*)',
|
3834
|
+
bygroups(Keyword.Declaration, Text, Name.Function), 'signature'),
|
3835
|
+
(r'(public|protected|private|provide)(\s+)(([a-z_][\w.]*=?|'
|
3836
|
+
r'[-+*/%<>]|==)(?=\s*\())', bygroups(Keyword, Text, Name.Function),
|
3837
|
+
'signature'),
|
3838
|
+
(r'(public|protected|private)(\s+)([a-z_][\w.]*)',
|
3839
|
+
bygroups(Keyword, Text, Name.Function)),
|
3840
|
+
|
3841
|
+
# keywords
|
3842
|
+
(r'(true|false|none|minimal|full|all)\b', Keyword.Constant),
|
3843
|
+
(r'(local|var|variable|data(?=\s))\b', Keyword.Declaration),
|
3844
|
+
(r'(array|date|decimal|duration|integer|map|pair|string|tag|xml|'
|
3845
|
+
r'null|list|queue|set|stack|staticarray)\b', Keyword.Type),
|
3846
|
+
(r'([a-z_][\w.]*)(\s+)(in)\b', bygroups(Name, Text, Keyword)),
|
3847
|
+
(r'(let|into)(\s+)([a-z_][\w.]*)', bygroups(Keyword, Text, Name)),
|
3848
|
+
(r'require\b', Keyword, 'requiresection'),
|
3849
|
+
(r'(/?)(Namespace_Using)\b', bygroups(Punctuation, Keyword.Namespace)),
|
3850
|
+
(r'(/?)(Cache|Database_Names|Database_SchemaNames|'
|
3851
|
+
r'Database_TableNames|Define_Tag|Define_Type|Email_Batch|'
|
3852
|
+
r'Encode_Set|HTML_Comment|Handle|Handle_Error|Header|If|Inline|'
|
3853
|
+
r'Iterate|LJAX_Target|Link|Link_CurrentAction|Link_CurrentGroup|'
|
3854
|
+
r'Link_CurrentRecord|Link_Detail|Link_FirstGroup|'
|
3855
|
+
r'Link_FirstRecord|Link_LastGroup|Link_LastRecord|Link_NextGroup|'
|
3856
|
+
r'Link_NextRecord|Link_PrevGroup|Link_PrevRecord|Log|Loop|'
|
3857
|
+
r'NoProcess|Output_None|Portal|Private|Protect|Records|Referer|'
|
3858
|
+
r'Referrer|Repeating|ResultSet|Rows|Search_Args|Search_Arguments|'
|
3859
|
+
r'Select|Sort_Args|Sort_Arguments|Thread_Atomic|Value_List|While|'
|
3860
|
+
r'Abort|Case|Else|If_Empty|If_False|If_Null|If_True|Loop_Abort|'
|
3861
|
+
r'Loop_Continue|Loop_Count|Params|Params_Up|Return|Return_Value|'
|
3862
|
+
r'Run_Children|SOAP_DefineTag|SOAP_LastRequest|SOAP_LastResponse|'
|
3863
|
+
r'Tag_Name|ascending|average|by|define|descending|do|equals|'
|
3864
|
+
r'frozen|group|handle_failure|import|in|into|join|let|match|max|'
|
3865
|
+
r'min|on|order|parent|protected|provide|public|require|skip|'
|
3866
|
+
r'split_thread|sum|take|thread|to|trait|type|where|with|yield)\b',
|
3867
|
+
bygroups(Punctuation, Keyword)),
|
3868
|
+
|
3869
|
+
# other
|
3870
|
+
(r',', Punctuation, 'commamember'),
|
3871
|
+
(r'(and|or|not)\b', Operator.Word),
|
3872
|
+
(r'([a-z_][\w.]*)(\s*::\s*)?([a-z_][\w.]*)?(\s*=(?!=))',
|
3873
|
+
bygroups(Name, Punctuation, Name.Label, Operator)),
|
3874
|
+
(r'(/?)([\w.]+)', bygroups(Punctuation, Name.Other)),
|
3875
|
+
(r'(=)(bw|ew|cn|lte?|gte?|n?eq|ft|n?rx)\b',
|
3876
|
+
bygroups(Operator, Operator.Word)),
|
3877
|
+
(r':=|[-+*/%=<>&|!?\\]+', Operator),
|
3878
|
+
(r'[{}():;,@^]', Punctuation),
|
3879
|
+
],
|
3880
|
+
'singlestring': [
|
3881
|
+
(r"'", String.Single, '#pop'),
|
3882
|
+
(r"[^'\\]+", String.Single),
|
3883
|
+
include('escape'),
|
3884
|
+
(r"\\+", String.Single),
|
3885
|
+
],
|
3886
|
+
'doublestring': [
|
3887
|
+
(r'"', String.Double, '#pop'),
|
3888
|
+
(r'[^"\\]+', String.Double),
|
3889
|
+
include('escape'),
|
3890
|
+
(r'\\+', String.Double),
|
3891
|
+
],
|
3892
|
+
'escape': [
|
3893
|
+
(r'\\(U[\da-f]{8}|u[\da-f]{4}|x[\da-f]{1,2}|[0-7]{1,3}|:[^:]+:|'
|
3894
|
+
r'[abefnrtv?\"\'\\]|$)', String.Escape),
|
3895
|
+
],
|
3896
|
+
'signature': [
|
3897
|
+
(r'=>', Operator, '#pop'),
|
3898
|
+
(r'\)', Punctuation, '#pop'),
|
3899
|
+
(r'[(,]', Punctuation, 'parameter'),
|
3900
|
+
include('lasso'),
|
3901
|
+
],
|
3902
|
+
'parameter': [
|
3903
|
+
(r'\)', Punctuation, '#pop'),
|
3904
|
+
(r'-?[a-z_][\w.]*', Name.Attribute, '#pop'),
|
3905
|
+
(r'\.\.\.', Name.Builtin.Pseudo),
|
3906
|
+
include('lasso'),
|
3907
|
+
],
|
3908
|
+
'requiresection': [
|
3909
|
+
(r'(([a-z_][\w.]*=?|[-+*/%<>]|==)(?=\s*\())', Name, 'requiresignature'),
|
3910
|
+
(r'(([a-z_][\w.]*=?|[-+*/%<>]|==)(?=(\s*::\s*[\w.]+)?\s*,))', Name),
|
3911
|
+
(r'[a-z_][\w.]*=?|[-+*/%<>]|==', Name, '#pop'),
|
3912
|
+
(r'(::\s*)([a-z_][\w.]*)', bygroups(Punctuation, Name.Label)),
|
3913
|
+
(r',', Punctuation),
|
3914
|
+
include('whitespacecomments'),
|
3915
|
+
],
|
3916
|
+
'requiresignature': [
|
3917
|
+
(r'(\)(?=(\s*::\s*[\w.]+)?\s*,))', Punctuation, '#pop'),
|
3918
|
+
(r'\)', Punctuation, '#pop:2'),
|
3919
|
+
(r'-?[a-z_][\w.]*', Name.Attribute),
|
3920
|
+
(r'(::\s*)([a-z_][\w.]*)', bygroups(Punctuation, Name.Label)),
|
3921
|
+
(r'\.\.\.', Name.Builtin.Pseudo),
|
3922
|
+
(r'[(,]', Punctuation),
|
3923
|
+
include('whitespacecomments'),
|
3924
|
+
],
|
3925
|
+
'commamember': [
|
3926
|
+
(r'(([a-z_][\w.]*=?|[-+*/%<>]|==)'
|
3927
|
+
r'(?=\s*(\(([^()]*\([^()]*\))*[^)]*\)\s*)?(::[\w.\s]+)?=>))',
|
3928
|
+
Name.Function, 'signature'),
|
3929
|
+
include('whitespacecomments'),
|
3930
|
+
(r'', Text, '#pop'),
|
3931
|
+
],
|
3932
|
+
}
|
3933
|
+
|
3934
|
+
def __init__(self, **options):
|
3935
|
+
self.builtinshighlighting = get_bool_opt(
|
3936
|
+
options, 'builtinshighlighting', True)
|
3937
|
+
self.requiredelimiters = get_bool_opt(
|
3938
|
+
options, 'requiredelimiters', False)
|
3939
|
+
|
3940
|
+
self._builtins = set()
|
3941
|
+
self._members = set()
|
3942
|
+
if self.builtinshighlighting:
|
3943
|
+
from pygments.lexers._lassobuiltins import BUILTINS, MEMBERS
|
3944
|
+
for key, value in BUILTINS.iteritems():
|
3945
|
+
self._builtins.update(value)
|
3946
|
+
for key, value in MEMBERS.iteritems():
|
3947
|
+
self._members.update(value)
|
3948
|
+
RegexLexer.__init__(self, **options)
|
3949
|
+
|
3950
|
+
def get_tokens_unprocessed(self, text):
|
3951
|
+
stack = ['root']
|
3952
|
+
if self.requiredelimiters:
|
3953
|
+
stack.append('delimiters')
|
3954
|
+
for index, token, value in \
|
3955
|
+
RegexLexer.get_tokens_unprocessed(self, text, stack):
|
3956
|
+
if (token is Name.Other and value.lower() in self._builtins or
|
3957
|
+
token is Name.Other.Member and value.lower() in self._members):
|
3958
|
+
yield index, Name.Builtin, value
|
3959
|
+
continue
|
3960
|
+
yield index, token, value
|
3961
|
+
|
3962
|
+
def analyse_text(text):
|
3963
|
+
rv = 0.0
|
3964
|
+
if 'bin/lasso9' in text:
|
3965
|
+
rv += 0.8
|
3966
|
+
if re.search(r'<\?(=|lasso)|\A\[', text, re.I):
|
3967
|
+
rv += 0.4
|
3968
|
+
if re.search(r'local\(', text, re.I):
|
3969
|
+
rv += 0.4
|
3970
|
+
if '?>' in text:
|
3971
|
+
rv += 0.1
|
3972
|
+
return rv
|
3973
|
+
|
3974
|
+
|
3975
|
+
class QmlLexer(RegexLexer):
|
3976
|
+
"""
|
3977
|
+
For QML files. See http://doc.qt.digia.com/4.7/qdeclarativeintroduction.html.
|
3978
|
+
|
3979
|
+
*New in Pygments 1.6.*
|
3980
|
+
"""
|
3981
|
+
|
3982
|
+
# QML is based on javascript, so much of this is taken from the
|
3983
|
+
# JavascriptLexer above.
|
3984
|
+
|
3985
|
+
name = 'QML'
|
3986
|
+
aliases = ['qml', 'Qt Meta Language', 'Qt modeling Language']
|
3987
|
+
filenames = ['*.qml',]
|
3988
|
+
mimetypes = [ 'application/x-qml',]
|
3989
|
+
|
3990
|
+
|
3991
|
+
# pasted from JavascriptLexer, with some additions
|
3992
|
+
flags = re.DOTALL
|
3993
|
+
tokens = {
|
3994
|
+
'commentsandwhitespace': [
|
3995
|
+
(r'\s+', Text),
|
3996
|
+
(r'<!--', Comment),
|
3997
|
+
(r'//.*?\n', Comment.Single),
|
3998
|
+
(r'/\*.*?\*/', Comment.Multiline)
|
3999
|
+
],
|
4000
|
+
'slashstartsregex': [
|
4001
|
+
include('commentsandwhitespace'),
|
4002
|
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
4003
|
+
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
4004
|
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
4005
|
+
(r'', Text, '#pop')
|
4006
|
+
],
|
4007
|
+
'badregex': [
|
4008
|
+
(r'\n', Text, '#pop')
|
4009
|
+
],
|
4010
|
+
'root' : [
|
4011
|
+
(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
|
4012
|
+
include('commentsandwhitespace'),
|
4013
|
+
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
|
4014
|
+
r'(<<|>>>?|==?|!=?|[-<>+*%&\|\^/])=?', Operator, 'slashstartsregex'),
|
4015
|
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
4016
|
+
(r'[})\].]', Punctuation),
|
4017
|
+
|
4018
|
+
# QML insertions
|
4019
|
+
(r'\bid\s*:\s*[A-Za-z][_A-Za-z.0-9]*',Keyword.Declaration,
|
4020
|
+
'slashstartsregex'),
|
4021
|
+
(r'\b[A-Za-z][_A-Za-z.0-9]*\s*:',Keyword, 'slashstartsregex'),
|
4022
|
+
|
4023
|
+
# the rest from JavascriptLexer
|
4024
|
+
(r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
|
4025
|
+
r'throw|try|catch|finally|new|delete|typeof|instanceof|void|'
|
4026
|
+
r'this)\b', Keyword, 'slashstartsregex'),
|
4027
|
+
(r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
|
4028
|
+
(r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|'
|
4029
|
+
r'extends|final|float|goto|implements|import|int|interface|long|native|'
|
4030
|
+
r'package|private|protected|public|short|static|super|synchronized|throws|'
|
4031
|
+
r'transient|volatile)\b', Keyword.Reserved),
|
4032
|
+
(r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
|
4033
|
+
(r'(Array|Boolean|Date|Error|Function|Math|netscape|'
|
4034
|
+
r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
|
4035
|
+
r'decodeURIComponent|encodeURI|encodeURIComponent|'
|
4036
|
+
r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
|
4037
|
+
r'window)\b', Name.Builtin),
|
4038
|
+
(r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
|
4039
|
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
4040
|
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
4041
|
+
(r'[0-9]+', Number.Integer),
|
4042
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
4043
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
4044
|
+
]
|
4045
|
+
}
|