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,193 @@
|
|
1
|
+
<!DOCTYPE html
|
2
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml"
|
5
|
+
xmlns:py="http://genshi.edgewall.org/"
|
6
|
+
xmlns:xi="http://www.w3.org/2001/XInclude">
|
7
|
+
<xi:include href="layout.html" />
|
8
|
+
<head>
|
9
|
+
<title>$title</title>
|
10
|
+
<script type="text/javascript">
|
11
|
+
$(document).ready(function() {
|
12
|
+
$("#group").change(function() {
|
13
|
+
$("#groupdesc").enable(this.selectedIndex != 0)
|
14
|
+
}).change();
|
15
|
+
});
|
16
|
+
</script>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<div id="ctxtnav" class="nav">
|
21
|
+
<ul py:if="report_href">
|
22
|
+
<li class="first"><a href="$report_href">Available Reports</a></li>
|
23
|
+
<li class="last">Custom Query</li>
|
24
|
+
</ul>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<py:def function="num_matches(v)">
|
28
|
+
<span class="numrows">(${v or 'No'} match${v != 1 and 'es' or ''})</span>
|
29
|
+
</py:def>
|
30
|
+
|
31
|
+
<div id="content" class="query">
|
32
|
+
<h1>$title ${num_matches(len(tickets))}</h1>
|
33
|
+
|
34
|
+
<form id="query" method="post" action="${href.query}">
|
35
|
+
<fieldset id="filters">
|
36
|
+
<legend>Filters</legend>
|
37
|
+
<table summary="Query filters">
|
38
|
+
<tbody>
|
39
|
+
<tr style="height: 1px"><td colspan="4"></td></tr>
|
40
|
+
</tbody>
|
41
|
+
<py:for each="field_name, field in fields.iteritems()">
|
42
|
+
<py:for each="constraint_name, constraint in constraints.iteritems()">
|
43
|
+
<tbody py:if="field_name == constraint_name"
|
44
|
+
py:with="multiline = field.type in ('select', 'text')">
|
45
|
+
<py:for each="constraint_idx, constraint_value in enumerate(constraint['values'])">
|
46
|
+
<tr class="${field_name}" py:if="multiline or constraint_idx == 0">
|
47
|
+
<py:choose test="constraint_idx">
|
48
|
+
<py:when test="0">
|
49
|
+
<th scope="row"><label>$field.label</label></th>
|
50
|
+
<td py:if="field.type not in ('radio', 'checkbox')" class="mode">
|
51
|
+
<select name="${field_name}_mode">
|
52
|
+
<option py:for="mode in modes[field.type]" value="$mode.value"
|
53
|
+
selected="${mode.value == constraint.mode and 'selected' or None}">$mode.name
|
54
|
+
</option>
|
55
|
+
</select>
|
56
|
+
</td>
|
57
|
+
</py:when>
|
58
|
+
<py:otherwise><!--! not the first line of a multiline constraint -->
|
59
|
+
<th colspan="2"><label>or</label></th>
|
60
|
+
</py:otherwise>
|
61
|
+
</py:choose>
|
62
|
+
|
63
|
+
<td class="filter" colspan="${field.type in ('radio', 'checkbox') and 2 or None}"
|
64
|
+
py:choose="field.type">
|
65
|
+
|
66
|
+
<py:when test="'select'">
|
67
|
+
<select name="${constraint_name}">
|
68
|
+
<option></option>
|
69
|
+
<option py:for="option in field.options"
|
70
|
+
selected="${option == constraint_value and 'selected' or None}">$option
|
71
|
+
</option>
|
72
|
+
</select>
|
73
|
+
</py:when>
|
74
|
+
|
75
|
+
|
76
|
+
<py:when test="'radio'">
|
77
|
+
<py:for each="option in field.options">
|
78
|
+
<input type="checkbox" id="${field_name}_$option" name="${field_name}"
|
79
|
+
value="$option"
|
80
|
+
checked="${any([(value == option) == (constraint.mode == '')
|
81
|
+
for value in constraint['values']]) and 'checked' or None}" />
|
82
|
+
<label for="${field_name}_$option">${option or 'none'}</label>
|
83
|
+
</py:for>
|
84
|
+
</py:when>
|
85
|
+
|
86
|
+
<py:when test="'checkbox'">
|
87
|
+
<input type="radio" id="${field_name}_on" name="$field_name" value="1"
|
88
|
+
checked="${constraint.mode != '!' or None}" />
|
89
|
+
<label for="${field_name}_on">yes</label>
|
90
|
+
<input type="radio" id="${field_name}_off" name="$field_name" value="0"
|
91
|
+
checked="${constraint.mode == '!' or None}" />
|
92
|
+
<label for="${field_name}_off">no</label>
|
93
|
+
</py:when>
|
94
|
+
|
95
|
+
<py:when test="'text'">
|
96
|
+
<input type="text" name="${field_name}" value="$constraint_value" size="42" />
|
97
|
+
</py:when>
|
98
|
+
|
99
|
+
</td>
|
100
|
+
<td class="actions"
|
101
|
+
py:with="rm_idx = multiline and idx or len(constraint['values'])-1">
|
102
|
+
<input type="submit" name="rm_filter_${field_name}${
|
103
|
+
field.type != 'radio' and '_%d' % rm_idx or ''}" value="-" />
|
104
|
+
</td>
|
105
|
+
</tr>
|
106
|
+
</py:for>
|
107
|
+
</tbody>
|
108
|
+
</py:for>
|
109
|
+
</py:for>
|
110
|
+
|
111
|
+
<tbody>
|
112
|
+
<tr class="actions">
|
113
|
+
<td class="actions" colspan="4" style="text-align: right">
|
114
|
+
<label for="add_filter">Add filter</label>
|
115
|
+
<select name="add_filter" id="add_filter">
|
116
|
+
<option></option>
|
117
|
+
<option py:for="field_name, field in fields.iteritems()"
|
118
|
+
value="$field_name"
|
119
|
+
disabled="${(field.type == 'radio' and
|
120
|
+
constraints[field_name] and
|
121
|
+
len(constraints[field_name])) or None}">
|
122
|
+
${field.label}
|
123
|
+
</option>
|
124
|
+
</select>
|
125
|
+
<input type="submit" name="add" value="+" />
|
126
|
+
</td>
|
127
|
+
</tr>
|
128
|
+
</tbody>
|
129
|
+
</table>
|
130
|
+
</fieldset>
|
131
|
+
|
132
|
+
<p class="option">
|
133
|
+
<label for="group">Group results by</label>
|
134
|
+
<select name="group" id="group">
|
135
|
+
<option></option>
|
136
|
+
<option py:for="field_name, field in fields.iteritems()"
|
137
|
+
py:if="field.type in ('select', 'radio') or field_name == 'owner'"
|
138
|
+
selected="${field_name == query.group or None}"
|
139
|
+
value="${field_name}">${field.label}</option>
|
140
|
+
</select>
|
141
|
+
<input type="checkbox" name="groupdesc" id="groupdesc"
|
142
|
+
checked="${query.groupdesc or None}" />
|
143
|
+
<label for="groupdesc">descending</label>
|
144
|
+
</p>
|
145
|
+
|
146
|
+
<p class="option">
|
147
|
+
<input type="checkbox" name="verbose" id="verbose"
|
148
|
+
checked="${query.verbose or None}" />
|
149
|
+
<label for="verbose">Show full description under each result</label>
|
150
|
+
</p>
|
151
|
+
|
152
|
+
<div class="buttons">
|
153
|
+
<input type="hidden" name="order" value="$query.order" />
|
154
|
+
<input py:if="desc" type="hidden" name="desc" value="1" />
|
155
|
+
<input type="submit" name="update" value="Update" />
|
156
|
+
</div>
|
157
|
+
<hr />
|
158
|
+
</form>
|
159
|
+
|
160
|
+
<script type="text/javascript">
|
161
|
+
var properties={
|
162
|
+
<py:for each="idx, (field_name, field) in enumerate(fields.items())">
|
163
|
+
$field_name: { type: "$field.type", label: "$field.label"
|
164
|
+
<py:if test="field.options">, options: [
|
165
|
+
<py:for each="idx, option in enumerate(field.options)">"$option"<py:if
|
166
|
+
test="idx < len(field.options)-1">,</py:if>
|
167
|
+
</py:for>]
|
168
|
+
</py:if>}<py:if test="idx < len(fields)-1">,</py:if>
|
169
|
+
</py:for>
|
170
|
+
};
|
171
|
+
var modes = {
|
172
|
+
<py:for each="idx, (type_name, type_modes) in enumerate(modes.items())">
|
173
|
+
$type_name: [
|
174
|
+
<py:for each="idx, mode in enumerate(type_modes)">
|
175
|
+
{text: "$mode.name", value: "$mode.value" }<py:if
|
176
|
+
test="idx < len(type_modes)-1">,</py:if>
|
177
|
+
</py:for>
|
178
|
+
]<py:if test="idx < len(modes)-1">,</py:if>
|
179
|
+
</py:for>
|
180
|
+
};
|
181
|
+
initializeFilters();
|
182
|
+
</script>
|
183
|
+
|
184
|
+
<xi:include href="query_div.html" />
|
185
|
+
|
186
|
+
<div id="help">
|
187
|
+
<strong>Note:</strong> See <a href="${href.wiki('TracQuery')}">TracQuery</a>
|
188
|
+
for help on using queries.
|
189
|
+
</div>
|
190
|
+
|
191
|
+
</div>
|
192
|
+
</body>
|
193
|
+
</html>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
## a comment
|
2
|
+
|
3
|
+
\## not a comment
|
4
|
+
|
5
|
+
#if foo
|
6
|
+
${bar}
|
7
|
+
#endif
|
8
|
+
|
9
|
+
The answer is:
|
10
|
+
#choose
|
11
|
+
#when 0 == 1
|
12
|
+
0
|
13
|
+
#end
|
14
|
+
#when 1 == 1
|
15
|
+
1
|
16
|
+
#end
|
17
|
+
#otherwise
|
18
|
+
2
|
19
|
+
#end
|
20
|
+
#end -- comment about choose
|
21
|
+
|
22
|
+
#for item in items
|
23
|
+
* ${item}
|
24
|
+
#end
|
25
|
+
|
26
|
+
#def greeting(name)
|
27
|
+
Hello, ${name}!
|
28
|
+
#end
|
29
|
+
${greeting('world')}
|
30
|
+
|
31
|
+
#with y=7; z=x+10
|
32
|
+
$x $y $z
|
33
|
+
#end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/* Vertex shader */
|
2
|
+
uniform float waveTime;
|
3
|
+
uniform float waveWidth;
|
4
|
+
uniform float waveHeight;
|
5
|
+
|
6
|
+
void main(void)
|
7
|
+
{
|
8
|
+
vec4 v = vec4(gl_Vertex);
|
9
|
+
|
10
|
+
v.z = sin(waveWidth * v.x + waveTime) * cos(waveWidth * v.y + waveTime) * waveHeight;
|
11
|
+
|
12
|
+
gl_Position = gl_ModelViewProjectionMatrix * v;
|
13
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
<?php
|
@@ -0,0 +1,14 @@
|
|
1
|
+
POST /demo/submit/ HTTP/1.1
|
2
|
+
Host: pygments.org
|
3
|
+
Connection: keep-alivk
|
4
|
+
Cache-Control: max-age=0
|
5
|
+
Origin: http://pygments.org
|
6
|
+
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7
|
7
|
+
Content-Type: application/x-www-form-urlencoded
|
8
|
+
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
|
9
|
+
Referer: http://pygments.org/
|
10
|
+
Accept-Encoding: gzip,deflate,sdch
|
11
|
+
Accept-Language: en-US,en;q=0.8
|
12
|
+
Accept-Charset: windows-949,utf-8;q=0.7,*;q=0.3
|
13
|
+
|
14
|
+
name=test&lang=text&code=asdf&user=
|
@@ -0,0 +1,27 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Date: Tue, 13 Dec 2011 00:11:44 GMT
|
3
|
+
Status: 200 OK
|
4
|
+
X-Transaction: 50b85fff78dab4a3
|
5
|
+
X-RateLimit-Limit: 150
|
6
|
+
ETag: "b31143be48ebfe7512b65fe64fe092f3"
|
7
|
+
X-Frame-Options: SAMEORIGIN
|
8
|
+
Last-Modified: Tue, 13 Dec 2011 00:11:44 GMT
|
9
|
+
X-RateLimit-Remaining: 145
|
10
|
+
X-Runtime: 0.01190
|
11
|
+
X-Transaction-Mask: a6183ffa5f8ca943ff1b53b5644ef1145f6f285d
|
12
|
+
Content-Type: application/json; charset=utf-8
|
13
|
+
Content-Length: 2389
|
14
|
+
Pragma: no-cache
|
15
|
+
X-RateLimit-Class: api
|
16
|
+
X-Revision: DEV
|
17
|
+
Expires: Tue, 31 Mar 1981 05:00:00 GMT
|
18
|
+
Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
|
19
|
+
X-MID: a55f21733bc52bb11d1fc58f9b51b4974fbb8f83
|
20
|
+
X-RateLimit-Reset: 1323738416
|
21
|
+
Set-Cookie: k=10.34.234.116.1323735104238974; path=/; expires=Tue, 20-Dec-11 00:11:44 GMT; domain=.twitter.com
|
22
|
+
Set-Cookie: guest_id=v1%3A13237351042425496; domain=.twitter.com; path=/; expires=Thu, 12-Dec-2013 12:11:44 GMT
|
23
|
+
Set-Cookie: _twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCPS6wjQ0AToHaWQiJTFiMTlhY2E1ZjczYThk%250ANDUwMWQxNjMwZGU2YTQ1ODBhIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--6b502f30a083e8a41a64f10930e142ea362b1561; domain=.twitter.com; path=/; HttpOnly
|
24
|
+
Vary: Accept-Encoding
|
25
|
+
Server: tfe
|
26
|
+
|
27
|
+
[{"contributors_enabled":false,"profile_background_tile":true,"followers_count":644,"protected":false,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/69064242\/gb_normal.jpg","screen_name":"birkenfeld","default_profile_image":false,"following":null,"friends_count":88,"profile_sidebar_fill_color":"7AC3EE","url":"http:\/\/pythonic.pocoo.org\/","name":"Georg Brandl","default_profile":false,"is_translator":false,"utc_offset":3600,"profile_sidebar_border_color":"65B0DA","description":"","profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme10\/bg.gif","favourites_count":0,"profile_use_background_image":true,"created_at":"Tue Dec 30 22:25:11 +0000 2008","status":{"retweet_count":10,"favorited":false,"geo":null,"possibly_sensitive":false,"coordinates":null,"in_reply_to_screen_name":null,"in_reply_to_status_id_str":null,"retweeted":false,"in_reply_to_status_id":null,"in_reply_to_user_id_str":null,"created_at":"Sat Jul 09 13:42:35 +0000 2011","truncated":false,"id_str":"89690914515206144","contributors":null,"place":null,"source":"web","in_reply_to_user_id":null,"id":89690914515206144,"retweeted_status":{"retweet_count":10,"favorited":false,"geo":null,"possibly_sensitive":false,"coordinates":null,"in_reply_to_screen_name":null,"in_reply_to_status_id_str":null,"retweeted":false,"in_reply_to_status_id":null,"in_reply_to_user_id_str":null,"created_at":"Sat Jul 09 13:07:04 +0000 2011","truncated":false,"id_str":"89681976755372032","contributors":null,"place":null,"source":"web","in_reply_to_user_id":null,"id":89681976755372032,"text":"Excellent Python posts from @mitsuhiko - http:\/\/t.co\/k1wt6e4 and @ncoghlan_dev - http:\/\/t.co\/eTxacgZ (links fixed)"},"text":"RT @jessenoller: Excellent Python posts from @mitsuhiko - http:\/\/t.co\/k1wt6e4 and @ncoghlan_dev - http:\/\/t.co\/eTxacgZ (links fixed)"},"follow_request_sent":null,"statuses_count":553,"geo_enabled":false,"notifications":null,"profile_text_color":"3D1957","id_str":"18490730","lang":"en","profile_background_image_url":"http:\/\/a1.twimg.com\/images\/themes\/theme10\/bg.gif","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/69064242\/gb_normal.jpg","show_all_inline_media":true,"listed_count":65,"profile_link_color":"FF0000","verified":false,"id":18490730,"time_zone":"Berlin","profile_background_color":"642D8B","location":"Bavaria, Germany"}]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/ioke
|
2
|
+
|
3
|
+
Ioke = LanguageExperiment with(
|
4
|
+
goal: :expressiveness,
|
5
|
+
data: as(code),
|
6
|
+
code: as(data),
|
7
|
+
features: [
|
8
|
+
:dynamic,
|
9
|
+
:object_oriented,
|
10
|
+
:prototype_based,
|
11
|
+
:homoiconic,
|
12
|
+
:macros
|
13
|
+
],
|
14
|
+
runtimes:(JVM, CLR),
|
15
|
+
inspirations: set(Io, Smalltalk, Ruby, Lisp)
|
16
|
+
)
|
17
|
+
|
18
|
+
hello = method("Every example needs a hello world!",
|
19
|
+
name,
|
20
|
+
"hello, #{name}!" println)
|
21
|
+
|
22
|
+
Ioke inspirations select(
|
23
|
+
features include?(:object_oriented)
|
24
|
+
) each(x, hello(x name))
|
@@ -0,0 +1,675 @@
|
|
1
|
+
(* Internal Syntax *)
|
2
|
+
(* Author: Frank Pfenning, Carsten Schuermann *)
|
3
|
+
(* Modified: Roberto Virga *)
|
4
|
+
|
5
|
+
functor IntSyn (structure Global : GLOBAL) :> INTSYN =
|
6
|
+
struct
|
7
|
+
|
8
|
+
type cid = int (* Constant identifier *)
|
9
|
+
type name = string (* Variable name *)
|
10
|
+
type mid = int (* Structure identifier *)
|
11
|
+
type csid = int (* CS module identifier *)
|
12
|
+
|
13
|
+
|
14
|
+
(* Contexts *)
|
15
|
+
datatype 'a Ctx = (* Contexts *)
|
16
|
+
Null (* G ::= . *)
|
17
|
+
| Decl of 'a Ctx * 'a (* | G, D *)
|
18
|
+
|
19
|
+
(* ctxPop (G) => G'
|
20
|
+
Invariant: G = G',D
|
21
|
+
*)
|
22
|
+
fun ctxPop (Decl (G, D)) = G
|
23
|
+
|
24
|
+
exception Error of string (* raised if out of space *)
|
25
|
+
(* ctxLookup (G, k) = D, kth declaration in G from right to left
|
26
|
+
Invariant: 1 <= k <= |G|, where |G| is length of G
|
27
|
+
*)
|
28
|
+
|
29
|
+
fun ctxLookup (Decl (G', D), 1) = D
|
30
|
+
| ctxLookup (Decl (G', _), k') = ctxLookup (G', k'-1)
|
31
|
+
(* | ctxLookup (Null, k') = (print ("Looking up k' = " ^ Int.toString k' ^ "\n"); raise Error "Out of Bounce\n")*)
|
32
|
+
(* ctxLookup (Null, k') should not occur by invariant *)
|
33
|
+
|
34
|
+
(* ctxLength G = |G|, the number of declarations in G *)
|
35
|
+
fun ctxLength G =
|
36
|
+
let
|
37
|
+
fun ctxLength' (Null, n) = n
|
38
|
+
| ctxLength' (Decl(G, _), n)= ctxLength' (G, n+1)
|
39
|
+
in
|
40
|
+
ctxLength' (G, 0)
|
41
|
+
end
|
42
|
+
|
43
|
+
type FgnExp = exn (* foreign expression representation *)
|
44
|
+
exception UnexpectedFgnExp of FgnExp
|
45
|
+
(* raised by a constraint solver
|
46
|
+
if passed an incorrect arg *)
|
47
|
+
|
48
|
+
type FgnCnstr = exn (* foreign unification constraint
|
49
|
+
representation *)
|
50
|
+
exception UnexpectedFgnCnstr of FgnCnstr
|
51
|
+
(* raised by a constraint solver
|
52
|
+
if passed an incorrect arg *)
|
53
|
+
|
54
|
+
datatype Depend = (* Dependency information *)
|
55
|
+
No (* P ::= No *)
|
56
|
+
| Maybe (* | Maybe *)
|
57
|
+
| Meta (* | Meta *)
|
58
|
+
|
59
|
+
(* Expressions *)
|
60
|
+
|
61
|
+
datatype Uni = (* Universes: *)
|
62
|
+
Kind (* L ::= Kind *)
|
63
|
+
| Type (* | Type *)
|
64
|
+
|
65
|
+
datatype Exp = (* Expressions: *)
|
66
|
+
Uni of Uni (* U ::= L *)
|
67
|
+
| Pi of (Dec * Depend) * Exp (* | bPi (D, P). V *)
|
68
|
+
| Root of Head * Spine (* | C @ S *)
|
69
|
+
| Redex of Exp * Spine (* | U @ S *)
|
70
|
+
| Lam of Dec * Exp (* | lam D. U *)
|
71
|
+
| EVar of Exp option ref * Dec Ctx * Exp * (Cnstr ref) list ref
|
72
|
+
(* | X<I> : G|-V, Cnstr *)
|
73
|
+
|
74
|
+
| EClo of Exp * Sub (* | U[s] *)
|
75
|
+
| AVar of Exp option ref (* | A<I> *)
|
76
|
+
| NVar of int (* | n (linear, fully applied) *)
|
77
|
+
(* grafting variable *)
|
78
|
+
|
79
|
+
| FgnExp of csid * FgnExp
|
80
|
+
(* | (foreign expression) *)
|
81
|
+
|
82
|
+
and Head = (* Heads: *)
|
83
|
+
BVar of int (* H ::= k *)
|
84
|
+
| Const of cid (* | c *)
|
85
|
+
| Proj of Block * int (* | #k(b) *)
|
86
|
+
| Skonst of cid (* | c# *)
|
87
|
+
| Def of cid (* | d *)
|
88
|
+
| NSDef of cid (* | d (non strict) *)
|
89
|
+
| FVar of name * Exp * Sub (* | F[s] *)
|
90
|
+
| FgnConst of csid * ConDec (* | (foreign constant) *)
|
91
|
+
|
92
|
+
and Spine = (* Spines: *)
|
93
|
+
Nil (* S ::= Nil *)
|
94
|
+
| App of Exp * Spine (* | U ; S *)
|
95
|
+
| SClo of Spine * Sub (* | S[s] *)
|
96
|
+
|
97
|
+
and Sub = (* Explicit substitutions: *)
|
98
|
+
Shift of int (* s ::= ^n *)
|
99
|
+
| Dot of Front * Sub (* | Ft.s *)
|
100
|
+
|
101
|
+
and Front = (* Fronts: *)
|
102
|
+
Idx of int (* Ft ::= k *)
|
103
|
+
| Exp of Exp (* | U *)
|
104
|
+
| Axp of Exp (* | U (assignable) *)
|
105
|
+
| Block of Block (* | _x *)
|
106
|
+
| Undef (* | _ *)
|
107
|
+
|
108
|
+
and Dec = (* Declarations: *)
|
109
|
+
Dec of name option * Exp (* D ::= x:V *)
|
110
|
+
| BDec of name option * (cid * Sub) (* | v:l[s] *)
|
111
|
+
| ADec of name option * int (* | v[^-d] *)
|
112
|
+
| NDec of name option
|
113
|
+
|
114
|
+
and Block = (* Blocks: *)
|
115
|
+
Bidx of int (* b ::= v *)
|
116
|
+
| LVar of Block option ref * Sub * (cid * Sub)
|
117
|
+
(* | L(l[^k],t) *)
|
118
|
+
| Inst of Exp list (* | u1, ..., Un *)
|
119
|
+
|
120
|
+
|
121
|
+
(* Constraints *)
|
122
|
+
|
123
|
+
and Cnstr = (* Constraint: *)
|
124
|
+
Solved (* Cnstr ::= solved *)
|
125
|
+
| Eqn of Dec Ctx * Exp * Exp (* | G|-(U1 == U2) *)
|
126
|
+
| FgnCnstr of csid * FgnCnstr (* | (foreign) *)
|
127
|
+
|
128
|
+
and Status = (* Status of a constant: *)
|
129
|
+
Normal (* inert *)
|
130
|
+
| Constraint of csid * (Dec Ctx * Spine * int -> Exp option)
|
131
|
+
(* acts as constraint *)
|
132
|
+
| Foreign of csid * (Spine -> Exp) (* is converted to foreign *)
|
133
|
+
|
134
|
+
and FgnUnify = (* Result of foreign unify *)
|
135
|
+
Succeed of FgnUnifyResidual list
|
136
|
+
(* succeed with a list of residual operations *)
|
137
|
+
| Fail
|
138
|
+
|
139
|
+
and FgnUnifyResidual = (* Residual of foreign unify *)
|
140
|
+
Assign of Dec Ctx * Exp * Exp * Sub
|
141
|
+
(* perform the assignment G |- X = U [ss] *)
|
142
|
+
| Delay of Exp * Cnstr ref
|
143
|
+
(* delay cnstr, associating it with all the rigid EVars in U *)
|
144
|
+
|
145
|
+
(* Global signature *)
|
146
|
+
|
147
|
+
and ConDec = (* Constant declaration *)
|
148
|
+
ConDec of string * mid option * int * Status
|
149
|
+
(* a : K : kind or *)
|
150
|
+
* Exp * Uni (* c : A : type *)
|
151
|
+
| ConDef of string * mid option * int (* a = A : K : kind or *)
|
152
|
+
* Exp * Exp * Uni (* d = M : A : type *)
|
153
|
+
* Ancestor (* Ancestor info for d or a *)
|
154
|
+
| AbbrevDef of string * mid option * int
|
155
|
+
(* a = A : K : kind or *)
|
156
|
+
* Exp * Exp * Uni (* d = M : A : type *)
|
157
|
+
| BlockDec of string * mid option (* %block l : SOME G1 PI G2 *)
|
158
|
+
* Dec Ctx * Dec list
|
159
|
+
|
160
|
+
| BlockDef of string * mid option * cid list
|
161
|
+
(* %block l = (l1 | ... | ln) *)
|
162
|
+
|
163
|
+
| SkoDec of string * mid option * int (* sa: K : kind or *)
|
164
|
+
* Exp * Uni (* sc: A : type *)
|
165
|
+
|
166
|
+
and Ancestor = (* Ancestor of d or a *)
|
167
|
+
Anc of cid option * int * cid option (* head(expand(d)), height, head(expand[height](d)) *)
|
168
|
+
(* NONE means expands to {x:A}B *)
|
169
|
+
|
170
|
+
datatype StrDec = (* Structure declaration *)
|
171
|
+
StrDec of string * mid option
|
172
|
+
|
173
|
+
(* Form of constant declaration *)
|
174
|
+
datatype ConDecForm =
|
175
|
+
FromCS (* from constraint domain *)
|
176
|
+
| Ordinary (* ordinary declaration *)
|
177
|
+
| Clause (* %clause declaration *)
|
178
|
+
|
179
|
+
(* Type abbreviations *)
|
180
|
+
type dctx = Dec Ctx (* G = . | G,D *)
|
181
|
+
type eclo = Exp * Sub (* Us = U[s] *)
|
182
|
+
type bclo = Block * Sub (* Bs = B[s] *)
|
183
|
+
type cnstr = Cnstr ref
|
184
|
+
|
185
|
+
(* exception Error of string (* raised if out of space *) *)
|
186
|
+
|
187
|
+
|
188
|
+
structure FgnExpStd = struct
|
189
|
+
|
190
|
+
structure ToInternal = FgnOpnTable (type arg = unit
|
191
|
+
type result = Exp)
|
192
|
+
|
193
|
+
structure Map = FgnOpnTable (type arg = Exp -> Exp
|
194
|
+
type result = Exp)
|
195
|
+
|
196
|
+
structure App = FgnOpnTable (type arg = Exp -> unit
|
197
|
+
type result = unit)
|
198
|
+
|
199
|
+
structure EqualTo = FgnOpnTable (type arg = Exp
|
200
|
+
type result = bool)
|
201
|
+
|
202
|
+
structure UnifyWith = FgnOpnTable (type arg = Dec Ctx * Exp
|
203
|
+
type result = FgnUnify)
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
fun fold csfe f b = let
|
208
|
+
val r = ref b
|
209
|
+
fun g U = r := f (U,!r)
|
210
|
+
in
|
211
|
+
App.apply csfe g ; !r
|
212
|
+
end
|
213
|
+
|
214
|
+
end
|
215
|
+
|
216
|
+
structure FgnCnstrStd = struct
|
217
|
+
|
218
|
+
structure ToInternal = FgnOpnTable (type arg = unit
|
219
|
+
type result = (Dec Ctx * Exp) list)
|
220
|
+
|
221
|
+
structure Awake = FgnOpnTable (type arg = unit
|
222
|
+
type result = bool)
|
223
|
+
|
224
|
+
structure Simplify = FgnOpnTable (type arg = unit
|
225
|
+
type result = bool)
|
226
|
+
|
227
|
+
end
|
228
|
+
|
229
|
+
fun conDecName (ConDec (name, _, _, _, _, _)) = name
|
230
|
+
| conDecName (ConDef (name, _, _, _, _, _, _)) = name
|
231
|
+
| conDecName (AbbrevDef (name, _, _, _, _, _)) = name
|
232
|
+
| conDecName (SkoDec (name, _, _, _, _)) = name
|
233
|
+
| conDecName (BlockDec (name, _, _, _)) = name
|
234
|
+
| conDecName (BlockDef (name, _, _)) = name
|
235
|
+
|
236
|
+
fun conDecParent (ConDec (_, parent, _, _, _, _)) = parent
|
237
|
+
| conDecParent (ConDef (_, parent, _, _, _, _, _)) = parent
|
238
|
+
| conDecParent (AbbrevDef (_, parent, _, _, _, _)) = parent
|
239
|
+
| conDecParent (SkoDec (_, parent, _, _, _)) = parent
|
240
|
+
| conDecParent (BlockDec (_, parent, _, _)) = parent
|
241
|
+
| conDecParent (BlockDef (_, parent, _)) = parent
|
242
|
+
|
243
|
+
|
244
|
+
(* conDecImp (CD) = k
|
245
|
+
|
246
|
+
Invariant:
|
247
|
+
If CD is either a declaration, definition, abbreviation, or
|
248
|
+
a Skolem constant
|
249
|
+
then k stands for the number of implicit elements.
|
250
|
+
*)
|
251
|
+
fun conDecImp (ConDec (_, _, i, _, _, _)) = i
|
252
|
+
| conDecImp (ConDef (_, _, i, _, _, _, _)) = i
|
253
|
+
| conDecImp (AbbrevDef (_, _, i, _, _, _)) = i
|
254
|
+
| conDecImp (SkoDec (_, _, i, _, _)) = i
|
255
|
+
| conDecImp (BlockDec (_, _, _, _)) = 0 (* watch out -- carsten *)
|
256
|
+
|
257
|
+
fun conDecStatus (ConDec (_, _, _, status, _, _)) = status
|
258
|
+
| conDecStatus _ = Normal
|
259
|
+
|
260
|
+
(* conDecType (CD) = V
|
261
|
+
|
262
|
+
Invariant:
|
263
|
+
If CD is either a declaration, definition, abbreviation, or
|
264
|
+
a Skolem constant
|
265
|
+
then V is the respective type
|
266
|
+
*)
|
267
|
+
fun conDecType (ConDec (_, _, _, _, V, _)) = V
|
268
|
+
| conDecType (ConDef (_, _, _, _, V, _, _)) = V
|
269
|
+
| conDecType (AbbrevDef (_, _, _, _, V, _)) = V
|
270
|
+
| conDecType (SkoDec (_, _, _, V, _)) = V
|
271
|
+
|
272
|
+
|
273
|
+
(* conDecBlock (CD) = (Gsome, Lpi)
|
274
|
+
|
275
|
+
Invariant:
|
276
|
+
If CD is block definition
|
277
|
+
then Gsome is the context of some variables
|
278
|
+
and Lpi is the list of pi variables
|
279
|
+
*)
|
280
|
+
fun conDecBlock (BlockDec (_, _, Gsome, Lpi)) = (Gsome, Lpi)
|
281
|
+
|
282
|
+
(* conDecUni (CD) = L
|
283
|
+
|
284
|
+
Invariant:
|
285
|
+
If CD is either a declaration, definition, abbreviation, or
|
286
|
+
a Skolem constant
|
287
|
+
then L is the respective universe
|
288
|
+
*)
|
289
|
+
fun conDecUni (ConDec (_, _, _, _, _, L)) = L
|
290
|
+
| conDecUni (ConDef (_, _, _, _, _, L, _)) = L
|
291
|
+
| conDecUni (AbbrevDef (_, _, _, _, _, L)) = L
|
292
|
+
| conDecUni (SkoDec (_, _, _, _, L)) = L
|
293
|
+
|
294
|
+
|
295
|
+
fun strDecName (StrDec (name, _)) = name
|
296
|
+
|
297
|
+
fun strDecParent (StrDec (_, parent)) = parent
|
298
|
+
|
299
|
+
local
|
300
|
+
val maxCid = Global.maxCid
|
301
|
+
val dummyEntry = ConDec("", NONE, 0, Normal, Uni (Kind), Kind)
|
302
|
+
val sgnArray = Array.array (maxCid+1, dummyEntry)
|
303
|
+
: ConDec Array.array
|
304
|
+
val nextCid = ref(0)
|
305
|
+
|
306
|
+
val maxMid = Global.maxMid
|
307
|
+
val sgnStructArray = Array.array (maxMid+1, StrDec("", NONE))
|
308
|
+
: StrDec Array.array
|
309
|
+
val nextMid = ref (0)
|
310
|
+
|
311
|
+
in
|
312
|
+
(* Invariants *)
|
313
|
+
(* Constant declarations are all well-typed *)
|
314
|
+
(* Constant declarations are stored in beta-normal form *)
|
315
|
+
(* All definitions are strict in all their arguments *)
|
316
|
+
(* If Const(cid) is valid, then sgnArray(cid) = ConDec _ *)
|
317
|
+
(* If Def(cid) is valid, then sgnArray(cid) = ConDef _ *)
|
318
|
+
|
319
|
+
fun sgnClean (i) = if i >= !nextCid then ()
|
320
|
+
else (Array.update (sgnArray, i, dummyEntry);
|
321
|
+
sgnClean (i+1))
|
322
|
+
|
323
|
+
fun sgnReset () = ((* Fri Dec 20 12:04:24 2002 -fp *)
|
324
|
+
(* this circumvents a space leak *)
|
325
|
+
sgnClean (0);
|
326
|
+
nextCid := 0; nextMid := 0)
|
327
|
+
fun sgnSize () = (!nextCid, !nextMid)
|
328
|
+
|
329
|
+
fun sgnAdd (conDec) =
|
330
|
+
let
|
331
|
+
val cid = !nextCid
|
332
|
+
in
|
333
|
+
if cid > maxCid
|
334
|
+
then raise Error ("Global signature size " ^ Int.toString (maxCid+1) ^ " exceeded")
|
335
|
+
else (Array.update (sgnArray, cid, conDec) ;
|
336
|
+
nextCid := cid + 1;
|
337
|
+
cid)
|
338
|
+
end
|
339
|
+
|
340
|
+
(* 0 <= cid < !nextCid *)
|
341
|
+
fun sgnLookup (cid) = Array.sub (sgnArray, cid)
|
342
|
+
|
343
|
+
fun sgnApp (f) =
|
344
|
+
let
|
345
|
+
fun sgnApp' (cid) =
|
346
|
+
if cid = !nextCid then () else (f cid; sgnApp' (cid+1))
|
347
|
+
in
|
348
|
+
sgnApp' (0)
|
349
|
+
end
|
350
|
+
|
351
|
+
fun sgnStructAdd (strDec) =
|
352
|
+
let
|
353
|
+
val mid = !nextMid
|
354
|
+
in
|
355
|
+
if mid > maxMid
|
356
|
+
then raise Error ("Global signature size " ^ Int.toString (maxMid+1) ^ " exceeded")
|
357
|
+
else (Array.update (sgnStructArray, mid, strDec) ;
|
358
|
+
nextMid := mid + 1;
|
359
|
+
mid)
|
360
|
+
end
|
361
|
+
|
362
|
+
(* 0 <= mid < !nextMid *)
|
363
|
+
fun sgnStructLookup (mid) = Array.sub (sgnStructArray, mid)
|
364
|
+
|
365
|
+
(* A hack used in Flit - jcreed 6/05 *)
|
366
|
+
fun rename (cid, new) =
|
367
|
+
let
|
368
|
+
val newConDec = case sgnLookup cid of
|
369
|
+
ConDec (n,m,i,s,e,u) => ConDec(new,m,i,s,e,u)
|
370
|
+
| ConDef (n,m,i,e,e',u,a) => ConDef(new,m,i,e,e',u,a)
|
371
|
+
| AbbrevDef (n,m,i,e,e',u) => AbbrevDef (new,m,i,e,e',u)
|
372
|
+
| BlockDec (n,m,d,d') => BlockDec (new,m,d,d')
|
373
|
+
| SkoDec (n,m,i,e,u) => SkoDec (new,m,i,e,u)
|
374
|
+
in
|
375
|
+
Array.update (sgnArray, cid, newConDec)
|
376
|
+
end
|
377
|
+
|
378
|
+
end
|
379
|
+
|
380
|
+
fun constDef (d) =
|
381
|
+
(case sgnLookup (d)
|
382
|
+
of ConDef(_, _, _, U,_, _, _) => U
|
383
|
+
| AbbrevDef (_, _, _, U,_, _) => U)
|
384
|
+
|
385
|
+
fun constType (c) = conDecType (sgnLookup c)
|
386
|
+
fun constImp (c) = conDecImp (sgnLookup c)
|
387
|
+
fun constUni (c) = conDecUni (sgnLookup c)
|
388
|
+
fun constBlock (c) = conDecBlock (sgnLookup c)
|
389
|
+
|
390
|
+
fun constStatus (c) =
|
391
|
+
(case sgnLookup (c)
|
392
|
+
of ConDec (_, _, _, status, _, _) => status
|
393
|
+
| _ => Normal)
|
394
|
+
|
395
|
+
|
396
|
+
(* Explicit Substitutions *)
|
397
|
+
|
398
|
+
(* id = ^0
|
399
|
+
|
400
|
+
Invariant:
|
401
|
+
G |- id : G id is patsub
|
402
|
+
*)
|
403
|
+
val id = Shift(0)
|
404
|
+
|
405
|
+
(* shift = ^1
|
406
|
+
|
407
|
+
Invariant:
|
408
|
+
G, V |- ^ : G ^ is patsub
|
409
|
+
*)
|
410
|
+
val shift = Shift(1)
|
411
|
+
|
412
|
+
(* invShift = ^-1 = _.^0
|
413
|
+
Invariant:
|
414
|
+
G |- ^-1 : G, V ^-1 is patsub
|
415
|
+
*)
|
416
|
+
val invShift = Dot(Undef, id)
|
417
|
+
|
418
|
+
|
419
|
+
(* comp (s1, s2) = s'
|
420
|
+
|
421
|
+
Invariant:
|
422
|
+
If G' |- s1 : G
|
423
|
+
and G'' |- s2 : G'
|
424
|
+
then s' = s1 o s2
|
425
|
+
and G'' |- s1 o s2 : G
|
426
|
+
|
427
|
+
If s1, s2 patsub
|
428
|
+
then s' patsub
|
429
|
+
*)
|
430
|
+
fun comp (Shift (0), s) = s
|
431
|
+
(* next line is an optimization *)
|
432
|
+
(* roughly 15% on standard suite for Twelf 1.1 *)
|
433
|
+
(* Sat Feb 14 10:15:16 1998 -fp *)
|
434
|
+
| comp (s, Shift (0)) = s
|
435
|
+
| comp (Shift (n), Dot (Ft, s)) = comp (Shift (n-1), s)
|
436
|
+
| comp (Shift (n), Shift (m)) = Shift (n+m)
|
437
|
+
| comp (Dot (Ft, s), s') = Dot (frontSub (Ft, s'), comp (s, s'))
|
438
|
+
|
439
|
+
(* bvarSub (n, s) = Ft'
|
440
|
+
|
441
|
+
Invariant:
|
442
|
+
If G |- s : G' G' |- n : V
|
443
|
+
then Ft' = Ftn if s = Ft1 .. Ftn .. ^k
|
444
|
+
or Ft' = ^(n+k) if s = Ft1 .. Ftm ^k and m<n
|
445
|
+
and G |- Ft' : V [s]
|
446
|
+
*)
|
447
|
+
and bvarSub (1, Dot(Ft, s)) = Ft
|
448
|
+
| bvarSub (n, Dot(Ft, s)) = bvarSub (n-1, s)
|
449
|
+
| bvarSub (n, Shift(k)) = Idx (n+k)
|
450
|
+
|
451
|
+
(* blockSub (B, s) = B'
|
452
|
+
|
453
|
+
Invariant:
|
454
|
+
If G |- s : G'
|
455
|
+
and G' |- B block
|
456
|
+
then G |- B' block
|
457
|
+
and B [s] == B'
|
458
|
+
*)
|
459
|
+
(* in front of substitutions, first case is irrelevant *)
|
460
|
+
(* Sun Dec 2 11:56:41 2001 -fp *)
|
461
|
+
and blockSub (Bidx k, s) =
|
462
|
+
(case bvarSub (k, s)
|
463
|
+
of Idx k' => Bidx k'
|
464
|
+
| Block B => B)
|
465
|
+
| blockSub (LVar (ref (SOME B), sk, _), s) =
|
466
|
+
blockSub (B, comp (sk, s))
|
467
|
+
(* -fp Sun Dec 1 21:18:30 2002 *)
|
468
|
+
(* --cs Sun Dec 1 11:25:41 2002 *)
|
469
|
+
(* Since always . |- t : Gsome, discard s *)
|
470
|
+
(* where is this needed? *)
|
471
|
+
(* Thu Dec 6 20:30:26 2001 -fp !!! *)
|
472
|
+
| blockSub (LVar (r as ref NONE, sk, (l, t)), s) =
|
473
|
+
LVar(r, comp(sk, s), (l, t))
|
474
|
+
(* was:
|
475
|
+
LVar (r, comp(sk, s), (l, comp (t, s)))
|
476
|
+
July 22, 2010 -fp -cs
|
477
|
+
*)
|
478
|
+
(* comp(^k, s) = ^k' for some k' by invariant *)
|
479
|
+
| blockSub (L as Inst ULs, s') = Inst (map (fn U => EClo (U, s')) ULs)
|
480
|
+
(* this should be right but somebody should verify *)
|
481
|
+
|
482
|
+
(* frontSub (Ft, s) = Ft'
|
483
|
+
|
484
|
+
Invariant:
|
485
|
+
If G |- s : G' G' |- Ft : V
|
486
|
+
then Ft' = Ft [s]
|
487
|
+
and G |- Ft' : V [s]
|
488
|
+
|
489
|
+
NOTE: EClo (U, s) might be undefined, so if this is ever
|
490
|
+
computed eagerly, we must introduce an "Undefined" exception,
|
491
|
+
raise it in whnf and handle it here so Exp (EClo (U, s)) => Undef
|
492
|
+
*)
|
493
|
+
and frontSub (Idx (n), s) = bvarSub (n, s)
|
494
|
+
| frontSub (Exp (U), s) = Exp (EClo (U, s))
|
495
|
+
| frontSub (Undef, s) = Undef
|
496
|
+
| frontSub (Block (B), s) = Block (blockSub (B, s))
|
497
|
+
|
498
|
+
(* decSub (x:V, s) = D'
|
499
|
+
|
500
|
+
Invariant:
|
501
|
+
If G |- s : G' G' |- V : L
|
502
|
+
then D' = x:V[s]
|
503
|
+
and G |- V[s] : L
|
504
|
+
*)
|
505
|
+
(* First line is an optimization suggested by cs *)
|
506
|
+
(* D[id] = D *)
|
507
|
+
(* Sat Feb 14 18:37:44 1998 -fp *)
|
508
|
+
(* seems to have no statistically significant effect *)
|
509
|
+
(* undo for now Sat Feb 14 20:22:29 1998 -fp *)
|
510
|
+
(*
|
511
|
+
fun decSub (D, Shift(0)) = D
|
512
|
+
| decSub (Dec (x, V), s) = Dec (x, EClo (V, s))
|
513
|
+
*)
|
514
|
+
fun decSub (Dec (x, V), s) = Dec (x, EClo (V, s))
|
515
|
+
| decSub (NDec x, s) = NDec x
|
516
|
+
| decSub (BDec (n, (l, t)), s) = BDec (n, (l, comp (t, s)))
|
517
|
+
|
518
|
+
(* dot1 (s) = s'
|
519
|
+
|
520
|
+
Invariant:
|
521
|
+
If G |- s : G'
|
522
|
+
then s' = 1. (s o ^)
|
523
|
+
and for all V s.t. G' |- V : L
|
524
|
+
G, V[s] |- s' : G', V
|
525
|
+
|
526
|
+
If s patsub then s' patsub
|
527
|
+
*)
|
528
|
+
(* first line is an optimization *)
|
529
|
+
(* roughly 15% on standard suite for Twelf 1.1 *)
|
530
|
+
(* Sat Feb 14 10:16:16 1998 -fp *)
|
531
|
+
fun dot1 (s as Shift (0)) = s
|
532
|
+
| dot1 s = Dot (Idx(1), comp(s, shift))
|
533
|
+
|
534
|
+
(* invDot1 (s) = s'
|
535
|
+
invDot1 (1. s' o ^) = s'
|
536
|
+
|
537
|
+
Invariant:
|
538
|
+
s = 1 . s' o ^
|
539
|
+
If G' |- s' : G
|
540
|
+
(so G',V[s] |- s : G,V)
|
541
|
+
*)
|
542
|
+
fun invDot1 (s) = comp (comp(shift, s), invShift)
|
543
|
+
|
544
|
+
|
545
|
+
(* Declaration Contexts *)
|
546
|
+
|
547
|
+
(* ctxDec (G, k) = x:V
|
548
|
+
Invariant:
|
549
|
+
If |G| >= k, where |G| is size of G,
|
550
|
+
then G |- k : V and G |- V : L
|
551
|
+
*)
|
552
|
+
fun ctxDec (G, k) =
|
553
|
+
let (* ctxDec' (G'', k') = x:V
|
554
|
+
where G |- ^(k-k') : G'', 1 <= k' <= k
|
555
|
+
*)
|
556
|
+
fun ctxDec' (Decl (G', Dec (x, V')), 1) = Dec (x, EClo (V', Shift (k)))
|
557
|
+
| ctxDec' (Decl (G', BDec (n, (l, s))), 1) = BDec (n, (l, comp (s, Shift (k))))
|
558
|
+
| ctxDec' (Decl (G', _), k') = ctxDec' (G', k'-1)
|
559
|
+
(* ctxDec' (Null, k') should not occur by invariant *)
|
560
|
+
in
|
561
|
+
ctxDec' (G, k)
|
562
|
+
end
|
563
|
+
|
564
|
+
(* blockDec (G, v, i) = V
|
565
|
+
|
566
|
+
Invariant:
|
567
|
+
If G (v) = l[s]
|
568
|
+
and Sigma (l) = SOME Gsome BLOCK Lblock
|
569
|
+
and G |- s : Gsome
|
570
|
+
then G |- pi (v, i) : V
|
571
|
+
*)
|
572
|
+
|
573
|
+
fun blockDec (G, v as (Bidx k), i) =
|
574
|
+
let
|
575
|
+
val BDec (_, (l, s)) = ctxDec (G, k)
|
576
|
+
(* G |- s : Gsome *)
|
577
|
+
val (Gsome, Lblock) = conDecBlock (sgnLookup l)
|
578
|
+
fun blockDec' (t, D :: L, 1, j) = decSub (D, t)
|
579
|
+
| blockDec' (t, _ :: L, n, j) =
|
580
|
+
blockDec' (Dot (Exp (Root (Proj (v, j), Nil)), t),
|
581
|
+
L, n-1, j+1)
|
582
|
+
in
|
583
|
+
blockDec' (s, Lblock, i, 1)
|
584
|
+
end
|
585
|
+
|
586
|
+
|
587
|
+
(* EVar related functions *)
|
588
|
+
|
589
|
+
(* newEVar (G, V) = newEVarCnstr (G, V, nil) *)
|
590
|
+
fun newEVar (G, V) = EVar(ref NONE, G, V, ref nil)
|
591
|
+
|
592
|
+
(* newAVar G = new AVar (assignable variable) *)
|
593
|
+
(* AVars carry no type, ctx, or cnstr *)
|
594
|
+
fun newAVar () = AVar(ref NONE)
|
595
|
+
|
596
|
+
(* newTypeVar (G) = X, X new
|
597
|
+
where G |- X : type
|
598
|
+
*)
|
599
|
+
fun newTypeVar (G) = EVar(ref NONE, G, Uni(Type), ref nil)
|
600
|
+
|
601
|
+
(* newLVar (l, s) = (l[s]) *)
|
602
|
+
fun newLVar (sk, (cid, t)) = LVar (ref NONE, sk, (cid, t))
|
603
|
+
|
604
|
+
(* Definition related functions *)
|
605
|
+
(* headOpt (U) = SOME(H) or NONE, U should be strict, normal *)
|
606
|
+
fun headOpt (Root (H, _)) = SOME(H)
|
607
|
+
| headOpt (Lam (_, U)) = headOpt U
|
608
|
+
| headOpt _ = NONE
|
609
|
+
|
610
|
+
fun ancestor' (NONE) = Anc(NONE, 0, NONE)
|
611
|
+
| ancestor' (SOME(Const(c))) = Anc(SOME(c), 1, SOME(c))
|
612
|
+
| ancestor' (SOME(Def(d))) =
|
613
|
+
(case sgnLookup(d)
|
614
|
+
of ConDef(_, _, _, _, _, _, Anc(_, height, cOpt))
|
615
|
+
=> Anc(SOME(d), height+1, cOpt))
|
616
|
+
| ancestor' (SOME _) = (* FgnConst possible, BVar impossible by strictness *)
|
617
|
+
Anc(NONE, 0, NONE)
|
618
|
+
(* ancestor(U) = ancestor info for d = U *)
|
619
|
+
fun ancestor (U) = ancestor' (headOpt U)
|
620
|
+
|
621
|
+
(* defAncestor(d) = ancestor of d, d must be defined *)
|
622
|
+
fun defAncestor (d) =
|
623
|
+
(case sgnLookup(d)
|
624
|
+
of ConDef(_, _, _, _, _, _, anc) => anc)
|
625
|
+
|
626
|
+
(* Type related functions *)
|
627
|
+
|
628
|
+
(* targetHeadOpt (V) = SOME(H) or NONE
|
629
|
+
where H is the head of the atomic target type of V,
|
630
|
+
NONE if V is a kind or object or have variable type.
|
631
|
+
Does not expand type definitions.
|
632
|
+
*)
|
633
|
+
(* should there possibly be a FgnConst case? also targetFamOpt -kw *)
|
634
|
+
fun targetHeadOpt (Root (H, _)) = SOME(H)
|
635
|
+
| targetHeadOpt (Pi(_, V)) = targetHeadOpt V
|
636
|
+
| targetHeadOpt (Redex (V, S)) = targetHeadOpt V
|
637
|
+
| targetHeadOpt (Lam (_, V)) = targetHeadOpt V
|
638
|
+
| targetHeadOpt (EVar (ref (SOME(V)),_,_,_)) = targetHeadOpt V
|
639
|
+
| targetHeadOpt (EClo (V, s)) = targetHeadOpt V
|
640
|
+
| targetHeadOpt _ = NONE
|
641
|
+
(* Root(Bvar _, _), Root(FVar _, _), Root(FgnConst _, _),
|
642
|
+
EVar(ref NONE,..), Uni, FgnExp _
|
643
|
+
*)
|
644
|
+
(* Root(Skonst _, _) can't occur *)
|
645
|
+
(* targetHead (A) = a
|
646
|
+
as in targetHeadOpt, except V must be a valid type
|
647
|
+
*)
|
648
|
+
fun targetHead (A) = valOf (targetHeadOpt A)
|
649
|
+
|
650
|
+
(* targetFamOpt (V) = SOME(cid) or NONE
|
651
|
+
where cid is the type family of the atomic target type of V,
|
652
|
+
NONE if V is a kind or object or have variable type.
|
653
|
+
Does expand type definitions.
|
654
|
+
*)
|
655
|
+
fun targetFamOpt (Root (Const(cid), _)) = SOME(cid)
|
656
|
+
| targetFamOpt (Pi(_, V)) = targetFamOpt V
|
657
|
+
| targetFamOpt (Root (Def(cid), _)) = targetFamOpt (constDef cid)
|
658
|
+
| targetFamOpt (Redex (V, S)) = targetFamOpt V
|
659
|
+
| targetFamOpt (Lam (_, V)) = targetFamOpt V
|
660
|
+
| targetFamOpt (EVar (ref (SOME(V)),_,_,_)) = targetFamOpt V
|
661
|
+
| targetFamOpt (EClo (V, s)) = targetFamOpt V
|
662
|
+
| targetFamOpt _ = NONE
|
663
|
+
(* Root(Bvar _, _), Root(FVar _, _), Root(FgnConst _, _),
|
664
|
+
EVar(ref NONE,..), Uni, FgnExp _
|
665
|
+
*)
|
666
|
+
(* Root(Skonst _, _) can't occur *)
|
667
|
+
(* targetFam (A) = a
|
668
|
+
as in targetFamOpt, except V must be a valid type
|
669
|
+
*)
|
670
|
+
fun targetFam (A) = valOf (targetFamOpt A)
|
671
|
+
|
672
|
+
end; (* functor IntSyn *)
|
673
|
+
|
674
|
+
structure IntSyn :> INTSYN =
|
675
|
+
IntSyn (structure Global = Global);
|