Merge branch 'master' into newlisp

This commit is contained in:
Paul Chaignon
2015-01-24 00:15:52 +01:00
285 changed files with 15092 additions and 443 deletions

1
.gitignore vendored
View File

@@ -5,3 +5,4 @@ lib/linguist/samples.json
/grammars
/node_modules
test/fixtures/ace_modes.json
/vendor/gems/

551
.gitmodules vendored Normal file
View File

@@ -0,0 +1,551 @@
[submodule "vendor/grammars/go-tmbundle"]
path = vendor/grammars/go-tmbundle
url = https://github.com/AlanQuatermain/go-tmbundle
[submodule "vendor/grammars/PHP-Twig.tmbundle"]
path = vendor/grammars/PHP-Twig.tmbundle
url = https://github.com/Anomareh/PHP-Twig.tmbundle
[submodule "vendor/grammars/sublime-cirru"]
path = vendor/grammars/sublime-cirru
url = https://github.com/Cirru/sublime-cirru
[submodule "vendor/grammars/Sublime-Logos"]
path = vendor/grammars/Sublime-Logos
url = https://github.com/Cykey/Sublime-Logos
[submodule "vendor/grammars/SublimeBrainfuck"]
path = vendor/grammars/SublimeBrainfuck
url = https://github.com/Drako/SublimeBrainfuck
[submodule "vendor/grammars/awk-sublime"]
path = vendor/grammars/awk-sublime
url = https://github.com/JohnNilsson/awk-sublime
[submodule "vendor/grammars/Sublime-SQF-Language"]
path = vendor/grammars/Sublime-SQF-Language
url = https://github.com/JonBons/Sublime-SQF-Language
[submodule "vendor/grammars/SCSS.tmbundle"]
path = vendor/grammars/SCSS.tmbundle
url = https://github.com/MarioRicalde/SCSS.tmbundle
[submodule "vendor/grammars/Sublime-REBOL"]
path = vendor/grammars/Sublime-REBOL
url = https://github.com/Oldes/Sublime-REBOL
[submodule "vendor/grammars/Sublime-Inform"]
path = vendor/grammars/Sublime-Inform
url = https://github.com/PogiNate/Sublime-Inform
[submodule "vendor/grammars/autoitv3-tmbundle"]
path = vendor/grammars/autoitv3-tmbundle
url = https://github.com/Red-Nova-Technologies/autoitv3-tmbundle
[submodule "vendor/grammars/Sublime-VimL"]
path = vendor/grammars/Sublime-VimL
url = https://github.com/SalGnt/Sublime-VimL
[submodule "vendor/grammars/boo-sublime"]
path = vendor/grammars/boo-sublime
url = https://github.com/Shammah/boo-sublime
[submodule "vendor/grammars/ColdFusion"]
path = vendor/grammars/ColdFusion
url = https://github.com/SublimeText/ColdFusion
[submodule "vendor/grammars/NSIS"]
path = vendor/grammars/NSIS
url = https://github.com/SublimeText/NSIS
[submodule "vendor/grammars/NimLime"]
path = vendor/grammars/NimLime
url = https://github.com/Varriount/NimLime
[submodule "vendor/grammars/gradle.tmbundle"]
path = vendor/grammars/gradle.tmbundle
url = https://github.com/alkemist/gradle.tmbundle
[submodule "vendor/grammars/Sublime-Loom"]
path = vendor/grammars/Sublime-Loom
url = https://github.com/ambethia/Sublime-Loom
[submodule "vendor/grammars/VBDotNetSyntax"]
path = vendor/grammars/VBDotNetSyntax
url = https://github.com/angryant0007/VBDotNetSyntax
[submodule "vendor/grammars/cool-tmbundle"]
path = vendor/grammars/cool-tmbundle
url = https://github.com/anunayk/cool-tmbundle
[submodule "vendor/grammars/Docker.tmbundle"]
path = vendor/grammars/Docker.tmbundle
url = https://github.com/asbjornenge/Docker.tmbundle
[submodule "vendor/grammars/jasmin-sublime"]
path = vendor/grammars/jasmin-sublime
url = https://github.com/atmarksharp/jasmin-sublime
[submodule "vendor/grammars/language-clojure"]
path = vendor/grammars/language-clojure
url = https://github.com/atom/language-clojure
[submodule "vendor/grammars/language-coffee-script"]
path = vendor/grammars/language-coffee-script
url = https://github.com/atom/language-coffee-script
[submodule "vendor/grammars/language-csharp"]
path = vendor/grammars/language-csharp
url = https://github.com/atom/language-csharp
[submodule "vendor/grammars/language-gfm"]
path = vendor/grammars/language-gfm
url = https://github.com/atom/language-gfm
[submodule "vendor/grammars/language-javascript"]
path = vendor/grammars/language-javascript
url = https://github.com/atom/language-javascript
[submodule "vendor/grammars/language-python"]
path = vendor/grammars/language-python
url = https://github.com/atom/language-python
[submodule "vendor/grammars/language-shellscript"]
path = vendor/grammars/language-shellscript
url = https://github.com/atom/language-shellscript
[submodule "vendor/grammars/language-yaml"]
path = vendor/grammars/language-yaml
url = https://github.com/atom/language-yaml
[submodule "vendor/grammars/sublime-sourcepawn"]
path = vendor/grammars/sublime-sourcepawn
url = https://github.com/austinwagner/sublime-sourcepawn
[submodule "vendor/grammars/Sublime-Lasso"]
path = vendor/grammars/Sublime-Lasso
url = https://github.com/bfad/Sublime-Lasso
[submodule "vendor/grammars/chapel-tmbundle"]
path = vendor/grammars/chapel-tmbundle
url = https://github.com/bholt/chapel-tmbundle
[submodule "vendor/grammars/sublime-nginx"]
path = vendor/grammars/sublime-nginx
url = https://github.com/brandonwamboldt/sublime-nginx
[submodule "vendor/grammars/bro-sublime"]
path = vendor/grammars/bro-sublime
url = https://github.com/bro/bro-sublime
[submodule "vendor/grammars/sublime_man_page_support"]
path = vendor/grammars/sublime_man_page_support
url = https://github.com/carsonoid/sublime_man_page_support
[submodule "vendor/grammars/sublime-MuPAD"]
path = vendor/grammars/sublime-MuPAD
url = https://github.com/ccreutzig/sublime-MuPAD
[submodule "vendor/grammars/nesC.tmbundle"]
path = vendor/grammars/nesC.tmbundle
url = https://github.com/cdwilson/nesC.tmbundle
[submodule "vendor/grammars/haxe-sublime-bundle"]
path = vendor/grammars/haxe-sublime-bundle
url = https://github.com/clemos/haxe-sublime-bundle
[submodule "vendor/grammars/cucumber-tmbundle"]
path = vendor/grammars/cucumber-tmbundle
url = https://github.com/cucumber/cucumber-tmbundle
[submodule "vendor/grammars/Handlebars"]
path = vendor/grammars/Handlebars
url = https://github.com/daaain/Handlebars
[submodule "vendor/grammars/powershell.tmbundle"]
path = vendor/grammars/powershell.tmbundle
url = https://github.com/davidpeckham/powershell.tmbundle
[submodule "vendor/grammars/jade-tmbundle"]
path = vendor/grammars/jade-tmbundle
url = https://github.com/davidrios/jade-tmbundle
[submodule "vendor/grammars/elixir-tmbundle"]
path = vendor/grammars/elixir-tmbundle
url = https://github.com/elixir-lang/elixir-tmbundle
[submodule "vendor/grammars/sublime-glsl"]
path = vendor/grammars/sublime-glsl
url = https://github.com/euler0/sublime-glsl
[submodule "vendor/grammars/fancy-tmbundle"]
path = vendor/grammars/fancy-tmbundle
url = https://github.com/fancy-lang/fancy-tmbundle
[submodule "vendor/grammars/fsharpbinding"]
path = vendor/grammars/fsharpbinding
url = https://github.com/fsharp/fsharpbinding
[submodule "vendor/grammars/monkey.tmbundle"]
path = vendor/grammars/monkey.tmbundle
url = https://github.com/gingerbeardman/monkey.tmbundle
[submodule "vendor/grammars/dart-sublime-bundle"]
path = vendor/grammars/dart-sublime-bundle
url = https://github.com/guillermooo/dart-sublime-bundle
[submodule "vendor/grammars/sublimetext-cuda-cpp"]
path = vendor/grammars/sublimetext-cuda-cpp
url = https://github.com/harrism/sublimetext-cuda-cpp
[submodule "vendor/grammars/pike-textmate"]
path = vendor/grammars/pike-textmate
url = https://github.com/hww3/pike-textmate
[submodule "vendor/grammars/ceylon-sublimetext"]
path = vendor/grammars/ceylon-sublimetext
url = https://github.com/jeancharles-roger/ceylon-sublimetext
[submodule "vendor/grammars/Sublime-Text-2-OpenEdge-ABL"]
path = vendor/grammars/Sublime-Text-2-OpenEdge-ABL
url = https://github.com/jfairbank/Sublime-Text-2-OpenEdge-ABL
[submodule "vendor/grammars/sublime-rust"]
path = vendor/grammars/sublime-rust
url = https://github.com/jhasse/sublime-rust
[submodule "vendor/grammars/sublime-befunge"]
path = vendor/grammars/sublime-befunge
url = https://github.com/johanasplund/sublime-befunge
[submodule "vendor/grammars/RDoc.tmbundle"]
path = vendor/grammars/RDoc.tmbundle
url = https://github.com/joshaven/RDoc.tmbundle
[submodule "vendor/grammars/Textmate-Gosu-Bundle"]
path = vendor/grammars/Textmate-Gosu-Bundle
url = https://github.com/jpcamara/Textmate-Gosu-Bundle
[submodule "vendor/grammars/jquery-tmbundle"]
path = vendor/grammars/jquery-tmbundle
url = https://github.com/kswedberg/jquery-tmbundle
[submodule "vendor/grammars/fish-tmbundle"]
path = vendor/grammars/fish-tmbundle
url = https://github.com/l15n/fish-tmbundle
[submodule "vendor/grammars/sublime-idris"]
path = vendor/grammars/sublime-idris
url = https://github.com/laughedelic/sublime-idris
[submodule "vendor/grammars/sublime-better-typescript"]
path = vendor/grammars/sublime-better-typescript
url = https://github.com/lavrton/sublime-better-typescript
[submodule "vendor/grammars/moonscript-tmbundle"]
path = vendor/grammars/moonscript-tmbundle
url = https://github.com/leafo/moonscript-tmbundle
[submodule "vendor/grammars/Isabelle.tmbundle"]
path = vendor/grammars/Isabelle.tmbundle
url = https://github.com/lsf37/Isabelle.tmbundle
[submodule "vendor/grammars/x86-assembly-textmate-bundle"]
path = vendor/grammars/x86-assembly-textmate-bundle
url = https://github.com/lunixbochs/x86-assembly-textmate-bundle
[submodule "vendor/grammars/Alloy.tmbundle"]
path = vendor/grammars/Alloy.tmbundle
url = https://github.com/macekond/Alloy.tmbundle
[submodule "vendor/grammars/opa.tmbundle"]
path = vendor/grammars/opa.tmbundle
url = https://github.com/mads379/opa.tmbundle
[submodule "vendor/grammars/scala.tmbundle"]
path = vendor/grammars/scala.tmbundle
url = https://github.com/mads379/scala.tmbundle
[submodule "vendor/grammars/mako-tmbundle"]
path = vendor/grammars/mako-tmbundle
url = https://github.com/marconi/mako-tmbundle
[submodule "vendor/grammars/gnuplot-tmbundle"]
path = vendor/grammars/gnuplot-tmbundle
url = https://github.com/mattfoster/gnuplot-tmbundle
[submodule "vendor/grammars/idl.tmbundle"]
path = vendor/grammars/idl.tmbundle
url = https://github.com/mgalloy/idl.tmbundle
[submodule "vendor/grammars/protobuf-tmbundle"]
path = vendor/grammars/protobuf-tmbundle
url = https://github.com/michaeledgar/protobuf-tmbundle
[submodule "vendor/grammars/Sublime-Coq"]
path = vendor/grammars/Sublime-Coq
url = https://github.com/mkolosick/Sublime-Coq
[submodule "vendor/grammars/Agda.tmbundle"]
path = vendor/grammars/Agda.tmbundle
url = https://github.com/mokus0/Agda.tmbundle
[submodule "vendor/grammars/Julia.tmbundle"]
path = vendor/grammars/Julia.tmbundle
url = https://github.com/nanoant/Julia.tmbundle
[submodule "vendor/grammars/assembly.tmbundle"]
path = vendor/grammars/assembly.tmbundle
url = https://github.com/nanoant/assembly.tmbundle
[submodule "vendor/grammars/ooc.tmbundle"]
path = vendor/grammars/ooc.tmbundle
url = https://github.com/nilium/ooc.tmbundle
[submodule "vendor/grammars/LiveScript.tmbundle"]
path = vendor/grammars/LiveScript.tmbundle
url = https://github.com/paulmillr/LiveScript.tmbundle
[submodule "vendor/grammars/sublime-tea"]
path = vendor/grammars/sublime-tea
url = https://github.com/pferruggiaro/sublime-tea
[submodule "vendor/grammars/puppet-textmate-bundle"]
path = vendor/grammars/puppet-textmate-bundle
url = https://github.com/puppet-textmate-bundle/puppet-textmate-bundle
[submodule "vendor/grammars/abap.tmbundle"]
path = vendor/grammars/abap.tmbundle
url = https://github.com/pvl/abap.tmbundle
[submodule "vendor/grammars/mercury-tmlanguage"]
path = vendor/grammars/mercury-tmlanguage
url = https://github.com/sebgod/mercury-tmlanguage
[submodule "vendor/grammars/mathematica-tmbundle"]
path = vendor/grammars/mathematica-tmbundle
url = https://github.com/shadanan/mathematica-tmbundle
[submodule "vendor/grammars/sublime-robot-plugin"]
path = vendor/grammars/sublime-robot-plugin
url = https://github.com/shellderp/sublime-robot-plugin
[submodule "vendor/grammars/actionscript3-tmbundle"]
path = vendor/grammars/actionscript3-tmbundle
url = https://github.com/simongregory/actionscript3-tmbundle
[submodule "vendor/grammars/Sublime-QML"]
path = vendor/grammars/Sublime-QML
url = https://github.com/skozlovf/Sublime-QML
[submodule "vendor/grammars/Slash.tmbundle"]
path = vendor/grammars/Slash.tmbundle
url = https://github.com/slash-lang/Slash.tmbundle
[submodule "vendor/grammars/factor"]
path = vendor/grammars/factor
url = https://github.com/slavapestov/factor
[submodule "vendor/grammars/ruby-slim.tmbundle"]
path = vendor/grammars/ruby-slim.tmbundle
url = https://github.com/slim-template/ruby-slim.tmbundle
[submodule "vendor/grammars/SublimeXtend"]
path = vendor/grammars/SublimeXtend
url = https://github.com/staltz/SublimeXtend
[submodule "vendor/grammars/Stata.tmbundle"]
path = vendor/grammars/Stata.tmbundle
url = https://github.com/statatmbundle/Stata.tmbundle
[submodule "vendor/grammars/Vala-TMBundle"]
path = vendor/grammars/Vala-TMBundle
url = https://github.com/technosophos/Vala-TMBundle
[submodule "vendor/grammars/ant.tmbundle"]
path = vendor/grammars/ant.tmbundle
url = https://github.com/textmate/ant.tmbundle
[submodule "vendor/grammars/antlr.tmbundle"]
path = vendor/grammars/antlr.tmbundle
url = https://github.com/textmate/antlr.tmbundle
[submodule "vendor/grammars/apache.tmbundle"]
path = vendor/grammars/apache.tmbundle
url = https://github.com/textmate/apache.tmbundle
[submodule "vendor/grammars/applescript.tmbundle"]
path = vendor/grammars/applescript.tmbundle
url = https://github.com/textmate/applescript.tmbundle
[submodule "vendor/grammars/asp.tmbundle"]
path = vendor/grammars/asp.tmbundle
url = https://github.com/textmate/asp.tmbundle
[submodule "vendor/grammars/bison.tmbundle"]
path = vendor/grammars/bison.tmbundle
url = https://github.com/textmate/bison.tmbundle
[submodule "vendor/grammars/capnproto.tmbundle"]
path = vendor/grammars/capnproto.tmbundle
url = https://github.com/textmate/capnproto.tmbundle
[submodule "vendor/grammars/cmake.tmbundle"]
path = vendor/grammars/cmake.tmbundle
url = https://github.com/textmate/cmake.tmbundle
[submodule "vendor/grammars/cpp-qt.tmbundle"]
path = vendor/grammars/cpp-qt.tmbundle
url = https://github.com/textmate/cpp-qt.tmbundle
[submodule "vendor/grammars/css.tmbundle"]
path = vendor/grammars/css.tmbundle
url = https://github.com/textmate/css.tmbundle
[submodule "vendor/grammars/d.tmbundle"]
path = vendor/grammars/d.tmbundle
url = https://github.com/textmate/d.tmbundle
[submodule "vendor/grammars/diff.tmbundle"]
path = vendor/grammars/diff.tmbundle
url = https://github.com/textmate/diff.tmbundle
[submodule "vendor/grammars/dylan.tmbundle"]
path = vendor/grammars/dylan.tmbundle
url = https://github.com/textmate/dylan.tmbundle
[submodule "vendor/grammars/eiffel.tmbundle"]
path = vendor/grammars/eiffel.tmbundle
url = https://github.com/textmate/eiffel.tmbundle
[submodule "vendor/grammars/erlang.tmbundle"]
path = vendor/grammars/erlang.tmbundle
url = https://github.com/textmate/erlang.tmbundle
[submodule "vendor/grammars/fortran.tmbundle"]
path = vendor/grammars/fortran.tmbundle
url = https://github.com/textmate/fortran.tmbundle
[submodule "vendor/grammars/gettext.tmbundle"]
path = vendor/grammars/gettext.tmbundle
url = https://github.com/textmate/gettext.tmbundle
[submodule "vendor/grammars/graphviz.tmbundle"]
path = vendor/grammars/graphviz.tmbundle
url = https://github.com/textmate/graphviz.tmbundle
[submodule "vendor/grammars/groovy.tmbundle"]
path = vendor/grammars/groovy.tmbundle
url = https://github.com/textmate/groovy.tmbundle
[submodule "vendor/grammars/haskell.tmbundle"]
path = vendor/grammars/haskell.tmbundle
url = https://github.com/textmate/haskell.tmbundle
[submodule "vendor/grammars/html.tmbundle"]
path = vendor/grammars/html.tmbundle
url = https://github.com/textmate/html.tmbundle
[submodule "vendor/grammars/ini.tmbundle"]
path = vendor/grammars/ini.tmbundle
url = https://github.com/textmate/ini.tmbundle
[submodule "vendor/grammars/io.tmbundle"]
path = vendor/grammars/io.tmbundle
url = https://github.com/textmate/io.tmbundle
[submodule "vendor/grammars/java.tmbundle"]
path = vendor/grammars/java.tmbundle
url = https://github.com/textmate/java.tmbundle
[submodule "vendor/grammars/javadoc.tmbundle"]
path = vendor/grammars/javadoc.tmbundle
url = https://github.com/textmate/javadoc.tmbundle
[submodule "vendor/grammars/javascript-objective-j.tmbundle"]
path = vendor/grammars/javascript-objective-j.tmbundle
url = https://github.com/textmate/javascript-objective-j.tmbundle
[submodule "vendor/grammars/json.tmbundle"]
path = vendor/grammars/json.tmbundle
url = https://github.com/textmate/json.tmbundle
[submodule "vendor/grammars/latex.tmbundle"]
path = vendor/grammars/latex.tmbundle
url = https://github.com/textmate/latex.tmbundle
[submodule "vendor/grammars/less.tmbundle"]
path = vendor/grammars/less.tmbundle
url = https://github.com/textmate/less.tmbundle
[submodule "vendor/grammars/lilypond.tmbundle"]
path = vendor/grammars/lilypond.tmbundle
url = https://github.com/textmate/lilypond.tmbundle
[submodule "vendor/grammars/lisp.tmbundle"]
path = vendor/grammars/lisp.tmbundle
url = https://github.com/textmate/lisp.tmbundle
[submodule "vendor/grammars/logtalk.tmbundle"]
path = vendor/grammars/logtalk.tmbundle
url = https://github.com/textmate/logtalk.tmbundle
[submodule "vendor/grammars/lua.tmbundle"]
path = vendor/grammars/lua.tmbundle
url = https://github.com/textmate/lua.tmbundle
[submodule "vendor/grammars/make.tmbundle"]
path = vendor/grammars/make.tmbundle
url = https://github.com/textmate/make.tmbundle
[submodule "vendor/grammars/matlab.tmbundle"]
path = vendor/grammars/matlab.tmbundle
url = https://github.com/textmate/matlab.tmbundle
[submodule "vendor/grammars/maven.tmbundle"]
path = vendor/grammars/maven.tmbundle
url = https://github.com/textmate/maven.tmbundle
[submodule "vendor/grammars/nemerle.tmbundle"]
path = vendor/grammars/nemerle.tmbundle
url = https://github.com/textmate/nemerle.tmbundle
[submodule "vendor/grammars/ninja.tmbundle"]
path = vendor/grammars/ninja.tmbundle
url = https://github.com/textmate/ninja.tmbundle
[submodule "vendor/grammars/objective-c.tmbundle"]
path = vendor/grammars/objective-c.tmbundle
url = https://github.com/textmate/objective-c.tmbundle
[submodule "vendor/grammars/ocaml.tmbundle"]
path = vendor/grammars/ocaml.tmbundle
url = https://github.com/textmate/ocaml.tmbundle
[submodule "vendor/grammars/pascal.tmbundle"]
path = vendor/grammars/pascal.tmbundle
url = https://github.com/textmate/pascal.tmbundle
[submodule "vendor/grammars/perl.tmbundle"]
path = vendor/grammars/perl.tmbundle
url = https://github.com/textmate/perl.tmbundle
[submodule "vendor/grammars/php-smarty.tmbundle"]
path = vendor/grammars/php-smarty.tmbundle
url = https://github.com/textmate/php-smarty.tmbundle
[submodule "vendor/grammars/php.tmbundle"]
path = vendor/grammars/php.tmbundle
url = https://github.com/textmate/php.tmbundle
[submodule "vendor/grammars/postscript.tmbundle"]
path = vendor/grammars/postscript.tmbundle
url = https://github.com/textmate/postscript.tmbundle
[submodule "vendor/grammars/processing.tmbundle"]
path = vendor/grammars/processing.tmbundle
url = https://github.com/textmate/processing.tmbundle
[submodule "vendor/grammars/prolog.tmbundle"]
path = vendor/grammars/prolog.tmbundle
url = https://github.com/textmate/prolog.tmbundle
[submodule "vendor/grammars/python-django.tmbundle"]
path = vendor/grammars/python-django.tmbundle
url = https://github.com/textmate/python-django.tmbundle
[submodule "vendor/grammars/r.tmbundle"]
path = vendor/grammars/r.tmbundle
url = https://github.com/textmate/r.tmbundle
[submodule "vendor/grammars/restructuredtext.tmbundle"]
path = vendor/grammars/restructuredtext.tmbundle
url = https://github.com/textmate/restructuredtext.tmbundle
[submodule "vendor/grammars/ruby-haml.tmbundle"]
path = vendor/grammars/ruby-haml.tmbundle
url = https://github.com/textmate/ruby-haml.tmbundle
[submodule "vendor/grammars/ruby-on-rails-tmbundle"]
path = vendor/grammars/ruby-on-rails-tmbundle
url = https://github.com/textmate/ruby-on-rails-tmbundle
[submodule "vendor/grammars/scheme.tmbundle"]
path = vendor/grammars/scheme.tmbundle
url = https://github.com/textmate/scheme.tmbundle
[submodule "vendor/grammars/scilab.tmbundle"]
path = vendor/grammars/scilab.tmbundle
url = https://github.com/textmate/scilab.tmbundle
[submodule "vendor/grammars/sql.tmbundle"]
path = vendor/grammars/sql.tmbundle
url = https://github.com/textmate/sql.tmbundle
[submodule "vendor/grammars/standard-ml.tmbundle"]
path = vendor/grammars/standard-ml.tmbundle
url = https://github.com/textmate/standard-ml.tmbundle
[submodule "vendor/grammars/swift.tmbundle"]
path = vendor/grammars/swift.tmbundle
url = https://github.com/textmate/swift.tmbundle
[submodule "vendor/grammars/tcl.tmbundle"]
path = vendor/grammars/tcl.tmbundle
url = https://github.com/textmate/tcl.tmbundle
[submodule "vendor/grammars/text.tmbundle"]
path = vendor/grammars/text.tmbundle
url = https://github.com/textmate/text.tmbundle
[submodule "vendor/grammars/textile.tmbundle"]
path = vendor/grammars/textile.tmbundle
url = https://github.com/textmate/textile.tmbundle
[submodule "vendor/grammars/textmate.tmbundle"]
path = vendor/grammars/textmate.tmbundle
url = https://github.com/textmate/textmate.tmbundle
[submodule "vendor/grammars/thrift.tmbundle"]
path = vendor/grammars/thrift.tmbundle
url = https://github.com/textmate/thrift.tmbundle
[submodule "vendor/grammars/toml.tmbundle"]
path = vendor/grammars/toml.tmbundle
url = https://github.com/textmate/toml.tmbundle
[submodule "vendor/grammars/verilog.tmbundle"]
path = vendor/grammars/verilog.tmbundle
url = https://github.com/textmate/verilog.tmbundle
[submodule "vendor/grammars/xml.tmbundle"]
path = vendor/grammars/xml.tmbundle
url = https://github.com/textmate/xml.tmbundle
[submodule "vendor/grammars/smalltalk-tmbundle"]
path = vendor/grammars/smalltalk-tmbundle
url = https://github.com/tomas-stefano/smalltalk-tmbundle
[submodule "vendor/grammars/ioke-outdated"]
path = vendor/grammars/ioke-outdated
url = https://github.com/vic/ioke-outdated
[submodule "vendor/grammars/kotlin-sublime-package"]
path = vendor/grammars/kotlin-sublime-package
url = https://github.com/vkostyukov/kotlin-sublime-package
[submodule "vendor/grammars/c.tmbundle"]
path = vendor/grammars/c.tmbundle
url = https://github.com/textmate/c.tmbundle
[submodule "vendor/grammars/zephir-sublime"]
path = vendor/grammars/zephir-sublime
url = https://github.com/vmg/zephir-sublime
[submodule "vendor/grammars/llvm.tmbundle"]
path = vendor/grammars/llvm.tmbundle
url = https://github.com/whitequark/llvm.tmbundle
[submodule "vendor/grammars/sublime-nix"]
path = vendor/grammars/sublime-nix
url = https://github.com/wmertens/sublime-nix
[submodule "vendor/grammars/ada.tmbundle"]
path = vendor/grammars/ada.tmbundle
url = https://github.com/aroben/ada.tmbundle
branch = better-with-highlighting
[submodule "vendor/grammars/oz-tmbundle"]
path = vendor/grammars/oz-tmbundle
url = https://github.com/eregon/oz-tmbundle
[submodule "vendor/grammars/ebundles"]
path = vendor/grammars/ebundles
url = https://github.com/ericzou/ebundles
[submodule "vendor/grammars/sublime-mask"]
path = vendor/grammars/sublime-mask
url = https://github.com/tenbits/sublime-mask
[submodule "vendor/grammars/sublime_cobol"]
path = vendor/grammars/sublime_cobol
url = https://bitbucket.org/bitlang/sublime_cobol
[submodule "vendor/grammars/ruby.tmbundle"]
path = vendor/grammars/ruby.tmbundle
url = https://github.com/aroben/ruby.tmbundle
branch = pl
[submodule "vendor/grammars/IDL-Syntax"]
path = vendor/grammars/IDL-Syntax
url = https://github.com/andik/IDL-Syntax
[submodule "vendor/grammars/sas.tmbundle"]
path = vendor/grammars/sas.tmbundle
url = https://github.com/rpardee/sas.tmbundle
[submodule "vendor/grammars/atom-salt"]
path = vendor/grammars/atom-salt
url = https://github.com/saltstack/atom-salt
[submodule "vendor/grammars/Scalate.tmbundle"]
path = vendor/grammars/Scalate.tmbundle
url = https://github.com/scalate/Scalate.tmbundle
[submodule "vendor/grammars/Elm.tmLanguage"]
path = vendor/grammars/Elm.tmLanguage
url = https://github.com/deadfoxygrandpa/Elm.tmLanguage
[submodule "vendor/grammars/sublime-bsv"]
path = vendor/grammars/sublime-bsv
url = https://github.com/thotypous/sublime-bsv
[submodule "vendor/grammars/AutoHotkey"]
path = vendor/grammars/AutoHotkey
url = https://github.com/robertcollier4/AutoHotkey
[submodule "vendor/grammars/Sublime-HTTP"]
path = vendor/grammars/Sublime-HTTP
url = https://github.com/httpspec/sublime-highlighting
[submodule "vendor/grammars/sass-textmate-bundle"]
path = vendor/grammars/sass-textmate-bundle
url = https://github.com/nathos/sass-textmate-bundle
[submodule "vendor/grammars/carto-atom"]
path = vendor/grammars/carto-atom
url = https://github.com/yohanboniface/carto-atom
[submodule "vendor/grammars/Sublime-Nit"]
path = vendor/grammars/Sublime-Nit
url = https://github.com/R4PaSs/Sublime-Nit
[submodule "vendor/grammars/language-hy"]
path = vendor/grammars/language-hy
url = https://github.com/rwtolbert/language-hy
[submodule "vendor/grammars/Racket"]
path = vendor/grammars/Racket
url = https://github.com/soegaard/racket-highlight-for-github
[submodule "vendor/grammars/turtle.tmbundle"]
path = vendor/grammars/turtle.tmbundle
url = https://github.com/peta/turtle.tmbundle

