gitlab-pygments.rb 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +2 -0
- data/README.md +91 -0
- data/Rakefile +78 -0
- data/bench.rb +22 -0
- data/cache-lexers.rb +8 -0
- data/lexers +0 -0
- data/lib/pygments/lexer.rb +148 -0
- data/lib/pygments/mentos.py +344 -0
- data/lib/pygments/popen.rb +389 -0
- data/lib/pygments/version.rb +3 -0
- data/lib/pygments.rb +8 -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 +276 -0
- data/vendor/custom_formatters/gitlab.py +171 -0
- data/vendor/custom_lexers/github.py +362 -0
- data/vendor/pygments-main/AUTHORS +115 -0
- data/vendor/pygments-main/CHANGES +762 -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 +43 -0
- data/vendor/pygments-main/docs/src/lexerdevelopment.txt +551 -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/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 +433 -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 +357 -0
- data/vendor/pygments-main/pygments/formatter.py +92 -0
- data/vendor/pygments-main/pygments/formatters/__init__.py +68 -0
- data/vendor/pygments-main/pygments/formatters/_mapping.py +94 -0
- data/vendor/pygments-main/pygments/formatters/bbcode.py +109 -0
- data/vendor/pygments-main/pygments/formatters/gitlab.py +171 -0
- data/vendor/pygments-main/pygments/formatters/html.py +750 -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 +117 -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 +697 -0
- data/vendor/pygments-main/pygments/lexers/__init__.py +229 -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/_luabuiltins.py +249 -0
- data/vendor/pygments-main/pygments/lexers/_mapping.py +298 -0
- data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +3787 -0
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +232 -0
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +29 -0
- data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +3 -0
- data/vendor/pygments-main/pygments/lexers/agile.py +1803 -0
- data/vendor/pygments-main/pygments/lexers/asm.py +360 -0
- data/vendor/pygments-main/pygments/lexers/compiled.py +2891 -0
- data/vendor/pygments-main/pygments/lexers/dotnet.py +636 -0
- data/vendor/pygments-main/pygments/lexers/functional.py +1832 -0
- data/vendor/pygments-main/pygments/lexers/github.py +362 -0
- data/vendor/pygments-main/pygments/lexers/hdl.py +356 -0
- data/vendor/pygments-main/pygments/lexers/jvm.py +847 -0
- data/vendor/pygments-main/pygments/lexers/math.py +1072 -0
- data/vendor/pygments-main/pygments/lexers/other.py +3339 -0
- data/vendor/pygments-main/pygments/lexers/parsers.py +695 -0
- data/vendor/pygments-main/pygments/lexers/shell.py +361 -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 +1631 -0
- data/vendor/pygments-main/pygments/lexers/text.py +1753 -0
- data/vendor/pygments-main/pygments/lexers/web.py +2864 -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 +130 -0
- data/vendor/pygments-main/pygments/util.py +232 -0
- data/vendor/pygments-main/scripts/check_sources.py +242 -0
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +30 -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 +171 -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 +6 -0
- data/vendor/pygments-main/setup.py +88 -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/CPDictionary.j +611 -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/Errors.scala +18 -0
- data/vendor/pygments-main/tests/examplefiles/File.hy +174 -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/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/badcase.java +2 -0
- data/vendor/pygments-main/tests/examplefiles/batchfile.bat +49 -0
- data/vendor/pygments-main/tests/examplefiles/boot-9.scm +1557 -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 +40 -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.c +2080 -0
- data/vendor/pygments-main/tests/examplefiles/example.cls +15 -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.kt +47 -0
- data/vendor/pygments-main/tests/examplefiles/example.lua +250 -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.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.rb +1852 -0
- data/vendor/pygments-main/tests/examplefiles/example.rhtml +561 -0
- data/vendor/pygments-main/tests/examplefiles/example.sh-session +19 -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.tea +34 -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.yaml +302 -0
- data/vendor/pygments-main/tests/examplefiles/example2.aspx +29 -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/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/html+php_faulty.php +1 -0
- data/vendor/pygments-main/tests/examplefiles/http_request_example +14 -0
- data/vendor/pygments-main/tests/examplefiles/http_response_example +27 -0
- data/vendor/pygments-main/tests/examplefiles/import.hs +4 -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/lighttpd_config.conf +13 -0
- data/vendor/pygments-main/tests/examplefiles/linecontinuation.py +47 -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 +27 -0
- data/vendor/pygments-main/tests/examplefiles/matlabsession_sample.txt +37 -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/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 +25 -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/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/pycon_test.pycon +14 -0
- data/vendor/pygments-main/tests/examplefiles/pytb_test2.pytb +2 -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/ruby_func_def.rb +11 -0
- data/vendor/pygments-main/tests/examplefiles/scilab.sci +30 -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/test.R +119 -0
- data/vendor/pygments-main/tests/examplefiles/test.adb +211 -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.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.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.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.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/truncated.pytb +15 -0
- data/vendor/pygments-main/tests/examplefiles/type.lisp +1202 -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/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 +48 -0
- data/vendor/pygments-main/tests/support.py +15 -0
- data/vendor/pygments-main/tests/test_basic_api.py +294 -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 +97 -0
- data/vendor/pygments-main/tests/test_html_formatter.py +162 -0
- data/vendor/pygments-main/tests/test_latex_formatter.py +55 -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 +116 -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 +492 -0
@@ -0,0 +1,2864 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.web
|
4
|
+
~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexers for web-related languages and markup.
|
7
|
+
|
8
|
+
:copyright: Copyright 2006-2012 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
|
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', 'DuelLexer', 'ScamlLexer',
|
29
|
+
'JadeLexer', 'XQueryLexer', 'DtdLexer', 'DartLexer']
|
30
|
+
|
31
|
+
|
32
|
+
class JavascriptLexer(RegexLexer):
|
33
|
+
"""
|
34
|
+
For JavaScript source code.
|
35
|
+
"""
|
36
|
+
|
37
|
+
name = 'JavaScript'
|
38
|
+
aliases = ['js', 'javascript']
|
39
|
+
filenames = ['*.js', ]
|
40
|
+
mimetypes = ['application/javascript', 'application/x-javascript',
|
41
|
+
'text/x-javascript', 'text/javascript', ]
|
42
|
+
|
43
|
+
flags = re.DOTALL
|
44
|
+
tokens = {
|
45
|
+
'commentsandwhitespace': [
|
46
|
+
(r'\s+', Text),
|
47
|
+
(r'<!--', Comment),
|
48
|
+
(r'//.*?\n', Comment.Single),
|
49
|
+
(r'/\*.*?\*/', Comment.Multiline)
|
50
|
+
],
|
51
|
+
'slashstartsregex': [
|
52
|
+
include('commentsandwhitespace'),
|
53
|
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
54
|
+
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
55
|
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
56
|
+
(r'', Text, '#pop')
|
57
|
+
],
|
58
|
+
'badregex': [
|
59
|
+
(r'\n', Text, '#pop')
|
60
|
+
],
|
61
|
+
'root': [
|
62
|
+
(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
|
63
|
+
include('commentsandwhitespace'),
|
64
|
+
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
|
65
|
+
r'(<<|>>>?|==?|!=?|[-<>+*%&\|\^/])=?', Operator, 'slashstartsregex'),
|
66
|
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
67
|
+
(r'[})\].]', Punctuation),
|
68
|
+
(r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
|
69
|
+
r'throw|try|catch|finally|new|delete|typeof|instanceof|void|'
|
70
|
+
r'this)\b', Keyword, 'slashstartsregex'),
|
71
|
+
(r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
|
72
|
+
(r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|'
|
73
|
+
r'extends|final|float|goto|implements|import|int|interface|long|native|'
|
74
|
+
r'package|private|protected|public|short|static|super|synchronized|throws|'
|
75
|
+
r'transient|volatile)\b', Keyword.Reserved),
|
76
|
+
(r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
|
77
|
+
(r'(Array|Boolean|Date|Error|Function|Math|netscape|'
|
78
|
+
r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
|
79
|
+
r'decodeURIComponent|encodeURI|encodeURIComponent|'
|
80
|
+
r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
|
81
|
+
r'window)\b', Name.Builtin),
|
82
|
+
(r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
|
83
|
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
84
|
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
85
|
+
(r'[0-9]+', Number.Integer),
|
86
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
87
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
88
|
+
]
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
class JSONLexer(RegexLexer):
|
93
|
+
"""
|
94
|
+
For JSON data structures.
|
95
|
+
|
96
|
+
*New in Pygments 1.5.*
|
97
|
+
"""
|
98
|
+
|
99
|
+
name = 'JSON'
|
100
|
+
aliases = ['json']
|
101
|
+
filenames = ['*.json']
|
102
|
+
mimetypes = [ 'application/json', ]
|
103
|
+
|
104
|
+
# integer part of a number
|
105
|
+
int_part = r'-?(0|[1-9]\d*)'
|
106
|
+
|
107
|
+
# fractional part of a number
|
108
|
+
frac_part = r'\.\d+'
|
109
|
+
|
110
|
+
# exponential part of a number
|
111
|
+
exp_part = r'[eE](\+|-)?\d+'
|
112
|
+
|
113
|
+
|
114
|
+
flags = re.DOTALL
|
115
|
+
tokens = {
|
116
|
+
'whitespace': [
|
117
|
+
(r'\s+', Text),
|
118
|
+
],
|
119
|
+
|
120
|
+
# represents a simple terminal value
|
121
|
+
'simplevalue': [
|
122
|
+
(r'(true|false|null)\b', Keyword.Constant),
|
123
|
+
(('%(int_part)s(%(frac_part)s%(exp_part)s|'
|
124
|
+
'%(exp_part)s|%(frac_part)s)') % vars(),
|
125
|
+
Number.Float),
|
126
|
+
(int_part, Number.Integer),
|
127
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
128
|
+
],
|
129
|
+
|
130
|
+
|
131
|
+
# the right hand side of an object, after the attribute name
|
132
|
+
'objectattribute': [
|
133
|
+
include('value'),
|
134
|
+
(r':', Punctuation),
|
135
|
+
# comma terminates the attribute but expects more
|
136
|
+
(r',', Punctuation, '#pop'),
|
137
|
+
# a closing bracket terminates the entire object, so pop twice
|
138
|
+
(r'}', Punctuation, ('#pop', '#pop')),
|
139
|
+
],
|
140
|
+
|
141
|
+
# a json object - { attr, attr, ... }
|
142
|
+
'objectvalue': [
|
143
|
+
include('whitespace'),
|
144
|
+
(r'"(\\\\|\\"|[^"])*"', Name.Tag, 'objectattribute'),
|
145
|
+
(r'}', Punctuation, '#pop'),
|
146
|
+
],
|
147
|
+
|
148
|
+
# json array - [ value, value, ... }
|
149
|
+
'arrayvalue': [
|
150
|
+
include('whitespace'),
|
151
|
+
include('value'),
|
152
|
+
(r',', Punctuation),
|
153
|
+
(r']', Punctuation, '#pop'),
|
154
|
+
],
|
155
|
+
|
156
|
+
# a json value - either a simple value or a complex value (object or array)
|
157
|
+
'value': [
|
158
|
+
include('whitespace'),
|
159
|
+
include('simplevalue'),
|
160
|
+
(r'{', Punctuation, 'objectvalue'),
|
161
|
+
(r'\[', Punctuation, 'arrayvalue'),
|
162
|
+
],
|
163
|
+
|
164
|
+
|
165
|
+
# the root of a json document whould be a value
|
166
|
+
'root': [
|
167
|
+
include('value'),
|
168
|
+
],
|
169
|
+
|
170
|
+
}
|
171
|
+
|
172
|
+
|
173
|
+
class ActionScriptLexer(RegexLexer):
|
174
|
+
"""
|
175
|
+
For ActionScript source code.
|
176
|
+
|
177
|
+
*New in Pygments 0.9.*
|
178
|
+
"""
|
179
|
+
|
180
|
+
name = 'ActionScript'
|
181
|
+
aliases = ['as', 'actionscript']
|
182
|
+
filenames = ['*.as']
|
183
|
+
mimetypes = ['application/x-actionscript3', 'text/x-actionscript3',
|
184
|
+
'text/actionscript3']
|
185
|
+
|
186
|
+
flags = re.DOTALL
|
187
|
+
tokens = {
|
188
|
+
'root': [
|
189
|
+
(r'\s+', Text),
|
190
|
+
(r'//.*?\n', Comment.Single),
|
191
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
192
|
+
(r'/(\\\\|\\/|[^/\n])*/[gim]*', String.Regex),
|
193
|
+
(r'[~\^\*!%&<>\|+=:;,/?\\-]+', Operator),
|
194
|
+
(r'[{}\[\]();.]+', Punctuation),
|
195
|
+
(r'(case|default|for|each|in|while|do|break|return|continue|if|else|'
|
196
|
+
r'throw|try|catch|var|with|new|typeof|arguments|instanceof|this|'
|
197
|
+
r'switch)\b', Keyword),
|
198
|
+
(r'(class|public|final|internal|native|override|private|protected|'
|
199
|
+
r'static|import|extends|implements|interface|intrinsic|return|super|'
|
200
|
+
r'dynamic|function|const|get|namespace|package|set)\b',
|
201
|
+
Keyword.Declaration),
|
202
|
+
(r'(true|false|null|NaN|Infinity|-Infinity|undefined|Void)\b',
|
203
|
+
Keyword.Constant),
|
204
|
+
(r'(Accessibility|AccessibilityProperties|ActionScriptVersion|'
|
205
|
+
r'ActivityEvent|AntiAliasType|ApplicationDomain|AsBroadcaster|Array|'
|
206
|
+
r'AsyncErrorEvent|AVM1Movie|BevelFilter|Bitmap|BitmapData|'
|
207
|
+
r'BitmapDataChannel|BitmapFilter|BitmapFilterQuality|BitmapFilterType|'
|
208
|
+
r'BlendMode|BlurFilter|Boolean|ByteArray|Camera|Capabilities|CapsStyle|'
|
209
|
+
r'Class|Color|ColorMatrixFilter|ColorTransform|ContextMenu|'
|
210
|
+
r'ContextMenuBuiltInItems|ContextMenuEvent|ContextMenuItem|'
|
211
|
+
r'ConvultionFilter|CSMSettings|DataEvent|Date|DefinitionError|'
|
212
|
+
r'DeleteObjectSample|Dictionary|DisplacmentMapFilter|DisplayObject|'
|
213
|
+
r'DisplacmentMapFilterMode|DisplayObjectContainer|DropShadowFilter|'
|
214
|
+
r'Endian|EOFError|Error|ErrorEvent|EvalError|Event|EventDispatcher|'
|
215
|
+
r'EventPhase|ExternalInterface|FileFilter|FileReference|'
|
216
|
+
r'FileReferenceList|FocusDirection|FocusEvent|Font|FontStyle|FontType|'
|
217
|
+
r'FrameLabel|FullScreenEvent|Function|GlowFilter|GradientBevelFilter|'
|
218
|
+
r'GradientGlowFilter|GradientType|Graphics|GridFitType|HTTPStatusEvent|'
|
219
|
+
r'IBitmapDrawable|ID3Info|IDataInput|IDataOutput|IDynamicPropertyOutput'
|
220
|
+
r'IDynamicPropertyWriter|IEventDispatcher|IExternalizable|'
|
221
|
+
r'IllegalOperationError|IME|IMEConversionMode|IMEEvent|int|'
|
222
|
+
r'InteractiveObject|InterpolationMethod|InvalidSWFError|InvokeEvent|'
|
223
|
+
r'IOError|IOErrorEvent|JointStyle|Key|Keyboard|KeyboardEvent|KeyLocation|'
|
224
|
+
r'LineScaleMode|Loader|LoaderContext|LoaderInfo|LoadVars|LocalConnection|'
|
225
|
+
r'Locale|Math|Matrix|MemoryError|Microphone|MorphShape|Mouse|MouseEvent|'
|
226
|
+
r'MovieClip|MovieClipLoader|Namespace|NetConnection|NetStatusEvent|'
|
227
|
+
r'NetStream|NewObjectSample|Number|Object|ObjectEncoding|PixelSnapping|'
|
228
|
+
r'Point|PrintJob|PrintJobOptions|PrintJobOrientation|ProgressEvent|Proxy|'
|
229
|
+
r'QName|RangeError|Rectangle|ReferenceError|RegExp|Responder|Sample|Scene|'
|
230
|
+
r'ScriptTimeoutError|Security|SecurityDomain|SecurityError|'
|
231
|
+
r'SecurityErrorEvent|SecurityPanel|Selection|Shape|SharedObject|'
|
232
|
+
r'SharedObjectFlushStatus|SimpleButton|Socket|Sound|SoundChannel|'
|
233
|
+
r'SoundLoaderContext|SoundMixer|SoundTransform|SpreadMethod|Sprite|'
|
234
|
+
r'StackFrame|StackOverflowError|Stage|StageAlign|StageDisplayState|'
|
235
|
+
r'StageQuality|StageScaleMode|StaticText|StatusEvent|String|StyleSheet|'
|
236
|
+
r'SWFVersion|SyncEvent|SyntaxError|System|TextColorType|TextField|'
|
237
|
+
r'TextFieldAutoSize|TextFieldType|TextFormat|TextFormatAlign|'
|
238
|
+
r'TextLineMetrics|TextRenderer|TextSnapshot|Timer|TimerEvent|Transform|'
|
239
|
+
r'TypeError|uint|URIError|URLLoader|URLLoaderDataFormat|URLRequest|'
|
240
|
+
r'URLRequestHeader|URLRequestMethod|URLStream|URLVariabeles|VerifyError|'
|
241
|
+
r'Video|XML|XMLDocument|XMLList|XMLNode|XMLNodeType|XMLSocket|XMLUI)\b',
|
242
|
+
Name.Builtin),
|
243
|
+
(r'(decodeURI|decodeURIComponent|encodeURI|escape|eval|isFinite|isNaN|'
|
244
|
+
r'isXMLName|clearInterval|fscommand|getTimer|getURL|getVersion|'
|
245
|
+
r'isFinite|parseFloat|parseInt|setInterval|trace|updateAfterEvent|'
|
246
|
+
r'unescape)\b',Name.Function),
|
247
|
+
(r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
|
248
|
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
249
|
+
(r'0x[0-9a-f]+', Number.Hex),
|
250
|
+
(r'[0-9]+', Number.Integer),
|
251
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
252
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
253
|
+
]
|
254
|
+
}
|
255
|
+
|
256
|
+
|
257
|
+
class ActionScript3Lexer(RegexLexer):
|
258
|
+
"""
|
259
|
+
For ActionScript 3 source code.
|
260
|
+
|
261
|
+
*New in Pygments 0.11.*
|
262
|
+
"""
|
263
|
+
|
264
|
+
name = 'ActionScript 3'
|
265
|
+
aliases = ['as3', 'actionscript3']
|
266
|
+
filenames = ['*.as']
|
267
|
+
mimetypes = ['application/x-actionscript', 'text/x-actionscript',
|
268
|
+
'text/actionscript']
|
269
|
+
|
270
|
+
identifier = r'[$a-zA-Z_][a-zA-Z0-9_]*'
|
271
|
+
typeidentifier = identifier + '(?:\.<\w+>)?'
|
272
|
+
|
273
|
+
flags = re.DOTALL | re.MULTILINE
|
274
|
+
tokens = {
|
275
|
+
'root': [
|
276
|
+
(r'\s+', Text),
|
277
|
+
(r'(function\s+)(' + identifier + r')(\s*)(\()',
|
278
|
+
bygroups(Keyword.Declaration, Name.Function, Text, Operator),
|
279
|
+
'funcparams'),
|
280
|
+
(r'(var|const)(\s+)(' + identifier + r')(\s*)(:)(\s*)(' +
|
281
|
+
typeidentifier + r')',
|
282
|
+
bygroups(Keyword.Declaration, Text, Name, Text, Punctuation, Text,
|
283
|
+
Keyword.Type)),
|
284
|
+
(r'(import|package)(\s+)((?:' + identifier + r'|\.)+)(\s*)',
|
285
|
+
bygroups(Keyword, Text, Name.Namespace, Text)),
|
286
|
+
(r'(new)(\s+)(' + typeidentifier + r')(\s*)(\()',
|
287
|
+
bygroups(Keyword, Text, Keyword.Type, Text, Operator)),
|
288
|
+
(r'//.*?\n', Comment.Single),
|
289
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
290
|
+
(r'/(\\\\|\\/|[^\n])*/[gisx]*', String.Regex),
|
291
|
+
(r'(\.)(' + identifier + r')', bygroups(Operator, Name.Attribute)),
|
292
|
+
(r'(case|default|for|each|in|while|do|break|return|continue|if|else|'
|
293
|
+
r'throw|try|catch|with|new|typeof|arguments|instanceof|this|'
|
294
|
+
r'switch|import|include|as|is)\b',
|
295
|
+
Keyword),
|
296
|
+
(r'(class|public|final|internal|native|override|private|protected|'
|
297
|
+
r'static|import|extends|implements|interface|intrinsic|return|super|'
|
298
|
+
r'dynamic|function|const|get|namespace|package|set)\b',
|
299
|
+
Keyword.Declaration),
|
300
|
+
(r'(true|false|null|NaN|Infinity|-Infinity|undefined|void)\b',
|
301
|
+
Keyword.Constant),
|
302
|
+
(r'(decodeURI|decodeURIComponent|encodeURI|escape|eval|isFinite|isNaN|'
|
303
|
+
r'isXMLName|clearInterval|fscommand|getTimer|getURL|getVersion|'
|
304
|
+
r'isFinite|parseFloat|parseInt|setInterval|trace|updateAfterEvent|'
|
305
|
+
r'unescape)\b', Name.Function),
|
306
|
+
(identifier, Name),
|
307
|
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
308
|
+
(r'0x[0-9a-f]+', Number.Hex),
|
309
|
+
(r'[0-9]+', Number.Integer),
|
310
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
311
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
312
|
+
(r'[~\^\*!%&<>\|+=:;,/?\\{}\[\]().-]+', Operator),
|
313
|
+
],
|
314
|
+
'funcparams': [
|
315
|
+
(r'\s+', Text),
|
316
|
+
(r'(\s*)(\.\.\.)?(' + identifier + r')(\s*)(:)(\s*)(' +
|
317
|
+
typeidentifier + r'|\*)(\s*)',
|
318
|
+
bygroups(Text, Punctuation, Name, Text, Operator, Text,
|
319
|
+
Keyword.Type, Text), 'defval'),
|
320
|
+
(r'\)', Operator, 'type')
|
321
|
+
],
|
322
|
+
'type': [
|
323
|
+
(r'(\s*)(:)(\s*)(' + typeidentifier + r'|\*)',
|
324
|
+
bygroups(Text, Operator, Text, Keyword.Type), '#pop:2'),
|
325
|
+
(r'\s*', Text, '#pop:2')
|
326
|
+
],
|
327
|
+
'defval': [
|
328
|
+
(r'(=)(\s*)([^(),]+)(\s*)(,?)',
|
329
|
+
bygroups(Operator, Text, using(this), Text, Operator), '#pop'),
|
330
|
+
(r',?', Operator, '#pop')
|
331
|
+
]
|
332
|
+
}
|
333
|
+
|
334
|
+
def analyse_text(text):
|
335
|
+
if re.match(r'\w+\s*:\s*\w', text):
|
336
|
+
return 0.3
|
337
|
+
return 0
|
338
|
+
|
339
|
+
|
340
|
+
class CssLexer(RegexLexer):
|
341
|
+
"""
|
342
|
+
For CSS (Cascading Style Sheets).
|
343
|
+
"""
|
344
|
+
|
345
|
+
name = 'CSS'
|
346
|
+
aliases = ['css']
|
347
|
+
filenames = ['*.css']
|
348
|
+
mimetypes = ['text/css']
|
349
|
+
|
350
|
+
tokens = {
|
351
|
+
'root': [
|
352
|
+
include('basics'),
|
353
|
+
],
|
354
|
+
'basics': [
|
355
|
+
(r'\s+', Text),
|
356
|
+
(r'/\*(?:.|\n)*?\*/', Comment),
|
357
|
+
(r'{', Punctuation, 'content'),
|
358
|
+
(r'\:[a-zA-Z0-9_-]+', Name.Decorator),
|
359
|
+
(r'\.[a-zA-Z0-9_-]+', Name.Class),
|
360
|
+
(r'\#[a-zA-Z0-9_-]+', Name.Function),
|
361
|
+
(r'@[a-zA-Z0-9_-]+', Keyword, 'atrule'),
|
362
|
+
(r'[a-zA-Z0-9_-]+', Name.Tag),
|
363
|
+
(r'[~\^\*!%&\[\]\(\)<>\|+=@:;,./?-]', Operator),
|
364
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
365
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single)
|
366
|
+
],
|
367
|
+
'atrule': [
|
368
|
+
(r'{', Punctuation, 'atcontent'),
|
369
|
+
(r';', Punctuation, '#pop'),
|
370
|
+
include('basics'),
|
371
|
+
],
|
372
|
+
'atcontent': [
|
373
|
+
include('basics'),
|
374
|
+
(r'}', Punctuation, '#pop:2'),
|
375
|
+
],
|
376
|
+
'content': [
|
377
|
+
(r'\s+', Text),
|
378
|
+
(r'}', Punctuation, '#pop'),
|
379
|
+
(r'url\(.*?\)', String.Other),
|
380
|
+
(r'^@.*?$', Comment.Preproc),
|
381
|
+
(r'(azimuth|background-attachment|background-color|'
|
382
|
+
r'background-image|background-position|background-repeat|'
|
383
|
+
r'background|border-bottom-color|border-bottom-style|'
|
384
|
+
r'border-bottom-width|border-left-color|border-left-style|'
|
385
|
+
r'border-left-width|border-right|border-right-color|'
|
386
|
+
r'border-right-style|border-right-width|border-top-color|'
|
387
|
+
r'border-top-style|border-top-width|border-bottom|'
|
388
|
+
r'border-collapse|border-left|border-width|border-color|'
|
389
|
+
r'border-spacing|border-style|border-top|border|caption-side|'
|
390
|
+
r'clear|clip|color|content|counter-increment|counter-reset|'
|
391
|
+
r'cue-after|cue-before|cue|cursor|direction|display|'
|
392
|
+
r'elevation|empty-cells|float|font-family|font-size|'
|
393
|
+
r'font-size-adjust|font-stretch|font-style|font-variant|'
|
394
|
+
r'font-weight|font|height|letter-spacing|line-height|'
|
395
|
+
r'list-style-type|list-style-image|list-style-position|'
|
396
|
+
r'list-style|margin-bottom|margin-left|margin-right|'
|
397
|
+
r'margin-top|margin|marker-offset|marks|max-height|max-width|'
|
398
|
+
r'min-height|min-width|opacity|orphans|outline|outline-color|'
|
399
|
+
r'outline-style|outline-width|overflow(?:-x|-y)?|padding-bottom|'
|
400
|
+
r'padding-left|padding-right|padding-top|padding|page|'
|
401
|
+
r'page-break-after|page-break-before|page-break-inside|'
|
402
|
+
r'pause-after|pause-before|pause|pitch|pitch-range|'
|
403
|
+
r'play-during|position|quotes|richness|right|size|'
|
404
|
+
r'speak-header|speak-numeral|speak-punctuation|speak|'
|
405
|
+
r'speech-rate|stress|table-layout|text-align|text-decoration|'
|
406
|
+
r'text-indent|text-shadow|text-transform|top|unicode-bidi|'
|
407
|
+
r'vertical-align|visibility|voice-family|volume|white-space|'
|
408
|
+
r'widows|width|word-spacing|z-index|bottom|left|'
|
409
|
+
r'above|absolute|always|armenian|aural|auto|avoid|baseline|'
|
410
|
+
r'behind|below|bidi-override|blink|block|bold|bolder|both|'
|
411
|
+
r'capitalize|center-left|center-right|center|circle|'
|
412
|
+
r'cjk-ideographic|close-quote|collapse|condensed|continuous|'
|
413
|
+
r'crop|crosshair|cross|cursive|dashed|decimal-leading-zero|'
|
414
|
+
r'decimal|default|digits|disc|dotted|double|e-resize|embed|'
|
415
|
+
r'extra-condensed|extra-expanded|expanded|fantasy|far-left|'
|
416
|
+
r'far-right|faster|fast|fixed|georgian|groove|hebrew|help|'
|
417
|
+
r'hidden|hide|higher|high|hiragana-iroha|hiragana|icon|'
|
418
|
+
r'inherit|inline-table|inline|inset|inside|invert|italic|'
|
419
|
+
r'justify|katakana-iroha|katakana|landscape|larger|large|'
|
420
|
+
r'left-side|leftwards|level|lighter|line-through|list-item|'
|
421
|
+
r'loud|lower-alpha|lower-greek|lower-roman|lowercase|ltr|'
|
422
|
+
r'lower|low|medium|message-box|middle|mix|monospace|'
|
423
|
+
r'n-resize|narrower|ne-resize|no-close-quote|no-open-quote|'
|
424
|
+
r'no-repeat|none|normal|nowrap|nw-resize|oblique|once|'
|
425
|
+
r'open-quote|outset|outside|overline|pointer|portrait|px|'
|
426
|
+
r'relative|repeat-x|repeat-y|repeat|rgb|ridge|right-side|'
|
427
|
+
r'rightwards|s-resize|sans-serif|scroll|se-resize|'
|
428
|
+
r'semi-condensed|semi-expanded|separate|serif|show|silent|'
|
429
|
+
r'slow|slower|small-caps|small-caption|smaller|soft|solid|'
|
430
|
+
r'spell-out|square|static|status-bar|super|sw-resize|'
|
431
|
+
r'table-caption|table-cell|table-column|table-column-group|'
|
432
|
+
r'table-footer-group|table-header-group|table-row|'
|
433
|
+
r'table-row-group|text|text-bottom|text-top|thick|thin|'
|
434
|
+
r'transparent|ultra-condensed|ultra-expanded|underline|'
|
435
|
+
r'upper-alpha|upper-latin|upper-roman|uppercase|url|'
|
436
|
+
r'visible|w-resize|wait|wider|x-fast|x-high|x-large|x-loud|'
|
437
|
+
r'x-low|x-small|x-soft|xx-large|xx-small|yes)\b', Keyword),
|
438
|
+
(r'(indigo|gold|firebrick|indianred|yellow|darkolivegreen|'
|
439
|
+
r'darkseagreen|mediumvioletred|mediumorchid|chartreuse|'
|
440
|
+
r'mediumslateblue|black|springgreen|crimson|lightsalmon|brown|'
|
441
|
+
r'turquoise|olivedrab|cyan|silver|skyblue|gray|darkturquoise|'
|
442
|
+
r'goldenrod|darkgreen|darkviolet|darkgray|lightpink|teal|'
|
443
|
+
r'darkmagenta|lightgoldenrodyellow|lavender|yellowgreen|thistle|'
|
444
|
+
r'violet|navy|orchid|blue|ghostwhite|honeydew|cornflowerblue|'
|
445
|
+
r'darkblue|darkkhaki|mediumpurple|cornsilk|red|bisque|slategray|'
|
446
|
+
r'darkcyan|khaki|wheat|deepskyblue|darkred|steelblue|aliceblue|'
|
447
|
+
r'gainsboro|mediumturquoise|floralwhite|coral|purple|lightgrey|'
|
448
|
+
r'lightcyan|darksalmon|beige|azure|lightsteelblue|oldlace|'
|
449
|
+
r'greenyellow|royalblue|lightseagreen|mistyrose|sienna|'
|
450
|
+
r'lightcoral|orangered|navajowhite|lime|palegreen|burlywood|'
|
451
|
+
r'seashell|mediumspringgreen|fuchsia|papayawhip|blanchedalmond|'
|
452
|
+
r'peru|aquamarine|white|darkslategray|ivory|dodgerblue|'
|
453
|
+
r'lemonchiffon|chocolate|orange|forestgreen|slateblue|olive|'
|
454
|
+
r'mintcream|antiquewhite|darkorange|cadetblue|moccasin|'
|
455
|
+
r'limegreen|saddlebrown|darkslateblue|lightskyblue|deeppink|'
|
456
|
+
r'plum|aqua|darkgoldenrod|maroon|sandybrown|magenta|tan|'
|
457
|
+
r'rosybrown|pink|lightblue|palevioletred|mediumseagreen|'
|
458
|
+
r'dimgray|powderblue|seagreen|snow|mediumblue|midnightblue|'
|
459
|
+
r'paleturquoise|palegoldenrod|whitesmoke|darkorchid|salmon|'
|
460
|
+
r'lightslategray|lawngreen|lightgreen|tomato|hotpink|'
|
461
|
+
r'lightyellow|lavenderblush|linen|mediumaquamarine|green|'
|
462
|
+
r'blueviolet|peachpuff)\b', Name.Builtin),
|
463
|
+
(r'\!important', Comment.Preproc),
|
464
|
+
(r'/\*(?:.|\n)*?\*/', Comment),
|
465
|
+
(r'\#[a-zA-Z0-9]{1,6}', Number),
|
466
|
+
(r'[\.-]?[0-9]*[\.]?[0-9]+(em|px|\%|pt|pc|in|mm|cm|ex|s)\b', Number),
|
467
|
+
(r'-?[0-9]+', Number),
|
468
|
+
(r'[~\^\*!%&<>\|+=@:,./?-]+', Operator),
|
469
|
+
(r'[\[\]();]+', Punctuation),
|
470
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
471
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
472
|
+
(r'[a-zA-Z_][a-zA-Z0-9_]*', Name)
|
473
|
+
]
|
474
|
+
}
|
475
|
+
|
476
|
+
|
477
|
+
class ObjectiveJLexer(RegexLexer):
|
478
|
+
"""
|
479
|
+
For Objective-J source code with preprocessor directives.
|
480
|
+
|
481
|
+
*New in Pygments 1.3.*
|
482
|
+
"""
|
483
|
+
|
484
|
+
name = 'Objective-J'
|
485
|
+
aliases = ['objective-j', 'objectivej', 'obj-j', 'objj']
|
486
|
+
filenames = ['*.j']
|
487
|
+
mimetypes = ['text/x-objective-j']
|
488
|
+
|
489
|
+
#: optional Comment or Whitespace
|
490
|
+
_ws = r'(?:\s|//.*?\n|/[*].*?[*]/)*'
|
491
|
+
|
492
|
+
flags = re.DOTALL | re.MULTILINE
|
493
|
+
|
494
|
+
tokens = {
|
495
|
+
'root': [
|
496
|
+
include('whitespace'),
|
497
|
+
|
498
|
+
# function definition
|
499
|
+
(r'^(' + _ws + r'[\+-]' + _ws + r')([\(a-zA-Z_].*?[^\(])(' + _ws + '{)',
|
500
|
+
bygroups(using(this), using(this, state='function_signature'),
|
501
|
+
using(this))),
|
502
|
+
|
503
|
+
# class definition
|
504
|
+
(r'(@interface|@implementation)(\s+)', bygroups(Keyword, Text),
|
505
|
+
'classname'),
|
506
|
+
(r'(@class|@protocol)(\s*)', bygroups(Keyword, Text),
|
507
|
+
'forward_classname'),
|
508
|
+
(r'(\s*)(@end)(\s*)', bygroups(Text, Keyword, Text)),
|
509
|
+
|
510
|
+
include('statements'),
|
511
|
+
('[{\(\)}]', Punctuation),
|
512
|
+
(';', Punctuation),
|
513
|
+
],
|
514
|
+
'whitespace': [
|
515
|
+
(r'(@import)(\s+)("(?:\\\\|\\"|[^"])*")',
|
516
|
+
bygroups(Comment.Preproc, Text, String.Double)),
|
517
|
+
(r'(@import)(\s+)(<(?:\\\\|\\>|[^>])*>)',
|
518
|
+
bygroups(Comment.Preproc, Text, String.Double)),
|
519
|
+
(r'(#(?:include|import))(\s+)("(?:\\\\|\\"|[^"])*")',
|
520
|
+
bygroups(Comment.Preproc, Text, String.Double)),
|
521
|
+
(r'(#(?:include|import))(\s+)(<(?:\\\\|\\>|[^>])*>)',
|
522
|
+
bygroups(Comment.Preproc, Text, String.Double)),
|
523
|
+
|
524
|
+
(r'#if\s+0', Comment.Preproc, 'if0'),
|
525
|
+
(r'#', Comment.Preproc, 'macro'),
|
526
|
+
|
527
|
+
(r'\n', Text),
|
528
|
+
(r'\s+', Text),
|
529
|
+
(r'\\\n', Text), # line continuation
|
530
|
+
(r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
|
531
|
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
532
|
+
(r'<!--', Comment),
|
533
|
+
],
|
534
|
+
'slashstartsregex': [
|
535
|
+
include('whitespace'),
|
536
|
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
537
|
+
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
538
|
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
539
|
+
(r'', Text, '#pop'),
|
540
|
+
],
|
541
|
+
'badregex': [
|
542
|
+
(r'\n', Text, '#pop'),
|
543
|
+
],
|
544
|
+
'statements': [
|
545
|
+
(r'(L|@)?"', String, 'string'),
|
546
|
+
(r"(L|@)?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'",
|
547
|
+
String.Char),
|
548
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
549
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
550
|
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
|
551
|
+
(r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
552
|
+
(r'0x[0-9a-fA-F]+[Ll]?', Number.Hex),
|
553
|
+
(r'0[0-7]+[Ll]?', Number.Oct),
|
554
|
+
(r'\d+[Ll]?', Number.Integer),
|
555
|
+
|
556
|
+
(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
|
557
|
+
|
558
|
+
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
|
559
|
+
r'(<<|>>>?|==?|!=?|[-<>+*%&\|\^/])=?',
|
560
|
+
Operator, 'slashstartsregex'),
|
561
|
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
562
|
+
(r'[})\].]', Punctuation),
|
563
|
+
|
564
|
+
(r'(for|in|while|do|break|return|continue|switch|case|default|if|'
|
565
|
+
r'else|throw|try|catch|finally|new|delete|typeof|instanceof|void|'
|
566
|
+
r'prototype|__proto__)\b', Keyword, 'slashstartsregex'),
|
567
|
+
|
568
|
+
(r'(var|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
|
569
|
+
|
570
|
+
(r'(@selector|@private|@protected|@public|@encode|'
|
571
|
+
r'@synchronized|@try|@throw|@catch|@finally|@end|@property|'
|
572
|
+
r'@synthesize|@dynamic|@for|@accessors|new)\b', Keyword),
|
573
|
+
|
574
|
+
(r'(int|long|float|short|double|char|unsigned|signed|void|'
|
575
|
+
r'id|BOOL|bool|boolean|IBOutlet|IBAction|SEL|@outlet|@action)\b',
|
576
|
+
Keyword.Type),
|
577
|
+
|
578
|
+
(r'(self|super)\b', Name.Builtin),
|
579
|
+
|
580
|
+
(r'(TRUE|YES|FALSE|NO|Nil|nil|NULL)\b', Keyword.Constant),
|
581
|
+
(r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
|
582
|
+
(r'(ABS|ASIN|ACOS|ATAN|ATAN2|SIN|COS|TAN|EXP|POW|CEIL|FLOOR|ROUND|'
|
583
|
+
r'MIN|MAX|RAND|SQRT|E|LN2|LN10|LOG2E|LOG10E|PI|PI2|PI_2|SQRT1_2|'
|
584
|
+
r'SQRT2)\b', Keyword.Constant),
|
585
|
+
|
586
|
+
(r'(Array|Boolean|Date|Error|Function|Math|netscape|'
|
587
|
+
r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
|
588
|
+
r'decodeURIComponent|encodeURI|encodeURIComponent|'
|
589
|
+
r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
|
590
|
+
r'window)\b', Name.Builtin),
|
591
|
+
|
592
|
+
(r'([$a-zA-Z_][a-zA-Z0-9_]*)(' + _ws + r')(?=\()',
|
593
|
+
bygroups(Name.Function, using(this))),
|
594
|
+
|
595
|
+
(r'[$a-zA-Z_][a-zA-Z0-9_]*', Name),
|
596
|
+
],
|
597
|
+
'classname' : [
|
598
|
+
# interface definition that inherits
|
599
|
+
(r'([a-zA-Z_][a-zA-Z0-9_]*)(' + _ws + r':' + _ws +
|
600
|
+
r')([a-zA-Z_][a-zA-Z0-9_]*)?',
|
601
|
+
bygroups(Name.Class, using(this), Name.Class), '#pop'),
|
602
|
+
# interface definition for a category
|
603
|
+
(r'([a-zA-Z_][a-zA-Z0-9_]*)(' + _ws + r'\()([a-zA-Z_][a-zA-Z0-9_]*)(\))',
|
604
|
+
bygroups(Name.Class, using(this), Name.Label, Text), '#pop'),
|
605
|
+
# simple interface / implementation
|
606
|
+
(r'([a-zA-Z_][a-zA-Z0-9_]*)', Name.Class, '#pop'),
|
607
|
+
],
|
608
|
+
'forward_classname' : [
|
609
|
+
(r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*,\s*)',
|
610
|
+
bygroups(Name.Class, Text), '#push'),
|
611
|
+
(r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*;?)',
|
612
|
+
bygroups(Name.Class, Text), '#pop'),
|
613
|
+
],
|
614
|
+
'function_signature': [
|
615
|
+
include('whitespace'),
|
616
|
+
|
617
|
+
# start of a selector w/ parameters
|
618
|
+
(r'(\(' + _ws + r')' # open paren
|
619
|
+
r'([a-zA-Z_][a-zA-Z0-9_]+)' # return type
|
620
|
+
r'(' + _ws + r'\)' + _ws + r')' # close paren
|
621
|
+
r'([$a-zA-Z_][a-zA-Z0-9_]+' + _ws + r':)', # function name
|
622
|
+
bygroups(using(this), Keyword.Type, using(this),
|
623
|
+
Name.Function), 'function_parameters'),
|
624
|
+
|
625
|
+
# no-param function
|
626
|
+
(r'(\(' + _ws + r')' # open paren
|
627
|
+
r'([a-zA-Z_][a-zA-Z0-9_]+)' # return type
|
628
|
+
r'(' + _ws + r'\)' + _ws + r')' # close paren
|
629
|
+
r'([$a-zA-Z_][a-zA-Z0-9_]+)', # function name
|
630
|
+
bygroups(using(this), Keyword.Type, using(this),
|
631
|
+
Name.Function), "#pop"),
|
632
|
+
|
633
|
+
# no return type given, start of a selector w/ parameters
|
634
|
+
(r'([$a-zA-Z_][a-zA-Z0-9_]+' + _ws + r':)', # function name
|
635
|
+
bygroups (Name.Function), 'function_parameters'),
|
636
|
+
|
637
|
+
# no return type given, no-param function
|
638
|
+
(r'([$a-zA-Z_][a-zA-Z0-9_]+)', # function name
|
639
|
+
bygroups(Name.Function), "#pop"),
|
640
|
+
|
641
|
+
('', Text, '#pop'),
|
642
|
+
],
|
643
|
+
'function_parameters': [
|
644
|
+
include('whitespace'),
|
645
|
+
|
646
|
+
# parameters
|
647
|
+
(r'(\(' + _ws + ')' # open paren
|
648
|
+
r'([^\)]+)' # type
|
649
|
+
r'(' + _ws + r'\)' + _ws + r')' # close paren
|
650
|
+
r'([$a-zA-Z_][a-zA-Z0-9_]+)', # param name
|
651
|
+
bygroups(using(this), Keyword.Type, using(this), Text)),
|
652
|
+
|
653
|
+
# one piece of a selector name
|
654
|
+
(r'([$a-zA-Z_][a-zA-Z0-9_]+' + _ws + r':)', # function name
|
655
|
+
Name.Function),
|
656
|
+
|
657
|
+
# smallest possible selector piece
|
658
|
+
(r'(:)', Name.Function),
|
659
|
+
|
660
|
+
# var args
|
661
|
+
(r'(,' + _ws + r'\.\.\.)', using(this)),
|
662
|
+
|
663
|
+
# param name
|
664
|
+
(r'([$a-zA-Z_][a-zA-Z0-9_]+)', Text),
|
665
|
+
],
|
666
|
+
'expression' : [
|
667
|
+
(r'([$a-zA-Z_][a-zA-Z0-9_]*)(\()', bygroups(Name.Function,
|
668
|
+
Punctuation)),
|
669
|
+
(r'(\))', Punctuation, "#pop"),
|
670
|
+
],
|
671
|
+
'string': [
|
672
|
+
(r'"', String, '#pop'),
|
673
|
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
|
674
|
+
(r'[^\\"\n]+', String), # all other characters
|
675
|
+
(r'\\\n', String), # line continuation
|
676
|
+
(r'\\', String), # stray backslash
|
677
|
+
],
|
678
|
+
'macro': [
|
679
|
+
(r'[^/\n]+', Comment.Preproc),
|
680
|
+
(r'/[*](.|\n)*?[*]/', Comment.Multiline),
|
681
|
+
(r'//.*?\n', Comment.Single, '#pop'),
|
682
|
+
(r'/', Comment.Preproc),
|
683
|
+
(r'(?<=\\)\n', Comment.Preproc),
|
684
|
+
(r'\n', Comment.Preproc, '#pop'),
|
685
|
+
],
|
686
|
+
'if0': [
|
687
|
+
(r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
|
688
|
+
(r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
|
689
|
+
(r'.*?\n', Comment),
|
690
|
+
]
|
691
|
+
}
|
692
|
+
|
693
|
+
def analyse_text(text):
|
694
|
+
if re.search('^\s*@import\s+[<"]', text, re.MULTILINE):
|
695
|
+
# special directive found in most Objective-J files
|
696
|
+
return True
|
697
|
+
return False
|
698
|
+
|
699
|
+
|
700
|
+
class HtmlLexer(RegexLexer):
|
701
|
+
"""
|
702
|
+
For HTML 4 and XHTML 1 markup. Nested JavaScript and CSS is highlighted
|
703
|
+
by the appropriate lexer.
|
704
|
+
"""
|
705
|
+
|
706
|
+
name = 'HTML'
|
707
|
+
aliases = ['html']
|
708
|
+
filenames = ['*.html', '*.htm', '*.xhtml', '*.xslt']
|
709
|
+
mimetypes = ['text/html', 'application/xhtml+xml']
|
710
|
+
|
711
|
+
flags = re.IGNORECASE | re.DOTALL
|
712
|
+
tokens = {
|
713
|
+
'root': [
|
714
|
+
('[^<&]+', Text),
|
715
|
+
(r'&\S*?;', Name.Entity),
|
716
|
+
(r'\<\!\[CDATA\[.*?\]\]\>', Comment.Preproc),
|
717
|
+
('<!--', Comment, 'comment'),
|
718
|
+
(r'<\?.*?\?>', Comment.Preproc),
|
719
|
+
('<![^>]*>', Comment.Preproc),
|
720
|
+
(r'<\s*script\s*', Name.Tag, ('script-content', 'tag')),
|
721
|
+
(r'<\s*style\s*', Name.Tag, ('style-content', 'tag')),
|
722
|
+
(r'<\s*[a-zA-Z0-9:]+', Name.Tag, 'tag'),
|
723
|
+
(r'<\s*/\s*[a-zA-Z0-9:]+\s*>', Name.Tag),
|
724
|
+
],
|
725
|
+
'comment': [
|
726
|
+
('[^-]+', Comment),
|
727
|
+
('-->', Comment, '#pop'),
|
728
|
+
('-', Comment),
|
729
|
+
],
|
730
|
+
'tag': [
|
731
|
+
(r'\s+', Text),
|
732
|
+
(r'[a-zA-Z0-9_:-]+\s*=', Name.Attribute, 'attr'),
|
733
|
+
(r'[a-zA-Z0-9_:-]+', Name.Attribute),
|
734
|
+
(r'/?\s*>', Name.Tag, '#pop'),
|
735
|
+
],
|
736
|
+
'script-content': [
|
737
|
+
(r'<\s*/\s*script\s*>', Name.Tag, '#pop'),
|
738
|
+
(r'.+?(?=<\s*/\s*script\s*>)', using(JavascriptLexer)),
|
739
|
+
],
|
740
|
+
'style-content': [
|
741
|
+
(r'<\s*/\s*style\s*>', Name.Tag, '#pop'),
|
742
|
+
(r'.+?(?=<\s*/\s*style\s*>)', using(CssLexer)),
|
743
|
+
],
|
744
|
+
'attr': [
|
745
|
+
('".*?"', String, '#pop'),
|
746
|
+
("'.*?'", String, '#pop'),
|
747
|
+
(r'[^\s>]+', String, '#pop'),
|
748
|
+
],
|
749
|
+
}
|
750
|
+
|
751
|
+
def analyse_text(text):
|
752
|
+
if html_doctype_matches(text):
|
753
|
+
return 0.5
|
754
|
+
|
755
|
+
|
756
|
+
class PhpLexer(RegexLexer):
|
757
|
+
"""
|
758
|
+
For `PHP <http://www.php.net/>`_ source code.
|
759
|
+
For PHP embedded in HTML, use the `HtmlPhpLexer`.
|
760
|
+
|
761
|
+
Additional options accepted:
|
762
|
+
|
763
|
+
`startinline`
|
764
|
+
If given and ``True`` the lexer starts highlighting with
|
765
|
+
php code (i.e.: no starting ``<?php`` required). The default
|
766
|
+
is ``False``.
|
767
|
+
`funcnamehighlighting`
|
768
|
+
If given and ``True``, highlight builtin function names
|
769
|
+
(default: ``True``).
|
770
|
+
`disabledmodules`
|
771
|
+
If given, must be a list of module names whose function names
|
772
|
+
should not be highlighted. By default all modules are highlighted
|
773
|
+
except the special ``'unknown'`` module that includes functions
|
774
|
+
that are known to php but are undocumented.
|
775
|
+
|
776
|
+
To get a list of allowed modules have a look into the
|
777
|
+
`_phpbuiltins` module:
|
778
|
+
|
779
|
+
.. sourcecode:: pycon
|
780
|
+
|
781
|
+
>>> from pygments.lexers._phpbuiltins import MODULES
|
782
|
+
>>> MODULES.keys()
|
783
|
+
['PHP Options/Info', 'Zip', 'dba', ...]
|
784
|
+
|
785
|
+
In fact the names of those modules match the module names from
|
786
|
+
the php documentation.
|
787
|
+
"""
|
788
|
+
|
789
|
+
name = 'PHP'
|
790
|
+
aliases = ['php', 'php3', 'php4', 'php5']
|
791
|
+
filenames = ['*.php', '*.php[345]']
|
792
|
+
mimetypes = ['text/x-php']
|
793
|
+
|
794
|
+
flags = re.IGNORECASE | re.DOTALL | re.MULTILINE
|
795
|
+
tokens = {
|
796
|
+
'root': [
|
797
|
+
(r'<\?(php)?', Comment.Preproc, 'php'),
|
798
|
+
(r'[^<]+', Other),
|
799
|
+
(r'<', Other)
|
800
|
+
],
|
801
|
+
'php': [
|
802
|
+
(r'\?>', Comment.Preproc, '#pop'),
|
803
|
+
(r'<<<(\'?)([a-zA-Z_][a-zA-Z0-9_]*)\1\n.*?\n\2\;?\n', String),
|
804
|
+
(r'\s+', Text),
|
805
|
+
(r'#.*?\n', Comment.Single),
|
806
|
+
(r'//.*?\n', Comment.Single),
|
807
|
+
# put the empty comment here, it is otherwise seen as
|
808
|
+
# the start of a docstring
|
809
|
+
(r'/\*\*/', Comment.Multiline),
|
810
|
+
(r'/\*\*.*?\*/', String.Doc),
|
811
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
812
|
+
(r'(->|::)(\s*)([a-zA-Z_][a-zA-Z0-9_]*)',
|
813
|
+
bygroups(Operator, Text, Name.Attribute)),
|
814
|
+
(r'[~!%^&*+=|:.<>/?@-]+', Operator),
|
815
|
+
(r'[\[\]{}();,]+', Punctuation),
|
816
|
+
(r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
|
817
|
+
(r'(function)(\s*)(?=\()', bygroups(Keyword, Text)),
|
818
|
+
(r'(function)(\s+)(&?)(\s*)',
|
819
|
+
bygroups(Keyword, Text, Operator, Text), 'functionname'),
|
820
|
+
(r'(const)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
|
821
|
+
bygroups(Keyword, Text, Name.Constant)),
|
822
|
+
(r'(and|E_PARSE|old_function|E_ERROR|or|as|E_WARNING|parent|'
|
823
|
+
r'eval|PHP_OS|break|exit|case|extends|PHP_VERSION|cfunction|'
|
824
|
+
r'FALSE|print|for|require|continue|foreach|require_once|'
|
825
|
+
r'declare|return|default|static|do|switch|die|stdClass|'
|
826
|
+
r'echo|else|TRUE|elseif|var|empty|if|xor|enddeclare|include|'
|
827
|
+
r'virtual|endfor|include_once|while|endforeach|global|__FILE__|'
|
828
|
+
r'endif|list|__LINE__|endswitch|new|__sleep|endwhile|not|'
|
829
|
+
r'array|__wakeup|E_ALL|NULL|final|php_user_filter|interface|'
|
830
|
+
r'implements|public|private|protected|abstract|clone|try|'
|
831
|
+
r'catch|throw|this|use|namespace)\b', Keyword),
|
832
|
+
(r'(true|false|null)\b', Keyword.Constant),
|
833
|
+
(r'\$\{\$+[a-zA-Z_][a-zA-Z0-9_]*\}', Name.Variable),
|
834
|
+
(r'\$+[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable),
|
835
|
+
(r'[\\a-zA-Z_][\\a-zA-Z0-9_]*', Name.Other),
|
836
|
+
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
|
837
|
+
(r'\d+[eE][+-]?[0-9]+', Number.Float),
|
838
|
+
(r'0[0-7]+', Number.Oct),
|
839
|
+
(r'0[xX][a-fA-F0-9]+', Number.Hex),
|
840
|
+
(r'\d+', Number.Integer),
|
841
|
+
(r"'([^'\\]*(?:\\.[^'\\]*)*)'", String.Single),
|
842
|
+
(r'`([^`\\]*(?:\\.[^`\\]*)*)`', String.Backtick),
|
843
|
+
(r'"', String.Double, 'string'),
|
844
|
+
],
|
845
|
+
'classname': [
|
846
|
+
(r'[a-zA-Z_][\\a-zA-Z0-9_]*', Name.Class, '#pop')
|
847
|
+
],
|
848
|
+
'functionname': [
|
849
|
+
(r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Function, '#pop')
|
850
|
+
],
|
851
|
+
'string': [
|
852
|
+
(r'"', String.Double, '#pop'),
|
853
|
+
(r'[^{$"\\]+', String.Double),
|
854
|
+
(r'\\([nrt\"$\\]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})', String.Escape),
|
855
|
+
(r'\$[a-zA-Z_][a-zA-Z0-9_]*(\[\S+\]|->[a-zA-Z_][a-zA-Z0-9_]*)?',
|
856
|
+
String.Interpol),
|
857
|
+
(r'(\{\$\{)(.*?)(\}\})',
|
858
|
+
bygroups(String.Interpol, using(this, _startinline=True),
|
859
|
+
String.Interpol)),
|
860
|
+
(r'(\{)(\$.*?)(\})',
|
861
|
+
bygroups(String.Interpol, using(this, _startinline=True),
|
862
|
+
String.Interpol)),
|
863
|
+
(r'(\$\{)(\S+)(\})',
|
864
|
+
bygroups(String.Interpol, Name.Variable, String.Interpol)),
|
865
|
+
(r'[${\\]+', String.Double)
|
866
|
+
],
|
867
|
+
}
|
868
|
+
|
869
|
+
def __init__(self, **options):
|
870
|
+
self.funcnamehighlighting = get_bool_opt(
|
871
|
+
options, 'funcnamehighlighting', True)
|
872
|
+
self.disabledmodules = get_list_opt(
|
873
|
+
options, 'disabledmodules', ['unknown'])
|
874
|
+
self.startinline = get_bool_opt(options, 'startinline', False)
|
875
|
+
|
876
|
+
# private option argument for the lexer itself
|
877
|
+
if '_startinline' in options:
|
878
|
+
self.startinline = options.pop('_startinline')
|
879
|
+
|
880
|
+
# collect activated functions in a set
|
881
|
+
self._functions = set()
|
882
|
+
if self.funcnamehighlighting:
|
883
|
+
from pygments.lexers._phpbuiltins import MODULES
|
884
|
+
for key, value in MODULES.iteritems():
|
885
|
+
if key not in self.disabledmodules:
|
886
|
+
self._functions.update(value)
|
887
|
+
RegexLexer.__init__(self, **options)
|
888
|
+
|
889
|
+
def get_tokens_unprocessed(self, text):
|
890
|
+
stack = ['root']
|
891
|
+
if self.startinline:
|
892
|
+
stack.append('php')
|
893
|
+
for index, token, value in \
|
894
|
+
RegexLexer.get_tokens_unprocessed(self, text, stack):
|
895
|
+
if token is Name.Other:
|
896
|
+
if value in self._functions:
|
897
|
+
yield index, Name.Builtin, value
|
898
|
+
continue
|
899
|
+
yield index, token, value
|
900
|
+
|
901
|
+
def analyse_text(text):
|
902
|
+
rv = 0.0
|
903
|
+
if re.search(r'<\?(?!xml)', text):
|
904
|
+
rv += 0.3
|
905
|
+
if '?>' in text:
|
906
|
+
rv += 0.1
|
907
|
+
return rv
|
908
|
+
|
909
|
+
|
910
|
+
class DtdLexer(RegexLexer):
|
911
|
+
"""
|
912
|
+
A lexer for DTDs (Document Type Definitions).
|
913
|
+
|
914
|
+
*New in Pygments 1.5.*
|
915
|
+
"""
|
916
|
+
|
917
|
+
flags = re.MULTILINE | re.DOTALL
|
918
|
+
|
919
|
+
name = 'DTD'
|
920
|
+
aliases = ['dtd']
|
921
|
+
filenames = ['*.dtd']
|
922
|
+
mimetypes = ['application/xml-dtd']
|
923
|
+
|
924
|
+
tokens = {
|
925
|
+
'root': [
|
926
|
+
include('common'),
|
927
|
+
|
928
|
+
(r'(<!ELEMENT)(\s+)(\S+)',
|
929
|
+
bygroups(Keyword, Text, Name.Tag), 'element'),
|
930
|
+
(r'(<!ATTLIST)(\s+)(\S+)',
|
931
|
+
bygroups(Keyword, Text, Name.Tag), 'attlist'),
|
932
|
+
(r'(<!ENTITY)(\s+)(\S+)',
|
933
|
+
bygroups(Keyword, Text, Name.Entity), 'entity'),
|
934
|
+
(r'(<!NOTATION)(\s+)(\S+)',
|
935
|
+
bygroups(Keyword, Text, Name.Tag), 'notation'),
|
936
|
+
(r'(<!\[)([^\[\s]+)(\s*)(\[)', # conditional sections
|
937
|
+
bygroups(Keyword, Name.Entity, Text, Keyword)),
|
938
|
+
|
939
|
+
(r'(<!DOCTYPE)(\s+)([^>\s]+)',
|
940
|
+
bygroups(Keyword, Text, Name.Tag)),
|
941
|
+
(r'PUBLIC|SYSTEM', Keyword.Constant),
|
942
|
+
(r'[\[\]>]', Keyword),
|
943
|
+
],
|
944
|
+
|
945
|
+
'common': [
|
946
|
+
(r'\s+', Text),
|
947
|
+
(r'(%|&)[^;]*;', Name.Entity),
|
948
|
+
('<!--', Comment, 'comment'),
|
949
|
+
(r'[(|)*,?+]', Operator),
|
950
|
+
(r'"[^"]*"', String.Double),
|
951
|
+
(r'\'[^\']*\'', String.Single),
|
952
|
+
],
|
953
|
+
|
954
|
+
'comment': [
|
955
|
+
('[^-]+', Comment),
|
956
|
+
('-->', Comment, '#pop'),
|
957
|
+
('-', Comment),
|
958
|
+
],
|
959
|
+
|
960
|
+
'element': [
|
961
|
+
include('common'),
|
962
|
+
(r'EMPTY|ANY|#PCDATA', Keyword.Constant),
|
963
|
+
(r'[^>\s\|()?+*,]+', Name.Tag),
|
964
|
+
(r'>', Keyword, '#pop'),
|
965
|
+
],
|
966
|
+
|
967
|
+
'attlist': [
|
968
|
+
include('common'),
|
969
|
+
(r'CDATA|IDREFS|IDREF|ID|NMTOKENS|NMTOKEN|ENTITIES|ENTITY|NOTATION', Keyword.Constant),
|
970
|
+
(r'#REQUIRED|#IMPLIED|#FIXED', Keyword.Constant),
|
971
|
+
(r'xml:space|xml:lang', Keyword.Reserved),
|
972
|
+
(r'[^>\s\|()?+*,]+', Name.Attribute),
|
973
|
+
(r'>', Keyword, '#pop'),
|
974
|
+
],
|
975
|
+
|
976
|
+
'entity': [
|
977
|
+
include('common'),
|
978
|
+
(r'SYSTEM|PUBLIC|NDATA', Keyword.Constant),
|
979
|
+
(r'[^>\s\|()?+*,]+', Name.Entity),
|
980
|
+
(r'>', Keyword, '#pop'),
|
981
|
+
],
|
982
|
+
|
983
|
+
'notation': [
|
984
|
+
include('common'),
|
985
|
+
(r'SYSTEM|PUBLIC', Keyword.Constant),
|
986
|
+
(r'[^>\s\|()?+*,]+', Name.Attribute),
|
987
|
+
(r'>', Keyword, '#pop'),
|
988
|
+
],
|
989
|
+
}
|
990
|
+
|
991
|
+
def analyse_text(text):
|
992
|
+
if not looks_like_xml(text) and \
|
993
|
+
('<!ELEMENT' in text or '<!ATTLIST' in text or '<!ENTITY' in text):
|
994
|
+
return 0.8
|
995
|
+
|
996
|
+
class XmlLexer(RegexLexer):
|
997
|
+
"""
|
998
|
+
Generic lexer for XML (eXtensible Markup Language).
|
999
|
+
"""
|
1000
|
+
|
1001
|
+
flags = re.MULTILINE | re.DOTALL
|
1002
|
+
|
1003
|
+
name = 'XML'
|
1004
|
+
aliases = ['xml']
|
1005
|
+
filenames = ['*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd', '*.wsdl']
|
1006
|
+
mimetypes = ['text/xml', 'application/xml', 'image/svg+xml',
|
1007
|
+
'application/rss+xml', 'application/atom+xml']
|
1008
|
+
|
1009
|
+
tokens = {
|
1010
|
+
'root': [
|
1011
|
+
('[^<&]+', Text),
|
1012
|
+
(r'&\S*?;', Name.Entity),
|
1013
|
+
(r'\<\!\[CDATA\[.*?\]\]\>', Comment.Preproc),
|
1014
|
+
('<!--', Comment, 'comment'),
|
1015
|
+
(r'<\?.*?\?>', Comment.Preproc),
|
1016
|
+
('<![^>]*>', Comment.Preproc),
|
1017
|
+
(r'<\s*[a-zA-Z0-9:._-]+', Name.Tag, 'tag'),
|
1018
|
+
(r'<\s*/\s*[a-zA-Z0-9:._-]+\s*>', Name.Tag),
|
1019
|
+
],
|
1020
|
+
'comment': [
|
1021
|
+
('[^-]+', Comment),
|
1022
|
+
('-->', Comment, '#pop'),
|
1023
|
+
('-', Comment),
|
1024
|
+
],
|
1025
|
+
'tag': [
|
1026
|
+
(r'\s+', Text),
|
1027
|
+
(r'[a-zA-Z0-9_.:-]+\s*=', Name.Attribute, 'attr'),
|
1028
|
+
(r'/?\s*>', Name.Tag, '#pop'),
|
1029
|
+
],
|
1030
|
+
'attr': [
|
1031
|
+
('\s+', Text),
|
1032
|
+
('".*?"', String, '#pop'),
|
1033
|
+
("'.*?'", String, '#pop'),
|
1034
|
+
(r'[^\s>]+', String, '#pop'),
|
1035
|
+
],
|
1036
|
+
}
|
1037
|
+
|
1038
|
+
def analyse_text(text):
|
1039
|
+
if looks_like_xml(text):
|
1040
|
+
return 0.5
|
1041
|
+
|
1042
|
+
|
1043
|
+
class XsltLexer(XmlLexer):
|
1044
|
+
'''
|
1045
|
+
A lexer for XSLT.
|
1046
|
+
|
1047
|
+
*New in Pygments 0.10.*
|
1048
|
+
'''
|
1049
|
+
|
1050
|
+
name = 'XSLT'
|
1051
|
+
aliases = ['xslt']
|
1052
|
+
filenames = ['*.xsl', '*.xslt']
|
1053
|
+
mimetypes = ['application/xsl+xml', 'application/xslt+xml']
|
1054
|
+
|
1055
|
+
EXTRA_KEYWORDS = set([
|
1056
|
+
'apply-imports', 'apply-templates', 'attribute',
|
1057
|
+
'attribute-set', 'call-template', 'choose', 'comment',
|
1058
|
+
'copy', 'copy-of', 'decimal-format', 'element', 'fallback',
|
1059
|
+
'for-each', 'if', 'import', 'include', 'key', 'message',
|
1060
|
+
'namespace-alias', 'number', 'otherwise', 'output', 'param',
|
1061
|
+
'preserve-space', 'processing-instruction', 'sort',
|
1062
|
+
'strip-space', 'stylesheet', 'template', 'text', 'transform',
|
1063
|
+
'value-of', 'variable', 'when', 'with-param'
|
1064
|
+
])
|
1065
|
+
|
1066
|
+
def get_tokens_unprocessed(self, text):
|
1067
|
+
for index, token, value in XmlLexer.get_tokens_unprocessed(self, text):
|
1068
|
+
m = re.match('</?xsl:([^>]*)/?>?', value)
|
1069
|
+
|
1070
|
+
if token is Name.Tag and m and m.group(1) in self.EXTRA_KEYWORDS:
|
1071
|
+
yield index, Keyword, value
|
1072
|
+
else:
|
1073
|
+
yield index, token, value
|
1074
|
+
|
1075
|
+
def analyse_text(text):
|
1076
|
+
if looks_like_xml(text) and '<xsl' in text:
|
1077
|
+
return 0.8
|
1078
|
+
|
1079
|
+
|
1080
|
+
class MxmlLexer(RegexLexer):
|
1081
|
+
"""
|
1082
|
+
For MXML markup.
|
1083
|
+
Nested AS3 in <script> tags is highlighted by the appropriate lexer.
|
1084
|
+
"""
|
1085
|
+
flags = re.MULTILINE | re.DOTALL
|
1086
|
+
name = 'MXML'
|
1087
|
+
aliases = ['mxml']
|
1088
|
+
filenames = ['*.mxml']
|
1089
|
+
mimetimes = ['text/xml', 'application/xml']
|
1090
|
+
|
1091
|
+
tokens = {
|
1092
|
+
'root': [
|
1093
|
+
('[^<&]+', Text),
|
1094
|
+
(r'&\S*?;', Name.Entity),
|
1095
|
+
(r'(\<\!\[CDATA\[)(.*?)(\]\]\>)',
|
1096
|
+
bygroups(String, using(ActionScript3Lexer), String)),
|
1097
|
+
('<!--', Comment, 'comment'),
|
1098
|
+
(r'<\?.*?\?>', Comment.Preproc),
|
1099
|
+
('<![^>]*>', Comment.Preproc),
|
1100
|
+
(r'<\s*[a-zA-Z0-9:._-]+', Name.Tag, 'tag'),
|
1101
|
+
(r'<\s*/\s*[a-zA-Z0-9:._-]+\s*>', Name.Tag),
|
1102
|
+
],
|
1103
|
+
'comment': [
|
1104
|
+
('[^-]+', Comment),
|
1105
|
+
('-->', Comment, '#pop'),
|
1106
|
+
('-', Comment),
|
1107
|
+
],
|
1108
|
+
'tag': [
|
1109
|
+
(r'\s+', Text),
|
1110
|
+
(r'[a-zA-Z0-9_.:-]+\s*=', Name.Attribute, 'attr'),
|
1111
|
+
(r'/?\s*>', Name.Tag, '#pop'),
|
1112
|
+
],
|
1113
|
+
'attr': [
|
1114
|
+
('\s+', Text),
|
1115
|
+
('".*?"', String, '#pop'),
|
1116
|
+
("'.*?'", String, '#pop'),
|
1117
|
+
(r'[^\s>]+', String, '#pop'),
|
1118
|
+
],
|
1119
|
+
}
|
1120
|
+
|
1121
|
+
|
1122
|
+
class HaxeLexer(RegexLexer):
|
1123
|
+
"""
|
1124
|
+
For haXe source code (http://haxe.org/).
|
1125
|
+
"""
|
1126
|
+
|
1127
|
+
name = 'haXe'
|
1128
|
+
aliases = ['hx', 'haXe']
|
1129
|
+
filenames = ['*.hx']
|
1130
|
+
mimetypes = ['text/haxe']
|
1131
|
+
|
1132
|
+
ident = r'(?:[a-zA-Z_][a-zA-Z0-9_]*)'
|
1133
|
+
typeid = r'(?:(?:[a-z0-9_\.])*[A-Z_][A-Za-z0-9_]*)'
|
1134
|
+
key_prop = r'(?:default|null|never)'
|
1135
|
+
key_decl_mod = r'(?:public|private|override|static|inline|extern|dynamic)'
|
1136
|
+
|
1137
|
+
flags = re.DOTALL | re.MULTILINE
|
1138
|
+
|
1139
|
+
tokens = {
|
1140
|
+
'root': [
|
1141
|
+
include('whitespace'),
|
1142
|
+
include('comments'),
|
1143
|
+
(key_decl_mod, Keyword.Declaration),
|
1144
|
+
include('enumdef'),
|
1145
|
+
include('typedef'),
|
1146
|
+
include('classdef'),
|
1147
|
+
include('imports'),
|
1148
|
+
],
|
1149
|
+
|
1150
|
+
# General constructs
|
1151
|
+
'comments': [
|
1152
|
+
(r'//.*?\n', Comment.Single),
|
1153
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
1154
|
+
(r'#[^\n]*', Comment.Preproc),
|
1155
|
+
],
|
1156
|
+
'whitespace': [
|
1157
|
+
include('comments'),
|
1158
|
+
(r'\s+', Text),
|
1159
|
+
],
|
1160
|
+
'codekeywords': [
|
1161
|
+
(r'\b(if|else|while|do|for|in|break|continue|'
|
1162
|
+
r'return|switch|case|try|catch|throw|null|trace|'
|
1163
|
+
r'new|this|super|untyped|cast|callback|here)\b',
|
1164
|
+
Keyword.Reserved),
|
1165
|
+
],
|
1166
|
+
'literals': [
|
1167
|
+
(r'0[xX][0-9a-fA-F]+', Number.Hex),
|
1168
|
+
(r'[0-9]+', Number.Integer),
|
1169
|
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
1170
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
1171
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
1172
|
+
(r'~/([^\n])*?/[gisx]*', String.Regex),
|
1173
|
+
(r'\b(true|false|null)\b', Keyword.Constant),
|
1174
|
+
],
|
1175
|
+
'codeblock': [
|
1176
|
+
include('whitespace'),
|
1177
|
+
include('new'),
|
1178
|
+
include('case'),
|
1179
|
+
include('anonfundef'),
|
1180
|
+
include('literals'),
|
1181
|
+
include('vardef'),
|
1182
|
+
include('codekeywords'),
|
1183
|
+
(r'[();,\[\]]', Punctuation),
|
1184
|
+
(r'(?:=|\+=|-=|\*=|/=|%=|&=|\|=|\^=|<<=|>>=|>>>=|\|\||&&|'
|
1185
|
+
r'\.\.\.|==|!=|>|<|>=|<=|\||&|\^|<<|>>>|>>|\+|\-|\*|/|%|'
|
1186
|
+
r'!|\+\+|\-\-|~|\.|\?|\:)',
|
1187
|
+
Operator),
|
1188
|
+
(ident, Name),
|
1189
|
+
|
1190
|
+
(r'}', Punctuation,'#pop'),
|
1191
|
+
(r'{', Punctuation,'#push'),
|
1192
|
+
],
|
1193
|
+
|
1194
|
+
# Instance/Block level constructs
|
1195
|
+
'propertydef': [
|
1196
|
+
(r'(\()(' + key_prop + ')(,)(' + key_prop + ')(\))',
|
1197
|
+
bygroups(Punctuation, Keyword.Reserved, Punctuation,
|
1198
|
+
Keyword.Reserved, Punctuation)),
|
1199
|
+
],
|
1200
|
+
'new': [
|
1201
|
+
(r'\bnew\b', Keyword, 'typedecl'),
|
1202
|
+
],
|
1203
|
+
'case': [
|
1204
|
+
(r'\b(case)(\s+)(' + ident + ')(\s*)(\()',
|
1205
|
+
bygroups(Keyword.Reserved, Text, Name, Text, Punctuation),
|
1206
|
+
'funargdecl'),
|
1207
|
+
],
|
1208
|
+
'vardef': [
|
1209
|
+
(r'\b(var)(\s+)(' + ident + ')',
|
1210
|
+
bygroups(Keyword.Declaration, Text, Name.Variable), 'vardecl'),
|
1211
|
+
],
|
1212
|
+
'vardecl': [
|
1213
|
+
include('whitespace'),
|
1214
|
+
include('typelabel'),
|
1215
|
+
(r'=', Operator,'#pop'),
|
1216
|
+
(r';', Punctuation,'#pop'),
|
1217
|
+
],
|
1218
|
+
'instancevardef': [
|
1219
|
+
(key_decl_mod,Keyword.Declaration),
|
1220
|
+
(r'\b(var)(\s+)(' + ident + ')',
|
1221
|
+
bygroups(Keyword.Declaration, Text, Name.Variable.Instance),
|
1222
|
+
'instancevardecl'),
|
1223
|
+
],
|
1224
|
+
'instancevardecl': [
|
1225
|
+
include('vardecl'),
|
1226
|
+
include('propertydef'),
|
1227
|
+
],
|
1228
|
+
|
1229
|
+
'anonfundef': [
|
1230
|
+
(r'\bfunction\b', Keyword.Declaration, 'fundecl'),
|
1231
|
+
],
|
1232
|
+
'instancefundef': [
|
1233
|
+
(key_decl_mod, Keyword.Declaration),
|
1234
|
+
(r'\b(function)(\s+)(' + ident + ')',
|
1235
|
+
bygroups(Keyword.Declaration, Text, Name.Function), 'fundecl'),
|
1236
|
+
],
|
1237
|
+
'fundecl': [
|
1238
|
+
include('whitespace'),
|
1239
|
+
include('typelabel'),
|
1240
|
+
include('generictypedecl'),
|
1241
|
+
(r'\(',Punctuation,'funargdecl'),
|
1242
|
+
(r'(?=[a-zA-Z0-9_])',Text,'#pop'),
|
1243
|
+
(r'{',Punctuation,('#pop','codeblock')),
|
1244
|
+
(r';',Punctuation,'#pop'),
|
1245
|
+
],
|
1246
|
+
'funargdecl': [
|
1247
|
+
include('whitespace'),
|
1248
|
+
(ident, Name.Variable),
|
1249
|
+
include('typelabel'),
|
1250
|
+
include('literals'),
|
1251
|
+
(r'=', Operator),
|
1252
|
+
(r',', Punctuation),
|
1253
|
+
(r'\?', Punctuation),
|
1254
|
+
(r'\)', Punctuation, '#pop'),
|
1255
|
+
],
|
1256
|
+
|
1257
|
+
'typelabel': [
|
1258
|
+
(r':', Punctuation, 'type'),
|
1259
|
+
],
|
1260
|
+
'typedecl': [
|
1261
|
+
include('whitespace'),
|
1262
|
+
(typeid, Name.Class),
|
1263
|
+
(r'<', Punctuation, 'generictypedecl'),
|
1264
|
+
(r'(?=[{}()=,a-z])', Text,'#pop'),
|
1265
|
+
],
|
1266
|
+
'type': [
|
1267
|
+
include('whitespace'),
|
1268
|
+
(typeid, Name.Class),
|
1269
|
+
(r'<', Punctuation, 'generictypedecl'),
|
1270
|
+
(r'->', Keyword.Type),
|
1271
|
+
(r'(?=[{}(),;=])', Text, '#pop'),
|
1272
|
+
],
|
1273
|
+
'generictypedecl': [
|
1274
|
+
include('whitespace'),
|
1275
|
+
(typeid, Name.Class),
|
1276
|
+
(r'<', Punctuation, '#push'),
|
1277
|
+
(r'>', Punctuation, '#pop'),
|
1278
|
+
(r',', Punctuation),
|
1279
|
+
],
|
1280
|
+
|
1281
|
+
# Top level constructs
|
1282
|
+
'imports': [
|
1283
|
+
(r'(package|import|using)(\s+)([^;]+)(;)',
|
1284
|
+
bygroups(Keyword.Namespace, Text, Name.Namespace,Punctuation)),
|
1285
|
+
],
|
1286
|
+
'typedef': [
|
1287
|
+
(r'typedef', Keyword.Declaration, ('typedefprebody', 'typedecl')),
|
1288
|
+
],
|
1289
|
+
'typedefprebody': [
|
1290
|
+
include('whitespace'),
|
1291
|
+
(r'(=)(\s*)({)', bygroups(Punctuation, Text, Punctuation),
|
1292
|
+
('#pop', 'typedefbody')),
|
1293
|
+
],
|
1294
|
+
'enumdef': [
|
1295
|
+
(r'enum', Keyword.Declaration, ('enumdefprebody', 'typedecl')),
|
1296
|
+
],
|
1297
|
+
'enumdefprebody': [
|
1298
|
+
include('whitespace'),
|
1299
|
+
(r'{', Punctuation, ('#pop','enumdefbody')),
|
1300
|
+
],
|
1301
|
+
'classdef': [
|
1302
|
+
(r'class', Keyword.Declaration, ('classdefprebody', 'typedecl')),
|
1303
|
+
],
|
1304
|
+
'classdefprebody': [
|
1305
|
+
include('whitespace'),
|
1306
|
+
(r'(extends|implements)', Keyword.Declaration,'typedecl'),
|
1307
|
+
(r'{', Punctuation, ('#pop', 'classdefbody')),
|
1308
|
+
],
|
1309
|
+
'interfacedef': [
|
1310
|
+
(r'interface', Keyword.Declaration,
|
1311
|
+
('interfacedefprebody', 'typedecl')),
|
1312
|
+
],
|
1313
|
+
'interfacedefprebody': [
|
1314
|
+
include('whitespace'),
|
1315
|
+
(r'(extends)', Keyword.Declaration, 'typedecl'),
|
1316
|
+
(r'{', Punctuation, ('#pop', 'classdefbody')),
|
1317
|
+
],
|
1318
|
+
|
1319
|
+
'typedefbody': [
|
1320
|
+
include('whitespace'),
|
1321
|
+
include('instancevardef'),
|
1322
|
+
include('instancefundef'),
|
1323
|
+
(r'>', Punctuation, 'typedecl'),
|
1324
|
+
(r',', Punctuation),
|
1325
|
+
(r'}', Punctuation, '#pop'),
|
1326
|
+
],
|
1327
|
+
'enumdefbody': [
|
1328
|
+
include('whitespace'),
|
1329
|
+
(ident, Name.Variable.Instance),
|
1330
|
+
(r'\(', Punctuation, 'funargdecl'),
|
1331
|
+
(r';', Punctuation),
|
1332
|
+
(r'}', Punctuation, '#pop'),
|
1333
|
+
],
|
1334
|
+
'classdefbody': [
|
1335
|
+
include('whitespace'),
|
1336
|
+
include('instancevardef'),
|
1337
|
+
include('instancefundef'),
|
1338
|
+
(r'}', Punctuation, '#pop'),
|
1339
|
+
include('codeblock'),
|
1340
|
+
],
|
1341
|
+
}
|
1342
|
+
|
1343
|
+
def analyse_text(text):
|
1344
|
+
if re.match(r'\w+\s*:\s*\w', text): return 0.3
|
1345
|
+
|
1346
|
+
|
1347
|
+
def _indentation(lexer, match, ctx):
|
1348
|
+
indentation = match.group(0)
|
1349
|
+
yield match.start(), Text, indentation
|
1350
|
+
ctx.last_indentation = indentation
|
1351
|
+
ctx.pos = match.end()
|
1352
|
+
|
1353
|
+
if hasattr(ctx, 'block_state') and ctx.block_state and \
|
1354
|
+
indentation.startswith(ctx.block_indentation) and \
|
1355
|
+
indentation != ctx.block_indentation:
|
1356
|
+
ctx.stack.append(ctx.block_state)
|
1357
|
+
else:
|
1358
|
+
ctx.block_state = None
|
1359
|
+
ctx.block_indentation = None
|
1360
|
+
ctx.stack.append('content')
|
1361
|
+
|
1362
|
+
def _starts_block(token, state):
|
1363
|
+
def callback(lexer, match, ctx):
|
1364
|
+
yield match.start(), token, match.group(0)
|
1365
|
+
|
1366
|
+
if hasattr(ctx, 'last_indentation'):
|
1367
|
+
ctx.block_indentation = ctx.last_indentation
|
1368
|
+
else:
|
1369
|
+
ctx.block_indentation = ''
|
1370
|
+
|
1371
|
+
ctx.block_state = state
|
1372
|
+
ctx.pos = match.end()
|
1373
|
+
|
1374
|
+
return callback
|
1375
|
+
|
1376
|
+
|
1377
|
+
class HamlLexer(ExtendedRegexLexer):
|
1378
|
+
"""
|
1379
|
+
For Haml markup.
|
1380
|
+
|
1381
|
+
*New in Pygments 1.3.*
|
1382
|
+
"""
|
1383
|
+
|
1384
|
+
name = 'Haml'
|
1385
|
+
aliases = ['haml', 'HAML']
|
1386
|
+
filenames = ['*.haml']
|
1387
|
+
mimetypes = ['text/x-haml']
|
1388
|
+
|
1389
|
+
flags = re.IGNORECASE
|
1390
|
+
# Haml can include " |\n" anywhere,
|
1391
|
+
# which is ignored and used to wrap long lines.
|
1392
|
+
# To accomodate this, use this custom faux dot instead.
|
1393
|
+
_dot = r'(?: \|\n(?=.* \|)|.)'
|
1394
|
+
|
1395
|
+
# In certain places, a comma at the end of the line
|
1396
|
+
# allows line wrapping as well.
|
1397
|
+
_comma_dot = r'(?:,\s*\n|' + _dot + ')'
|
1398
|
+
tokens = {
|
1399
|
+
'root': [
|
1400
|
+
(r'[ \t]*\n', Text),
|
1401
|
+
(r'[ \t]*', _indentation),
|
1402
|
+
],
|
1403
|
+
|
1404
|
+
'css': [
|
1405
|
+
(r'\.[a-z0-9_:-]+', Name.Class, 'tag'),
|
1406
|
+
(r'\#[a-z0-9_:-]+', Name.Function, 'tag'),
|
1407
|
+
],
|
1408
|
+
|
1409
|
+
'eval-or-plain': [
|
1410
|
+
(r'[&!]?==', Punctuation, 'plain'),
|
1411
|
+
(r'([&!]?[=~])(' + _comma_dot + r'*\n)',
|
1412
|
+
bygroups(Punctuation, using(RubyLexer)),
|
1413
|
+
'root'),
|
1414
|
+
(r'', Text, 'plain'),
|
1415
|
+
],
|
1416
|
+
|
1417
|
+
'content': [
|
1418
|
+
include('css'),
|
1419
|
+
(r'%[a-z0-9_:-]+', Name.Tag, 'tag'),
|
1420
|
+
(r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'),
|
1421
|
+
(r'(/)(\[' + _dot + '*?\])(' + _dot + r'*\n)',
|
1422
|
+
bygroups(Comment, Comment.Special, Comment),
|
1423
|
+
'#pop'),
|
1424
|
+
(r'/' + _dot + r'*\n', _starts_block(Comment, 'html-comment-block'),
|
1425
|
+
'#pop'),
|
1426
|
+
(r'-#' + _dot + r'*\n', _starts_block(Comment.Preproc,
|
1427
|
+
'haml-comment-block'), '#pop'),
|
1428
|
+
(r'(-)(' + _comma_dot + r'*\n)',
|
1429
|
+
bygroups(Punctuation, using(RubyLexer)),
|
1430
|
+
'#pop'),
|
1431
|
+
(r':' + _dot + r'*\n', _starts_block(Name.Decorator, 'filter-block'),
|
1432
|
+
'#pop'),
|
1433
|
+
include('eval-or-plain'),
|
1434
|
+
],
|
1435
|
+
|
1436
|
+
'tag': [
|
1437
|
+
include('css'),
|
1438
|
+
(r'\{(,\n|' + _dot + ')*?\}', using(RubyLexer)),
|
1439
|
+
(r'\[' + _dot + '*?\]', using(RubyLexer)),
|
1440
|
+
(r'\(', Text, 'html-attributes'),
|
1441
|
+
(r'/[ \t]*\n', Punctuation, '#pop:2'),
|
1442
|
+
(r'[<>]{1,2}(?=[ \t=])', Punctuation),
|
1443
|
+
include('eval-or-plain'),
|
1444
|
+
],
|
1445
|
+
|
1446
|
+
'plain': [
|
1447
|
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text),
|
1448
|
+
(r'(#\{)(' + _dot + '*?)(\})',
|
1449
|
+
bygroups(String.Interpol, using(RubyLexer), String.Interpol)),
|
1450
|
+
(r'\n', Text, 'root'),
|
1451
|
+
],
|
1452
|
+
|
1453
|
+
'html-attributes': [
|
1454
|
+
(r'\s+', Text),
|
1455
|
+
(r'[a-z0-9_:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
|
1456
|
+
(r'[a-z0-9_:-]+', Name.Attribute),
|
1457
|
+
(r'\)', Text, '#pop'),
|
1458
|
+
],
|
1459
|
+
|
1460
|
+
'html-attribute-value': [
|
1461
|
+
(r'[ \t]+', Text),
|
1462
|
+
(r'[a-z0-9_]+', Name.Variable, '#pop'),
|
1463
|
+
(r'@[a-z0-9_]+', Name.Variable.Instance, '#pop'),
|
1464
|
+
(r'\$[a-z0-9_]+', Name.Variable.Global, '#pop'),
|
1465
|
+
(r"'(\\\\|\\'|[^'\n])*'", String, '#pop'),
|
1466
|
+
(r'"(\\\\|\\"|[^"\n])*"', String, '#pop'),
|
1467
|
+
],
|
1468
|
+
|
1469
|
+
'html-comment-block': [
|
1470
|
+
(_dot + '+', Comment),
|
1471
|
+
(r'\n', Text, 'root'),
|
1472
|
+
],
|
1473
|
+
|
1474
|
+
'haml-comment-block': [
|
1475
|
+
(_dot + '+', Comment.Preproc),
|
1476
|
+
(r'\n', Text, 'root'),
|
1477
|
+
],
|
1478
|
+
|
1479
|
+
'filter-block': [
|
1480
|
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Name.Decorator),
|
1481
|
+
(r'(#\{)(' + _dot + '*?)(\})',
|
1482
|
+
bygroups(String.Interpol, using(RubyLexer), String.Interpol)),
|
1483
|
+
(r'\n', Text, 'root'),
|
1484
|
+
],
|
1485
|
+
}
|
1486
|
+
|
1487
|
+
|
1488
|
+
common_sass_tokens = {
|
1489
|
+
'value': [
|
1490
|
+
(r'[ \t]+', Text),
|
1491
|
+
(r'[!$][\w-]+', Name.Variable),
|
1492
|
+
(r'url\(', String.Other, 'string-url'),
|
1493
|
+
(r'[a-z_-][\w-]*(?=\()', Name.Function),
|
1494
|
+
(r'(azimuth|background-attachment|background-color|'
|
1495
|
+
r'background-image|background-position|background-repeat|'
|
1496
|
+
r'background|border-bottom-color|border-bottom-style|'
|
1497
|
+
r'border-bottom-width|border-left-color|border-left-style|'
|
1498
|
+
r'border-left-width|border-right|border-right-color|'
|
1499
|
+
r'border-right-style|border-right-width|border-top-color|'
|
1500
|
+
r'border-top-style|border-top-width|border-bottom|'
|
1501
|
+
r'border-collapse|border-left|border-width|border-color|'
|
1502
|
+
r'border-spacing|border-style|border-top|border|caption-side|'
|
1503
|
+
r'clear|clip|color|content|counter-increment|counter-reset|'
|
1504
|
+
r'cue-after|cue-before|cue|cursor|direction|display|'
|
1505
|
+
r'elevation|empty-cells|float|font-family|font-size|'
|
1506
|
+
r'font-size-adjust|font-stretch|font-style|font-variant|'
|
1507
|
+
r'font-weight|font|height|letter-spacing|line-height|'
|
1508
|
+
r'list-style-type|list-style-image|list-style-position|'
|
1509
|
+
r'list-style|margin-bottom|margin-left|margin-right|'
|
1510
|
+
r'margin-top|margin|marker-offset|marks|max-height|max-width|'
|
1511
|
+
r'min-height|min-width|opacity|orphans|outline|outline-color|'
|
1512
|
+
r'outline-style|outline-width|overflow|padding-bottom|'
|
1513
|
+
r'padding-left|padding-right|padding-top|padding|page|'
|
1514
|
+
r'page-break-after|page-break-before|page-break-inside|'
|
1515
|
+
r'pause-after|pause-before|pause|pitch|pitch-range|'
|
1516
|
+
r'play-during|position|quotes|richness|right|size|'
|
1517
|
+
r'speak-header|speak-numeral|speak-punctuation|speak|'
|
1518
|
+
r'speech-rate|stress|table-layout|text-align|text-decoration|'
|
1519
|
+
r'text-indent|text-shadow|text-transform|top|unicode-bidi|'
|
1520
|
+
r'vertical-align|visibility|voice-family|volume|white-space|'
|
1521
|
+
r'widows|width|word-spacing|z-index|bottom|left|'
|
1522
|
+
r'above|absolute|always|armenian|aural|auto|avoid|baseline|'
|
1523
|
+
r'behind|below|bidi-override|blink|block|bold|bolder|both|'
|
1524
|
+
r'capitalize|center-left|center-right|center|circle|'
|
1525
|
+
r'cjk-ideographic|close-quote|collapse|condensed|continuous|'
|
1526
|
+
r'crop|crosshair|cross|cursive|dashed|decimal-leading-zero|'
|
1527
|
+
r'decimal|default|digits|disc|dotted|double|e-resize|embed|'
|
1528
|
+
r'extra-condensed|extra-expanded|expanded|fantasy|far-left|'
|
1529
|
+
r'far-right|faster|fast|fixed|georgian|groove|hebrew|help|'
|
1530
|
+
r'hidden|hide|higher|high|hiragana-iroha|hiragana|icon|'
|
1531
|
+
r'inherit|inline-table|inline|inset|inside|invert|italic|'
|
1532
|
+
r'justify|katakana-iroha|katakana|landscape|larger|large|'
|
1533
|
+
r'left-side|leftwards|level|lighter|line-through|list-item|'
|
1534
|
+
r'loud|lower-alpha|lower-greek|lower-roman|lowercase|ltr|'
|
1535
|
+
r'lower|low|medium|message-box|middle|mix|monospace|'
|
1536
|
+
r'n-resize|narrower|ne-resize|no-close-quote|no-open-quote|'
|
1537
|
+
r'no-repeat|none|normal|nowrap|nw-resize|oblique|once|'
|
1538
|
+
r'open-quote|outset|outside|overline|pointer|portrait|px|'
|
1539
|
+
r'relative|repeat-x|repeat-y|repeat|rgb|ridge|right-side|'
|
1540
|
+
r'rightwards|s-resize|sans-serif|scroll|se-resize|'
|
1541
|
+
r'semi-condensed|semi-expanded|separate|serif|show|silent|'
|
1542
|
+
r'slow|slower|small-caps|small-caption|smaller|soft|solid|'
|
1543
|
+
r'spell-out|square|static|status-bar|super|sw-resize|'
|
1544
|
+
r'table-caption|table-cell|table-column|table-column-group|'
|
1545
|
+
r'table-footer-group|table-header-group|table-row|'
|
1546
|
+
r'table-row-group|text|text-bottom|text-top|thick|thin|'
|
1547
|
+
r'transparent|ultra-condensed|ultra-expanded|underline|'
|
1548
|
+
r'upper-alpha|upper-latin|upper-roman|uppercase|url|'
|
1549
|
+
r'visible|w-resize|wait|wider|x-fast|x-high|x-large|x-loud|'
|
1550
|
+
r'x-low|x-small|x-soft|xx-large|xx-small|yes)\b', Name.Constant),
|
1551
|
+
(r'(indigo|gold|firebrick|indianred|darkolivegreen|'
|
1552
|
+
r'darkseagreen|mediumvioletred|mediumorchid|chartreuse|'
|
1553
|
+
r'mediumslateblue|springgreen|crimson|lightsalmon|brown|'
|
1554
|
+
r'turquoise|olivedrab|cyan|skyblue|darkturquoise|'
|
1555
|
+
r'goldenrod|darkgreen|darkviolet|darkgray|lightpink|'
|
1556
|
+
r'darkmagenta|lightgoldenrodyellow|lavender|yellowgreen|thistle|'
|
1557
|
+
r'violet|orchid|ghostwhite|honeydew|cornflowerblue|'
|
1558
|
+
r'darkblue|darkkhaki|mediumpurple|cornsilk|bisque|slategray|'
|
1559
|
+
r'darkcyan|khaki|wheat|deepskyblue|darkred|steelblue|aliceblue|'
|
1560
|
+
r'gainsboro|mediumturquoise|floralwhite|coral|lightgrey|'
|
1561
|
+
r'lightcyan|darksalmon|beige|azure|lightsteelblue|oldlace|'
|
1562
|
+
r'greenyellow|royalblue|lightseagreen|mistyrose|sienna|'
|
1563
|
+
r'lightcoral|orangered|navajowhite|palegreen|burlywood|'
|
1564
|
+
r'seashell|mediumspringgreen|papayawhip|blanchedalmond|'
|
1565
|
+
r'peru|aquamarine|darkslategray|ivory|dodgerblue|'
|
1566
|
+
r'lemonchiffon|chocolate|orange|forestgreen|slateblue|'
|
1567
|
+
r'mintcream|antiquewhite|darkorange|cadetblue|moccasin|'
|
1568
|
+
r'limegreen|saddlebrown|darkslateblue|lightskyblue|deeppink|'
|
1569
|
+
r'plum|darkgoldenrod|sandybrown|magenta|tan|'
|
1570
|
+
r'rosybrown|pink|lightblue|palevioletred|mediumseagreen|'
|
1571
|
+
r'dimgray|powderblue|seagreen|snow|mediumblue|midnightblue|'
|
1572
|
+
r'paleturquoise|palegoldenrod|whitesmoke|darkorchid|salmon|'
|
1573
|
+
r'lightslategray|lawngreen|lightgreen|tomato|hotpink|'
|
1574
|
+
r'lightyellow|lavenderblush|linen|mediumaquamarine|'
|
1575
|
+
r'blueviolet|peachpuff)\b', Name.Entity),
|
1576
|
+
(r'(black|silver|gray|white|maroon|red|purple|fuchsia|green|'
|
1577
|
+
r'lime|olive|yellow|navy|blue|teal|aqua)\b', Name.Builtin),
|
1578
|
+
(r'\!(important|default)', Name.Exception),
|
1579
|
+
(r'(true|false)', Name.Pseudo),
|
1580
|
+
(r'(and|or|not)', Operator.Word),
|
1581
|
+
(r'/\*', Comment.Multiline, 'inline-comment'),
|
1582
|
+
(r'//[^\n]*', Comment.Single),
|
1583
|
+
(r'\#[a-z0-9]{1,6}', Number.Hex),
|
1584
|
+
(r'(-?\d+)(\%|[a-z]+)?', bygroups(Number.Integer, Keyword.Type)),
|
1585
|
+
(r'(-?\d*\.\d+)(\%|[a-z]+)?', bygroups(Number.Float, Keyword.Type)),
|
1586
|
+
(r'#{', String.Interpol, 'interpolation'),
|
1587
|
+
(r'[~\^\*!&%<>\|+=@:,./?-]+', Operator),
|
1588
|
+
(r'[\[\]()]+', Punctuation),
|
1589
|
+
(r'"', String.Double, 'string-double'),
|
1590
|
+
(r"'", String.Single, 'string-single'),
|
1591
|
+
(r'[a-z_-][\w-]*', Name),
|
1592
|
+
],
|
1593
|
+
|
1594
|
+
'interpolation': [
|
1595
|
+
(r'\}', String.Interpol, '#pop'),
|
1596
|
+
include('value'),
|
1597
|
+
],
|
1598
|
+
|
1599
|
+
'selector': [
|
1600
|
+
(r'[ \t]+', Text),
|
1601
|
+
(r'\:', Name.Decorator, 'pseudo-class'),
|
1602
|
+
(r'\.', Name.Class, 'class'),
|
1603
|
+
(r'\#', Name.Namespace, 'id'),
|
1604
|
+
(r'[a-zA-Z0-9_-]+', Name.Tag),
|
1605
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
1606
|
+
(r'&', Keyword),
|
1607
|
+
(r'[~\^\*!&\[\]\(\)<>\|+=@:;,./?-]', Operator),
|
1608
|
+
(r'"', String.Double, 'string-double'),
|
1609
|
+
(r"'", String.Single, 'string-single'),
|
1610
|
+
],
|
1611
|
+
|
1612
|
+
'string-double': [
|
1613
|
+
(r'(\\.|#(?=[^\n{])|[^\n"#])+', String.Double),
|
1614
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
1615
|
+
(r'"', String.Double, '#pop'),
|
1616
|
+
],
|
1617
|
+
|
1618
|
+
'string-single': [
|
1619
|
+
(r"(\\.|#(?=[^\n{])|[^\n'#])+", String.Double),
|
1620
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
1621
|
+
(r"'", String.Double, '#pop'),
|
1622
|
+
],
|
1623
|
+
|
1624
|
+
'string-url': [
|
1625
|
+
(r'(\\#|#(?=[^\n{])|[^\n#)])+', String.Other),
|
1626
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
1627
|
+
(r'\)', String.Other, '#pop'),
|
1628
|
+
],
|
1629
|
+
|
1630
|
+
'pseudo-class': [
|
1631
|
+
(r'[\w-]+', Name.Decorator),
|
1632
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
1633
|
+
(r'', Text, '#pop'),
|
1634
|
+
],
|
1635
|
+
|
1636
|
+
'class': [
|
1637
|
+
(r'[\w-]+', Name.Class),
|
1638
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
1639
|
+
(r'', Text, '#pop'),
|
1640
|
+
],
|
1641
|
+
|
1642
|
+
'id': [
|
1643
|
+
(r'[\w-]+', Name.Namespace),
|
1644
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
1645
|
+
(r'', Text, '#pop'),
|
1646
|
+
],
|
1647
|
+
|
1648
|
+
'for': [
|
1649
|
+
(r'(from|to|through)', Operator.Word),
|
1650
|
+
include('value'),
|
1651
|
+
],
|
1652
|
+
}
|
1653
|
+
|
1654
|
+
class SassLexer(ExtendedRegexLexer):
|
1655
|
+
"""
|
1656
|
+
For Sass stylesheets.
|
1657
|
+
|
1658
|
+
*New in Pygments 1.3.*
|
1659
|
+
"""
|
1660
|
+
|
1661
|
+
name = 'Sass'
|
1662
|
+
aliases = ['sass', 'SASS']
|
1663
|
+
filenames = ['*.sass']
|
1664
|
+
mimetypes = ['text/x-sass']
|
1665
|
+
|
1666
|
+
flags = re.IGNORECASE
|
1667
|
+
tokens = {
|
1668
|
+
'root': [
|
1669
|
+
(r'[ \t]*\n', Text),
|
1670
|
+
(r'[ \t]*', _indentation),
|
1671
|
+
],
|
1672
|
+
|
1673
|
+
'content': [
|
1674
|
+
(r'//[^\n]*', _starts_block(Comment.Single, 'single-comment'),
|
1675
|
+
'root'),
|
1676
|
+
(r'/\*[^\n]*', _starts_block(Comment.Multiline, 'multi-comment'),
|
1677
|
+
'root'),
|
1678
|
+
(r'@import', Keyword, 'import'),
|
1679
|
+
(r'@for', Keyword, 'for'),
|
1680
|
+
(r'@(debug|warn|if|while)', Keyword, 'value'),
|
1681
|
+
(r'(@mixin)( [\w-]+)', bygroups(Keyword, Name.Function), 'value'),
|
1682
|
+
(r'(@include)( [\w-]+)', bygroups(Keyword, Name.Decorator), 'value'),
|
1683
|
+
(r'@extend', Keyword, 'selector'),
|
1684
|
+
(r'@[a-z0-9_-]+', Keyword, 'selector'),
|
1685
|
+
(r'=[\w-]+', Name.Function, 'value'),
|
1686
|
+
(r'\+[\w-]+', Name.Decorator, 'value'),
|
1687
|
+
(r'([!$][\w-]\w*)([ \t]*(?:(?:\|\|)?=|:))',
|
1688
|
+
bygroups(Name.Variable, Operator), 'value'),
|
1689
|
+
(r':', Name.Attribute, 'old-style-attr'),
|
1690
|
+
(r'(?=.+?[=:]([^a-z]|$))', Name.Attribute, 'new-style-attr'),
|
1691
|
+
(r'', Text, 'selector'),
|
1692
|
+
],
|
1693
|
+
|
1694
|
+
'single-comment': [
|
1695
|
+
(r'.+', Comment.Single),
|
1696
|
+
(r'\n', Text, 'root'),
|
1697
|
+
],
|
1698
|
+
|
1699
|
+
'multi-comment': [
|
1700
|
+
(r'.+', Comment.Multiline),
|
1701
|
+
(r'\n', Text, 'root'),
|
1702
|
+
],
|
1703
|
+
|
1704
|
+
'import': [
|
1705
|
+
(r'[ \t]+', Text),
|
1706
|
+
(r'\S+', String),
|
1707
|
+
(r'\n', Text, 'root'),
|
1708
|
+
],
|
1709
|
+
|
1710
|
+
'old-style-attr': [
|
1711
|
+
(r'[^\s:="\[]+', Name.Attribute),
|
1712
|
+
(r'#{', String.Interpol, 'interpolation'),
|
1713
|
+
(r'[ \t]*=', Operator, 'value'),
|
1714
|
+
(r'', Text, 'value'),
|
1715
|
+
],
|
1716
|
+
|
1717
|
+
'new-style-attr': [
|
1718
|
+
(r'[^\s:="\[]+', Name.Attribute),
|
1719
|
+
(r'#{', String.Interpol, 'interpolation'),
|
1720
|
+
(r'[ \t]*[=:]', Operator, 'value'),
|
1721
|
+
],
|
1722
|
+
|
1723
|
+
'inline-comment': [
|
1724
|
+
(r"(\\#|#(?=[^\n{])|\*(?=[^\n/])|[^\n#*])+", Comment.Multiline),
|
1725
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
1726
|
+
(r"\*/", Comment, '#pop'),
|
1727
|
+
],
|
1728
|
+
}
|
1729
|
+
for group, common in common_sass_tokens.iteritems():
|
1730
|
+
tokens[group] = copy.copy(common)
|
1731
|
+
tokens['value'].append((r'\n', Text, 'root'))
|
1732
|
+
tokens['selector'].append((r'\n', Text, 'root'))
|
1733
|
+
|
1734
|
+
|
1735
|
+
class ScssLexer(RegexLexer):
|
1736
|
+
"""
|
1737
|
+
For SCSS stylesheets.
|
1738
|
+
"""
|
1739
|
+
|
1740
|
+
name = 'SCSS'
|
1741
|
+
aliases = ['scss']
|
1742
|
+
filenames = ['*.scss']
|
1743
|
+
mimetypes = ['text/x-scss']
|
1744
|
+
|
1745
|
+
flags = re.IGNORECASE | re.DOTALL
|
1746
|
+
tokens = {
|
1747
|
+
'root': [
|
1748
|
+
(r'\s+', Text),
|
1749
|
+
(r'//.*?\n', Comment.Single),
|
1750
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
1751
|
+
(r'@import', Keyword, 'value'),
|
1752
|
+
(r'@for', Keyword, 'for'),
|
1753
|
+
(r'@(debug|warn|if|while)', Keyword, 'value'),
|
1754
|
+
(r'(@mixin)( [\w-]+)', bygroups(Keyword, Name.Function), 'value'),
|
1755
|
+
(r'(@include)( [\w-]+)', bygroups(Keyword, Name.Decorator), 'value'),
|
1756
|
+
(r'@extend', Keyword, 'selector'),
|
1757
|
+
(r'@[a-z0-9_-]+', Keyword, 'selector'),
|
1758
|
+
(r'(\$[\w-]\w*)([ \t]*:)', bygroups(Name.Variable, Operator), 'value'),
|
1759
|
+
(r'(?=[^;{}][;}])', Name.Attribute, 'attr'),
|
1760
|
+
(r'(?=[^;{}:]+:[^a-z])', Name.Attribute, 'attr'),
|
1761
|
+
(r'', Text, 'selector'),
|
1762
|
+
],
|
1763
|
+
|
1764
|
+
'attr': [
|
1765
|
+
(r'[^\s:="\[]+', Name.Attribute),
|
1766
|
+
(r'#{', String.Interpol, 'interpolation'),
|
1767
|
+
(r'[ \t]*:', Operator, 'value'),
|
1768
|
+
],
|
1769
|
+
|
1770
|
+
'inline-comment': [
|
1771
|
+
(r"(\\#|#(?=[^{])|\*(?=[^/])|[^#*])+", Comment.Multiline),
|
1772
|
+
(r'#\{', String.Interpol, 'interpolation'),
|
1773
|
+
(r"\*/", Comment, '#pop'),
|
1774
|
+
],
|
1775
|
+
}
|
1776
|
+
for group, common in common_sass_tokens.iteritems():
|
1777
|
+
tokens[group] = copy.copy(common)
|
1778
|
+
tokens['value'].extend([(r'\n', Text), (r'[;{}]', Punctuation, 'root')])
|
1779
|
+
tokens['selector'].extend([(r'\n', Text), (r'[;{}]', Punctuation, 'root')])
|
1780
|
+
|
1781
|
+
|
1782
|
+
class CoffeeScriptLexer(RegexLexer):
|
1783
|
+
"""
|
1784
|
+
For `CoffeeScript`_ source code.
|
1785
|
+
|
1786
|
+
.. _CoffeeScript: http://coffeescript.org
|
1787
|
+
|
1788
|
+
*New in Pygments 1.3.*
|
1789
|
+
"""
|
1790
|
+
|
1791
|
+
name = 'CoffeeScript'
|
1792
|
+
aliases = ['coffee-script', 'coffeescript']
|
1793
|
+
filenames = ['*.coffee']
|
1794
|
+
mimetypes = ['text/coffeescript']
|
1795
|
+
|
1796
|
+
flags = re.DOTALL
|
1797
|
+
tokens = {
|
1798
|
+
'commentsandwhitespace': [
|
1799
|
+
(r'\s+', Text),
|
1800
|
+
(r'###.*?###', Comment.Multiline),
|
1801
|
+
(r'#.*?\n', Comment.Single),
|
1802
|
+
],
|
1803
|
+
'multilineregex': [
|
1804
|
+
include('commentsandwhitespace'),
|
1805
|
+
(r'///([gim]+\b|\B)', String.Regex, '#pop'),
|
1806
|
+
(r'/', String.Regex),
|
1807
|
+
(r'[^/#]+', String.Regex)
|
1808
|
+
],
|
1809
|
+
'slashstartsregex': [
|
1810
|
+
include('commentsandwhitespace'),
|
1811
|
+
(r'///', String.Regex, ('#pop', 'multilineregex')),
|
1812
|
+
(r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
1813
|
+
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
1814
|
+
(r'', Text, '#pop'),
|
1815
|
+
],
|
1816
|
+
'root': [
|
1817
|
+
# this next expr leads to infinite loops root -> slashstartsregex
|
1818
|
+
#(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
|
1819
|
+
include('commentsandwhitespace'),
|
1820
|
+
(r'\+\+|--|~|&&|\band\b|\bor\b|\bis\b|\bisnt\b|\bnot\b|\?|:|=|'
|
1821
|
+
r'\|\||\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*`%&\|\^/])=?',
|
1822
|
+
Operator, 'slashstartsregex'),
|
1823
|
+
(r'\([^()]*\)\s*->', Name.Function),
|
1824
|
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
1825
|
+
(r'[})\].]', Punctuation),
|
1826
|
+
(r'(for|in|of|while|break|return|continue|switch|when|then|if|else|'
|
1827
|
+
r'throw|try|catch|finally|new|delete|typeof|instanceof|super|'
|
1828
|
+
r'extends|this|class|by)\b', Keyword, 'slashstartsregex'),
|
1829
|
+
(r'(true|false|yes|no|on|off|null|NaN|Infinity|undefined)\b',
|
1830
|
+
Keyword.Constant),
|
1831
|
+
(r'(Array|Boolean|Date|Error|Function|Math|netscape|'
|
1832
|
+
r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
|
1833
|
+
r'decodeURIComponent|encodeURI|encodeURIComponent|'
|
1834
|
+
r'eval|isFinite|isNaN|parseFloat|parseInt|document|window)\b',
|
1835
|
+
Name.Builtin),
|
1836
|
+
(r'[$a-zA-Z_][a-zA-Z0-9_\.:]*\s*[:=]\s', Name.Variable,
|
1837
|
+
'slashstartsregex'),
|
1838
|
+
(r'@[$a-zA-Z_][a-zA-Z0-9_\.:]*\s*[:=]\s', Name.Variable.Instance,
|
1839
|
+
'slashstartsregex'),
|
1840
|
+
(r'@', Name.Other, 'slashstartsregex'),
|
1841
|
+
(r'@?[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other, 'slashstartsregex'),
|
1842
|
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
1843
|
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
1844
|
+
(r'[0-9]+', Number.Integer),
|
1845
|
+
('"""', String, 'tdqs'),
|
1846
|
+
("'''", String, 'tsqs'),
|
1847
|
+
('"', String, 'dqs'),
|
1848
|
+
("'", String, 'sqs'),
|
1849
|
+
],
|
1850
|
+
'strings': [
|
1851
|
+
(r'[^#\\\'"]+', String),
|
1852
|
+
# note that all coffee script strings are multi-line.
|
1853
|
+
# hashmarks, quotes and backslashes must be parsed one at a time
|
1854
|
+
],
|
1855
|
+
'interpoling_string' : [
|
1856
|
+
(r'}', String.Interpol, "#pop"),
|
1857
|
+
include('root')
|
1858
|
+
],
|
1859
|
+
'dqs': [
|
1860
|
+
(r'"', String, '#pop'),
|
1861
|
+
(r'\\.|\'', String), # double-quoted string don't need ' escapes
|
1862
|
+
(r'#{', String.Interpol, "interpoling_string"),
|
1863
|
+
include('strings')
|
1864
|
+
],
|
1865
|
+
'sqs': [
|
1866
|
+
(r"'", String, '#pop'),
|
1867
|
+
(r'#|\\.|"', String), # single quoted strings don't need " escapses
|
1868
|
+
include('strings')
|
1869
|
+
],
|
1870
|
+
'tdqs': [
|
1871
|
+
(r'"""', String, '#pop'),
|
1872
|
+
(r'\\.|\'|"', String), # no need to escape quotes in triple-string
|
1873
|
+
(r'#{', String.Interpol, "interpoling_string"),
|
1874
|
+
include('strings'),
|
1875
|
+
],
|
1876
|
+
'tsqs': [
|
1877
|
+
(r"'''", String, '#pop'),
|
1878
|
+
(r'#|\\.|\'|"', String), # no need to escape quotes in triple-strings
|
1879
|
+
include('strings')
|
1880
|
+
],
|
1881
|
+
}
|
1882
|
+
|
1883
|
+
class DuelLexer(RegexLexer):
|
1884
|
+
"""
|
1885
|
+
Lexer for Duel Views Engine (formerly JBST) markup with JavaScript code blocks.
|
1886
|
+
See http://duelengine.org/.
|
1887
|
+
See http://jsonml.org/jbst/.
|
1888
|
+
|
1889
|
+
*New in Pygments 1.4.*
|
1890
|
+
"""
|
1891
|
+
|
1892
|
+
name = 'Duel'
|
1893
|
+
aliases = ['duel', 'Duel Engine', 'Duel View', 'JBST', 'jbst', 'JsonML+BST']
|
1894
|
+
filenames = ['*.duel','*.jbst']
|
1895
|
+
mimetypes = ['text/x-duel','text/x-jbst']
|
1896
|
+
|
1897
|
+
flags = re.DOTALL
|
1898
|
+
|
1899
|
+
tokens = {
|
1900
|
+
'root': [
|
1901
|
+
(r'(<%[@=#!:]?)(.*?)(%>)',
|
1902
|
+
bygroups(Name.Tag, using(JavascriptLexer), Name.Tag)),
|
1903
|
+
(r'(<%\$)(.*?)(:)(.*?)(%>)',
|
1904
|
+
bygroups(Name.Tag, Name.Function, Punctuation, String, Name.Tag)),
|
1905
|
+
(r'(<%--)(.*?)(--%>)',
|
1906
|
+
bygroups(Name.Tag, Comment.Multiline, Name.Tag)),
|
1907
|
+
(r'(<script.*?>)(.*?)(</script>)',
|
1908
|
+
bygroups(using(HtmlLexer),
|
1909
|
+
using(JavascriptLexer), using(HtmlLexer))),
|
1910
|
+
(r'(.+?)(?=<)', using(HtmlLexer)),
|
1911
|
+
(r'.+', using(HtmlLexer)),
|
1912
|
+
],
|
1913
|
+
}
|
1914
|
+
|
1915
|
+
|
1916
|
+
class ScamlLexer(ExtendedRegexLexer):
|
1917
|
+
"""
|
1918
|
+
For `Scaml markup <http://scalate.fusesource.org/>`_. Scaml is Haml for Scala.
|
1919
|
+
|
1920
|
+
*New in Pygments 1.4.*
|
1921
|
+
"""
|
1922
|
+
|
1923
|
+
name = 'Scaml'
|
1924
|
+
aliases = ['scaml', 'SCAML']
|
1925
|
+
filenames = ['*.scaml']
|
1926
|
+
mimetypes = ['text/x-scaml']
|
1927
|
+
|
1928
|
+
flags = re.IGNORECASE
|
1929
|
+
# Scaml does not yet support the " |\n" notation to
|
1930
|
+
# wrap long lines. Once it does, use the custom faux
|
1931
|
+
# dot instead.
|
1932
|
+
# _dot = r'(?: \|\n(?=.* \|)|.)'
|
1933
|
+
_dot = r'.'
|
1934
|
+
|
1935
|
+
tokens = {
|
1936
|
+
'root': [
|
1937
|
+
(r'[ \t]*\n', Text),
|
1938
|
+
(r'[ \t]*', _indentation),
|
1939
|
+
],
|
1940
|
+
|
1941
|
+
'css': [
|
1942
|
+
(r'\.[a-z0-9_:-]+', Name.Class, 'tag'),
|
1943
|
+
(r'\#[a-z0-9_:-]+', Name.Function, 'tag'),
|
1944
|
+
],
|
1945
|
+
|
1946
|
+
'eval-or-plain': [
|
1947
|
+
(r'[&!]?==', Punctuation, 'plain'),
|
1948
|
+
(r'([&!]?[=~])(' + _dot + r'*\n)',
|
1949
|
+
bygroups(Punctuation, using(ScalaLexer)),
|
1950
|
+
'root'),
|
1951
|
+
(r'', Text, 'plain'),
|
1952
|
+
],
|
1953
|
+
|
1954
|
+
'content': [
|
1955
|
+
include('css'),
|
1956
|
+
(r'%[a-z0-9_:-]+', Name.Tag, 'tag'),
|
1957
|
+
(r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'),
|
1958
|
+
(r'(/)(\[' + _dot + '*?\])(' + _dot + r'*\n)',
|
1959
|
+
bygroups(Comment, Comment.Special, Comment),
|
1960
|
+
'#pop'),
|
1961
|
+
(r'/' + _dot + r'*\n', _starts_block(Comment, 'html-comment-block'),
|
1962
|
+
'#pop'),
|
1963
|
+
(r'-#' + _dot + r'*\n', _starts_block(Comment.Preproc,
|
1964
|
+
'scaml-comment-block'), '#pop'),
|
1965
|
+
(r'(-@\s*)(import)?(' + _dot + r'*\n)',
|
1966
|
+
bygroups(Punctuation, Keyword, using(ScalaLexer)),
|
1967
|
+
'#pop'),
|
1968
|
+
(r'(-)(' + _dot + r'*\n)',
|
1969
|
+
bygroups(Punctuation, using(ScalaLexer)),
|
1970
|
+
'#pop'),
|
1971
|
+
(r':' + _dot + r'*\n', _starts_block(Name.Decorator, 'filter-block'),
|
1972
|
+
'#pop'),
|
1973
|
+
include('eval-or-plain'),
|
1974
|
+
],
|
1975
|
+
|
1976
|
+
'tag': [
|
1977
|
+
include('css'),
|
1978
|
+
(r'\{(,\n|' + _dot + ')*?\}', using(ScalaLexer)),
|
1979
|
+
(r'\[' + _dot + '*?\]', using(ScalaLexer)),
|
1980
|
+
(r'\(', Text, 'html-attributes'),
|
1981
|
+
(r'/[ \t]*\n', Punctuation, '#pop:2'),
|
1982
|
+
(r'[<>]{1,2}(?=[ \t=])', Punctuation),
|
1983
|
+
include('eval-or-plain'),
|
1984
|
+
],
|
1985
|
+
|
1986
|
+
'plain': [
|
1987
|
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text),
|
1988
|
+
(r'(#\{)(' + _dot + '*?)(\})',
|
1989
|
+
bygroups(String.Interpol, using(ScalaLexer), String.Interpol)),
|
1990
|
+
(r'\n', Text, 'root'),
|
1991
|
+
],
|
1992
|
+
|
1993
|
+
'html-attributes': [
|
1994
|
+
(r'\s+', Text),
|
1995
|
+
(r'[a-z0-9_:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
|
1996
|
+
(r'[a-z0-9_:-]+', Name.Attribute),
|
1997
|
+
(r'\)', Text, '#pop'),
|
1998
|
+
],
|
1999
|
+
|
2000
|
+
'html-attribute-value': [
|
2001
|
+
(r'[ \t]+', Text),
|
2002
|
+
(r'[a-z0-9_]+', Name.Variable, '#pop'),
|
2003
|
+
(r'@[a-z0-9_]+', Name.Variable.Instance, '#pop'),
|
2004
|
+
(r'\$[a-z0-9_]+', Name.Variable.Global, '#pop'),
|
2005
|
+
(r"'(\\\\|\\'|[^'\n])*'", String, '#pop'),
|
2006
|
+
(r'"(\\\\|\\"|[^"\n])*"', String, '#pop'),
|
2007
|
+
],
|
2008
|
+
|
2009
|
+
'html-comment-block': [
|
2010
|
+
(_dot + '+', Comment),
|
2011
|
+
(r'\n', Text, 'root'),
|
2012
|
+
],
|
2013
|
+
|
2014
|
+
'scaml-comment-block': [
|
2015
|
+
(_dot + '+', Comment.Preproc),
|
2016
|
+
(r'\n', Text, 'root'),
|
2017
|
+
],
|
2018
|
+
|
2019
|
+
'filter-block': [
|
2020
|
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Name.Decorator),
|
2021
|
+
(r'(#\{)(' + _dot + '*?)(\})',
|
2022
|
+
bygroups(String.Interpol, using(ScalaLexer), String.Interpol)),
|
2023
|
+
(r'\n', Text, 'root'),
|
2024
|
+
],
|
2025
|
+
}
|
2026
|
+
|
2027
|
+
|
2028
|
+
class JadeLexer(ExtendedRegexLexer):
|
2029
|
+
"""
|
2030
|
+
For Jade markup.
|
2031
|
+
Jade is a variant of Scaml, see:
|
2032
|
+
http://scalate.fusesource.org/documentation/scaml-reference.html
|
2033
|
+
|
2034
|
+
*New in Pygments 1.4.*
|
2035
|
+
"""
|
2036
|
+
|
2037
|
+
name = 'Jade'
|
2038
|
+
aliases = ['jade', 'JADE']
|
2039
|
+
filenames = ['*.jade']
|
2040
|
+
mimetypes = ['text/x-jade']
|
2041
|
+
|
2042
|
+
flags = re.IGNORECASE
|
2043
|
+
_dot = r'.'
|
2044
|
+
|
2045
|
+
tokens = {
|
2046
|
+
'root': [
|
2047
|
+
(r'[ \t]*\n', Text),
|
2048
|
+
(r'[ \t]*', _indentation),
|
2049
|
+
],
|
2050
|
+
|
2051
|
+
'css': [
|
2052
|
+
(r'\.[a-z0-9_:-]+', Name.Class, 'tag'),
|
2053
|
+
(r'\#[a-z0-9_:-]+', Name.Function, 'tag'),
|
2054
|
+
],
|
2055
|
+
|
2056
|
+
'eval-or-plain': [
|
2057
|
+
(r'[&!]?==', Punctuation, 'plain'),
|
2058
|
+
(r'([&!]?[=~])(' + _dot + r'*\n)',
|
2059
|
+
bygroups(Punctuation, using(ScalaLexer)), 'root'),
|
2060
|
+
(r'', Text, 'plain'),
|
2061
|
+
],
|
2062
|
+
|
2063
|
+
'content': [
|
2064
|
+
include('css'),
|
2065
|
+
(r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'),
|
2066
|
+
(r'(/)(\[' + _dot + '*?\])(' + _dot + r'*\n)',
|
2067
|
+
bygroups(Comment, Comment.Special, Comment),
|
2068
|
+
'#pop'),
|
2069
|
+
(r'/' + _dot + r'*\n', _starts_block(Comment, 'html-comment-block'),
|
2070
|
+
'#pop'),
|
2071
|
+
(r'-#' + _dot + r'*\n', _starts_block(Comment.Preproc,
|
2072
|
+
'scaml-comment-block'), '#pop'),
|
2073
|
+
(r'(-@\s*)(import)?(' + _dot + r'*\n)',
|
2074
|
+
bygroups(Punctuation, Keyword, using(ScalaLexer)),
|
2075
|
+
'#pop'),
|
2076
|
+
(r'(-)(' + _dot + r'*\n)',
|
2077
|
+
bygroups(Punctuation, using(ScalaLexer)),
|
2078
|
+
'#pop'),
|
2079
|
+
(r':' + _dot + r'*\n', _starts_block(Name.Decorator, 'filter-block'),
|
2080
|
+
'#pop'),
|
2081
|
+
(r'[a-z0-9_:-]+', Name.Tag, 'tag'),
|
2082
|
+
(r'\|', Text, 'eval-or-plain'),
|
2083
|
+
],
|
2084
|
+
|
2085
|
+
'tag': [
|
2086
|
+
include('css'),
|
2087
|
+
(r'\{(,\n|' + _dot + ')*?\}', using(ScalaLexer)),
|
2088
|
+
(r'\[' + _dot + '*?\]', using(ScalaLexer)),
|
2089
|
+
(r'\(', Text, 'html-attributes'),
|
2090
|
+
(r'/[ \t]*\n', Punctuation, '#pop:2'),
|
2091
|
+
(r'[<>]{1,2}(?=[ \t=])', Punctuation),
|
2092
|
+
include('eval-or-plain'),
|
2093
|
+
],
|
2094
|
+
|
2095
|
+
'plain': [
|
2096
|
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text),
|
2097
|
+
(r'(#\{)(' + _dot + '*?)(\})',
|
2098
|
+
bygroups(String.Interpol, using(ScalaLexer), String.Interpol)),
|
2099
|
+
(r'\n', Text, 'root'),
|
2100
|
+
],
|
2101
|
+
|
2102
|
+
'html-attributes': [
|
2103
|
+
(r'\s+', Text),
|
2104
|
+
(r'[a-z0-9_:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
|
2105
|
+
(r'[a-z0-9_:-]+', Name.Attribute),
|
2106
|
+
(r'\)', Text, '#pop'),
|
2107
|
+
],
|
2108
|
+
|
2109
|
+
'html-attribute-value': [
|
2110
|
+
(r'[ \t]+', Text),
|
2111
|
+
(r'[a-z0-9_]+', Name.Variable, '#pop'),
|
2112
|
+
(r'@[a-z0-9_]+', Name.Variable.Instance, '#pop'),
|
2113
|
+
(r'\$[a-z0-9_]+', Name.Variable.Global, '#pop'),
|
2114
|
+
(r"'(\\\\|\\'|[^'\n])*'", String, '#pop'),
|
2115
|
+
(r'"(\\\\|\\"|[^"\n])*"', String, '#pop'),
|
2116
|
+
],
|
2117
|
+
|
2118
|
+
'html-comment-block': [
|
2119
|
+
(_dot + '+', Comment),
|
2120
|
+
(r'\n', Text, 'root'),
|
2121
|
+
],
|
2122
|
+
|
2123
|
+
'scaml-comment-block': [
|
2124
|
+
(_dot + '+', Comment.Preproc),
|
2125
|
+
(r'\n', Text, 'root'),
|
2126
|
+
],
|
2127
|
+
|
2128
|
+
'filter-block': [
|
2129
|
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Name.Decorator),
|
2130
|
+
(r'(#\{)(' + _dot + '*?)(\})',
|
2131
|
+
bygroups(String.Interpol, using(ScalaLexer), String.Interpol)),
|
2132
|
+
(r'\n', Text, 'root'),
|
2133
|
+
],
|
2134
|
+
}
|
2135
|
+
|
2136
|
+
|
2137
|
+
class XQueryLexer(ExtendedRegexLexer):
|
2138
|
+
"""
|
2139
|
+
An XQuery lexer, parsing a stream and outputting the tokens needed to
|
2140
|
+
highlight xquery code.
|
2141
|
+
|
2142
|
+
*New in Pygments 1.4.*
|
2143
|
+
"""
|
2144
|
+
name = 'XQuery'
|
2145
|
+
aliases = ['xquery', 'xqy']
|
2146
|
+
filenames = ['*.xqy', '*.xquery']
|
2147
|
+
mimetypes = ['text/xquery', 'application/xquery']
|
2148
|
+
|
2149
|
+
xquery_parse_state = []
|
2150
|
+
|
2151
|
+
# FIX UNICODE LATER
|
2152
|
+
#ncnamestartchar = (
|
2153
|
+
# ur"[A-Z]|_|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|"
|
2154
|
+
# ur"[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|"
|
2155
|
+
# ur"[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|"
|
2156
|
+
# ur"[\u10000-\uEFFFF]"
|
2157
|
+
#)
|
2158
|
+
ncnamestartchar = r"(?:[A-Z]|_|[a-z])"
|
2159
|
+
# FIX UNICODE LATER
|
2160
|
+
#ncnamechar = ncnamestartchar + (ur"|-|\.|[0-9]|\u00B7|[\u0300-\u036F]|"
|
2161
|
+
# ur"[\u203F-\u2040]")
|
2162
|
+
ncnamechar = r"(?:" + ncnamestartchar + r"|-|\.|[0-9])"
|
2163
|
+
ncname = "(?:%s+%s*)" % (ncnamestartchar, ncnamechar)
|
2164
|
+
pitarget_namestartchar = r"(?:[A-KN-WY-Z]|_|:|[a-kn-wy-z])"
|
2165
|
+
pitarget_namechar = r"(?:" + pitarget_namestartchar + r"|-|\.|[0-9])"
|
2166
|
+
pitarget = "%s+%s*" % (pitarget_namestartchar, pitarget_namechar)
|
2167
|
+
prefixedname = "%s:%s" % (ncname, ncname)
|
2168
|
+
unprefixedname = ncname
|
2169
|
+
qname = "(?:%s|%s)" % (prefixedname, unprefixedname)
|
2170
|
+
|
2171
|
+
entityref = r'(?:&(?:lt|gt|amp|quot|apos|nbsp);)'
|
2172
|
+
charref = r'(?:&#[0-9]+;|&#x[0-9a-fA-F]+;)'
|
2173
|
+
|
2174
|
+
stringdouble = r'(?:"(?:' + entityref + r'|' + charref + r'|""|[^&"])*")'
|
2175
|
+
stringsingle = r"(?:'(?:" + entityref + r"|" + charref + r"|''|[^&'])*')"
|
2176
|
+
|
2177
|
+
# FIX UNICODE LATER
|
2178
|
+
#elementcontentchar = (ur'\t|\r|\n|[\u0020-\u0025]|[\u0028-\u003b]|'
|
2179
|
+
# ur'[\u003d-\u007a]|\u007c|[\u007e-\u007F]')
|
2180
|
+
elementcontentchar = r'[A-Za-z]|\s|\d|[!"#$%\(\)\*\+,\-\./\:;=\?\@\[\\\]^_\'`\|~]'
|
2181
|
+
#quotattrcontentchar = (ur'\t|\r|\n|[\u0020-\u0021]|[\u0023-\u0025]|'
|
2182
|
+
# ur'[\u0027-\u003b]|[\u003d-\u007a]|\u007c|[\u007e-\u007F]')
|
2183
|
+
quotattrcontentchar = r'[A-Za-z]|\s|\d|[!#$%\(\)\*\+,\-\./\:;=\?\@\[\\\]^_\'`\|~]'
|
2184
|
+
#aposattrcontentchar = (ur'\t|\r|\n|[\u0020-\u0025]|[\u0028-\u003b]|'
|
2185
|
+
# ur'[\u003d-\u007a]|\u007c|[\u007e-\u007F]')
|
2186
|
+
aposattrcontentchar = r'[A-Za-z]|\s|\d|[!"#$%\(\)\*\+,\-\./\:;=\?\@\[\\\]^_`\|~]'
|
2187
|
+
|
2188
|
+
|
2189
|
+
# CHAR elements - fix the above elementcontentchar, quotattrcontentchar,
|
2190
|
+
# aposattrcontentchar
|
2191
|
+
#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
|
2192
|
+
|
2193
|
+
flags = re.DOTALL | re.MULTILINE | re.UNICODE
|
2194
|
+
|
2195
|
+
def punctuation_root_callback(lexer, match, ctx):
|
2196
|
+
yield match.start(), Punctuation, match.group(1)
|
2197
|
+
# transition to root always - don't pop off stack
|
2198
|
+
ctx.stack = ['root']
|
2199
|
+
ctx.pos = match.end()
|
2200
|
+
|
2201
|
+
def operator_root_callback(lexer, match, ctx):
|
2202
|
+
yield match.start(), Operator, match.group(1)
|
2203
|
+
# transition to root always - don't pop off stack
|
2204
|
+
ctx.stack = ['root']
|
2205
|
+
ctx.pos = match.end()
|
2206
|
+
|
2207
|
+
def popstate_tag_callback(lexer, match, ctx):
|
2208
|
+
yield match.start(), Name.Tag, match.group(1)
|
2209
|
+
ctx.stack.append(lexer.xquery_parse_state.pop())
|
2210
|
+
ctx.pos = match.end()
|
2211
|
+
|
2212
|
+
def popstate_xmlcomment_callback(lexer, match, ctx):
|
2213
|
+
yield match.start(), String.Doc, match.group(1)
|
2214
|
+
ctx.stack.append(lexer.xquery_parse_state.pop())
|
2215
|
+
ctx.pos = match.end()
|
2216
|
+
|
2217
|
+
def popstate_kindtest_callback(lexer, match, ctx):
|
2218
|
+
yield match.start(), Punctuation, match.group(1)
|
2219
|
+
next_state = lexer.xquery_parse_state.pop()
|
2220
|
+
if next_state == 'occurrenceindicator':
|
2221
|
+
if re.match("[?*+]+", match.group(2)):
|
2222
|
+
yield match.start(), Punctuation, match.group(2)
|
2223
|
+
ctx.stack.append('operator')
|
2224
|
+
ctx.pos = match.end()
|
2225
|
+
else:
|
2226
|
+
ctx.stack.append('operator')
|
2227
|
+
ctx.pos = match.end(1)
|
2228
|
+
else:
|
2229
|
+
ctx.stack.append(next_state)
|
2230
|
+
ctx.pos = match.end(1)
|
2231
|
+
|
2232
|
+
def popstate_callback(lexer, match, ctx):
|
2233
|
+
yield match.start(), Punctuation, match.group(1)
|
2234
|
+
# if we have run out of our state stack, pop whatever is on the pygments
|
2235
|
+
# state stack
|
2236
|
+
if len(lexer.xquery_parse_state) == 0:
|
2237
|
+
ctx.stack.pop()
|
2238
|
+
elif len(ctx.stack) > 1:
|
2239
|
+
ctx.stack.append(lexer.xquery_parse_state.pop())
|
2240
|
+
else:
|
2241
|
+
# i don't know if i'll need this, but in case, default back to root
|
2242
|
+
ctx.stack = ['root']
|
2243
|
+
ctx.pos = match.end()
|
2244
|
+
|
2245
|
+
def pushstate_element_content_starttag_callback(lexer, match, ctx):
|
2246
|
+
yield match.start(), Name.Tag, match.group(1)
|
2247
|
+
lexer.xquery_parse_state.append('element_content')
|
2248
|
+
ctx.stack.append('start_tag')
|
2249
|
+
ctx.pos = match.end()
|
2250
|
+
|
2251
|
+
def pushstate_cdata_section_callback(lexer, match, ctx):
|
2252
|
+
yield match.start(), String.Doc, match.group(1)
|
2253
|
+
ctx.stack.append('cdata_section')
|
2254
|
+
lexer.xquery_parse_state.append(ctx.state.pop)
|
2255
|
+
ctx.pos = match.end()
|
2256
|
+
|
2257
|
+
def pushstate_starttag_callback(lexer, match, ctx):
|
2258
|
+
yield match.start(), Name.Tag, match.group(1)
|
2259
|
+
lexer.xquery_parse_state.append(ctx.state.pop)
|
2260
|
+
ctx.stack.append('start_tag')
|
2261
|
+
ctx.pos = match.end()
|
2262
|
+
|
2263
|
+
def pushstate_operator_order_callback(lexer, match, ctx):
|
2264
|
+
yield match.start(), Keyword, match.group(1)
|
2265
|
+
yield match.start(), Text, match.group(2)
|
2266
|
+
yield match.start(), Punctuation, match.group(3)
|
2267
|
+
ctx.stack = ['root']
|
2268
|
+
lexer.xquery_parse_state.append('operator')
|
2269
|
+
ctx.pos = match.end()
|
2270
|
+
|
2271
|
+
def pushstate_operator_root_validate(lexer, match, ctx):
|
2272
|
+
yield match.start(), Keyword, match.group(1)
|
2273
|
+
yield match.start(), Text, match.group(2)
|
2274
|
+
yield match.start(), Punctuation, match.group(3)
|
2275
|
+
ctx.stack = ['root']
|
2276
|
+
lexer.xquery_parse_state.append('operator')
|
2277
|
+
ctx.pos = match.end()
|
2278
|
+
|
2279
|
+
def pushstate_operator_root_validate_withmode(lexer, match, ctx):
|
2280
|
+
yield match.start(), Keyword, match.group(1)
|
2281
|
+
yield match.start(), Text, match.group(2)
|
2282
|
+
yield match.start(), Keyword, match.group(3)
|
2283
|
+
ctx.stack = ['root']
|
2284
|
+
lexer.xquery_parse_state.append('operator')
|
2285
|
+
ctx.pos = match.end()
|
2286
|
+
|
2287
|
+
def pushstate_operator_processing_instruction_callback(lexer, match, ctx):
|
2288
|
+
yield match.start(), String.Doc, match.group(1)
|
2289
|
+
ctx.stack.append('processing_instruction')
|
2290
|
+
lexer.xquery_parse_state.append('operator')
|
2291
|
+
ctx.pos = match.end()
|
2292
|
+
|
2293
|
+
def pushstate_element_content_processing_instruction_callback(lexer, match, ctx):
|
2294
|
+
yield match.start(), String.Doc, match.group(1)
|
2295
|
+
ctx.stack.append('processing_instruction')
|
2296
|
+
lexer.xquery_parse_state.append('element_content')
|
2297
|
+
ctx.pos = match.end()
|
2298
|
+
|
2299
|
+
def pushstate_element_content_cdata_section_callback(lexer, match, ctx):
|
2300
|
+
yield match.start(), String.Doc, match.group(1)
|
2301
|
+
ctx.stack.append('cdata_section')
|
2302
|
+
lexer.xquery_parse_state.append('element_content')
|
2303
|
+
ctx.pos = match.end()
|
2304
|
+
|
2305
|
+
def pushstate_operator_cdata_section_callback(lexer, match, ctx):
|
2306
|
+
yield match.start(), String.Doc, match.group(1)
|
2307
|
+
ctx.stack.append('cdata_section')
|
2308
|
+
lexer.xquery_parse_state.append('operator')
|
2309
|
+
ctx.pos = match.end()
|
2310
|
+
|
2311
|
+
def pushstate_element_content_xmlcomment_callback(lexer, match, ctx):
|
2312
|
+
yield match.start(), String.Doc, match.group(1)
|
2313
|
+
ctx.stack.append('xml_comment')
|
2314
|
+
lexer.xquery_parse_state.append('element_content')
|
2315
|
+
ctx.pos = match.end()
|
2316
|
+
|
2317
|
+
def pushstate_operator_xmlcomment_callback(lexer, match, ctx):
|
2318
|
+
yield match.start(), String.Doc, match.group(1)
|
2319
|
+
ctx.stack.append('xml_comment')
|
2320
|
+
lexer.xquery_parse_state.append('operator')
|
2321
|
+
ctx.pos = match.end()
|
2322
|
+
|
2323
|
+
def pushstate_kindtest_callback(lexer, match, ctx):
|
2324
|
+
yield match.start(), Keyword, match.group(1)
|
2325
|
+
yield match.start(), Text, match.group(2)
|
2326
|
+
yield match.start(), Punctuation, match.group(3)
|
2327
|
+
lexer.xquery_parse_state.append('kindtest')
|
2328
|
+
ctx.stack.append('kindtest')
|
2329
|
+
ctx.pos = match.end()
|
2330
|
+
|
2331
|
+
def pushstate_operator_kindtestforpi_callback(lexer, match, ctx):
|
2332
|
+
yield match.start(), Keyword, match.group(1)
|
2333
|
+
yield match.start(), Text, match.group(2)
|
2334
|
+
yield match.start(), Punctuation, match.group(3)
|
2335
|
+
lexer.xquery_parse_state.append('operator')
|
2336
|
+
ctx.stack.append('kindtestforpi')
|
2337
|
+
ctx.pos = match.end()
|
2338
|
+
|
2339
|
+
def pushstate_operator_kindtest_callback(lexer, match, ctx):
|
2340
|
+
yield match.start(), Keyword, match.group(1)
|
2341
|
+
yield match.start(), Text, match.group(2)
|
2342
|
+
yield match.start(), Punctuation, match.group(3)
|
2343
|
+
lexer.xquery_parse_state.append('operator')
|
2344
|
+
ctx.stack.append('kindtest')
|
2345
|
+
ctx.pos = match.end()
|
2346
|
+
|
2347
|
+
def pushstate_occurrenceindicator_kindtest_callback(lexer, match, ctx):
|
2348
|
+
yield match.start(), Name.Tag, match.group(1)
|
2349
|
+
yield match.start(), Text, match.group(2)
|
2350
|
+
yield match.start(), Punctuation, match.group(3)
|
2351
|
+
lexer.xquery_parse_state.append('occurrenceindicator')
|
2352
|
+
ctx.stack.append('kindtest')
|
2353
|
+
ctx.pos = match.end()
|
2354
|
+
|
2355
|
+
def pushstate_operator_starttag_callback(lexer, match, ctx):
|
2356
|
+
yield match.start(), Name.Tag, match.group(1)
|
2357
|
+
lexer.xquery_parse_state.append('operator')
|
2358
|
+
ctx.stack.append('start_tag')
|
2359
|
+
ctx.pos = match.end()
|
2360
|
+
|
2361
|
+
def pushstate_operator_root_callback(lexer, match, ctx):
|
2362
|
+
yield match.start(), Punctuation, match.group(1)
|
2363
|
+
lexer.xquery_parse_state.append('operator')
|
2364
|
+
ctx.stack = ['root']#.append('root')
|
2365
|
+
ctx.pos = match.end()
|
2366
|
+
|
2367
|
+
def pushstate_operator_root_construct_callback(lexer, match, ctx):
|
2368
|
+
yield match.start(), Keyword, match.group(1)
|
2369
|
+
yield match.start(), Text, match.group(2)
|
2370
|
+
yield match.start(), Punctuation, match.group(3)
|
2371
|
+
lexer.xquery_parse_state.append('operator')
|
2372
|
+
ctx.stack = ['root']
|
2373
|
+
ctx.pos = match.end()
|
2374
|
+
|
2375
|
+
def pushstate_root_callback(lexer, match, ctx):
|
2376
|
+
yield match.start(), Punctuation, match.group(1)
|
2377
|
+
cur_state = ctx.stack.pop()
|
2378
|
+
lexer.xquery_parse_state.append(cur_state)
|
2379
|
+
ctx.stack = ['root']#.append('root')
|
2380
|
+
ctx.pos = match.end()
|
2381
|
+
|
2382
|
+
def pushstate_operator_attribute_callback(lexer, match, ctx):
|
2383
|
+
yield match.start(), Name.Attribute, match.group(1)
|
2384
|
+
ctx.stack.append('operator')
|
2385
|
+
ctx.pos = match.end()
|
2386
|
+
|
2387
|
+
def pushstate_operator_callback(lexer, match, ctx):
|
2388
|
+
yield match.start(), Keyword, match.group(1)
|
2389
|
+
yield match.start(), Text, match.group(2)
|
2390
|
+
yield match.start(), Punctuation, match.group(3)
|
2391
|
+
lexer.xquery_parse_state.append('operator')
|
2392
|
+
ctx.pos = match.end()
|
2393
|
+
|
2394
|
+
tokens = {
|
2395
|
+
'comment': [
|
2396
|
+
# xquery comments
|
2397
|
+
(r'(:\))', Comment, '#pop'),
|
2398
|
+
(r'(\(:)', Comment, '#push'),
|
2399
|
+
(r'[^:)]', Comment),
|
2400
|
+
(r'([^:)]|:|\))', Comment),
|
2401
|
+
],
|
2402
|
+
'whitespace': [
|
2403
|
+
(r'\s+', Text),
|
2404
|
+
],
|
2405
|
+
'operator': [
|
2406
|
+
include('whitespace'),
|
2407
|
+
(r'(\})', popstate_callback),
|
2408
|
+
(r'\(:', Comment, 'comment'),
|
2409
|
+
|
2410
|
+
(r'(\{)', pushstate_root_callback),
|
2411
|
+
(r'then|else|external|at|div|except', Keyword, 'root'),
|
2412
|
+
(r'order by', Keyword, 'root'),
|
2413
|
+
(r'is|mod|order\s+by|stable\s+order\s+by', Keyword, 'root'),
|
2414
|
+
(r'and|or', Operator.Word, 'root'),
|
2415
|
+
(r'(eq|ge|gt|le|lt|ne|idiv|intersect|in)(?=\b)',
|
2416
|
+
Operator.Word, 'root'),
|
2417
|
+
(r'return|satisfies|to|union|where|preserve\s+strip',
|
2418
|
+
Keyword, 'root'),
|
2419
|
+
(r'(>=|>>|>|<=|<<|<|-|\*|!=|\+|\||:=|=)',
|
2420
|
+
operator_root_callback),
|
2421
|
+
(r'(::|;|\[|//|/|,)',
|
2422
|
+
punctuation_root_callback),
|
2423
|
+
(r'(castable|cast)(\s+)(as)\b',
|
2424
|
+
bygroups(Keyword, Text, Keyword), 'singletype'),
|
2425
|
+
(r'(instance)(\s+)(of)\b',
|
2426
|
+
bygroups(Keyword, Text, Keyword), 'itemtype'),
|
2427
|
+
(r'(treat)(\s+)(as)\b',
|
2428
|
+
bygroups(Keyword, Text, Keyword), 'itemtype'),
|
2429
|
+
(r'(case|as)\b', Keyword, 'itemtype'),
|
2430
|
+
(r'(\))(\s*)(as)',
|
2431
|
+
bygroups(Punctuation, Text, Keyword), 'itemtype'),
|
2432
|
+
(r'\$', Name.Variable, 'varname'),
|
2433
|
+
(r'(for|let)(\s+)(\$)',
|
2434
|
+
bygroups(Keyword, Text, Name.Variable), 'varname'),
|
2435
|
+
#(r'\)|\?|\]', Punctuation, '#push'),
|
2436
|
+
(r'\)|\?|\]', Punctuation),
|
2437
|
+
(r'(empty)(\s+)(greatest|least)', bygroups(Keyword, Text, Keyword)),
|
2438
|
+
(r'ascending|descending|default', Keyword, '#push'),
|
2439
|
+
(r'external', Keyword),
|
2440
|
+
(r'collation', Keyword, 'uritooperator'),
|
2441
|
+
# finally catch all string literals and stay in operator state
|
2442
|
+
(stringdouble, String.Double),
|
2443
|
+
(stringsingle, String.Single),
|
2444
|
+
|
2445
|
+
(r'(catch)(\s*)', bygroups(Keyword, Text), 'root'),
|
2446
|
+
],
|
2447
|
+
'uritooperator': [
|
2448
|
+
(stringdouble, String.Double, '#pop'),
|
2449
|
+
(stringsingle, String.Single, '#pop'),
|
2450
|
+
],
|
2451
|
+
'namespacedecl': [
|
2452
|
+
include('whitespace'),
|
2453
|
+
(r'\(:', Comment, 'comment'),
|
2454
|
+
(r'(at)(\s+)('+stringdouble+')', bygroups(Keyword, Text, String.Double)),
|
2455
|
+
(r"(at)(\s+)("+stringsingle+')', bygroups(Keyword, Text, String.Single)),
|
2456
|
+
(stringdouble, String.Double),
|
2457
|
+
(stringsingle, String.Single),
|
2458
|
+
(r',', Punctuation),
|
2459
|
+
(r'=', Operator),
|
2460
|
+
(r';', Punctuation, 'root'),
|
2461
|
+
(ncname, Name.Namespace),
|
2462
|
+
],
|
2463
|
+
'namespacekeyword': [
|
2464
|
+
include('whitespace'),
|
2465
|
+
(r'\(:', Comment, 'comment'),
|
2466
|
+
(stringdouble, String.Double, 'namespacedecl'),
|
2467
|
+
(stringsingle, String.Single, 'namespacedecl'),
|
2468
|
+
(r'inherit|no-inherit', Keyword, 'root'),
|
2469
|
+
(r'namespace', Keyword, 'namespacedecl'),
|
2470
|
+
(r'(default)(\s+)(element)', bygroups(Keyword, Text, Keyword)),
|
2471
|
+
(r'preserve|no-preserve', Keyword),
|
2472
|
+
(r',', Punctuation),
|
2473
|
+
],
|
2474
|
+
'varname': [
|
2475
|
+
(r'\(:', Comment, 'comment'),
|
2476
|
+
(qname, Name.Variable, 'operator'),
|
2477
|
+
],
|
2478
|
+
'singletype': [
|
2479
|
+
(r'\(:', Comment, 'comment'),
|
2480
|
+
(ncname + r'(:\*)', Name.Variable, 'operator'),
|
2481
|
+
(qname, Name.Variable, 'operator'),
|
2482
|
+
],
|
2483
|
+
'itemtype': [
|
2484
|
+
include('whitespace'),
|
2485
|
+
(r'\(:', Comment, 'comment'),
|
2486
|
+
(r'\$', Punctuation, 'varname'),
|
2487
|
+
(r'(void)(\s*)(\()(\s*)(\))',
|
2488
|
+
bygroups(Keyword, Text, Punctuation, Text, Punctuation), 'operator'),
|
2489
|
+
(r'(element|attribute|schema-element|schema-attribute|comment|text|'
|
2490
|
+
r'node|binary|document-node|empty-sequence)(\s*)(\()',
|
2491
|
+
pushstate_occurrenceindicator_kindtest_callback),
|
2492
|
+
# Marklogic specific type?
|
2493
|
+
(r'(processing-instruction)(\s*)(\()',
|
2494
|
+
bygroups(Keyword, Text, Punctuation),
|
2495
|
+
('occurrenceindicator', 'kindtestforpi')),
|
2496
|
+
(r'(item)(\s*)(\()(\s*)(\))(?=[*+?])',
|
2497
|
+
bygroups(Keyword, Text, Punctuation, Text, Punctuation),
|
2498
|
+
'occurrenceindicator'),
|
2499
|
+
(r'\(\#', Punctuation, 'pragma'),
|
2500
|
+
(r';', Punctuation, '#pop'),
|
2501
|
+
(r'then|else', Keyword, '#pop'),
|
2502
|
+
(r'(at)(\s+)(' + stringdouble + ')',
|
2503
|
+
bygroups(Keyword, Text, String.Double), 'namespacedecl'),
|
2504
|
+
(r'(at)(\s+)(' + stringsingle + ')',
|
2505
|
+
bygroups(Keyword, Text, String.Single), 'namespacedecl'),
|
2506
|
+
(r'except|intersect|in|is|return|satisfies|to|union|where',
|
2507
|
+
Keyword, 'root'),
|
2508
|
+
(r'and|div|eq|ge|gt|le|lt|ne|idiv|mod|or', Operator.Word, 'root'),
|
2509
|
+
(r':=|=|,|>=|>>|>|\[|\(|<=|<<|<|-|!=|\|', Operator, 'root'),
|
2510
|
+
(r'external|at', Keyword, 'root'),
|
2511
|
+
(r'(stable)(\s+)(order)(\s+)(by)',
|
2512
|
+
bygroups(Keyword, Text, Keyword, Text, Keyword), 'root'),
|
2513
|
+
(r'(castable|cast)(\s+)(as)',
|
2514
|
+
bygroups(Keyword, Text, Keyword), 'singletype'),
|
2515
|
+
(r'(treat)(\s+)(as)', bygroups(Keyword, Text, Keyword)),
|
2516
|
+
(r'(instance)(\s+)(of)', bygroups(Keyword, Text, Keyword)),
|
2517
|
+
(r'case|as', Keyword, 'itemtype'),
|
2518
|
+
(r'(\))(\s*)(as)', bygroups(Operator, Text, Keyword), 'itemtype'),
|
2519
|
+
(ncname + r':\*', Keyword.Type, 'operator'),
|
2520
|
+
(qname, Keyword.Type, 'occurrenceindicator'),
|
2521
|
+
],
|
2522
|
+
'kindtest': [
|
2523
|
+
(r'\(:', Comment, 'comment'),
|
2524
|
+
(r'{', Punctuation, 'root'),
|
2525
|
+
(r'(\))([*+?]?)', popstate_kindtest_callback),
|
2526
|
+
(r'\*', Name, 'closekindtest'),
|
2527
|
+
(qname, Name, 'closekindtest'),
|
2528
|
+
(r'(element|schema-element)(\s*)(\()', pushstate_kindtest_callback),
|
2529
|
+
],
|
2530
|
+
'kindtestforpi': [
|
2531
|
+
(r'\(:', Comment, 'comment'),
|
2532
|
+
(r'\)', Punctuation, '#pop'),
|
2533
|
+
(ncname, Name.Variable),
|
2534
|
+
(stringdouble, String.Double),
|
2535
|
+
(stringsingle, String.Single),
|
2536
|
+
],
|
2537
|
+
'closekindtest': [
|
2538
|
+
(r'\(:', Comment, 'comment'),
|
2539
|
+
(r'(\))', popstate_callback),
|
2540
|
+
(r',', Punctuation),
|
2541
|
+
(r'(\{)', pushstate_operator_root_callback),
|
2542
|
+
(r'\?', Punctuation),
|
2543
|
+
],
|
2544
|
+
'xml_comment': [
|
2545
|
+
(r'(-->)', popstate_xmlcomment_callback),
|
2546
|
+
(r'[^-]{1,2}', Literal),
|
2547
|
+
(ur'\t|\r|\n|[\u0020-\U0000D7FF]|[\U0000E000-\U0000FFFD]|'
|
2548
|
+
ur'[\U00010000-\U0010FFFF]', Literal),
|
2549
|
+
],
|
2550
|
+
'processing_instruction': [
|
2551
|
+
(r'\s+', Text, 'processing_instruction_content'),
|
2552
|
+
(r'\?>', String.Doc, '#pop'),
|
2553
|
+
(pitarget, Name),
|
2554
|
+
],
|
2555
|
+
'processing_instruction_content': [
|
2556
|
+
(r'\?>', String.Doc, '#pop'),
|
2557
|
+
(ur'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|'
|
2558
|
+
ur'[\U00010000-\U0010FFFF]', Literal),
|
2559
|
+
],
|
2560
|
+
'cdata_section': [
|
2561
|
+
(r']]>', String.Doc, '#pop'),
|
2562
|
+
(ur'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|'
|
2563
|
+
ur'[\U00010000-\U0010FFFF]', Literal),
|
2564
|
+
],
|
2565
|
+
'start_tag': [
|
2566
|
+
include('whitespace'),
|
2567
|
+
(r'(/>)', popstate_tag_callback),
|
2568
|
+
(r'>', Name.Tag, 'element_content'),
|
2569
|
+
(r'"', Punctuation, 'quot_attribute_content'),
|
2570
|
+
(r"'", Punctuation, 'apos_attribute_content'),
|
2571
|
+
(r'=', Operator),
|
2572
|
+
(qname, Name.Tag),
|
2573
|
+
],
|
2574
|
+
'quot_attribute_content': [
|
2575
|
+
(r'"', Punctuation, 'start_tag'),
|
2576
|
+
(r'(\{)', pushstate_root_callback),
|
2577
|
+
(r'""', Name.Attribute),
|
2578
|
+
(quotattrcontentchar, Name.Attribute),
|
2579
|
+
(entityref, Name.Attribute),
|
2580
|
+
(charref, Name.Attribute),
|
2581
|
+
(r'\{\{|\}\}', Name.Attribute),
|
2582
|
+
],
|
2583
|
+
'apos_attribute_content': [
|
2584
|
+
(r"'", Punctuation, 'start_tag'),
|
2585
|
+
(r'\{', Punctuation, 'root'),
|
2586
|
+
(r"''", Name.Attribute),
|
2587
|
+
(aposattrcontentchar, Name.Attribute),
|
2588
|
+
(entityref, Name.Attribute),
|
2589
|
+
(charref, Name.Attribute),
|
2590
|
+
(r'\{\{|\}\}', Name.Attribute),
|
2591
|
+
],
|
2592
|
+
'element_content': [
|
2593
|
+
(r'</', Name.Tag, 'end_tag'),
|
2594
|
+
(r'(\{)', pushstate_root_callback),
|
2595
|
+
(r'(<!--)', pushstate_element_content_xmlcomment_callback),
|
2596
|
+
(r'(<\?)', pushstate_element_content_processing_instruction_callback),
|
2597
|
+
(r'(<!\[CDATA\[)', pushstate_element_content_cdata_section_callback),
|
2598
|
+
(r'(<)', pushstate_element_content_starttag_callback),
|
2599
|
+
(elementcontentchar, Literal),
|
2600
|
+
(entityref, Literal),
|
2601
|
+
(charref, Literal),
|
2602
|
+
(r'\{\{|\}\}', Literal),
|
2603
|
+
],
|
2604
|
+
'end_tag': [
|
2605
|
+
include('whitespace'),
|
2606
|
+
(r'(>)', popstate_tag_callback),
|
2607
|
+
(qname, Name.Tag),
|
2608
|
+
],
|
2609
|
+
'xmlspace_decl': [
|
2610
|
+
(r'\(:', Comment, 'comment'),
|
2611
|
+
(r'preserve|strip', Keyword, '#pop'),
|
2612
|
+
],
|
2613
|
+
'declareordering': [
|
2614
|
+
(r'\(:', Comment, 'comment'),
|
2615
|
+
include('whitespace'),
|
2616
|
+
(r'ordered|unordered', Keyword, '#pop'),
|
2617
|
+
],
|
2618
|
+
'xqueryversion': [
|
2619
|
+
include('whitespace'),
|
2620
|
+
(r'\(:', Comment, 'comment'),
|
2621
|
+
(stringdouble, String.Double),
|
2622
|
+
(stringsingle, String.Single),
|
2623
|
+
(r'encoding', Keyword),
|
2624
|
+
(r';', Punctuation, '#pop'),
|
2625
|
+
],
|
2626
|
+
'pragma': [
|
2627
|
+
(qname, Name.Variable, 'pragmacontents'),
|
2628
|
+
],
|
2629
|
+
'pragmacontents': [
|
2630
|
+
(r'#\)', Punctuation, 'operator'),
|
2631
|
+
(ur'\t|\r|\n|[\u0020-\U0000D7FF]|[\U0000E000-\U0000FFFD]|'
|
2632
|
+
ur'[\U00010000-\U0010FFFF]', Literal),
|
2633
|
+
(r'(\s+)', Text),
|
2634
|
+
],
|
2635
|
+
'occurrenceindicator': [
|
2636
|
+
include('whitespace'),
|
2637
|
+
(r'\(:', Comment, 'comment'),
|
2638
|
+
(r'\*|\?|\+', Operator, 'operator'),
|
2639
|
+
(r':=', Operator, 'root'),
|
2640
|
+
(r'', Text, 'operator'),
|
2641
|
+
],
|
2642
|
+
'option': [
|
2643
|
+
include('whitespace'),
|
2644
|
+
(qname, Name.Variable, '#pop'),
|
2645
|
+
],
|
2646
|
+
'qname_braren': [
|
2647
|
+
include('whitespace'),
|
2648
|
+
(r'(\{)', pushstate_operator_root_callback),
|
2649
|
+
(r'(\()', Punctuation, 'root'),
|
2650
|
+
],
|
2651
|
+
'element_qname': [
|
2652
|
+
(qname, Name.Variable, 'root'),
|
2653
|
+
],
|
2654
|
+
'attribute_qname': [
|
2655
|
+
(qname, Name.Variable, 'root'),
|
2656
|
+
],
|
2657
|
+
'root': [
|
2658
|
+
include('whitespace'),
|
2659
|
+
(r'\(:', Comment, 'comment'),
|
2660
|
+
|
2661
|
+
# handle operator state
|
2662
|
+
# order on numbers matters - handle most complex first
|
2663
|
+
(r'\d+(\.\d*)?[eE][\+\-]?\d+', Number.Double, 'operator'),
|
2664
|
+
(r'(\.\d+)[eE][\+\-]?\d+', Number.Double, 'operator'),
|
2665
|
+
(r'(\.\d+|\d+\.\d*)', Number, 'operator'),
|
2666
|
+
(r'(\d+)', Number.Integer, 'operator'),
|
2667
|
+
(r'(\.\.|\.|\))', Punctuation, 'operator'),
|
2668
|
+
(r'(declare)(\s+)(construction)',
|
2669
|
+
bygroups(Keyword, Text, Keyword), 'operator'),
|
2670
|
+
(r'(declare)(\s+)(default)(\s+)(order)',
|
2671
|
+
bygroups(Keyword, Text, Keyword, Text, Keyword), 'operator'),
|
2672
|
+
(ncname + ':\*', Name, 'operator'),
|
2673
|
+
('\*:'+ncname, Name.Tag, 'operator'),
|
2674
|
+
('\*', Name.Tag, 'operator'),
|
2675
|
+
(stringdouble, String.Double, 'operator'),
|
2676
|
+
(stringsingle, String.Single, 'operator'),
|
2677
|
+
|
2678
|
+
(r'(\})', popstate_callback),
|
2679
|
+
|
2680
|
+
#NAMESPACE DECL
|
2681
|
+
(r'(declare)(\s+)(default)(\s+)(collation)',
|
2682
|
+
bygroups(Keyword, Text, Keyword, Text, Keyword)),
|
2683
|
+
(r'(module|declare)(\s+)(namespace)',
|
2684
|
+
bygroups(Keyword, Text, Keyword), 'namespacedecl'),
|
2685
|
+
(r'(declare)(\s+)(base-uri)',
|
2686
|
+
bygroups(Keyword, Text, Keyword), 'namespacedecl'),
|
2687
|
+
|
2688
|
+
#NAMESPACE KEYWORD
|
2689
|
+
(r'(declare)(\s+)(default)(\s+)(element|function)',
|
2690
|
+
bygroups(Keyword, Text, Keyword, Text, Keyword), 'namespacekeyword'),
|
2691
|
+
(r'(import)(\s+)(schema|module)',
|
2692
|
+
bygroups(Keyword.Pseudo, Text, Keyword.Pseudo), 'namespacekeyword'),
|
2693
|
+
(r'(declare)(\s+)(copy-namespaces)',
|
2694
|
+
bygroups(Keyword, Text, Keyword), 'namespacekeyword'),
|
2695
|
+
|
2696
|
+
#VARNAMEs
|
2697
|
+
(r'(for|let|some|every)(\s+)(\$)',
|
2698
|
+
bygroups(Keyword, Text, Name.Variable), 'varname'),
|
2699
|
+
(r'\$', Name.Variable, 'varname'),
|
2700
|
+
(r'(declare)(\s+)(variable)(\s+)(\$)',
|
2701
|
+
bygroups(Keyword, Text, Keyword, Text, Name.Variable), 'varname'),
|
2702
|
+
|
2703
|
+
#ITEMTYPE
|
2704
|
+
(r'(\))(\s+)(as)', bygroups(Operator, Text, Keyword), 'itemtype'),
|
2705
|
+
|
2706
|
+
(r'(element|attribute|schema-element|schema-attribute|comment|'
|
2707
|
+
r'text|node|document-node|empty-sequence)(\s+)(\()',
|
2708
|
+
pushstate_operator_kindtest_callback),
|
2709
|
+
|
2710
|
+
(r'(processing-instruction)(\s+)(\()',
|
2711
|
+
pushstate_operator_kindtestforpi_callback),
|
2712
|
+
|
2713
|
+
(r'(<!--)', pushstate_operator_xmlcomment_callback),
|
2714
|
+
|
2715
|
+
(r'(<\?)', pushstate_operator_processing_instruction_callback),
|
2716
|
+
|
2717
|
+
(r'(<!\[CDATA\[)', pushstate_operator_cdata_section_callback),
|
2718
|
+
|
2719
|
+
# (r'</', Name.Tag, 'end_tag'),
|
2720
|
+
(r'(<)', pushstate_operator_starttag_callback),
|
2721
|
+
|
2722
|
+
(r'(declare)(\s+)(boundary-space)',
|
2723
|
+
bygroups(Keyword, Text, Keyword), 'xmlspace_decl'),
|
2724
|
+
|
2725
|
+
(r'(validate)(\s+)(lax|strict)',
|
2726
|
+
pushstate_operator_root_validate_withmode),
|
2727
|
+
(r'(validate)(\s*)(\{)', pushstate_operator_root_validate),
|
2728
|
+
(r'(typeswitch)(\s*)(\()', bygroups(Keyword, Text, Punctuation)),
|
2729
|
+
(r'(element|attribute)(\s*)(\{)',
|
2730
|
+
pushstate_operator_root_construct_callback),
|
2731
|
+
|
2732
|
+
(r'(document|text|processing-instruction|comment)(\s*)(\{)',
|
2733
|
+
pushstate_operator_root_construct_callback),
|
2734
|
+
#ATTRIBUTE
|
2735
|
+
(r'(attribute)(\s+)(?=' + qname + r')',
|
2736
|
+
bygroups(Keyword, Text), 'attribute_qname'),
|
2737
|
+
#ELEMENT
|
2738
|
+
(r'(element)(\s+)(?=' +qname+ r')',
|
2739
|
+
bygroups(Keyword, Text), 'element_qname'),
|
2740
|
+
#PROCESSING_INSTRUCTION
|
2741
|
+
(r'(processing-instruction)(\s+)(' + ncname + r')(\s*)(\{)',
|
2742
|
+
bygroups(Keyword, Text, Name.Variable, Text, Punctuation),
|
2743
|
+
'operator'),
|
2744
|
+
|
2745
|
+
(r'(declare|define)(\s+)(function)',
|
2746
|
+
bygroups(Keyword, Text, Keyword)),
|
2747
|
+
|
2748
|
+
(r'(\{)', pushstate_operator_root_callback),
|
2749
|
+
|
2750
|
+
(r'(unordered|ordered)(\s*)(\{)',
|
2751
|
+
pushstate_operator_order_callback),
|
2752
|
+
|
2753
|
+
(r'(declare)(\s+)(ordering)',
|
2754
|
+
bygroups(Keyword, Text, Keyword), 'declareordering'),
|
2755
|
+
|
2756
|
+
(r'(xquery)(\s+)(version)',
|
2757
|
+
bygroups(Keyword.Pseudo, Text, Keyword.Pseudo), 'xqueryversion'),
|
2758
|
+
|
2759
|
+
(r'(\(#)', Punctuation, 'pragma'),
|
2760
|
+
|
2761
|
+
# sometimes return can occur in root state
|
2762
|
+
(r'return', Keyword),
|
2763
|
+
|
2764
|
+
(r'(declare)(\s+)(option)', bygroups(Keyword, Text, Keyword),
|
2765
|
+
'option'),
|
2766
|
+
|
2767
|
+
#URI LITERALS - single and double quoted
|
2768
|
+
(r'(at)(\s+)('+stringdouble+')', String.Double, 'namespacedecl'),
|
2769
|
+
(r'(at)(\s+)('+stringsingle+')', String.Single, 'namespacedecl'),
|
2770
|
+
|
2771
|
+
(r'(ancestor-or-self|ancestor|attribute|child|descendant-or-self)(::)',
|
2772
|
+
bygroups(Keyword, Punctuation)),
|
2773
|
+
(r'(descendant|following-sibling|following|parent|preceding-sibling'
|
2774
|
+
r'|preceding|self)(::)', bygroups(Keyword, Punctuation)),
|
2775
|
+
|
2776
|
+
(r'(if)(\s*)(\()', bygroups(Keyword, Text, Punctuation)),
|
2777
|
+
|
2778
|
+
(r'then|else', Keyword),
|
2779
|
+
|
2780
|
+
# ML specific
|
2781
|
+
(r'(try)(\s*)', bygroups(Keyword, Text), 'root'),
|
2782
|
+
(r'(catch)(\s*)(\()(\$)',
|
2783
|
+
bygroups(Keyword, Text, Punctuation, Name.Variable), 'varname'),
|
2784
|
+
|
2785
|
+
(r'(@'+qname+')', Name.Attribute),
|
2786
|
+
(r'(@'+ncname+')', Name.Attribute),
|
2787
|
+
(r'@\*:'+ncname, Name.Attribute),
|
2788
|
+
(r'(@)', Name.Attribute),
|
2789
|
+
|
2790
|
+
(r'//|/|\+|-|;|,|\(|\)', Punctuation),
|
2791
|
+
|
2792
|
+
# STANDALONE QNAMES
|
2793
|
+
(qname + r'(?=\s*{)', Name.Tag, 'qname_braren'),
|
2794
|
+
(qname + r'(?=\s*\([^:])', Name.Function, 'qname_braren'),
|
2795
|
+
(qname, Name.Tag, 'operator'),
|
2796
|
+
]
|
2797
|
+
}
|
2798
|
+
|
2799
|
+
|
2800
|
+
class DartLexer(RegexLexer):
|
2801
|
+
"""
|
2802
|
+
For `Dart <http://dartlang.org/>`_ source code.
|
2803
|
+
|
2804
|
+
*New in Pygments 1.5.*
|
2805
|
+
"""
|
2806
|
+
|
2807
|
+
name = 'Dart'
|
2808
|
+
aliases = ['dart']
|
2809
|
+
filenames = ['*.dart']
|
2810
|
+
mimetypes = ['text/x-dart']
|
2811
|
+
|
2812
|
+
flags = re.MULTILINE | re.DOTALL
|
2813
|
+
|
2814
|
+
tokens = {
|
2815
|
+
'root': [
|
2816
|
+
(r'#!(.*?)$', Comment.Preproc),
|
2817
|
+
(r'(#)(import|library|source)', bygroups(Text, Keyword)),
|
2818
|
+
(r'[^\S\n]+', Text),
|
2819
|
+
(r'//.*?\n', Comment.Single),
|
2820
|
+
(r'/\*.*?\*/', Comment.Multiline),
|
2821
|
+
(r'(class|interface)(\s+)',
|
2822
|
+
bygroups(Keyword.Declaration, Text), 'class'),
|
2823
|
+
(r'(assert|break|case|catch|continue|default|do|else|finally|for|'
|
2824
|
+
r'if|in|is|new|return|super|switch|this|throw|try|while)\b',
|
2825
|
+
Keyword),
|
2826
|
+
(r'(abstract|const|extends|factory|final|get|implements|'
|
2827
|
+
r'native|operator|set|static|typedef|var)\b', Keyword.Declaration),
|
2828
|
+
(r'(bool|double|Dynamic|int|num|Object|String|void)', Keyword.Type),
|
2829
|
+
(r'(false|null|true)', Keyword.Constant),
|
2830
|
+
(r'@"(\\\\|\\"|[^"])*"', String.Double), # raw string
|
2831
|
+
(r"@'(\\\\|\\'|[^'])*'", String.Single), # raw string
|
2832
|
+
(r'"', String.Double, 'string_double'),
|
2833
|
+
(r"'", String.Single, 'string_single'),
|
2834
|
+
(r'[a-zA-Z_$][a-zA-Z0-9_]*:', Name.Label),
|
2835
|
+
(r'[a-zA-Z_$][a-zA-Z0-9_]*', Name),
|
2836
|
+
(r'[~!%^&*+=|?:<>/-]', Operator),
|
2837
|
+
(r'[(){}\[\],.;]', Punctuation),
|
2838
|
+
(r'0[xX][0-9a-fA-F]+', Number.Hex),
|
2839
|
+
# DIGIT+ (‘.’ DIGIT*)? EXPONENT?
|
2840
|
+
(r'\d+(\.\d*)?([eE][+-]?\d+)?', Number),
|
2841
|
+
(r'\.\d+([eE][+-]?\d+)?', Number), # ‘.’ DIGIT+ EXPONENT?
|
2842
|
+
(r'\n', Text)
|
2843
|
+
# pseudo-keyword negate intentionally left out
|
2844
|
+
],
|
2845
|
+
'class': [
|
2846
|
+
(r'[a-zA-Z_$][a-zA-Z0-9_]*', Name.Class, '#pop')
|
2847
|
+
],
|
2848
|
+
'string_double': [
|
2849
|
+
(r'"', String.Double, '#pop'),
|
2850
|
+
(r'[^"$]+', String.Double),
|
2851
|
+
(r'(\$)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(String.Interpol, Name)),
|
2852
|
+
(r'(\$\{)(.*?)(\})',
|
2853
|
+
bygroups(String.Interpol, using(this), String.Interpol)),
|
2854
|
+
(r'\$+', String.Double)
|
2855
|
+
],
|
2856
|
+
'string_single': [
|
2857
|
+
(r"'", String.Single, '#pop'),
|
2858
|
+
(r"[^'$]+", String.Single),
|
2859
|
+
(r'(\$)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(String.Interpol, Name)),
|
2860
|
+
(r'(\$\{)(.*?)(\})',
|
2861
|
+
bygroups(String.Interpol, using(this), String.Interpol)),
|
2862
|
+
(r'\$+', String.Single)
|
2863
|
+
]
|
2864
|
+
}
|