View File

@@ -1,9 +1,5 @@
before_install:
- git fetch origin master:master
- git fetch origin v2.0.0:v2.0.0
- git fetch origin test/attributes:test/attributes
- git fetch origin test/master:test/master
- sudo apt-get install libicu-dev -y
sudo: false
before_install: script/travis/before_install
rvm:
- 1.9.3
- 2.0.0
@@ -11,3 +7,6 @@ rvm:
- 2.2
notifications:
disabled: true
git:
submodules: false
cache: bundler

View File

@@ -21,9 +21,19 @@ Once the bug has been fixed upstream, please let us know and we'll pick it up fo
Great! You'll need to:
0. Add an entry for your language to [`languages.yml`][languages].
0. Add a grammar for your language to [`grammars.yml`][grammars] by running `script/download-grammars --add URL`. Please only add grammars that have a license that permits redistribution.
0. Add a grammar for your language. Please only add grammars that have a license that permits redistribution.
0. Add your grammar as a submodule: `git submodule add https://github.com/JaneSmith/MyGrammar vendor/grammars/MyGrammar`.
0. Add your grammar to [`grammars.yml`][grammars] by running `script/convert-grammars --add vendor/grammars/MyGrammar`.
0. Add samples for your language to the [samples directory][samples].
In addition, if your new language defines an extension that's already listed in [`languages.yml`][languages] (such as `.foo`) then sometimes a few more steps will need to be taken:
0. Make sure that example `.foo` files are present in the [samples directory][samples] for each language that uses `.foo`.
0. Test the performance of the Bayesian classifier with a relatively large number (1000s) of sample `.foo` files. (ping @arfon or @bkeepers to help with this) to ensure we're not misclassifying files.
0. If the Bayesian classifier does a bad job with the sample `.foo` files then a [heuristic](https://github.com/github/linguist/blob/master/lib/linguist/heuristics.rb) may need to be written to help.
Remember, the goal here is to try and avoid false positives!
We try only to add languages once they have some usage on GitHub, so please note in-the-wild usage examples in your pull request. In most cases we prefer that languages already be in use in hundreds of repositories before supporting them in Linguist.
[grammars]: /grammars.yml

View File

@@ -1,5 +1,4 @@
source 'https://rubygems.org'
gemspec :name => "github-linguist"
gemspec :name => "github-linguist-grammars"
gem 'test-unit', require: false if RUBY_VERSION >= '2.2'
gem 'byebug' if RUBY_VERSION >= '2.0'

View File

@@ -141,7 +141,7 @@ But for development you are going to want to checkout out the source. To get it,
git clone https://github.com/github/linguist.git
cd linguist/
bundle install
script/bootstrap
To run the tests:
@@ -181,7 +181,8 @@ Here's our current build status, which is hopefully green: [![Build Status](http
If you are the current maintainer of this gem:
0. Create a branch for the release: `git checkout -b cut-release-vxx.xx.xx`
0. Make sure your local dependencies are up to date: `bundle install`
0. Make sure your local dependencies are up to date: `script/bootstrap`
0. If grammar submodules have not been updated recently, update them: `git submodule update --remote && git commit -a`
0. Ensure that samples are updated: `bundle exec rake samples`
0. Ensure that tests are green: `bundle exec rake test`
0. Bump gem version in `lib/linguist/version.rb`. For example, [like this](https://github.com/github/linguist/commit/8d2ea90a5ba3b2fe6e1508b7155aa4632eea2985).

View File

@@ -48,7 +48,7 @@ end
task :build_grammars_gem do
rm_rf "grammars"
sh "script/download-grammars"
sh "script/convert-grammars"
sh "gem", "build", "github-linguist-grammars.gemspec"
end

View File

@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
s.add_dependency 'mime-types', '>= 1.19'
s.add_dependency 'rugged', '~> 0.22.0b4'
s.add_development_dependency 'minitest', '>= 5.0'
s.add_development_dependency 'mocha'
s.add_development_dependency 'pry'
s.add_development_dependency 'rake'

View File

@@ -18,413 +18,449 @@ http://svn.textmate.org/trunk/Review/Bundles/XQuery.tmbundle:
https://bitbucket.org/Clams/sublimesystemverilog/get/default.tar.gz:
- source.systemverilog
- source.ucfconstraints
https://bitbucket.org/bitlang/sublime_cobol/raw/b0e9c44ac5f7a2fb553421aa986b35854cbfda4a/COBOL.tmLanguage:
- source.cobol
https://fan.googlecode.com/hg-history/Build%201.0.55/adm/tools/textmate/Fan.tmbundle/Syntaxes/Fan.tmLanguage:
- source.fan
https://github.com/AlanQuatermain/go-tmbundle:
- source.go
https://github.com/Anomareh/PHP-Twig.tmbundle:
- text.html.twig
https://github.com/Cirru/sublime-cirru/raw/master/Cirru.tmLanguage:
- source.cirru
https://github.com/Cykey/Sublime-Logos:
- source.logos
https://github.com/Drako/SublimeBrainfuck/raw/master/Brainfuck.tmLanguage:
- source.bf
https://github.com/JohnNilsson/awk-sublime/raw/master/AWK.tmLanguage:
- source.awk
https://github.com/JonBons/Sublime-SQF-Language:
- source.sqf
https://github.com/MarioRicalde/SCSS.tmbundle:
- source.scss
https://github.com/Oldes/Sublime-REBOL:
- source.rebol
https://github.com/PogiNate/Sublime-Inform:
- source.Inform7
https://github.com/Red-Nova-Technologies/autoitv3-tmbundle:
- source.autoit.3
https://github.com/SalGnt/Sublime-VimL:
- source.viml
https://github.com/Shammah/boo-sublime/raw/master/Boo.tmLanguage:
- source.boo
https://github.com/SublimeText/ColdFusion:
vendor/grammars/Agda.tmbundle:
- source.agda
vendor/grammars/Alloy.tmbundle:
- source.alloy
vendor/grammars/AutoHotkey:
- source.ahk
vendor/grammars/ColdFusion:
- source.cfscript
- source.cfscript.cfc
- text.cfml.basic
- text.html.cfm
https://github.com/SublimeText/NSIS:
- source.nsis
https://github.com/Varriount/NimLime:
- source.nimrod
- source.nimrod_filter
- source.nimrodcfg
https://github.com/alkemist/gradle.tmbundle:
- source.groovy.gradle
https://github.com/ambethia/Sublime-Loom:
- source.loomscript
https://github.com/angryant0007/VBDotNetSyntax:
- source.vbnet
https://github.com/anunayk/cool-tmbundle:
- source.cool
https://github.com/aroben/ada.tmbundle/raw/c45eed4d5f98fe3bcbbffbb9e436601ab5bbde4b/Syntaxes/Ada.plist:
- source.ada
https://github.com/aroben/ruby.tmbundle@4636a3023153c3034eb6ffc613899ba9cf33b41f:
- source.ruby
- text.html.erb
https://github.com/asbjornenge/Docker.tmbundle:
vendor/grammars/Docker.tmbundle:
- source.dockerfile
https://github.com/atom/language-clojure:
- source.clojure
https://github.com/atom/language-coffee-script:
- source.coffee
- source.litcoffee
https://github.com/atom/language-csharp:
- source.cs
- source.csx
- source.nant-build
https://github.com/atom/language-gfm:
- text.html.markdown
https://github.com/atom/language-javascript:
- source.js
- source.js.regexp
https://github.com/atom/language-python:
- source.python
- source.regexp.python
- text.python.traceback
https://github.com/atom/language-sass:
- source.css.scss
- source.sass
https://github.com/atom/language-shellscript:
- source.shell
- text.shell-session
https://github.com/austinwagner/sublime-sourcepawn:
- source.sp
https://github.com/bfad/Sublime-Lasso:
- file.lasso
https://github.com/bholt/chapel-tmbundle:
- source.chapel
https://github.com/brandonwamboldt/sublime-nginx:
- source.nginx
https://github.com/bro/bro-sublime:
- source.bro
https://github.com/carsonoid/sublime_man_page_support/raw/master/man-groff.tmLanguage:
- text.groff
https://github.com/ccreutzig/sublime-MuPAD:
- source.mupad
https://github.com/cdwilson/nesC.tmbundle:
- source.nesc
https://github.com/christophevg/racket-tmbundle:
vendor/grammars/Elm.tmLanguage:
- source.elm
vendor/grammars/Handlebars:
- text.html.handlebars
vendor/grammars/IDL-Syntax:
- source.webidl
vendor/grammars/Isabelle.tmbundle:
- source.isabelle.root
- source.isabelle.theory
vendor/grammars/Julia.tmbundle:
- source.julia
vendor/grammars/LiveScript.tmbundle:
- source.livescript
vendor/grammars/NSIS:
- source.nsis
vendor/grammars/NimLime:
- source.nim
- source.nim_filter
- source.nimcfg
vendor/grammars/PHP-Twig.tmbundle:
- text.html.twig
vendor/grammars/RDoc.tmbundle:
- text.rdoc
vendor/grammars/Racket:
- source.racket
https://github.com/clemos/haxe-sublime-bundle:
vendor/grammars/SCSS.tmbundle:
- source.scss
vendor/grammars/Scalate.tmbundle:
- source.scaml
- text.html.ssp
vendor/grammars/Slash.tmbundle:
- text.html.slash
vendor/grammars/Stata.tmbundle:
- source.mata
- source.stata
vendor/grammars/Sublime-Coq:
- source.coq
vendor/grammars/Sublime-HTTP:
- source.httpspec
vendor/grammars/Sublime-Inform:
- source.Inform7
vendor/grammars/Sublime-Lasso:
- file.lasso
vendor/grammars/Sublime-Logos:
- source.logos
vendor/grammars/Sublime-Loom:
- source.loomscript
vendor/grammars/Sublime-Nit:
- source.nit
vendor/grammars/Sublime-QML:
- source.qml
vendor/grammars/Sublime-REBOL:
- source.rebol
vendor/grammars/Sublime-SQF-Language:
- source.sqf
vendor/grammars/Sublime-Text-2-OpenEdge-ABL:
- source.abl
vendor/grammars/Sublime-VimL:
- source.viml
vendor/grammars/SublimeBrainfuck:
- source.bf
vendor/grammars/SublimeXtend:
- source.xtend
vendor/grammars/Textmate-Gosu-Bundle:
- source.gosu.2
vendor/grammars/VBDotNetSyntax:
- source.vbnet
vendor/grammars/Vala-TMBundle:
- source.vala
vendor/grammars/abap.tmbundle:
- source.abap
vendor/grammars/actionscript3-tmbundle:
- source.actionscript.3
- text.html.asdoc
- text.xml.flex-config
vendor/grammars/ada.tmbundle:
- source.ada
vendor/grammars/ant.tmbundle:
- text.xml.ant
vendor/grammars/antlr.tmbundle:
- source.antlr
vendor/grammars/apache.tmbundle:
- source.apache-config
- source.apache-config.mod_perl
vendor/grammars/applescript.tmbundle:
- source.applescript
vendor/grammars/asp.tmbundle:
- source.asp
- text.html.asp
vendor/grammars/assembly.tmbundle:
- objdump.x86asm
- source.x86asm
vendor/grammars/atom-salt:
- source.python.salt
- source.yaml.salt
vendor/grammars/autoitv3-tmbundle:
- source.autoit.3
vendor/grammars/awk-sublime:
- source.awk
vendor/grammars/bison.tmbundle:
- source.bison
vendor/grammars/boo-sublime:
- source.boo
vendor/grammars/bro-sublime:
- source.bro
vendor/grammars/c.tmbundle:
- source.c
- source.c++
- source.c.platform
vendor/grammars/capnproto.tmbundle:
- source.capnp
vendor/grammars/carto-atom:
- source.css.mss
vendor/grammars/ceylon-sublimetext:
- module.ceylon
- source.ceylon
vendor/grammars/chapel-tmbundle:
- source.chapel
vendor/grammars/cmake.tmbundle:
- source.cache.cmake
- source.cmake
vendor/grammars/cool-tmbundle:
- source.cool
vendor/grammars/cpp-qt.tmbundle:
- source.c++.qt
- source.qmake
vendor/grammars/css.tmbundle:
- source.css
vendor/grammars/cucumber-tmbundle:
- source.ruby.rspec.cucumber.steps
- text.gherkin.feature
vendor/grammars/d.tmbundle:
- source.d
vendor/grammars/dart-sublime-bundle:
- source.dart
- source.pubspec
- text.dart-doccomments
vendor/grammars/diff.tmbundle:
- source.diff
vendor/grammars/dylan.tmbundle:
- source.dylan
- source.lid
- source.makegen
vendor/grammars/ebundles/Bundles/MSDOS batch file.tmbundle:
- source.dosbatch
vendor/grammars/eiffel.tmbundle:
- source.eiffel
vendor/grammars/elixir-tmbundle:
- source.elixir
- text.elixir
- text.html.elixir
vendor/grammars/erlang.tmbundle:
- source.erlang
- text.html.erlang.yaws
vendor/grammars/factor:
- source.factor
- text.html.factor
vendor/grammars/fancy-tmbundle:
- source.fancy
vendor/grammars/fish-tmbundle:
- source.fish
vendor/grammars/fortran.tmbundle:
- source.fortran
- source.fortran.modern
vendor/grammars/fsharpbinding:
- source.fsharp
vendor/grammars/gettext.tmbundle:
- source.po
vendor/grammars/gnuplot-tmbundle:
- source.gnuplot
vendor/grammars/go-tmbundle:
- source.go
vendor/grammars/gradle.tmbundle:
- source.groovy.gradle
vendor/grammars/graphviz.tmbundle:
- source.dot
vendor/grammars/groovy.tmbundle:
- source.groovy
vendor/grammars/haskell.tmbundle:
- source.haskell
- text.tex.latex.haskell
vendor/grammars/haxe-sublime-bundle:
- source.erazor
- source.haxe.2
- source.hss.1
- source.hxml
- source.nmml
https://github.com/cucumber/cucumber-tmbundle:
- source.ruby.rspec.cucumber.steps
- text.gherkin.feature
https://github.com/daaain/Handlebars/raw/master/Handlebars.tmLanguage:
- text.html.handlebars
https://github.com/davidpeckham/powershell.tmbundle:
- source.powershell
https://github.com/davidrios/jade-tmbundle:
- source.jade
- source.pyjade
https://github.com/elixir-lang/elixir-tmbundle:
- source.elixir
- text.elixir
- text.html.elixir
https://github.com/ericzou/ebundles/raw/master/Bundles/MSDOS%20batch%20file.tmbundle/Syntaxes/MSDOS%20batch%20file.tmLanguage:
- source.dosbatch
https://github.com/euler0/sublime-glsl/raw/master/GLSL.tmLanguage:
- source.glsl
https://github.com/fancy-lang/fancy-tmbundle:
- source.fancy
https://github.com/fsharp/fsharpbinding:
- source.fsharp
https://github.com/gingerbeardman/monkey.tmbundle:
- source.monkey
https://github.com/guillermooo/dart-sublime-bundle/raw/master/Dart.tmLanguage:
- source.dart
https://github.com/harrism/sublimetext-cuda-cpp/raw/master/cuda-c%2B%2B.tmLanguage:
- source.cuda-c++
https://github.com/hww3/pike-textmate:
- source.pike
https://github.com/jeancharles-roger/ceylon-sublimetext/raw/master/Ceylon.tmLanguage:
- source.ceylon
https://github.com/jfairbank/Sublime-Text-2-OpenEdge-ABL:
- source.abl
https://github.com/jhasse/sublime-rust:
- source.rust
https://github.com/johanasplund/sublime-befunge/raw/master/Befunge-93.tmLanguage:
- source.befunge
https://github.com/joshaven/RDoc.tmbundle:
- text.rdoc
https://github.com/jpcamara/Textmate-Gosu-Bundle/raw/master/Gosu.tmbundle/Syntaxes/Gosu.tmLanguage:
- source.gosu.2
https://github.com/kswedberg/jquery-tmbundle:
- source.js.jquery
https://github.com/laughedelic/sublime-idris/raw/master/Idris.tmLanguage:
- source.idris
https://github.com/lavrton/sublime-better-typescript:
- source.ts
https://github.com/leafo/moonscript-tmbundle:
- source.moonscript
https://github.com/lsf37/Isabelle.tmbundle:
- source.isabelle.root
- source.isabelle.theory
https://github.com/lunixbochs/x86-assembly-textmate-bundle:
- source.asm.x86
https://github.com/macekond/Alloy.tmbundle:
- source.alloy
https://github.com/mads379/opa.tmbundle:
- source.opa
https://github.com/mads379/scala.tmbundle:
- source.sbt
- source.scala
https://github.com/marconi/mako-tmbundle:
- text.html.mako
https://github.com/mattfoster/gnuplot-tmbundle:
- source.gnuplot
https://github.com/mgalloy/idl.tmbundle:
vendor/grammars/html.tmbundle:
- text.html.basic
vendor/grammars/idl.tmbundle:
- source.idl
- source.idl-dlm
- text.idl-idldoc
https://github.com/michaeledgar/protobuf-tmbundle:
- source.protobuf
https://github.com/mkolosick/Sublime-Coq/raw/master/Coq.tmLanguage:
- source.coq
https://github.com/mokus0/Agda.tmbundle:
- source.agda
https://github.com/nanoant/Julia.tmbundle:
- source.julia
https://github.com/nanoant/assembly.tmbundle/raw/master/Syntaxes/objdump%20C%2B%2B.tmLanguage:
- objdump.x86asm
https://github.com/nilium/ooc.tmbundle:
- source.ooc
https://github.com/paulmillr/LiveScript.tmbundle:
- source.livescript
https://github.com/pferruggiaro/sublime-tea:
- source.tea
https://github.com/puppet-textmate-bundle/puppet-textmate-bundle:
- source.puppet
https://github.com/pvl/abap.tmbundle:
- source.abap
https://github.com/scalate/Scalate.tmbundle:
- source.scaml
- text.html.ssp
https://github.com/shadanan/mathematica-tmbundle:
- source.mathematica
https://github.com/shellderp/sublime-robot-plugin:
- text.robot
https://github.com/simongregory/actionscript3-tmbundle:
- source.actionscript.3
- text.html.asdoc
- text.xml.flex-config
https://github.com/skozlovf/Sublime-QML:
- source.qml
https://github.com/slash-lang/Slash.tmbundle:
- text.html.slash
https://github.com/slavapestov/factor/raw/master/misc/Factor.tmbundle/Syntaxes/Factor.tmLanguage:
- source.factor
https://github.com/slim-template/ruby-slim.tmbundle:
- text.slim
https://github.com/staltz/SublimeXtend:
- source.xtend
https://github.com/statatmbundle/Stata.tmbundle:
- source.mata
- source.stata
https://github.com/technosophos/Vala-TMBundle:
- source.vala
https://github.com/textmate/ant.tmbundle:
- text.xml.ant
https://github.com/textmate/antlr.tmbundle:
- source.antlr
https://github.com/textmate/apache.tmbundle:
- source.apache-config
- source.apache-config.mod_perl
https://github.com/textmate/applescript.tmbundle:
- source.applescript
https://github.com/textmate/asp.tmbundle:
- source.asp
- text.html.asp
https://github.com/textmate/bison.tmbundle:
- source.bison
https://github.com/textmate/c.tmbundle:
- source.c
- source.c++
- source.c.platform
https://github.com/textmate/capnproto.tmbundle:
- source.capnp
https://github.com/textmate/cmake.tmbundle:
- source.cache.cmake
- source.cmake
https://github.com/textmate/cpp-qt.tmbundle:
- source.c++.qt
- source.qmake
https://github.com/textmate/css.tmbundle:
- source.css
https://github.com/textmate/d.tmbundle:
- source.d
https://github.com/textmate/diff.tmbundle:
- source.diff
https://github.com/textmate/dylan.tmbundle:
- source.dylan
- source.lid
- source.makegen
https://github.com/textmate/eiffel.tmbundle:
- source.eiffel
https://github.com/textmate/erlang.tmbundle:
- source.erlang
- text.html.erlang.yaws
https://github.com/textmate/fortran.tmbundle:
- source.fortran
- source.fortran.modern
https://github.com/textmate/gettext.tmbundle:
- source.po
https://github.com/textmate/graphviz.tmbundle:
- source.dot
https://github.com/textmate/groovy.tmbundle:
- source.groovy
https://github.com/textmate/haskell.tmbundle:
- source.haskell
- text.tex.latex.haskell
https://github.com/textmate/html.tmbundle:
- text.html.basic
https://github.com/textmate/ini.tmbundle:
vendor/grammars/ini.tmbundle:
- source.ini
https://github.com/textmate/io.tmbundle:
vendor/grammars/io.tmbundle:
- source.io
https://github.com/textmate/java.tmbundle:
vendor/grammars/ioke-outdated:
- source.ioke
vendor/grammars/jade-tmbundle:
- source.jade
- source.pyjade
vendor/grammars/jasmin-sublime:
- source.jasmin
vendor/grammars/java.tmbundle:
- source.java
- source.java-properties
- text.html.jsp
- text.junit-test-report
https://github.com/textmate/javadoc.tmbundle:
vendor/grammars/javadoc.tmbundle:
- text.html.javadoc
https://github.com/textmate/javascript-objective-j.tmbundle:
vendor/grammars/javascript-objective-j.tmbundle:
- source.js.objj
https://github.com/textmate/json.tmbundle:
vendor/grammars/jquery-tmbundle:
- source.js.jquery
vendor/grammars/json.tmbundle:
- source.json
https://github.com/textmate/latex.tmbundle:
vendor/grammars/kotlin-sublime-package:
- source.Kotlin
vendor/grammars/language-clojure:
- source.clojure
vendor/grammars/language-coffee-script:
- source.coffee
- source.litcoffee
vendor/grammars/language-csharp:
- source.cs
- source.csx
- source.nant-build
vendor/grammars/language-gfm:
- source.gfm
vendor/grammars/language-hy:
- source.hy
vendor/grammars/language-javascript:
- source.js
- source.js.regexp
vendor/grammars/language-python:
- source.python
- source.regexp.python
- text.python.console
- text.python.traceback
vendor/grammars/language-shellscript:
- source.shell
- text.shell-session
vendor/grammars/language-yaml:
- source.yaml
vendor/grammars/latex.tmbundle:
- text.bibtex
- text.log.latex
- text.tex
- text.tex.latex
- text.tex.latex.beamer
- text.tex.latex.memoir
https://github.com/textmate/less.tmbundle:
vendor/grammars/less.tmbundle:
- source.css.less
https://github.com/textmate/lilypond.tmbundle:
vendor/grammars/lilypond.tmbundle:
- source.lilypond
https://github.com/textmate/lisp.tmbundle:
vendor/grammars/lisp.tmbundle:
- source.lisp
https://github.com/textmate/logtalk.tmbundle:
vendor/grammars/llvm.tmbundle:
- source.llvm
vendor/grammars/logtalk.tmbundle:
- source.logtalk
https://github.com/textmate/lua.tmbundle:
vendor/grammars/lua.tmbundle:
- source.lua
https://github.com/textmate/make.tmbundle:
vendor/grammars/make.tmbundle:
- source.makefile
https://github.com/textmate/matlab.tmbundle:
vendor/grammars/mako-tmbundle:
- text.html.mako
vendor/grammars/mathematica-tmbundle:
- source.mathematica
vendor/grammars/matlab.tmbundle:
- source.matlab
- source.octave
https://github.com/textmate/maven.tmbundle:
vendor/grammars/maven.tmbundle:
- text.xml.pom
https://github.com/textmate/nemerle.tmbundle:
vendor/grammars/mercury-tmlanguage:
- source.mercury
vendor/grammars/monkey.tmbundle:
- source.monkey
vendor/grammars/moonscript-tmbundle:
- source.moonscript
vendor/grammars/nemerle.tmbundle:
- source.nemerle
https://github.com/textmate/ninja.tmbundle:
vendor/grammars/nesC.tmbundle:
- source.nesc
vendor/grammars/ninja.tmbundle:
- source.ninja
https://github.com/textmate/objective-c.tmbundle:
vendor/grammars/objective-c.tmbundle:
- source.objc
- source.objc++
- source.objc.platform
- source.strings
https://github.com/textmate/ocaml.tmbundle:
vendor/grammars/ocaml.tmbundle:
- source.camlp4.ocaml
- source.ocaml
- source.ocamllex
- source.ocamlyacc
https://github.com/textmate/pascal.tmbundle:
vendor/grammars/ooc.tmbundle:
- source.ooc
vendor/grammars/opa.tmbundle:
- source.opa
vendor/grammars/oz-tmbundle/Syntaxes/Oz.tmLanguage:
- source.oz
vendor/grammars/pascal.tmbundle:
- source.pascal
https://github.com/textmate/perl.tmbundle:
vendor/grammars/perl.tmbundle:
- source.perl
https://github.com/textmate/php-smarty.tmbundle:
vendor/grammars/php-smarty.tmbundle:
- source.smarty
https://github.com/textmate/php.tmbundle:
vendor/grammars/php.tmbundle:
- text.html.php
https://github.com/textmate/postscript.tmbundle:
vendor/grammars/pike-textmate:
- source.pike
vendor/grammars/postscript.tmbundle:
- source.postscript
https://github.com/textmate/processing.tmbundle:
vendor/grammars/powershell.tmbundle:
- source.powershell
vendor/grammars/processing.tmbundle:
- source.processing
https://github.com/textmate/prolog.tmbundle:
vendor/grammars/prolog.tmbundle:
- source.prolog
https://github.com/textmate/python-django.tmbundle:
vendor/grammars/protobuf-tmbundle:
- source.protobuf
vendor/grammars/puppet-textmate-bundle:
- source.puppet
vendor/grammars/python-django.tmbundle:
- source.python.django
- text.html.django
https://github.com/textmate/r.tmbundle:
vendor/grammars/r.tmbundle:
- source.r
- text.tex.latex.rd
https://github.com/textmate/restructuredtext.tmbundle:
vendor/grammars/restructuredtext.tmbundle:
- text.restructuredtext
https://github.com/textmate/ruby-haml.tmbundle:
vendor/grammars/ruby-haml.tmbundle:
- text.haml
https://github.com/textmate/ruby-on-rails-tmbundle:
vendor/grammars/ruby-on-rails-tmbundle:
- source.js.erb.rails
- source.ruby.rails
- source.ruby.rails.rjs
- source.sql.ruby
- text.html.erb.rails
https://github.com/textmate/scheme.tmbundle:
vendor/grammars/ruby-slim.tmbundle:
- text.slim
vendor/grammars/ruby.tmbundle:
- source.ruby
- text.html.erb
vendor/grammars/sas.tmbundle:
- source.SASLog
- source.sas
vendor/grammars/sass-textmate-bundle:
- source.sass
vendor/grammars/scala.tmbundle:
- source.sbt
- source.scala
vendor/grammars/scheme.tmbundle:
- source.scheme
https://github.com/textmate/scilab.tmbundle:
vendor/grammars/scilab.tmbundle:
- source.scilab
https://github.com/textmate/sql.tmbundle:
vendor/grammars/smalltalk-tmbundle:
- source.smalltalk
vendor/grammars/sql.tmbundle:
- source.sql
https://github.com/textmate/standard-ml.tmbundle:
vendor/grammars/standard-ml.tmbundle:
- source.cm
- source.ml
https://github.com/textmate/swift.tmbundle:
vendor/grammars/sublime-MuPAD:
- source.mupad
vendor/grammars/sublime-befunge:
- source.befunge
vendor/grammars/sublime-better-typescript:
- source.ts
vendor/grammars/sublime-bsv:
- source.bsv
vendor/grammars/sublime-cirru:
- source.cirru
vendor/grammars/sublime-glsl:
- source.essl
- source.glsl
vendor/grammars/sublime-idris:
- source.idris
vendor/grammars/sublime-mask:
- source.mask
vendor/grammars/sublime-nginx:
- source.nginx
vendor/grammars/sublime-nix:
- source.nix
vendor/grammars/sublime-robot-plugin:
- text.robot
vendor/grammars/sublime-rust:
- source.rust
vendor/grammars/sublime-sourcepawn:
- source.sp
vendor/grammars/sublime-tea:
- source.tea
vendor/grammars/sublime_cobol:
- source.acucobol
- source.cobol
- source.opencobol
vendor/grammars/sublime_man_page_support:
- source.man
- text.groff
vendor/grammars/sublimetext-cuda-cpp:
- source.cuda-c++
vendor/grammars/swift.tmbundle:
- source.swift
https://github.com/textmate/tcl.tmbundle:
vendor/grammars/tcl.tmbundle:
- source.tcl
- text.html.tcl
https://github.com/textmate/text.tmbundle:
vendor/grammars/text.tmbundle:
- text.plain
https://github.com/textmate/textile.tmbundle:
vendor/grammars/textile.tmbundle:
- text.html.textile
https://github.com/textmate/textmate.tmbundle:
vendor/grammars/textmate.tmbundle:
- source.regexp.oniguruma
- source.tm-properties
https://github.com/textmate/thrift.tmbundle:
vendor/grammars/thrift.tmbundle:
- source.thrift
https://github.com/textmate/toml.tmbundle:
vendor/grammars/toml.tmbundle:
- source.toml
https://github.com/textmate/verilog.tmbundle:
vendor/grammars/turtle.tmbundle:
- source.sparql
- source.turtle
vendor/grammars/verilog.tmbundle:
- source.verilog
https://github.com/textmate/xml.tmbundle:
vendor/grammars/x86-assembly-textmate-bundle:
- source.asm.x86
vendor/grammars/xml.tmbundle:
- text.xml
- text.xml.xsl
https://github.com/textmate/yaml.tmbundle:
- source.yaml
https://github.com/tomas-stefano/smalltalk-tmbundle:
- source.smalltalk
https://github.com/vic/ioke-outdated/raw/master/share/TextMate/Ioke.tmbundle/Syntaxes/Ioke.tmLanguage:
- source.ioke
https://github.com/vkostyukov/kotlin-sublime-package:
- source.Kotlin
https://github.com/vmg/zephir-sublime:
vendor/grammars/zephir-sublime:
- source.php.zephir
https://github.com/whitequark/llvm.tmbundle:
- source.llvm
https://github.com/wmertens/sublime-nix:
- source.nix
https://raw.githubusercontent.com/eregon/oz-tmbundle/master/Syntaxes/Oz.tmLanguage:
- source.oz
https://raw.githubusercontent.com/tenbits/sublime-mask/release/Syntaxes/mask.tmLanguage:
- source.mask
https://github.com/l15n/fish-tmbundle:
- source.fish
https://raw.githubusercontent.com/andik/IDL-Syntax/master/IDL.tmLanguage:
- source.webidl

View File

@@ -51,20 +51,20 @@ module Linguist
#
# Return true or false
def generated?
minified_files? ||
compiled_coffeescript? ||
xcode_file? ||
generated_parser? ||
generated_net_docfile? ||
generated_net_designer_file? ||
generated_postscript? ||
generated_protocol_buffer? ||
generated_jni_header? ||
composer_lock? ||
node_modules? ||
godeps? ||
vcr_cassette? ||
generated_by_zephir?
generated_by_zephir? ||
minified_files? ||
compiled_coffeescript? ||
generated_parser? ||
generated_net_docfile? ||
generated_postscript? ||
generated_protocol_buffer? ||
generated_jni_header? ||
vcr_cassette?
end
# Internal: Is the blob an Xcode file?

View File

@@ -69,11 +69,19 @@ module Linguist
end
end
disambiguate "C#", "Smalltalk" do |data|
if /![\w\s]+methodsFor: /.match(data)
Language["Smalltalk"]
elsif /^\s*namespace\s*[\w\.]+\s*{/.match(data) || /^\s*\/\//.match(data)
Language["C#"]
end
end
disambiguate "Objective-C", "C++", "C" do |data|
if (/@(interface|class|protocol|property|end|synchronised|selector|implementation)\b/.match(data))
if (/^[ \t]*@(interface|class|protocol|property|end|synchronised|selector|implementation)\b/.match(data))
Language["Objective-C"]
elsif (/^\s*#\s*include <(cstdint|string|vector|map|list|array|bitset|queue|stack|forward_list|unordered_map|unordered_set|(i|o|io)stream)>/.match(data) ||
/^\s*template\s*</.match(data) || /^[^@]class\s+\w+/.match(data) || /^[^@](private|public|protected):$/.match(data) || /std::.+$/.match(data))
/^\s*template\s*</.match(data) || /^[ \t]*try/.match(data) || /^[ \t]*catch\s*\(/.match(data) || /^[ \t]*(class|(using[ \t]+)?namespace)\s+\w+/.match(data) || /^[ \t]*(private|public|protected):$/.match(data) || /std::\w+/.match(data))
Language["C++"]
end
end
@@ -104,6 +112,15 @@ module Linguist
end
end
disambiguate "GAP", "Scilab" do |data|
if (data.include?("gap> "))
Language["GAP"]
# Heads up - we don't usually write heuristics like this (with no regex match)
else
Language["Scilab"]
end
end
disambiguate "Common Lisp", "OpenCL", "Cool" do |data|
if data.include?("(defun ")
Language["Common Lisp"]
@@ -183,7 +200,7 @@ module Linguist
disambiguate "Frege", "Forth", "Text" do |data|
if /^(: |also |new-device|previous )/.match(data)
Language["Forth"]
elsif /\s*(import|module|package|data|type) /.match(data)
elsif /^\s*(import|module|package|data|type) /.match(data)
Language["Frege"]
else
Language["Text"]

View File

@@ -548,7 +548,7 @@ module Linguist
if extnames = extensions[name]
extnames.each do |extname|
if !options['extensions'].include?(extname)
if !options['extensions'].index { |x| x.end_with? extname }
warn "#{name} has a sample with extension (#{extname}) that isn't explicitly defined in languages.yml" unless extname == '.script!'
options['extensions'] << extname
end

View File

@@ -224,7 +224,7 @@ AutoHotkey:
extensions:
- .ahk
- .ahkl
tm_scope: none
tm_scope: source.ahk
ace_mode: autohotkey
AutoIt:
@@ -314,7 +314,7 @@ Bluespec:
type: programming
extensions:
- .bsv
tm_scope: source.verilog
tm_scope: source.bsv
ace_mode: verilog
Boo:
@@ -419,7 +419,7 @@ CLIPS:
CMake:
extensions:
- .cmake
- .in
- .cmake.in
filenames:
- CMakeLists.txt
ace_mode: text
@@ -449,6 +449,15 @@ Cap'n Proto:
- .capnp
ace_mode: text
CartoCSS:
type: programming
aliases:
- Carto
extensions:
- .mss
ace_mode: text
tm_scope: source.css.mss
Ceylon:
type: programming
extensions:
@@ -495,10 +504,10 @@ Clojure:
- .cl2
- .cljc
- .cljs
- .cljs.hl
- .cljscm
- .cljx
- .hic
- .hl
filenames:
- riemann.config
@@ -787,9 +796,10 @@ Elixir:
Elm:
type: programming
color: "#60B5CC"
extensions:
- .elm
tm_scope: source.haskell
tm_scope: source.elm
ace_mode: elm
Emacs Lisp:
@@ -941,11 +951,13 @@ GAMS:
GAP:
type: programming
lexer: GAP
extensions:
- .g
- .gap
- .gd
- .gi
- .tst
tm_scope: none
ace_mode: text
@@ -990,8 +1002,8 @@ Game Maker Language:
color: "#8ad353"
extensions:
- .gml
tm_scope: source.js
ace_mode: javascript
tm_scope: source.c++
ace_mode: c_cpp
Genshi:
extensions:
@@ -1162,6 +1174,7 @@ HTML:
extensions:
- .html
- .htm
- .html.hl
- .st
- .xht
- .xhtml
@@ -1187,7 +1200,7 @@ HTML+ERB:
- erb
extensions:
- .erb
- .deface
- .erb.deface
ace_mode: html_ruby
HTML+PHP:
@@ -1202,7 +1215,7 @@ HTTP:
type: data
extensions:
- .http
tm_scope: none
tm_scope: source.httpspec
ace_mode: text
Hack:
@@ -1211,14 +1224,14 @@ Hack:
extensions:
- .hh
- .php
tm_scope: none
tm_scope: text.html.php
Haml:
group: HTML
type: markup
extensions:
- .haml
- .deface
- .haml.deface
ace_mode: haml
Handlebars:
@@ -1258,13 +1271,13 @@ Haxe:
Hy:
type: programming
ace_mode: clojure
ace_mode: text
color: "#7891b1"
extensions:
- .hy
aliases:
- hylang
tm_scope: none
tm_scope: source.hy
IDL:
type: programming
@@ -1372,13 +1385,6 @@ JSON:
extensions:
- .json
- .lock
- .sublime-keymap
- .sublime-mousemap
- .sublime-project
- .sublime-settings
- .sublime-workspace
- .sublime_metrics
- .sublime_session
filenames:
- .jshintrc
- composer.lock
@@ -1413,6 +1419,13 @@ Jade:
tm_scope: source.jade
ace_mode: jade
Jasmin:
type: programming
ace_mode: java
extensions:
- .j
tm_scope: source.jasmin
Java:
type: programming
ace_mode: java
@@ -1455,6 +1468,19 @@ JavaScript:
- .pac
- .sjs
- .ssjs
- .sublime-build
- .sublime-commands
- .sublime-completions
- .sublime-keymap
- .sublime-macro
- .sublime-menu
- .sublime-mousemap
- .sublime-project
- .sublime-settings
- .sublime-theme
- .sublime-workspace
- .sublime_metrics
- .sublime_session
- .xsjs
- .xsjslib
filenames:
@@ -1718,7 +1744,7 @@ Markdown:
- .mkdn
- .mkdown
- .ron
tm_scope: text.html.markdown
tm_scope: source.gfm
Mask:
type: markup
@@ -1789,7 +1815,7 @@ Mercury:
extensions:
- .m
- .moo
tm_scope: source.prolog
tm_scope: source.mercury
ace_mode: prolog
MiniD: # Legacy
@@ -1888,6 +1914,7 @@ Nimrod:
- .nim
- .nimrod
ace_mode: text
tm_scope: source.nim
Ninja:
type: data
@@ -1901,7 +1928,7 @@ Nit:
color: "#0d8921"
extensions:
- .nit
tm_scope: none
tm_scope: source.nit
ace_mode: text
Nix:
@@ -2043,7 +2070,7 @@ OpenSCAD:
extensions:
- .scad
tm_scope: none
ace_mode: text
ace_mode: scad
Org:
type: prose
@@ -2200,6 +2227,8 @@ Perl6:
- .pm
- .pm6
- .t
filenames:
- Rexfile
interpreters:
- perl6
tm_scope: none
@@ -2219,6 +2248,8 @@ Pike:
extensions:
- .pike
- .pmod
interpreters:
- pike
ace_mode: text
Pod:
@@ -2319,6 +2350,15 @@ Pure Data:
tm_scope: none
ace_mode: text
PureBasic:
type: programming
color: "#5a6986"
extensions:
- .pb
- .pbi
tm_scope: none
ace_mode: text
PureScript:
type: programming
color: "#bcdc53"
@@ -2582,7 +2622,7 @@ SAS:
color: "#1E90FF"
extensions:
- .sas
tm_scope: none
tm_scope: source.sas
ace_mode: text
SCSS:
@@ -2593,6 +2633,14 @@ SCSS:
extensions:
- .scss
SPARQL:
type: data
tm_scope: source.sparql
ace_mode: text
extensions:
- .sparql
- .rq
SQF:
type: programming
color: "#FFCB1F"
@@ -2608,6 +2656,8 @@ SQL:
ace_mode: sql
extensions:
- .sql
- .cql
- .ddl
- .prc
- .tab
- .udf
@@ -2618,17 +2668,29 @@ STON:
group: Smalltalk
extensions:
- .ston
tm_scope: source.json
ace_mode: lisp
tm_scope: source.smalltalk
ace_mode: text
Sage:
type: programming
group: Python
extensions:
- .sage
- .sagews
tm_scope: source.python
ace_mode: python
SaltStack:
type: data
group: YAML
aliases:
- saltstate
- salt
extensions:
- .sls
tm_scope: source.yaml.salt
ace_mode: yaml
Sass:
type: markup
tm_scope: source.sass
@@ -2752,6 +2814,7 @@ Smalltalk:
color: "#596706"
extensions:
- .st
- .cs
aliases:
- squeak
ace_mode: text
@@ -2935,6 +2998,13 @@ Turing:
tm_scope: none
ace_mode: text
Turtle:
type: data
extensions:
- .ttl
tm_scope: source.turtle
ace_mode: text
Twig:
type: markup
group: PHP
@@ -3049,6 +3119,14 @@ Volt:
tm_scope: source.d
ace_mode: d
Web Ontology Language:
type: markup
color: "#3994bc"
extensions:
- .owl
tm_scope: text.xml
ace_mode: xml
WebIDL:
type: programming
extensions:
@@ -3082,8 +3160,10 @@ XML:
- .dita
- .ditamap
- .ditaval
- .dll.config
- .filters
- .fsproj
- .fxml
- .glade
- .grxml
- .ivy
@@ -3104,6 +3184,8 @@ XML:
- .rss
- .scxml
- .srdf
- .stTheme
- .sublime-snippet
- .svg
- .targets
- .tmCommand
@@ -3129,18 +3211,18 @@ XML:
- .xlf
- .xliff
- .xmi
- .xml.dist
- .xsd
- .xul
- .zcml
filenames:
- .classpath
- .project
- Settings.StyleCop
- Web.Debug.config
- Web.Release.config
- Web.config
- build.xml.dist
- packages.config
- phpunit.xml.dist
XProc:
type: programming

View File

@@ -40,24 +40,27 @@
# Minified JavaScript and CSS
- (\.|-)min\.(js|css)$
#Stylesheets imported from packages
- ([^\s]*)import\.(css|less|scss|styl)$
# Bootstrap css and js
- (^|/)bootstrap([^.]*)\.(js|css)$
- (^|/)bootstrap([^.]*)\.(js|css|less|scss|styl)$
- (^|/)custom\.bootstrap([^\s]*)(js|css|less|scss|styl)$
# Font Awesome
- font-awesome.css
- (^|/)font-awesome\.(css|less|scss|styl)$
# Foundation css
- foundation.css
- (^|/)foundation\.(css|less|scss|styl)$
# Normalize.css
- normalize.css
- (^|/)normalize\.(css|less|scss|styl)$
# Bourbon SCSS
- (^|/)[Bb]ourbon/.*\.css$
- (^|/)[Bb]ourbon/.*\.scss$
# Bourbon css
- (^|/)[Bb]ourbon/.*\.(css|less|scss|styl)$
# Animate.css
- animate.css
- (^|/)animate\.(css|less|scss|styl)$
# Vendored dependencies
- third[-_]?party/

View File

@@ -1,3 +1,3 @@
module Linguist
VERSION = "4.2.3"
VERSION = "4.2.7"
end

View File

@@ -0,0 +1,26 @@
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("Simple")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

View File

@@ -0,0 +1,20 @@
using System;
namespace MongoDB.Serialization.Descriptors
{
internal class BsonPropertyValue
{
public bool IsDictionary { get; private set; }
public Type Type { get; private set; }
public object Value { get; private set; }
public BsonPropertyValue(Type type, object value, bool isDictionary)
{
Type = type;
Value = value;
IsDictionary = isDictionary;
}
}
}

View File

@@ -0,0 +1,153 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Expressions;
namespace MongoDB.Linq.Expressions
{
internal class MongoExpressionVisitor : ExpressionVisitor
{
protected override Expression Visit(Expression exp)
{
if (exp == null)
return null;
switch ((MongoExpressionType)exp.NodeType)
{
case MongoExpressionType.Collection:
return VisitCollection((CollectionExpression)exp);
case MongoExpressionType.Field:
return VisitField((FieldExpression)exp);
case MongoExpressionType.Projection:
return VisitProjection((ProjectionExpression)exp);
case MongoExpressionType.Select:
return VisitSelect((SelectExpression)exp);
case MongoExpressionType.Aggregate:
return VisitAggregate((AggregateExpression)exp);
case MongoExpressionType.AggregateSubquery:
return VisitAggregateSubquery((AggregateSubqueryExpression)exp);
case MongoExpressionType.Scalar:
return VisitScalar((ScalarExpression)exp);
default:
return base.Visit(exp);
}
}
protected virtual Expression VisitAggregate(AggregateExpression aggregate)
{
var exp = Visit(aggregate.Argument);
if (exp != aggregate.Argument)
return new AggregateExpression(aggregate.Type, aggregate.AggregateType, exp, aggregate.Distinct);
return aggregate;
}
protected virtual Expression VisitAggregateSubquery(AggregateSubqueryExpression aggregateSubquery)
{
Expression e = Visit(aggregateSubquery.AggregateAsSubquery);
ScalarExpression subquery = (ScalarExpression)e;
if (subquery != aggregateSubquery.AggregateAsSubquery)
return new AggregateSubqueryExpression(aggregateSubquery.GroupByAlias, aggregateSubquery.AggregateInGroupSelect, subquery);
return aggregateSubquery;
}
protected virtual Expression VisitCollection(CollectionExpression collection)
{
return collection;
}
protected virtual Expression VisitField(FieldExpression field)
{
var e = Visit(field.Expression);
if (field.Expression != e)
field = new FieldExpression(e, field.Alias, field.Name);
return field;
}
protected virtual Expression VisitProjection(ProjectionExpression projection)
{
var source = (SelectExpression)Visit(projection.Source);
var projector = Visit(projection.Projector);
if (source != projection.Source || projector != projection.Projector)
return new ProjectionExpression(source, projector, projection.Aggregator);
return projection;
}
protected ReadOnlyCollection<OrderExpression> VisitOrderBy(ReadOnlyCollection<OrderExpression> orderBys)
{
if (orderBys != null)
{
List<OrderExpression> alternate = null;
for (int i = 0, n = orderBys.Count; i < n; i++)
{
OrderExpression expr = orderBys[i];
Expression e = this.Visit(expr.Expression);
if (alternate == null && e != expr.Expression)
alternate = orderBys.Take(i).ToList();
if (alternate != null)
alternate.Add(new OrderExpression(expr.OrderType, e));
}
if (alternate != null)
return alternate.AsReadOnly();
}
return orderBys;
}
protected virtual Expression VisitScalar(ScalarExpression scalar)
{
SelectExpression select = (SelectExpression)Visit(scalar.Select);
if (select != scalar.Select)
return new ScalarExpression(scalar.Type, select);
return scalar;
}
protected virtual Expression VisitSelect(SelectExpression select)
{
var from = VisitSource(select.From);
var where = Visit(select.Where);
var groupBy = Visit(select.GroupBy);
var orderBy = VisitOrderBy(select.OrderBy);
var skip = Visit(select.Skip);
var take = Visit(select.Take);
var fields = VisitFieldDeclarationList(select.Fields);
if (from != select.From || where != select.Where || orderBy != select.OrderBy || groupBy != select.GroupBy || skip != select.Skip || take != select.Take || fields != select.Fields)
return new SelectExpression(select.Alias, fields, from, where, orderBy, groupBy, select.IsDistinct, skip, take);
return select;
}
protected virtual Expression VisitSource(Expression source)
{
return Visit(source);
}
protected virtual Expression VisitSubquery(SubqueryExpression subquery)
{
switch ((MongoExpressionType)subquery.NodeType)
{
case MongoExpressionType.Scalar:
return VisitScalar((ScalarExpression)subquery);
}
return subquery;
}
protected virtual ReadOnlyCollection<FieldDeclaration> VisitFieldDeclarationList(ReadOnlyCollection<FieldDeclaration> fields)
{
if (fields == null)
return fields;
List<FieldDeclaration> alternate = null;
for (int i = 0, n = fields.Count; i < n; i++)
{
var f = fields[i];
var e = Visit(f.Expression);
if (f.Expression != e && alternate == null)
alternate = fields.Take(i).ToList();
if (alternate != null)
alternate.Add(new FieldDeclaration(f.Name, e));
}
if (alternate != null)
return alternate.AsReadOnly();
return fields;
}
}
}

98
samples/C++/Entity.h Normal file
View File

@@ -0,0 +1,98 @@
/**
* @file Entity.h
* @page EntityPage Entity
* @brief represent an entity in the game
* @author vinz243
* @version 0.1.0
* This file represents an Entity in the game system
* This parent type is a static entity which is shown and loaded into the Physics engine but never updated
*/
#ifndef ENTITY_H
#define ENTITY_H
#include "base.h"
/// @namespace Whitedrop
namespace Whitedrop {
/** @class Entity
* This parent type is a static entity which is shown and loaded into the Physics engine but never updated
*/
class Entity {
public:
/**
* @brief Create static entity
* @details creates a static entity instance according to the mesh and the id, the position
* This needs to be attached to a World after!
* The material name is not the file name but the material name!
* @ref WorldPage
* @param mesh the name of the mesh for the object, file must be in media/meshes
* @param id an unique identifier for the object, shortest as possible
* @param dimensions an Ogre::Vector3 which contains the dimensions in meter
* @param position the Vector3 which contains it position
* @param material the material name
*/
Entity(std::string mesh, std::string id, Ogre::Vector3 dimensions, Ogre::Vector3 position, std::string material);
/**
* @brief The copy constructor
* @details A copy constr
*
* @param ref the Entity to be copied from
*/
Entity(const Entity &ref);
/**
* @brief The assignement operator
* @details
*
* @param ent the entity to be copied
*/
Entity& operator=(const Entity ent);
/**
* @brief destrctor
* @details
*/
virtual ~Entity(void);
/**
* @brief a constance type of the entity
* @details depends of the class.
* May contain STATIC, DYNAMIC or ETHERAL
*/
const std::string type = "STATIC";
/**
* @brief Attach the entity to specified sceneManager
* @details This creates the OgreEntity using sceneMgr,
* set material, create a Node with name as `<id>_n`,
* scale it to match dimensions and translate the node to pos
* @param sceneMgr the scene manager to use
*/
virtual void setup(Ogre::SceneManager* sceneMgr);
/**
* @brief the update method
* @details this method should be called on each world update.
* Even though the method is necessary declared, the main impl of
* a static entity should be empty since it is not updated by physics
* However, a Dynamic entity should implement this function in order to:
* 1) Get from the physics engine the actor position in the physic world
* 2) Update the OgreEntity position and rotation from the previous actor
* @return whether it was successful or not, if falsey engine should stop
*/
virtual bool update(void);
protected:
std::string mMesh = "cube.mesh";
std::string mId;
std::string mMaterial;
Ogre::Vector3 mDimensions;
Ogre::Vector3 mPosition;
Ogre::Entity* mEntity;
Ogre::SceneNode* mNode;
};
}
#endif

View File

@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 2.6)
enable_testing()
set(CMAKE_BUILD_TYPE debug)
include_directories("/usr/local/include")
find_library(ssl_LIBRARY NAMES ssl PATHS "/usr/local/lib")
add_custom_command(OUTPUT "ver.c" "ver.h" COMMAND ./ver.sh)
add_executable(foo foo.c bar.c baz.c ver.c)
target_link_libraries(foo ${ssl_LIBRARY})

View File

@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(PCLVisualizer)
target_link_libraries (PCLVisualizer ${PCL_LIBRARIES})
#it seems it's needed only on OS X 10.9
find_package(GLEW REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/include -v")
find_package(PCL 1.7 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
set(PCL_BUILD_TYPE Release)
file(GLOB PCL_openni_viewer_SRC
"src/*.h"
"src/*.cpp"
)
add_executable(PCLVisualizer ${PCL_openni_viewer_SRC})
#add this line to solve probem in mac os x 10.9
target_link_libraries(PCLVisualizer ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES} ${PCL_VISUALIZATION_LIBRARIES} ${PCL_FEATURES_LIBRARIES})

View File

@@ -0,0 +1,33 @@
# Specifications for building user and development documentation.
#
# ====================================================================
# Copyright (c) 2009 Ian Blumel. All rights reserved.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
# ====================================================================
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
FIND_FILE( SPHINX sphinx-build.exe)
# If we are windows call to the make.bat file, otherwise rely on the Makefile
# to handle the processing.
IF(WIN32)
SET(SPHINX_MAKE make.bat)
ELSE(WIN32)
SET(SPHINX_MAKE make)
ENDIF(WIN32)
ADD_CUSTOM_TARGET(
doc_usr
COMMAND ${SPHINX_MAKE} html
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/usr
)
ADD_CUSTOM_TARGET(
doc_dev
COMMAND ${SPHINX_MAKE} html
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dev
)

View File

@@ -0,0 +1,33 @@
cmake_minimum_required (VERSION 2.6)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/vala)
find_package(Vala REQUIRED)
include(ValaPrecompile)
include(ValaVersion)
ensure_vala_version("0.11.0" MINIMUM)
project (template C)
find_package(PkgConfig)
pkg_check_modules(GOBJECT REQUIRED gobject-2.0)
add_definitions(${GOBJECT_CFLAGS} ${GOBJECT_CFLAGS_OTHER})
link_libraries(${GOBJECT_LIBRARIES})
link_directories(${GOBJECT_LIBRARY_DIRS})
vala_precompile(VALA_C
src/template.vala
PACKAGES
OPTIONS
--thread
CUSTOM_VAPIS
GENERATE_VAPI
GENERATE_HEADER
DIRECTORY
gen
)
add_executable("template" ${VALA_C})

View File

@@ -0,0 +1,89 @@
# - Check if the STDCALL function exists.
# This works for non-cdecl functions (kernel32 functions, for example)
# CHECK_STDCALL_FUNCTION_EXISTS(FUNCTION FUNCTION_DUMMY_ARGS VARIABLE)
# - macro which checks if the stdcall function exists
# FUNCTION_DECLARATION - the definition of the function ( e.g.: Sleep(500) )
# VARIABLE - variable to store the result
#
# The following variables may be set before calling this macro to
# modify the way the check is run:
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
# CMAKE_EXTRA_INCLUDE_FILES = list of extra includes to check in
MACRO(CHECK_STDCALL_FUNCTION_EXISTS FUNCTION_DECLARATION VARIABLE)
IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
#get includes
SET(CHECK_STDCALL_FUNCTION_PREMAIN)
FOREACH(def ${CMAKE_EXTRA_INCLUDE_FILES})
SET(CHECK_STDCALL_FUNCTION_PREMAIN "${CHECK_STDCALL_FUNCTION_PREMAIN}#include \"${def}\"\n")
ENDFOREACH(def)
#add some default includes
IF ( HAVE_WINDOWS_H )
SET(CHECK_STDCALL_FUNCTION_PREMAIN "${CHECK_STDCALL_FUNCTION_PREMAIN}#include \"windows.h\"\n")
ENDIF ( HAVE_WINDOWS_H )
IF ( HAVE_UNISTD_H )
SET(CHECK_STDCALL_FUNCTION_PREMAIN "${CHECK_STDCALL_FUNCTION_PREMAIN}#include \"unistd.h\"\n")
ENDIF ( HAVE_UNISTD_H )
IF ( HAVE_DIRECT_H )
SET(CHECK_STDCALL_FUNCTION_PREMAIN "${CHECK_STDCALL_FUNCTION_PREMAIN}#include \"direct.h\"\n")
ENDIF ( HAVE_DIRECT_H )
IF ( HAVE_IO_H )
SET(CHECK_STDCALL_FUNCTION_PREMAIN "${CHECK_STDCALL_FUNCTION_PREMAIN}#include \"io.h\"\n")
ENDIF ( HAVE_IO_H )
IF ( HAVE_SYS_TIMEB_H )
SET(CHECK_STDCALL_FUNCTION_PREMAIN "${CHECK_STDCALL_FUNCTION_PREMAIN}#include \"sys/timeb.h\"\n")
ENDIF ( HAVE_SYS_TIMEB_H )
STRING(REGEX REPLACE "(\\(.*\\))" "" CHECK_STDCALL_FUNCTION_EXISTS_FUNCTION ${FUNCTION_DECLARATION} )
SET(MACRO_CHECK_STDCALL_FUNCTION_DEFINITIONS "${CMAKE_REQUIRED_FLAGS}")
MESSAGE(STATUS "Looking for ${CHECK_STDCALL_FUNCTION_EXISTS_FUNCTION}")
IF(CMAKE_REQUIRED_LIBRARIES)
SET(CHECK_STDCALL_FUNCTION_EXISTS_ADD_LIBRARIES
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
ELSE(CMAKE_REQUIRED_LIBRARIES)
SET(CHECK_STDCALL_FUNCTION_EXISTS_ADD_LIBRARIES)
ENDIF(CMAKE_REQUIRED_LIBRARIES)
IF(CMAKE_REQUIRED_INCLUDES)
SET(CHECK_STDCALL_FUNCTION_EXISTS_ADD_INCLUDES
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
ELSE(CMAKE_REQUIRED_INCLUDES)
SET(CHECK_STDCALL_FUNCTION_EXISTS_ADD_INCLUDES)
ENDIF(CMAKE_REQUIRED_INCLUDES)
SET(CHECK_STDCALL_FUNCTION_DECLARATION ${FUNCTION_DECLARATION})
CONFIGURE_FILE("${clucene-shared_SOURCE_DIR}/cmake/CheckStdCallFunctionExists.cpp.in"
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckStdCallFunctionExists.cpp" IMMEDIATE @ONLY)
FILE(READ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckStdCallFunctionExists.cpp"
CHECK_STDCALL_FUNCTION_CONTENT)
TRY_COMPILE(${VARIABLE}
${CMAKE_BINARY_DIR}
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckStdCallFunctionExists.cpp"
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_STDCALL_FUNCTION_DEFINITIONS}
"${CHECK_STDCALL_FUNCTION_EXISTS_ADD_LIBRARIES}"
"${CHECK_STDCALL_FUNCTION_EXISTS_ADD_INCLUDES}"
OUTPUT_VARIABLE OUTPUT)
IF(${VARIABLE})
SET(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION_DECLARATION}")
MESSAGE(STATUS "Looking for ${FUNCTION_DECLARATION} - found")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the stdcall function ${FUNCTION_DECLARATION} exists passed with the following output:\n"
"${OUTPUT}\nCheckStdCallFunctionExists.cpp:\n${CHECK_STDCALL_FUNCTION_CONTENT}\n\n")
ELSE(${VARIABLE})
MESSAGE(STATUS "Looking for ${FUNCTION_DECLARATION} - not found")
SET(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION_DECLARATION}")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the stdcall function ${FUNCTION_DECLARATION} exists failed with the following output:\n"
"${OUTPUT}\nCheckStdCallFunctionExists.cpp:\n${CHECK_STDCALL_FUNCTION_CONTENT}\n\n")
ENDIF(${VARIABLE})
ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
ENDMACRO(CHECK_STDCALL_FUNCTION_EXISTS)

View File

@@ -0,0 +1,22 @@
IF (NOT EXISTS "@PROJECT_BINARY_DIR@/install_manifest.txt")
MESSAGE (FATAL_ERROR "Cannot find install manifest: \"@PROJECT_BINARY_DIR@/install_manifest.txt\"")
ENDIF (NOT EXISTS "@PROJECT_BINARY_DIR@/install_manifest.txt")
FILE (READ "@PROJECT_BINARY_DIR@/install_manifest.txt" files)
STRING (REGEX REPLACE "\n" ";" files "${files}")
FOREACH (file ${files})
MESSAGE (STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
IF (EXISTS "$ENV{DESTDIR}${file}")
EXEC_PROGRAM (
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
IF (NOT "${rm_retval}" STREQUAL 0)
MESSAGE (FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
ENDIF (NOT "${rm_retval}" STREQUAL 0)
ELSE (EXISTS "$ENV{DESTDIR}${file}")
MESSAGE (STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
ENDIF (EXISTS "$ENV{DESTDIR}${file}")
ENDFOREACH (file)

File diff suppressed because it is too large Load Diff

161
samples/GAP/bugfix.tst Normal file
View File

@@ -0,0 +1,161 @@
gap> START_TEST("Test for various former bugs");
gap> # The following used to trigger an error starting with:
gap> # "SolutionMat: matrix and vector incompatible called from"
gap> K:=AbelianPcpGroup([3,3,3]);;
gap> A:=Subgroup(K,[K.1]);;
gap> cr:=CRRecordBySubgroup(K,A);;
gap> ExtensionsCR(cr);;
# Comparing homomorphisms used to be broken
gap> K:=AbelianPcpGroup(1,[3]);;
gap> hom1:=GroupHomomorphismByImages(K,K,[K.1],[K.1]);;
gap> hom2:=GroupHomomorphismByImages(K,K,[K.1^2],[K.1^2]);;
gap> hom1=hom2;
true
gap> hom1=IdentityMapping(K);
true
gap> hom2=IdentityMapping(K);
true
gap> # The following incorrectly triggered an error at some point
gap> IsTorsionFree(ExamplesOfSomePcpGroups(5));
true
gap> # Verify IsGeneratorsOfMagmaWithInverses warnings are silenced
gap> IsGeneratorsOfMagmaWithInverses(GeneratorsOfGroup(ExamplesOfSomePcpGroups(5)));
true
gap> # Check for a bug reported 2012-01-19 by Robert Morse
gap> g := PcGroupToPcpGroup(SmallGroup(48,1));
Pcp-group with orders [ 2, 2, 2, 2, 3 ]
gap> # The next two commands used to trigger errors
gap> NonAbelianTensorSquare(Centre(g));
Pcp-group with orders [ 8 ]
gap> NonAbelianExteriorSquare(Centre(g));
Pcp-group with orders [ ]
gap> # Check for a bug reported 2012-01-19 by Robert Morse
gap> F := FreeGroup("x","y");
<free group on the generators [ x, y ]>
gap> x := F.1;; y := F.2;;
gap> G := F/[x^2/y^24, y^24, y^x/y^23];
<fp group on the generators [ x, y ]>
gap> iso := IsomorphismPcGroup(G);
[ x, y ] -> [ f1, f2*f5 ]
gap> iso1 := IsomorphismPcpGroup(Image(iso));
[ f1, f2, f3, f4, f5 ] -> [ g1, g2, g3, g4, g5 ]
gap> G := Image(iso*iso1);
Pcp-group with orders [ 2, 2, 2, 2, 3 ]
gap> # The next command used to trigger an error
gap> NonAbelianTensorSquare(Image(iso*iso1));
Pcp-group with orders [ 2, 2, 3, 2, 2, 2, 2 ]
gap> # The problem with the previous example is/was that Igs(G)
gap> # is set to a non-standard value:
gap> Igs(G);
[ g1, g2*g5, g3*g4*g5^2, g4*g5, g5 ]
gap> # Unfortunately, it seems that a lot of code that
gap> # really should be using Ngs or Cgs is using Igs incorrectly.
gap> # For example, direct products could return *invalid* embeddings:
gap> D := DirectProduct(G, G);
Pcp-group with orders [ 2, 2, 2, 2, 3, 2, 2, 2, 2, 3 ]
gap> hom:=Embedding(D,1);;
gap> mapi:=MappingGeneratorsImages(hom);;
gap> GroupHomomorphismByImages(Source(hom),Range(hom),mapi[1],mapi[2]) <> fail;
true
gap> hom:=Projection(D,1);;
gap> mapi:=MappingGeneratorsImages(hom);;
gap> GroupHomomorphismByImages(Source(hom),Range(hom),mapi[1],mapi[2]) <> fail;
true
gap> # Check for bug computing Schur extension of infinite cyclic groups,
gap> # found by Max Horn 2012-05-25
gap> G:=AbelianPcpGroup(1,[0]);
Pcp-group with orders [ 0 ]
gap> # The next command used to trigger an error
gap> SchurExtension(G);
Pcp-group with orders [ 0 ]
gap> # Check for bug computing Schur extensions of subgroups, found by MH 2012-05-25.
gap> G:=HeisenbergPcpGroup(2);
Pcp-group with orders [ 0, 0, 0, 0, 0 ]
gap> H:=Subgroup(G,[G.2^3*G.3^2, G.1^9]);
Pcp-group with orders [ 0, 0, 0 ]
gap> # The next command used to trigger an error
gap> SchurExtension(H);
Pcp-group with orders [ 0, 0, 0, 0, 0, 0 ]
gap> # Check for bug computing Schur extensions of subgroups, found by MH 2012-05-25.
gap> G:=HeisenbergPcpGroup(2);
Pcp-group with orders [ 0, 0, 0, 0, 0 ]
gap> H:=Subgroup(G,[G.1, G.2]);
Pcp-group with orders [ 0, 0 ]
gap> # The next command used to trigger an error
gap> SchurExtension(H);
Pcp-group with orders [ 0, 0, 0 ]
gap> # Check for bug computing normalizer of two subgroups, found by MH 2012-05-30.
gap> # The problem was caused by incorrect resp. overly restrictive use of Parent().
gap> G:=HeisenbergPcpGroup(2);
Pcp-group with orders [ 0, 0, 0, 0, 0 ]
gap> A:=Subgroup(Subgroup(G,[G.2,G.3,G.4,G.5]), [G.3]);
Pcp-group with orders [ 0 ]
gap> B:=Subgroup(Subgroup(G,[G.1,G.4,G.5]), [G.4]);
Pcp-group with orders [ 0 ]
gap> Normalizer(A,B);
Pcp-group with orders [ 0 ]
gap> # The following used to trigger the error "arguments must have a common parent group"
gap> Normalizer(B,A);
Pcp-group with orders [ 0 ]
gap> # In polycyclic 2.9 and 2.10, the code for 2-cohomology computations was broken.
gap> G := UnitriangularPcpGroup(3,0);
Pcp-group with orders [ 0, 0, 0 ]
gap> mats := G!.mats;
[ [ [ 1, 1, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ],
[ [ 1, 0, 0 ], [ 0, 1, 1 ], [ 0, 0, 1 ] ],
[ [ 1, 0, 1 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ] ]
gap> C := CRRecordByMats(G,mats);;
gap> cc := TwoCohomologyCR(C);;
gap> cc.factor.rels;
[ 2, 0, 0 ]
gap> c := cc.factor.prei[2];
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1, 1 ]
gap> cc.gcb;
[ [ 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0 ],
[ 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1 ],
[ -1, 0, 1, 1, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1 ] ]
gap> cc.gcc;
[ [ 1, 0, 0, 0, 0, -2, -1, 0, 1, 1, -1, -1, 0, 0, 0, 0, 0, 0 ],
[ 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 1, 0, 0, -2, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 1, 0, 0, -1, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1, 1 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1 ] ]
gap> # LowerCentralSeriesOfGroup for non-nilpotent pcp-groups used to trigger
gap> # an infinite recursion
gap> G := PcGroupToPcpGroup(SmallGroup(6,1));
Pcp-group with orders [ 2, 3 ]
gap> LowerCentralSeriesOfGroup(G);
[ Pcp-group with orders [ 2, 3 ], Pcp-group with orders [ 3 ] ]
gap> STOP_TEST( "bugfix.tst", 10000000);

21
samples/GAP/factor.tst Normal file
View File

@@ -0,0 +1,21 @@
gap> START_TEST("Test of factor groups and natural homomorphisms");
gap> G:=HeisenbergPcpGroup(2);
Pcp-group with orders [ 0, 0, 0, 0, 0 ]
gap> H:=Subgroup(G,[G.2,G.3,G.4,G.5]);
gap> K:=G/H;
gap> NaturalHomomorphism(K);
gap> A:=Subgroup(H, [G.3]);
Pcp-group with orders [ 0 ]
gap> B:=Subgroup(Subgroup(G,[G.1,G.4,G.5]), [G.4]);
Pcp-group with orders [ 0 ]
gap> Normalizer(A,B);
Pcp-group with orders [ 0 ]
gap> # The following used to trigger the error "arguments must have a common parent group"
gap> Normalizer(B,A);
Pcp-group with orders [ 0 ]
gap> STOP_TEST( "factor.tst", 10000000);

328
samples/HTML/index.html.hl Normal file
View File

@@ -0,0 +1,328 @@
<script type="text/hoplon">
(page "index.html")
(defn mouse-loc->vec
"Given a Google Closure normalized DOM mouse event return the
mouse x and y position as a two element vector."
[e]
[(.-clientX e) (.-clientY e)])
;; =============================================================================
;; Example 1
(defc ex1-content ["Waiting for a click ...."])
(defc ex1-click-count 0)
(defn ex1 []
(when (< @ex1-click-count 1)
(swap! ex1-click-count inc)
(swap! ex1-content conj "Got a click!")))
;; =============================================================================
;; Example 2
(defc ex2-content ["Waiting for a click ...."])
(defc ex2-click-count 0)
(defn ex2 []
(when (= @ex2-click-count 1)
(swap! ex2-click-count inc)
(swap! ex2-content conj "Done"))
(when (= @ex2-click-count 0)
(swap! ex2-click-count inc)
(swap! ex2-content conj "Got a Click!" "Waiting for another click ....")))
;; =============================================================================
;; Example 3
(defc ex3-content ["Waiting for a click from Button A ....."])
(defc ex3-click-count-a 0)
(defc ex3-click-count-b 0)
(defn ex3a []
(when (= @ex3-click-count-a 0)
(swap! ex3-click-count-a inc)
(swap! ex3-content conj "Got a click!" "Waiting for a click from Button B ....")) )
(defn ex3b []
(when (and (= @ex3-click-count-a 1) (= @ex3-click-count-b 0))
(swap! ex3-click-count-b inc)
(swap! ex3-content conj "Done!")))
;; =============================================================================
;; Example 6
(defc ex6-content ["Click the button to start tracking the mouse."])
(defc ex6-button-name "GO!")
(defn ex6-toggle []
(let [new-name (if (= @ex6-button-name "GO!") "STOP!" "GO!")]
(reset! ex6-button-name new-name)))
(defn ex6 [e]
(when (= @ex6-button-name "STOP!")
(swap! ex6-content conj (str (mouse-loc->vec e)))))
;; =============================================================================
;; Example 7
(defc ex7-content ["Click the button to start tracking the mouse."])
(defc ex7-button-name "GO!")
(defn ex7-toggle []
(let [new-name (if (= @ex7-button-name "GO!") "STOP!" "GO!")]
(reset! ex7-button-name new-name)))
(defn ex7 [e]
(when (= @ex7-button-name "STOP!")
(let [[x y :as m] (mouse-loc->vec e)]
(when (zero? (mod y 5))
(swap! ex7-content conj (str m))))))
;; =============================================================================
;; Example 8
(defc ex8-content ["Click the button ten times."])
(defc ex8-click-count 0)
(defn ex8 []
(when (< @ex8-click-count 10)
(swap! ex8-click-count inc)
(when (= @ex8-click-count 1)
(swap! ex8-content conj "1 Click!"))
(when (> @ex8-click-count 1)
(swap! ex8-content conj (str @ex8-click-count " clicks!")))
(when (= @ex8-click-count 10)
(swap! ex8-content conj "Done."))))
;; =============================================================================
;; Example 9
(defc ex9-index 0)
(defc ex9-animals [:aardvark :beetle :cat :dog :elk :ferret
:goose :hippo :ibis :jellyfish :kangaroo])
(defc= ex9-card (nth ex9-animals ex9-index))
(defn ex9-prev []
(when (> @ex9-index 0)
(swap! ex9-index dec)))
(defn ex9-next []
(when (< @ex9-index (dec (count @ex9-animals)))
(swap! ex9-index inc)))
;; =============================================================================
;; Example 10
(defc ex10-button-name "START!")
(defc ex10-index 0)
(defn ex10 []
(let [the-name @ex10-button-name]
(when (= the-name"START!")
(reset! ex10-button-name "STOP!"))
(when (= the-name"STOP!")
(reset! ex10-button-name "DONE!"))))
(defc ex10-animals [:aardvark :beetle :cat :dog :elk :ferret
:goose :hippo :ibis :jellyfish :kangaroo])
(defc= ex10-max (dec (count ex10-animals)))
(defc= ex10-card (nth ex10-animals ex10-index))
(defn ex10-prev []
(if (> @ex10-index 0)
(swap! ex10-index dec)
(reset! ex10-index @ex10-max)))
(defn ex10-next []
(if (< @ex10-index @ex10-max)
(swap! ex10-index inc)
(reset! ex10-index 0)))
(defn ex10-nav [k]
(when (= @ex10-button-name "STOP!")
(when (= k :next)
(ex10-next))
(when (= k :prev)
(ex10-prev))))
(defn ex10-keys [e]
(when (= @ex10-button-name "STOP!")
(if (= (.-keyCode e) 39) (ex10-nav :next))
(if (= (.-keyCode e) 37) (ex10-nav :prev))
)
)
</script>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/main.css" />
</head>
<body>
<!-- Example 1 -->
<div id="ex1" class="example">
<h2>Example 1</h2>
<table>
<tr>
<td class="left">
<button id="ex1-button" on-click='{{ #(ex1) }}'>Click me</button>
</td>
<td id="ex1-display" class="display">
<div id="ex1-messages">
<loop-tpl bindings='{{ [x ex1-content] }}'>
<p><text>~{x}</text></p>
</loop-tpl>
</div>
</td>
</tr>
</table>
</div>
<!-- Example 2 -->
<div id="ex2" class="example">
<h2>Example 2</h2>
<table>
<tr>
<td class="left">
<button id="ex2-button" on-click='{{ #(ex2) }}'>Click me</button>
</td>
<td id="ex2-display" class="display">
<div id="ex2-messages">
<loop-tpl bindings='{{ [x ex2-content] }}'>
<p><text>~{x}</text></p>
</loop-tpl>
</div>
</td>
</tr>
</table>
</div>
<!-- Example 3 -->
<div id="ex3" class="example">
<h2>Example 3</h2>
<table>
<tr>
<td class="left">
<button id="ex3-button-a" on-click='{{ #(ex3a) }}'>Button A</button>
<button id="ex3-button-b" on-click='{{ #(ex3b) }}'>Button B</button>
</td>
<td id="ex3-display" class="display">
<div id="ex3-messages">
<loop-tpl bindings='{{ [x ex3-content] }}'>
<p><text>~{x}</text></p>
</loop-tpl>
</div>
</td>
</tr>
</table>
</div>
<!-- Example 4 -->
<div id="ex4" class="example">
<h2>Example 4</h2>
<table>
<tr>
<td class="left">
<button id="ex4-button-a">Go!</button>
</td>
<td id="ex4-display" class="display">
<div id="ex4-messages"></div>
</td>
</tr>
</table>
</div>
<!-- Example 5 -->
<div id="ex5" class="example">
<h2>Example 5</h2>
<table>
<tr>
<td class="left">
<button id="ex5-button">Go!</button>
</td>
<td id="ex5-display" class="display">
<div id="ex5-messages"></div>
</td>
</tr>
</table>
</div>
<!-- Example 6 -->
<div id="ex6" class="example" on-mousemove='{{ #(ex6 %) }}' >
<h2>Example 6</h2>
<table>
<tr>
<td class="left">
<button id="ex6-button" do-text='{{ ex6-button-name }}' on-click='{{ #(ex6-toggle)}}' ></button>
</td>
<td id="ex6-display" class="display">
<div class="scrolling">
<div id="ex6-messages">
<loop-tpl bindings='{{ [x ex6-content] }}'>
<p><text>~{x}</text></p>
</loop-tpl>
</div>
</div>
</td>
</tr>
</table>
</div>
<!-- Example 7 -->
<div id="ex7" class="example" on-mousemove='{{ #(ex7 %) }}'>
<h2>Example 7</h2>
<table>
<tr>
<td class="left">
<button id="ex7-button" do-text='{{ ex7-button-name }}' on-click='{{ #(ex7-toggle)}}'></button>
</td>
<td id="ex7-display" class="display">
<div class="scrolling">
<div id="ex7-messages">
<loop-tpl bindings='{{ [x ex7-content] }}'>
<p><text>~{x}</text></p>
</loop-tpl>
</div>
</div>
</td>
</tr>
</table>
</div>
<!-- Example 8 -->
<div id="ex8" class="example">
<h2>Example 8</h2>
<table>
<tr>
<td class="left">
<button id="ex8-button" on-click='{{ #(ex8) }}'>Click me!</button>
</td>
<td id="ex8-display" class="display card">
<div class="scrolling">
<div id="ex8-messages">
<loop-tpl bindings='{{ [x ex8-content] }}'>
<p><text>~{x}</text></p>
</loop-tpl>
</div>
</div>
</td>
</tr>
</table>
</div>
<!-- Example 9 -->
<div id="ex9" class="example">
<h2>Example 9</h2>
<table>
<tr>
<td class="left">
<button id="ex9-button-prev" on-click='{{ #(ex9-prev) }}' do-class='{{ (cell= {:disabled (= ex9-index 0)})}}'>Previous</button>
<button id="ex9-button-next" on-click='{{ #(ex9-next) }}' do-class='{{ (cell= {:disabled (= ex9-index (dec (count ex9-animals)))}) }}'>Next</button>
</td>
<td id="ex9-card" class="display card" do-text='{{ ex9-card }}'></td>
</tr>
</table>
</div>
<!-- Example 10 -->
<div id="ex10" class="example" on-keydown='{{ #(ex10-keys %) }}'>
<h2>Example 10</h2>
<table>
<tr>
<td class="left">
<button id="ex10-button-start-stop" do-text='{{ ex10-button-name}}' on-click='{{ #(ex10) }}'></button>
<button id="ex10-button-prev" on-click='{{ #(ex10-nav :prev) }}'
do-class='{{ (cell= {:disabled (not= ex10-button-name "STOP!")}) }}'>Previous
</button>
<button id="ex10-button-next" on-click='{{ #(ex10-nav :next) }}' do-class='{{ (cell= {:disabled (not= ex10-button-name "STOP!")}) }}'>Next</button>
</td>
<td id="ex10-card" class="display card" do-text='{{ ex10-card }}'></td>
</tr>
</table>
</div>
</body>
</html>

56
samples/Jasmin/if1.j Normal file
View File

@@ -0,0 +1,56 @@
.class public if1
.super java/lang/Object
;
; standard initializer (calls java.lang.Object's initializer)
;
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit locals 1
.limit stack 5
BeginGlobal:
.line 2
ldc 0x1
ldc 0x1
if_icmpeq If556261059
goto IfElse556261059
If556261059:
.line 3
.line 3
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x1
invokevirtual java/io/PrintStream/print(I)V
goto IfDone556261059
IfElse556261059:
.line 5
.line 5
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x2
invokevirtual java/io/PrintStream/print(I)V
IfDone556261059:
.line 6
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x3
invokevirtual java/io/PrintStream/print(I)V
.line 7
ldc 0x1
ldc 0x1
if_icmpne IfNot-920218690
.line 8
.line 8
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x4
invokevirtual java/io/PrintStream/print(I)V
IfNot-920218690:
EndGlobal:
return
.end method

167
samples/Jasmin/if2.j Normal file
View File

@@ -0,0 +1,167 @@
.class public if2
.super java/lang/Object
;
; standard initializer (calls java.lang.Object's initializer)
;
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit locals 1
.limit stack 5
BeginGlobal:
.line 2
ldc 0x1
ldc 0x1
if_icmpeq Cmp1893841232
ldc 0x0
goto CmpDone1893841232
Cmp1893841232:
ldc 0x1
CmpDone1893841232:
ldc 0x1
if_icmpeq If-1736765035
goto IfElse-1736765035
If-1736765035:
.line 2
.line 3
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x1
invokevirtual java/io/PrintStream/print(I)V
goto IfDone-1736765035
IfElse-1736765035:
.line 4
.line 4
ldc 0x2
ldc 0x1
if_icmpeq Cmp-1460884369
ldc 0x0
goto CmpDone-1460884369
Cmp-1460884369:
ldc 0x1
CmpDone-1460884369:
ldc 0x1
if_icmpeq If-247349760
goto IfElse-247349760
If-247349760:
.line 4
.line 5
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x2
invokevirtual java/io/PrintStream/print(I)V
goto IfDone-247349760
IfElse-247349760:
.line 6
.line 7
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x3
invokevirtual java/io/PrintStream/print(I)V
IfDone-247349760:
IfDone-1736765035:
.line 10
ldc 0x1
ldc 0x2
if_icmpeq Cmp933554851
ldc 0x0
goto CmpDone933554851
Cmp933554851:
ldc 0x1
CmpDone933554851:
ldc 0x1
if_icmpeq If1623625546
goto IfElse1623625546
If1623625546:
.line 10
.line 11
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x1
invokevirtual java/io/PrintStream/print(I)V
goto IfDone1623625546
IfElse1623625546:
.line 12
.line 12
ldc 0x2
ldc 0x2
if_icmpeq Cmp1572138409
ldc 0x0
goto CmpDone1572138409
Cmp1572138409:
ldc 0x1
CmpDone1572138409:
ldc 0x1
if_icmpeq If126354425
goto IfElse126354425
If126354425:
.line 12
.line 13
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x2
invokevirtual java/io/PrintStream/print(I)V
goto IfDone126354425
IfElse126354425:
.line 14
.line 15
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x3
invokevirtual java/io/PrintStream/print(I)V
IfDone126354425:
IfDone1623625546:
.line 18
ldc 0x1
ldc 0x2
if_icmpeq Cmp126493150
ldc 0x0
goto CmpDone126493150
Cmp126493150:
ldc 0x1
CmpDone126493150:
ldc 0x1
if_icmpeq If1522284422
goto IfElse1522284422
If1522284422:
.line 18
.line 19
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x1
invokevirtual java/io/PrintStream/print(I)V
goto IfDone1522284422
IfElse1522284422:
.line 20
.line 20
ldc 0x2
ldc 0x1
if_icmpeq Cmp-906666545
ldc 0x0
goto CmpDone-906666545
Cmp-906666545:
ldc 0x1
CmpDone-906666545:
ldc 0x1
if_icmpeq If1083939031
goto IfElse1083939031
If1083939031:
.line 20
.line 21
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x2
invokevirtual java/io/PrintStream/print(I)V
goto IfDone1083939031
IfElse1083939031:
.line 22
.line 23
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x3
invokevirtual java/io/PrintStream/print(I)V
IfDone1083939031:
IfDone1522284422:
EndGlobal:
return
.end method

55
samples/Jasmin/if3.j Normal file
View File

@@ -0,0 +1,55 @@
.class public if3
.super java/lang/Object
;
; standard initializer (calls java.lang.Object's initializer)
;
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit locals 1
.limit stack 5
BeginGlobal:
.line 2
ldc 0x1
ldc 0x1
if_icmpeq If-811796083
goto IfElse-811796083
If-811796083:
.line 3
.line 3
ldc 0x0
ldc 0x1
if_icmpeq If-1001319390
goto IfElse-1001319390
If-1001319390:
.line 4
.line 4
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x1
invokevirtual java/io/PrintStream/print(I)V
goto IfDone-1001319390
IfElse-1001319390:
.line 6
.line 6
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x2
invokevirtual java/io/PrintStream/print(I)V
IfDone-1001319390:
goto IfDone-811796083
IfElse-811796083:
.line 8
.line 8
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x3
invokevirtual java/io/PrintStream/print(I)V
IfDone-811796083:
EndGlobal:
return
.end method

37
samples/Jasmin/if4.j Normal file
View File

@@ -0,0 +1,37 @@
.class public if4
.super java/lang/Object
;
; standard initializer (calls java.lang.Object's initializer)
;
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit locals 1
.limit stack 5
BeginGlobal:
.line 2
ldc 0x1
ldc 0x1
if_icmpne IfNot1919266740
.line 2
.line 2
ldc 0x1
ldc 0x1
if_icmpne IfNot613368541
.line 2
.line 2
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x1
invokevirtual java/io/PrintStream/print(I)V
IfNot613368541:
IfNot1919266740:
EndGlobal:
return
.end method

54
samples/Jasmin/op1.j Normal file
View File

@@ -0,0 +1,54 @@
.class public op1
.super java/lang/Object
;
; standard initializer (calls java.lang.Object's initializer)
;
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit locals 1
.limit stack 5
BeginGlobal:
.line 2
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x1
ldc 0x1
iadd
invokevirtual java/io/PrintStream/println(I)V
.line 3
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0xa
ldc 0x5
isub
invokevirtual java/io/PrintStream/println(I)V
.line 4
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x15
ldc 0x3
idiv
invokevirtual java/io/PrintStream/println(I)V
.line 5
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x159
ldc 0x38
imul
invokevirtual java/io/PrintStream/println(I)V
.line 6
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x52
ldc 0x9
irem
invokevirtual java/io/PrintStream/println(I)V
EndGlobal:
return
.end method

34
samples/Jasmin/op2.j Normal file
View File

@@ -0,0 +1,34 @@
.class public op2
.super java/lang/Object
;
; standard initializer (calls java.lang.Object's initializer)
;
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit locals 1
.limit stack 5
BeginGlobal:
.line 2
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x1
ldc 0x0
iand
invokevirtual java/io/PrintStream/println(Z)V
.line 3
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x1
ldc 0x0
ior
invokevirtual java/io/PrintStream/println(Z)V
EndGlobal:
return
.end method

68
samples/Jasmin/op3.j Normal file
View File

@@ -0,0 +1,68 @@
.class public op3
.super java/lang/Object
;
; standard initializer (calls java.lang.Object's initializer)
;
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit locals 1
.limit stack 5
BeginGlobal:
.line 2
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x0
ldc 0x1
if_icmpeq Cmp-1307183590
ldc 0x0
goto CmpDone-1307183590
Cmp-1307183590:
ldc 0x1
CmpDone-1307183590:
invokevirtual java/io/PrintStream/println(Z)V
.line 3
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x0
ldc 0x0
if_icmpeq Cmp-1443270821
ldc 0x0
goto CmpDone-1443270821
Cmp-1443270821:
ldc 0x1
CmpDone-1443270821:
invokevirtual java/io/PrintStream/println(Z)V
.line 4
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x1
ldc 0x1
if_icmpeq Cmp1759327329
ldc 0x0
goto CmpDone1759327329
Cmp1759327329:
ldc 0x1
CmpDone1759327329:
invokevirtual java/io/PrintStream/println(Z)V
.line 5
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x1
ldc 0x0
if_icmpeq Cmp-678570146
ldc 0x0
goto CmpDone-678570146
Cmp-678570146:
ldc 0x1
CmpDone-678570146:
invokevirtual java/io/PrintStream/println(Z)V
EndGlobal:
return
.end method

68
samples/Jasmin/op4.j Normal file
View File

@@ -0,0 +1,68 @@
.class public op4
.super java/lang/Object
;
; standard initializer (calls java.lang.Object's initializer)
;
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit locals 1
.limit stack 5
BeginGlobal:
.line 2
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x0
ldc 0x1
if_icmpne Cmp-191731100
ldc 0x0
goto CmpDone-191731100
Cmp-191731100:
ldc 0x1
CmpDone-191731100:
invokevirtual java/io/PrintStream/println(Z)V
.line 3
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x0
ldc 0x0
if_icmpne Cmp-901585603
ldc 0x0
goto CmpDone-901585603
Cmp-901585603:
ldc 0x1
CmpDone-901585603:
invokevirtual java/io/PrintStream/println(Z)V
.line 4
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x1
ldc 0x1
if_icmpne Cmp1522577937
ldc 0x0
goto CmpDone1522577937
Cmp1522577937:
ldc 0x1
CmpDone1522577937:
invokevirtual java/io/PrintStream/println(Z)V
.line 5
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0x1
ldc 0x0
if_icmpne Cmp-1653028684
ldc 0x0
goto CmpDone-1653028684
Cmp-1653028684:
ldc 0x1
CmpDone-1653028684:
invokevirtual java/io/PrintStream/println(Z)V
EndGlobal:
return
.end method

798
samples/Nit/file.nit Normal file
View File

@@ -0,0 +1,798 @@
# This file is part of NIT ( http://www.nitlanguage.org ).
#
# Copyright 2004-2008 Jean Privat <jean@pryen.org>
# Copyright 2008 Floréal Morandat <morandat@lirmm.fr>
# Copyright 2008 Jean-Sébastien Gélinas <calestar@gmail.com>
#
# This file is free software, which comes along with NIT. This software is
# distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. You can modify it is you want, provided this header
# is kept unaltered, and a notification of the changes is added.
# You are allowed to redistribute it and sell it, alone or is a part of
# another product.
# File manipulations (create, read, write, etc.)
module file
intrude import stream
intrude import ropes
import string_search
import time
in "C Header" `{
#include <dirent.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <poll.h>
#include <errno.h>
`}
# File Abstract Stream
abstract class FStream
super IOS
# The path of the file.
var path: nullable String = null
# The FILE *.
private var file: nullable NativeFile = null
fun file_stat: FileStat do return _file.file_stat
# File descriptor of this file
fun fd: Int do return _file.fileno
end
# File input stream
class IFStream
super FStream
super BufferedIStream
super PollableIStream
# Misc
# Open the same file again.
# The original path is reused, therefore the reopened file can be a different file.
fun reopen
do
if not eof and not _file.address_is_null then close
_file = new NativeFile.io_open_read(path.to_cstring)
if _file.address_is_null then
last_error = new IOError("Error: Opening file at '{path.as(not null)}' failed with '{sys.errno.strerror}'")
end_reached = true
return
end
end_reached = false
_buffer_pos = 0
_buffer.clear
end
redef fun close
do
if _file.address_is_null then return
var i = _file.io_close
_buffer.clear
end_reached = true
end
redef fun fill_buffer
do
var nb = _file.io_read(_buffer.items, _buffer.capacity)
if nb <= 0 then
end_reached = true
nb = 0
end
_buffer.length = nb
_buffer_pos = 0
end
# End of file?
redef var end_reached: Bool = false
# Open the file at `path` for reading.
init open(path: String)
do
self.path = path
prepare_buffer(10)
_file = new NativeFile.io_open_read(path.to_cstring)
if _file.address_is_null then
last_error = new IOError("Error: Opening file at '{path}' failed with '{sys.errno.strerror}'")
end_reached = true
end
end
init from_fd(fd: Int) do
self.path = ""
prepare_buffer(10)
_file = fd_to_stream(fd, read_only)
if _file.address_is_null then
last_error = new IOError("Error: Converting fd {fd} to stream failed with '{sys.errno.strerror}'")
end_reached = true
end
end
end
# File output stream
class OFStream
super FStream
super OStream
redef fun write(s)
do
if last_error != null then return
if not _is_writable then
last_error = new IOError("Cannot write to non-writable stream")
return
end
if s isa FlatText then
write_native(s.to_cstring, s.length)
else
for i in s.substrings do write_native(i.to_cstring, i.length)
end
end
redef fun close
do
if _file.address_is_null then
last_error = new IOError("Cannot close non-existing write stream")
_is_writable = false
return
end
var i = _file.io_close
_is_writable = false
end
redef var is_writable = false
# Write `len` bytes from `native`.
private fun write_native(native: NativeString, len: Int)
do
if last_error != null then return
if not _is_writable then
last_error = new IOError("Cannot write to non-writable stream")
return
end
if _file.address_is_null then
last_error = new IOError("Writing on a null stream")
_is_writable = false
return
end
var err = _file.io_write(native, len)
if err != len then
# Big problem
last_error = new IOError("Problem in writing : {err} {len} \n")
end
end
# Open the file at `path` for writing.
init open(path: String)
do
_file = new NativeFile.io_open_write(path.to_cstring)
if _file.address_is_null then
last_error = new IOError("Error: Opening file at '{path}' failed with '{sys.errno.strerror}'")
self.path = path
is_writable = false
end
self.path = path
_is_writable = true
end
# Creates a new File stream from a file descriptor
init from_fd(fd: Int) do
self.path = ""
_file = fd_to_stream(fd, wipe_write)
_is_writable = true
if _file.address_is_null then
last_error = new IOError("Error: Opening stream from file descriptor {fd} failed with '{sys.errno.strerror}'")
_is_writable = false
end
end
end
redef interface Object
private fun read_only: NativeString do return "r".to_cstring
private fun wipe_write: NativeString do return "w".to_cstring
private fun fd_to_stream(fd: Int, mode: NativeString): NativeFile `{
return fdopen(fd, mode);
`}
# returns first available stream to read or write to
# return null on interruption (possibly a signal)
protected fun poll( streams : Sequence[FStream] ) : nullable FStream
do
var in_fds = new Array[Int]
var out_fds = new Array[Int]
var fd_to_stream = new HashMap[Int,FStream]
for s in streams do
var fd = s.fd
if s isa IFStream then in_fds.add( fd )
if s isa OFStream then out_fds.add( fd )
fd_to_stream[fd] = s
end
var polled_fd = intern_poll( in_fds, out_fds )
if polled_fd == null then
return null
else
return fd_to_stream[polled_fd]
end
end
private fun intern_poll(in_fds: Array[Int], out_fds: Array[Int]) : nullable Int is extern import Array[Int].length, Array[Int].[], Int.as(nullable Int) `{
int in_len, out_len, total_len;
struct pollfd *c_fds;
sigset_t sigmask;
int i;
int first_polled_fd = -1;
int result;
in_len = Array_of_Int_length( in_fds );
out_len = Array_of_Int_length( out_fds );
total_len = in_len + out_len;
c_fds = malloc( sizeof(struct pollfd) * total_len );
/* input streams */
for ( i=0; i<in_len; i ++ ) {
int fd;
fd = Array_of_Int__index( in_fds, i );
c_fds[i].fd = fd;
c_fds[i].events = POLLIN;
}
/* output streams */
for ( i=0; i<out_len; i ++ ) {
int fd;
fd = Array_of_Int__index( out_fds, i );
c_fds[i].fd = fd;
c_fds[i].events = POLLOUT;
}
/* poll all fds, unlimited timeout */
result = poll( c_fds, total_len, -1 );
if ( result > 0 ) {
/* analyse results */
for ( i=0; i<total_len; i++ )
if ( c_fds[i].revents & c_fds[i].events || /* awaited event */
c_fds[i].revents & POLLHUP ) /* closed */
{
first_polled_fd = c_fds[i].fd;
break;
}
return Int_as_nullable( first_polled_fd );
}
else if ( result < 0 )
fprintf( stderr, "Error in Stream:poll: %s\n", strerror( errno ) );
return null_Int();
`}
end
###############################################################################
class Stdin
super IFStream
init do
_file = new NativeFile.native_stdin
path = "/dev/stdin"
prepare_buffer(1)
end
redef fun poll_in: Bool is extern "file_stdin_poll_in"
end
class Stdout
super OFStream
init do
_file = new NativeFile.native_stdout
path = "/dev/stdout"
_is_writable = true
end
end
class Stderr
super OFStream
init do
_file = new NativeFile.native_stderr
path = "/dev/stderr"
_is_writable = true
end
end
###############################################################################
redef class Streamable
# Like `write_to` but take care of creating the file
fun write_to_file(filepath: String)
do
var stream = new OFStream.open(filepath)
write_to(stream)
stream.close
end
end
redef class String
# return true if a file with this names exists
fun file_exists: Bool do return to_cstring.file_exists
# The status of a file. see POSIX stat(2).
fun file_stat: FileStat do return to_cstring.file_stat
# The status of a file or of a symlink. see POSIX lstat(2).
fun file_lstat: FileStat do return to_cstring.file_lstat
# Remove a file, return true if success
fun file_delete: Bool do return to_cstring.file_delete
# Copy content of file at `self` to `dest`
fun file_copy_to(dest: String)
do
var input = new IFStream.open(self)
var output = new OFStream.open(dest)
while not input.eof do
var buffer = input.read(1024)
output.write buffer
end
input.close
output.close
end
# Remove the trailing extension `ext`.
#
# `ext` usually starts with a dot but could be anything.
#
# assert "file.txt".strip_extension(".txt") == "file"
# assert "file.txt".strip_extension("le.txt") == "fi"
# assert "file.txt".strip_extension("xt") == "file.t"
#
# if `ext` is not present, `self` is returned unmodified.
#
# assert "file.txt".strip_extension(".tar.gz") == "file.txt"
fun strip_extension(ext: String): String
do
if has_suffix(ext) then
return substring(0, length - ext.length)
end
return self
end
# Extract the basename of a path and remove the extension
#
# assert "/path/to/a_file.ext".basename(".ext") == "a_file"
# assert "path/to/a_file.ext".basename(".ext") == "a_file"
# assert "path/to".basename(".ext") == "to"
# assert "path/to/".basename(".ext") == "to"
# assert "path".basename("") == "path"
# assert "/path".basename("") == "path"
# assert "/".basename("") == "/"
# assert "".basename("") == ""
fun basename(ext: String): String
do
var l = length - 1 # Index of the last char
while l > 0 and self.chars[l] == '/' do l -= 1 # remove all trailing `/`
if l == 0 then return "/"
var pos = chars.last_index_of_from('/', l)
var n = self
if pos >= 0 then
n = substring(pos+1, l-pos)
end
return n.strip_extension(ext)
end
# Extract the dirname of a path
#
# assert "/path/to/a_file.ext".dirname == "/path/to"
# assert "path/to/a_file.ext".dirname == "path/to"
# assert "path/to".dirname == "path"
# assert "path/to/".dirname == "path"
# assert "path".dirname == "."
# assert "/path".dirname == "/"
# assert "/".dirname == "/"
# assert "".dirname == "."
fun dirname: String
do
var l = length - 1 # Index of the last char
while l > 0 and self.chars[l] == '/' do l -= 1 # remove all trailing `/`
var pos = chars.last_index_of_from('/', l)
if pos > 0 then
return substring(0, pos)
else if pos == 0 then
return "/"
else
return "."
end
end
# Return the canonicalized absolute pathname (see POSIX function `realpath`)
fun realpath: String do
var cs = to_cstring.file_realpath
var res = cs.to_s_with_copy
# cs.free_malloc # FIXME memory leak
return res
end
# Simplify a file path by remove useless ".", removing "//", and resolving ".."
# ".." are not resolved if they start the path
# starting "/" is not removed
# trainling "/" is removed
#
# Note that the method only wonrk on the string:
# * no I/O access is performed
# * the validity of the path is not checked
#
# assert "some/./complex/../../path/from/../to/a////file//".simplify_path == "path/to/a/file"
# assert "../dir/file".simplify_path == "../dir/file"
# assert "dir/../../".simplify_path == ".."
# assert "dir/..".simplify_path == "."
# assert "//absolute//path/".simplify_path == "/absolute/path"
# assert "//absolute//../".simplify_path == "/"
fun simplify_path: String
do
var a = self.split_with("/")
var a2 = new Array[String]
for x in a do
if x == "." then continue
if x == "" and not a2.is_empty then continue
if x == ".." and not a2.is_empty and a2.last != ".." then
a2.pop
continue
end
a2.push(x)
end
if a2.is_empty then return "."
if a2.length == 1 and a2.first == "" then return "/"
return a2.join("/")
end
# Correctly join two path using the directory separator.
#
# Using a standard "{self}/{path}" does not work in the following cases:
#
# * `self` is empty.
# * `path` ends with `'/'`.
# * `path` starts with `'/'`.
#
# This method ensures that the join is valid.
#
# assert "hello".join_path("world") == "hello/world"
# assert "hel/lo".join_path("wor/ld") == "hel/lo/wor/ld"
# assert "".join_path("world") == "world"
# assert "hello".join_path("/world") == "/world"
# assert "hello/".join_path("world") == "hello/world"
# assert "hello/".join_path("/world") == "/world"
#
# Note: You may want to use `simplify_path` on the result.
#
# Note: This method works only with POSIX paths.
fun join_path(path: String): String
do
if path.is_empty then return self
if self.is_empty then return path
if path.chars[0] == '/' then return path
if self.last == '/' then return "{self}{path}"
return "{self}/{path}"
end
# Convert the path (`self`) to a program name.
#
# Ensure the path (`self`) will be treated as-is by POSIX shells when it is
# used as a program name. In order to do that, prepend `./` if needed.
#
# assert "foo".to_program_name == "./foo"
# assert "/foo".to_program_name == "/foo"
# assert "".to_program_name == "./" # At least, your shell will detect the error.
fun to_program_name: String do
if self.has_prefix("/") then
return self
else
return "./{self}"
end
end
# Alias for `join_path`
#
# assert "hello" / "world" == "hello/world"
# assert "hel/lo" / "wor/ld" == "hel/lo/wor/ld"
# assert "" / "world" == "world"
# assert "/hello" / "/world" == "/world"
#
# This operator is quite useful for chaining changes of path.
# The next one being relative to the previous one.
#
# var a = "foo"
# var b = "/bar"
# var c = "baz/foobar"
# assert a/b/c == "/bar/baz/foobar"
fun /(path: String): String do return join_path(path)
# Returns the relative path needed to go from `self` to `dest`.
#
# assert "/foo/bar".relpath("/foo/baz") == "../baz"
# assert "/foo/bar".relpath("/baz/bar") == "../../baz/bar"
#
# If `self` or `dest` is relative, they are considered relatively to `getcwd`.
#
# In some cases, the result is still independent of the current directory:
#
# assert "foo/bar".relpath("..") == "../../.."
#
# In other cases, parts of the current directory may be exhibited:
#
# var p = "../foo/bar".relpath("baz")
# var c = getcwd.basename("")
# assert p == "../../{c}/baz"
#
# For path resolution independent of the current directory (eg. for paths in URL),
# or to use an other starting directory than the current directory,
# just force absolute paths:
#
# var start = "/a/b/c/d"
# var p2 = (start/"../foo/bar").relpath(start/"baz")
# assert p2 == "../../d/baz"
#
#
# Neither `self` or `dest` has to be real paths or to exist in directories since
# the resolution is only done with string manipulations and without any access to
# the underlying file system.
#
# If `self` and `dest` are the same directory, the empty string is returned:
#
# assert "foo".relpath("foo") == ""
# assert "foo/../bar".relpath("bar") == ""
#
# The empty string and "." designate both the current directory:
#
# assert "".relpath("foo/bar") == "foo/bar"
# assert ".".relpath("foo/bar") == "foo/bar"
# assert "foo/bar".relpath("") == "../.."
# assert "/" + "/".relpath(".") == getcwd
fun relpath(dest: String): String
do
var cwd = getcwd
var from = (cwd/self).simplify_path.split("/")
if from.last.is_empty then from.pop # case for the root directory
var to = (cwd/dest).simplify_path.split("/")
if to.last.is_empty then to.pop # case for the root directory
# Remove common prefixes
while not from.is_empty and not to.is_empty and from.first == to.first do
from.shift
to.shift
end
# Result is going up in `from` with ".." then going down following `to`
var from_len = from.length
if from_len == 0 then return to.join("/")
var up = "../"*(from_len-1) + ".."
if to.is_empty then return up
var res = up + "/" + to.join("/")
return res
end
# Create a directory (and all intermediate directories if needed)
fun mkdir
do
var dirs = self.split_with("/")
var path = new FlatBuffer
if dirs.is_empty then return
if dirs[0].is_empty then
# it was a starting /
path.add('/')
end
for d in dirs do
if d.is_empty then continue
path.append(d)
path.add('/')
path.to_s.to_cstring.file_mkdir
end
end
# Delete a directory and all of its content, return `true` on success
#
# Does not go through symbolic links and may get stuck in a cycle if there
# is a cycle in the filesystem.
fun rmdir: Bool
do
var ok = true
for file in self.files do
var file_path = self.join_path(file)
var stat = file_path.file_lstat
if stat.is_dir then
ok = file_path.rmdir and ok
else
ok = file_path.file_delete and ok
end
stat.free
end
# Delete the directory itself
if ok then to_cstring.rmdir
return ok
end
# Change the current working directory
#
# "/etc".chdir
# assert getcwd == "/etc"
# "..".chdir
# assert getcwd == "/"
#
# TODO: errno
fun chdir do to_cstring.file_chdir
# Return right-most extension (without the dot)
#
# Only the last extension is returned.
# There is no special case for combined extensions.
#
# assert "file.txt".file_extension == "txt"
# assert "file.tar.gz".file_extension == "gz"
#
# For file without extension, `null` is returned.
# Hoever, for trailing dot, `""` is returned.
#
# assert "file".file_extension == null
# assert "file.".file_extension == ""
#
# The starting dot of hidden files is never considered.
#
# assert ".file.txt".file_extension == "txt"
# assert ".file".file_extension == null
fun file_extension: nullable String
do
var last_slash = chars.last_index_of('.')
if last_slash > 0 then
return substring( last_slash+1, length )
else
return null
end
end
# returns files contained within the directory represented by self
fun files : Set[ String ] is extern import HashSet[String], HashSet[String].add, NativeString.to_s, String.to_cstring, HashSet[String].as(Set[String]) `{
char *dir_path;
DIR *dir;
dir_path = String_to_cstring( recv );
if ((dir = opendir(dir_path)) == NULL)
{
perror( dir_path );
exit( 1 );
}
else
{
HashSet_of_String results;
String file_name;
struct dirent *de;
results = new_HashSet_of_String();
while ( ( de = readdir( dir ) ) != NULL )
if ( strcmp( de->d_name, ".." ) != 0 &&
strcmp( de->d_name, "." ) != 0 )
{
file_name = NativeString_to_s( strdup( de->d_name ) );
HashSet_of_String_add( results, file_name );
}
closedir( dir );
return HashSet_of_String_as_Set_of_String( results );
}
`}
end
redef class NativeString
private fun file_exists: Bool is extern "string_NativeString_NativeString_file_exists_0"
private fun file_stat: FileStat is extern "string_NativeString_NativeString_file_stat_0"
private fun file_lstat: FileStat `{
struct stat* stat_element;
int res;
stat_element = malloc(sizeof(struct stat));
res = lstat(recv, stat_element);
if (res == -1) return NULL;
return stat_element;
`}
private fun file_mkdir: Bool is extern "string_NativeString_NativeString_file_mkdir_0"
private fun rmdir: Bool `{ return rmdir(recv); `}
private fun file_delete: Bool is extern "string_NativeString_NativeString_file_delete_0"
private fun file_chdir is extern "string_NativeString_NativeString_file_chdir_0"
private fun file_realpath: NativeString is extern "file_NativeString_realpath"
end
# This class is system dependent ... must reify the vfs
extern class FileStat `{ struct stat * `}
# Returns the permission bits of file
fun mode: Int is extern "file_FileStat_FileStat_mode_0"
# Returns the last access time
fun atime: Int is extern "file_FileStat_FileStat_atime_0"
# Returns the last status change time
fun ctime: Int is extern "file_FileStat_FileStat_ctime_0"
# Returns the last modification time
fun mtime: Int is extern "file_FileStat_FileStat_mtime_0"
# Returns the size
fun size: Int is extern "file_FileStat_FileStat_size_0"
# Returns true if it is a regular file (not a device file, pipe, sockect, ...)
fun is_reg: Bool `{ return S_ISREG(recv->st_mode); `}
# Returns true if it is a directory
fun is_dir: Bool `{ return S_ISDIR(recv->st_mode); `}
# Returns true if it is a character device
fun is_chr: Bool `{ return S_ISCHR(recv->st_mode); `}
# Returns true if it is a block device
fun is_blk: Bool `{ return S_ISBLK(recv->st_mode); `}
# Returns true if the type is fifo
fun is_fifo: Bool `{ return S_ISFIFO(recv->st_mode); `}
# Returns true if the type is a link
fun is_lnk: Bool `{ return S_ISLNK(recv->st_mode); `}
# Returns true if the type is a socket
fun is_sock: Bool `{ return S_ISSOCK(recv->st_mode); `}
end
# Instance of this class are standard FILE * pointers
private extern class NativeFile `{ FILE* `}
fun io_read(buf: NativeString, len: Int): Int is extern "file_NativeFile_NativeFile_io_read_2"
fun io_write(buf: NativeString, len: Int): Int is extern "file_NativeFile_NativeFile_io_write_2"
fun io_close: Int is extern "file_NativeFile_NativeFile_io_close_0"
fun file_stat: FileStat is extern "file_NativeFile_NativeFile_file_stat_0"
fun fileno: Int `{ return fileno(recv); `}
new io_open_read(path: NativeString) is extern "file_NativeFileCapable_NativeFileCapable_io_open_read_1"
new io_open_write(path: NativeString) is extern "file_NativeFileCapable_NativeFileCapable_io_open_write_1"
new native_stdin is extern "file_NativeFileCapable_NativeFileCapable_native_stdin_0"
new native_stdout is extern "file_NativeFileCapable_NativeFileCapable_native_stdout_0"
new native_stderr is extern "file_NativeFileCapable_NativeFileCapable_native_stderr_0"
end
redef class Sys
# Standard input
var stdin: PollableIStream = new Stdin is protected writable
# Standard output
var stdout: OStream = new Stdout is protected writable
# Standard output for errors
var stderr: OStream = new Stderr is protected writable
end
# Print `objects` on the standard output (`stdout`).
protected fun printn(objects: Object...)
do
sys.stdout.write(objects.to_s)
end
# Print an `object` on the standard output (`stdout`) and add a newline.
protected fun print(object: Object)
do
sys.stdout.write(object.to_s)
sys.stdout.write("\n")
end
# Read a character from the standard input (`stdin`).
protected fun getc: Char
do
return sys.stdin.read_char.ascii
end
# Read a line from the standard input (`stdin`).
protected fun gets: String
do
return sys.stdin.read_line
end
# Return the working (current) directory
protected fun getcwd: String do return file_getcwd.to_s
private fun file_getcwd: NativeString is extern "string_NativeString_NativeString_file_getcwd_0"

376
samples/Nit/meetup.nit Normal file
View File

@@ -0,0 +1,376 @@
# This file is part of NIT ( http://www.nitlanguage.org ).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License
# Shows a meetup and allows to modify its participants
module meetup
import opportunity_model
import boilerplate
import welcome
import template
# Shows a meetup and allows to modify its participants
class OpportunityMeetupPage
super OpportunityPage
# Meetup the page is supposed to show
var meetup: nullable Meetup = null
# Answer mode for the meetup
var mode = 0
init from_id(id: String) do
var db = new OpportunityDB.open("opportunity")
meetup = db.find_meetup_by_id(id)
db.close
if meetup != null then mode = meetup.answer_mode
init
end
init do
header.page_js = "mode = {mode};\n"
header.page_js += """
function update_scores(){
var anss = $('.answer');
var count = {};
var scores = {};
var answers = [];
var maxscore = 0;
for(i=0; i < anss.length; i++){
var incscore = 0;
var inccount = 0;
var idparts = anss[i].id.split("_");
var ansid = idparts[1];
var html = anss[i].innerHTML;
if(html === "<center>✔</center>"){
inccount = 1;
incscore = 2;
}else if(html === "<center>❓</center>"){
incscore = 1;
}
var intansid = parseInt(ansid)
if(answers.indexOf(intansid) == -1){
answers.push(intansid);
}
if(ansid in count){
count[ansid] += inccount;
}else{
count[ansid] = inccount;
}
if(ansid in scores){
scores[ansid] += incscore;
}else{
scores[ansid] = incscore;
}
if(scores[ansid] > maxscore){
maxscore = scores[ansid];
}
}
for(i=0; i < answers.length; i++){
var ansid = answers[i].toString();
var el = $('#total'+ansid)[0];
var ins = "<center>"+count[ansid];
if(scores[ansid] >= maxscore){
ins += "<br/><span style=\\"color:blue\\">★</span>";
}
ins += "</center>";
el.innerHTML = ins;
}
}
function change_answer(ele, id){
// modify only the currently selected entry
if (in_modification_id != id) return;
var e = document.getElementById(ele.id);
var i = e.innerHTML;
var ans = true;"""
if mode == 0 then
header.page_js += """
if(i === "<center>✔</center>"){
ans = 0;
e.innerHTML = "<center>✘</center>"
e.style.color = "red";
}else{
ans = 1;
e.innerHTML = "<center>✔</center>";
e.style.color = "green";
}"""
else
header.page_js += """
if(i === "<center>✔</center>"){
ans = 1;
e.innerHTML = "<center>❓</center>"
e.style.color = "#B8860B";
}else if(i === "<center>❓</center>"){
ans = 0;
e.innerHTML = "<center>✘</center>"
e.style.color = "red";
}else{
ans = 2;
e.innerHTML = "<center>✔</center>";
e.style.color = "green";
}"""
end
header.page_js += """
var a = ele.id.split('_')
var pid = a[1]
var aid = a[2]
update_scores();
$.ajax({
type: "POST",
url: "./rest/answer",
data: {
answer_id: aid,
pers_id: pid,
answer: ans
}
});
}
function change_temp_answer(ele){
var e = document.getElementById(ele.id);
var i = e.innerHTML;"""
if mode == 0 then
header.page_js += """
if(i === "<center>✔</center>"){
e.innerHTML = "<center>✘</center>"
e.style.color = "red";
}else{
e.innerHTML = "<center>✔</center>";
e.style.color = "green";
}
"""
else
header.page_js += """
if(i === "<center>✔</center>"){
e.innerHTML = "<center>❓</center>";
e.style.color = "#B8860B";
}else if(i === "<center>❓</center>"){
e.innerHTML = "<center>✘</center>"
e.style.color = "red";
}else{
e.innerHTML = "<center>✔</center>";
e.style.color = "green";
}
"""
end
header.page_js += """
update_scores();
}
function add_part(ele){
var e = document.getElementById(ele.id);
var pname = document.getElementById("new_name").value;
var arr = e.id.split("_");
var mid = arr[1];
var ans = $('#' + ele.id).parent().parent().parent().children(".answer");
ansmap = {};
for(i=0;i<ans.length;i++){
var curr = ans.eq(i)
"""
if mode == 0 then
header.page_js += """
if(curr[0].innerHTML === "<center>✔</center>"){
ansmap[curr.attr('id')] = 1
}else{
ansmap[curr.attr('id')] = 0
}"""
else
header.page_js += """
if(curr[0].innerHTML === "<center>✔</center>"){
ansmap[curr.attr('id')] = 2
}else if(curr[0].innerHTML === "<center>❓</center>"){
ansmap[curr.attr('id')] = 1
}else{
ansmap[curr.attr('id')] = 0
}"""
end
header.page_js += """
}
$.ajax({
type: "POST",
url: "./rest/meetup/new_pers",
data: {
meetup_id: mid,
persname: pname,
answers: $.param(ansmap)
}
})
.done(function(data){
location.reload();
})
.fail(function(data){
//TODO: Notify of failure
});
}
function remove_people(ele){
var arr = ele.id.split("_")
var pid = arr[1]
$('#' + ele.id).parent().parent().parent().remove();
update_scores();
$.ajax({
type: "POST",
url: "./rest/people",
data: {
method: "DELETE",
p_id: pid
}
});
}
// ID of line currently open for modification
var in_modification_id = null;
function modify_people(ele, id){
if (in_modification_id != null) {
// reset to normal values
$('#modify_'+in_modification_id).text("Modify or delete");
$('#modify_'+in_modification_id).attr("class", "btn btn-xs btn-warning");
$('#line_'+in_modification_id).css("background-color", "");
$('#delete_'+in_modification_id).css("display", "none");
}
if (in_modification_id != id) {
// activate modifiable mode
$('#modify_'+id).text("Done");
$('#modify_'+id).attr("class", "btn btn-xs btn-success");
$('#line_'+id).css("background-color", "LightYellow");
$('#delete_'+id).show();
in_modification_id = id;
} else {
in_modification_id = null;
}
}
"""
end
redef fun rendering do
if meetup == null then
add((new OpportunityHomePage).write_to_string)
return
end
add header
var db = new OpportunityDB.open("opportunity")
add meetup.to_html(db)
db.close
add footer
end
end
redef class Meetup
# Build the HTML for `self`
fun to_html(db: OpportunityDB): Streamable do
var t = new Template
t.add """
<div class="container">
<div class="page-header">
<center><h1>{{{name}}}</h1></center>
"""
if not date.is_empty then t.add """
<center><h4>When: {{{date}}}</h4></center>"""
if not place.is_empty then t.add """
<center><h4>Where: {{{place}}}</h4></center>"""
t.add """
</div>
<table class="table">
"""
t.add "<th>Participant name</th>"
for i in answers(db) do
t.add "<th class=\"text-center\">"
t.add i.to_s
t.add "</th>"
end
t.add "<th></th>"
t.add "</tr>"
for i in participants(db) do
i.load_answers(db, self)
t.add "<tr id=\"line_{i.id}\">"
t.add "<td>"
t.add i.to_s
t.add "</td>"
for j, k in i.answers do
var color
if answer_mode == 0 then
if k == 1 then
color = "green"
else
color = "red"
end
else
if k == 2 then
color = "green"
else if k == 1 then
color = "#B8860B"
else
color = "red"
end
end
t.add """<td class="answer" onclick="change_answer(this, {{{i.id}}})" id="answer_{{{j.id}}}_{{{i.id}}}" style="color:{{{color}}}">"""
t.add "<center>"
if answer_mode == 0 then
if k == 1 then
t.add "✔"
else
t.add "✘"
end
else
if k == 2 then
t.add "✔"
else if k == 1 then
t.add "❓"
else
t.add "✘"
end
end
t.add "</center></td>"
end
t.add """<td class="opportunity-action"><center><button class="btn btn-xs btn-warning" type="button" onclick="modify_people(this, {{{i.id}}})" id="modify_{{{i.id}}}">Modify or delete</button>&nbsp;"""
t.add """<button class="btn btn-xs btn-danger" type="button" onclick="remove_people(this)" id="delete_{{{i.id}}}" style="display: none;">Delete</button></center></td>"""
t.add "</tr>"
end
t.add """
<tr id="newrow" style="background-color: LightYellow">
<td><input id="new_name" type="text" placeholder="Your name" class="input-large"></td>
"""
for i in answers(db) do
t.add "<td class=\"answer\" id=\"newans_{i.id}\" onclick=\"change_temp_answer(this)\" style=\"color:red;\"><center>✘</center></td>"
end
t.add """
<td><center><span id="add_{{{id}}}" onclick="add_part(this)" style="color:green;" class="action"><button class="btn btn-xs btn-success" type="button">Done</button></span></center></td>"""
t.add "</tr>"
# Compute score for each answer
var scores = new HashMap[Int, Int]
var maxsc = 0
for i in answers(db) do
scores[i.id] = i.score(db)
if scores[i.id] > maxsc then maxsc = scores[i.id]
end
t.add """
<tr id="total">
<th>Total</th>
"""
for i in answers(db) do
t.add """<th id="total{{{i.id}}}"><center>{{{i.count(db)}}}"""
if scores.has_key(i.id) and scores[i.id] >= maxsc then
t.add """<br/><span style="color:blue">★</span>"""
end
t.add "</center></th>"
end
t.add "</th>"
t.add """
<th></th>
</tr>"""
t.add "</table>"
t.add "</div>"
return t
end
end

View File

@@ -0,0 +1,434 @@
//
// AppController.j
// FlickrPhoto
//
// Created by Ross Boucher.
// Copyright 2008 - 2010, 280 North, Inc. All rights reserved.
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
var SliderToolbarItemIdentifier = "SliderToolbarItemIdentifier",
AddToolbarItemIdentifier = "AddToolbarItemIdentifier",
RemoveToolbarItemIdentifier = "RemoveToolbarItemIdentifier";
/*
Important note about CPJSONPConnection: CPJSONPConnection is ONLY for JSONP APIs.
If aren't sure you NEED JSONP (see http://ajaxian.com/archives/jsonp-json-with-padding ),
you most likely don't want to use CPJSONPConnection, but rather the more standard
CPURLConnection. CPJSONPConnection is designed for cross-domain
connections, and if you are making requests to the same domain (as most web
applications do), you do not need it.
*/
@implementation AppController : CPObject
{
CPString lastIdentifier;
CPDictionary photosets;
CPCollectionView listCollectionView;
CPCollectionView photosCollectionView;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
//the first thing we need to do is create a window to take up the full screen
//we'll also create a toolbar to go with it, and grab its size for future reference
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView],
toolbar = [[CPToolbar alloc] initWithIdentifier:"Photos"],
bounds = [contentView bounds];
//we tell the toolbar that we want to be its delegate and attach it to theWindow
[toolbar setDelegate:self];
[toolbar setVisible:true];
[theWindow setToolbar:toolbar];
photosets = [CPDictionary dictionary]; //storage for our sets of photos return from Flickr
//now we create a scroll view to contain the list of collections of photos (photosets)
//inside the scroll view, we'll place our collection view, which manages a collection of "cells"
//each cell will represent one photo collection, and choosing cells will select that collection
var listScrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, 200, CGRectGetHeight(bounds) - 58)];
[listScrollView setAutohidesScrollers:YES];
[listScrollView setAutoresizingMask:CPViewHeightSizable];
[[listScrollView contentView] setBackgroundColor:[CPColor colorWithRed:213.0 / 255.0 green:221.0 / 255.0 blue:230.0 / 255.0 alpha:1.0]];
//we create the collection view cells by creating a single prototype (CPCollectionViewItem) and setting its view.
//the CPCollectionView class will then duplicate this item as many times as it needs
var photosListItem = [[CPCollectionViewItem alloc] init];
[photosListItem setView:[[PhotosListCell alloc] initWithFrame:CGRectMakeZero()]];
listCollectionView = [[CPCollectionView alloc] initWithFrame:CGRectMake(0, 0, 200, 0)];
[listCollectionView setDelegate:self]; //we want delegate methods
[listCollectionView setItemPrototype:photosListItem]; //set the item prototype
[listCollectionView setMinItemSize:CGSizeMake(20.0, 45.0)];
[listCollectionView setMaxItemSize:CGSizeMake(1000.0, 45.0)];
[listCollectionView setMaxNumberOfColumns:1]; //setting a single column will make this appear as a vertical list
[listCollectionView setVerticalMargin:0.0];
[listCollectionView setAutoresizingMask:CPViewWidthSizable];
//finally, we put our collection view inside the scroll view as it's document view, so it can be scrolled
[listScrollView setDocumentView:listCollectionView];
//and we add it to the window's content view, so it will show up on the screen
[contentView addSubview:listScrollView];
//repeat the process with another collection view for the actual photos
//this time we'll use a different view for the prototype (PhotoCell)
var photoItem = [[CPCollectionViewItem alloc] init];
[photoItem setView:[[PhotoCell alloc] initWithFrame:CGRectMake(0, 0, 150, 150)]];
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(200, 0, CGRectGetWidth(bounds) - 200, CGRectGetHeight(bounds) - 58)];
photosCollectionView = [[CPCollectionView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(bounds) - 200, 0)];
[photosCollectionView setDelegate:self];
[photosCollectionView setItemPrototype:photoItem];
[photosCollectionView setMinItemSize:CGSizeMake(150, 150)];
[photosCollectionView setMaxItemSize:CGSizeMake(150, 150)];
[photosCollectionView setAutoresizingMask:CPViewWidthSizable];
[scrollView setAutoresizingMask:CPViewHeightSizable | CPViewWidthSizable];
[scrollView setDocumentView:photosCollectionView];
[scrollView setAutohidesScrollers:YES];
[[scrollView contentView] setBackgroundColor:[CPColor colorWithCalibratedWhite:0.25 alpha:1.0]];
[contentView addSubview:scrollView];
//bring forward the window to display it
[theWindow orderFront:self];
//get the most interesting photos on flickr
var request = [CPURLRequest requestWithURL:"http://www.flickr.com/services/rest/?method=flickr.interestingness.getList&per_page=20&format=json&api_key=ca4dd89d3dfaeaf075144c3fdec76756"];
// see important note about CPJSONPConnection above
var connection = [CPJSONPConnection sendRequest:request callback:"jsoncallback" delegate:self];
lastIdentifier = "Interesting Photos";
}
- (void)add:(id)sender
{
var string = prompt("Enter a tag to search Flickr for photos.");
if (string)
{
//create a new request for the photos with the tag returned from the javascript prompt
var request = [CPURLRequest requestWithURL:"http://www.flickr.com/services/rest/?"+
"method=flickr.photos.search&tags="+encodeURIComponent(string)+
"&media=photos&machine_tag_mode=any&per_page=20&format=json&api_key=ca4dd89d3dfaeaf075144c3fdec76756"];
// see important note about CPJSONPConnection above
[CPJSONPConnection sendRequest:request callback:"jsoncallback" delegate:self];
lastIdentifier = string;
}
}
- (void)remove:(id)sender
{
//remove this photo
[self removeImageListWithIdentifier:[[photosets allKeys] objectAtIndex:[[listCollectionView selectionIndexes] firstIndex]]];
}
- (void)addImageList:(CPArray)images withIdentifier:(CPString)aString
{
[photosets setObject:images forKey:aString];
[listCollectionView setContent:[[photosets allKeys] copy]];
[listCollectionView setSelectionIndexes:[CPIndexSet indexSetWithIndex:[[photosets allKeys] indexOfObject:aString]]];
}
- (void)removeImageListWithIdentifier:(CPString)aString
{
var nextIndex = MAX([[listCollectionView content] indexOfObject:aString] - 1, 0);
[photosets removeObjectForKey:aString];
[listCollectionView setContent:[[photosets allKeys] copy]];
[listCollectionView setSelectionIndexes:[CPIndexSet indexSetWithIndex:nextIndex]];
}
- (void)adjustImageSize:(id)sender
{
var newSize = [sender value];
[photosCollectionView setMinItemSize:CGSizeMake(newSize, newSize)];
[photosCollectionView setMaxItemSize:CGSizeMake(newSize, newSize)];
}
- (void)collectionViewDidChangeSelection:(CPCollectionView)aCollectionView
{
if (aCollectionView == listCollectionView)
{
var listIndex = [[listCollectionView selectionIndexes] firstIndex];
if (listIndex === CPNotFound)
return;
var key = [listCollectionView content][listIndex];
[photosCollectionView setContent:[photosets objectForKey:key]];
[photosCollectionView setSelectionIndexes:[CPIndexSet indexSet]];
}
}
- (void)connection:(CPJSONPConnection)aConnection didReceiveData:(CPString)data
{
//this method is called when the network request returns. the data is the returned
//information from flickr. we set the array of photo urls as the data to our collection view
[self addImageList:data.photos.photo withIdentifier:lastIdentifier];
}
- (void)connection:(CPJSONPConnection)aConnection didFailWithError:(CPString)error
{
alert(error); //a network error occurred
}
//these two methods are the toolbar delegate methods, and tell the toolbar what it should display to the user
- (CPArray)toolbarAllowedItemIdentifiers:(CPToolbar)aToolbar
{
return [self toolbarDefaultItemIdentifiers:aToolbar];
}
- (CPArray)toolbarDefaultItemIdentifiers:(CPToolbar)aToolbar
{
return [AddToolbarItemIdentifier, RemoveToolbarItemIdentifier, CPToolbarFlexibleSpaceItemIdentifier, SliderToolbarItemIdentifier];
}
//this delegate method returns the actual toolbar item for the given identifier
- (CPToolbarItem)toolbar:(CPToolbar)aToolbar itemForItemIdentifier:(CPString)anItemIdentifier willBeInsertedIntoToolbar:(BOOL)aFlag
{
var toolbarItem = [[CPToolbarItem alloc] initWithItemIdentifier:anItemIdentifier];
if (anItemIdentifier == SliderToolbarItemIdentifier)
{
[toolbarItem setView:[[PhotoResizeView alloc] initWithFrame:CGRectMake(0, 0, 180, 32)]];
[toolbarItem setMinSize:CGSizeMake(180, 32)];
[toolbarItem setMaxSize:CGSizeMake(180, 32)];
[toolbarItem setLabel:"Scale"];
}
else if (anItemIdentifier == AddToolbarItemIdentifier)
{
var image = [[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"add.png"] size:CPSizeMake(30, 25)],
highlighted = [[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"addHighlighted.png"] size:CPSizeMake(30, 25)];
[toolbarItem setImage:image];
[toolbarItem setAlternateImage:highlighted];
[toolbarItem setTarget:self];
[toolbarItem setAction:@selector(add:)];
[toolbarItem setLabel:"Add Photo List"];
[toolbarItem setMinSize:CGSizeMake(32, 32)];
[toolbarItem setMaxSize:CGSizeMake(32, 32)];
}
else if (anItemIdentifier == RemoveToolbarItemIdentifier)
{
var image = [[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"remove.png"] size:CPSizeMake(30, 25)],
highlighted = [[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"removeHighlighted.png"] size:CPSizeMake(30, 25)];
[toolbarItem setImage:image];
[toolbarItem setAlternateImage:highlighted];
[toolbarItem setTarget:self];
[toolbarItem setAction:@selector(remove:)];
[toolbarItem setLabel:"Remove Photo List"];
[toolbarItem setMinSize:CGSizeMake(32, 32)];
[toolbarItem setMaxSize:CGSizeMake(32, 32)];
}
return toolbarItem;
}
@end
/*
This code demonstrates how to add a category to an existing class.
In this case, we are adding the class method +flickr_labelWithText: to
the CPTextField class. Later on, we can call [CPTextField flickr_labelWithText:"foo"]
to return a new text field with the string foo.
Best practices suggest prefixing category methods with your unique prefix, to prevent collisions.
*/
@implementation CPTextField (CreateLabel)
+ (CPTextField)flickr_labelWithText:(CPString)aString
{
var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[label setStringValue:aString];
[label sizeToFit];
[label setTextShadowColor:[CPColor whiteColor]];
[label setTextShadowOffset:CGSizeMake(0, 1)];
return label;
}
@end
// This class wraps our slider + labels combo
@implementation PhotoResizeView : CPView
{
}
- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
var slider = [[CPSlider alloc] initWithFrame:CGRectMake(30, CGRectGetHeight(aFrame) / 2.0 - 8, CGRectGetWidth(aFrame) - 65, 24)];
[slider setMinValue:50.0];
[slider setMaxValue:250.0];
[slider setIntValue:150.0];
[slider setAction:@selector(adjustImageSize:)];
[self addSubview:slider];
var label = [CPTextField flickr_labelWithText:"50"];
[label setFrameOrigin:CGPointMake(0, CGRectGetHeight(aFrame) / 2.0 - 4.0)];
[self addSubview:label];
label = [CPTextField flickr_labelWithText:"250"];
[label setFrameOrigin:CGPointMake(CGRectGetWidth(aFrame) - CGRectGetWidth([label frame]), CGRectGetHeight(aFrame) / 2.0 - 4.0)];
[self addSubview:label];
return self;
}
@end
// This class displays a single photo collection inside our list of photo collecitions
@implementation PhotosListCell : CPView
{
CPTextField label;
CPView highlightView;
}
- (void)setRepresentedObject:(JSObject)anObject
{
if (!label)
{
label = [[CPTextField alloc] initWithFrame:CGRectInset([self bounds], 4, 4)];
[label setFont:[CPFont systemFontOfSize:16.0]];
[label setTextShadowColor:[CPColor whiteColor]];
[label setTextShadowOffset:CGSizeMake(0, 1)];
[self addSubview:label];
}
[label setStringValue:anObject];
[label sizeToFit];
[label setFrameOrigin:CGPointMake(10,CGRectGetHeight([label bounds]) / 2.0)];
}
- (void)setSelected:(BOOL)flag
{
if (!highlightView)
{
highlightView = [[CPView alloc] initWithFrame:CGRectCreateCopy([self bounds])];
[highlightView setBackgroundColor:[CPColor blueColor]];
}
if (flag)
{
[self addSubview:highlightView positioned:CPWindowBelow relativeTo:label];
[label setTextColor:[CPColor whiteColor]];
[label setTextShadowColor:[CPColor blackColor]];
}
else
{
[highlightView removeFromSuperview];
[label setTextColor:[CPColor blackColor]];
[label setTextShadowColor:[CPColor whiteColor]];
}
}
@end
// This class displays a single photo from our collection
@implementation PhotoCell : CPView
{
CPImage image;
CPImageView imageView;
CPView highlightView;
}
- (void)setRepresentedObject:(JSObject)anObject
{
if (!imageView)
{
imageView = [[CPImageView alloc] initWithFrame:CGRectMakeCopy([self bounds])];
[imageView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[imageView setImageScaling:CPScaleProportionally];
[imageView setHasShadow:YES];
[self addSubview:imageView];
}
[image setDelegate:nil];
image = [[CPImage alloc] initWithContentsOfFile:thumbForFlickrPhoto(anObject)];
[image setDelegate:self];
if ([image loadStatus] == CPImageLoadStatusCompleted)
[imageView setImage:image];
else
[imageView setImage:nil];
}
- (void)imageDidLoad:(CPImage)anImage
{
[imageView setImage:anImage];
}
- (void)setSelected:(BOOL)flag
{
if (!highlightView)
{
highlightView = [[CPView alloc] initWithFrame:[self bounds]];
[highlightView setBackgroundColor:[CPColor colorWithCalibratedWhite:0.8 alpha:0.6]];
[highlightView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
}
if (flag)
{
[highlightView setFrame:[self bounds]];
[self addSubview:highlightView positioned:CPWindowBelow relativeTo:imageView];
}
else
[highlightView removeFromSuperview];
}
@end
// helper javascript functions for turning a Flickr photo object into a URL for getting the image
function urlForFlickrPhoto(photo)
{
return "http://farm" + photo.farm + ".static.flickr.com/" + photo.server + "/" + photo.id+"_" + photo.secret + ".jpg";
}
function thumbForFlickrPhoto(photo)
{
return "http://farm" + photo.farm + ".static.flickr.com/" + photo.server + "/" + photo.id + "_" + photo.secret + "_m.jpg";
}

View File

@@ -0,0 +1,88 @@
@import <Foundation/CPObject.j>
@import <AppKit/CPView.j>
@import <AppKit/CPButton.j>
@import <AppKit/CPWebView.j>
@import "LOBoard.j"
@implementation LOInfoView : CPView
{
}
- (void)drawRect:(CGRect)r
{
[[CPColor whiteColor] setFill]
var path = [CPBezierPath bezierPath];
[path appendBezierPathWithRoundedRect:CGRectMake(5, 0, CGRectGetWidth([self bounds]) - 10.0, CGRectGetHeight([self bounds])) xRadius:10 yRadius:10];
[path fill];
}
@end
@implementation AppController : CPObject
{
}
- (CPPanel)initInfoWindow
{
var infoWindow = [[CPPanel alloc] initWithContentRect:CGRectMake(400, 50, 320, 480) styleMask:CPHUDBackgroundWindowMask | CPResizableWindowMask];
[infoWindow setFloatingPanel:YES];
var _infoContent = [infoWindow contentView],
_iconImage = [[CPImage alloc] initWithContentsOfFile:"Resources/icon.png" size:CPSizeMake(59, 60)],
_iconView = [[CPImageView alloc] initWithFrame:CGRectMake(125, 0, 59, 60)];
[_iconView setImage:_iconImage];
[_infoContent addSubview:_iconView];
var _infoView = [[LOInfoView alloc] initWithFrame:CGRectMake(0, 65, 320, 395)],
_webView = [[CPWebView alloc] initWithFrame:CGRectMake(20, 0, 270, 370)];
[_webView loadHTMLString:@"<center><h3>Lights Off</h3></center> <p>Lights Off is a fantastic game exclusively for iPhone and iPod touch and inspired by Tiger Electronic's 'Lights Out'.</p> <p>The goal of the game is simply to switch all of the lights off, but it's harder than it looks! Give the first few levels a try in the playable demo to the left.</p><center><img src='Resources/avail_on_app_store.png'></center>"];
[_infoView addSubview:_webView];
[_infoContent addSubview:_infoView];
return infoWindow;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
/* Enable Logging (DEBUG) */
// CPLogRegister(CPLogPopup);
var rootWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask];
[rootWindow setBackgroundColor:[CPColor grayColor]];
[rootWindow orderFront:self];
var infoWindow = [self initInfoWindow],
gameWindow = [[CPPanel alloc] initWithContentRect:CGRectMake(50, 50, 324, 482) styleMask:CPHUDBackgroundWindowMask];
[gameWindow setFloatingPanel:YES];
[gameWindow setTitle:@"Lights Off"];
contentView = [gameWindow contentView];
var _board = [[LOBoard alloc] initWithFrame:CGRectMake(2, 0, 320, 480)],
_bgImage = [[CPImage alloc] initWithContentsOfFile:"Resources/lo-background.png" size:CPSizeMake(320, 480)];
[_board setImage:_bgImage];
[_board resetBoard];
var _buttonImage = [[CPImage alloc] initWithContentsOfFile:"Resources/button-reset.png" size:CPSizeMake(90, 28)],
_buttonPressImage = [[CPImage alloc] initWithContentsOfFile:"Resources/button-reset-press.png" size:CPSizeMake(90, 28)],
_resetButton = [[CPButton alloc] initWithFrame:CGRectMake(195, 422, 90, 28)];
[_resetButton setImage:_buttonImage];
[_resetButton setAlternateImage:_buttonPressImage];
[_resetButton setBordered:NO];
[contentView addSubview:_board];
[contentView addSubview:_resetButton];
[_resetButton setTarget:_board];
[_resetButton setAction:@selector(resetBoard)];
[gameWindow orderFront:self];
[infoWindow orderFront:self];
}
@end

View File

@@ -0,0 +1,47 @@
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
{
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
// The end result of this layout will be the kind of master/detail/auxilliary view
// found in iTunes, Mail, and many other apps.
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
var navigationArea = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 150.0, CGRectGetHeight([contentView bounds]) - 150.0)];
[navigationArea setBackgroundColor:[CPColor redColor]];
// This view will grow in height, but stay fixed width attached to the left side of the screen.
[navigationArea setAutoresizingMask:CPViewHeightSizable | CPViewMaxXMargin];
[contentView addSubview:navigationArea];
var metaDataArea = [[CPView alloc] initWithFrame:CGRectMake(0.0, CGRectGetMaxY([navigationArea frame]), 150.0, 150.0)];
[metaDataArea setBackgroundColor:[CPColor greenColor]];
// This view will stay the same size in both directions, and fixed to the lower left corner.
[metaDataArea setAutoresizingMask:CPViewMinYMargin | CPViewMaxXMargin];
[contentView addSubview:metaDataArea];
var contentArea = [[CPView alloc] initWithFrame:CGRectMake(150.0, 0.0, CGRectGetWidth([contentView bounds]) - 150.0, CGRectGetHeight([contentView bounds]))];
[contentArea setBackgroundColor:[CPColor blueColor]];
// This view will grow in both height an width.
[contentArea setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[contentView addSubview:contentArea];
[theWindow orderFront:self];
}
@end

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env pike
int main(int argc, array argv) {
return 0;
}

View File

@@ -0,0 +1,137 @@
EnableExplicit
; ##################################################### Includes ####################################################
XIncludeFile "Includes/AudioOut.pbi"
; ##################################################### Prototypes ##################################################
; ##################################################### Structures ##################################################
; ##################################################### Constants ###################################################
#Samplerate = 44100
; ##################################################### Structures ##################################################
Structure Main
*AudioOut
Quit.i
EndStructure
Global Main.Main
Structure Main_Window
ID.i
TrackBar.i [10]
EndStructure
Global Main_Window.Main_Window
; ##################################################### Variables ###################################################
Global Frequency.d = 1000
Global Amplitude.d = 0.25
; ##################################################### Procedures ##################################################
Procedure Main_Window_Open()
Main_Window\ID = OpenWindow(#PB_Any, 0, 0, 800, 100, "AudioOut Example", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
If Main_Window\ID
Main_Window\TrackBar[0] = TrackBarGadget(#PB_Any, 10, 10, 780, 30, 0, 20000)
SetGadgetState(Main_Window\TrackBar[0], Frequency)
Main_Window\TrackBar[1] = TrackBarGadget(#PB_Any, 10, 40, 780, 30, 0, 1000)
SetGadgetState(Main_Window\TrackBar[1], Amplitude*1000)
EndIf
EndProcedure
Procedure Notifier_CallBack(*AudioOut)
Protected *Temp, Temp_Size.i
Static Rotation.d
While AudioOut::GetQueuedBlocks(*AudioOut) <= 3
Temp_Size = AudioOut::GetBufferBlocksize(*AudioOut)
If Temp_Size > 0
*Temp = AllocateMemory(Temp_Size)
Define Left.d, Right.d, i
For i = 0 To Temp_Size / 4 - 1
Left = Sin(Rotation) * Amplitude
Right = Sin(Rotation) * Amplitude
PokeW(*Temp + i*4 , Left*32767)
PokeW(*Temp + i*4 + 2, Right*32767)
Rotation + 2.0*#PI / #Samplerate * Frequency
Next
AudioOut::Write_Data(Main\AudioOut, *Temp, Temp_Size)
FreeMemory(*Temp)
EndIf
Wend
EndProcedure
; ##################################################### Initialisation ##############################################
Main_Window_Open()
AudioOut::GetDevices()
ForEach AudioOut::Device()
Debug PeekS(AudioOut::@Device()\szPname)
Next
Main\AudioOut = AudioOut::Initialize(#WAVE_MAPPER, #Samplerate, 2, 16, @Notifier_CallBack())
If Not Main\AudioOut
Debug AudioOut::GetError()
End
EndIf
Notifier_CallBack(Main\AudioOut)
; ##################################################### Main ########################################################
Repeat
Repeat
Select WaitWindowEvent(100)
Case #PB_Event_Gadget
Select EventGadget()
Case Main_Window\TrackBar[0]
Frequency = GetGadgetState(Main_Window\TrackBar[0])
Debug Frequency
Case Main_Window\TrackBar[1]
Amplitude = GetGadgetState(Main_Window\TrackBar[1]) / 1000
EndSelect
Case #PB_Event_CloseWindow
Main\Quit = #True
Case 0
Break
EndSelect
ForEver
Until Main\Quit
; ##################################################### End #########################################################
AudioOut::Deinitialize(Main\AudioOut)
; IDE Options = PureBasic 5.30 Beta 2 (Windows - x64)
; CursorPosition = 109
; FirstLine = 79
; Folding = -
; EnableUnicode
; EnableThread
; EnableXP

View File

@@ -0,0 +1,203 @@
Structure Memory_Operation
Src_Offset.q
Src_Size.q
Dst_Offset.q
Dst_Size.q
Copy_Size.q
EndStructure
; #### Cuts the Offset's / Sizes of the memory operation to prevent memory violations
Procedure Memory_Operation_Check(*Memory_Operation.Memory_Operation)
Protected Temp.q
If *Memory_Operation\Src_Offset < 0
*Memory_Operation\Copy_Size + *Memory_Operation\Src_Offset
*Memory_Operation\Dst_Offset - *Memory_Operation\Src_Offset
*Memory_Operation\Src_Offset - *Memory_Operation\Src_Offset
EndIf
If *Memory_Operation\Dst_Offset < 0
*Memory_Operation\Copy_Size + *Memory_Operation\Dst_Offset
*Memory_Operation\Src_Offset - *Memory_Operation\Dst_Offset
*Memory_Operation\Dst_Offset - *Memory_Operation\Dst_Offset
EndIf
Temp = *Memory_Operation\Src_Size - *Memory_Operation\Src_Offset
If *Memory_Operation\Copy_Size > Temp
*Memory_Operation\Copy_Size = Temp
EndIf
Temp = *Memory_Operation\Dst_Size - *Memory_Operation\Dst_Offset
If *Memory_Operation\Copy_Size > Temp
*Memory_Operation\Copy_Size = Temp
EndIf
If *Memory_Operation\Copy_Size < 0
*Memory_Operation\Copy_Size = 0
EndIf
ProcedureReturn #True
EndProcedure
; #### Fills a *Destination with a specified amount of data.
; #### It cuts everything, to prevent memory violations
Procedure Memory_Range_Fill(Ascii.a, Fill_Size.q, *Dst, Dst_Offset.q, Dst_Size.q=-1)
Protected Temp.q
If Not *Dst
ProcedureReturn #False
EndIf
If Dst_Size = -1
Dst_Size.q = MemorySize(*Dst)
EndIf
If Dst_Offset < 0
Fill_Size + Dst_Offset
Dst_Offset - Dst_Offset
EndIf
Temp = Dst_Size - Dst_Offset
If Fill_Size > Temp
Fill_Size = Temp
EndIf
If Fill_Size > 0
FillMemory(*Dst+Dst_Offset, Fill_Size, Ascii)
EndIf
ProcedureReturn #True
EndProcedure
; #### Copies a specified amount of data (Copy_Size) from the source to the destination.
; #### It cuts everything, to prevent memory violations
Procedure Memory_Range_Copy(*Src, Src_Offset.q, *Dst, Dst_Offset.q, Copy_Size.q, Src_Size.q=-1, Dst_Size.q=-1)
Protected Temp.q
If Not *Src
ProcedureReturn #False
EndIf
If Not *Dst
ProcedureReturn #False
EndIf
If Src_Size = -1
Src_Size.q = MemorySize(*Src)
EndIf
If Dst_Size = -1
Dst_Size.q = MemorySize(*Dst)
EndIf
If Src_Offset < 0
Copy_Size + Src_Offset
Dst_Offset - Src_Offset
Src_Offset - Src_Offset
EndIf
If Dst_Offset < 0
Copy_Size + Dst_Offset
Src_Offset - Dst_Offset
Dst_Offset - Dst_Offset
EndIf
Temp = Src_Size - Src_Offset
If Copy_Size > Temp
Copy_Size = Temp
EndIf
Temp = Dst_Size - Dst_Offset
If Copy_Size > Temp
Copy_Size = Temp
EndIf
If Copy_Size > 0
CopyMemory(*Src+Src_Offset, *Dst+Dst_Offset, Copy_Size)
EndIf
ProcedureReturn #True
EndProcedure
; #### Copies (MoveMemory) a specified amount of data (Copy_Size) from the source to the destination.
; #### It cuts everything, to prevent memory violations
Procedure Memory_Range_Move(*Src, Src_Offset.q, *Dst, Dst_Offset.q, Copy_Size.q, Src_Size.q=-1, Dst_Size.q=-1)
Protected Temp.q
If Not *Src
ProcedureReturn #False
EndIf
If Not *Dst
ProcedureReturn #False
EndIf
If Src_Size = -1
Src_Size.q = MemorySize(*Src)
EndIf
If Dst_Size = -1
Dst_Size.q = MemorySize(*Dst)
EndIf
If Src_Offset < 0
Copy_Size + Src_Offset
Dst_Offset - Src_Offset
Src_Offset - Src_Offset
EndIf
If Dst_Offset < 0
Copy_Size + Dst_Offset
Src_Offset - Dst_Offset
Dst_Offset - Dst_Offset
EndIf
Temp = Src_Size - Src_Offset
If Copy_Size > Temp
Copy_Size = Temp
EndIf
Temp = Dst_Size - Dst_Offset
If Copy_Size > Temp
Copy_Size = Temp
EndIf
If Copy_Size > 0
MoveMemory(*Src+Src_Offset, *Dst+Dst_Offset, Copy_Size)
EndIf
ProcedureReturn #True
EndProcedure
; #### Mirrors the memory, usable for little/big endian switching
Procedure Memory_Mirror(*Memory, Memory_Size)
Protected Elements, i
Protected Temp.a, *A.Ascii, *B.Ascii
If Not *Memory
ProcedureReturn #False
EndIf
If Memory_Size < 1
ProcedureReturn #True
EndIf
Elements = Memory_Size/2
*A = *Memory
*B = *Memory + Memory_Size - 1
For i = 0 To Elements - 1
Temp = *A\a
*A\a = *B\a
*B\a = Temp
*A + 1
*B - 1
Next
ProcedureReturn #True
EndProcedure
; IDE Options = PureBasic 5.31 (Windows - x64)
; CursorPosition = 190
; FirstLine = 177
; Folding = -
; EnableXP
; DisableDebugger

275
samples/SAS/detect_phi.sas Normal file
View File

@@ -0,0 +1,275 @@
%macro check_dataset(dset =, obs_lim = max, eldest_age = 89) ;
%local i ;
%local inset_name ;
%let inset_name = &dset ;
%if %lowcase(&obs_lim) = max %then %do ;
%** Nothing ;
%end ;
%else %do ;
proc surveyselect
data = &inset_name
out = __sub_dset
method = srs
sampsize = &obs_lim SELECTALL
seed = 1234567
noprint
;
run;
%let dset = __sub_dset ;
%end ;
%macro check_varname(regx, msg) ;
create table possible_bad_vars as
select name, label
from these_vars
where prxmatch(compress("/(&regx)/i"), name)
;
%if &sqlobs > 0 %then %do ;
insert into phi_warnings(dset, variable, label, warning)
select "&inset_name" as dset, name, label, "&msg"
from possible_bad_vars
;
%end ;
%mend check_varname ;
%macro check_vars_for_mrn(length_limit = 6, obs_lim = max) ;
%local char ;
%let char = 2 ;
proc sql noprint ;
select name
into :mrn_array separated by ' '
from these_vars
where type = &char and length ge &length_limit
;
quit ;
%if &sqlobs > 0 %then %do ;
%put Checking these vars for possible MRN contents: &mrn_array ;
data __gnu ;
retain
mrn_regex_handle
badcount
;
set &inset_name (obs = &obs_lim keep = &mrn_array) ;
if _n_ = 1 then do ;
mrn_regex_handle = prxparse("/&mrn_regex/") ;
badcount = 0 ;
end ;
array p &mrn_array ;
do i = 1 to dim(p) ;
if prxmatch(mrn_regex_handle, p{i}) then do ;
badvar = vname(p{i}) ;
badvalue = p{i} ;
badcount = _n_ ;
output ;
end ;
keep badvar badvalue badcount ;
end ;
run ;
proc sql noprint ;
select compress(put(max(badcount), best.))
into :badcount
from __gnu
;
insert into phi_warnings(dset, variable, warning)
select distinct "&inset_name", badvar, "Could this var hold MRN values? Contents of %trim(&badcount) records match the pattern given for MRN values. MRNs should never move across sites."
from __gnu ;
drop table __gnu ;
quit ;
%end ;
%mend check_vars_for_mrn ;
%macro check_vars_for_oldsters(eldest_age = 89, obs_lim = max) ;
%local dtfmts ;
%let dtfmts = 'B8601DA','B8601DN','B8601DT','B8601DZ','B8601LZ','B8601TM','B8601TZ','DATE','DATEAMPM','DATETIME','DAY','DDMMYY',
'DDMMYYB','DDMMYYC','DDMMYYD','DDMMYYN','DDMMYYP','DDMMYYS','DOWNAME','DTDATE','DTMONYY','DTWKDATX','DTYEAR',
'DTYYQC','E8601DA','E8601DN','E8601DT','E8601DZ','E8601LZ','E8601TM','E8601TZ','HHMM','HOUR','JULDAY','JULIAN',
'MMDDYY','MMDDYYB','MMDDYYC','MMDDYYD','MMDDYYN','MMDDYYP','MMDDYYS','MMSS','MMYY','MMYY','MONNAME','MONTH','MONYY',
'PDJULG','PDJULI','QTR','QTRR','WEEKDATE','WEEKDATX','WEEKDAY','WEEKU','WEEKV','WEEKW','WORDDATE','WORDDATX',
'YEAR','YYMM','YYMMC','YYMMD','YYMMN','YYMMP','YYMMS','YYMMDD','YYMMDDB','YYMMDDC','YYMMDDD','YYMMDDN','YYMMDDP',
'YYMMDDS','YYMON','YYQ','YYQC','YYQD','YYQN','YYQP','YYQS','YYQR','YYQRC','YYQRD','YYQRN','YYQRP','YYQRS' ;
%local num ;
%let num = 1 ;
proc sql noprint ;
select name
into :dat_array separated by ' '
from these_vars
where type = &num and (format in (&dtfmts) or lowcase(name) like '%date%')
;
/* added by cb to shorten the process of looking at all dates */
%if &sqlobs > 0 %then %do ;
%put Checking these vars for possible DOB contents: &dat_array ;
select 'min(' || trim(name) || ') as ' || name into :var_list separated by ','
from these_vars
where type = &num and (format in (&dtfmts) or lowcase(name) like '%date%')
;
create table __gnu as
select &var_list from &inset_name
;
/* end cb additions */
quit ;
data __gnu ;
set __gnu (obs = &obs_lim keep = &dat_array) ;
array d &dat_array ;
do i = 1 to dim(d) ;
if n(d{i}) then maybe_age = %calcage(bdtvar = d{i}, refdate = "&sysdate9."d) ;
if maybe_age ge &eldest_age then do ;
badvar = vname(d{i}) ;
badvalue = d{i} ;
output ;
end ;
keep badvar badvalue maybe_age ;
end ;
run ;
proc sql outobs = 30 nowarn ;
insert into phi_warnings(dset, variable, warning)
select distinct "&inset_name", badvar, "If this is a date, at least one value is " || compress(put(maybe_age, best.)) || " years ago, which is older than &eldest_age.. " ||
"If this date applies to a person, the record is probably PHI."
from __gnu ;
drop table __gnu ;
quit ;
%end ;
%else %do ;
%put No obvious date variables found in &inset_name.--skipping age checks. ;
%end ;
%mend check_vars_for_oldsters ;
proc contents noprint data = &inset_name out = these_vars ;
run ;
proc sql noprint ;
create table phi_warnings (dset char(50), variable char(256), label char(256), warning char(200)) ;
%check_varname(regx = mrn|hrn , msg = %str(Name suggests this var may be an MRN, which should never move across sites.)) ;
%check_varname(regx = birth_date|BirthDate|DOB|BDate , msg = %str(Name suggests this var may be a date of birth.)) ;
%check_varname(regx = SSN|SocialSecurityNumber|social_security_number|socsec, msg = %str(Name suggests this var may be a social security number.)) ;
%if %symexist(locally_forbidden_varnames) %then %do ;
%check_varname(regx = &locally_forbidden_varnames, msg = %str(May be on the locally defined list of variables not allowed to be sent to other sites.)) ;
%end ;
quit ;
%check_vars_for_mrn(obs_lim = &obs_lim) ;
%check_vars_for_oldsters(obs_lim = &obs_lim, eldest_age = &eldest_age) ;
title3 "WARNINGS for dataset &inset_name:" ;
proc sql noprint ;
select count(*) as num_warns into :num_warns from phi_warnings ;
%if &num_warns = 0 %then %do ;
reset print outobs = 5 NOWARN ;
select "No obvious PHI-like data elements in &inset_name--BUT PLEASE INSPECT THE CONTENTS AND PRINTs TO FOLLOW" as x label = "No warnings for &inset_name"
from &inset_name
;
%do i = 1 %to 5 ;
%put No obvious phi-like data elements in &inset_name. BUT PLEASE INSPECT THE CONTENTS AND PRINTs CAREFULLY TO MAKE SURE OF THIS! ;
%end ;
%end ;
%else %do ;
reset print ;
select variable, warning from phi_warnings
order by variable, warning
;
quit ;
%end ;
title3 "Dataset &inset_name" ;
proc contents data = &inset_name varnum ;
run ;
/*
proc print data = &inset_name (obs = 20) ;
run ;
*/
** TODO: make the print print out recs that trip the value warnings. ;
proc sql number ;
select *
from &inset_name (obs = 20)
;
quit ;
quit ;
%RemoveDset(dset = __sub_dset) ;
%RemoveDset(dset = possible_bad_vars) ;
%RemoveDset(dset = phi_warnings) ;
%RemoveDset(dset = these_vars) ;
%mend check_dataset ;
%macro detect_phi(transfer_lib, obs_lim = max, eldest_age = 89) ;
%put ;
%put ;
%put ============================================================== ;
%put ;
%put Macro detect_phi: ;
%put ;
%put Checking all datasets found in %sysfunc(pathname(&transfer_lib)) for the following signs of PHI: ;
%put - Variable names signifying sensitive items like 'MRN', 'birth_date', 'SSN' and so forth. ;
%if %symexist(locally_forbidden_varnames) %then %do ;
%put - Variable names on the list defined in the standard macro variable locally_forbidden_varnames (here those names are: &locally_forbidden_varnames). ;
%end ;
%put - Contents of CHARACTER variables that match the pattern given in the standard macro variable mrn_regex (here that var is &mrn_regex) ;
%put Please note that numeric variables ARE NOT CHECKED FOR MRN-LIKE CONTENT. ;
%put - The contents of date variables (as divined by their formats) for values that, if they were DOBs, would indicate a person older than &eldest_age years. ;
%put ;
%put THIS IS BETA SOFTWARE-PLEASE SCRUTINIZE THE RESULTS AND REPORT PROBLEMS TO pardee.r@ghc.org. ;
%put ;
%put THIS MACRO IS NOT A SUBSTITUTE FOR HUMAN INSPECTION AND THOUGHT--PLEASE CAREFULLY INSPECT ALL VARIABLES--WHETHER ;
%put OR NOT THEY TRIP A WARNING--TO MAKE SURE THE DATA COMPORTS WITH YOUR DATA SHARING AGREEMENT!!! ;
%put THIS MACRO IS NOT A SUBSTITUTE FOR HUMAN INSPECTION AND THOUGHT--PLEASE CAREFULLY INSPECT ALL VARIABLES--WHETHER ;
%put OR NOT THEY TRIP A WARNING--TO MAKE SURE THE DATA COMPORTS WITH YOUR DATA SHARING AGREEMENT!!! ;
%put ;
%put THIS MACRO IS NOT A SUBSTITUTE FOR HUMAN INSPECTION AND THOUGHT--PLEASE CAREFULLY INSPECT ALL VARIABLES--WHETHER ;
%put OR NOT THEY TRIP A WARNING--TO MAKE SURE THE DATA COMPORTS WITH YOUR DATA SHARING AGREEMENT!!! ;
%put THIS MACRO IS NOT A SUBSTITUTE FOR HUMAN INSPECTION AND THOUGHT--PLEASE CAREFULLY INSPECT ALL VARIABLES--WHETHER ;
%put OR NOT THEY TRIP A WARNING--TO MAKE SURE THE DATA COMPORTS WITH YOUR DATA SHARING AGREEMENT!!! ;
%put ;
%put THIS MACRO IS NOT A SUBSTITUTE FOR HUMAN INSPECTION AND THOUGHT--PLEASE CAREFULLY INSPECT ALL VARIABLES--WHETHER ;
%put OR NOT THEY TRIP A WARNING--TO MAKE SURE THE DATA COMPORTS WITH YOUR DATA SHARING AGREEMENT!!! ;
%put THIS MACRO IS NOT A SUBSTITUTE FOR HUMAN INSPECTION AND THOUGHT--PLEASE CAREFULLY INSPECT ALL VARIABLES--WHETHER ;
%put OR NOT THEY TRIP A WARNING--TO MAKE SURE THE DATA COMPORTS WITH YOUR DATA SHARING AGREEMENT!!! ;
%put ;
%put THIS MACRO IS NOT A SUBSTITUTE FOR HUMAN INSPECTION AND THOUGHT--PLEASE CAREFULLY INSPECT ALL VARIABLES--WHETHER ;
%put OR NOT THEY TRIP A WARNING--TO MAKE SURE THE DATA COMPORTS WITH YOUR DATA SHARING AGREEMENT!!! ;
%put THIS MACRO IS NOT A SUBSTITUTE FOR HUMAN INSPECTION AND THOUGHT--PLEASE CAREFULLY INSPECT ALL VARIABLES--WHETHER ;
%put OR NOT THEY TRIP A WARNING--TO MAKE SURE THE DATA COMPORTS WITH YOUR DATA SHARING AGREEMENT!!! ;
%put ;
%put ;
%put ============================================================== ;
%put ;
%put ;
title1 "PHI-Detection Report for the datasets in %sysfunc(pathname(&transfer_lib))." ;
title2 "please inspect all output carefully to make sure it comports with your data sharing agreement!!!" ;
proc sql noprint ;
** describe table dictionary.tables ;
select trim(libname) || '.' || memname as dset
into :d1-:d999
from dictionary.tables
where libname = "%upcase(&transfer_lib)" AND
memtype = 'DATA'
;
%local num_dsets ;
%let num_dsets = &sqlobs ;
quit ;
%local i ;
%if &num_dsets = 0 %then %do i = 1 %to 10 ;
%put ERROR: NO DATASETS FOUND IN &transfer_lib!!!! ;
%end ;
%do i = 1 %to &num_dsets ;
%put about to check &&d&i ;
%check_dataset(dset = &&d&i, obs_lim = &obs_lim, eldest_age = &eldest_age) ;
%end ;
%mend detect_phi ;

View File

@@ -0,0 +1,7 @@
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?email
WHERE {
?person a foaf:Person.
?person foaf:name ?name.
?person foaf:mbox ?email.
}

View File

@@ -0,0 +1,40 @@
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT DISTINCT ?s ?label
WHERE {
SERVICE <http://api.finto.fi/sparql>
{
SELECT DISTINCT ?s ?label ?plabel ?alabel ?hlabel (GROUP_CONCAT(DISTINCT STR(?type)) as ?types)
WHERE {
GRAPH <http://www.yso.fi/onto/kauno/>
{
?s rdf:type <http://www.w3.org/2004/02/skos/core#Concept>
{
?s rdf:type ?type .
?s ?prop ?match .
FILTER (
strstarts(lcase(str(?match)), "test") && !(?match != ?label && strstarts(lcase(str(?label)), "test"))
)
OPTIONAL {
?s skos:prefLabel ?label .
FILTER (langMatches(lang(?label), "en"))
}
OPTIONAL { # in case previous OPTIONAL block gives no labels
?s ?prop ?match .
?s skos:prefLabel ?label .
FILTER (langMatches(lang(?label), lang(?match))) }
}
FILTER NOT EXISTS { ?s owl:deprecated true }
}
BIND(IF(?prop = skos:prefLabel && ?match != ?label, ?match, "") as ?plabel)
BIND(IF(?prop = skos:altLabel, ?match, "") as ?alabel)
BIND(IF(?prop = skos:hiddenLabel, ?match, "") as ?hlabel)
VALUES (?prop) { (skos:prefLabel) (skos:altLabel) (skos:hiddenLabel) }
}
GROUP BY ?match ?s ?label ?plabel ?alabel ?hlabel ?prop
ORDER BY lcase(str(?match)) lang(?match)
LIMIT 10
}
}

85
samples/SQL/videodb.cql Normal file
View File

@@ -0,0 +1,85 @@
CREATE KEYSPACE videodb WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
use videodb;
// Basic entity table
// Object mapping ?
CREATE TABLE users (
username varchar,
firstname varchar,
lastname varchar,
email varchar,
password varchar,
created_date timestamp,
total_credits int,
credit_change_date timeuuid,
PRIMARY KEY (username)
);
// One-to-many entity table
CREATE TABLE videos (
videoid uuid,
videoname varchar,
username varchar,
description varchar,
tags list<varchar>,
upload_date timestamp,
PRIMARY KEY (videoid)
);
// One-to-many from the user point of view
// Also know as a lookup table
CREATE TABLE username_video_index (
username varchar,
videoid uuid,
upload_date timestamp,
videoname varchar,
PRIMARY KEY (username, videoid)
);
// Counter table
CREATE TABLE video_rating (
videoid uuid,
rating_counter counter,
rating_total counter,
PRIMARY KEY (videoid)
);
// Creating index tables for tab keywords
CREATE TABLE tag_index (
tag varchar,
videoid uuid,
timestamp timestamp,
PRIMARY KEY (tag, videoid)
);
// Comments as a many-to-many
// Looking from the video side to many users
CREATE TABLE comments_by_video (
videoid uuid,
username varchar,
comment_ts timestamp,
comment varchar,
PRIMARY KEY (videoid,comment_ts,username)
) WITH CLUSTERING ORDER BY (comment_ts DESC, username ASC);
// looking from the user side to many videos
CREATE TABLE comments_by_user (
username varchar,
videoid uuid,
comment_ts timestamp,
comment varchar,
PRIMARY KEY (username,comment_ts,videoid)
) WITH CLUSTERING ORDER BY (comment_ts DESC, videoid ASC);
// Time series wide row with reverse comparator
CREATE TABLE video_event (
videoid uuid,
username varchar,
event varchar,
event_timestamp timeuuid,
video_timestamp bigint,
PRIMARY KEY ((videoid,username), event_timestamp,event)
) WITH CLUSTERING ORDER BY (event_timestamp DESC,event ASC);

85
samples/SQL/videodb.ddl Normal file
View File

@@ -0,0 +1,85 @@
CREATE KEYSPACE videodb WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
use videodb;
// Basic entity table
// Object mapping ?
CREATE TABLE users (
username varchar,
firstname varchar,
lastname varchar,
email varchar,
password varchar,
created_date timestamp,
total_credits int,
credit_change_date timeuuid,
PRIMARY KEY (username)
);
// One-to-many entity table
CREATE TABLE videos (
videoid uuid,
videoname varchar,
username varchar,
description varchar,
tags list<varchar>,
upload_date timestamp,
PRIMARY KEY (videoid)
);
// One-to-many from the user point of view
// Also know as a lookup table
CREATE TABLE username_video_index (
username varchar,
videoid uuid,
upload_date timestamp,
videoname varchar,
PRIMARY KEY (username, videoid)
);
// Counter table
CREATE TABLE video_rating (
videoid uuid,
rating_counter counter,
rating_total counter,
PRIMARY KEY (videoid)
);
// Creating index tables for tab keywords
CREATE TABLE tag_index (
tag varchar,
videoid uuid,
timestamp timestamp,
PRIMARY KEY (tag, videoid)
);
// Comments as a many-to-many
// Looking from the video side to many users
CREATE TABLE comments_by_video (
videoid uuid,
username varchar,
comment_ts timestamp,
comment varchar,
PRIMARY KEY (videoid,comment_ts,username)
) WITH CLUSTERING ORDER BY (comment_ts DESC, username ASC);
// looking from the user side to many videos
CREATE TABLE comments_by_user (
username varchar,
videoid uuid,
comment_ts timestamp,
comment varchar,
PRIMARY KEY (username,comment_ts,videoid)
) WITH CLUSTERING ORDER BY (comment_ts DESC, videoid ASC);
// Time series wide row with reverse comparator
CREATE TABLE video_event (
videoid uuid,
username varchar,
event varchar,
event_timestamp timeuuid,
video_timestamp bigint,
PRIMARY KEY ((videoid,username), event_timestamp,event)
) WITH CLUSTERING ORDER BY (event_timestamp DESC,event ASC);

View File

@@ -0,0 +1,136 @@
# -*- coding: utf-8 -*-
#
# Funciones en Python/Sage para el trabajo con polinomios con una
# incógnita (x).
#
# Copyright (C) 2014-2015, David Abián <davidabian [at] davidabian.com>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
def pols (grado=-1, K=GF(2), mostrar=False):
"""Devuelve la lista de polinomios constantes y no constantes de
coeficientes mónicos y grado igual o menor que el especificado.
Si el grado indicado no es válido, devuelve una lista vacía.
"""
lpols = []
if not grado.is_integer():
grado = grado.round()
if grado >= 0:
var('x')
xs = vector([(x^i) for i in range(grado+1)])
V = VectorSpace(K,grado+1)
lpols = [cs*xs for cs in V]
if mostrar:
for pol in lpols:
print pol
return lpols
def polsNoCtes (grado=-1, K=GF(2), mostrar=False):
"""Devuelve la lista de polinomios no constantes de coeficientes mónicos y
grado igual o menor que el especificado.
Si el grado indicado no es válido, devuelve una lista vacía.
"""
lpols = []
if not grado.is_integer():
grado = grado.round()
if grado >= 0:
var('x')
xs = vector([(x^i) for i in range(grado+1)])
for cs in K^(grado+1):
if cs[:grado] != vector(grado*[0]): # no constantes
lpols += [cs*xs]
if mostrar:
for pol in lpols:
print pol
return lpols
def polsMismoGrado (grado=-1, K=GF(2), mostrar=False):
"""Devuelve la lista de polinomios de coeficientes mónicos del grado
especificado.
Si el grado indicado no es válido, devuelve una lista vacía.
"""
lpols = []
if not grado.is_integer():
grado = grado.round()
if grado >= 0:
var('x')
xs = vector([(x^(grado-i)) for i in [0..grado]])
for cs in K^(grado+1):
if cs[0] != 0: # polinomios del mismo grado
lpols += [cs*xs]
if mostrar:
for pol in lpols:
print pol
return lpols
def excluirReducibles (lpols=[], mostrar=False):
"""Filtra una lista dada de polinomios de coeficientes mónicos y devuelve
aquellos irreducibles.
"""
var('x')
irreds = []
for p in lpols:
fp = (p.factor_list())
if len(fp) == 1 and fp[0][1] == 1:
irreds += [p]
if mostrar:
for pol in irreds:
print pol
return irreds
def vecPol (vec=random_vector(GF(2),0)):
"""Transforma los coeficientes dados en forma de vector en el polinomio
que representan.
Por ejemplo, con vecPol(vector([1,0,3,1])) se obtiene x³ + 3*x + 1.
Para la función opuesta, véase polVec().
"""
var('x')
xs = vector([x^(len(vec)-1-i) for i in range(len(vec))])
return vec*xs
def polVec (p=None):
"""Devuelve el vector de coeficientes del polinomio dado que acompañan a la
incógnita x, de mayor a menor grado.
Por ejemplo, con polVec(x^3 + 3*x + 1) se obtiene el vector (1, 0, 3, 1).
Para la función opuesta, véase vecPol().
"""
cs = []
if p != None:
var('x')
p(x) = p
for i in [0..p(x).degree(x)]:
cs.append(p(x).coefficient(x,i))
cs = list(reversed(cs))
return vector(cs)
def completar2 (p=0):
"""Aplica el método de completar cuadrados en parábolas al polinomio dado de
grado 2 y lo devuelve en su nueva forma.
Si el polinomio dado no es válido, devuelve 0.
Por ejemplo, con complCuad(3*x^2 + 12*x + 5) se obtiene 3*(x + 2)^2 - 7.
"""
var('x')
p(x) = p.expand()
if p(x).degree(x) != 2:
p(x) = 0
else:
cs = polVec(p(x))
p(x) = cs[0]*(x+(cs[1]/(2*cs[0])))^2+(4*cs[0]*cs[2]-cs[1]^2)/(4*cs[0])
return p(x)

View File

@@ -0,0 +1,48 @@
ceph:
pkg.installed:
- refresh: True
service:
- dead
- enable: False
- require:
- file: /etc/eval.conf
{% if grains['os'] == 'Ubuntu'%}
- file: /etc/apt/sources.list.d/ceph.list
{% endif %}
ceph-mds:
pkg.installed:
- require:
- pkg: ceph
include:
- ceph.extras
{% if grains['os'] == 'Ubuntu'%}
/etc/apt/sources.list.d/ceph.list:
file.managed:
- source: salt://ceph/apt.list
- template: jinja
- require:
- cmd: repo-key
repo-key:
cmd.run:
- name: 'wget -q -O - https://raw.github.com/release.asc | sudo apt-key add -'
- unless: 'apt-key list | grep -q -i ceph'
{% endif %}
/etc/ceph/ceph.conf:
file.managed:
- source: salt://ceph/eval.conf
- template: jinja
- makedirs: true
/var/lib/ceph:
file.directory:
- names:
{% for dir in 'mon.a','osd.0','osd.1','mds.a' %}
- /var/lib/ceph/{{ dir.split('.')[0] }}/ceph-{{ dir.split('.')[1] }}
{% endfor %}
- require:
- pkg: ceph

View File

@@ -0,0 +1,4 @@
base:
'*':
- packages
- coffeestats

View File

@@ -0,0 +1,46 @@
(library (lambdastar)
(export (rename (lambda* lambda)))
(import (rnrs))
(define-syntax lambda*
(syntax-rules ()
((_ a* e* ...)
( lambda*-h a* (let () e* ...)))))
(define-syntax lambda*-h
(syntax-rules ()
((_ () e)
(lambda a* (if (null? a*) e (apply (e) a*))))
((_ (a a* ...) e) (posary-h (a a* ...) e))
((_ (a a* ... . rest) e)
(polyvariadic-h (a a* ... . rest) e))
((_ a* e) (lambda a* e))))
(define-syntax posary-h
(syntax-rules ()
((_ (a a* ...) e)
(letrec
((rec
(case-lambda
(() rec)
((a a* ...) e)
((a a* ... . rest)
(apply (rec a a* ...) rest))
(some (get-more rec some)))))
rec))))
(define-syntax polyvariadic-h
(syntax-rules ()
((_ (a a* ... . rest) e)
(letrec
((rec
(case-lambda
(() rec)
((a a* ... . rest) e)
(some (get-more rec some)))))
rec))))
(define get-more
(lambda (rec some)
(lambda more
(apply rec (append some more))))))

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +1,2 @@
the green potato=la pomme de terre verte
le nouveau type de musique=the new type of music

View File

@@ -0,0 +1,183 @@
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix gndo: <http://d-nb.info/standards/elementset/gnd#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://d-nb.info/gnd/118514768>
a <http://d-nb.info/standards/elementset/gnd#Pseudonym> ;
foaf:page <http://de.wikipedia.org/wiki/Bertolt_Brecht> ;
owl:sameAs <http://dbpedia.org/resource/Bertolt_Brecht>, <http://viaf.org/viaf/2467372>, <http://www.filmportal.de/person/261E2D3A93D54134BF8AB5F21F0B2399> ;
gndo:gndIdentifier "118514768" ;
gndo:oldAuthorityNumber "(DE-588)1022091077", "(DE-588a)118514768", "(DE-588a)141399074", "(DE-588a)139089691", "(DE-588a)141300248", "(DE-588a)136949541", "(DE-588a)134336232", "(DE-588a)12794544X", "(DE-588a)12736630X", "(DE-588a)12722811X", "(DE-588a)127228098", "(DE-588a)127228101" ;
gndo:variantNameForThePerson "Brêcht, Becton", "Brecht, Bert", "Brecht, Bertolʹ", "Brecht, Berthold", "Brecht, Bertholt", "Brecht, Bertold", "Brecht, B.", "Brecht, Eugen Berthold Friedrich", "Brecht, ...", "Brecht-Eisler, ...", "Becht, Bertolt", "Beituo'erte-Bulaixite", "Berchito, B.", "Brechtas, B.", "Brechts, Bertolts", "Brehd, Berd", "Breht, Bertolt", "Brehts, Bertolts", "Breḳhṭ, Bārṭolṭ", "Brekt, Berṭolṭ", "Brekṭ, Berṭōlṭ", "Breḳṭ, Berṭôlṭ", "Breśṭ, Berṭalṭa", "Breṣṭa, Barṭolṭa", "Brišt, Bartūlt", "Brišt, Birtūld", "Brišt, Birtult", "Buchito, Berutorutu", "Bulaixite, Beituo'erte", "Bulaixite, ...", "Burehito, Berutoruto", "Burehito, ...", "B. B.", "Larsen, Berthold", "Mprecht, Mpertolt", "Mprecht, ...", "Pulaihsit'ê, Peit'oĉrht'ê", "Pulaihsit'ê, ...", "Pŭrehit'ŭ, Peŏt'olt'ŭ", "Bŭrehit'ŭ, Beŏt'olt'ŭ", "برشت، برتولد", "브레히트, 베르톨트", "ברכט, ברטולט", "贝·布莱希特", "布莱希特, 贝", "ブレヒト, ベルトルト" ;
gndo:variantNameEntityForThePerson [
gndo:forename "Becton" ;
gndo:surname "Brêcht"
], [
gndo:forename "Bert" ;
gndo:surname "Brecht"
], [
gndo:forename "Bertolʹ" ;
gndo:surname "Brecht"
], [
gndo:forename "Berthold" ;
gndo:surname "Brecht"
], [
gndo:forename "Bertholt" ;
gndo:surname "Brecht"
], [
gndo:forename "Bertold" ;
gndo:surname "Brecht"
], [
gndo:forename "B." ;
gndo:surname "Brecht"
], [
gndo:forename "Eugen Berthold Friedrich" ;
gndo:surname "Brecht"
], [
gndo:forename "..." ;
gndo:surname "Brecht"
], [
gndo:forename "..." ;
gndo:surname "Brecht-Eisler"
], [
gndo:forename "Bertolt" ;
gndo:surname "Becht"
], [ gndo:personalName "Beituo'erte-Bulaixite" ], [
gndo:forename "B." ;
gndo:surname "Berchito"
], [
gndo:forename "B." ;
gndo:surname "Brechtas"
], [
gndo:forename "Bertolts" ;
gndo:surname "Brechts"
], [
gndo:forename "Berd" ;
gndo:surname "Brehd"
], [
gndo:forename "Bertolt" ;
gndo:surname "Breht"
], [
gndo:forename "Bertolts" ;
gndo:surname "Brehts"
], [
gndo:forename "Bārṭolṭ" ;
gndo:surname "Breḳhṭ"
], [
gndo:forename "Berṭolṭ" ;
gndo:surname "Brekt"
], [
gndo:forename "Berṭōlṭ" ;
gndo:surname "Brekṭ"
], [
gndo:forename "Berṭôlṭ" ;
gndo:surname "Breḳṭ"
], [
gndo:forename "Berṭalṭa" ;
gndo:surname "Breśṭ"
], [
gndo:forename "Barṭolṭa" ;
gndo:surname "Breṣṭa"
], [
gndo:forename "Bartūlt" ;
gndo:surname "Brišt"
], [
gndo:forename "Birtūld" ;
gndo:surname "Brišt"
], [
gndo:forename "Birtult" ;
gndo:surname "Brišt"
], [
gndo:forename "Berutorutu" ;
gndo:surname "Buchito"
], [
gndo:forename "Beituo'erte" ;
gndo:surname "Bulaixite"
], [
gndo:forename "..." ;
gndo:surname "Bulaixite"
], [
gndo:forename "Berutoruto" ;
gndo:surname "Burehito"
], [
gndo:forename "..." ;
gndo:surname "Burehito"
], [ gndo:personalName "B. B." ], [
gndo:forename "Berthold" ;
gndo:surname "Larsen"
], [
gndo:forename "Mpertolt" ;
gndo:surname "Mprecht"
], [
gndo:forename "..." ;
gndo:surname "Mprecht"
], [
gndo:forename "Peit'oĉrht'ê" ;
gndo:surname "Pulaihsit'ê"
], [
gndo:forename "..." ;
gndo:surname "Pulaihsit'ê"
], [
gndo:forename "Peŏt'olt'ŭ" ;
gndo:surname "Pŭrehit'ŭ"
], [
gndo:forename "Beŏt'olt'ŭ" ;
gndo:surname "Bŭrehit'ŭ"
], [ gndo:personalName "برشت، برتولد" ], [
gndo:forename "베르톨트" ;
gndo:surname "브레히트"
], [
gndo:forename "ברטולט" ;
gndo:surname "ברכט"
], [ gndo:personalName "贝·布莱希特" ], [
gndo:forename "" ;
gndo:surname "布莱希特"
], [
gndo:forename "ベルトルト" ;
gndo:surname "ブレヒト"
] ;
gndo:preferredNameForThePerson "Brecht, Bertolt" ;
gndo:preferredNameEntityForThePerson [
gndo:forename "Bertolt" ;
gndo:surname "Brecht"
] ;
gndo:familialRelationship <http://d-nb.info/gnd/121608557>, <http://d-nb.info/gnd/119056011>, <http://d-nb.info/gnd/118738348>, <http://d-nb.info/gnd/137070411>, <http://d-nb.info/gnd/118809849>, <http://d-nb.info/gnd/119027615>, <http://d-nb.info/gnd/118940163>, <http://d-nb.info/gnd/118630091>, <http://d-nb.info/gnd/123783283>, <http://d-nb.info/gnd/118940155>, <http://d-nb.info/gnd/110005449>, <http://d-nb.info/gnd/13612495X>, <http://d-nb.info/gnd/123757398>, <http://d-nb.info/gnd/1030496250>, <http://d-nb.info/gnd/1030496366> ;
gndo:professionOrOccupation <http://d-nb.info/gnd/4185053-1>, <http://d-nb.info/gnd/4140241-8>, <http://d-nb.info/gnd/4052154-0>, <http://d-nb.info/gnd/4168391-2>, <http://d-nb.info/gnd/4053309-8>, <http://d-nb.info/gnd/4049050-6>, <http://d-nb.info/gnd/4294338-3> ;
gndo:playedInstrument <http://d-nb.info/gnd/4057587-1> ;
gndo:gndSubjectCategory <http://d-nb.info/standards/vocab/gnd/gnd-sc#12.2p>, <http://d-nb.info/standards/vocab/gnd/gnd-sc#15.1p>, <http://d-nb.info/standards/vocab/gnd/gnd-sc#15.3p> ;
gndo:geographicAreaCode <http://d-nb.info/standards/vocab/gnd/geographic-area-code#XA-DE> ;
gndo:languageCode <http://id.loc.gov/vocabulary/iso639-2/ger> ;
gndo:placeOfBirth <http://d-nb.info/gnd/4003614-5> ;
gndo:placeOfDeath <http://d-nb.info/gnd/4005728-8> ;
gndo:placeOfExile <http://d-nb.info/gnd/4010877-6>, <http://d-nb.info/gnd/4077258-5> ;
gndo:gender <http://d-nb.info/standards/vocab/gnd/Gender#male> ;
gndo:dateOfBirth "1898-02-10"^^xsd:date ;
gndo:dateOfDeath "1956-08-14"^^xsd:date .
<http://d-nb.info/gnd/121608557> gndo:preferredNameForThePerson "Brecht, Berthold Friedrich" .
<http://d-nb.info/gnd/119056011> gndo:preferredNameForThePerson "Banholzer, Paula" .
<http://d-nb.info/gnd/118738348> gndo:preferredNameForThePerson "Neher, Carola" .
<http://d-nb.info/gnd/137070411> gndo:preferredNameForThePerson "Banholzer, Frank" .
<http://d-nb.info/gnd/118809849> gndo:preferredNameForThePerson "Berlau, Ruth" .
<http://d-nb.info/gnd/119027615> gndo:preferredNameForThePerson "Steffin, Margarete" .
<http://d-nb.info/gnd/118940163> gndo:preferredNameForThePerson "Zoff, Marianne" .
<http://d-nb.info/gnd/118630091> gndo:preferredNameForThePerson "Weigel, Helene" .
<http://d-nb.info/gnd/123783283> gndo:preferredNameForThePerson "Reichel, Käthe" .
<http://d-nb.info/gnd/118940155> gndo:preferredNameForThePerson "Hiob, Hanne" .
<http://d-nb.info/gnd/110005449> gndo:preferredNameForThePerson "Brecht, Stefan" .
<http://d-nb.info/gnd/13612495X> gndo:preferredNameForThePerson "Brecht-Schall, Barbara" .
<http://d-nb.info/gnd/123757398> gndo:preferredNameForThePerson "Schall, Ekkehard" .
<http://d-nb.info/gnd/1030496250> gndo:preferredNameForThePerson "Brezing, Joseph Friedrich" .
<http://d-nb.info/gnd/1030496366> gndo:preferredNameForThePerson "Brezing, Friederike" .
<http://d-nb.info/gnd/4185053-1> gndo:preferredNameForTheSubjectHeading "Theaterregisseur" .
<http://d-nb.info/gnd/4140241-8> gndo:preferredNameForTheSubjectHeading "Dramatiker" .
<http://d-nb.info/gnd/4052154-0> gndo:preferredNameForTheSubjectHeading "Schauspieler" .
<http://d-nb.info/gnd/4168391-2> gndo:preferredNameForTheSubjectHeading "Lyriker" .
<http://d-nb.info/gnd/4053309-8> gndo:preferredNameForTheSubjectHeading "Schriftsteller" .
<http://d-nb.info/gnd/4049050-6> gndo:preferredNameForTheSubjectHeading "Regisseur" .
<http://d-nb.info/gnd/4294338-3> gndo:preferredNameForTheSubjectHeading "Drehbuchautor" .
<http://d-nb.info/gnd/4003614-5> gndo:preferredNameForThePlaceOrGeographicName "Augsburg" .
<http://d-nb.info/gnd/4005728-8> gndo:preferredNameForThePlaceOrGeographicName "Berlin" .
<http://d-nb.info/gnd/4010877-6> gndo:preferredNameForThePlaceOrGeographicName "Dänemark" .
<http://d-nb.info/gnd/4077258-5> gndo:preferredNameForThePlaceOrGeographicName "Schweden" .

View File

@@ -0,0 +1,10 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix ex: <http://example.org/stuff/1.0/> .
<http://www.w3.org/TR/rdf-syntax-grammar>
dc:title "RDF/XML Syntax Specification (Revised)" ;
ex:editor [
ex:fullname "Dave Beckett";
ex:homePage <http://purl.org/net/dajobe/>
] .

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<center>
<TableView prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<columns>
<TableColumn prefWidth="114.0" text="Column 1" />
<TableColumn minWidth="0.0" prefWidth="243.0" text="Column 2" />
<TableColumn prefWidth="214.0" text="Column 3" />
</columns>
</TableView>
</center>
<bottom>
<HBox alignment="CENTER_RIGHT" prefWidth="200.0" spacing="10.0" BorderPane.alignment="CENTER">
<children>
<Button mnemonicParsing="false" text="Button">
<HBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</HBox.margin>
</Button>
</children>
</HBox>
</bottom>
</BorderPane>

View File

@@ -0,0 +1,6 @@
<configuration>
<dllmap dll="libsomething">
<dllentry dll="libdifferent.so" name="somefunction" target="differentfunction" />
<dllentry os="solaris,freebsd" dll="libanother.so" name="somefunction" target="differentfunction" />
</dllmap>
</configuration>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
colors="true">
<testsuites>
<testsuite>
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>

13
script/bootstrap Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
set -e
cd "$(dirname "$0")/.."
bundle config --local path vendor/gems
bundle check > /dev/null 2>&1 || bundle install
git submodule init
git submodule sync --quiet
script/fast-submodule-update

View File

@@ -1,4 +1,7 @@
#!/bin/sh
set -e
if [ -d /usr/share/rbenv/shims ]; then
export PATH=/usr/share/rbenv/shims:$PATH
export RBENV_VERSION=2.1.2-github
@@ -11,11 +14,9 @@ ruby -v
bundle -v
set +x
mkdir -p ./vendor/gems
# Clean out any unversioned files
git clean -fd
bundle install --local --path ./vendor/gems
script/bootstrap
bundle exec rake samples
bundle exec rake

View File

@@ -2,19 +2,72 @@
require 'json'
require 'net/http'
require 'optparse'
require 'plist'
require 'set'
require 'thread'
require 'tmpdir'
require 'uri'
require 'yaml'
GRAMMARS_PATH = File.expand_path("../../grammars", __FILE__)
SOURCES_FILE = File.expand_path("../../grammars.yml", __FILE__)
CSONC = File.expand_path("../../node_modules/.bin/csonc", __FILE__)
ROOT = File.expand_path("../..", __FILE__)
GRAMMARS_PATH = File.join(ROOT, "grammars")
SOURCES_FILE = File.join(ROOT, "grammars.yml")
CSONC = File.join(ROOT, "node_modules", ".bin", "csonc")
$options = {
:add => false,
:install => true,
:output => SOURCES_FILE,
:remote => true,
}
class SingleFile
def initialize(path)
@path = path
end
def url
@path
end
def fetch(tmp_dir)
[@path]
end
end
class DirectoryPackage
def self.fetch(dir)
Dir["#{dir}/**/*"].select do |path|
case File.extname(path.downcase)
when '.plist'
path.split('/')[-2] == 'Syntaxes'
when '.tmlanguage'
true
when '.cson', '.json'
path.split('/')[-2] == 'grammars'
else
false
end
end
end
def initialize(directory)
@directory = directory
end
def url
@directory
end
def fetch(tmp_dir)
self.class.fetch(File.join(ROOT, @directory))
end
end
class TarballPackage
def self.fetch(tmp_dir, url)
`curl --silent --location --max-time 10 --output "#{tmp_dir}/archive" "#{url}"`
`curl --silent --location --max-time 30 --output "#{tmp_dir}/archive" "#{url}"`
raise "Failed to fetch GH package: #{url} #{$?.to_s}" unless $?.success?
output = File.join(tmp_dir, 'extracted')
@@ -22,18 +75,7 @@ class TarballPackage
`tar -C "#{output}" -xf "#{tmp_dir}/archive"`
raise "Failed to uncompress tarball: #{tmp_dir}/archive (from #{url}) #{$?.to_s}" unless $?.success?
Dir["#{output}/**/*"].select do |path|
case File.extname(path.downcase)
when '.plist'
path.split('/')[-2] == 'Syntaxes'
when '.tmlanguage'
true
when '.cson'
path.split('/')[-2] == 'grammars'
else
false
end
end
DirectoryPackage.fetch(output)
end
attr_reader :url
@@ -110,13 +152,24 @@ def load_grammar(path)
cson = `"#{CSONC}" "#{path}"`
raise "Failed to convert CSON grammar '#{path}': #{$?.to_s}" unless $?.success?
JSON.parse(cson)
when '.json'
JSON.parse(File.read(path))
else
raise "Invalid document type #{path}"
end
end
def install_grammar(tmp_dir, source, all_scopes)
p = if source.end_with?('.tmLanguage', '.plist')
def load_grammars(tmp_dir, source, all_scopes)
is_url = source.start_with?("http:", "https:")
return [] if is_url && !$options[:remote]
p = if !is_url
if File.directory?(source)
DirectoryPackage.new(source)
else
SingleFile.new(source)
end
elsif source.end_with?('.tmLanguage', '.plist')
SingleGrammar.new(source)
elsif source.start_with?('https://github.com')
GitHubPackage.new(source)
@@ -130,9 +183,7 @@ def install_grammar(tmp_dir, source, all_scopes)
raise "Unsupported source: #{source}" unless p
installed = []
p.fetch(tmp_dir).each do |path|
p.fetch(tmp_dir).map do |path|
grammar = load_grammar(path)
scope = grammar['scopeName']
@@ -142,13 +193,21 @@ def install_grammar(tmp_dir, source, all_scopes)
" Previous package: #{all_scopes[scope]}"
next
end
File.write(File.join(GRAMMARS_PATH, "#{scope}.json"), JSON.pretty_generate(grammar))
all_scopes[scope] = p.url
grammar
end
end
def install_grammars(grammars, path)
installed = []
grammars.each do |grammar|
scope = grammar['scopeName']
File.write(File.join(GRAMMARS_PATH, "#{scope}.json"), JSON.pretty_generate(grammar))
installed << scope
end
$stderr.puts("OK #{p.url} (#{installed.join(', ')})")
$stderr.puts("OK #{path} (#{installed.join(', ')})")
end
def run_thread(queue, all_scopes)
@@ -164,7 +223,8 @@ def run_thread(queue, all_scopes)
dir = "#{tmpdir}/#{index}"
Dir.mkdir(dir)
install_grammar(dir, source, all_scopes)
grammars = load_grammars(dir, source, all_scopes)
install_grammars(grammars, source) if $options[:install]
end
end
end
@@ -175,7 +235,7 @@ def generate_yaml(all_scopes, base)
out[value] << key
end
yaml = yaml.sort.to_h
yaml = Hash[yaml.sort]
yaml.each { |k, v| v.sort! }
yaml
end
@@ -190,9 +250,10 @@ def main(sources)
all_scopes = {}
if ARGV[0] == '--add'
if source = $options[:add]
Dir.mktmpdir do |tmpdir|
install_grammar(tmpdir, ARGV[1], all_scopes)
grammars = load_grammars(tmpdir, source, all_scopes)
install_grammars(grammars, source) if $options[:install]
end
generate_yaml(all_scopes, sources)
else
@@ -210,12 +271,34 @@ def main(sources)
end
end
OptionParser.new do |opts|
opts.banner = "Usage: #{$0} [options]"
opts.on("--add GRAMMAR", "Add a new grammar. GRAMMAR may be a file path or URL.") do |a|
$options[:add] = a
end
opts.on("--[no-]install", "Install grammars into grammars/ directory.") do |i|
$options[:install] = i
end
opts.on("--output FILE", "Write output to FILE. Use - for stdout.") do |o|
$options[:output] = o == "-" ? $stdout : o
end
opts.on("--[no-]remote", "Download remote grammars.") do |r|
$options[:remote] = r
end
end.parse!
sources = File.open(SOURCES_FILE) do |file|
YAML.load(file)
end
yaml = main(sources)
File.write(SOURCES_FILE, YAML.dump(yaml))
$stderr.puts("Done")
if $options[:output].is_a?(IO)
$options[:output].write(YAML.dump(yaml))
else
File.write($options[:output], YAML.dump(yaml))
end

67
script/fast-submodule-update Executable file
View File

@@ -0,0 +1,67 @@
#!/usr/bin/env ruby
require "thread"
ROOT = File.expand_path("../..", __FILE__).freeze
Dir.chdir(ROOT)
SUBMODULES = `git config --list --file .gitmodules`.lines.grep(/\.path=/).map { |line| line.chomp.split("=", 2).last }.freeze
SLOW_SUBMODULES = %w[
vendor/grammars/factor
vendor/grammars/fsharpbinding
vendor/grammars/ioke-outdated
]
class TaskResult < Struct.new(:submodule, :output, :status); end
def run_process(*args)
read, write = IO.pipe
pid = Process.spawn(*args, in: :close, out: write, err: [:child, :out])
write.close
output = read.read
read.close
Process.wait(pid)
[output, $?]
end
def update_submodule(submodule)
output, status = run_process("git", "submodule", "update", "--", submodule)
TaskResult.new(submodule, output, status)
end
def run_thread(submodules, results)
loop do
begin
submodule = submodules.pop(true)
rescue ThreadError
# The queue is empty.
break
end
results.push(update_submodule(submodule))
end
end
submodules = Queue.new
results = Queue.new
# Update the slow submodules first so they can update in the background while
# the fast ones run.
SUBMODULES.partition { |submodule| SLOW_SUBMODULES.include?(submodule) }.flatten.each do |submodule|
submodules.push(submodule)
end
8.times do
Thread.new { run_thread(submodules, results) }
end
success = true
SUBMODULES.each do
result = results.pop
unless result.status.success?
success = false
puts "Error updating #{result.submodule}"
end
puts result.output if result.output =~ /\S/
end
exit success ? 0 : 1

20
script/travis/before_install Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/sh
set -ex
# Fetch all commits/refs needed to run our tests.
git fetch origin master:master v2.0.0:v2.0.0 test/attributes:test/attributes test/master:test/master
script/vendor-deb libicu48 libicu-dev
if ruby -e 'exit RUBY_VERSION >= "2.0" && RUBY_VERSION < "2.1"'; then
# Workaround for https://bugs.ruby-lang.org/issues/8074. We can't use this
# solution on all versions of Ruby due to
# https://github.com/bundler/bundler/pull/3338.
bundle config build.charlock_holmes --with-icu-include=$(pwd)/vendor/debs/include --with-icu-lib=$(pwd)/vendor/debs/lib
else
bundle config build.charlock_holmes --with-icu-dir=$(pwd)/vendor/debs
fi
git submodule init
git submodule sync --quiet
script/fast-submodule-update

13
script/vendor-deb Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
set -ex
cd "$(dirname "$0")/.."
mkdir -p vendor/apt vendor/debs
(cd vendor/apt && apt-get --assume-yes download "$@")
for deb in vendor/apt/*.deb; do
ar p $deb data.tar.gz | tar -vzxC vendor/debs --strip-components=2
done

View File

@@ -1,4 +1,4 @@
require "bundler/setup"
require "test/unit"
require "minitest/autorun"
require "mocha/setup"
require "linguist"

View File

@@ -1,6 +1,6 @@
require_relative "./helper"
class TestBlob < Test::Unit::TestCase
class TestBlob < Minitest::Test
include Linguist
def setup

View File

@@ -1,6 +1,6 @@
require_relative "./helper"
class TestClassifier < Test::Unit::TestCase
class TestClassifier < Minitest::Test
include Linguist
def samples_path

View File

@@ -1,7 +1,6 @@
require 'linguist/file_blob'
require 'test/unit'
require_relative "./helper"
class TestFileBlob < Test::Unit::TestCase
class TestFileBlob < Minitest::Test
def test_extensions
assert_equal [".gitignore"], Linguist::FileBlob.new(".gitignore").extensions
assert_equal [".xml"], Linguist::FileBlob.new("build.xml").extensions

55
test/test_generated.rb Normal file
View File

@@ -0,0 +1,55 @@
require_relative "./helper"
class TestGenerated < Minitest::Test
include Linguist
def samples_path
File.expand_path("../../samples", __FILE__)
end
class DataLoadedError < StandardError; end
def generated_without_loading_data(name)
blob = File.join(samples_path, name)
begin
assert Generated.generated?(blob, lambda { raise DataLoadedError.new }), "#{name} was not recognized as a generated file"
rescue DataLoadedError
assert false, "Data was loaded when calling generated? on #{name}"
end
end
def generated_loading_data(name)
blob = File.join(samples_path, name)
assert_raises(DataLoadedError, "Data wasn't loaded when calling generated? on #{name}") do
Generated.generated?(blob, lambda { raise DataLoadedError.new })
end
end
def test_check_generated_without_loading_data
# Xcode project files
generated_without_loading_data("Binary/MainMenu.nib")
generated_without_loading_data("Dummy/foo.xcworkspacedata")
generated_without_loading_data("Dummy/foo.xcuserstate")
# .NET designer file
generated_without_loading_data("Dummu/foo.designer.cs")
# Composer generated composer.lock file
generated_without_loading_data("JSON/composer.lock")
# Node modules
generated_without_loading_data("Dummy/node_modules/foo.js")
# Godep saved dependencies
generated_without_loading_data("Godeps/Godeps.json")
generated_without_loading_data("Godeps/_workspace/src/github.com/kr/s3/sign.go")
# Generated by Zephir
generated_without_loading_data("C/exception.zep.c")
generated_without_loading_data("C/exception.zep.h")
generated_without_loading_data("PHP/exception.zep.php")
# Minified files
generated_loading_data("JavaScript/jquery-1.6.1.min.js")
end
end

136
test/test_grammars.rb Normal file
View File

@@ -0,0 +1,136 @@
require_relative "./helper"
class TestGrammars < Minitest::Test
ROOT = File.expand_path("../..", __FILE__)
# These grammars have no license but have been grandfathered in. New grammars
# must have a license that allows redistribution.
UNLICENSED_GRAMMARS_WHITELIST = %w[
vendor/grammars/Sublime-Lasso
vendor/grammars/Sublime-REBOL
vendor/grammars/x86-assembly-textmate-bundle
].freeze
def setup
@grammars = YAML.load(File.read(File.join(ROOT, "grammars.yml")))
end
def test_no_duplicate_scopes
scopes = @grammars.values.flatten
duplicates = scopes.group_by { |s| s }.select { |k, v| v.length > 1 }.map(&:first)
assert duplicates.empty?, "The following scopes appear in grammars.yml more than once:\n#{duplicates.sort.join("\n")}"
end
def test_submodules_are_in_sync
# Strip off paths inside the submodule so that just the submodule path remains.
listed_submodules = @grammars.keys.grep(/vendor\/grammars/).map { |source| source[%r{vendor/grammars/[^/]+}] }
nonexistent_submodules = listed_submodules - submodule_paths
unlisted_submodules = submodule_paths - listed_submodules
message = ""
unless nonexistent_submodules.empty?
message << "The following submodules are listed in grammars.yml but don't seem to exist in the repository.\n"
message << "Either add them using `git submodule add` or remove them from grammars.yml.\n"
message << nonexistent_submodules.sort.join("\n")
end
unless unlisted_submodules.empty?
message << "\n" unless message.empty?
message << "The following submodules exist in the repository but aren't listed in grammars.yml.\n"
message << "Either add them to grammars.yml or remove them from the repository using `git rm`.\n"
message << unlisted_submodules.sort.join("\n")
end
assert nonexistent_submodules.empty? && unlisted_submodules.empty?, message
end
def test_local_scopes_are_in_sync
actual = YAML.load(`"#{File.join(ROOT, "script", "convert-grammars")}" --output - --no-install --no-remote`)
assert $?.success?, "script/convert-grammars failed"
# We're not checking remote grammars. That can take a long time and make CI
# flaky if network conditions are poor.
@grammars.delete_if { |k, v| k.start_with?("http:", "https:") }
@grammars.each do |k, v|
assert_equal v, actual[k], "The scopes listed for #{k} in grammars.yml don't match the scopes found in that repository"
end
end
def test_submodules_have_licenses
categories = submodule_paths.group_by do |submodule|
files = Dir[File.join(ROOT, submodule, "*")]
license = files.find { |path| File.basename(path) =~ /\b(un)?licen[cs]e\b/i } || files.find { |path| File.basename(path) =~ /\bcopying\b/i }
if license.nil?
if readme = files.find { |path| File.basename(path) =~ /\Areadme\b/i }
license = readme if File.read(readme) =~ /\blicen[cs]e\b/i
end
end
if license.nil?
:unlicensed
elsif classify_license(license)
:licensed
else
:unrecognized
end
end
unlicensed = categories[:unlicensed] || []
unrecognized = categories[:unrecognized] || []
disallowed_unlicensed = unlicensed - UNLICENSED_GRAMMARS_WHITELIST
disallowed_unrecognized = unrecognized - UNLICENSED_GRAMMARS_WHITELIST
extra_whitelist_entries = UNLICENSED_GRAMMARS_WHITELIST - (unlicensed | unrecognized)
message = ""
if disallowed_unlicensed.any?
message << "The following grammar submodules don't seem to have a license. All grammars must have a license that permits redistribution.\n"
message << disallowed_unlicensed.sort.join("\n")
end
if disallowed_unrecognized.any?
message << "\n\n" unless message.empty?
message << "The following grammar submodules have an unrecognized license. Please update #{__FILE__} to recognize the license.\n"
message << disallowed_unrecognized.sort.join("\n")
end
if extra_whitelist_entries.any?
message << "\n\n" unless message.empty?
message << "The following grammar submodules are listed in UNLICENSED_GRAMMARS_WHITELIST but either have a license (yay!)\n"
message << "or have been removed from the repository. Please remove them from the whitelist.\n"
message << extra_whitelist_entries.sort.join("\n")
end
assert disallowed_unlicensed.empty? && disallowed_unrecognized.empty? && extra_whitelist_entries.empty?, message
end
private
def submodule_paths
@submodule_paths ||= `git config --list --file "#{File.join(ROOT, ".gitmodules")}"`.lines.grep(/\.path=/).map { |line| line.chomp.split("=", 2).last }
end
def classify_license(path)
content = File.read(path)
if content.include?("Apache License") && content.include?("2.0")
"Apache 2.0"
elsif content.include?("GNU") && content =~ /general/i && content =~ /public/i
if content =~ /version 2/i
"GPLv2"
elsif content =~ /version 3/i
"GPLv3"
end
elsif content.include?("GPL") && content.include?("http://www.gnu.org/licenses/gpl.html")
"GPLv3"
elsif content.include?("Creative Commons")
"CC"
elsif content.include?("tidy-license.txt") || content.include?("If not otherwise specified (see below)")
"textmate"
elsif content =~ /^\s*[*-]\s+Redistribution/ || content.include?("Redistributions of source code")
"BSD"
elsif content.include?("Permission is hereby granted") || content =~ /\bMIT\b/
"MIT"
elsif content.include?("unlicense.org")
"unlicense"
elsif content.include?("http://www.wtfpl.net/txt/copying/")
"WTFPL"
end
end
end

View File

@@ -1,6 +1,6 @@
require_relative "./helper"
class TestHeuristcs < Test::Unit::TestCase
class TestHeuristcs < Minitest::Test
include Linguist
def samples_path
@@ -140,6 +140,13 @@ class TestHeuristcs < Test::Unit::TestCase
})
end
def test_cs_by_heuristics
assert_heuristics({
"C#" => all_fixtures("C#", "*.cs"),
"Smalltalk" => all_fixtures("Smalltalk", "*.cs")
})
end
def assert_heuristics(hash)
candidates = hash.keys.map { |l| Language[l] }

View File

@@ -1,6 +1,6 @@
require_relative "./helper"
class TestLanguage < Test::Unit::TestCase
class TestLanguage < Minitest::Test
include Linguist
def test_find_by_alias
@@ -198,7 +198,7 @@ class TestLanguage < Test::Unit::TestCase
def test_find_all_by_extension
Language.all.each do |language|
language.extensions.each do |extension|
assert_include Language.find_by_extension(extension), language
assert_includes Language.find_by_extension(extension), language
end
end
end
@@ -283,7 +283,7 @@ class TestLanguage < Test::Unit::TestCase
end
def test_error_without_name
assert_raise ArgumentError do
assert_raises ArgumentError do
Language.new :name => nil
end
end

View File

@@ -1,6 +1,6 @@
require_relative "./helper"
class TestMD5 < Test::Unit::TestCase
class TestMD5 < Minitest::Test
include Linguist
def test_hexdigest_string
@@ -12,28 +12,28 @@ class TestMD5 < Test::Unit::TestCase
assert_equal "450c1ae043459546517b3dd2f98250f0", MD5.hexdigest(:foo)
assert_equal "f06967526af9d7a512594b0a81b31ede", MD5.hexdigest(:bar)
assert_not_equal MD5.hexdigest("foo"), MD5.hexdigest(:foo)
refute_equal MD5.hexdigest("foo"), MD5.hexdigest(:foo)
end
def test_hexdigest_integer
assert_equal "7605ec17fd7fd213fdcd23cac302cbb4", MD5.hexdigest(1)
assert_equal "097c311a46d330e4e119ba2b1dc0f9a5", MD5.hexdigest(2)
assert_not_equal MD5.hexdigest("1"), MD5.hexdigest(1)
refute_equal MD5.hexdigest("1"), MD5.hexdigest(1)
end
def test_hexdigest_boolean
assert_equal "a690a0615820e2e5c53901d8b8958509", MD5.hexdigest(true)
assert_equal "fca6a9b459e702fa93513c6a8b8c5dfe", MD5.hexdigest(false)
assert_not_equal MD5.hexdigest("true"), MD5.hexdigest(true)
assert_not_equal MD5.hexdigest("false"), MD5.hexdigest(false)
refute_equal MD5.hexdigest("true"), MD5.hexdigest(true)
refute_equal MD5.hexdigest("false"), MD5.hexdigest(false)
end
def test_hexdigest_nil
assert_equal "35589a1cc0b3ca90fc52d0e711c0c434", MD5.hexdigest(nil)
assert_not_equal MD5.hexdigest("nil"), MD5.hexdigest(nil)
refute_equal MD5.hexdigest("nil"), MD5.hexdigest(nil)
end
def test_hexdigest_array
@@ -49,7 +49,7 @@ class TestMD5 < Test::Unit::TestCase
assert_equal "868ee214faf277829a85667cf332749f", MD5.hexdigest({:a => 1})
assert_equal "fa9df957c2b26de6fcca9d062ea8701e", MD5.hexdigest({:b => 2})
assert_not_equal MD5.hexdigest([:b, 2]), MD5.hexdigest({:b => 2})
refute_equal MD5.hexdigest([:b, 2]), MD5.hexdigest({:b => 2})
assert_equal MD5.hexdigest({:b => 2, :a => 1}), MD5.hexdigest({:a => 1, :b => 2})
assert_equal MD5.hexdigest({:c => 3, :b => 2, :a => 1}), MD5.hexdigest({:a => 1, :b => 2, :c => 3})

View File

@@ -1,8 +1,9 @@
require_relative "./helper"
class TestPedantic < Test::Unit::TestCase
class TestPedantic < Minitest::Test
filename = File.expand_path("../../lib/linguist/languages.yml", __FILE__)
LANGUAGES = YAML.load(File.read(filename))
GRAMMARS = YAML.load(File.read(File.expand_path("../../grammars.yml", __FILE__)))
def test_language_names_are_sorted
assert_sorted LANGUAGES.keys
@@ -21,6 +22,16 @@ class TestPedantic < Test::Unit::TestCase
end
end
def test_grammars_are_sorted
assert_sorted GRAMMARS.keys
end
def test_scopes_are_sorted
GRAMMARS.values.each do |scopes|
assert_sorted scopes
end
end
def assert_sorted(list)
list.each_cons(2) do |previous, item|
flunk "#{previous} should come after #{item}" if previous > item

View File

@@ -1,6 +1,6 @@
require_relative "./helper"
class TestRepository < Test::Unit::TestCase
class TestRepository < Minitest::Test
def rugged_repository
@rugged ||= Rugged::Repository.new(File.expand_path("../../.git", __FILE__))
end

View File

@@ -1,7 +1,7 @@
require_relative "./helper"
require "tempfile"
class TestSamples < Test::Unit::TestCase
class TestSamples < Minitest::Test
include Linguist
def test_up_to_date
@@ -43,7 +43,7 @@ class TestSamples < Test::Unit::TestCase
if extnames = Samples.cache['extnames'][name]
extnames.each do |extname|
next if extname == '.script!'
assert options['extensions'].include?(extname), "#{name} has a sample with extension (#{extname}) that isn't explicitly defined in languages.yml"
assert options['extensions'].index { |x| x.end_with? extname }, "#{name} has a sample with extension (#{extname}) that isn't explicitly defined in languages.yml"
end
end

View File

@@ -1,6 +1,6 @@
require_relative "./helper"
class TestShebang < Test::Unit::TestCase
class TestShebang < Minitest::Test
include Linguist
def assert_interpreter(interpreter, body)

View File

@@ -1,6 +1,6 @@
require_relative "./helper"
class TestTokenizer < Test::Unit::TestCase
class TestTokenizer < Minitest::Test
include Linguist
def samples_path

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More