diff --git a/samples/CoffeeScript/empty.coffee b/.gitattributes similarity index 100% rename from samples/CoffeeScript/empty.coffee rename to .gitattributes diff --git a/.gitignore b/.gitignore index 243eb9ab..c0ab5df0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ -Gemfile.lock +/Gemfile.lock .bundle/ -vendor/ benchmark/ lib/linguist/samples.json +/grammars +/node_modules +test/fixtures/ace_modes.json +/vendor/gems/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..aea5068f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,659 @@ +[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"] + path = vendor/grammars/powershell + url = https://github.com/SublimeText/PowerShell +[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/honzabrecka/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/desktop.tmbundle"] + path = vendor/grammars/desktop.tmbundle + url = https://github.com/Mailaender/desktop.tmbundle.git +[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/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/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 +[submodule "vendor/grammars/liquid.tmbundle"] + path = vendor/grammars/liquid.tmbundle + url = https://github.com/bastilian/validcode-textmate-bundles +[submodule "vendor/grammars/ats.sublime"] + path = vendor/grammars/ats.sublime + url = https://github.com/steinwaywhw/ats-mode-sublimetext +[submodule "vendor/grammars/Modelica"] + path = vendor/grammars/Modelica + url = https://github.com/BorisChumichev/modelicaSublimeTextPackage +[submodule "vendor/grammars/sublime-apl"] + path = vendor/grammars/sublime-apl + url = https://github.com/StoneCypher/sublime-apl +[submodule "vendor/grammars/CLIPS-sublime"] + path = vendor/grammars/CLIPS-sublime + url = https://github.com/psicomante/CLIPS-sublime +[submodule "vendor/grammars/Creole"] + path = vendor/grammars/Creole + url = https://github.com/Siddley/Creole +[submodule "vendor/grammars/GDScript-sublime"] + path = vendor/grammars/GDScript-sublime + url = https://github.com/beefsack/GDScript-sublime +[submodule "vendor/grammars/sublime-golo"] + path = vendor/grammars/sublime-golo + url = https://github.com/TypeUnsafe/sublime-golo +[submodule "vendor/grammars/JSyntax"] + path = vendor/grammars/JSyntax + url = https://github.com/bcj/JSyntax +[submodule "vendor/grammars/TXL"] + path = vendor/grammars/TXL + url = https://github.com/MikeHoffert/Sublime-Text-TXL-syntax +[submodule "vendor/grammars/G-Code"] + path = vendor/grammars/G-Code + url = https://github.com/robotmaster/sublime-text-syntax-highlighting +[submodule "vendor/grammars/grace-tmbundle"] + path = vendor/grammars/grace-tmbundle + url = https://github.com/zmthy/grace-tmbundle +[submodule "vendor/grammars/sublime-text-ox"] + path = vendor/grammars/sublime-text-ox + url = https://github.com/andreashetland/sublime-text-ox +[submodule "vendor/grammars/AutoHotkey"] + path = vendor/grammars/AutoHotkey + url = https://github.com/ahkscript/SublimeAutoHotkey +[submodule "vendor/grammars/ec.tmbundle"] + path = vendor/grammars/ec.tmbundle + url = https://github.com/ecere/ec.tmbundle +[submodule "vendor/grammars/InnoSetup"] + path = vendor/grammars/InnoSetup + url = https://github.com/idleberg/InnoSetup-Sublime-Text +[submodule "vendor/grammars/gap-tmbundle"] + path = vendor/grammars/gap-tmbundle + url = https://github.com/dhowden/gap-tmbundle +[submodule "vendor/grammars/SublimePapyrus"] + path = vendor/grammars/SublimePapyrus + url = https://github.com/Kapiainen/SublimePapyrus +[submodule "vendor/grammars/sublime-spintools"] + path = vendor/grammars/sublime-spintools + url = https://github.com/bitbased/sublime-spintools +[submodule "vendor/grammars/PogoScript.tmbundle"] + path = vendor/grammars/PogoScript.tmbundle + url = https://github.com/featurist/PogoScript.tmbundle +[submodule "vendor/grammars/sublime-opal"] + path = vendor/grammars/sublime-opal + url = https://github.com/artifactz/sublime-opal +[submodule "vendor/grammars/mediawiki.tmbundle"] + path = vendor/grammars/mediawiki.tmbundle + url = https://github.com/textmate/mediawiki.tmbundle +[submodule "vendor/grammars/SublimeClarion"] + path = vendor/grammars/SublimeClarion + url = https://github.com/fushnisoft/SublimeClarion +[submodule "vendor/grammars/oracle.tmbundle"] + path = vendor/grammars/oracle.tmbundle + url = https://github.com/mulander/oracle.tmbundle.git +[submodule "vendor/grammars/BrightScript.tmbundle"] + path = vendor/grammars/BrightScript.tmbundle + url = https://github.com/cmink/BrightScript.tmbundle +[submodule "vendor/grammars/Stylus"] + path = vendor/grammars/Stylus + url = https://github.com/billymoon/Stylus +[submodule "vendor/grammars/asciidoc.tmbundle"] + path = vendor/grammars/asciidoc.tmbundle + url = https://github.com/zuckschwerdt/asciidoc.tmbundle +[submodule "vendor/grammars/sublime-text-pig-latin"] + path = vendor/grammars/sublime-text-pig-latin + url = https://github.com/goblindegook/sublime-text-pig-latin +[submodule "vendor/grammars/Lean.tmbundle"] + path = vendor/grammars/Lean.tmbundle + url = https://github.com/leanprover/Lean.tmbundle +[submodule "vendor/grammars/ampl"] + path = vendor/grammars/ampl + url = https://github.com/ampl/sublime-ampl +[submodule "vendor/grammars/openscad.tmbundle"] + path = vendor/grammars/openscad.tmbundle + url = https://github.com/tbuser/openscad.tmbundle +[submodule "vendor/grammars/sublime-varnish"] + path = vendor/grammars/sublime-varnish + url = https://github.com/brandonwamboldt/sublime-varnish +[submodule "vendor/grammars/xc.tmbundle"] + path = vendor/grammars/xc.tmbundle + url = https://github.com/graymalkin/xc.tmbundle +[submodule "vendor/grammars/perl.tmbundle"] + path = vendor/grammars/perl.tmbundle + url = https://github.com/textmate/perl.tmbundle +[submodule "vendor/grammars/sublime-netlinx"] + path = vendor/grammars/sublime-netlinx + url = https://github.com/amclain/sublime-netlinx +[submodule "vendor/grammars/Sublime-Red"] + path = vendor/grammars/Sublime-Red + url = https://github.com/Oldes/Sublime-Red +[submodule "vendor/grammars/jflex.tmbundle"] + path = vendor/grammars/jflex.tmbundle + url = https://github.com/jflex-de/jflex.tmbundle.git diff --git a/.travis.yml b/.travis.yml index 1f4c61e5..52540b57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,11 @@ -before_install: - - git fetch origin master:master - - git fetch origin v2.0.0:v2.0.0 - - sudo apt-get install libicu-dev -y +before_install: script/travis/before_install rvm: - 1.9.3 - 2.0.0 - - 2.1.1 + - 2.1 + - 2.2 notifications: disabled: true +git: + submodules: false +cache: bundler diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..ebae203c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,81 @@ +# Contributing + +Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great. The majority of contributions won't need to touch any Ruby code at all. + +## Adding a language + +We try only to add languages once they have some usage on GitHub. In most cases we prefer that languages be in use in hundreds of repositories before supporting them in Linguist. + +To add support for a new language: + +0. Add an entry for your language to [`languages.yml`][languages]. +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 the correct subdirectory. +0. Open a pull request, linking to a [GitHub search result](https://github.com/search?utf8=%E2%9C%93&q=extension%3Aboot+NOT+nothack&type=Code&ref=searchresults) showing in-the-wild usage. + +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! + +## Fixing a misclassified language + +Most languages are detected by their file extension defined in [languages.yml][languages]. For disambiguating between files with common extensions, linguist applies some [heuristics](/lib/linguist/heuristics.rb) and a [statistical classifier](lib/linguist/classifier.rb). This process can help differentiate between, for example, `.h` files which could be either C, C++, or Obj-C. + +Misclassifications can often be solved by either adding a new filename or extension for the language or adding more [samples][samples] to make the classifier smarter. + +## Fixing syntax highlighting + +Syntax highlighting in GitHub is performed using TextMate-compatible grammars. These are the same grammars that TextMate, Sublime Text and Atom use. Every language in [languages.yml][languages] is mapped to its corresponding TM `scope`. This scope will be used when picking up a grammar for highlighting. + +Assuming your code is being detected as the right language, in most cases this is due to a bug in the language grammar rather than a bug in Linguist. [`grammars.yml`][grammars] lists all the grammars we use for syntax highlighting on github.com. Find the one corresponding to your code's programming language and submit a bug report upstream. If you can, try to reproduce the highlighting problem in the text editor that the grammar is designed for (TextMate, Sublime Text, or Atom) and include that information in your bug report. + +You can also try to fix the bug yourself and submit a Pull Request. [TextMate's documentation](http://manual.macromates.com/en/language_grammars) offers a good introduction on how to work with TextMate-compatible grammars. You can test grammars using [Lightshow](https://github-lightshow.herokuapp.com). + +Once the bug has been fixed upstream, we'll pick it up for GitHub in the next release of Linguist. + +## Testing + +For development you are going to want to checkout out the source. To get it, clone the repo and run [Bundler](http://gembundler.com/) to install its dependencies. + + git clone https://github.com/github/linguist.git + cd linguist/ + script/bootstrap + +To run the tests: + + bundle exec rake test + +Sometimes getting the tests running can be too much work, especially if you don't have much Ruby experience. It's okay: be lazy and let our build bot [Travis](http://travis-ci.org/#!/github/linguist) run the tests for you. Just open a pull request and the bot will start cranking away. + +Here's our current build status: [![Build Status](https://secure.travis-ci.org/github/linguist.png?branch=master)](http://travis-ci.org/github/linguist) + +## Releasing + +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: `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`, [like this](https://github.com/github/linguist/commit/8d2ea90a5ba3b2fe6e1508b7155aa4632eea2985). +0. Make a PR to github/linguist, [like this](https://github.com/github/linguist/pull/1238). +0. Build a local gem: `bundle exec rake build_gem` +0. Test the gem: + 0. Bump the Gemfile and Gemfile.lock versions for an app which relies on this gem + 0. Install the new gem locally + 0. Test behavior locally, branch deploy, whatever needs to happen +0. Merge github/linguist PR +0. Tag and push: `git tag vx.xx.xx; git push --tags` +0. Push to rubygems.org -- `gem push github-linguist-3.0.0.gem` + +[grammars]: /grammars.yml +[languages]: /lib/linguist/languages.yml +[samples]: /samples +[new-issue]: https://github.com/github/linguist/issues/new diff --git a/Gemfile b/Gemfile index 851fabc2..c5f2cc3b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,4 @@ source 'https://rubygems.org' -gemspec +gemspec :name => "github-linguist" +gemspec :name => "github-linguist-grammars" +gem 'byebug' if RUBY_VERSION >= '2.0' diff --git a/LICENSE b/LICENSE index f09a7d0a..c0a52444 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2011-2014 GitHub, Inc. +Copyright (c) 2011-2015 GitHub, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/README.md b/README.md index a51dc919..c7d77101 100644 --- a/README.md +++ b/README.md @@ -1,151 +1,112 @@ # Linguist -We use this library at GitHub to detect blob languages, highlight code, ignore binary files, suppress generated files in diffs, and generate language breakdown graphs. +[issues]: https://github.com/github/linguist/issues +[new-issue]: https://github.com/github/linguist/issues/new -## Features +This library is used on GitHub.com to detect blob languages, ignore binary or vendored files, suppress generated files in diffs, and generate language breakdown graphs. -### Language detection +See [Troubleshooting](#troubleshooting) and [`CONTRIBUTING.md`](/CONTRIBUTING.md) before filing an issue or creating a pull request. -Linguist defines a list of all languages known to GitHub in a [yaml file](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). In order for a file to be highlighted, a language and a lexer must be defined there. +## Troubleshooting -Most languages are detected by their file extension. For disambiguating between files with common extensions, we first apply some common-sense heuristics to pick out obvious languages. After that, we use a -[statistical -classifier](https://github.com/github/linguist/blob/master/lib/linguist/classifier.rb). -This process can help us tell the difference between, for example, `.h` files which could be either C, C++, or Obj-C. +### My repository is detected as the wrong language -```ruby +![language stats bar](https://cloud.githubusercontent.com/assets/173/5562290/48e24654-8ddf-11e4-8fe7-735b0ce3a0d3.png) -Linguist::FileBlob.new("lib/linguist.rb").language.name #=> "Ruby" +The Language stats bar is built by aggregating the languages of each file in that repository. If it is reporting a language that you don't expect: -Linguist::FileBlob.new("bin/linguist").language.name #=> "Ruby" +0. Click on the name of the language in the stats bar to see a list of the files that are identified as that language. +0. If you see files that you didn't write, consider moving the files into one of the [paths for vendored code](https://github.com/github/linguist/blob/master/lib/linguist/vendor.yml), or use the [manual overrides](#overrides) feature to ignore them. +0. If the files are being misclassified, search for [open issues][issues] to see if anyone else has already reported the issue. Any information you an add, especially links to public repositories, is helpful. +0. If there are no reported issues of this misclassification, [open an issue][new-issue] and include a link to the repository or a sample of the code that is being misclassified. + +## Overrides + +Linguist supports a number of different custom overrides strategies for language definitions and vendored paths. + +### Using gitattributes + +Add a `.gitattributes` file to your project and use standard git-style path matchers for the files you want to override to set `linguist-documentation`, `linguist-language`, and `linguist-vendored`. `.gitattributes` will be used to determine language statistics, but will not be used to syntax highlight files. To manually set syntax highlighting, use [Vim or Emacs modelines](#using-emacs-and-vim-modelines). + +``` +$ cat .gitattributes +*.rb linguist-language=Java ``` -See [lib/linguist/language.rb](https://github.com/github/linguist/blob/master/lib/linguist/language.rb) and [lib/linguist/languages.yml](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). +Checking code you didn't write, such as JavaScript libraries, into your git repo is a common practice, but this often inflates your project's language stats and may even cause your project to be labeled as another language. By default, Linguist treats all of the paths defined in [lib/linguist/vendor.yml](https://github.com/github/linguist/blob/master/lib/linguist/vendor.yml) as vendored and therefore doesn't include them in the language statistics for a repository. Vendored files are also hidden by default in diffs on github.com. -### Syntax Highlighting +Use the `linguist-vendored` attribute to vendor or un-vendor paths. Please note, overriding the vendored (or un-vendored) status of a file only affects the language statistics for the repository and not the behavior in diffs on github.com. -The actual syntax highlighting is handled by our Pygments wrapper, [pygments.rb](https://github.com/tmm1/pygments.rb). It also provides a [Lexer abstraction](https://github.com/tmm1/pygments.rb/blob/master/lib/pygments/lexer.rb) that determines which highlighter should be used on a file. - -### Stats - -The Language stats bar that you see on every repository is built by aggregating the languages of each file in that repository. The top language in the graph determines the project's primary language. - -The repository stats API, accessed through `#languages`, can be used on a directory: - -```ruby -project = Linguist::Repository.from_directory(".") -project.language.name #=> "Ruby" -project.languages #=> { "Ruby" => 0.98, "Shell" => 0.02 } +``` +$ cat .gitattributes +special-vendored-path/* linguist-vendored +jquery.js linguist-vendored=false ``` -These stats are also printed out by the `linguist` binary. You can use the +Similar to vendored files, Linguist excludes documentation files from your project's language stats. (Unlike vendored files, documentation files are displayed in diffs on github.com.) [lib/linguist/documentation.yml](lib/linguist/documentation.yml) lists common documentation paths and excludes them from the language statistics for your repository. + +Use the `linguist-documentation` attribute to mark or unmark paths as documentation. + +``` +$ cat .gitattributes +project-docs/* linguist-documentation +docs/formatter.rb linguist-documentation=false +``` + +### Using Emacs and Vim modelines + +Alternatively, you can use Vim and Emacs style modelines to set the language for a single file. Modelines can be placed anywhere within a file and are respected when determining how to syntax-highlight a file on GitHub.com + +``` +Vim +vim: set filetype=prolog: +vim: set ft=cpp: + +Emacs +-*- mode: php;-*- +``` + +## Usage + +Install the gem: + +``` +$ gem install github-linguist +``` + +Then use it in your application: + +```ruby +require 'rugged' +require 'linguist' + +repo = Rugged::Repository.new('.') +project = Linguist::Repository.new(repo, repo.head.target_id) +project.language #=> "Ruby" +project.languages #=> { "Ruby" => 119387 } +``` + +These stats are also printed out by the `linguist` executable. You can use the `--breakdown` flag, and the binary will also output the breakdown of files by language. -You can try running `linguist` on the `lib/` directory in this repository itself: +You can try running `linguist` on the root directory in this repository itself: - $ bundle exec linguist lib/ --breakdown - - 100.00% Ruby - - Ruby: - linguist/blob_helper.rb - linguist/classifier.rb - linguist/file_blob.rb - linguist/generated.rb - linguist/heuristics.rb - linguist/language.rb - linguist/md5.rb - linguist/repository.rb - linguist/samples.rb - linguist/tokenizer.rb - linguist.rb - -#### Ignore vendored files - -Checking other code into your git repo is a common practice. But this often inflates your project's language stats and may even cause your project to be labeled as another language. We are able to identify some of these files and directories and exclude them. - -```ruby -Linguist::FileBlob.new("vendor/plugins/foo.rb").vendored? # => true ``` +$ bundle exec linguist --breakdown -See [Linguist::BlobHelper#vendored?](https://github.com/github/linguist/blob/master/lib/linguist/blob_helper.rb) and [lib/linguist/vendor.yml](https://github.com/github/linguist/blob/master/lib/linguist/vendor.yml). +100.00% Ruby -#### Generated file detection - -Not all plain text files are true source files. Generated files like minified js and compiled CoffeeScript can be detected and excluded from language stats. As an extra bonus, these files are suppressed in diffs. - -```ruby -Linguist::FileBlob.new("underscore.min.js").generated? # => true +Ruby: +Gemfile +Rakefile +bin/linguist +github-linguist.gemspec +lib/linguist.rb +… ``` -See [Linguist::Generated#generated?](https://github.com/github/linguist/blob/master/lib/linguist/generated.rb). - -## Installation - -github.com is usually running the latest version of the `github-linguist` gem that is released on [RubyGems.org](http://rubygems.org/gems/github-linguist). - -But for development you are going to want to checkout out the source. To get it, clone the repo and run [Bundler](http://gembundler.com/) to install its dependencies. - - git clone https://github.com/github/linguist.git - cd linguist/ - bundle install - -To run the tests: - - bundle exec rake test - ## Contributing -The majority of contributions won't need to touch any Ruby code at all. The [master language list](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml) is just a YAML configuration file. +Please check out our [contributing guidelines](CONTRIBUTING.md). -We try to only add languages once they have some usage on GitHub, so please note in-the-wild usage examples in your pull request. - -Almost all bug fixes or new language additions should come with some additional code samples. Just drop them under [`samples/`](https://github.com/github/linguist/tree/master/samples) in the correct subdirectory and our test suite will automatically test them. In most cases you shouldn't need to add any new assertions. - -### A note on language extensions - -Linguist has a number of methods available to it for identifying the language of a particular file. The initial lookup is based upon the extension of the file, possible file extensions are defined in an array called `extensions`. Take a look at this example for example for `Perl`: - -``` -Perl: - type: programming - ace_mode: perl - color: "#0298c3" - extensions: - - .pl - - .PL - - .perl - - .ph - - .plx - - .pm - - .pod - - .psgi - interpreters: - - perl -``` -Any of the extensions defined are valid but the first in this array should be the most popular. - -### Testing - -Sometimes getting the tests running can be too much work, especially if you don't have much Ruby experience. It's okay: be lazy and let our build bot [Travis](http://travis-ci.org/#!/github/linguist) run the tests for you. Just open a pull request and the bot will start cranking away. - -Here's our current build status, which is hopefully green: [![Build Status](https://secure.travis-ci.org/github/linguist.png?branch=master)](http://travis-ci.org/github/linguist) - -### Releasing - -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. 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). - 0. Make a PR to github/linguist. For example, [#1238](https://github.com/github/linguist/pull/1238). - 0. Build a local gem: `gem build github-linguist.gemspec` - 0. Testing: - 0. Bump the Gemfile and Gemfile.lock versions for an app which relies on this gem - 0. Install the new gem locally - 0. Test behavior locally, branch deploy, whatever needs to happen - 0. Merge github/linguist PR - 0. Tag and push: `git tag vx.xx.xx; git push --tags` - 0. Push to rubygems.org -- `gem push github-linguist-3.0.0.gem` +## diff --git a/Rakefile b/Rakefile index 60e3565a..b38486c0 100644 --- a/Rakefile +++ b/Rakefile @@ -1,15 +1,16 @@ -require 'json' +require 'bundler/setup' require 'rake/clean' require 'rake/testtask' require 'yaml' -require 'pry' +require 'yajl' +require 'open-uri' task :default => :test Rake::TestTask.new -# Extend test task to check for samples -task :test => :check_samples +# Extend test task to check for samples and fetch latest Ace modes +task :test => [:check_samples, :fetch_ace_modes] desc "Check that we have samples.json generated" task :check_samples do @@ -18,21 +19,39 @@ task :check_samples do end end +desc "Fetch the latest Ace modes from its GitHub repository" +task :fetch_ace_modes do + ACE_FIXTURE_PATH = File.join('test', 'fixtures', 'ace_modes.json') + + File.delete(ACE_FIXTURE_PATH) if File.exist?(ACE_FIXTURE_PATH) + + begin + ace_github_modes = open("https://api.github.com/repos/ajaxorg/ace/contents/lib/ace/mode").read + File.write(ACE_FIXTURE_PATH, ace_github_modes) + rescue OpenURI::HTTPError, SocketError + # no internet? no problem. + end +end + task :samples do require 'linguist/samples' - require 'yajl' - data = Linguist::Samples.data - json = Yajl::Encoder.encode(data, :pretty => true) - File.open('lib/linguist/samples.json', 'w') { |io| io.write json } + json = Yajl.dump(Linguist::Samples.data, :pretty => true) + File.write 'lib/linguist/samples.json', json end task :build_gem => :samples do languages = YAML.load_file("lib/linguist/languages.yml") - File.write("lib/linguist/languages.json", JSON.dump(languages)) + File.write("lib/linguist/languages.json", Yajl.dump(languages)) `gem build github-linguist.gemspec` File.delete("lib/linguist/languages.json") end +task :build_grammars_gem do + rm_rf "grammars" + sh "script/convert-grammars" + sh "gem", "build", "github-linguist-grammars.gemspec" +end + namespace :benchmark do benchmark_path = "benchmark/results" @@ -72,11 +91,11 @@ namespace :benchmark do reference_file = ENV["REFERENCE"] candidate_file = ENV["CANDIDATE"] - reference = JSON.parse(File.read(reference_file)) + reference = Yajl.load(File.read(reference_file)) reference_counts = Hash.new(0) reference.each { |filename, language| reference_counts[language] += 1 } - candidate = JSON.parse(File.read(candidate_file)) + candidate = Yajl.load(File.read(candidate_file)) candidate_counts = Hash.new(0) candidate.each { |filename, language| candidate_counts[language] += 1 } @@ -126,14 +145,12 @@ namespace :classifier do def each_public_gist require 'open-uri' - require 'json' - url = "https://api.github.com/gists/public" loop do resp = open(url) url = resp.meta['link'][/<([^>]+)>; rel="next"/, 1] - gists = JSON.parse(resp.read) + gists = Yajl.load(resp.read) for gist in gists for filename, attrs in gist['files'] diff --git a/bin/linguist b/bin/linguist index 6ac8f0a7..d1d9c306 100755 --- a/bin/linguist +++ b/bin/linguist @@ -2,10 +2,8 @@ # linguist — detect language type for a file, or, given a directory, determine language breakdown # usage: linguist [<--breakdown>] - -require 'linguist/file_blob' -require 'linguist/language' -require 'linguist/repository' +# +require 'linguist' require 'rugged' path = ARGV[0] || Dir.pwd diff --git a/github-linguist-grammars.gemspec b/github-linguist-grammars.gemspec new file mode 100644 index 00000000..429b3ff1 --- /dev/null +++ b/github-linguist-grammars.gemspec @@ -0,0 +1,14 @@ +require File.expand_path('../lib/linguist/version', __FILE__) + +Gem::Specification.new do |s| + s.name = 'github-linguist-grammars' + s.version = Linguist::VERSION + s.summary = "Language grammars for use with github-linguist" + + s.authors = "GitHub" + s.homepage = "https://github.com/github/linguist" + + s.files = ['lib/linguist/grammars.rb'] + Dir['grammars/*'] + + s.add_development_dependency 'plist', '~>3.1' +end diff --git a/github-linguist.gemspec b/github-linguist.gemspec index 382b6cae..3f3a0853 100644 --- a/github-linguist.gemspec +++ b/github-linguist.gemspec @@ -10,18 +10,18 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/github/linguist" s.license = "MIT" - s.files = Dir['lib/**/*'] + s.files = Dir['lib/**/*'] - ['lib/linguist/grammars.rb'] s.executables << 'linguist' s.add_dependency 'charlock_holmes', '~> 0.7.3' - s.add_dependency 'escape_utils', '~> 1.0.1' - s.add_dependency 'mime-types', '~> 1.19' - s.add_dependency 'pygments.rb', '~> 0.6.0' - s.add_dependency 'rugged', '~> 0.21.0' + s.add_dependency 'escape_utils', '~> 1.1.0' + s.add_dependency 'mime-types', '>= 1.19' + s.add_dependency 'rugged', '~> 0.23.0b1' - s.add_development_dependency 'json' + s.add_development_dependency 'minitest', '>= 5.0' s.add_development_dependency 'mocha' s.add_development_dependency 'pry' s.add_development_dependency 'rake' s.add_development_dependency 'yajl-ruby' + s.add_development_dependency 'color-proximity', '~> 0.2.1' end diff --git a/grammars.yml b/grammars.yml new file mode 100644 index 00000000..46f2fd5d --- /dev/null +++ b/grammars.yml @@ -0,0 +1,550 @@ +--- +http://svn.edgewall.org/repos/genshi/contrib/textmate/Genshi.tmbundle/Syntaxes/Markup%20Template%20%28XML%29.tmLanguage: +- text.xml.genshi +http://svn.textmate.org/trunk/Review/Bundles/BlitzMax.tmbundle: +- source.blitzmax +http://svn.textmate.org/trunk/Review/Bundles/Cython.tmbundle: +- source.cython +http://svn.textmate.org/trunk/Review/Bundles/Forth.tmbundle: +- source.forth +http://svn.textmate.org/trunk/Review/Bundles/Parrot.tmbundle: +- source.parrot.pir +http://svn.textmate.org/trunk/Review/Bundles/SecondLife%20LSL.tmbundle: +- source.lsl +http://svn.textmate.org/trunk/Review/Bundles/VHDL.tmbundle: +- source.vhdl +http://svn.textmate.org/trunk/Review/Bundles/XQuery.tmbundle: +- source.xquery +https://bitbucket.org/Clams/sublimesystemverilog/get/default.tar.gz: +- source.systemverilog +- source.ucfconstraints +https://fan.googlecode.com/hg-history/Build%201.0.55/adm/tools/textmate/Fan.tmbundle/Syntaxes/Fan.tmLanguage: +- source.fan +vendor/grammars/Agda.tmbundle: +- source.agda +vendor/grammars/Alloy.tmbundle: +- source.alloy +vendor/grammars/AutoHotkey/: +- source.ahk +vendor/grammars/BrightScript.tmbundle/: +- source.brightauthorproject +- source.brightscript +vendor/grammars/CLIPS-sublime: +- source.clips +vendor/grammars/ColdFusion: +- source.cfscript +- source.cfscript.cfc +- text.cfml.basic +- text.html.cfm +vendor/grammars/Creole: +- text.html.creole +vendor/grammars/Docker.tmbundle: +- source.dockerfile +vendor/grammars/Elm.tmLanguage: +- source.elm +vendor/grammars/G-Code/: +- source.LS +- source.MCPOST +- source.MOD +- source.apt +- source.gcode +vendor/grammars/GDScript-sublime/: +- source.gdscript +vendor/grammars/Handlebars: +- text.html.handlebars +vendor/grammars/IDL-Syntax: +- source.webidl +vendor/grammars/InnoSetup/: +- source.inno +vendor/grammars/Isabelle.tmbundle: +- source.isabelle.root +- source.isabelle.theory +vendor/grammars/JSyntax/: +- source.j +vendor/grammars/Julia.tmbundle: +- source.julia +vendor/grammars/Lean.tmbundle: +- source.lean +vendor/grammars/LiveScript.tmbundle: +- source.livescript +vendor/grammars/Modelica/: +- source.modelica +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/PogoScript.tmbundle/: +- source.pogoscript +vendor/grammars/RDoc.tmbundle: +- text.rdoc +vendor/grammars/Racket: +- source.racket +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/Stylus/: +- source.stylus +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-Red: +- source.red +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/SublimeClarion/: +- source.clarion +vendor/grammars/SublimePapyrus/: +- source.compiled-papyrus +- source.papyrus +- source.papyrus-assembly +vendor/grammars/SublimeXtend: +- source.xtend +vendor/grammars/TXL/: +- source.txl +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/ampl: +- source.ampl +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/asciidoc.tmbundle/: +- text.html.asciidoc +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/ats.sublime: +- source.ats +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/desktop.tmbundle: +- source.desktop +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/ec.tmbundle/: +- source.c.ec +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/gap-tmbundle/: +- source.gap +vendor/grammars/gettext.tmbundle: +- source.po +vendor/grammars/gnuplot-tmbundle: +- source.gnuplot +vendor/grammars/go-tmbundle: +- source.go +vendor/grammars/grace-tmbundle/: +- source.grace +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 +vendor/grammars/html.tmbundle: +- text.html.basic +vendor/grammars/idl.tmbundle: +- source.idl +- source.idl-dlm +- text.idl-idldoc +vendor/grammars/ini.tmbundle: +- source.ini +vendor/grammars/io.tmbundle: +- source.io +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 +vendor/grammars/javadoc.tmbundle: +- text.html.javadoc +vendor/grammars/javascript-objective-j.tmbundle: +- source.js.objj +vendor/grammars/jflex.tmbundle: +- source.jflex +vendor/grammars/jquery-tmbundle: +- source.js.jquery +vendor/grammars/json.tmbundle: +- source.json +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 +vendor/grammars/less.tmbundle: +- source.css.less +vendor/grammars/lilypond.tmbundle: +- source.lilypond +vendor/grammars/liquid.tmbundle: +- text.html.liquid +vendor/grammars/lisp.tmbundle: +- source.lisp +vendor/grammars/llvm.tmbundle: +- source.llvm +vendor/grammars/logtalk.tmbundle: +- source.logtalk +vendor/grammars/lua.tmbundle: +- source.lua +vendor/grammars/make.tmbundle: +- source.makefile +vendor/grammars/mako-tmbundle: +- text.html.mako +vendor/grammars/mathematica-tmbundle: +- source.mathematica +vendor/grammars/matlab.tmbundle: +- source.matlab +- source.octave +vendor/grammars/maven.tmbundle: +- text.xml.pom +vendor/grammars/mediawiki.tmbundle/: +- text.html.mediawiki +vendor/grammars/mercury-tmlanguage: +- source.mercury +vendor/grammars/monkey.tmbundle: +- source.monkey +vendor/grammars/moonscript-tmbundle: +- source.moonscript +vendor/grammars/nemerle.tmbundle: +- source.nemerle +vendor/grammars/nesC.tmbundle: +- source.nesc +vendor/grammars/ninja.tmbundle: +- source.ninja +vendor/grammars/objective-c.tmbundle: +- source.objc +- source.objc++ +- source.objc.platform +- source.strings +vendor/grammars/ocaml.tmbundle: +- source.camlp4.ocaml +- source.ocaml +- source.ocamllex +- source.ocamlyacc +vendor/grammars/ooc.tmbundle: +- source.ooc +vendor/grammars/opa.tmbundle: +- source.opa +vendor/grammars/openscad.tmbundle/: +- source.scad +vendor/grammars/oracle.tmbundle: +- source.plsql.oracle +vendor/grammars/oz-tmbundle/Syntaxes/Oz.tmLanguage: +- source.oz +vendor/grammars/pascal.tmbundle: +- source.pascal +vendor/grammars/perl.tmbundle/: +- source.perl +- source.perl.6 +vendor/grammars/php-smarty.tmbundle: +- source.smarty +vendor/grammars/php.tmbundle: +- text.html.php +vendor/grammars/pike-textmate: +- source.pike +vendor/grammars/postscript.tmbundle: +- source.postscript +vendor/grammars/powershell: +- source.powershell +vendor/grammars/processing.tmbundle: +- source.processing +vendor/grammars/prolog.tmbundle: +- source.prolog +vendor/grammars/protobuf-tmbundle: +- source.protobuf +vendor/grammars/puppet-textmate-bundle: +- source.puppet +vendor/grammars/python-django.tmbundle: +- source.python.django +- text.html.django +vendor/grammars/r.tmbundle: +- source.r +- text.tex.latex.rd +vendor/grammars/restructuredtext.tmbundle: +- text.restructuredtext +vendor/grammars/ruby-haml.tmbundle: +- text.haml +vendor/grammars/ruby-on-rails-tmbundle: +- source.js.erb.rails +- source.ruby.rails +- source.ruby.rails.rjs +- source.sql.ruby +- text.html.erb.rails +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 +vendor/grammars/scilab.tmbundle: +- source.scilab +vendor/grammars/smalltalk-tmbundle: +- source.smalltalk +vendor/grammars/sql.tmbundle: +- source.sql +vendor/grammars/standard-ml.tmbundle: +- source.cm +- source.ml +vendor/grammars/sublime-MuPAD: +- source.mupad +vendor/grammars/sublime-apl/: +- source.apl +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-golo/: +- source.golo +vendor/grammars/sublime-idris: +- source.idris +vendor/grammars/sublime-mask: +- source.mask +vendor/grammars/sublime-netlinx: +- source.netlinx +- source.netlinx.erb +vendor/grammars/sublime-nginx: +- source.nginx +vendor/grammars/sublime-nix: +- source.nix +vendor/grammars/sublime-opal/: +- source.opal +- source.opalsysdefs +vendor/grammars/sublime-robot-plugin: +- text.robot +vendor/grammars/sublime-rust: +- source.rust +vendor/grammars/sublime-sourcepawn: +- source.sp +vendor/grammars/sublime-spintools/: +- source.regexp.spin +- source.spin +vendor/grammars/sublime-tea: +- source.tea +vendor/grammars/sublime-text-ox/: +- source.ox +vendor/grammars/sublime-text-pig-latin/: +- source.pig_latin +vendor/grammars/sublime-varnish: +- source.varnish.vcl +vendor/grammars/sublime_cobol: +- source.acucobol +- source.cobol +- source.jcl +- 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 +vendor/grammars/tcl.tmbundle: +- source.tcl +- text.html.tcl +vendor/grammars/text.tmbundle: +- text.plain +vendor/grammars/textile.tmbundle: +- text.html.textile +vendor/grammars/textmate.tmbundle: +- source.regexp.oniguruma +- source.tm-properties +vendor/grammars/thrift.tmbundle: +- source.thrift +vendor/grammars/toml.tmbundle: +- source.toml +vendor/grammars/turtle.tmbundle: +- source.sparql +- source.turtle +vendor/grammars/verilog.tmbundle: +- source.verilog +vendor/grammars/x86-assembly-textmate-bundle: +- source.asm.x86 +vendor/grammars/xc.tmbundle/: +- source.xc +vendor/grammars/xml.tmbundle: +- text.xml +- text.xml.xsl +vendor/grammars/zephir-sublime: +- source.php.zephir diff --git a/lib/linguist.rb b/lib/linguist.rb index 3714b5a0..3929efb9 100644 --- a/lib/linguist.rb +++ b/lib/linguist.rb @@ -4,4 +4,17 @@ require 'linguist/heuristics' require 'linguist/language' require 'linguist/repository' require 'linguist/samples' +require 'linguist/shebang' require 'linguist/version' + +class << Linguist + attr_accessor :instrumenter + + def instrument(*args, &bk) + if instrumenter + instrumenter.instrument(*args, &bk) + else + yield if block_given? + end + end +end diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb index 84aa2281..01a567e0 100644 --- a/lib/linguist/blob_helper.rb +++ b/lib/linguist/blob_helper.rb @@ -2,7 +2,6 @@ require 'linguist/generated' require 'charlock_holmes' require 'escape_utils' require 'mime/types' -require 'pygments' require 'yaml' module Linguist @@ -100,7 +99,7 @@ module Linguist elsif name.nil? "attachment" else - "attachment; filename=#{EscapeUtils.escape_url(File.basename(name))}" + "attachment; filename=#{EscapeUtils.escape_url(name)}" end end @@ -147,6 +146,13 @@ module Linguist end end + # Public: Is the blob empty? + # + # Return true or false + def empty? + data.nil? || data == "" + end + # Public: Is the blob text? # # Return true or false @@ -193,10 +199,6 @@ module Linguist # Public: Is the blob safe to colorize? # - # We use Pygments for syntax highlighting blobs. Pygments - # can be too slow for very large blobs or for certain - # corner-case blobs. - # # Return true or false def safe_to_colorize? !large? && text? && !high_ratio_of_long_lines? @@ -204,9 +206,6 @@ module Linguist # Internal: Does the blob have a ratio of long lines? # - # These types of files are usually going to make Pygments.rb - # angry if we try to colorize them. - # # Return true or false def high_ratio_of_long_lines? return false if loc == 0 @@ -234,7 +233,22 @@ module Linguist # # Return true or false def vendored? - name =~ VendoredRegexp ? true : false + path =~ VendoredRegexp ? true : false + end + + documentation_paths = YAML.load_file(File.expand_path("../documentation.yml", __FILE__)) + DocumentationRegexp = Regexp.new(documentation_paths.join('|')) + + # Public: Is the blob in a documentation directory? + # + # Documentation files are ignored by language statistics. + # + # See "documentation.yml" for a list of documentation conventions that match + # this pattern. + # + # Return true or false + def documentation? + path =~ DocumentationRegexp ? true : false end # Public: Get each line of data @@ -302,7 +316,7 @@ module Linguist # # Return true or false def generated? - @_generated ||= Generated.generated?(name, lambda { data }) + @_generated ||= Generated.generated?(path, lambda { data }) end # Public: Detects the Language of the blob. @@ -314,23 +328,19 @@ module Linguist @language ||= Language.detect(self) end - # Internal: Get the lexer of the blob. - # - # Returns a Lexer. - def lexer - language ? language.lexer : Pygments::Lexer.find_by_name('Text only') + # Internal: Get the TextMate compatible scope for the blob + def tm_scope + language && language.tm_scope end - # Public: Highlight syntax of blob - # - # options - A Hash of options (defaults to {}) - # - # Returns html String - def colorize(options = {}) - return unless safe_to_colorize? - options[:options] ||= {} - options[:options][:encoding] ||= encoding - lexer.highlight(data, options) + DETECTABLE_TYPES = [:programming, :markup].freeze + + # Internal: Should this blob be included in repository language statistics? + def include_in_language_stats? + !vendored? && + !documentation? && + !generated? && + language && DETECTABLE_TYPES.include?(language.type) end end end diff --git a/lib/linguist/classifier.rb b/lib/linguist/classifier.rb index 5370bdd8..89a0df2f 100644 --- a/lib/linguist/classifier.rb +++ b/lib/linguist/classifier.rb @@ -3,6 +3,25 @@ require 'linguist/tokenizer' module Linguist # Language bayesian classifier. class Classifier + # Public: Use the classifier to detect language of the blob. + # + # blob - An object that quacks like a blob. + # possible_languages - Array of Language objects + # + # Examples + # + # Classifier.call(FileBlob.new("path/to/file"), [ + # Language["Ruby"], Language["Python"] + # ]) + # + # Returns an Array of Language objects, most probable first. + def self.call(blob, possible_languages) + language_names = possible_languages.map(&:name) + classify(Samples.cache, blob.data, language_names).map do |name, _| + Language[name] # Return the actual Language objects + end + end + # Public: Train classifier that data is a certain language. # # db - Hash classifier database object diff --git a/lib/linguist/documentation.yml b/lib/linguist/documentation.yml new file mode 100644 index 00000000..6e06329f --- /dev/null +++ b/lib/linguist/documentation.yml @@ -0,0 +1,23 @@ +# Documentation files and directories are excluded from language +# statistics. +# +# Lines in this file are Regexps that are matched against the file +# pathname. +# +# Please add additional test coverage to +# `test/test_blob.rb#test_documentation` if you make any changes. + +## Documentation directories ## + +- ^docs?/ +- (^|/)[Dd]ocumentation/ +- (^|/)javadoc/ +- ^man/ + +## Documentation files ## + +- (^|/)CONTRIBUTING(\.|$) +- (^|/)COPYING(\.|$) +- (^|/)INSTALL(\.|$) +- (^|/)LICEN[CS]E(\.|$) +- (^|/)README(\.|$) diff --git a/lib/linguist/file_blob.rb b/lib/linguist/file_blob.rb index bc475023..20d87bb0 100644 --- a/lib/linguist/file_blob.rb +++ b/lib/linguist/file_blob.rb @@ -3,7 +3,7 @@ require 'linguist/blob_helper' module Linguist # A FileBlob is a wrapper around a File object to make it quack # like a Grit::Blob. It provides the basic interface: `name`, - # `data`, and `size`. + # `data`, `path` and `size`. class FileBlob include BlobHelper @@ -14,57 +14,70 @@ module Linguist # # Returns a FileBlob. def initialize(path, base_path = nil) - @path = path - @name = base_path ? path.sub("#{base_path}/", '') : path + @fullpath = path + @path = base_path ? path.sub("#{base_path}/", '') : path end # Public: Filename # # Examples # - # FileBlob.new("/path/to/linguist/lib/linguist.rb").name + # FileBlob.new("/path/to/linguist/lib/linguist.rb").path # # => "/path/to/linguist/lib/linguist.rb" # # FileBlob.new("/path/to/linguist/lib/linguist.rb", - # "/path/to/linguist").name + # "/path/to/linguist").path # # => "lib/linguist.rb" # # Returns a String - attr_reader :name + attr_reader :path # Public: Read file permissions # # Returns a String like '100644' def mode - File.stat(@path).mode.to_s(8) + File.stat(@fullpath).mode.to_s(8) + end + + # Public: File name + # + # Returns a String + def name + File.basename(@fullpath) end # Public: Read file contents. # # Returns a String. def data - File.read(@path) + File.read(@fullpath) end # Public: Get byte size # # Returns an Integer. def size - File.size(@path) + File.size(@fullpath) end # Public: Get file extension. # # Returns a String. def extension - # File.extname returns nil if the filename is an extension. - extension = File.extname(name) - basename = File.basename(name) - # Checks if the filename is an extension. - if extension.empty? && basename[0] == "." - basename - else - extension + extensions.last || "" + end + + # Public: Return an array of the file extensions + # + # >> Linguist::FileBlob.new("app/views/things/index.html.erb").extensions + # => [".html.erb", ".erb"] + # + # Returns an Array + def extensions + basename, *segments = name.downcase.split(".") + + segments.map.with_index do |segment, index| + "." + segments[index..-1].join(".") end end end diff --git a/lib/linguist/generated.rb b/lib/linguist/generated.rb index 0f911c45..b53ae155 100644 --- a/lib/linguist/generated.rb +++ b/lib/linguist/generated.rb @@ -51,26 +51,28 @@ module Linguist # # Return true or false def generated? - name == 'Gemfile.lock' || - 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? + xcode_file? || + generated_net_designer_file? || + composer_lock? || + node_modules? || + godeps? || + generated_by_zephir? || + minified_files? || + source_map? || + compiled_coffeescript? || + generated_parser? || + generated_net_docfile? || + generated_postscript? || + compiled_cython_file? || + generated_protocol_buffer_go? || + generated_protocol_buffer? || + generated_jni_header? || + vcr_cassette? end # Internal: Is the blob an Xcode file? # - # Generated if the file extension is an Xcode + # Generated if the file extension is an Xcode # file extension. # # Returns true of false. @@ -95,6 +97,20 @@ module Linguist end end + # Internal: Is the blob a generated source map? + # + # Source Maps usually have .css.map or .js.map extensions. In case they + # are not following the name convention, detect them based on the content. + # + # Returns true or false. + def source_map? + return false unless extname.downcase == '.map' + + name =~ /(\.css|\.js)\.map$/i || # Name convention + lines[0] =~ /^{"version":\d+,/ || # Revision 2 and later begin with the version number + lines[0] =~ /^\/\*\* Begin line maps\. \*\*\/{/ # Revision 1 begins with a magic comment + end + # Internal: Is the blob of JS generated by CoffeeScript? # # CoffeeScript is meant to output JS that would be difficult to @@ -203,6 +219,13 @@ module Linguist creator.include?("ImageMagick") end + def generated_protocol_buffer_go? + return false unless extname == '.go' + return false unless lines.count > 1 + + return lines[0].include?("Code generated by protoc-gen-go") + end + # Internal: Is the blob a C++, Java or Python source file generated by the # Protocol Buffer compiler? # @@ -263,6 +286,18 @@ module Linguist # VCR Cassettes have "recorded_with: VCR" in the second last line. return lines[-2].include?("recorded_with: VCR") end + + # Internal: Is this a compiled C/C++ file from Cython? + # + # Cython-compiled C/C++ files typically contain: + # /* Generated by Cython x.x.x on ... */ + # on the first line. + # + # Return true or false + def compiled_cython_file? + return false unless ['.c', '.cpp'].include? extname + return false unless lines.count > 1 + return lines[0].include?("Generated by Cython") + end end end - diff --git a/lib/linguist/grammars.rb b/lib/linguist/grammars.rb new file mode 100644 index 00000000..f6468280 --- /dev/null +++ b/lib/linguist/grammars.rb @@ -0,0 +1,13 @@ +# Note: This file is included in the github-linguist-grammars gem, not the +# github-linguist gem. + +module Linguist + module Grammars + # Get the path to the directory containing the language grammar JSON files. + # + # Returns a String. + def self.path + File.expand_path("../../../grammars", __FILE__) + end + end +end diff --git a/lib/linguist/heuristics.rb b/lib/linguist/heuristics.rb index 21764b34..e196e8bf 100644 --- a/lib/linguist/heuristics.rb +++ b/lib/linguist/heuristics.rb @@ -1,82 +1,293 @@ module Linguist # A collection of simple heuristics that can be used to better analyze languages. class Heuristics - ACTIVE = true + # Public: Use heuristics to detect language of the blob. + # + # blob - An object that quacks like a blob. + # possible_languages - Array of Language objects + # + # Examples + # + # Heuristics.call(FileBlob.new("path/to/file"), [ + # Language["Ruby"], Language["Python"] + # ]) + # + # Returns an Array of languages, or empty if none matched or were inconclusive. + def self.call(blob, languages) + data = blob.data - # Public: Given an array of String language names, - # apply heuristics against the given data and return an array - # of matching languages, or nil. + @heuristics.each do |heuristic| + return Array(heuristic.call(data)) if heuristic.matches?(languages) + end + + [] # No heuristics matched + end + + # Internal: Define a new heuristic. # - # data - Array of tokens or String data to analyze. - # languages - Array of language name Strings to restrict to. + # languages - String names of languages to disambiguate. + # heuristic - Block which takes data as an argument and returns a Language or nil. # - # Returns an array of Languages or [] - def self.find_by_heuristics(data, languages) - if active? - if languages.all? { |l| ["Perl", "Prolog"].include?(l) } - result = disambiguate_pl(data, languages) - end - if languages.all? { |l| ["ECL", "Prolog"].include?(l) } - result = disambiguate_ecl(data, languages) - end - if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) } - result = disambiguate_cl(data, languages) - end - return result + # Examples + # + # disambiguate "Perl", "Prolog" do |data| + # if data.include?("use strict") + # Language["Perl"] + # elsif /^[^#]+:-/.match(data) + # Language["Prolog"] + # end + # end + # + def self.disambiguate(*languages, &heuristic) + @heuristics << new(languages, &heuristic) + end + + # Internal: Array of defined heuristics + @heuristics = [] + + # Internal + def initialize(languages, &heuristic) + @languages = languages + @heuristic = heuristic + end + + # Internal: Check if this heuristic matches the candidate languages. + def matches?(candidates) + candidates.any? && candidates.all? { |l| @languages.include?(l.name) } + end + + # Internal: Perform the heuristic + def call(data) + @heuristic.call(data) + end + + # Common heuristics + ObjectiveCRegex = /^[ \t]*@(interface|class|protocol|property|end|synchronised|selector|implementation)\b/ + + disambiguate "BitBake", "BlitzBasic" do |data| + if /^\s*; /.match(data) || data.include?("End Function") + Language["BlitzBasic"] + elsif /^\s*(# |include|require)\b/.match(data) + Language["BitBake"] end end - # .h extensions are ambiguous between C, C++, and Objective-C. - # We want to shortcut look for Objective-C _and_ now C++ too! - # - # Returns an array of Languages or [] - def self.disambiguate_c(data, languages) - matches = [] - matches << Language["Objective-C"] if data.include?("@interface") - matches << Language["C++"] if data.include?("#include ") - matches + 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 - def self.disambiguate_pl(data, languages) - matches = [] - matches << Language["Prolog"] if data.include?(":-") - matches << Language["Perl"] if data.include?("use strict") - matches + disambiguate "Objective-C", "C++", "C" do |data| + if ObjectiveCRegex.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*")) - matches << Language["XML"] + disambiguate "ECL", "Prolog" do |data| + if /^[^#]+:-/.match(data) + Language["Prolog"] + elsif data.include?(":=") + Language["ECL"] + end + end + + disambiguate "IDL", "Prolog", "INI", "QMake" do |data| + if /^[^#]+:-/.match(data) + Language["Prolog"] + elsif data.include?("last_client=") + Language["INI"] + elsif data.include?("HEADERS") && data.include?("SOURCES") + Language["QMake"] + elsif /^\s*function[ \w,]+$/.match(data) + Language["IDL"] + 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 - matches << Language["TypeScript"] + Language["Scilab"] end - matches end - def self.disambiguate_cl(data, languages) - matches = [] - matches << Language["Common Lisp"] if data.include?("(defun ") - matches << Language["OpenCL"] if /\/\* |\/\/ |^\}/.match(data) - matches + disambiguate "Common Lisp", "OpenCL", "Cool" do |data| + if data.include?("(defun ") + Language["Common Lisp"] + elsif /^class/x.match(data) + Language["Cool"] + elsif /\/\* |\/\/ |^\}/.match(data) + Language["OpenCL"] + end end - def self.disambiguate_r(data, languages) - matches = [] - matches << Language["Rebol"] if /\bRebol\b/i.match(data) - matches << Language["R"] if data.include?("<-") - matches + disambiguate "Hack", "PHP" do |data| + if data.include?(" |case\s+(\S+\s)+of/.match(data) + Language["Standard ML"] + end + end + + disambiguate "NL", "NewLisp" do |data| + if /^g3 /.match(data) + Language["NL"] + else + Language["NewLisp"] + end + end + + disambiguate "Rust", "RenderScript" do |data| + if data.include?("^(use |fn |mod |pub |macro_rules|impl|#!?\[)") + Language["Rust"] + elsif /#include|#pragma\s+(rs|version)|__attribute__/.match(data) + Language["RenderScript"] + end end end end diff --git a/lib/linguist/language.rb b/lib/linguist/language.rb index 9c53eb9d..da02b110 100644 --- a/lib/linguist/language.rb +++ b/lib/linguist/language.rb @@ -1,8 +1,7 @@ require 'escape_utils' -require 'pygments' require 'yaml' begin - require 'json' + require 'yajl' rescue LoadError end @@ -11,6 +10,9 @@ require 'linguist/heuristics' require 'linguist/samples' require 'linguist/file_blob' require 'linguist/blob_helper' +require 'linguist/strategy/filename' +require 'linguist/strategy/modeline' +require 'linguist/shebang' module Linguist # Language names that are recognizable by GitHub. Defined languages @@ -30,13 +32,6 @@ module Linguist # Valid Languages types TYPES = [:data, :markup, :programming, :prose] - # Names of non-programming languages that we will still detect - # - # Returns an array - def self.detectable_markup - ["CSS", "Less", "Sass", "SCSS", "Stylus", "TeX"] - end - # Detect languages by a specific type # # type - A symbol that exists within TYPES @@ -62,7 +57,7 @@ module Linguist end # Language name index - @index[language.name] = @name_index[language.name] = language + @index[language.name.downcase] = @name_index[language.name.downcase] = language language.aliases.each do |name| # All Language aliases should be unique. Raise if there is a duplicate. @@ -70,7 +65,7 @@ module Linguist raise ArgumentError, "Duplicate alias: #{name}" end - @index[name] = @alias_index[name] = language + @index[name.downcase] = @alias_index[name.downcase] = language end language.extensions.each do |extension| @@ -78,7 +73,7 @@ module Linguist raise ArgumentError, "Extension is missing a '.': #{extension.inspect}" end - @extension_index[extension] << language + @extension_index[extension.downcase] << language end language.interpreters.each do |interpreter| @@ -92,6 +87,14 @@ module Linguist language end + STRATEGIES = [ + Linguist::Strategy::Modeline, + Linguist::Shebang, + Linguist::Strategy::Filename, + Linguist::Heuristics, + Linguist::Classifier + ] + # Public: Detects the Language of the blob. # # blob - an object that includes the Linguist `BlobHelper` interface; @@ -99,50 +102,33 @@ module Linguist # # Returns Language or nil. def self.detect(blob) - name = blob.name.to_s + # Bail early if the blob is binary or empty. + return nil if blob.likely_binary? || blob.binary? || blob.empty? - # Check if the blob is possibly binary and bail early; this is a cheap - # test that uses the extension name to guess a binary binary mime type. - # - # We'll perform a more comprehensive test later which actually involves - # looking for binary characters in the blob - return nil if blob.likely_binary? || blob.binary? + Linguist.instrument("linguist.detection", :blob => blob) do + # Call each strategy until one candidate is returned. + languages = [] + returning_strategy = nil - # A bit of an elegant hack. If the file is executable but extensionless, - # append a "magic" extension so it can be classified with other - # languages that have shebang scripts. - extension = FileBlob.new(name).extension - if extension.empty? && blob.mode && (blob.mode.to_i(8) & 05) == 05 - name += ".script!" - end - - # First try to find languages that match based on filename. - possible_languages = find_by_filename(name) - - # If there is more than one possible language with that extension (or no - # extension at all, in the case of extensionless scripts), we need to continue - # our detection work - if possible_languages.length > 1 - data = blob.data - possible_language_names = possible_languages.map(&:name) - - # Don't bother with binary contents or an empty file - if data.nil? || data == "" - nil - # Check if there's a shebang line and use that as authoritative - elsif (result = find_by_shebang(data)) && !result.empty? - result.first - # No shebang. Still more work to do. Try to find it with our heuristics. - elsif (determined = Heuristics.find_by_heuristics(data, possible_language_names)) && !determined.empty? - determined.first - # Lastly, fall back to the probabilistic classifier. - elsif classified = Classifier.classify(Samples.cache, data, possible_language_names).first - # Return the actual Language object based of the string language name (i.e., first element of `#classify`) - Language[classified[0]] + STRATEGIES.each do |strategy| + returning_strategy = strategy + candidates = Linguist.instrument("linguist.strategy", :blob => blob, :strategy => strategy, :candidates => languages) do + strategy.call(blob, languages) + end + if candidates.size == 1 + languages = candidates + break + elsif candidates.size > 1 + # More than one candidate was found, pass them to the next strategy. + languages = candidates + else + # No candidates, try the next strategy + end end - else - # Simplest and most common case, we can just return the one match based on extension - possible_languages.first + + Linguist.instrument("linguist.detected", :blob => blob, :strategy => returning_strategy, :language => languages.first) + + languages.first end end @@ -164,7 +150,7 @@ module Linguist # # Returns the Language or nil if none was found. def self.find_by_name(name) - @name_index[name] + name && @name_index[name.downcase] end # Public: Look up Language by one of its aliases. @@ -176,9 +162,9 @@ module Linguist # Language.find_by_alias('cpp') # # => # # - # Returns the Lexer or nil if none was found. + # Returns the Language or nil if none was found. def self.find_by_alias(name) - @alias_index[name] + name && @alias_index[name.downcase] end # Public: Look up Languages by filename. @@ -193,27 +179,54 @@ module Linguist # Returns all matching Languages or [] if none were found. def self.find_by_filename(filename) basename = File.basename(filename) - extname = FileBlob.new(filename).extension - langs = @filename_index[basename] + - @extension_index[extname] - langs.compact.uniq + + # find the first extension with language definitions + extname = FileBlob.new(filename).extensions.detect do |e| + !@extension_index[e].empty? + end + + (@filename_index[basename] + @extension_index[extname]).compact.uniq end - # Public: Look up Languages by shebang line. + # Public: Look up Languages by file extension. # - # data - Array of tokens or String data to analyze. + # extname - The extension String. # # Examples # - # Language.find_by_shebang("#!/bin/bash\ndate;") + # Language.find_by_extension('.rb') + # # => [#] + # + # Language.find_by_extension('rb') + # # => [#] + # + # Returns all matching Languages or [] if none were found. + def self.find_by_extension(extname) + extname = ".#{extname}" unless extname.start_with?(".") + @extension_index[extname.downcase] + end + + # DEPRECATED + def self.find_by_shebang(data) + @interpreter_index[Shebang.interpreter(data)] + end + + # Public: Look up Languages by interpreter. + # + # interpreter - String of interpreter name + # + # Examples + # + # Language.find_by_interpreter("bash") # # => [#] # # Returns the matching Language - def self.find_by_shebang(data) - @interpreter_index[Linguist.interpreter_from_shebang(data)] + def self.find_by_interpreter(interpreter) + @interpreter_index[interpreter] end - # Public: Look up Language by its name or lexer. + + # Public: Look up Language by its name. # # name - The String name of the Language # @@ -227,7 +240,7 @@ module Linguist # # Returns the Language or nil if none was found. def self.[](name) - @index[name] + name && @index[name.downcase] end # Public: A List of popular languages @@ -237,7 +250,7 @@ module Linguist # # This list is configured in "popular.yml". # - # Returns an Array of Lexers. + # Returns an Array of Languages. def self.popular @popular ||= all.select(&:popular?).sort_by { |lang| lang.name.downcase } end @@ -249,7 +262,7 @@ module Linguist # # This list is created from all the languages not listed in "popular.yml". # - # Returns an Array of Lexers. + # Returns an Array of Languages. def self.unpopular @unpopular ||= all.select(&:unpopular?).sort_by { |lang| lang.name.downcase } end @@ -263,8 +276,12 @@ module Linguist # Public: A List of languages compatible with Ace. # + # TODO: Remove this method in a 5.x release. Every language now needs an ace_mode + # key, so this function isn't doing anything unique anymore. + # # Returns an Array of Languages. def self.ace_modes + warn "This method will be deprecated in a future 5.x release. Every language now has an `ace_mode` set." @ace_modes ||= all.select(&:ace_mode).sort_by { |lang| lang.name.downcase } end @@ -286,9 +303,16 @@ module Linguist # Set aliases @aliases = [default_alias_name] + (attributes[:aliases] || []) - # Lookup Lexer object - @lexer = Pygments::Lexer.find_by_name(attributes[:lexer] || name) || - raise(ArgumentError, "#{@name} is missing lexer") + # Load the TextMate scope name or try to guess one + @tm_scope = attributes[:tm_scope] || begin + context = case @type + when :data, :markup, :prose + 'text' + when :programming, nil + 'source' + end + "#{context}.#{@name.downcase}" + end @ace_mode = attributes[:ace_mode] @wrap = attributes[:wrap] || false @@ -358,10 +382,10 @@ module Linguist # Returns the name String attr_reader :search_term - # Public: Get Lexer + # Public: Get the name of a TextMate-compatible scope # - # Returns the Lexer - attr_reader :lexer + # Returns the scope + attr_reader :tm_scope # Public: Get Ace mode # @@ -406,11 +430,6 @@ module Linguist # Returns the extensions Array attr_reader :filenames - # Public: Return all possible extensions for language - def all_extensions - (extensions + [primary_extension]).uniq - end - # Deprecated: Get primary extension # # Defaults to the first extension but can be overridden @@ -478,16 +497,6 @@ module Linguist @searchable end - # Public: Highlight syntax of text - # - # text - String of code to be highlighted - # options - A Hash of options (defaults to {}) - # - # Returns html String - def colorize(text, options = {}) - lexer.highlight(text, options) - end - # Public: Return name as String representation def to_s name @@ -518,8 +527,8 @@ module Linguist languages_yml = File.expand_path("../languages.yml", __FILE__) languages_json = File.expand_path("../languages.json", __FILE__) - if File.exist?(languages_json) && defined?(JSON) - languages = JSON.load(File.read(languages_json)) + if File.exist?(languages_json) && defined?(Yajl) + languages = Yajl.load(File.read(languages_json)) else languages = YAML.load_file(languages_yml) end @@ -531,8 +540,8 @@ module Linguist if extnames = extensions[name] extnames.each do |extname| - if !options['extensions'].include?(extname) - warn "#{name} has a sample with extension (#{extname}) that isn't explicitly defined in languages.yml" unless extname == '.script!' + if !options['extensions'].index { |x| x.downcase.end_with? extname.downcase } + warn "#{name} has a sample with extension (#{extname.downcase}) that isn't explicitly defined in languages.yml" unless extname == '.script!' options['extensions'] << extname end end @@ -563,13 +572,13 @@ module Linguist :color => options['color'], :type => options['type'], :aliases => options['aliases'], - :lexer => options['lexer'], + :tm_scope => options['tm_scope'], :ace_mode => options['ace_mode'], :wrap => options['wrap'], :group_name => options['group'], - :searchable => options.key?('searchable') ? options['searchable'] : true, + :searchable => options.fetch('searchable', true), :search_term => options['search_term'], - :extensions => [options['extensions'].first] + options['extensions'][1..-1].sort, + :extensions => Array(options['extensions']), :interpreters => options['interpreters'].sort, :filenames => options['filenames'], :popular => popular.include?(name) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index d90f6a39..d3457a17 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1,13 +1,11 @@ # Defines all Languages known to GitHub. # -# All languages have an associated lexer for syntax highlighting. It -# defaults to name.downcase, which covers most cases. -# # type - Either data, programming, markup, prose, or nil -# lexer - An explicit lexer String (defaults to name) # aliases - An Array of additional aliases (implicitly # includes name.downcase) -# ace_mode - A String name of Ace Mode (if available) +# ace_mode - A String name of the Ace Mode used for highlighting whenever +# a file is edited. This must match one of the filenames in http://git.io/3XO_Cg. +# Use "text" if a mode does not exist. # wrap - Boolean wrap to enable line wrapping (default: false) # extensions - An Array of associated extensions (the first one is # considered the primary extension) @@ -16,6 +14,12 @@ # search_term - Deprecated: Some languages maybe indexed under a # different alias. Avoid defining new exceptions. # color - CSS hex color to represent the language. +# tm_scope - The TextMate scope that represents this programming +# language. This should match one of the scopes listed in +# the grammars.yml file. Use "none" if there is no grammar +# for this language. +# group - Name of the parent language. Languages in a group are counted +# in the statistics as the parent language. # # Any additions or modifications (even trivial) should have corresponding # test change in `test/test_blob.rb`. @@ -24,38 +28,51 @@ ABAP: type: programming - lexer: ABAP + color: "#E8274B" extensions: - .abap + ace_mode: abap AGS Script: type: programming - lexer: C++ color: "#B9D9FF" aliases: - ags extensions: - .asc - .ash + tm_scope: source.c++ + ace_mode: c_cpp + +AMPL: + type: programming + color: "#E6EFBB" + extensions: + - .ampl + tm_scope: source.ampl + ace_mode: text ANTLR: type: programming color: "#9DC3FF" - lexer: ANTLR extensions: - .g4 + ace_mode: text APL: type: programming - color: "#8a0707" + color: "#5A8164" extensions: - .apl + - .dyalog + tm_scope: source.apl + ace_mode: text ASP: type: programming color: "#6a40fd" - lexer: aspx-vb search_term: aspx-vb + tm_scope: text.html.asp aliases: - aspx - aspx-vb @@ -67,61 +84,83 @@ ASP: - .asmx - .aspx - .axd + ace_mode: text ATS: type: programming color: "#1ac620" - lexer: OCaml aliases: - ats2 extensions: - .dats - - .atxt - .hats - .sats + tm_scope: source.ats + ace_mode: ocaml ActionScript: type: programming - lexer: ActionScript 3 - color: "#e3491a" + tm_scope: source.actionscript.3 + color: "#882B0F" search_term: as3 aliases: + - actionscript 3 + - actionscript3 - as3 extensions: - .as + ace_mode: actionscript Ada: type: programming color: "#02f88c" extensions: - .adb + - .ada - .ads + aliases: + - ada95 + - ada2005 + ace_mode: ada Agda: type: programming - color: "#467C91" + color: "#315665" extensions: - .agda + ace_mode: text Alloy: type: programming # 'modeling' would be more appropiate - lexer: Alloy color: "#cc5c24" extensions: - .als + ace_mode: text + +Ant Build System: + type: data + tm_scope: text.xml.ant + filenames: + - ant.xml + - build.xml + ace_mode: xml ApacheConf: type: markup aliases: + - aconf - apache extensions: - .apacheconf + tm_scope: source.apache-config + ace_mode: apache_conf Apex: type: programming - lexer: Java extensions: - .cls + tm_scope: source.java + ace_mode: java AppleScript: type: programming @@ -132,75 +171,87 @@ AppleScript: - .scpt interpreters: - osascript + ace_mode: applescript Arc: type: programming - color: "#ca2afe" - lexer: Text only + color: "#aa2afe" extensions: - .arc + tm_scope: none + ace_mode: text Arduino: type: programming color: "#bd79d1" - lexer: C++ extensions: - .ino + tm_scope: source.c++ + ace_mode: c_cpp AsciiDoc: type: prose - lexer: Text only ace_mode: asciidoc wrap: true extensions: - .asciidoc - .adoc - .asc + tm_scope: text.html.asciidoc AspectJ: type: programming - lexer: AspectJ - color: "#1957b0" + color: "#a957b0" extensions: - .aj + tm_scope: none + ace_mode: text Assembly: type: programming - lexer: NASM - color: "#a67219" + color: "#6E4C13" search_term: nasm aliases: - nasm extensions: - .asm + - .a51 + - .nasm + tm_scope: source.asm.x86 + ace_mode: assembly_x86 Augeas: type: programming extensions: - .aug + tm_scope: none + ace_mode: text AutoHotkey: type: programming - lexer: autohotkey color: "#6594b9" aliases: - ahk extensions: - .ahk + - .ahkl + tm_scope: source.ahk + ace_mode: autohotkey AutoIt: type: programming - color: "#36699B" + color: "#1C3552" aliases: - au3 - AutoIt3 - AutoItScript extensions: - .au3 + tm_scope: source.autoit.3 + ace_mode: autohotkey Awk: type: programming - lexer: Awk extensions: - .awk - .auk @@ -212,76 +263,117 @@ Awk: - gawk - mawk - nawk + ace_mode: text Batchfile: type: programming - group: Shell search_term: bat aliases: - bat + - batch + - dosbatch + - winbatch extensions: - .bat - .cmd + tm_scope: source.dosbatch + ace_mode: batchfile Befunge: + type: programming extensions: - .befunge + ace_mode: text + +Bison: + type: programming + tm_scope: source.bison + extensions: + - .y + ace_mode: text + +BitBake: + type: programming + tm_scope: none + extensions: + - .bb + ace_mode: text BlitzBasic: type: programming aliases: - - blitzplus + - b3d - blitz3d + - blitzplus + - bplus extensions: - .bb - .decls + tm_scope: source.blitzmax + ace_mode: text BlitzMax: type: programming color: "#cd6400" extensions: - .bmx + aliases: + - bmax + ace_mode: text Bluespec: type: programming - lexer: verilog extensions: - .bsv + tm_scope: source.bsv + ace_mode: verilog Boo: type: programming color: "#d4bec1" extensions: - .boo + ace_mode: text Brainfuck: + type: programming + color: "#2F2530" extensions: - .b - .bf + tm_scope: source.bf + ace_mode: text Brightscript: type: programming - lexer: Text only extensions: - .brs + tm_scope: source.brightscript + ace_mode: text Bro: type: programming extensions: - .bro + ace_mode: text C: type: programming - color: "#555" + color: "#555555" extensions: - .c - .cats - .h + - .idc - .w + interpreters: + - tcc + ace_mode: c_cpp C#: type: programming ace_mode: csharp + tm_scope: source.cs search_term: csharp color: "#178600" aliases: @@ -300,48 +392,52 @@ C++: - cpp extensions: - .cpp - - .C - .c++ - .cc + - .cp - .cxx - - .H - .h - .h++ - .hh - .hpp - .hxx - .inl + - .ipp - .tcc - .tpp - - .ipp C-ObjDump: type: data - lexer: c-objdump extensions: - .c-objdump + tm_scope: objdump.x86asm + ace_mode: assembly_x86 C2hs Haskell: type: programming - lexer: Haskell group: Haskell aliases: - c2hs extensions: - .chs + tm_scope: source.haskell + ace_mode: haskell CLIPS: type: programming - lexer: Text only extensions: - .clp + tm_scope: source.clips + ace_mode: text CMake: + type: programming extensions: - .cmake - - .in + - .cmake.in filenames: - CMakeLists.txt + ace_mode: text COBOL: type: programming @@ -351,18 +447,37 @@ COBOL: - .ccp - .cobol - .cpy + ace_mode: cobol CSS: + type: markup + tm_scope: source.css ace_mode: css color: "#563d7c" extensions: - .css +Cap'n Proto: + type: programming + tm_scope: source.capnp + extensions: + - .capnp + ace_mode: text + +CartoCSS: + type: programming + aliases: + - Carto + extensions: + - .mss + ace_mode: text + tm_scope: source.css.mss + Ceylon: type: programming - lexer: Ceylon extensions: - .ceylon + ace_mode: text Chapel: type: programming @@ -371,27 +486,38 @@ Chapel: - chpl extensions: - .chpl + ace_mode: text ChucK: - lexer: Java + type: programming extensions: - .ck + tm_scope: source.java + ace_mode: java Cirru: type: programming - color: "#aaaaff" + color: "#ccccff" ace_mode: cirru - lexer: Cirru extensions: - .cirru +Clarion: + type: programming + color: "#db901e" + ace_mode: text + extensions: + - .clw + tm_scope: source.clarion + Clean: type: programming - color: "#3a81ad" - lexer: Text only + color: "#3F85AF" extensions: - .icl - .dcl + tm_scope: none + ace_mode: text Clojure: type: programming @@ -399,18 +525,20 @@ Clojure: color: "#db5855" extensions: - .clj + - .boot - .cl2 - .cljc - .cljs + - .cljs.hl - .cljscm - .cljx - .hic - - .hl filenames: - riemann.config CoffeeScript: type: programming + tm_scope: source.coffee ace_mode: coffee color: "#244776" aliases: @@ -419,6 +547,7 @@ CoffeeScript: extensions: - .coffee - ._coffee + - .cjsx - .cson - .iced filenames: @@ -429,20 +558,21 @@ CoffeeScript: ColdFusion: type: programming group: ColdFusion - lexer: Coldfusion HTML ace_mode: coldfusion color: "#ed2cd6" search_term: cfm aliases: - cfm - cfml + - coldfusion html extensions: - .cfm + - .cfml + tm_scope: text.html.cfm ColdFusion CFC: type: programming group: ColdFusion - lexer: Coldfusion CFC ace_mode: coldfusion color: "#ed2cd6" search_term: cfc @@ -450,9 +580,11 @@ ColdFusion CFC: - cfc extensions: - .cfc + tm_scope: source.cfscript Common Lisp: type: programming + tm_scope: source.lisp color: "#3fb68b" aliases: - lisp @@ -469,60 +601,88 @@ Common Lisp: - ccl - clisp - ecl + ace_mode: lisp Component Pascal: type: programming - lexer: Delphi color: "#b0ce4e" extensions: - .cp - .cps + tm_scope: source.pascal + aliases: + - delphi + - objectpascal + ace_mode: pascal + +Cool: + type: programming + extensions: + - .cl + tm_scope: source.cool + ace_mode: text Coq: type: programming extensions: - .coq - .v + ace_mode: text Cpp-ObjDump: type: data - lexer: cpp-objdump extensions: - .cppobjdump + - .c++-objdump - .c++objdump + - .cpp-objdump - .cxx-objdump + tm_scope: objdump.x86asm + aliases: + - c++-objdumb + ace_mode: assembly_x86 Creole: type: prose - lexer: Text only wrap: true extensions: - .creole + tm_scope: text.html.creole + ace_mode: text Crystal: type: programming - lexer: Ruby + color: "#776791" extensions: - .cr ace_mode: ruby + tm_scope: source.ruby + interpreters: + - crystal Cucumber: - lexer: Gherkin + type: programming extensions: - .feature + tm_scope: text.gherkin.feature + aliases: + - gherkin + ace_mode: text Cuda: type: programming - lexer: CUDA extensions: - .cu - .cuh + tm_scope: source.cuda-c++ + ace_mode: c_cpp Cycript: type: programming - lexer: JavaScript extensions: - .cy + tm_scope: source.js + ace_mode: javascript Cython: type: programming @@ -531,6 +691,9 @@ Cython: - .pyx - .pxd - .pxi + aliases: + - pyrex + ace_mode: text D: type: programming @@ -538,12 +701,14 @@ D: extensions: - .d - .di + ace_mode: d D-ObjDump: type: data - lexer: d-objdump extensions: - .d-objdump + tm_scope: objdump.x86asm + ace_mode: assembly_x86 DIGITAL Command Language: type: programming @@ -556,90 +721,121 @@ DIGITAL Command Language: DM: type: programming - color: "#075ff1" - lexer: C++ + color: "#447265" extensions: - .dm aliases: - byond + tm_scope: source.c++ + ace_mode: c_cpp -DOT: - type: data - lexer: Text only +DTrace: + type: programming + aliases: + - dtrace-script extensions: - - .dot - - .gv + - .d + interpreters: + - dtrace + tm_scope: source.c + ace_mode: c_cpp Darcs Patch: + type: data search_term: dpatch aliases: - dpatch extensions: - .darcspatch - .dpatch + tm_scope: none + ace_mode: text Dart: type: programming - color: "#98BAD6" + color: "#00B4AB" extensions: - .dart + ace_mode: dart Diff: + type: data + color: "#88dddd" extensions: - .diff - .patch + aliases: + - udiff + tm_scope: source.diff + ace_mode: diff + +Dockerfile: + type: data + tm_scope: source.dockerfile + extensions: + - .dockerfile + filenames: + - Dockerfile + ace_mode: dockerfile Dogescript: type: programming - lexer: Text only color: "#cca760" extensions: - .djs + tm_scope: none + ace_mode: text Dylan: type: programming - color: "#3ebc27" + color: "#6c616e" extensions: - .dylan + - .dyl - .intr - .lid + ace_mode: text E: type: programming color: "#ccce35" - lexer: Text only extensions: - .E - -Ecere Projects: - type: data - group: JavaScript - lexer: JSON - extensions: - - .epj + tm_scope: none + ace_mode: text ECL: type: programming color: "#8a1267" - lexer: ECL extensions: - .ecl - .eclxml + tm_scope: none + ace_mode: text Eagle: type: markup - color: "#3994bc" - lexer: XML + color: "#814C05" extensions: - .sch - .brd + tm_scope: text.xml + ace_mode: xml + +Ecere Projects: + type: data + group: JavaScript + extensions: + - .epj + tm_scope: source.json + ace_mode: json Eiffel: type: programming - lexer: Eiffel color: "#946d57" extensions: - .e + ace_mode: eiffel Elixir: type: programming @@ -647,45 +843,61 @@ Elixir: extensions: - .ex - .exs + ace_mode: elixir + filenames: + - mix.lock Elm: type: programming - lexer: Haskell + color: "#60B5CC" extensions: - .elm + tm_scope: source.elm + ace_mode: elm Emacs Lisp: type: programming - lexer: Common Lisp + tm_scope: source.lisp color: "#c065db" aliases: - elisp - emacs filenames: - .emacs + - .emacs.desktop extensions: - .el - .emacs + - .emacs.desktop + ace_mode: lisp EmberScript: type: programming - color: "#f64e3e" - lexer: CoffeeScript + color: "#FFF4F3" extensions: - .em - .emberscript + tm_scope: source.coffee + ace_mode: coffee Erlang: type: programming - color: "#0faf8d" + color: "#B83998" extensions: - .erl + - .es - .escript - .hrl + filenames: + - rebar.config + - rebar.config.lock + - rebar.lock + ace_mode: erlang + interpreters: + - escript F#: type: programming - lexer: FSharp color: "#b845fc" search_term: fsharp aliases: @@ -694,29 +906,23 @@ F#: - .fs - .fsi - .fsx + tm_scope: source.fsharp + ace_mode: text FLUX: type: programming - color: "#33CCFF" - lexer: Text only + color: "#88ccff" extensions: - .fx - .flux + tm_scope: none + ace_mode: text FORTRAN: type: programming - lexer: Fortran color: "#4d41b1" extensions: - .f90 - - .F - - .F03 - - .F08 - - .F77 - - .F90 - - .F95 - - .FOR - - .FPP - .f - .f03 - .f08 @@ -724,6 +930,8 @@ FORTRAN: - .f95 - .for - .fpp + tm_scope: source.fortran.modern + ace_mode: text Factor: type: programming @@ -731,8 +939,9 @@ Factor: extensions: - .factor filenames: - - .factor-rc - .factor-boot-rc + - .factor-rc + ace_mode: text Fancy: type: programming @@ -742,82 +951,105 @@ Fancy: - .fancypack filenames: - Fakefile + ace_mode: text Fantom: type: programming color: "#dbded5" extensions: - .fan + tm_scope: source.fan + ace_mode: text + +Filterscript: + type: programming + group: RenderScript + extensions: + - .fs + tm_scope: none + ace_mode: text + +Formatted: + type: data + extensions: + - .for + tm_scope: none + ace_mode: text Forth: type: programming color: "#341708" - lexer: Text only extensions: - .fth - .4th + - .f + - .for - .forth + - .fr - .frt + - .fs + ace_mode: forth Frege: type: programming color: "#00cafe" - lexer: Haskell extensions: - .fr + tm_scope: source.haskell + ace_mode: haskell G-code: type: data - lexer: Text only extensions: - .g - .gco - .gcode - -Game Maker Language: - type: programming - color: "#8ad353" - lexer: JavaScript - extensions: - - .gml + tm_scope: source.gcode + ace_mode: gcode GAMS: type: programming - lexer: Text only extensions: - .gms + tm_scope: none + ace_mode: text GAP: type: programming - lexer: Text only extensions: - .g - .gap - .gd - .gi + - .tst + tm_scope: source.gap + ace_mode: text GAS: type: programming group: Assembly extensions: - .s - - .S + tm_scope: source.asm.x86 + ace_mode: assembly_x86 GDScript: type: programming - lexer: Text only extensions: - .gd + tm_scope: source.gdscript + ace_mode: text GLSL: - group: C type: programming extensions: - .glsl - .fp - .frag - .frg + - .fs - .fshader + - .geo - .geom - .glslv - .gshader @@ -825,24 +1057,44 @@ GLSL: - .vert - .vrx - .vshader + ace_mode: glsl + +Game Maker Language: + type: programming + color: "#8fb200" + extensions: + - .gml + tm_scope: source.c++ + ace_mode: c_cpp Genshi: + type: programming extensions: - .kid + tm_scope: text.xml.genshi + aliases: + - xml+genshi + - xml+kid + ace_mode: xml Gentoo Ebuild: + type: programming group: Shell - lexer: Bash extensions: - .ebuild + tm_scope: source.shell + ace_mode: sh Gentoo Eclass: + type: programming group: Shell - lexer: Bash extensions: - .eclass + tm_scope: source.shell + ace_mode: sh Gettext Catalog: + type: prose search_term: pot searchable: false aliases: @@ -850,30 +1102,44 @@ Gettext Catalog: extensions: - .po - .pot + tm_scope: source.po + ace_mode: text Glyph: type: programming color: "#e4cc98" - lexer: Tcl extensions: - .glf + tm_scope: source.tcl + ace_mode: tcl Gnuplot: type: programming color: "#f0a9f0" - lexer: Gnuplot extensions: - .gp - .gnu - .gnuplot - .plot - .plt + interpreters: + - gnuplot + ace_mode: text Go: type: programming color: "#375eab" extensions: - .go + ace_mode: golang + +Golo: + type: programming + color: "#88562A" + extensions: + - .golo + tm_scope: source.golo + ace_mode: text Gosu: type: programming @@ -883,31 +1149,52 @@ Gosu: - .gst - .gsx - .vark + tm_scope: source.gosu.2 + ace_mode: text Grace: type: programming - lexer: Text only extensions: - .grace + tm_scope: source.grace + ace_mode: text + +Gradle: + type: data + extensions: + - .gradle + tm_scope: source.groovy.gradle + ace_mode: text Grammatical Framework: type: programming - lexer: Haskell aliases: - gf wrap: false extensions: - .gf searchable: true - color: "#ff0000" + color: "#79aa7a" + tm_scope: source.haskell + ace_mode: haskell Graph Modeling Language: type: data - lexer: Text only extensions: - .gml + tm_scope: none + ace_mode: text + +Graphviz (DOT): + type: data + tm_scope: source.dot + extensions: + - .dot + - .gv + ace_mode: text Groff: + type: markup extensions: - .man - '.1' @@ -917,6 +1204,10 @@ Groff: - '.5' - '.6' - '.7' + tm_scope: text.groff + aliases: + - nroff + ace_mode: text Groovy: type: programming @@ -924,7 +1215,6 @@ Groovy: color: "#e69f56" extensions: - .groovy - - .gradle - .grt - .gtpl - .gvy @@ -932,73 +1222,105 @@ Groovy: - groovy Groovy Server Pages: + type: programming group: Groovy - lexer: Java Server Page aliases: - gsp + - java server page extensions: - .gsp + tm_scope: text.html.jsp + ace_mode: jsp HTML: type: markup + tm_scope: text.html.basic ace_mode: html + color: "#e44b23" aliases: - xhtml extensions: - .html - .htm + - .html.hl - .st + - .xht - .xhtml HTML+Django: type: markup + tm_scope: text.html.django group: HTML - lexer: HTML+Django/Jinja extensions: - .mustache - .jinja + aliases: + - html+django/jinja + - html+jinja + - htmldjango + ace_mode: django HTML+ERB: type: markup + tm_scope: text.html.erb group: HTML - lexer: RHTML aliases: - erb extensions: - .erb - - .deface + - .erb.deface + ace_mode: html_ruby HTML+PHP: type: markup + tm_scope: text.html.php group: HTML extensions: - .phtml + ace_mode: php HTTP: type: data extensions: - .http + tm_scope: source.httpspec + ace_mode: text + +Hack: + type: programming + ace_mode: php + extensions: + - .hh + - .php + tm_scope: text.html.php Haml: group: HTML type: markup extensions: - .haml - - .deface + - .haml.deface + ace_mode: haml Handlebars: type: markup - lexer: Handlebars + color: "#01a9d6" + aliases: + - hbs + - htmlbars extensions: - .handlebars - .hbs + tm_scope: text.html.handlebars + ace_mode: handlebars Harbour: type: programming - lexer: Text only color: "#0e60e3" extensions: - .hb + tm_scope: none + ace_mode: text Haskell: type: programming @@ -1006,6 +1328,7 @@ Haskell: extensions: - .hs - .hsc + ace_mode: haskell Haxe: type: programming @@ -1014,140 +1337,177 @@ Haxe: extensions: - .hx - .hxsl + tm_scope: source.haxe.2 Hy: type: programming - lexer: Hy - ace_mode: clojure - color: "#7891b1" + ace_mode: text + color: "#7790B2" extensions: - .hy + aliases: + - hylang + tm_scope: source.hy IDL: type: programming - lexer: IDL - color: "#e3592c" + color: "#a3522f" extensions: - .pro - .dlm + ace_mode: text IGOR Pro: type: programming - lexer: Igor extensions: - .ipf + aliases: + - igor + - igorpro + tm_scope: none + ace_mode: text INI: type: data extensions: - .ini + - .cfg - .prefs + - .pro - .properties + tm_scope: source.ini + aliases: + - dosini + ace_mode: ini -Inno Setup: +IRC log: + type: data + search_term: irc + aliases: + - irc + - irc logs extensions: - - .iss - lexer: Text only + - .irclog + - .weechatlog + tm_scope: none + ace_mode: text Idris: type: programming - lexer: Idris extensions: - .idr - .lidr + ace_mode: text Inform 7: type: programming - lexer: Inform 7 wrap: true extensions: - .ni - .i7x + tm_scope: source.Inform7 + aliases: + - i7 + - inform7 + ace_mode: text Inno Setup: + type: programming extensions: - .iss - lexer: Text only - -IRC log: - lexer: IRC logs - search_term: irc - aliases: - - irc - extensions: - - .irclog - - .weechatlog + tm_scope: source.inno + ace_mode: text Io: type: programming color: "#a9188d" extensions: - .io + ace_mode: io Ioke: type: programming color: "#078193" extensions: - .ik + interpreters: + - ioke + ace_mode: text Isabelle: type: programming - lexer: Text only - color: "#fdcd00" + color: "#FEFE00" extensions: - .thy + tm_scope: source.isabelle.theory + ace_mode: text J: type: programming - lexer: Text only + color: "#9EEDFF" extensions: - .ijs + tm_scope: source.j + ace_mode: text + +JFlex: + type: programming + color: "#DBCA00" + extensions: + - .flex + - .jflex + tm_scope: source.jflex + ace_mode: text JSON: type: data + tm_scope: source.json group: JavaScript ace_mode: json searchable: false extensions: - .json - .lock - - .sublime-keymap - - .sublime-mousemap - - .sublime-project - - .sublime-settings - - .sublime-workspace - - .sublime_metrics - - .sublime_session filenames: - .jshintrc - composer.lock JSON5: type: data - lexer: JavaScript extensions: - .json5 + tm_scope: source.js + ace_mode: javascript JSONLD: type: data group: JavaScript - ace_mode: json - lexer: JavaScript + ace_mode: javascript extensions: - .jsonld + tm_scope: source.js JSONiq: type: programming ace_mode: jsoniq - lexer: XQuery extensions: - .jq + tm_scope: source.xquery Jade: group: HTML type: markup extensions: - .jade + tm_scope: source.jade + ace_mode: jade + +Jasmin: + type: programming + ace_mode: java + extensions: + - .j + tm_scope: source.jasmin Java: type: programming @@ -1157,16 +1517,19 @@ Java: - .java Java Server Pages: + type: programming group: Java - lexer: Java Server Page search_term: jsp aliases: - jsp extensions: - .jsp + tm_scope: text.html.jsp + ace_mode: jsp JavaScript: type: programming + tm_scope: source.js ace_mode: javascript color: "#f1e05a" aliases: @@ -1178,6 +1541,7 @@ JavaScript: - .bones - .es6 - .frag + - .gs - .jake - .jsb - .jsfl @@ -1188,6 +1552,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: @@ -1200,43 +1577,65 @@ Julia: extensions: - .jl color: "#a270ba" + ace_mode: julia KRL: - lexer: Text only type: programming - color: "#f5c800" + color: "#28431f" extensions: - .krl + tm_scope: none + ace_mode: text + +KiCad: + type: programming + extensions: + - .sch + tm_scope: none + ace_mode: text Kit: type: markup - lexer: HTML ace_mode: html extensions: - .kit + tm_scope: text.html.basic Kotlin: type: programming + color: "#EA4DFA" extensions: - .kt - .ktm - .kts + tm_scope: source.Kotlin + ace_mode: text LFE: type: programming extensions: - .lfe color: "#004200" - lexer: Common Lisp group: Erlang + tm_scope: source.lisp + ace_mode: lisp LLVM: + type: programming extensions: - .ll + ace_mode: text + +LOLCODE: + type: programming + extensions: + - .lol + color: "#cc9900" + tm_scope: none + ace_mode: text LSL: type: programming - lexer: LSL ace_mode: lsl extensions: - .lsl @@ -1246,57 +1645,83 @@ LSL: LabVIEW: type: programming - lexer: Text only extensions: - .lvproj + tm_scope: none + ace_mode: text Lasso: type: programming - lexer: Lasso - color: "#2584c3" + color: "#999999" extensions: - .lasso - .las + - .lasso8 - .lasso9 - .ldml + tm_scope: file.lasso + aliases: + - lassoscript + ace_mode: text Latte: type: markup color: "#A8FF97" group: HTML - lexer: Smarty extensions: - .latte + tm_scope: source.smarty + ace_mode: smarty + +Lean: + type: programming + extensions: + - .lean + - .hlean + ace_mode: lean Less: type: markup group: CSS - lexer: CSS extensions: - .less + tm_scope: source.css.less + ace_mode: less LilyPond: - lexer: Text only + type: programming extensions: - .ly - .ily + ace_mode: text + +Limbo: + type: programming + extensions: + - .b + - .m + tm_scope: none + ace_mode: text Liquid: type: markup - lexer: Text only extensions: - .liquid + tm_scope: text.html.liquid + ace_mode: liquid Literate Agda: type: programming group: Agda extensions: - .lagda + tm_scope: none + ace_mode: text Literate CoffeeScript: type: programming + tm_scope: source.litcoffee group: CoffeeScript - lexer: Text only ace_mode: markdown wrap: true search_term: litcoffee @@ -1304,96 +1729,133 @@ Literate CoffeeScript: - litcoffee extensions: - .litcoffee + ace_mode: text Literate Haskell: type: programming group: Haskell search_term: lhs aliases: + - lhaskell - lhs extensions: - .lhs + tm_scope: text.tex.latex.haskell + ace_mode: text LiveScript: type: programming - ace_mode: ls color: "#499886" aliases: + - live-script - ls extensions: - .ls - ._ls filenames: - Slakefile + ace_mode: livescript Logos: type: programming extensions: - .xm + - .x + - .xi + ace_mode: text Logtalk: type: programming extensions: - .lgt - .logtalk + ace_mode: text LookML: type: programming - lexer: YAML ace_mode: yaml color: "#652B81" extensions: - .lookml + tm_scope: source.yaml + +LoomScript: + type: programming + extensions: + - .ls + tm_scope: source.loomscript + ace_mode: text Lua: type: programming ace_mode: lua - color: "#fa1fa1" + color: "#000080" extensions: - .lua + - .fcgi - .nse - .pd_lua - .rbxs + - .wlua interpreters: - lua M: type: programming - lexer: Common Lisp aliases: - mumps extensions: - .mumps - .m + tm_scope: source.lisp + ace_mode: lisp MTML: type: markup - lexer: HTML - color: "#0095d9" + color: "#b7e1f4" extensions: - .mtml + tm_scope: text.html.basic + ace_mode: html + +MUF: + type: programming + group: Forth + extensions: + - .muf + - .m + tm_scope: none + ace_mode: forth Makefile: + type: programming + color: "#427819" aliases: + - bsdmake - make + - mf extensions: - .mak + - .d - .mk filenames: - - makefile - - Makefile - GNUmakefile + - Makefile + - makefile interpreters: - make + ace_mode: makefile Mako: + type: programming extensions: - .mako - .mao + tm_scope: text.html.mako + ace_mode: text Markdown: type: prose - lexer: Text only ace_mode: markdown wrap: true extensions: @@ -1403,22 +1865,30 @@ Markdown: - .mkdn - .mkdown - .ron + tm_scope: source.gfm Mask: type: markup - lexer: SCSS color: "#f97732" - ace_mode: scss + ace_mode: mask extensions: - .mask + tm_scope: source.mask Mathematica: type: programming extensions: - .mathematica + - .cdf - .m + - .ma - .nb - lexer: Mathematica + - .nbp + - .wl + - .wlt + aliases: + - mma + ace_mode: text Matlab: type: programming @@ -1426,11 +1896,18 @@ Matlab: extensions: - .matlab - .m + ace_mode: matlab + +Maven POM: + type: data + tm_scope: text.xml.pom + filenames: + - pom.xml + ace_mode: xml Max: type: programming - color: "#ce279c" - lexer: JSON + color: "#c4a79c" aliases: - max/msp - maxmsp @@ -1441,31 +1918,39 @@ Max: - .maxproj - .mxt - .pat + tm_scope: source.json + ace_mode: json MediaWiki: type: prose - lexer: Text only wrap: true extensions: - .mediawiki + tm_scope: text.html.mediawiki + ace_mode: text Mercury: type: programming - color: "#abcdef" - lexer: Prolog + color: "#ff2b2b" ace_mode: prolog + interpreters: + - mmi extensions: - .m - .moo + tm_scope: source.mercury + ace_mode: prolog MiniD: # Legacy + type: programming searchable: false extensions: - .minid # Dummy extension + tm_scope: none + ace_mode: text Mirah: type: programming - lexer: Ruby search_term: mirah color: "#c7a938" extensions: @@ -1473,6 +1958,15 @@ Mirah: - .duby - .mir - .mirah + tm_scope: source.ruby + ace_mode: ruby + +Modelica: + type: programming + extensions: + - .mo + tm_scope: source.modelica + ace_mode: text Module Management System: type: programming @@ -1487,48 +1981,100 @@ Module Management System: Monkey: type: programming - lexer: Monkey extensions: - .monkey + ace_mode: text Moocode: type: programming - lexer: MOOCode extensions: - .moo + tm_scope: none + ace_mode: text MoonScript: type: programming extensions: - .moon + interpreters: + - moon + ace_mode: text Myghty: + type: programming extensions: - .myt + tm_scope: none + ace_mode: text + +NL: + type: data + extensions: + - .nl + tm_scope: none + ace_mode: text NSIS: + type: programming extensions: - .nsi - .nsh + ace_mode: text Nemerle: type: programming - color: "#0d3c6e" + color: "#3d3c6e" extensions: - .n + ace_mode: text + +NetLinx: + type: programming + color: "#0aa0ff" + extensions: + - .axs + - .axi + tm_scope: source.netlinx + ace_mode: text + +NetLinx+ERB: + type: programming + color: "#747faa" + extensions: + - .axs.erb + - .axi.erb + tm_scope: source.netlinx.erb + ace_mode: text NetLogo: type: programming - lexer: Common Lisp - color: "#ff2b2b" + color: "#ff6375" extensions: - .nlogo + tm_scope: source.lisp + ace_mode: lisp + +NewLisp: + type: programming + lexer: NewLisp + color: "#87AED7" + extensions: + - .nl + - .lisp + - .lsp + interpreters: + - newlisp + tm_scope: source.lisp + ace_mode: lisp Nginx: type: markup - lexer: Nginx configuration file extensions: - .nginxconf + tm_scope: source.nginx + aliases: + - nginx configuration file + ace_mode: text Nimrod: type: programming @@ -1536,23 +2082,36 @@ Nimrod: extensions: - .nim - .nimrod + ace_mode: text + tm_scope: source.nim + +Ninja: + type: data + tm_scope: source.ninja + extensions: + - .ninja + ace_mode: text Nit: type: programming - lexer: Text only - color: "#0d8921" + color: "#009917" extensions: - .nit + tm_scope: source.nit + ace_mode: text Nix: type: programming - lexer: Nix + color: "#7e7eff" extensions: - .nix + aliases: + - nixos + tm_scope: source.nix + ace_mode: nix Nu: type: programming - lexer: Scheme color: "#c9df40" aliases: - nush @@ -1560,13 +2119,20 @@ Nu: - .nu filenames: - Nukefile + tm_scope: source.scheme + ace_mode: scheme + interpreters: + - nush NumPy: + type: programming group: Python extensions: - .numpy - .numpyw - .numsc + tm_scope: none + ace_mode: text OCaml: type: programming @@ -1580,67 +2146,86 @@ OCaml: - .mli - .mll - .mly + interpreters: + - ocaml + - ocamlrun + tm_scope: source.ocaml ObjDump: type: data - lexer: objdump extensions: - .objdump + tm_scope: objdump.x86asm + ace_mode: assembly_x86 Objective-C: type: programming + tm_scope: source.objc color: "#438eff" aliases: - obj-c - objc + - objectivec extensions: - .m - .h + ace_mode: objectivec Objective-C++: type: programming - color: "#4886FC" + tm_scope: source.objc++ + color: "#6866fb" aliases: - obj-c++ - objc++ + - objectivec++ extensions: - .mm + ace_mode: objectivec Objective-J: type: programming color: "#ff0c5a" aliases: - obj-j + - objectivej + - objj extensions: - .j - .sj + tm_scope: source.js.objj + ace_mode: text Omgrofl: type: programming extensions: - .omgrofl color: "#cabbff" - lexer: Text only + tm_scope: none + ace_mode: text Opa: type: programming extensions: - .opa + ace_mode: text Opal: type: programming color: "#f7ede0" - lexer: Text only extensions: - .opal + tm_scope: source.opal + ace_mode: text OpenCL: type: programming group: C - lexer: C extensions: - .cl - .opencl + tm_scope: source.c + ace_mode: c_cpp OpenEdge ABL: type: programming @@ -1651,51 +2236,67 @@ OpenEdge ABL: extensions: - .p - .cls + tm_scope: source.abl + ace_mode: text OpenSCAD: type: programming - lexer: Text only extensions: - .scad + tm_scope: source.scad + ace_mode: scad Org: type: prose - lexer: Text only wrap: true extensions: - .org + tm_scope: none + ace_mode: text Ox: type: programming - lexer: Text only extensions: - .ox - .oxh - .oxo + tm_scope: source.ox + ace_mode: text Oxygene: type: programming - lexer: Text only - color: "#5a63a3" + color: "#cdd0e3" extensions: - .oxygene + tm_scope: none + ace_mode: text + +Oz: + type: programming + color: "#fab738" + extensions: + - .oz + tm_scope: source.oz + ace_mode: text PAWN: type: programming - lexer: C++ color: "#dbb284" extensions: - .pwn + tm_scope: source.c++ + ace_mode: c_cpp PHP: type: programming + tm_scope: text.html.php ace_mode: php color: "#4F5D95" extensions: - .php - .aw - .ctp - - .module + - .fcgi - .php3 - .php4 - .php5 @@ -1704,42 +2305,80 @@ PHP: - Phakefile interpreters: - php + aliases: + - inc + +#Oracle +PLSQL: + type: programming + ace_mode: sql + tm_scope: source.plsql.oracle + extensions: + - .pls + - .pkb + - .pks + - .plb + - .plsql + - .sql + +#Postgres +PLpgSQL: + type: programming + ace_mode: pgsql + tm_scope: source.sql + extensions: + - .sql Pan: type: programming - lexer: Pan color: '#cc0000' extensions: - .pan + tm_scope: none + ace_mode: text + +Papyrus: + type: programming + color: "#6600cc" + extensions: + - .psc + tm_scope: source.papyrus + ace_mode: text Parrot: type: programming color: "#f3ca0a" - lexer: Text only extensions: - .parrot # Dummy extension - -Parrot Internal Representation: - group: Parrot - type: programming - lexer: Text only - aliases: - - pir - extensions: - - .pir + tm_scope: none + ace_mode: text Parrot Assembly: group: Parrot type: programming - lexer: Text only aliases: - pasm extensions: - .pasm + interpreters: + - parrot + tm_scope: none + ace_mode: text + +Parrot Internal Representation: + group: Parrot + tm_scope: source.parrot.pir + type: programming + aliases: + - pir + extensions: + - .pir + interpreters: + - parrot + ace_mode: text Pascal: type: programming - lexer: Delphi color: "#b0ce4e" extensions: - .pas @@ -1747,14 +2386,15 @@ Pascal: - .dpr - .lpr - .pp + ace_mode: pascal Perl: type: programming + tm_scope: source.perl ace_mode: perl color: "#0298c3" extensions: - .pl - - .PL - .cgi - .fcgi - .perl @@ -1769,52 +2409,69 @@ Perl: Perl6: type: programming - color: "#0298c3" + color: "#0000fb" extensions: - - .p6 - .6pl - .6pm - .nqp + - .p6 - .p6l - .p6m + - .pl - .pl6 + - .pm - .pm6 + - .t + filenames: + - Rexfile + interpreters: + - perl6 + tm_scope: source.perl.6 + ace_mode: perl PigLatin: type: programming color: "#fcd7de" - lexer: Text only extensions: - .pig + tm_scope: source.pig_latin + ace_mode: text Pike: type: programming - color: "#066ab2" - lexer: Pike + color: "#005390" extensions: - .pike - .pmod + interpreters: + - pike + ace_mode: text Pod: type: prose - lexer: Text only ace_mode: perl wrap: true extensions: - .pod + tm_scope: none PogoScript: type: programming color: "#d80074" - lexer: Text only extensions: - .pogo + tm_scope: source.pogoscript + ace_mode: text PostScript: type: markup extensions: - .ps - .eps + tm_scope: source.postscript + aliases: + - postscr + ace_mode: text PowerShell: type: programming @@ -1828,26 +2485,30 @@ PowerShell: Processing: type: programming - lexer: Java - color: "#2779ab" + color: "#0096D8" extensions: - .pde + ace_mode: text Prolog: type: programming - lexer: Logtalk color: "#74283c" extensions: - .pl - .ecl + - .pro - .prolog + interpreters: + - swipl + ace_mode: prolog Propeller Spin: type: programming - lexer: Text only - color: "#2b446d" + color: "#7fa2a7" extensions: - .spin + tm_scope: source.spin + ace_mode: text Protocol Buffer: type: markup @@ -1856,100 +2517,142 @@ Protocol Buffer: - Protocol Buffers extensions: - .proto + tm_scope: source.protobuf + ace_mode: protobuf + +Public Key: + type: data + extensions: + - .asc + - .pub + tm_scope: none + ace_mode: text Puppet: type: programming - color: "#cc5555" + color: "#332A77" extensions: - .pp filenames: - Modulefile + ace_mode: text Pure Data: type: programming color: "#91de79" - lexer: Text only extensions: - .pd + 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" - lexer: Haskell + color: "#1D222D" extensions: - .purs + tm_scope: source.haskell + ace_mode: haskell Python: type: programming ace_mode: python - color: "#3581ba" + color: "#3572A5" extensions: - .py - .cgi + - .fcgi - .gyp - .lmi - .pyde - .pyp - .pyt - .pyw + - .tac - .wsgi - .xpy filenames: - - wscript - - SConstruct + - BUILD - SConscript + - SConstruct + - Snakefile + - wscript interpreters: - python + - python2 + - python3 + aliases: + - rusthon Python traceback: type: data group: Python - lexer: Python Traceback searchable: false extensions: - .pytb + tm_scope: text.python.traceback + ace_mode: text QML: - type: markup + type: programming color: "#44a51c" extensions: - .qml + tm_scope: source.qml + ace_mode: text QMake: - lexer: Text only + type: programming extensions: - .pro - .pri + interpreters: + - qmake + ace_mode: text R: type: programming color: "#198ce7" - lexer: S aliases: - R - Rscript + - splus extensions: - .r - - .R - - .Rd - .rd - .rsx filenames: - .Rprofile interpreters: - Rscript + ace_mode: r + +RAML: + type: data + ace_mode: yaml + tm_scope: source.yaml + color: "#77d9fb" + extensions: + - .raml RDoc: type: prose - lexer: Rd ace_mode: rdoc wrap: true extensions: - .rdoc + tm_scope: text.rdoc REALbasic: type: programming - lexer: VB.net extensions: - .rbbas - .rbfrm @@ -1957,49 +2660,63 @@ REALbasic: - .rbres - .rbtbar - .rbuistate + tm_scope: source.vbnet + ace_mode: text RHTML: type: markup group: HTML extensions: - .rhtml + tm_scope: text.html.erb + aliases: + - html+ruby + ace_mode: rhtml RMarkdown: type: prose - lexer: Text only wrap: true ace_mode: markdown extensions: - .rmd - - .Rmd + tm_scope: none Racket: type: programming - lexer: Racket - color: "#ae17ff" + color: "#22228f" extensions: - .rkt - .rktd - .rktl - .scrbl + interpreters: + - racket + tm_scope: source.racket + ace_mode: lisp Ragel in Ruby Host: type: programming - lexer: Ragel in Ruby Host - color: "#ff9c2e" + color: "#e17600" extensions: - .rl + aliases: + - ragel-rb + - ragel-ruby + tm_scope: none + ace_mode: text Raw token data: + type: data search_term: raw aliases: - raw extensions: - .raw + tm_scope: none + ace_mode: text Rebol: type: programming - lexer: REBOL color: "#358a5b" extensions: - .reb @@ -2007,32 +2724,50 @@ Rebol: - .r2 - .r3 - .rebol + ace_mode: text + tm_scope: source.rebol Red: type: programming - lexer: Text only color: "#ee0000" extensions: - .red - .reds + aliases: + - red/system + tm_scope: source.red + ace_mode: text Redcode: + type: programming extensions: - .cw + tm_scope: none + ace_mode: text + +RenderScript: + type: programming + extensions: + - .rs + - .rsh + tm_scope: none + ace_mode: text RobotFramework: type: programming extensions: - .robot # - .txt + tm_scope: text.robot + ace_mode: text Rouge: type: programming - lexer: Clojure ace_mode: clojure color: "#cc0088" extensions: - .rg + tm_scope: source.clojure Ruby: type: programming @@ -2047,9 +2782,11 @@ Ruby: extensions: - .rb - .builder + - .fcgi - .gemspec - .god - .irbrc + - .jbuilder - .mspec - .pluginspec - .podspec @@ -2059,10 +2796,13 @@ Ruby: - .rbw - .rbx - .ru + - .ruby - .thor - .watchr interpreters: - ruby + - macruby + - rake filenames: - .pryrc - Appraisals @@ -2084,59 +2824,105 @@ Rust: color: "#dea584" extensions: - .rs + ace_mode: rust SAS: type: programming - color: "#1E90FF" - lexer: Text only + color: "#B34936" extensions: - .sas + tm_scope: source.sas + ace_mode: text SCSS: type: markup + tm_scope: source.scss group: CSS ace_mode: scss extensions: - .scss +SPARQL: + type: data + tm_scope: source.sparql + ace_mode: text + extensions: + - .sparql + - .rq + SQF: type: programming - color: "#FFCB1F" - lexer: C++ + color: "#3F3F3F" extensions: - .sqf - .hqf + tm_scope: source.sqf + ace_mode: text SQL: type: data + tm_scope: source.sql ace_mode: sql extensions: - .sql + - .cql + - .ddl - .prc - .tab - .udf - .viw +#IBM DB2 +SQLPL: + type: programming + ace_mode: sql + tm_scope: source.sql + extensions: + - .sql + - .db2 + STON: type: data group: Smalltalk - lexer: JSON extensions: - .ston + tm_scope: source.smalltalk + ace_mode: text + +SVG: + type: data + extensions: + - .svg + tm_scope: text.xml + ace_mode: xml Sage: type: programming - lexer: Python 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 group: CSS extensions: - .sass - - .scss + ace_mode: sass Scala: type: programming @@ -2146,12 +2932,16 @@ Scala: - .scala - .sbt - .sc + interpreters: + - scala Scaml: group: HTML type: markup extensions: - .scaml + tm_scope: source.scaml + ace_mode: text Scheme: type: programming @@ -2164,9 +2954,9 @@ Scheme: - .ss interpreters: - guile - - racket - bigloo - chicken + ace_mode: scheme Scilab: type: programming @@ -2174,19 +2964,20 @@ Scilab: - .sci - .sce - .tst + ace_mode: text Self: type: programming color: "#0579aa" - lexer: Text only extensions: - .self + tm_scope: none + ace_mode: text Shell: type: programming - lexer: Bash search_term: bash - color: "#5861ce" + color: "#89e051" aliases: - sh - bash @@ -2196,65 +2987,87 @@ Shell: - .bash - .bats - .cgi + - .command + - .fcgi + - .ksh - .tmux + - .tool - .zsh interpreters: - bash + - rc - sh - zsh - filenames: - - Dockerfile + ace_mode: sh ShellSession: type: programming - lexer: Bash Session extensions: - .sh-session + aliases: + - bash session + - console + tm_scope: text.shell-session + ace_mode: sh Shen: type: programming color: "#120F14" - lexer: Text only extensions: - .shen + tm_scope: none + ace_mode: text Slash: type: programming color: "#007eff" extensions: - .sl + tm_scope: text.html.slash + ace_mode: text Slim: group: HTML type: markup - lexer: Slim - color: "#ff8877" + color: "#ff8f77" extensions: - .slim + ace_mode: text Smalltalk: type: programming color: "#596706" extensions: - .st + - .cs + aliases: + - squeak + ace_mode: text Smarty: + type: programming extensions: - .tpl + ace_mode: smarty SourcePawn: type: programming - color: "#f69e1d" + color: "#5c7611" aliases: - sourcemod extensions: - .sp + - .sma + tm_scope: source.sp + ace_mode: text Squirrel: type: programming - lexer: C++ + color: "#800000" extensions: - .nut + tm_scope: source.c++ + ace_mode: c_cpp Standard ML: type: programming @@ -2266,10 +3079,11 @@ Standard ML: - .fun - .sig - .sml + tm_scope: source.ml + ace_mode: text Stata: type: programming - lexer: Text only extensions: - .do - .ado @@ -2278,47 +3092,54 @@ Stata: - .mata - .matah - .sthlp + ace_mode: text Stylus: type: markup group: CSS - lexer: Text only extensions: - .styl + tm_scope: source.stylus + ace_mode: stylus SuperCollider: type: programming color: "#46390b" - lexer: Text only extensions: - .scd + - .sc + tm_scope: none + ace_mode: text Swift: type: programming - lexer: Swift color: "#ffac45" extensions: - .swift + ace_mode: text SystemVerilog: type: programming - color: "#343761" - lexer: systemverilog + color: "#DAE1C2" extensions: - .sv - .svh - .vh + ace_mode: verilog TOML: type: data extensions: - .toml + tm_scope: source.toml + ace_mode: toml TXL: type: programming - lexer: Text only extensions: - .txl + tm_scope: source.txl + ace_mode: text Tcl: type: programming @@ -2327,6 +3148,10 @@ Tcl: - .tcl - .adp - .tm + interpreters: + - tclsh + - wish + ace_mode: tcl Tcsh: type: programming @@ -2334,11 +3159,13 @@ Tcsh: extensions: - .tcsh - .csh + tm_scope: source.shell + ace_mode: sh TeX: type: markup color: "#3D6117" - ace_mode: latex + ace_mode: tex wrap: true aliases: - latex @@ -2363,66 +3190,97 @@ Tea: type: markup extensions: - .tea + tm_scope: source.tea + ace_mode: text + +Text: + type: prose + wrap: true + aliases: + - fundamental + extensions: + - .txt + - .fr + tm_scope: none + ace_mode: text Textile: type: prose - lexer: Text only ace_mode: textile wrap: true extensions: - .textile + tm_scope: none + +Thrift: + type: programming + tm_scope: source.thrift + extensions: + - .thrift + ace_mode: text Turing: type: programming color: "#45f715" - lexer: Text only extensions: - .t - .tu + tm_scope: none + ace_mode: text + +Turtle: + type: data + extensions: + - .ttl + tm_scope: source.turtle + ace_mode: text Twig: type: markup group: PHP - lexer: HTML+Django/Jinja extensions: - .twig + tm_scope: text.html.twig + ace_mode: twig TypeScript: type: programming - color: "#31859c" + color: "#2b7489" aliases: - ts extensions: - .ts + tm_scope: source.ts + ace_mode: typescript Unified Parallel C: type: programming group: C - lexer: C ace_mode: c_cpp - color: "#755223" + color: "#4e3617" extensions: - .upc + tm_scope: source.c UnrealScript: type: programming color: "#a54c4d" - lexer: Java extensions: - .uc + tm_scope: source.java + ace_mode: java VCL: + group: Perl type: programming - lexer: Perl - ace_mode: perl - color: "#0298c3" extensions: - .vcl + tm_scope: source.varnish.vcl + ace_mode: text VHDL: type: programming - lexer: vhdl - color: "#543978" + color: "#adb2cb" extensions: - .vhdl - .vhd @@ -2432,38 +3290,44 @@ VHDL: - .vhs - .vht - .vhw + ace_mode: vhdl Vala: type: programming - color: "#ee7d06" + color: "#fbe5cd" extensions: - .vala - .vapi + ace_mode: vala Verilog: type: programming - lexer: verilog - color: "#848bf3" + color: "#b2b7f8" extensions: - .v - .veo + ace_mode: verilog VimL: type: programming - color: "#199c4b" + color: "#199f4b" search_term: vim aliases: - vim + - nvim extensions: - .vim filenames: + - .nvimrc - .vimrc - - vimrc + - _vimrc - gvimrc + - nvimrc + - vimrc + ace_mode: text Visual Basic: type: programming - lexer: VB.net color: "#945db7" extensions: - .vb @@ -2474,22 +3338,45 @@ Visual Basic: - .vba - .vbhtml - .vbs + tm_scope: source.vbnet + aliases: + - vb.net + - vbnet + ace_mode: text Volt: - type: programming - lexer: D - color: "#0098db" - extensions: - - .volt + type: programming + color: "#1F1F1F" + extensions: + - .volt + tm_scope: source.d + ace_mode: d + +Web Ontology Language: + type: markup + color: "#9cc9dd" + extensions: + - .owl + tm_scope: text.xml + ace_mode: xml + +WebIDL: + type: programming + extensions: + - .webidl + tm_scope: source.webidl + ace_mode: text XC: type: programming - lexer: C + color: "#99DA07" extensions: - .xc + tm_scope: source.xc + ace_mode: c_cpp XML: - type: markup + type: data ace_mode: xml aliases: - rss @@ -2507,17 +3394,21 @@ XML: - .dita - .ditamap - .ditaval + - .dll.config - .filters - .fsproj + - .fxml - .glade - .grxml - .ivy - .jelly - .kml - .launch + - .mm - .mxml - .nproj - .nuspec + - .odd - .osm - .plist - .pluginspec @@ -2528,58 +3419,72 @@ XML: - .rss - .scxml - .srdf - - .svg + - .storyboard + - .stTheme + - .sublime-snippet - .targets - .tmCommand + - .tml - .tmLanguage - .tmPreferences - .tmSnippet - .tmTheme - - .tml + - .ts - .ui - .urdf - .vbproj - .vcxproj - .vxml - .wsdl + - .wsf - .wxi - .wxl - .wxs - .x3d - .xacro - .xaml + - .xib - .xlf - .xliff - .xmi + - .xml.dist - .xsd - .xul - .zcml filenames: - .classpath - .project - - phpunit.xml.dist + - Settings.StyleCop + - Web.Debug.config + - Web.Release.config + - Web.config + - packages.config XProc: type: programming - lexer: XML extensions: - .xpl - .xproc + tm_scope: text.xml + ace_mode: xml XQuery: type: programming - color: "#2700e2" + color: "#5232e7" extensions: - .xquery - .xq - .xql - .xqm - .xqy + ace_mode: xquery XS: - lexer: C + type: programming extensions: - .xs + tm_scope: source.c + ace_mode: c_cpp XSLT: type: programming @@ -2588,10 +3493,11 @@ XSLT: extensions: - .xslt - .xsl + tm_scope: text.xml.xsl + ace_mode: xml Xojo: type: programming - lexer: VB.net extensions: - .xojo_code - .xojo_menu @@ -2599,14 +3505,18 @@ Xojo: - .xojo_script - .xojo_toolbar - .xojo_window + tm_scope: source.vbnet + ace_mode: text Xtend: type: programming extensions: - .xtend + ace_mode: text YAML: type: data + tm_scope: source.yaml aliases: - yml extensions: @@ -2614,62 +3524,78 @@ YAML: - .reek - .rviz - .yaml + ace_mode: yaml Zephir: type: programming - lexer: PHP color: "#118f9e" extensions: - .zep + tm_scope: source.php.zephir + ace_mode: php Zimpl: type: programming - lexer: Text only extensions: - .zimpl - .zmpl - .zpl + tm_scope: none + ace_mode: text + +desktop: + type: data + extensions: + - .desktop + - .desktop.in + tm_scope: source.desktop + ace_mode: text eC: type: programming + color: "#913960" search_term: ec extensions: - .ec - .eh + tm_scope: source.c.ec + ace_mode: text edn: type: data - lexer: Clojure ace_mode: clojure color: "#db5855" extensions: - .edn + tm_scope: source.clojure fish: type: programming group: Shell - lexer: Text only extensions: - .fish + tm_scope: source.fish + ace_mode: text mupad: - lexer: MuPAD + type: programming extensions: - .mu + ace_mode: text nesC: type: programming - color: "#ffce3b" - lexer: nesC + color: "#94B0C7" extensions: - .nc + ace_mode: text ooc: type: programming - lexer: Ooc color: "#b0b77e" extensions: - .ooc + ace_mode: text reStructuredText: type: prose @@ -2680,18 +3606,20 @@ reStructuredText: extensions: - .rst - .rest + ace_mode: text wisp: type: programming - lexer: Clojure ace_mode: clojure color: "#7582D1" extensions: - .wisp + tm_scope: source.clojure xBase: type: programming - lexer: Text only - color: "#3a4040" + color: "#403a40" extensions: - .prg + tm_scope: none + ace_mode: text diff --git a/lib/linguist/lazy_blob.rb b/lib/linguist/lazy_blob.rb index bb262241..78f37b18 100644 --- a/lib/linguist/lazy_blob.rb +++ b/lib/linguist/lazy_blob.rb @@ -1,24 +1,62 @@ require 'linguist/blob_helper' +require 'linguist/language' require 'rugged' module Linguist class LazyBlob + GIT_ATTR = ['linguist-documentation', 'linguist-language', 'linguist-vendored'] + GIT_ATTR_OPTS = { :priority => [:index], :skip_system => true } + GIT_ATTR_FLAGS = Rugged::Repository::Attributes.parse_opts(GIT_ATTR_OPTS) + include BlobHelper MAX_SIZE = 128 * 1024 attr_reader :repository attr_reader :oid - attr_reader :name + attr_reader :path attr_reader :mode - def initialize(repo, oid, name, mode = nil) + alias :name :path + + def initialize(repo, oid, path, mode = nil) @repository = repo @oid = oid - @name = name + @path = path @mode = mode end + def git_attributes + @git_attributes ||= repository.fetch_attributes( + name, GIT_ATTR, GIT_ATTR_FLAGS) + end + + def vendored? + if attr = git_attributes['linguist-vendored'] + return boolean_attribute(attr) + else + return super + end + end + + def documentation? + if attr = git_attributes['linguist-documentation'] + boolean_attribute(attr) + else + super + end + end + + def language + return @language if defined?(@language) + + @language = if lang = git_attributes['linguist-language'] + Language.find_by_alias(lang) + else + super + end + end + def data load_blob! @data @@ -30,6 +68,12 @@ module Linguist end protected + + # Returns true if the attribute is present and not the string "false". + def boolean_attribute(attr) + attr != "false" + end + def load_blob! @data, @size = Rugged::Blob.to_buffer(repository, oid, MAX_SIZE) if @data.nil? end diff --git a/lib/linguist/popular.yml b/lib/linguist/popular.yml index 68d9d0b8..afb68021 100644 --- a/lib/linguist/popular.yml +++ b/lib/linguist/popular.yml @@ -3,27 +3,27 @@ # This file should only be edited by GitHub staff - ActionScript -- Bash - C - C# - C++ - CSS - Clojure - CoffeeScript -- Common Lisp -- Diff -- Emacs Lisp -- Erlang +- Go - HTML - Haskell - Java - JavaScript - Lua +- Matlab - Objective-C - PHP - Perl - Python +- R - Ruby -- SQL - Scala -- Scheme +- Shell +- Swift +- TeX +- VimL diff --git a/lib/linguist/repository.rb b/lib/linguist/repository.rb index a89c81e6..895a3754 100644 --- a/lib/linguist/repository.rb +++ b/lib/linguist/repository.rb @@ -110,18 +110,37 @@ module Linguist if @old_commit_oid == @commit_oid @old_stats else - compute_stats(@old_commit_oid, @commit_oid, @old_stats) + compute_stats(@old_commit_oid, @old_stats) end end end - protected - def compute_stats(old_commit_oid, commit_oid, cache = nil) - file_map = cache ? cache.dup : {} - old_tree = old_commit_oid && Rugged::Commit.lookup(repository, old_commit_oid).tree - new_tree = Rugged::Commit.lookup(repository, commit_oid).tree + def read_index + attr_index = Rugged::Index.new + attr_index.read_tree(current_tree) + repository.index = attr_index + end - diff = Rugged::Tree.diff(repository, old_tree, new_tree) + def current_tree + @tree ||= Rugged::Commit.lookup(repository, @commit_oid).tree + end + + protected + + def compute_stats(old_commit_oid, cache = nil) + old_tree = old_commit_oid && Rugged::Commit.lookup(repository, old_commit_oid).tree + + read_index + + diff = Rugged::Tree.diff(repository, old_tree, current_tree) + + # Clear file map and fetch full diff if any .gitattributes files are changed + if cache && diff.each_delta.any? { |delta| File.basename(delta.new_file[:path]) == ".gitattributes" } + diff = Rugged::Tree.diff(repository, old_tree = nil, current_tree) + file_map = {} + else + file_map = cache ? cache.dup : {} + end diff.each_delta do |delta| old = delta.old_file[:path] @@ -137,13 +156,8 @@ module Linguist blob = Linguist::LazyBlob.new(repository, delta.new_file[:oid], new, mode.to_s(8)) - # Skip vendored or generated blobs - next if blob.vendored? || blob.generated? || blob.language.nil? - - # Only include programming languages and acceptable markup languages - if blob.language.type == :programming || Language.detectable_markup.include?(blob.language.name) - file_map[new] = [blob.language.group.name, blob.size] - end + next unless blob.include_in_language_stats? + file_map[new] = [blob.language.group.name, blob.size] end end diff --git a/lib/linguist/samples.rb b/lib/linguist/samples.rb index 920bb87e..efcba365 100644 --- a/lib/linguist/samples.rb +++ b/lib/linguist/samples.rb @@ -1,11 +1,12 @@ begin - require 'json' + require 'yajl' rescue LoadError require 'yaml' end require 'linguist/md5' require 'linguist/classifier' +require 'linguist/shebang' module Linguist # Model for accessing classifier training data. @@ -19,7 +20,7 @@ module Linguist # Hash of serialized samples object def self.cache @cache ||= begin - serializer = defined?(JSON) ? JSON : YAML + serializer = defined?(Yajl) ? Yajl : YAML serializer.load(File.read(PATH)) end end @@ -33,10 +34,6 @@ module Linguist Dir.entries(ROOT).sort!.each do |category| next if category == '.' || category == '..' - # Skip text and binary for now - # Possibly reconsider this later - next if category == 'Text' || category == 'Binary' - dirname = File.join(ROOT, category) Dir.entries(dirname).each do |filename| next if filename == '.' || filename == '..' @@ -52,14 +49,16 @@ module Linguist }) end else + path = File.join(dirname, filename) + if File.extname(filename) == "" - raise "#{File.join(dirname, filename)} is missing an extension, maybe it belongs in filenames/ subdir" + raise "#{path} is missing an extension, maybe it belongs in filenames/ subdir" end yield({ - :path => File.join(dirname, filename), + :path => path, :language => category, - :interpreter => File.exist?(filename) ? Linguist.interpreter_from_shebang(File.read(filename)) : nil, + :interpreter => Shebang.interpreter(File.read(path)), :extname => File.extname(filename) }) end @@ -112,40 +111,4 @@ module Linguist db end end - - # Used to retrieve the interpreter from the shebang line of a file's - # data. - def self.interpreter_from_shebang(data) - lines = data.lines.to_a - - if lines.any? && (match = lines[0].match(/(.+)\n?/)) && (bang = match[0]) =~ /^#!/ - bang.sub!(/^#! /, '#!') - tokens = bang.split(' ') - pieces = tokens.first.split('/') - - if pieces.size > 1 - script = pieces.last - else - script = pieces.first.sub('#!', '') - end - - script = script == 'env' ? tokens[1] : script - - # "python2.6" -> "python" - if script =~ /((?:\d+\.?)+)/ - script.sub! $1, '' - end - - # Check for multiline shebang hacks that call `exec` - if script == 'sh' && - lines[0...5].any? { |l| l.match(/exec (\w+).+\$0.+\$@/) } - script = $1 - end - - script - else - nil - end - end - end diff --git a/lib/linguist/shebang.rb b/lib/linguist/shebang.rb new file mode 100644 index 00000000..5b27532a --- /dev/null +++ b/lib/linguist/shebang.rb @@ -0,0 +1,59 @@ +module Linguist + class Shebang + # Public: Use shebang to detect language of the blob. + # + # blob - An object that quacks like a blob. + # + # Examples + # + # Shebang.call(FileBlob.new("path/to/file")) + # + # Returns an Array with one Language if the blob has a shebang with a valid + # interpreter, or empty if there is no shebang. + def self.call(blob, _ = nil) + Language.find_by_interpreter interpreter(blob.data) + end + + # Public: Get the interpreter from the shebang + # + # Returns a String or nil + def self.interpreter(data) + shebang = data.lines.first + + # First line must start with #! + return unless shebang && shebang.start_with?("#!") + + s = StringScanner.new(shebang) + + # There was nothing after the #! + return unless path = s.scan(/^#!\s*\S+/) + + # Keep going + script = path.split('/').last + + # if /usr/bin/env type shebang then walk the string + if script == 'env' + s.scan(/\s+/) + s.scan(/.*=[^\s]+\s+/) # skip over variable arguments e.g. foo=bar + script = s.scan(/\S+/) + end + + # Interpreter was /usr/bin/env with no arguments + return unless script + + # "python2.6" -> "python2" + script.sub! /(\.\d+)$/, '' + + # #! perl -> perl + script.sub! /^#!\s*/, '' + + # Check for multiline shebang hacks that call `exec` + if script == 'sh' && + data.lines.first(5).any? { |l| l.match(/exec (\w+).+\$0.+\$@/) } + script = $1 + end + + File.basename(script) + end + end +end diff --git a/lib/linguist/strategy/filename.rb b/lib/linguist/strategy/filename.rb new file mode 100644 index 00000000..e682863b --- /dev/null +++ b/lib/linguist/strategy/filename.rb @@ -0,0 +1,20 @@ +module Linguist + module Strategy + # Detects language based on filename and/or extension + class Filename + def self.call(blob, _) + name = blob.name.to_s + + # A bit of an elegant hack. If the file is executable but extensionless, + # append a "magic" extension so it can be classified with other + # languages that have shebang scripts. + extensions = FileBlob.new(name).extensions + if extensions.empty? && blob.mode && (blob.mode.to_i(8) & 05) == 05 + name += ".script!" + end + + Language.find_by_filename(name) + end + end + end +end diff --git a/lib/linguist/strategy/modeline.rb b/lib/linguist/strategy/modeline.rb new file mode 100644 index 00000000..55a8f355 --- /dev/null +++ b/lib/linguist/strategy/modeline.rb @@ -0,0 +1,30 @@ +module Linguist + module Strategy + class Modeline + EmacsModeline = /-\*-\s*(?:(?!mode)[\w-]+\s*:\s*(?:[\w+-]+)\s*;?\s*)*(?:mode\s*:)?\s*([\w+-]+)\s*(?:;\s*(?!mode)[\w-]+\s*:\s*[\w+-]+\s*)*;?\s*-\*-/i + VimModeline = /\/\*\s*vim:\s*set\s*(?:ft|filetype)=(\w+):\s*\*\//i + + # Public: Detects language based on Vim and Emacs modelines + # + # blob - An object that quacks like a blob. + # + # Examples + # + # Modeline.call(FileBlob.new("path/to/file")) + # + # Returns an Array with one Language if the blob has a Vim or Emacs modeline + # that matches a Language name or alias. Returns an empty array if no match. + def self.call(blob, _ = nil) + Array(Language.find_by_alias(modeline(blob.data))) + end + + # Public: Get the modeline from the first n-lines of the file + # + # Returns a String or nil + def self.modeline(data) + match = data.match(EmacsModeline) || data.match(VimModeline) + match[1] if match + end + end + end +end diff --git a/lib/linguist/tokenizer.rb b/lib/linguist/tokenizer.rb index 4b2ea607..0123f385 100644 --- a/lib/linguist/tokenizer.rb +++ b/lib/linguist/tokenizer.rb @@ -22,8 +22,10 @@ module Linguist # Start state on token, ignore anything till the next newline SINGLE_LINE_COMMENTS = [ '//', # C + '--', # Ada, Haskell, AppleScript '#', # Ruby '%', # Tex + '"', # Vim ] # Start state on opening token, ignore anything until the closing @@ -33,7 +35,8 @@ module Linguist [''], # XML ['{-', '-}'], # Haskell ['(*', '*)'], # Coq - ['"""', '"""'] # Python + ['"""', '"""'], # Python + ["'''", "'''"] # Python ] START_SINGLE_LINE_COMMENT = Regexp.compile(SINGLE_LINE_COMMENTS.map { |c| @@ -129,6 +132,9 @@ module Linguist # extract_shebang("#!/usr/bin/env node") # # => "node" # + # extract_shebang("#!/usr/bin/env A=B foo=bar awk -f") + # # => "awk" + # # Returns String token or nil it couldn't be parsed. def extract_shebang(data) s = StringScanner.new(data) @@ -137,6 +143,7 @@ module Linguist script = path.split('/').last if script == 'env' s.scan(/\s+/) + s.scan(/.*=[^\s]+\s+/) script = s.scan(/\S+/) end script = script[/[^\d]+/, 0] if script diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index e141eff8..edc95804 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -24,6 +24,9 @@ - (^|/)config.guess$ - (^|/)config.sub$ +# Linters +- cpplint.py + # Node dependencies - node_modules/ @@ -32,31 +35,35 @@ # Erlang bundles - ^rebar$ +- erlang.mk # Go dependencies - Godeps/_workspace/ -# Bootstrap minified css and js -- (^|/)bootstrap([^.]*)(\.min)?\.(js|css)$ +# Minified JavaScript and CSS +- (\.|-)min\.(js|css)$ + +# Stylesheets imported from packages +- ([^\s]*)import\.(css|less|scss|styl)$ + +# Bootstrap css and js +- (^|/)bootstrap([^.]*)\.(js|css|less|scss|styl)$ +- (^|/)custom\.bootstrap([^\s]*)(js|css|less|scss|styl)$ # Font Awesome -- font-awesome.min.css -- font-awesome.css +- (^|/)font-awesome\.(css|less|scss|styl)$ # Foundation css -- foundation.min.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.min.css +- (^|/)animate\.(css|less|scss|styl)$ # Vendored dependencies - third[-_]?party/ @@ -73,12 +80,12 @@ ## Commonly Bundled JavaScript frameworks ## # jQuery -- (^|/)jquery([^.]*)(\.min)?\.js$ -- (^|/)jquery\-\d\.\d+(\.\d+)?(\.min)?\.js$ +- (^|/)jquery([^.]*)\.js$ +- (^|/)jquery\-\d\.\d+(\.\d+)?\.js$ # jQuery UI -- (^|/)jquery\-ui(\-\d\.\d+(\.\d+)?)?(\.\w+)?(\.min)?\.(js|css)$ -- (^|/)jquery\.(ui|effects)\.([^.]*)(\.min)?\.(js|css)$ +- (^|/)jquery\-ui(\-\d\.\d+(\.\d+)?)?(\.\w+)?\.(js|css)$ +- (^|/)jquery\.(ui|effects)\.([^.]*)\.(js|css)$ # Prototype - (^|/)prototype(.*)\.js$ @@ -110,30 +117,38 @@ # MathJax - (^|/)MathJax/ +# Chart.js +- (^|/)Chart\.js$ + +# Codemirror +- (^|/)[Cc]ode[Mm]irror/(lib|mode|theme|addon|keymap) + # SyntaxHighlighter - http://alexgorbatchev.com/ - (^|/)shBrush([^.]*)\.js$ - (^|/)shCore\.js$ - (^|/)shLegacy\.js$ # AngularJS -- (^|/)angular([^.]*)(\.min)?\.js$ +- (^|/)angular([^.]*)\.js$ # D3.js -- (^|\/)d3(\.v\d+)?([^.]*)(\.min)?\.js$ +- (^|\/)d3(\.v\d+)?([^.]*)\.js$ # React -- (^|/)react(-[^.]*)?(\.min)?\.js$ +- (^|/)react(-[^.]*)?\.js$ # Modernizr -- (^|/)modernizr\-\d\.\d+(\.\d+)?(\.min)?\.js$ +- (^|/)modernizr\-\d\.\d+(\.\d+)?\.js$ - (^|/)modernizr\.custom\.\d+\.js$ # Knockout - (^|/)knockout-(\d+\.){3}(debug\.)?js$ -- knockout-min.js ## Python ## +# Sphinx +- (^|/)docs?/_?(build|themes?|templates?|static)/ + # django - (^|/)admin_media/ @@ -168,8 +183,8 @@ - \.intellisense\.js$ # jQuery validation plugin (MS bundles this with asp.net mvc) -- (^|/)jquery([^.]*)\.validate(\.unobtrusive)?(\.min)?\.js$ -- (^|/)jquery([^.]*)\.unobtrusive\-ajax(\.min)?\.js$ +- (^|/)jquery([^.]*)\.validate(\.unobtrusive)?\.js$ +- (^|/)jquery([^.]*)\.unobtrusive\-ajax\.js$ # Microsoft Ajax - (^|/)[Mm]icrosoft([Mm]vc)?([Aa]jax|[Vv]alidation)(\.debug)?\.js$ @@ -196,7 +211,7 @@ - (^|/)extjs/welcome/ # Html5shiv -- (^|/)html5shiv(\.min)?\.js$ +- (^|/)html5shiv\.js$ # Samples folders - ^[Ss]amples/ @@ -212,11 +227,11 @@ - ^readme$ # Test fixtures -- ^[Tt]est/fixtures/ +- ^[Tt]ests?/fixtures/ # PhoneGap/Cordova -- (^|/)cordova([^.]*)(\.min)?\.js$ -- (^|/)cordova\-\d\.\d(\.\d)?(\.min)?\.js$ +- (^|/)cordova([^.]*)\.js$ +- (^|/)cordova\-\d\.\d(\.\d)?\.js$ # Foundation js - foundation(\..*)?\.js$ @@ -224,21 +239,27 @@ # Vagrant - ^Vagrantfile$ -# .DS_Store's +# .DS_Stores - .[Dd][Ss]_[Ss]tore$ -# Mercury --use-subdirs -- Mercury/ - # R packages - ^vignettes/ - ^inst/extdata/ # Octicons - octicons.css -- octicons.min.css - sprockets-octicons.scss # Typesafe Activator - (^|/)activator$ - (^|/)activator\.bat$ + +# ProGuard +- proguard.pro +- proguard-rules.pro + +# PuPHPet +- ^puphpet/ + +# Android Google APIs +- (^|/)\.google_apis/ diff --git a/lib/linguist/version.rb b/lib/linguist/version.rb index b5bd50de..f46571b1 100644 --- a/lib/linguist/version.rb +++ b/lib/linguist/version.rb @@ -1,3 +1,3 @@ module Linguist - VERSION = "3.1.5" + VERSION = "4.5.4" end diff --git a/package.json b/package.json new file mode 100644 index 00000000..025b6c1e --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "repository": "https://github.com/github/linguist", + "dependencies": { + "season": "~>5.0" + } +} diff --git a/samples/AMPL/toy.ampl b/samples/AMPL/toy.ampl new file mode 100644 index 00000000..0ca0c7cf --- /dev/null +++ b/samples/AMPL/toy.ampl @@ -0,0 +1,25 @@ +# A toy knapsack problem from the LocalSolver docs written in AMPL. + +set I; +param Value{I}; +param Weight{I}; +param KnapsackBound; +var Take{I} binary; + +maximize TotalValue: sum{i in I} Take[i] * Value[i]; +s.t. WeightLimit: sum{i in I} Take[i] * Weight[i] <= KnapsackBound; + +data; + +param: +I: Weight Value := +0 10 1 +1 60 10 +2 30 15 +3 40 40 +4 30 60 +5 20 90 +6 20 100 +7 2 15; + +param KnapsackBound := 102; diff --git a/samples/APL/UT.dyalog b/samples/APL/UT.dyalog new file mode 100644 index 00000000..6c5f28fa --- /dev/null +++ b/samples/APL/UT.dyalog @@ -0,0 +1,367 @@ +:NameSpace UT + + sac ← 0 + expect_orig ← expect ← ⎕NS⍬ + exception ← ⍬ + nexpect_orig ← nexpect ← ⎕NS⍬ + + ∇ {Z}←{Conf}run Argument;PRE_test;POST_test;TEST_step;COVER_step;FromSpace + + load_display_if_not_already_loaded + load_salt_scripts_into_current_namespace_if_configured + + FromSpace←1⊃⎕RSI + + PRE_test←{} + POST_test←{} + COVER_step←{} + :If 0≠⎕NC'Conf' + :If Conf has'cover_target' + PRE_test←{{}⎕PROFILE'start'} + POST_test←{{}⎕PROFILE'stop'} + :EndIf + :EndIf + + :If is_function Argument + TEST_step←single_function_test_function + COVER_file←Argument,'_coverage.html' + + :ElseIf is_list_of_functions Argument + TEST_step←list_of_functions_test_function + COVER_file←'list_coverage.html' + + :ElseIf is_file Argument + TEST_step←file_test_function + COVER_file←(get_file_name Argument),'_coverage.html' + + :ElseIf is_dir Argument + test_files←test_files_in_dir Argument + TEST_step←test_dir_function + Argument←test_files + :EndIf + + :If 0≠⎕NC'Conf' + :If Conf has'cover_target' + COVER_step←{Conf,←⊂('cover_file'COVER_file) + generate_coverage_page Conf} + :EndIf + :EndIf + + PRE_test ⍬ + Z←FromSpace TEST_step Argument + POST_test ⍬ + COVER_step ⍬ + ∇ + + ∇ load_display_if_not_already_loaded + :If 0=⎕NC'#.DISPLAY' + 'DISPLAY'#.⎕CY'display' + :EndIf + ∇ + + ∇ load_salt_scripts_into_current_namespace_if_configured + :If 0≠⎕NC'#.UT.appdir' + :If ⍬≢#.UT.appdir + ⎕SE.SALT.Load #.UT.appdir,'src/*.dyalog -target=#' + ⎕SE.SALT.Load #.UT.appdir,'test/*.dyalog -target=#' + :EndIf + :EndIf + ∇ + + ∇ Z←FromSpace single_function_test_function TestName + Z←run_ut FromSpace TestName + ∇ + + ∇ Z←FromSpace list_of_functions_test_function ListOfNames;t + t←⎕TS + Z←run_ut¨{FromSpace ⍵}¨ListOfNames + t←⎕TS-t + ('Test execution report')print_passed_crashed_failed Z t + ∇ + + ∇ Z←FromSpace file_test_function FilePath;FileNS;Functions;TestFunctions;t + FileNS←⎕SE.SALT.Load FilePath,' -target=#' + Functions←↓FileNS.⎕NL 3 + TestFunctions←(is_test¨Functions)/Functions + :If (0/⍬,⊂0/'')≡TestFunctions + ⎕←'No test functions found' + Z←⍬ + :Else + t←⎕TS + Z←run_ut¨{FileNS ⍵}¨TestFunctions + t←⎕TS-t + (FilePath,' tests')print_passed_crashed_failed Z t + :EndIf + ∇ + + ∇ Z←FromSpace test_dir_function Test_files + :If Test_files≡⍬/⍬,⊂'' + ⎕←'No test files found' + Z←⍬ + :Else + Z←#.UT.run¨Test_files + :EndIf + ∇ + + ∇ Z←get_file_name Argument;separator + separator←⊃⌽(Argument∊'/\')/⍳⍴Argument + Z←¯7↓separator↓Argument + ∇ + + ∇ generate_coverage_page Conf;ProfileData;CoverResults;HTML + ProfileData←⎕PROFILE'data' + ToCover←retrieve_coverables¨(⊃'cover_target'in Conf) + :If (⍴ToCover)≡(⍴⊂1) + ToCover←⊃ToCover + :EndIf + Representations←get_representation¨ToCover + CoverResults←ProfileData∘generate_cover_result¨↓ToCover,[1.5]Representations + HTML←generate_html CoverResults + Conf write_html_to_page HTML + ⎕PROFILE'clear' + ∇ + + ∇ Z←retrieve_coverables Something;nc;functions + nc←⎕NC Something + :If nc=3 + Z←Something + :ElseIf nc=9 + functions←strip¨↓⍎Something,'.⎕NL 3' + Z←{(Something,'.',⍵)}¨functions + :EndIf + ∇ + + ∇ Z←strip input + Z←(input≠' ')/input + ∇ + + ∇ Z←get_representation Function;nc;rep + nc←⎕NC⊂Function + :If nc=3.1 + rep←↓⎕CR Function + rep[1]←⊂'∇',⊃rep[1] + rep,←⊂'∇' + rep←↑rep + :Else + rep←⎕CR Function + :EndIf + Z←rep + ∇ + + ∇ Z←ProfileData generate_cover_result(name representation);Indices;lines;functionlines;covered_lines + Indices←({name≡⍵}¨ProfileData[;1])/⍳⍴ProfileData[;1] + lines←ProfileData[Indices;2] + nc←⎕NC⊂name + :If 3.1=nc + functionlines←¯2+⍴↓representation + :Else + functionlines←⊃⍴↓representation + :EndIf + covered_lines←(⍬∘≢¨lines)/lines + Z←(nc lines functionlines covered_lines representation) + ∇ + + ∇ Z←generate_html CoverResults;Covered;Total;Percentage;CoverageText;ColorizedCode;Timestamp;Page + Covered←⊃⊃+/{⍴4⊃⍵}¨CoverResults + Total←⊃⊃+/{3⊃⍵}¨CoverResults + Percentage←100×Covered÷Total + CoverageText←'Coverage: ',Percentage,'% (',Covered,'/',Total,')' + ColorizedCode←⊃,/{colorize_code_by_coverage ⍵}¨CoverResults + Timestamp←generate_timestamp_text + Page←⍬ + Page,←⊂⍬,'' + Page,←⊂⍬,'' + Page,←⊂⍬,'' + Page,←⊂⍬,CoverageText + Page,←⊂⍬,'
'
+      Page,←ColorizedCode
+      Page,←⊂⍬,'
' + Page,←Timestamp + Page,←⊂⍬,'' + Z←Page + ∇ + + ∇ Z←colorize_code_by_coverage CoverResult;Colors;Ends;Code + :If 3.1=⊃CoverResult + Colors←(2+3⊃CoverResult)⍴⊂'' + Colors[1]←⊂'' + Colors[⍴Colors]←⊂'' + Ends←(2+3⊃CoverResult)⍴⊂'' + Ends[1]←⊂'' + Ends[⍴Ends]←⊂'' + :Else + Colors←(3⊃CoverResult)⍴⊂'' + Ends←(3⊃CoverResult)⍴⊂'' + :EndIf + Colors[1+4⊃CoverResult]←⊂'' + Ends[1+4⊃CoverResult]←⊂'' + Code←↓5⊃CoverResult + Z←Colors,[1.5]Code + Z←{⍺,(⎕UCS 13),⍵}/Z,Ends + ∇ + + ∇ Z←generate_timestamp_text;TS;YYMMDD;HHMMSS + TS←⎕TS + YYMMDD←⊃{⍺,'-',⍵}/3↑TS + HHMMSS←⊃{⍺,':',⍵}/3↑3↓TS + Z←'Page generated: ',YYMMDD,'|',HHMMSS + ∇ + + ∇ Conf write_html_to_page Page;tie;filename + filename←(⊃'cover_out'in Conf),(⊃'cover_file'in Conf) + :Trap 22 + tie←filename ⎕NTIE 0 + filename ⎕NERASE tie + filename ⎕NCREATE tie + :Else + tie←filename ⎕NCREATE 0 + :EndTrap + Simple_array←⍕⊃,/Page + (⎕UCS'UTF-8'⎕UCS Simple_array)⎕NAPPEND tie + ∇ + + ∇ Z←is_function Argument + Z←'_TEST'≡¯5↑Argument + ∇ + + ∇ Z←is_list_of_functions Argument + Z←2=≡Argument + ∇ + + ∇ Z←is_file Argument + Z←'.dyalog'≡¯7↑Argument + ∇ + + ∇ Z←is_dir Argument;attr + :If 'Linux'≡5↑⊃'.'⎕WG'APLVersion' + Z←'yes'≡⊃⎕CMD'test -d ',Argument,' && echo yes || echo no' + :Else + 'gfa'⎕NA'I kernel32|GetFileAttributes* <0t' + :If Z←¯1≠attr←gfa⊂Argument ⍝ If file exists + Z←⊃2 16⊤attr ⍝ Return bit 4 + :EndIf + :EndIf + ∇ + + + ∇ Z←test_files_in_dir Argument + :If 'Linux'≡5↑⊃'.'⎕WG'APLVersion' + Z←⎕SH'find ',Argument,' -name \*_tests.dyalog' + :Else + #.⎕CY'files' + Z←#.Files.Dir Argument,'\*_tests.dyalog' + Z←(Argument,'\')∘,¨Z + :EndIf + ∇ + + ∇ Z←run_ut ut_data;returned;crashed;pass;crash;fail;message + (returned crashed time)←execute_function ut_data + (pass crash fail)←determine_pass_crash_or_fail returned crashed + message←determine_message pass fail crashed(2⊃ut_data)returned time + print_message_to_screen message + Z←(pass crash fail) + ∇ + + ∇ Z←execute_function ut_data;function;t + reset_UT_globals + function←(⍕(⊃ut_data[1])),'.',⊃ut_data[2] + :Trap sac + :If 3.2≡⎕NC⊂function + t←⎕TS + Z←(⍎function,' ⍬')0 + t←⎕TS-t + :Else + t←⎕TS + Z←(⍎function)0 + t←⎕TS-t + :EndIf + + :Else + Z←(↑⎕DM)1 + :If exception≢⍬ + expect←exception + Z[2]←0 + t←⎕TS-t + :EndIf + :EndTrap + Z,←⊂t + ∇ + + ∇ reset_UT_globals + expect_orig ← expect← ⎕NS⍬ + exception←⍬ + nexpect_orig ← nexpect← ⎕NS⍬ + ∇ + + ∇ Z←is_test FunctionName;wsIndex + wsIndex←FunctionName⍳' ' + FunctionName←(wsIndex-1)↑FunctionName + Z←'_TEST'≡¯5↑FunctionName + ∇ + + ∇ Heading print_passed_crashed_failed(ArrayRes time) + ⎕←'-----------------------------------------' + ⎕←Heading + ⎕←' ⍋ Passed: ',+/{1⊃⍵}¨ArrayRes + ⎕←' ⍟ Crashed: ',+/{2⊃⍵}¨ArrayRes + ⎕←' ⍒ Failed: ',+/{3⊃⍵}¨ArrayRes + ⎕←' ○ Runtime: ',time[5],'m',time[6],'s',time[7],'ms' + ∇ + + determine_pass_crash_or_fail←{ + r c←⍵ ⋄ 0≠c:0 1 0 ⋄ z←(0 0 1)(1 0 0) + expect_orig≢expect:(⎕IO+expect≡r)⊃z ⋄ (⎕IO+nexpect≢r)⊃z + } + + ∇ Z←determine_message(pass fail crashed name returned time) + :If crashed + Z←'CRASHED: 'failure_message name returned + :ElseIf pass + Z←'Passed ',time[5],'m',time[6],'s',time[7],'ms' + :Else + Z←'FAILED: 'failure_message name returned + :EndIf + ∇ + + ∇ print_message_to_screen message + ⎕←message + ∇ + + ∇ Z←term_to_text Term;Text;Rows + Text←#.DISPLAY Term + Rows←1⊃⍴Text + Z←(Rows 4⍴''),Text + ∇ + + ∇ Z←Cause failure_message(name returned);hdr;exp;expterm;got;gotterm + hdr←Cause,name + exp←'Expected' + expterm←term_to_text #.UT.expect + got←'Got' + gotterm←term_to_text returned + Z←align_and_join_message_parts hdr exp expterm got gotterm + ∇ + + ∇ Z←align_and_join_message_parts Parts;hdr;exp;expterm;got;gotterm;R1;C1;R2;C2;W + (hdr exp expterm got gotterm)←Parts + (R1 C1)←⍴expterm + (R2 C2)←⍴gotterm + W←⊃⊃⌈/C1 C2(⍴hdr)(⍴exp)(⍴got) + Z←(W↑hdr),[0.5](W↑exp) + Z←Z⍪(R1 W↑expterm) + Z←Z⍪(W↑got) + Z←Z⍪(R2 W↑gotterm) + ∇ + + ∇ Z←confparam in config + Z←1↓⊃({confparam≡⊃⍵}¨config)/config + ∇ + + ∇ Z←config has confparam + Z←∨/{confparam≡⊃⍵}¨config + ∇ + +:EndNameSpace diff --git a/samples/ATS/main.atxt b/samples/ATS/main.atxt deleted file mode 100644 index 3bba35f0..00000000 --- a/samples/ATS/main.atxt +++ /dev/null @@ -1,215 +0,0 @@ -%{ -#include "./../ATEXT/atextfun.hats" -%} - - - - - - -EFFECTIVATS-DiningPhil2 -#patscode_style() - - - - -

-Effective ATS: Dining Philosophers -

- -In this article, I present an implementation of a slight variant of the -famous problem of 5-Dining-Philosophers by Dijkstra that makes simple but -convincing use of linear types. - -

-The Original Problem -

- -There are five philosophers sitting around a table and there are also 5 -forks placed on the table such that each fork is located between the left -hand of a philosopher and the right hand of another philosopher. Each -philosopher does the following routine repeatedly: thinking and dining. In -order to dine, a philosopher needs to first acquire two forks: one located -on his left-hand side and the other on his right-hand side. After -finishing dining, a philosopher puts the two acquired forks onto the table: -one on his left-hand side and the other on his right-hand side. - -

-A Variant of the Original Problem -

- -The following twist is added to the original version: - -

- -After a fork is used, it becomes a "dirty" fork and needs to be put in a -tray for dirty forks. There is a cleaner who cleans dirty forks and then -puts them back on the table. - -

-Channels for Communication -

- -A channel is just a shared queue of fixed capacity. The following two -functions are for inserting an element into and taking an element out of a -given channel: - -
-#pats2xhtml_sats("\
-fun{a:vt0p} channel_insert (channel (a), a): void
-fun{a:vt0p} channel_takeout (chan: channel (a)): (a) 
-")
- -If [channel_insert] is called on a channel that is full, then the caller is -blocked until an element is taken out of the channel. If [channel_takeout] -is called on a channel that is empty, then the caller is blocked until an -element is inserted into the channel. - -

-A Channel for Each Fork -

- -Forks are resources given a linear type. Each fork is initially stored in a -channel, which can be obtained by calling the following function: - -
-#pats2xhtml_sats("\
-fun fork_changet (n: nphil): channel(fork)
-")
- -where the type [nphil] is defined to be [natLt(5)] (for natural numbers -less than 5). The channels for storing forks are chosen to be of capacity -2. The reason that channels of capacity 2 are chosen to store at most one -element (in each of them) is to guarantee that these channels can never be -full (so that there is no attempt made to send signals to awake callers -supposedly being blocked due to channels being full). - - -

-A Channel for the Fork Tray -

- -A tray for storing "dirty" forks is also a channel, which can be obtained -by calling the following function: - -
-#pats2xhtml_sats("\
-fun forktray_changet ((*void*)): channel(fork)
-")
- -The capacity chosen for the channel is 6 (instead of 5) so that it can -never become full (as there are only 5 forks in total). - -

-Philosopher Loop -

- -Each philosopher is implemented as a loop: - -
-#pats2xhtml_dats('\
-implement
-phil_loop (n) = let
-//
-val () = phil_think (n)
-//
-val nl = phil_left (n) // = n
-val nr = phil_right (n) // = (n+1) % 5
-//
-val ch_lfork = fork_changet (nl)
-val ch_rfork = fork_changet (nr)
-//
-val lf = channel_takeout (ch_lfork)
-val () = println! ("phil_loop(", n, ") picks left fork")
-//
-val () = randsleep (2) // sleep up to 2 seconds
-//
-val rf = channel_takeout (ch_rfork)
-val () = println! ("phil_loop(", n, ") picks right fork")
-//
-val () = phil_dine (n, lf, rf)
-//
-val ch_forktray = forktray_changet ()
-val () = channel_insert (ch_forktray, lf) // left fork to dirty tray
-val () = channel_insert (ch_forktray, rf) // right fork to dirty tray
-//
-in
-  phil_loop (n)
-end // end of [phil_loop]
-')
- -It should be straighforward to follow the code for [phil_loop]. - -

-Fork Cleaner Loop -

- -A cleaner is implemented as a loop: - -
-#pats2xhtml_dats('\
-implement
-cleaner_loop () = let
-//
-val ch = forktray_changet ()
-val f0 = channel_takeout (ch) // [f0] is dirty
-//
-val () = cleaner_wash (f0) // washes dirty [f0]
-val () = cleaner_return (f0) // puts back cleaned [f0]
-//
-in
-  cleaner_loop ()
-end // end of [cleaner_loop]
-')
- -The function [cleaner_return] first finds out the number of a given fork -and then uses the number to locate the channel for storing the fork. Its -actual implementation is given as follows: - -
-#pats2xhtml_dats('\
-implement
-cleaner_return (f) =
-{
-  val n = fork_get_num (f)
-  val ch = fork_changet (n)
-  val () = channel_insert (ch, f)
-}
-')
- -It should now be straighforward to follow the code for [cleaner_loop]. - -

-Testing -

- -The entire code of this implementation is stored in the following files: - -
-DiningPhil2.sats
-DiningPhil2.dats
-DiningPhil2_fork.dats
-DiningPhil2_thread.dats
-
- -There is also a Makefile available for compiling the ATS source code into -an excutable for testing. One should be able to encounter a deadlock after -running the simulation for a while. - -
- -This article is written by Hongwei Xi. - - - - -%{ -implement main () = fprint_filsub (stdout_ref, "main_atxt.txt") -%} diff --git a/samples/Ant Build System/filenames/ant.xml b/samples/Ant Build System/filenames/ant.xml new file mode 100644 index 00000000..54e96ddc --- /dev/null +++ b/samples/Ant Build System/filenames/ant.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/Ant Build System/filenames/build.xml b/samples/Ant Build System/filenames/build.xml new file mode 120000 index 00000000..6c7d5cd4 --- /dev/null +++ b/samples/Ant Build System/filenames/build.xml @@ -0,0 +1 @@ +ant.xml \ No newline at end of file diff --git a/samples/Assembly/External Interrupt.a51 b/samples/Assembly/External Interrupt.a51 new file mode 100644 index 00000000..33feadc2 --- /dev/null +++ b/samples/Assembly/External Interrupt.a51 @@ -0,0 +1,66 @@ + ORG 0000h + SJMP START + ORG 0003h + LCALL INT0_ISR + RETI + ORG 000Bh + LCALL T0_ISR + RETI + ORG 0013h + LCALL INT1_ISR + RETI + ORG 001Bh + LCALL T1_ISR + RETI + ORG 0023h + LCALL UART_ISR + RETI + ORG 0030h +START: + MOV A,#11111110b + SETB IT0 ; Set External Interrupt 0 to be falling edge triggered + SETB EX0 ; Enable External Interrut 0 + SETB EA ; Enable Interrupt +LEFT: + CJNE A,#01111111b,LOOP1 + JMP RIGHT +LOOP1: + MOV P1,A + RL A + LCALL DELAY + SJMP LEFT +RIGHT: + CJNE A,#11111110b,LOOP2 + JMP LEFT +LOOP2: + MOV P1,A + RR A + LCALL DELAY + SJMP RIGHT + +INT0_ISR: + MOV R1,#3 +FLASH: + MOV P1,#00h + LCALL DELAY + MOV P1,#0FFh + LCALL DELAY + DJNZ R1,FLASH + RET +T0_ISR: + RET +INT1_ISR: + RET +T1_ISR: + RET +UART_ISR: + RET + +DELAY: MOV R5,#20 ;R5*20 mS +D1: MOV R6,#40 +D2: MOV R7,#249 + DJNZ R7,$ + DJNZ R6,D2 + DJNZ R5,D1 + RET + END diff --git a/samples/Assembly/forth.nasm b/samples/Assembly/forth.nasm new file mode 100644 index 00000000..c411c7ff --- /dev/null +++ b/samples/Assembly/forth.nasm @@ -0,0 +1,2841 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; A Forth by Chris Hinsley +;; nasm -f macho forth.nasm +;; ld -o forth -e _main forth.o +;; ./forth +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + %define VERSION_NUM 30 + + ; various buffer area sizes + %define DATA_STACK_SIZE 1024 + %define USER_DEFS_SIZE (64*1024) + %define NUM_HASH_CHAINS 64 + %define MAX_LINE_SIZE 128 + + %define SYS_exit 1 + %define SYS_read 3 + %define SYS_write 4 + %define SYS_open 5 + %define SYS_close 6 + %define SYS_unlink 10 + %define SYS_mprotect 74 + %define SYS_fsync 95 + %define SYS_rename 128 + %define SYS_stat 188 + %define SYS_lseek 199 + %define SYS_fstat 189 + %define SYS_ftruncate 201 + + %define PROT_READ 0x01 ;pages can be read + %define PROT_WRITE 0x02 ;pages can be written + %define PROT_EXEC 0x04 ;pages can be executed + %define PROT_ALL (PROT_READ | PROT_WRITE | PROT_EXEC) + %define PAGE_SIZE 4096 + +;;;;;;;;;;;;;;;;;;;;;;;;;; +; some NASM codeing macros +;;;;;;;;;;;;;;;;;;;;;;;;;; + + %macro loopstart 0 + %push loopstart + %$loop_start: + %endmacro + + %macro break 0 + jmp %$loop_exit + %endmacro + + %macro breakif 1 + j%+1 %$loop_exit + %endmacro + + %macro loopend 0 + jmp %$loop_start + %$loop_exit: + %pop + %endmacro + + %macro repeat 0 + %push repeat + %$loop_start: + %endmacro + + %macro until 1 + j%-1 %$loop_start + %$loop_exit: + %pop + %endmacro + + %macro if 1 + %push if + j%-1 %$ifnot + %endmacro + + %macro else 0 + %ifctx if + %repl else + jmp %$ifend + %$ifnot: + %else + %error "expected `if' before `else'" + %endif + %endmacro + + %macro endif 0 + %ifctx if + %$ifnot: + %pop + %elifctx else + %$ifend: + %pop + %else + %error "expected `if' or `else' before `endif'" + %endif + %endmacro + +;;;;;;;;;;;;;;;; +; base VM macros +;;;;;;;;;;;;;;;; + + ; eip Forths IP + ; esp Forths R + ; ebp Forths S + ; ebx Forths TOS + + ; push on to return stack + %macro PUSHRSP 1 + push %1 + %endm + + ; pop top of return stack + %macro POPRSP 1 + pop %1 + %endm + + ; save into return stack + %macro PUTRSP 2 + %if (%2 = 0) + mov [esp], %1 + %elif ((%2 >= -128) && (%2 < 128)) + mov [byte esp + %2], %1 + %else + mov [long esp + %2], %1 + %endif + %endm + + ; load from return stack + %macro PICKRSP 2 + %if (%2 = 0) + mov %1, [esp] + %elif ((%2 >= -128) && (%2 < 128)) + mov %1, [byte esp + %2] + %else + mov %1, [long esp + %2] + %endif + %endm + + ; set return stack + %macro SETRSP 1 + mov esp, %1 + %endm + + ; get return stack + %macro GETRSP 1 + mov %1, esp + %endm + + ; adjust return stack + %macro ADDRSP 1 + %if ((%1 >= -128) && (%1 < 128)) + add esp, byte %1 + %else + add esp, %1 + %endif + %endm + + ; push on to data stack + %macro PUSHDSP 1 + sub ebp, byte 4 + mov [ebp], %1 + %endm + + ; pop top of data stack + %macro POPDSP 1 + mov %1, [ebp] + add ebp, byte 4 + %endm + + ; save into data stack + %macro PUTDSP 2 + %if (%2 = 0) + mov [ebp], %1 + %elif ((%2 >= -128) && (%2 < 128)) + mov [byte ebp + %2], %1 + %else + mov [long ebp + %2], %1 + %endif + %endm + + ; load from data stack + %macro PICKDSP 2 + %if (%2 = 0) + mov %1, [ebp] + %elif ((%2 >= -128) && (%2 < 128)) + mov %1, [byte ebp + %2] + %else + mov %1, [long ebp + %2] + %endif + %endm + + ; set data stack + %macro SETDSP 1 + mov ebp, %1 + %endm + + ; get data stack + %macro GETDSP 1 + mov %1, ebp + %endm + + ; adjust data stack + %macro ADDDSP 1 + %if ((%1 >= -128) && (%1 < 128)) + add ebp, byte %1 + %else + add ebp, %1 + %endif + %endm + + ; load value onto data stack + %macro LOADTOS 1 + PUSHDSP ebx + mov ebx, %1 + %endm + + ; move from data to return stack + %macro TORSP 0 + PUSHRSP ebx + POPDSP ebx + %endm + + ; move from return to data stack + %macro FROMRSP 0 + PUSHDSP ebx + POPRSP ebx + %endm + + ; copy from return to data stack + %macro FETCHRSP 0 + PUSHDSP ebx + PICKRSP ebx, 0 + %endm + + ; align reg + %define DP_ALIGN 3 + %macro ALIGNREG 1 + add %1, byte DP_ALIGN + and %1, byte ~DP_ALIGN + %endm + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; dictionary building macros +;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + ; format of dictionary entry flag byte + %define F_IMMED 0x80 + %define F_HIDDEN 0x20 + %define F_LENMASK 0x1f + + %define NULL 0 + %define H_LLINK 0 + %define H_HLINK 4 + %define H_NSIZE 8 + %define H_NAME 9 + + %define XT_BODY -12 + %define XT_LENGTH -8 + %define XT_COMPILE -4 + %define XT_SIZE 12 + + %macro defword 4 + %push newword + %strlen len %1 + align 4 + dic_%3: + dd NULL ; LATEST list link + dd NULL ; hash chain link + db len + %2 ; flags + length byte + db %1 ; the name + dd %3 ; body pointer + dd %$code_end - %3 ; code length + dd %4 ; compile action word + %3: + %endm ; assembler code follows + + %macro defword_end 0 + %$code_end: + %pop + %endm + + %macro defvar 4 + defword %1, %2, %3, WORD_INLINE_COMMA + LOADTOS var_%3 + ret + defword_end + align 4 + var_%3: + dd %4 + %endm + + %macro defvar2 5 + defword %1, %2, %3, WORD_INLINE_COMMA + LOADTOS var_%3 + ret + defword_end + align 4 + var_%3: + dd %4 + dd %5 + %endm + + %macro defconst 4 + defword %1, %2, %3, WORD_INLINE_COMMA + LOADTOS %4 + ret + defword_end + %endm + +;;;;;;;;;;;;;;;;;;;;;;;;;; +; entry point +;;;;;;;;;;;;;;;;;;;;;;;;;; + + SECTION .text + global _main +_main: + ; use mprotect to allow read/write/execute of the data section + mov edx, forth_start + and edx, -PAGE_SIZE ;start address + mov ecx, forth_end + sub ecx, edx ;length + mov ebx, PROT_ALL ;flags + push ebx + push ecx + push edx + push 0 ;padding + mov eax, SYS_mprotect + int 0x80 + add esp, 16 + jmp forth_start + + SECTION .data +forth_start: + ; init data and return stacks, saving initial positions + ; in Forth vars R0 and S0 + cld + GETRSP [var_WORD_SZ] + SETDSP [var_WORD_SZ] + ADDRSP -DATA_STACK_SIZE + GETRSP [var_WORD_RZ] + + ; link built in dictionary + mov esi, dictionary_start + xor edi, edi + repeat + lodsd + mov [eax + H_LLINK], edi + mov edi, eax + push esi + mov cl, [eax + H_NSIZE] + and ecx, F_LENMASK + lea esi, [eax + H_NAME] + call strhashi + and ebx, NUM_HASH_CHAINS-1 + mov esi, hash_buckets + mov eax, [esi + (ebx * 4)] + mov [esi + (ebx * 4)], edi + mov [edi + H_HLINK], eax + pop esi + cmp esi, dictionary_end + until z + mov [var_WORD_LATEST], edi + + ; run temp interpreter loop till we can get into the real QUIT word + call WORD_LBRAC ; interpret state + LOADTOS 666q ; octal ! + TORSP + LOADTOS 0 + TORSP + LOADTOS bootfile + TORSP + call WORD_SYS_OPEN + call WORD_SYSCALL + ADDRSP 12 + TORSP ; ( fd ) of "forth.f" + loopstart + LOADTOS tib_buffer + LOADTOS MAX_LINE_SIZE + FETCHRSP ; ( c-addr len fd ) + call WORD_READLINE ; ( num flag flag ) + call WORD_DROP2 + LOADTOS tib_buffer + call WORD_SWAP + call WORD_INHASH + call WORD_STORE2 + LOADTOS 0 + call WORD_TOIN + call WORD_STORE + call WORD_INTERPRET + loopend ; and loop till QUIT takes over + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; a few case insensative string operations +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + %macro to_lower 1 + ; lower case check + cmp %1, 'A' + if ge + cmp %1, 'Z' + if le + ; make it lower case + add %1, byte 'a' - 'A' + endif + endif + %endm + +strcpyi: + test ecx, ecx + if nz + strcpyi_l1: + lodsb + to_lower al + stosb + loop strcpyi_l1 + endif + ret + +strcmpi: + test ecx, ecx + if nz + strcmpi_l1: + lodsb + mov bl, [edi] + lea edi, [edi + 1] + to_lower al + to_lower bl + cmp bl, al + if z + loop strcmpi_l1 + endif + endif + ret + +;;;;;;;;;;;;;;; +; hash function +;;;;;;;;;;;;;;; + +strhashi: + mov ebx, 5381 + test ecx, ecx + if nz + mov edx, 33 + strhashi_l1: + lodsb + movzx eax, al + to_lower eax + imul ebx, edx + add ebx, eax + loop strhashi_l1 + endif + ret + +;;;;;;;;;;;;;;;;;;; +; syscall functions +;;;;;;;;;;;;;;;;;;; + +_syscall: + int 0x80 + if c + neg eax + endif + ret + +_lsyscall: + int 0x80 + if c + not eax + not edx + add eax, 1 + adc edx, 0 + endif + ret + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; built in variables +; STATE Is the interpreter executing code (0) or compiling a word (non-zero)? +; LATEST Points to the latest (most recently defined) word in the dictionary. +; DP Points to the next free byte of memory. When compiling, compiled words go here. +; S0 Stores the address of the top of the parameter stack. +; R0 The address of the top of the return stack. +; BASE The current base for printing and reading numbers. +; #IN The current input buffer descriptor. +; >IN The current input offset. +; SOURCEFD The current input source file descriptor. +; BLK The current block number. +; CHARBUF Single char buffer. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + defvar "state", 0, WORD_STATE, 0 + defvar "dp", 0, WORD_DP, dictionary_start + defvar "latest", 0, WORD_LATEST, 0 + defvar "s0", 0, WORD_SZ, 0 + defvar "r0", 0, WORD_RZ, 0 + defvar "base", 0, WORD_BASE, 10 + defvar2 "#IN", 0, WORD_INHASH, 0, 0 + defvar ">in", 0, WORD_TOIN, 0 + defvar "sourcefd", 0, WORD_SOURCEFD, 0 + defvar "blk", 0, WORD_BLK, 0 + defvar "charbuf", 0, WORD_CHARBUF, 0 + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; built in constants +; VERSION The current version of this FORTH. +; WORDBUF The address of the buffer WORD uses. +; LINESIZE The line buffer size. +; F_IMMED The IMMEDIATE flag's actual value. +; F_HIDDEN The HIDDEN flag's actual value. +; F_LENMASK The length mask in the flags/len byte. +; H_NSIZE The flags/len field offset. +; H_NAME The name field offset. +; XT_BODY The xt body pointer. +; XT_LENGTH The xt length field offset. +; XT_COMPILE The xt compile field offset. +; XT_SIZE The xt size offset. +; SYS_* The numeric codes of various syscalls. +; O_* Various sycall flags/modes. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + defconst "version", 0, WORD_VERSION, VERSION_NUM + defconst "wordbuf", 0, WORD_WORDBUF, word_buf + defconst "linesize", 0, WORD_LINESIZE, MAX_LINE_SIZE + defconst "f_immed", 0, WORD__F_IMMED, F_IMMED + defconst "f_hidden", 0, WORD__F_HIDDEN, F_HIDDEN + defconst "f_lenmask", 0, WORD__F_LENMASK, F_LENMASK + defconst "h_nsize", 0, WORD__H_NSIZE, H_NSIZE + defconst "h_name", 0, WORD__H_NAME, H_NAME + defconst "xt_body", 0, WORD__XT_BODY, XT_BODY + defconst "xt_length", 0, WORD__XT_LENGTH, XT_LENGTH + defconst "xt_compile", 0, WORD__XT_COMPILE, XT_COMPILE + defconst "xt_size", 0, WORD__XT_SIZE, XT_SIZE + + defconst "sys_exit", 0, WORD_SYS_EXIT, SYS_exit + defconst "sys_open", 0, WORD_SYS_OPEN, SYS_open + defconst "sys_close", 0, WORD_SYS_CLOSE, SYS_close + defconst "sys_read", 0, WORD_SYS_READ, SYS_read + defconst "sys_write", 0, WORD_SYS_WRITE, SYS_write + defconst "sys_unlink", 0, WORD_SYS_UNLINK, SYS_unlink + defconst "sys_rename", 0, WORD_SYS_RENAME, SYS_rename + defconst "sys_ftruncate", 0, WORD_SYS_FTRUNCATE, SYS_ftruncate + defconst "sys_fsync", 0, WORD_SYS_FSYNC, SYS_fsync + defconst "sys_lseek", 0, WORD_SYS_LSEEK, SYS_lseek + defconst "sys_fstat", 0, WORD_SYS_FSTAT, SYS_fstat + defconst "sys_stat", 0, WORD_SYS_STAT, SYS_stat + + defconst "o_rdonly", 0, WORD_O_RDONLY, 0x0 + defconst "o_wronly", 0, WORD_O_WRONLY, 0x1 + defconst "o_rdwr", 0, WORD_O_RDWR, 0x2 + defconst "o_creat", 0, WORD_O_CREAT, 0x100 + defconst "o_excl", 0, WORD_O_EXCL, 0x200 + defconst "o_trunc", 0, WORD_O_TRUNC, 0x1000 + defconst "o_append", 0, WORD_O_APPEND, 0x2000 + defconst "o_nonblock", 0, WORD_O_NONBLOCK, 0x4000 + +;;;;;;;;;;;;;;;;;;;;;;;;;;; +; data stack ordering words +;;;;;;;;;;;;;;;;;;;;;;;;;;; + + defword "dsp@", 0, WORD_DSPFETCH, WORD_INLINE_COMMA + PUSHDSP ebx + GETDSP ebx + ret + defword_end + + defword "dsp!", 0, WORD_DSPSTORE, WORD_INLINE_COMMA + SETDSP ebx + POPDSP ebx + ret + defword_end + + defword "drop", 0, WORD_DROP, WORD_INLINE_COMMA + POPDSP ebx + ret + defword_end + + defword "swap", 0, WORD_SWAP, WORD_INLINE_COMMA + xchg ebx, [ebp] + ret + defword_end + + defword "dup", 0, WORD_DUP, WORD_INLINE_COMMA + PUSHDSP ebx + ret + defword_end + + defword "over", 0, WORD_OVER, WORD_INLINE_COMMA + PUSHDSP ebx + PICKDSP ebx, 4 + ret + defword_end + + defword "rot", 0, WORD_ROT, WORD_INLINE_COMMA + mov eax, ebx + PICKDSP ecx, 0 + PICKDSP ebx, 4 + PUTDSP eax, 0 + PUTDSP ecx, 4 + ret + defword_end + + defword "-rot", 0, WORD_NROT, WORD_INLINE_COMMA + mov eax, ebx + PICKDSP ebx, 0 + PICKDSP ecx, 4 + PUTDSP ecx, 0 + PUTDSP eax, 4 + ret + defword_end + + defword "2drop", 0, WORD_DROP2, WORD_INLINE_COMMA + PICKDSP ebx, 4 + ADDDSP 8 + ret + defword_end + + defword "2dup", 0, WORD_DUP2, WORD_INLINE_COMMA + PICKDSP eax, 0 + ADDDSP -8 + PUTDSP eax, 0 + PUTDSP ebx, 4 + ret + defword_end + + defword "2swap", 0, WORD_SWAP2, WORD_INLINE_COMMA + mov eax, ebx + PICKDSP ecx, 0 + PICKDSP ebx, 4 + PICKDSP edx, 8 + PUTDSP edx, 0 + PUTDSP eax, 4 + PUTDSP ecx, 8 + ret + defword_end + + defword "2rot", 0, WORD_ROT2, WORD_INLINE_COMMA + mov eax, ebx + PICKDSP ecx, 16 + PICKDSP ebx, 12 + PICKDSP edx, 8 + PICKDSP edi, 4 + PICKDSP esi, 0 + PUTDSP edx, 16 + PUTDSP edi, 12 + PUTDSP esi, 8 + PUTDSP eax, 4 + PUTDSP ecx, 0 + ret + defword_end + + defword "?dup", 0, WORD_QDUP, WORD_INLINE_COMMA + test ebx, ebx + if nz + PUSHDSP ebx + endif + ret + defword_end + + defword "!?dup", 0, WORD_NQDUP, WORD_INLINE_COMMA + test ebx, ebx + if z + PUSHDSP ebx + endif + ret + defword_end + + defword "nip", 0, WORD_NIP, WORD_INLINE_COMMA + ADDDSP 4 + ret + defword_end + + defword "tuck", 0, WORD_TUCK, WORD_INLINE_COMMA + PICKDSP eax, 0 + PUTDSP ebx, 0 + PUSHDSP eax + ret + defword_end + + defword "pick", 0, WORD_PICK, WORD_INLINE_COMMA + mov ebx, [ebp + (ebx * 4)] + ret + defword_end + + defword "2tuck", 0, WORD_TUCK2, WORD_INLINE_COMMA + PICKDSP eax, 0 + PICKDSP ecx, 4 + PICKDSP edx, 8 + ADDDSP -8 + PUTDSP eax, 0 + PUTDSP ecx, 4 + PUTDSP edx, 8 + PUTDSP ebx, 12 + PUTDSP eax, 16 + ret + defword_end + + defword "2nip", 0, WORD_NIP2, WORD_INLINE_COMMA + PICKDSP eax, 0 + ADDDSP 8 + PUTDSP eax, 0 + ret + defword_end + + defword "2over", 0, WORD_OVER2, WORD_INLINE_COMMA + ADDDSP -8 + PUTDSP ebx, 4 + PICKDSP ebx, 16 + PUTDSP ebx, 0 + PICKDSP ebx, 12 + ret + defword_end + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; return stack ordering words +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + defword ">r", 0, WORD_TOR, WORD_INLINE_COMMA + TORSP + ret + defword_end + + defword "r>", 0, WORD_FROMR, WORD_INLINE_COMMA + FROMRSP + ret + defword_end + + defword "2>r", 0, WORD_TOR2, WORD_INLINE_COMMA + ADDRSP -8 + PICKDSP ecx, 0 + PUTRSP ebx, 0 + PUTRSP ecx, 4 + PICKDSP ebx, 4 + ADDDSP 8 + ret + defword_end + + defword "2r>", 0, WORD_FROMR2, WORD_INLINE_COMMA + ADDDSP -8 + PUTDSP ebx, 4 + PICKRSP ebx, 0 + PICKRSP ecx, 4 + PUTDSP ecx, 0 + ADDRSP 8 + ret + defword_end + + defword "rsp@", 0, WORD_RSPFETCH, WORD_INLINE_COMMA + PUSHDSP ebx + GETRSP ebx + ret + defword_end + + defword "r@", 0, WORD_RFETCH, WORD_INLINE_COMMA + PUSHDSP ebx + PICKRSP ebx, 0 + ret + defword_end + + defword "r!", 0, WORD_RSTORE, WORD_INLINE_COMMA + PUTRSP ebx, 0 + POPDSP ebx + ret + defword_end + + defword "2r@", 0, WORD_RFETCH2, WORD_INLINE_COMMA + ADDDSP -8 + PUTDSP ebx, 4 + PICKRSP ebx, 4 + PICKRSP ecx, 0 + PUTDSP ecx, 0 + ret + defword_end + + defword "rsp!", 0, WORD_RSPSTORE, WORD_INLINE_COMMA + SETRSP ebx + POPDSP ebx + ret + defword_end + + defword "rdrop", 0, WORD_RDROP, WORD_INLINE_COMMA + ADDRSP 4 + ret + defword_end + + defword "2rdrop", 0, WORD_RDROP2, WORD_INLINE_COMMA + ADDRSP 8 + ret + defword_end + + defword "n>r", 0, WORD_NTOR, WORD_CALL_COMMA + PUSHDSP ebx + PICKRSP eax, 0 + mov ecx, ebx + inc ecx + neg ebx + lea esp, [esp + (ebx * 4)] + mov esi, ebp + mov edi, esp + rep movsd + mov ebp, esi + POPDSP ebx + jmp eax + defword_end + + defword "nr>", 0, WORD_NFROMR, WORD_CALL_COMMA + PUSHDSP ebx + POPRSP eax + PICKRSP ebx, 0 + inc ebx + mov ecx, ebx + neg ebx + lea ebp, [ebp + (ebx * 4)] + mov esi, esp + mov edi, ebp + rep movsd + mov esp, esi + POPDSP ebx + jmp eax + defword_end + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; memory fetch and store words +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + defword "!", 0, WORD_STORE, WORD_INLINE_COMMA + PICKDSP eax, 0 + mov [ebx], eax + PICKDSP ebx, 4 + ADDDSP 8 + ret + defword_end + + defword "@", 0, WORD_FETCH, WORD_INLINE_COMMA + mov ebx, [ebx] + ret + defword_end + + defword "+!", 0, WORD_ADDSTORE, WORD_INLINE_COMMA + PICKDSP eax, 0 + add [ebx], eax + PICKDSP ebx, 4 + ADDDSP 8 + ret + defword_end + + defword "-!", 0, WORD_SUBSTORE, WORD_INLINE_COMMA + PICKDSP eax, 0 + sub [ebx], eax + PICKDSP ebx, 4 + ADDDSP 8 + ret + defword_end + + defword "c!", 0, WORD_STOREBYTE, WORD_INLINE_COMMA + PICKDSP eax, 0 + mov [ebx], al + PICKDSP ebx, 4 + ADDDSP 8 + ret + defword_end + + defword "c+!", 0, WORD_ADDBYTE, WORD_INLINE_COMMA + PICKDSP eax, 0 + add [ebx], al + PICKDSP ebx, 4 + ADDDSP 8 + ret + defword_end + + defword "c@", 0, WORD_FETCHBYTE, WORD_INLINE_COMMA + mov eax, ebx + xor ebx, ebx + mov bl, [eax] + ret + defword_end + + defword "w!", 0, WORD_STORESHORT, WORD_INLINE_COMMA + PICKDSP eax, 0 + mov [ebx], ax + PICKDSP ebx, 4 + ADDDSP 8 + ret + defword_end + + defword "w@", 0, WORD_FETCHSHORT, WORD_INLINE_COMMA + mov eax, ebx + xor ebx, ebx + mov bx, [eax] + ret + defword_end + + defword "2!", 0, WORD_STORE2, WORD_INLINE_COMMA + PICKDSP ecx, 4 + PICKDSP edx, 0 + mov [ebx + 4], ecx + mov [ebx], edx + PICKDSP ebx, 8 + ADDDSP 12 + ret + defword_end + + defword "2@", 0, WORD_FETCH2, WORD_INLINE_COMMA + ADDDSP -4 + mov ecx, [ebx +4] + mov ebx, [ebx] + PUTDSP ecx, 0 + ret + defword_end + + defword "blank", 0, WORD_BLANK, WORD_CALL_COMMA + mov ecx, ebx + PICKDSP ebx, 4 + PICKDSP edi, 0 + ADDDSP 8 + mov eax, 0x20 + rep stosb + ret + defword_end + + defword "erase", 0, WORD_ERASE, WORD_CALL_COMMA + mov ecx, ebx + PICKDSP ebx, 4 + PICKDSP edi, 0 + ADDDSP 8 + xor eax, eax + rep stosb + ret + defword_end + + defword "fill", 0, WORD_FILL, WORD_CALL_COMMA + mov eax, ebx + PICKDSP ebx, 8 + PICKDSP edi, 4 + PICKDSP ecx, 0 + ADDDSP 12 + rep stosb + ret + defword_end + + defword "cmove>", 0, WORD_CMOVEB, WORD_CALL_COMMA + mov ecx, ebx + PICKDSP ebx, 8 + PICKDSP esi, 4 + PICKDSP edi, 0 + ADDDSP 12 + lea esi, [esi + ecx - 1] + lea edi, [edi + ecx - 1] + std + rep movsb + cld + ret + defword_end + + defword "cmove", 0, WORD_CMOVE, WORD_CALL_COMMA + mov ecx, ebx + PICKDSP ebx, 8 + PICKDSP esi, 4 + PICKDSP edi, 0 + ADDDSP 12 + rep movsb + ret + defword_end + + defword "move", 0, WORD_MOVE, WORD_CALL_COMMA + mov ecx, ebx + PICKDSP ebx, 8 + PICKDSP esi, 4 + PICKDSP edi, 0 + ADDDSP 12 + cmp esi, edi + if a + rep movsb + else + lea esi, [esi + ecx -1] + lea edi, [edi + ecx -1] + std + rep movsb + cld + endif + ret + defword_end + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; single precision alu words +;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + defword "+", 0, WORD_ADD, WORD_INLINE_COMMA + add ebx, [ebp] + ADDDSP 4 + ret + defword_end + + defword "-", 0, WORD_SUB, WORD_INLINE_COMMA + mov eax, ebx + POPDSP ebx + sub ebx, eax + ret + defword_end + + defword "*", 0, WORD_MULL, WORD_INLINE_COMMA + imul ebx, [ebp] + ADDDSP 4 + ret + defword_end + + defword "/", 0, WORD_DIV, WORD_INLINE_COMMA + POPDSP eax + cdq + idiv ebx + mov ebx, eax + ret + defword_end + + defword "mod", 0, WORD_MOD, WORD_INLINE_COMMA + POPDSP eax + cdq + idiv ebx + mov ebx, edx + ret + defword_end + + defword "1+", 0, WORD_INCR, WORD_INLINE_COMMA + add ebx, byte 1 + ret + defword_end + + defword "1-", 0, WORD_DECR, WORD_INLINE_COMMA + sub ebx, byte 1 + ret + defword_end + + defword "4+", 0, WORD_INCR4, WORD_INLINE_COMMA + add ebx, byte 4 + ret + defword_end + + defword "4-", 0, WORD_DECR4, WORD_INLINE_COMMA + sub ebx, byte 4 + ret + defword_end + + defword "2+", 0, WORD_INCR2, WORD_INLINE_COMMA + add ebx, byte 2 + ret + defword_end + + defword "2-", 0, WORD_DECR2, WORD_INLINE_COMMA + sub ebx, byte 2 + ret + defword_end + + defword "2*", 0, WORD_TWOMUL, WORD_INLINE_COMMA + shl ebx, byte 1 + ret + defword_end + + defword "2/", 0, WORD_TWODIV, WORD_INLINE_COMMA + sar ebx, byte 1 + ret + defword_end + + defword "abs", 0, WORD_ABS, WORD_INLINE_COMMA + mov eax, ebx + sar eax, byte 31 + add ebx, eax + xor ebx, eax + ret + defword_end + + defword "min", 0, WORD_MIN, WORD_INLINE_COMMA + POPDSP eax + cmp ebx, eax + if g + mov ebx, eax + endif + ret + defword_end + + defword "max", 0, WORD_MAX, WORD_INLINE_COMMA + POPDSP eax + cmp ebx, eax + if l + mov ebx, eax + endif + ret + defword_end + + defword "lshift", 0, WORD_LSHIFT, WORD_INLINE_COMMA + mov ecx, ebx + POPDSP ebx + shl ebx, cl + ret + defword_end + + defword "rshift", 0, WORD_RSHIFT, WORD_INLINE_COMMA + mov ecx, ebx + POPDSP ebx + shr ebx, cl + ret + defword_end + + defword "and", 0, WORD_AND, WORD_INLINE_COMMA + and ebx, [ebp] + ADDDSP 4 + ret + defword_end + + defword "or", 0, WORD_OR, WORD_INLINE_COMMA + or ebx, [ebp] + ADDDSP 4 + ret + defword_end + + defword "xor", 0, WORD_XOR, WORD_INLINE_COMMA + xor ebx, [ebp] + ADDDSP 4 + ret + defword_end + + defword "negate", 0, WORD_NEGATE, WORD_INLINE_COMMA + neg ebx + ret + defword_end + + defword "invert", 0, WORD_INVERT, WORD_INLINE_COMMA + not ebx + ret + defword_end + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; single precision comparision words +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + defword "=", 0, WORD_EQ, WORD_INLINE_COMMA + cmp [ebp], ebx + sete bl + ADDDSP 4 + movzx ebx, bl + neg ebx + ret + defword_end + + defword "<>", 0, WORD_NE, WORD_INLINE_COMMA + cmp [ebp], ebx + setne bl + ADDDSP 4 + movzx ebx, bl + neg ebx + ret + defword_end + + defword "<", 0, WORD_LT, WORD_INLINE_COMMA + cmp [ebp], ebx + setl bl + ADDDSP 4 + movzx ebx, bl + neg ebx + ret + defword_end + + defword ">", 0, WORD_GT, WORD_INLINE_COMMA + cmp [ebp], ebx + setg bl + ADDDSP 4 + movzx ebx, bl + neg ebx + ret + defword_end + + defword "u<", 0, WORD_ULT, WORD_INLINE_COMMA + cmp [ebp], ebx + setb bl + ADDDSP 4 + movzx ebx, bl + neg ebx + ret + defword_end + + defword "u>", 0, WORD_UGT, WORD_INLINE_COMMA + cmp [ebp], ebx + seta bl + ADDDSP 4 + movzx ebx, bl + neg ebx + ret + defword_end + + defword "u<=", 0, WORD_ULTEQ, WORD_INLINE_COMMA + cmp [ebp], ebx + setbe bl + ADDDSP 4 + movzx ebx, bl + neg ebx + ret + defword_end + + defword "u>=", 0, WORD_UGTEQ, WORD_INLINE_COMMA + cmp [ebp], ebx + setae bl + ADDDSP 4 + movzx ebx, bl + neg ebx + ret + defword_end + + defword "<=", 0, WORD_LTEQ, WORD_INLINE_COMMA + cmp [ebp], ebx + setle bl + ADDDSP 4 + movzx ebx, bl + neg ebx + ret + defword_end + + defword ">=", 0, WORD_GTEQ, WORD_INLINE_COMMA + cmp [ebp], ebx + setge bl + ADDDSP 4 + movzx ebx, bl + neg ebx + ret + defword_end + + defword "0=", 0, WORD_ZEQ, WORD_INLINE_COMMA + test ebx, ebx + setz bl + movzx ebx, bl + neg ebx + ret + defword_end + + defword "0<>", 0, WORD_ZNE, WORD_INLINE_COMMA + test ebx, ebx + setnz bl + movzx ebx, bl + neg ebx + ret + defword_end + + defword "0<", 0, WORD_ZLT, WORD_INLINE_COMMA + test ebx, ebx + setl bl + movzx ebx, bl + neg ebx + ret + defword_end + + defword "0>", 0, WORD_ZGT, WORD_INLINE_COMMA + test ebx, ebx + setg bl + movzx ebx, bl + neg ebx + ret + defword_end + + defword "0<=", 0, WORD_ZLTEQ, WORD_INLINE_COMMA + test ebx, ebx + setle bl + movzx ebx, bl + neg ebx + ret + defword_end + + defword "0>=", 0, WORD_ZGTEQ, WORD_INLINE_COMMA + test ebx, ebx + setge bl + movzx ebx, bl + neg ebx + ret + defword_end + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; double precision ALU words +;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + defword "s>d", 0, WORD_STOD, WORD_INLINE_COMMA + mov eax, ebx + cdq + PUSHDSP eax + mov ebx, edx + ret + defword_end + + defword "d>s", 0, WORD_DTOS, WORD_INLINE_COMMA + POPDSP ebx + ret + defword_end + + defword "d+", 0, WORD_DPLUS, WORD_INLINE_COMMA + PICKDSP ecx, 8 + PICKDSP edx, 4 + PICKDSP eax, 0 + add eax, ecx + adc ebx, edx + PUTDSP eax, 8 + ADDDSP 8 + ret + defword_end + + defword "d-", 0, WORD_DMINUS, WORD_INLINE_COMMA + PICKDSP ecx, 8 + PICKDSP edx, 4 + PICKDSP eax, 0 + sub ecx, eax + sbb edx, ebx + PUTDSP ecx, 8 + mov ebx, edx + ADDDSP 8 + ret + defword_end + + defword "d2*", 0, WORD_D2STAR, WORD_INLINE_COMMA + PICKDSP eax, 0 + shl eax, 1 + rcl ebx, 1 + PUTDSP eax, 0 + ret + defword_end + + defword "d2/", 0, WORD_D2SLASH, WORD_INLINE_COMMA + PICKDSP eax, 0 + sar ebx, 1 + rcr eax, 1 + PUTDSP eax, 0 + ret + defword_end + + defword "*/", 0, WORD_MULDIV, WORD_INLINE_COMMA + PICKDSP edx, 4 + PICKDSP eax, 0 + imul edx + idiv ebx + mov ebx, eax + ADDDSP 8 + ret + defword_end + + defword "*/mod", 0, WORD_STARSMOD, WORD_INLINE_COMMA + PICKDSP edx, 4 + PICKDSP eax, 0 + imul edx + idiv ebx + PUTDSP edx, 4 + ADDDSP 4 + mov ebx, eax + ret + defword_end + + defword "/mod", 0, WORD_DIVMOD, WORD_INLINE_COMMA + PICKDSP eax, 0 + cdq + idiv ebx + PUTDSP edx, 0 + mov ebx, eax + ret + defword_end + + defword "dnegate", 0, WORD_DNEGATE, WORD_INLINE_COMMA + PICKDSP eax, 0 + not eax + not ebx + add eax, 1 + adc ebx, 0 + PUTDSP eax, 0 + ret + defword_end + + defword "dabs", 0, WORD_DABS, WORD_INLINE_COMMA + test ebx, ebx + if l + PICKDSP eax, 0 + not eax + not ebx + add eax, 1 + adc ebx, 0 + PUTDSP eax, 0 + endif + ret + defword_end + + defword "dmax", 0, WORD_DMAX, WORD_INLINE_COMMA + PICKDSP ecx, 8 + PICKDSP edx, 4 + PICKDSP eax, 0 + ADDDSP 8 + mov esi, ecx + mov edi, edx + sub esi, eax + sbb edi, ebx + if l + PUTDSP eax, 0 + else + mov ebx, edx + endif + ret + defword_end + + defword "dmin", 0, WORD_DMIN, WORD_INLINE_COMMA + PICKDSP ecx, 8 + PICKDSP edx, 4 + PICKDSP eax, 0 + ADDDSP 8 + mov esi, ecx + mov edi, edx + sub esi, eax + sbb edi, ebx + if ge + PUTDSP eax, 0 + else + mov ebx, edx + endif + ret + defword_end + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; double precision comparision words +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + defword "d0=", 0, WORD_DZEQ, WORD_INLINE_COMMA + or ebx, [ebp] + setz bl + ADDDSP 4 + movzx ebx, bl + neg ebx + ret + defword_end + + defword "d0<>", 0, WORD_DZNEQ, WORD_INLINE_COMMA + or ebx, [ebp] + setnz bl + ADDDSP 4 + movzx ebx, bl + neg ebx + ret + defword_end + + defword "d0<", 0, WORD_DZLT, WORD_INLINE_COMMA + test ebx, ebx + setl bl + ADDDSP 4 + movzx ebx, bl + neg ebx + ret + defword_end + + defword "d=", 0, WORD_DEQ, WORD_INLINE_COMMA + PICKDSP ecx, 8 + PICKDSP eax, 4 + sub ecx, [ebp] + sbb eax, ebx + setz bl + ADDDSP 12 + movzx ebx, bl + neg ebx + ret + defword_end + + defword "d<>", 0, WORD_DNEQ, WORD_INLINE_COMMA + PICKDSP ecx, 8 + PICKDSP eax, 4 + sub ecx, [ebp] + sbb eax, ebx + setnz bl + ADDDSP 12 + movzx ebx, bl + neg ebx + ret + defword_end + + defword "d<", 0, WORD_DLT, WORD_INLINE_COMMA + PICKDSP ecx, 8 + PICKDSP eax, 4 + sub ecx, [ebp] + sbb eax, ebx + setl bl + ADDDSP 12 + movzx ebx, bl + neg ebx + ret + defword_end + + defword "du<", 0, WORD_DULT, WORD_INLINE_COMMA + PICKDSP ecx, 8 + PICKDSP eax, 4 + sub ecx, [ebp] + sbb eax, ebx + setb bl + ADDDSP 12 + movzx ebx, bl + neg ebx + ret + defword_end + +;;;;;;;;;;;;;;;;;;;;;;; +; mixed precision words +;;;;;;;;;;;;;;;;;;;;;;; + + defword "m+", 0, WORD_MPLUS, WORD_INLINE_COMMA + PICKDSP eax, 4 + PICKDSP edx, 0 + add eax, ebx + adc edx, 0 + PUTDSP eax, 4 + mov ebx, edx + ADDDSP 4 + ret + defword_end + + defword "m-", 0, WORD_MMINUS, WORD_INLINE_COMMA + PICKDSP eax, 4 + PICKDSP edx, 0 + sub eax, ebx + sbb edx, 0 + PUTDSP eax, 4 + mov ebx, edx + ADDDSP 4 + ret + defword_end + + defword "m*", 0, WORD_MULSTAR, WORD_INLINE_COMMA + PICKDSP eax, 0 + imul ebx + PUTDSP eax, 0 + mov ebx, edx + ret + defword_end + + defword "m/", 0, WORD_MSLASH, WORD_INLINE_COMMA + PICKDSP eax, 4 + PICKDSP edx, 0 + idiv ebx + mov ebx, eax + ADDDSP 8 + ret + defword_end + + defword "um*", 0, WORD_UMULSTAR, WORD_INLINE_COMMA + PICKDSP eax, 0 + mul ebx + PUTDSP eax, 0 + mov ebx, edx + ret + defword_end + + defword "um/mod", 0, WORD_UMDIVMOD, WORD_INLINE_COMMA + PICKDSP eax, 4 + PICKDSP edx, 0 + div ebx + PUTDSP edx, 4 + mov ebx, eax + ADDDSP 4 + ret + defword_end + + defword "fm/mod", 0, WORD_FMDIVMOD, WORD_INLINE_COMMA + PICKDSP edx, 0 + PICKDSP eax, 4 + mov ecx, ebx + ADDDSP 4 + xor ecx, edx + idiv ebx + test ecx, ecx + if s + test edx, edx + if nz + dec eax + add edx, ebx + endif + endif + PUTDSP edx, 0 + mov ebx, eax + ret + defword_end + + defword "sm/rem", 0, WORD_SMDIVREM, WORD_INLINE_COMMA + PICKDSP eax, 4 + PICKDSP edx, 0 + idiv ebx + PUTDSP edx, 4 + mov ebx, eax + ADDDSP 4 + ret + defword_end + + defword "u/mod", 0, WORD_UDIVMOD, WORD_INLINE_COMMA + xor edx, edx + PICKDSP eax, 0 + div ebx + PUTDSP edx, 0 + mov ebx, eax + ret + defword_end + + defword "dm*", 0, WORD_DMULSTAR, WORD_CALL_COMMA + call WORD_TUCK + call WORD_MULL + TORSP + call WORD_UMULSTAR + FROMRSP + call WORD_ADD + ret + defword_end + +;;;;;;;;;;;;;;;;;;;; +; control flow words +;;;;;;;;;;;;;;;;;;;; + + defword "branch", 0, WORD_BRANCH, WORD_INLINE_COMMA +i_jmp: + jmp strict near i_ret + ret + defword_end + + defword "0branch", 0, WORD_ZBRANCH, WORD_INLINE_COMMA + mov eax, ebx + POPDSP ebx + test eax, eax + jz strict near i_jmp + ret + defword_end + + defword "exit", 0, WORD_EXIT, WORD_EXIT_COMMA +i_ret: + ret + defword_end + + defword "exit,", 0, WORD_EXIT_COMMA, WORD_CALL_COMMA + mov edi, [var_WORD_DP] + sub edi, 5 + cmp edi, [lastcall] ; are we just after a call instruction ? + if z + mov al, [i_jmp] + mov [edi], al ; change it to a jmp + endif + mov edi, [var_WORD_DP] + mov al, [i_ret] + stosb + mov [var_WORD_DP], edi + POPDSP ebx + ret + defword_end + + defword "execute", 0, WORD_EXECUTE, WORD_CALL_COMMA + mov eax, ebx ; Get xt into eax + POPDSP ebx ; After xt runs its ret will continue executing the current word. + jmp eax ; and jump to it. + defword_end + +;;;;;;;;;;;;;;;;;;;;;;;;;; +; terminal input words +;;;;;;;;;;;;;;;;;;;;;;;;;; + + defword "read-char", 0, WORD_READCHAR, WORD_CALL_COMMA + mov ecx, var_WORD_CHARBUF ; 2nd param: buffer + mov edx, 1 ; 3rd param: max length + push edx + push ecx + push ebx + mov eax, SYS_read ; syscall: read + call _syscall + add esp, 12 + xor ebx, ebx + test eax, eax + if be + mov ebx, -1 + endif + ret + defword_end + + defword "read-line", 0, WORD_READLINE, WORD_CALL_COMMA + call WORD_NROT + call WORD_OVER + call WORD_ADD + call WORD_OVER ; ( fd start end cur ) +readline_l1: + PICKDSP eax, 0 + cmp ebx, eax + jz readline_l4 + PUSHDSP ebx + PICKDSP ebx, 12 + call WORD_READCHAR + test ebx, ebx + jz readline_l2 + call WORD_DROP + call WORD_DROP2 + call WORD_DROP2 + LOADTOS 0 + LOADTOS 0 + LOADTOS -1 + jmp readline_l5 +readline_l2: + mov ebx, [var_WORD_CHARBUF] + cmp ebx, 10 ; LF + jz readline_l3 + call WORD_OVER + call WORD_STOREBYTE + call WORD_INCR + jmp readline_l1 +readline_l3: + call WORD_DROP +readline_l4: + call WORD_NIP + call WORD_SWAP + call WORD_SUB + call WORD_NIP + LOADTOS -1 + LOADTOS 0 +readline_l5: + ret + defword_end + + defword "key", 0, WORD_KEY, WORD_CALL_COMMA + PUSHDSP ebx + xor ebx, ebx ; stdin + call WORD_READCHAR + mov ebx, [var_WORD_CHARBUF] + ret + defword_end + + defword "accept", 0, WORD_ACCEPT, WORD_CALL_COMMA + call WORD_OVER + call WORD_ADD + call WORD_OVER ; ( start end cur ) +accept_l1: + call WORD_KEY + cmp ebx, 127 ; BS + jz accept_l2 + cmp ebx, 10 ; LF + jz accept_l3 + call WORD_OVER ; ( start end cur key cur ) + call WORD_STOREBYTE + call WORD_INCR ; ( start end cur' ) + PICKDSP eax, 0 + cmp ebx, eax + jz accept_l4 + jmp accept_l1 +accept_l2: + PICKDSP eax, 4 ; ( start end cur' ) + cmp ebx, eax + jz accept_l1 + call WORD_DECR + jmp accept_l1 +accept_l3: + call WORD_DROP ; ( start end cur' ) +accept_l4: + call WORD_NIP + call WORD_SWAP + call WORD_SUB + ret + defword_end + + defword "tabs>spaces", 0, WORD_TABSTOSPACES, WORD_CALL_COMMA + mov ecx, ebx + POPDSP esi + test ecx, ecx + if nz + repeat + lodsb + cmp al, 9 ;TAB + if z + mov byte [esi - 1], ' ' + endif + dec ecx + until z + endif + POPDSP ebx + ret + defword_end + +;;;;;;;;;;;;;;;;;;;;;;; +; terminal output words +;;;;;;;;;;;;;;;;;;;;;;; + + defword "type-fd", 0, WORD_TYPE_FD, WORD_CALL_COMMA + PICKDSP edx, 0 ; 3rd param: length of string + PICKDSP ecx, 4 ; 2nd param: address of string + ADDDSP 8 ; 1st param: FD in ebx + mov eax, SYS_write ; write syscall + push edx + push ecx + push ebx + call _syscall + add esp, 12 + POPDSP ebx + ret + defword_end + + defword "type", 0, WORD_TYPE, WORD_CALL_COMMA + LOADTOS 1 ; stdout + call WORD_TYPE_FD + ret + defword_end + + defword "emit", 0, WORD_EMIT, WORD_CALL_COMMA + mov [emit_scratch], bl ; write needs the address of the byte to write + mov ebx, emit_scratch + LOADTOS 1 + call WORD_TYPE + ret + defword_end + +;;;;;;;;;;;;;;;;;;; +; system call words +;;;;;;;;;;;;;;;;;;; + + defword "syscall", 0, WORD_SYSCALL, WORD_CALL_COMMA + pop eax + mov [syscallret], eax ; save return address + mov eax, ebx ; System call number (see ) + call _syscall + mov ebx, eax ; Result (negative for -errno) + jmp [syscallret] ; return to caller + defword_end + + defword "lsyscall", 0, WORD_LSYSCALL, WORD_CALL_COMMA + pop eax + mov [syscallret], eax ; save return address + mov eax, ebx ; System call number (see ) + call _lsyscall + PUSHDSP eax + mov ebx, edx ; Result (negative for -errno) + jmp [syscallret] ; return to caller + defword_end + +;;;;;;;;;;;;;; +; string words +;;;;;;;;;;;;;; + + defword "count", 0, WORD_COUNT, WORD_CALL_COMMA + xor eax, eax + mov al, [ebx] + inc ebx + LOADTOS eax + ret + defword_end + + defword "-trailing", 0, WORD_TRAILING, WORD_CALL_COMMA + test ebx, ebx + if nz + PICKDSP esi, 0 + mov ecx, ebx + add esi, ebx + dec esi + std + trailing_l1: + lodsb + cmp al, ' ' + if be + loop trailing_l1 + endif + mov ebx, ecx + cld + endif + ret + defword_end + + defword "/string", 0, WORD_SSTRING, WORD_CALL_COMMA + mov eax, ebx + POPDSP ebx + PICKDSP ecx, 0 + sub ebx, eax + add ecx, eax + PUTDSP ecx, 0 + ret + defword_end + + defword "compare", 0, WORD_COMPARE, WORD_CALL_COMMA + PICKDSP esi, 8 + PICKDSP edx, 4 + PICKDSP edi, 0 + ADDDSP 12 + mov ecx, ebx + cmp edx, ebx + if be + mov ecx, edx + endif + test ecx, ecx ; ecx lowest length + jnz compare_l2 + cmp edx, ebx + jz compare_l3 ; both are 0 length + jmp compare_l4 ; otherwise the longest wins +compare_l2: + cmpsb + jnz compare_l4 ; chars not same + loop compare_l2 + cmp edx, ebx ; all chars same + jnz compare_l4 ; strings not same size +compare_l3: + xor ebx, ebx ; same + jmp compare_l7 +compare_l4: + ja compare_l6 +compare_l5: + mov ebx, -1 + jmp compare_l7 +compare_l6: + mov ebx, 1 +compare_l7: + ret + defword_end + + defword "icompare", 0, WORD_COMPAREI, WORD_CALL_COMMA + PICKDSP esi, 8 + PICKDSP edx, 4 + PICKDSP edi, 0 + ADDDSP 12 + mov ecx, ebx + cmp edx, ebx + if be + mov ecx, edx + endif + test ecx, ecx ; ecx lowest length + jnz comparei_l2 + cmp edx, ebx + jz comparei_l3 ; both are 0 length + jmp comparei_l4 ; otherwise the longest wins +comparei_l2: + mov al, [esi] + mov ah, [edi] + to_lower al + to_lower ah + cmp ah, al + jnz comparei_l4 ; chars not same + inc edi + inc esi + loop comparei_l2 + cmp edx, ebx ; all chars same + jnz comparei_l4 ; strings not same size +comparei_l3: + xor ebx, ebx ; same + jmp comparei_l7 +comparei_l4: + ja comparei_l6 +comparei_l5: + mov ebx, -1 + jmp comparei_l7 +comparei_l6: + mov ebx, 1 +comparei_l7: + ret + defword_end + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; dictionary searching words +;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + defword "find", 0, WORD_FIND, WORD_CALL_COMMA + call WORD_DUP + call WORD_COUNT + call WORD_FIND_DICT + test ebx, ebx + if nz + mov dl, [ebx + H_NSIZE] + call WORD_TCFA + LOADTOS 1 + and edx, F_IMMED + if z + neg ebx + endif + call WORD_ROT + call WORD_DROP + endif + ret + defword_end + + defword "(find)", 0, WORD_FIND_DICT, WORD_CALL_COMMA + mov ecx, ebx ; ecx = length + POPDSP edi ; edi = address + PUSHRSP ecx + mov esi, edi + call strhashi + and ebx, NUM_HASH_CHAINS-1 + mov esi, hash_buckets + mov edx, [esi + (ebx * 4)] + POPRSP ecx ; edx can now scan back through this hash chain +findd_l1: + test edx, edx ; NULL pointer? (end of the linked list) + je findd_l4 + xor eax, eax + mov al, [edx + H_NSIZE] ; al = flags+length field + and al, (F_HIDDEN|F_LENMASK) ; al = name length + cmp al, cl ; Length is the same? + jne findd_l2 + PUSHRSP ecx ; Save the length + PUSHRSP edi ; Save the address (repe cmpsb will move this pointer) + lea esi, [edx + H_NAME] ; Dictionary string we are checking against. + call strcmpi + POPRSP edi + POPRSP ecx + jne findd_l2 ; Not the same. + mov ebx, edx + ret +findd_l2: + mov edx, [edx + H_HLINK] ; Move back through the link field to the previous word + jmp findd_l1 ; .. and loop. +findd_l4: + xor ebx, ebx ; Return zero to indicate not found. + ret + defword_end + + defword ">cfa", 0, WORD_TCFA, WORD_CALL_COMMA + add ebx, H_NSIZE + mov al, [ebx] ; Load flags+len into al. + inc ebx ; skip flags+len byte. + and eax, F_LENMASK ; Just the length, not the flags. + add ebx, eax ; skip the name + add ebx, XT_SIZE ; skip to the xt + ret + defword_end + + defword "(bucket)", 0, WORD_BUCKET, WORD_CALL_COMMA + mov ecx, ebx ; ecx = length + POPDSP ebx ; ebx = address of name + PUSHRSP esi + mov esi, ebx + call strhashi + and ebx, NUM_HASH_CHAINS-1 + mov esi, hash_buckets + lea ebx, [esi + (ebx * 4)] + POPRSP esi + ret + defword_end + + defword "unused", 0, WORD_UNUSED, WORD_CALL_COMMA + LOADTOS forth_end + LOADTOS [var_WORD_DP] + call WORD_SUB + ret + defword_end + +;;;;;;;;;;;;;;;;;;;;;;;;;;; +; dictionary building words +;;;;;;;;;;;;;;;;;;;;;;;;;;; + + defword "align", 0, WORD_ALIGNDP, WORD_CALL_COMMA + mov eax, [var_WORD_DP] + ALIGNREG eax + mov [var_WORD_DP], eax + ret + defword_end + + defword "header,", 0, WORD_HEADER_COMMA, WORD_CALL_COMMA + mov ecx, ebx ; ecx = length + POPDSP ebx ; ebx = address of name + call WORD_ALIGNDP ; align header + mov edi, [var_WORD_DP] ; edi is the address of the header + mov eax, [var_WORD_LATEST] ; Get link pointer + mov [edi + H_LLINK], eax ; and store it in the header. + mov [var_WORD_LATEST], edi + PUSHRSP ebx ; hash chain + PUSHRSP ecx + mov esi, ebx + call strhashi + and ebx, NUM_HASH_CHAINS-1 + mov esi, hash_buckets + mov eax, [esi + (ebx * 4)] + mov [esi + (ebx * 4)], edi + mov [edi + H_HLINK], eax ; and store it in the header. + POPRSP ecx + POPRSP esi + mov [edi + H_NSIZE], cl ; Store the length/flags byte. + add edi, H_NAME + call strcpyi + mov ecx, XT_SIZE + xor eax, eax + rep stosb ; clear the gap till the xt + mov [var_WORD_DP], edi + mov long [edi + XT_COMPILE], WORD_CALL_COMMA ;compile action + POPDSP ebx + ret + defword_end + + defword "lit,", 0, WORD_LIT_COMMA, WORD_CALL_COMMA + mov esi, litc_l1 + mov edi, [var_WORD_DP] + mov ecx, litc_l2 - litc_l1 - 4 + rep movsb + mov [var_WORD_DP], edi + ret + defword_end +litc_l1: + LOADTOS 0xBAADF00D +litc_l2: + + defword "slits", 0, WORD_SLITS, WORD_CALL_COMMA + PUSHDSP ebx + POPRSP esi + xor eax, eax + lodsb ; get the length of the string + PUSHDSP esi ; push the address of the start of the string + mov ebx, eax ; push length on the stack + add esi, eax ; skip past the string + jmp esi + defword_end + + defword "clits", 0, WORD_CLITS, WORD_CALL_COMMA + FROMRSP + xor eax, eax + mov al, [ebx] + lea eax, [ebx + eax + 1] + jmp eax + defword_end + + defword ",", 0, WORD_COMMA, WORD_CALL_COMMA + mov edi, [var_WORD_DP] ; DP + mov eax, ebx + stosd ; Store it. + mov [var_WORD_DP], edi ; Update DP (incremented) + POPDSP ebx + ret + defword_end + + defword "c,", 0, WORD_CHAR_COMMA, WORD_CALL_COMMA + mov eax, ebx + mov edi, [var_WORD_DP] ; DP + stosb ; Store it. + mov [var_WORD_DP], edi ; Update DP (incremented) + POPDSP ebx + ret + defword_end + + defword ":", 0, WORD_COLON, WORD_CALL_COMMA + call WORD_PARSENAME + call WORD_HEADER_COMMA ; Create the dictionary entry / header + mov eax, [var_WORD_DP] + mov [eax + XT_BODY], eax + call WORD_LATEST + call WORD_FETCH + call WORD_HIDDEN ; Make the word hidden + call WORD_RBRAC ; Go into compile mode. + ret + defword_end + + defword "create", 0, WORD_CREATE, WORD_CALL_COMMA + call WORD_PARSENAME + call WORD_HEADER_COMMA + mov esi, create_l1 + mov edi, [var_WORD_DP] + PUSHRSP edi + mov ecx, create_l4 - create_l1 + rep movsb + mov [var_WORD_DP], edi + mov edx, edi + call WORD_ALIGNDP + POPRSP eax + mov edi, [var_WORD_DP] + sub edx, eax + mov [eax + create_l2 - create_l1 - 4], edi + mov [eax + XT_BODY], edi + mov [eax + XT_LENGTH], edx + ret + defword_end +create_l1: + LOADTOS 0xBAADF00D +create_l2: + call strict near create_l3 +create_l3: + ret +create_l4: + + defword "dodoes", 0, WORD_DODOES, WORD_CALL_COMMA + call WORD_LATEST + call WORD_FETCH + call WORD_TCFA + add ebx, create_l3 - create_l1 - 4 + POPDSP eax + sub eax, ebx + sub eax, 4 + mov [ebx], eax + POPDSP ebx + ret + defword_end + + defword "does>", F_IMMED, WORD_DOES, WORD_CALL_COMMA + call WORD_LIT_COMMA + LOADTOS [var_WORD_DP] + add ebx, 10 + call WORD_COMMA + LOADTOS WORD_DODOES + call WORD_COMPILE_COMMA + LOADTOS 0 + mov bl, [does_l1] + call WORD_CHAR_COMMA +does_l1: + ret + defword_end + + defword "postpone", F_IMMED, WORD_POSTPONE, WORD_CALL_COMMA + call WORD_PARSENAME + call WORD_FIND_DICT + mov dl, [ebx + H_NSIZE] + call WORD_TCFA + and edx, F_IMMED + if z + call WORD_LIT_COMMA + call WORD_COMMA + LOADTOS WORD_COMPILE_COMMA + endif + jmp WORD_COMPILE_COMMA + ret + defword_end + + defword "call,", 0, WORD_CALL_COMMA, WORD_CALL_COMMA + mov edi, [var_WORD_DP] + mov [lastcall], edi ; record last location of last call + mov esi, i_call + movsb + mov eax, ebx + sub eax, 4 + sub eax, edi + stosd + mov [var_WORD_DP], edi + POPDSP ebx + ret + defword_end + + defword "inline,", 0, WORD_INLINE_COMMA, WORD_CALL_COMMA + mov ecx, [ebx + XT_LENGTH] + dec ecx ; actual code length minus ret + mov esi, ebx + mov edi, [var_WORD_DP] + rep movsb ; inline copy the code + mov [var_WORD_DP], edi ; update DP + POPDSP ebx + ret + defword_end + + defword "compile,", 0, WORD_COMPILE_COMMA, WORD_INLINE_COMMA + call [ebx + XT_COMPILE] + ret + defword_end + + defword ";", F_IMMED, WORD_SEMICOLON, WORD_CALL_COMMA + LOADTOS WORD_EXIT +i_call: + call strict near WORD_COMPILE_COMMA + call WORD_LATEST + call WORD_FETCH + call WORD_HIDDEN ; toggle hidden flag -- unhide the word (see below for definition). + call WORD_LBRAC ; go back to IMMEDIATE mode. + mov edx, ebx + mov ebx, [var_WORD_LATEST] + call WORD_TCFA + mov ecx, [var_WORD_DP] + sub ecx, ebx + mov [ebx + XT_LENGTH], ecx ; set code size of word + mov ebx, edx + ret + defword_end + + defword "immediate", 0, WORD_IMMEDIATE, WORD_CALL_COMMA + mov edi, [var_WORD_LATEST] ; LATEST word. + add edi, H_NSIZE ; Point to name/flags byte. + xor byte [edi], F_IMMED ; Toggle the IMMED bit. + ret + defword_end + + defword "hidden", 0, WORD_HIDDEN, WORD_CALL_COMMA + add ebx, H_NSIZE ; Point to name/flags byte. + xor byte [ebx], F_HIDDEN ; Toggle the HIDDEN bit. + POPDSP ebx + ret + defword_end + + defword "[", F_IMMED, WORD_LBRAC, WORD_CALL_COMMA + mov long [var_WORD_STATE], 0 ; Set STATE to 0. + ret + defword_end + + defword "]", 0, WORD_RBRAC, WORD_CALL_COMMA + mov long [var_WORD_STATE], 1 ; Set STATE to 1. + ret + defword_end + +;;;;;;;;;;;;;;;;;;;;; +; source buffer words +;;;;;;;;;;;;;;;;;;;;; + + defword "source", 0, WORD_SOURCE, WORD_CALL_COMMA + call WORD_INHASH + call WORD_FETCH2 + ret + defword_end + + defword "refill", 0, WORD_REFILL, WORD_CALL_COMMA + LOADTOS tib_buffer + call WORD_LINESIZE ; ( tib len ) + call WORD_OVER + call WORD_SWAP ; ( tib tib len ) + call WORD_ACCEPT ; read line into TIB + call WORD_DUP2 + call WORD_TABSTOSPACES + call WORD_INHASH + call WORD_STORE2 ; set as current WORD_SOURCE + LOADTOS 0 + call WORD_TOIN + call WORD_STORE ; set to start of buffer + LOADTOS -1 + ret + defword_end + + defword "isspace?", 0, WORD_ISSPACE, WORD_CALL_COMMA + LOADTOS ' ' + call WORD_ULTEQ + ret + defword_end + + defword "isnotspace?", 0, WORD_ISNOTSPACE, WORD_CALL_COMMA + call WORD_ISSPACE + call WORD_ZEQ + ret + defword_end + + defword "xt-skip", 0, WORD_XTSKIP, WORD_CALL_COMMA + TORSP +xtskip_l1: + test ebx, ebx + jz xtskip_l3 + call WORD_OVER + call WORD_FETCHBYTE + FETCHRSP + call WORD_EXECUTE + test ebx, ebx + jz xtskip_l2 + mov ebx, 1 + call WORD_SSTRING + jmp xtskip_l1 +xtskip_l2: + call WORD_DROP +xtskip_l3: + ADDRSP 4 + ret + defword_end + +;;;;;;;;;;;;;;;;;;;;;; +; input parseing words +;;;;;;;;;;;;;;;;;;;;;; + + defword "parse-name", 0, WORD_PARSENAME, WORD_CALL_COMMA + call WORD_SOURCE + call WORD_TOIN + call WORD_FETCH + call WORD_SSTRING + LOADTOS WORD_ISSPACE + call WORD_XTSKIP + call WORD_OVER + TORSP + LOADTOS WORD_ISNOTSPACE + call WORD_XTSKIP + call WORD_DUP2 + LOADTOS 1 + call WORD_MIN + call WORD_ADD + call WORD_SOURCE + call WORD_DROP + call WORD_SUB + call WORD_TOIN + call WORD_STORE + call WORD_DROP + FROMRSP + call WORD_TUCK + call WORD_SUB +; code to print out "P CR" +;LOADTOS 80 +;call WORD_EMIT +;LOADTOS 32 +;call WORD_EMIT +;call WORD_DUP2 +;call WORD_TYPE +;LOADTOS 10 +;call WORD_EMIT + ret + defword_end + + defword "word-name", 0, WORD_WORDNAME, WORD_CALL_COMMA + call WORD_PARSENAME ; ( start len ) + LOADTOS word_buf ; ( string size buf ) + call WORD_DUP2 ; ( string size buf size buf ) + call WORD_STOREBYTE ; ( string size buf ) + call WORD_INCR ; ( string size buf+1 ) + call WORD_SWAP ; ( string buf+1 size ) + call WORD_CMOVE + LOADTOS word_buf ; ( cstring ) +; debug code to print out "N CR" +;LOADTOS 78 +;call WORD_EMIT +;LOADTOS 32 +;call WORD_EMIT +;call WORD_DUP2 +;call WORD_TYPE +;LOADTOS 10 +;call WORD_EMIT + ret + defword_end + + defword "interp-name", 0, WORD_INTERPNAME, WORD_CALL_COMMA + call WORD_PARSENAME ; ( start len ) + LOADTOS intep_name_buf ; ( string size buf ) + call WORD_DUP2 ; ( string size buf size buf ) + call WORD_STOREBYTE ; ( string size buf ) + call WORD_INCR ; ( string size buf+1 ) + call WORD_SWAP ; ( string buf+1 size ) + call WORD_CMOVE + LOADTOS intep_name_buf ;( cstring ) + ret + defword_end + + defword "interpret", 0, WORD_INTERPRET, WORD_CALL_COMMA + loopstart + call WORD_INTERPNAME + mov al, [ebx] + test al, al + breakif z + ; debug code to print out "I CR" + ;LOADTOS 73 + ;call WORD_EMIT + ;LOADTOS 32 + ;call WORD_EMIT + ;call WORD_DUP + ;call WORD_COUNT + ;call WORD_TYPE + ;LOADTOS 10 + ;call WORD_EMIT + call WORD_INTERP + loopend + call WORD_DROP + ret + defword_end + + defword "interp", 0, WORD_INTERP, WORD_CALL_COMMA + call WORD_FIND ; ( cstring 0 | xt 1 | xt | -1 ) + mov eax, ebx + POPDSP ebx + test eax, eax + jz tryasnumber + jle nonimediate +executeword: + mov eax, ebx + POPDSP ebx + jmp eax +nonimediate: + mov eax, [var_WORD_STATE] + test eax, eax ; are we in imedeate mode ? + jz executeword + jmp WORD_COMPILE_COMMA ; compile xt +tryasnumber: + call WORD_COUNT ; ( adr len ) + LOADTOS 0 + LOADTOS 0 + call WORD_SWAP2 ; ( 0d addr len ) + call WORD_TOSNUMBER ; ( d addr len ) + test ebx, ebx + jnz parseproblem + call WORD_DROP2 + call WORD_DROP ; ( num ) + mov eax, [var_WORD_STATE] + test eax, eax + if nz + call WORD_LIT_COMMA ; compile LIT + call WORD_COMMA ; compile value + endif + ret +parseproblem: + LOADTOS errmsg + LOADTOS errmsgend - errmsg + LOADTOS 2 + call WORD_TYPE_FD + LOADTOS errmsgnl + LOADTOS 1 + LOADTOS 2 + call WORD_TYPE_FD + LOADTOS tib_buffer + LOADTOS [var_WORD_TOIN] + LOADTOS 2 + call WORD_TYPE_FD + LOADTOS errmsgnl + LOADTOS 1 + LOADTOS 2 + call WORD_TYPE_FD + call WORD_DROP2 + call WORD_DROP2 + ret + defword_end + + defword ">number", 0, WORD_TONUMBER, WORD_CALL_COMMA + call WORD_OVER + call WORD_ADD + call WORD_SWAP ; ( ud end cur ) +tonumber_l1: + PICKDSP eax, 0 + cmp ebx, eax + jz near tonumber_l4 + call WORD_DUP + call WORD_FETCHBYTE ; ( ud end cur char ) + to_lower ebx + sub ebx, byte '0' + jb tonumber_l3 ; < '0'? + cmp ebx, byte 10 + jb tonumber_l2 ; <= '9' ? + sub ebx, byte 'a' - '0' + jb tonumber_l3 ; < 'a' ? + add ebx, byte 10 +tonumber_l2: + cmp ebx, [var_WORD_BASE] + jge tonumber_l3 ; >= WORD_BASE ? + TORSP + call WORD_SWAP2 ; ( end cur ud ) + LOADTOS [var_WORD_BASE] + call WORD_DMULSTAR + FROMRSP + call WORD_MPLUS ; ( end cur ud' ) + call WORD_SWAP2 + call WORD_INCR ; ( ud' end cur' ) + jmp tonumber_l1 +tonumber_l3: + call WORD_DROP +tonumber_l4: + call WORD_SWAP + call WORD_OVER + call WORD_SUB ; ( ud' c-addr u2 ) + ret + defword_end + + defword ">snumber", 0, WORD_TOSNUMBER, WORD_CALL_COMMA + test ebx, ebx + if nz + PICKDSP eax, 0 + mov cl, [eax] + cmp cl, '-' + jnz WORD_TONUMBER ; not '-' + inc eax + PUTDSP eax, 0 + dec ebx + call WORD_TONUMBER + call WORD_SWAP2 + call WORD_DNEGATE + call WORD_SWAP2 + endif + ret + defword_end + +;;;;;;;;;;; +; tick word +;;;;;;;;;;; + + defword "ticks", 0, WORD_TICKS, WORD_CALL_COMMA + sub ebp, byte 8 + rdtsc + mov [byte ebp -4], ebx + mov [ebp], eax + mov ebx, edx + ret + defword_end + +;;;;;;;;;;; +; test word +;;;;;;;;;;; + + defword "test", 0, WORD_TEST, WORD_CALL_COMMA + ret + defword_end + +;;;;;;;;;;;;;;;;; +; read/write data +;;;;;;;;;;;;;;;;; + + align 4 +syscallret: + ; return address saved by syscall + dd 0 +lastcall: + ; last call layed down by compiler + dd 0 + +tib_buffer: + ; keyboard input buffer + times MAX_LINE_SIZE db 0 +word_buf: + ; static buffer where WORD returns. Subsequent calls + ; overwrite this buffer. + times MAX_LINE_SIZE db 0 +intep_name_buf: + ; static buffer where INTERPNAME returns. Subsequent calls + ; overwrite this buffer. + times MAX_LINE_SIZE db 0 +emit_scratch: + ; scratch used by EMIT + db 0 +errmsg: + db "PARSE ERROR:" +errmsgend: +errmsgnl: + db 10 +bootfile: + db "forth.f" + db 0 + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; dictionary hash table (64) +;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + align 4 +hash_buckets: + dd 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + dd 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + dd 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + dd 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; addresses of all built in dictionary words. +; this ends up as part of the user space after booting ! +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + align 4 +dictionary_start: + dd dic_WORD_ABS + dd dic_WORD_ACCEPT + dd dic_WORD_ADD + dd dic_WORD_ADDBYTE + dd dic_WORD_ADDSTORE + dd dic_WORD_ALIGNDP + dd dic_WORD_AND + dd dic_WORD_BASE + dd dic_WORD_BLANK + dd dic_WORD_BLK + dd dic_WORD_BRANCH + dd dic_WORD_BUCKET + dd dic_WORD_CALL_COMMA + dd dic_WORD_CHARBUF + dd dic_WORD_CHAR_COMMA + dd dic_WORD_CLITS + dd dic_WORD_CMOVE + dd dic_WORD_CMOVEB + dd dic_WORD_COLON + dd dic_WORD_COMMA + dd dic_WORD_COMPARE + dd dic_WORD_COMPAREI + dd dic_WORD_COMPILE_COMMA + dd dic_WORD_COUNT + dd dic_WORD_CREATE + dd dic_WORD_D2SLASH + dd dic_WORD_D2STAR + dd dic_WORD_DABS + dd dic_WORD_DECR + dd dic_WORD_DECR2 + dd dic_WORD_DECR4 + dd dic_WORD_DEQ + dd dic_WORD_DIV + dd dic_WORD_DIVMOD + dd dic_WORD_DLT + dd dic_WORD_DMAX + dd dic_WORD_DMIN + dd dic_WORD_DMINUS + dd dic_WORD_DMULSTAR + dd dic_WORD_DNEGATE + dd dic_WORD_DNEQ + dd dic_WORD_DODOES + dd dic_WORD_DOES + dd dic_WORD_DP + dd dic_WORD_DPLUS + dd dic_WORD_DROP + dd dic_WORD_DROP2 + dd dic_WORD_DSPFETCH + dd dic_WORD_DSPSTORE + dd dic_WORD_DTOS + dd dic_WORD_DULT + dd dic_WORD_DUP + dd dic_WORD_DUP2 + dd dic_WORD_DZEQ + dd dic_WORD_DZLT + dd dic_WORD_DZNEQ + dd dic_WORD_EMIT + dd dic_WORD_EQ + dd dic_WORD_ERASE + dd dic_WORD_EXECUTE + dd dic_WORD_EXIT + dd dic_WORD_FETCH + dd dic_WORD_FETCH2 + dd dic_WORD_FETCHBYTE + dd dic_WORD_FETCHSHORT + dd dic_WORD_FILL + dd dic_WORD_FIND + dd dic_WORD_FIND_DICT + dd dic_WORD_FMDIVMOD + dd dic_WORD_FROMR + dd dic_WORD_FROMR2 + dd dic_WORD_GT + dd dic_WORD_GTEQ + dd dic_WORD_HEADER_COMMA + dd dic_WORD_HIDDEN + dd dic_WORD_IMMEDIATE + dd dic_WORD_INCR + dd dic_WORD_INCR2 + dd dic_WORD_INCR4 + dd dic_WORD_INHASH + dd dic_WORD_INLINE_COMMA + dd dic_WORD_INTERP + dd dic_WORD_INTERPNAME + dd dic_WORD_INTERPRET + dd dic_WORD_INVERT + dd dic_WORD_ISNOTSPACE + dd dic_WORD_ISSPACE + dd dic_WORD_KEY + dd dic_WORD_LATEST + dd dic_WORD_LBRAC + dd dic_WORD_LINESIZE + dd dic_WORD_LIT_COMMA + dd dic_WORD_LSHIFT + dd dic_WORD_LSYSCALL + dd dic_WORD_LT + dd dic_WORD_LTEQ + dd dic_WORD_MAX + dd dic_WORD_MIN + dd dic_WORD_MMINUS + dd dic_WORD_MOD + dd dic_WORD_MOVE + dd dic_WORD_MPLUS + dd dic_WORD_MSLASH + dd dic_WORD_MULDIV + dd dic_WORD_MULL + dd dic_WORD_MULSTAR + dd dic_WORD_NE + dd dic_WORD_NEGATE + dd dic_WORD_NFROMR + dd dic_WORD_NIP + dd dic_WORD_NIP2 + dd dic_WORD_NQDUP + dd dic_WORD_NROT + dd dic_WORD_NTOR + dd dic_WORD_OR + dd dic_WORD_OVER + dd dic_WORD_OVER2 + dd dic_WORD_O_APPEND + dd dic_WORD_O_CREAT + dd dic_WORD_O_EXCL + dd dic_WORD_O_NONBLOCK + dd dic_WORD_O_RDONLY + dd dic_WORD_O_RDWR + dd dic_WORD_O_TRUNC + dd dic_WORD_O_WRONLY + dd dic_WORD_PARSENAME + dd dic_WORD_PICK + dd dic_WORD_POSTPONE + dd dic_WORD_QDUP + dd dic_WORD_RBRAC + dd dic_WORD_RDROP + dd dic_WORD_RDROP2 + dd dic_WORD_READCHAR + dd dic_WORD_READLINE + dd dic_WORD_REFILL + dd dic_WORD_RFETCH + dd dic_WORD_RFETCH2 + dd dic_WORD_ROT + dd dic_WORD_ROT2 + dd dic_WORD_RSHIFT + dd dic_WORD_RSPFETCH + dd dic_WORD_RSPSTORE + dd dic_WORD_RSTORE + dd dic_WORD_RZ + dd dic_WORD_SEMICOLON + dd dic_WORD_SLITS + dd dic_WORD_SMDIVREM + dd dic_WORD_SOURCE + dd dic_WORD_SOURCEFD + dd dic_WORD_SSTRING + dd dic_WORD_STARSMOD + dd dic_WORD_STATE + dd dic_WORD_STOD + dd dic_WORD_STORE + dd dic_WORD_STORE2 + dd dic_WORD_STOREBYTE + dd dic_WORD_STORESHORT + dd dic_WORD_SUB + dd dic_WORD_SUBSTORE + dd dic_WORD_SWAP + dd dic_WORD_SWAP2 + dd dic_WORD_SYSCALL + dd dic_WORD_SYS_CLOSE + dd dic_WORD_SYS_EXIT + dd dic_WORD_SYS_FSTAT + dd dic_WORD_SYS_FSYNC + dd dic_WORD_SYS_FTRUNCATE + dd dic_WORD_SYS_LSEEK + dd dic_WORD_SYS_OPEN + dd dic_WORD_SYS_READ + dd dic_WORD_SYS_RENAME + dd dic_WORD_SYS_STAT + dd dic_WORD_SYS_UNLINK + dd dic_WORD_SYS_WRITE + dd dic_WORD_SZ + dd dic_WORD_TABSTOSPACES + dd dic_WORD_TCFA + dd dic_WORD_TICKS + dd dic_WORD_TOIN + dd dic_WORD_TONUMBER + dd dic_WORD_TOR + dd dic_WORD_TOR2 + dd dic_WORD_TOSNUMBER + dd dic_WORD_TRAILING + dd dic_WORD_TUCK + dd dic_WORD_TUCK2 + dd dic_WORD_TWODIV + dd dic_WORD_TWOMUL + dd dic_WORD_TYPE + dd dic_WORD_TYPE_FD + dd dic_WORD_UDIVMOD + dd dic_WORD_UGT + dd dic_WORD_UGTEQ + dd dic_WORD_ULT + dd dic_WORD_ULTEQ + dd dic_WORD_UMDIVMOD + dd dic_WORD_UMULSTAR + dd dic_WORD_UNUSED + dd dic_WORD_VERSION + dd dic_WORD_WORDBUF + dd dic_WORD_WORDNAME + dd dic_WORD_XOR + dd dic_WORD_XTSKIP + dd dic_WORD_ZBRANCH + dd dic_WORD_ZEQ + dd dic_WORD_ZGT + dd dic_WORD_ZGTEQ + dd dic_WORD_ZLT + dd dic_WORD_ZLTEQ + dd dic_WORD_ZNE + dd dic_WORD__F_HIDDEN + dd dic_WORD__F_IMMED + dd dic_WORD__F_LENMASK + dd dic_WORD__H_NAME + dd dic_WORD__H_NSIZE + dd dic_WORD__XT_BODY + dd dic_WORD__XT_COMPILE + dd dic_WORD__XT_LENGTH + dd dic_WORD__XT_SIZE + dd dic_WORD_TEST +dictionary_end: + +;;;;;;;;;;;;;;;;;;;;;;;;;; +; room for user dictionary +;;;;;;;;;;;;;;;;;;;;;;;;;; + + times USER_DEFS_SIZE db 0 +forth_end: diff --git a/samples/BitBake/gstreamer-libav.bb b/samples/BitBake/gstreamer-libav.bb new file mode 100644 index 00000000..803bcf2f --- /dev/null +++ b/samples/BitBake/gstreamer-libav.bb @@ -0,0 +1,25 @@ +include gstreamer1.0-libav.inc + +LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ + file://COPYING.LIB;md5=6762ed442b3822387a51c92d928ead0d \ + file://ext/libav/gstav.h;beginline=1;endline=18;md5=a752c35267d8276fd9ca3db6994fca9c \ + file://gst-libs/ext/libav/LICENSE;md5=23a54f59b82572c203a559346e89ed57 \ + file://gst-libs/ext/libav/COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ + file://gst-libs/ext/libav/COPYING.GPLv3;md5=d32239bcb673463ab874e80d47fae504 \ + file://gst-libs/ext/libav/COPYING.LGPLv2.1;md5=bd7a443320af8c812e4c18d1b79df004 \ + file://gst-libs/ext/libav/COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02" + +SRC_URI = " \ + http://gstreamer.freedesktop.org/src/gst-libav/gst-libav-${PV}.tar.xz \ + file://0001-Disable-yasm-for-libav-when-disable-yasm.patch \ + " +SRC_URI[md5sum] = "86540dee14d31daf976eb2713f2294f3" +SRC_URI[sha256sum] = "585eb7971006100ad771a852e07bd2f3e23bcc6eb0b1253a40b5a0e40e4e7418" + +LIBAV_EXTRA_CONFIGURE_COMMON_ARG = "--target-os=linux \ + --cc='${CC}' --as='${CC}' --ld='${CC}' --nm='${NM}' --ar='${AR}' \ + --ranlib='${RANLIB}' \ + ${GSTREAMER_1_0_DEBUG}" + +S = "${WORKDIR}/gst-libav-${PV}" + diff --git a/samples/BitBake/qtbase-native.bb b/samples/BitBake/qtbase-native.bb new file mode 100644 index 00000000..5d24f48a --- /dev/null +++ b/samples/BitBake/qtbase-native.bb @@ -0,0 +1,13 @@ +require qt5-git.inc +require ${PN}.inc + +do_install_append() { + # for modules which are still using syncqt and call qtPrepareTool(QMAKE_SYNCQT, syncqt) + # e.g. qt3d, qtwayland + ln -sf syncqt.pl ${D}${OE_QMAKE_PATH_QT_BINS}/syncqt +} + +QT_MODULE_BRANCH = "release" +# v5.2.1 + 168 commits +SRCREV = "08cbbde61778276ccdda73d89fd64d02c623779f" + diff --git a/samples/Brainfuck/factor.b b/samples/Brainfuck/factor.b new file mode 100644 index 00000000..43f06ba2 --- /dev/null +++ b/samples/Brainfuck/factor.b @@ -0,0 +1,195 @@ +* factor an arbitrarily large positive integer +* +* Copyright (C) 1999 by Brian Raiter +* under the GNU General Public License + +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>- + +* +* read in the number +* + +<<<<<<<<<+ +[-[>>>>>>>>>>][-]<<<<<<<<<<[[->>>>>>>>>>+<<<<<<<<<<]<<<<<<<<<<] + >>>>>>>>>>,----------] +>>>>>>>>>>[------------------------------------->>>>>>>>>->] +<[+>[>>>>>>>>>+>]<-<<<<<<<<<<]- + +* +* display the number and initialize the loop variable to two +* + +[>++++++++++++++++++++++++++++++++++++++++++++++++. + ------------------------------------------------<<<<<<<<<<<] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++. +--------------------------.[-] +>>>>>>>>>>>>++<<<<+ + +* +* the main loop +* + +[ [-]>> + + * + * make copies of the number and the loop variable + * + + [>>>>[-]>[-]>[-]>[-] + >[-]>[-] + <<<<<<<[->>>+>+<<<<]>>>>>>>>] + <<<<<<<<<<[>>>>>>[-<<<<+>>>>]<<<<<<<<<<<<<<<<]>>>>>>>>>> + [>[->>>+>>+<<<<<]>>>>>>>>>] + <<<<<<<<<<[>>>>>>[-<<<<<+>>>>>]<<<<<<<<<<<<<<<<]>>>>>>>>>> + + * + * divide the number by the loop variable + * + + [>>>[-]>>>[-]>[-]>>>] initialize + <<<<<<<<<<[<<<<<<<<<<] + >>>>>>>>>[-]>>>>>>>+<<<<<<<<[+]+ + [ ->> double divisor until above dividend + [>>>>>>[->++<]>>>>]<<<<<<<<<< + [>>>>>>>>[-]>[-] + <<<<[->>>++<<<]<<<<<<<<<<<<<<<]>>>>>>>>>> + [>>>>>>>>[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+< + [->--------->>>>>>>>>+<<<<<<<<<<[->+<]]]]]]]]]]]>>] + <<<<<<<<<<[>>>>>>>>>[-<+<<<+>>>>]<<<<<<<<<<<<<<<<<<<]>>>>>>>>>> + [>>>>>>>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+> + [-<--------->>>>>>>>>>>+<<<<<<<<<<[-<+>]]]]]]]]]]]>>>] + <<<<<<<<<< + [>>>>[->>>+>>+<<<<<]<<<<<<<<<<<<<<] + >>>>>>>>>>[>>>>>>>[-<<<+>>>]>>>]<<<<<<<<<< + [>>>>>>>>[->-<]> + [<<<<<<<<<[<[-]>>>>>>>>>>[-<<<<<<<<<<+>>>>>>>>>>]<<<<<<<<<<<<<<<<<<<] + >>>>>>>>>>>>>>>>>>>] + <<<<<<<<<<<<<<<<<<<] + >>>>>>>>>[+[+[+[+[+[+[+[+[+[+[[-]<+>]]]]]]]]]]]< + ] + >>>>>>>> + [ subtract divisor from dividend + <<<<<< + [>>>>>>>>[-]>[-]<<<<<[->>>+>+<<<<]>>>>>>]<<<<<<<<<< + [>>>>>>>>[-<<<<+>>>>]<<<[->>>+>+<<<<]<<<<<<<<<<<<<<<]>>>>>>>>>> + [>>>>>>>>>[-<<<<+>>>>]>]<<<<<<<<<< + [>>>>>>>>[-<->]<<<<<<<<<<<<<<<<<<]>>>>>>>>>> + [>>>>>>>[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+< + [++++++++++[+>-<]>>>>>>>>>>-<<<<<<<<<<]]]]]]]]]]]>>>] + >>>>>>>+ + [ if difference is nonnegative then + [-]<<<<<<<<<<<<<<<<< replace dividend and increment quotient + [>>>>[-]>>>>[-<<<<+>>>>]<<[->>+<<]<<<<<<<<<<<<<<<<]>>>>>>>>>> + [>>>>>>>>[->+<<<+>>]>>]<<<<<<<<<< + [>>>[->>>>>>+<<<<<<]<<<<<<<<<<<<<]>>>>>>>>>> + [>>>>>>>>>[-<<<<<<+>>>>>>[-<<<<<<+>>>>>> + [-<<<<<<+>>>>>>[-<<<<<<+>>>>>> + [-<<<<<<+>>>>>>[-<<<<<<+>>>>>> + [-<<<<<<+>>>>>>[-<<<<<<+>>>>>> + [-<<<<<<+>>>>>>[-<<<<<<--------->>>>>>>>>>>>>>>>+<<<<<<<<<< + [-<<<<<<+>>>>>>]]]]]]]]]]]>] + >>>>>>> + ] halve divisor and loop until zero + <<<<<<<<<<<<<<<<<[<<<<<<<<<<]>>>>>>>>>> + [>>>>>>>>[-]<<[->+<]<[->>>+<<<]>>>>>]<<<<<<<<<< + [+>>>>>>>[-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+> + [-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+> + [-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+> + [-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+> + [-<<<<<<<+>>>>>>>]]]]]]]]]<<<<<<< + [->>>>>>>+<<<<<<<]-<<<<<<<<<<] + >>>>>>> + [-<<<<<<<<<<<+>>>>>>>>>>>] + >>>[>>>>>>>[-<<<<<<<<<<<+++++>>>>>>>>>>>]>>>]<<<<<<<<<< + [+>>>>>>>>[-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>> + [-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>> + [-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>> + [-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>> + [-<<<<<<<<+>>>>>>>>]]]]]]]]]<<<<<<<< + [->>>>>>>>+<<<<<<<<]-<<<<<<<<<<] + >>>>>>>>[-<<<<<<<<<<<<<+>>>>>>>>>>>>>]>> + [>>>>>>>>[-<<<<<<<<<<<<<+++++>>>>>>>>>>>>>]>>]<<<<<<<<<< + [<<<<<<<<<<]>>>>>>>>>> + >>>>>> + ] + <<<<<< + + * + * make copies of the loop variable and the quotient + * + + [>>>[->>>>+>+<<<<<]>>>>>>>] + <<<<<<<<<< + [>>>>>>>[-<<<<+>>>>]<<<<<[->>>>>+>>+<<<<<<<]<<<<<<<<<<<<] + >>>>>>>>>>[>>>>>>>[-<<<<<+>>>>>]>>>]<<<<<<<<<< + + * + * break out of the loop if the quotient is larger than the loop variable + * + + [>>>>>>>>>[-<->]< + [<<<<<<<< + [<<[-]>>>>>>>>>>[-<<<<<<<<<<+>>>>>>>>>>]<<<<<<<<<<<<<<<<<<] + >>>>>>>>>>>>>>>>>>]<<<<<<<<<<<<<<<<<<] + >>>>>>>>[>-<[+[+[+[+[+[+[+[+[+[[-]>+<]]]]]]]]]]]>+ + + [ [-] + + * + * partially increment the loop variable + * + + <[-]+>>>>+>>>>>>>>[>>>>>>>>>>]<<<<<<<<<< + + * + * examine the remainder for nonzero digits + * + + [<<<<<<[<<<<[<<<<<<<<<<]>>>>+<<<<<<<<<<]<<<<] + >>>>>>>>>>>>>>>>>>>>[>>>>>>>>>>]<<<<<<<<<<[<<<<<<<<<<] + >>>>- + + [ [+] + + * + * decrement the loop variable and replace the number with the quotient + * + + >>>>>>>>-<<[>[-]>>[-<<+>>]>>>>>>>]<<<<<<<<<< + + * + * display the loop variable + * + + [+>>[>>>>>>>>+>>]<<-<<<<<<<<<<]- + [>>++++++++++++++++++++++++++++++++++++++++++++++++. + ------------------------------------------------<<<<<<<<<<<<] + ++++++++++++++++++++++++++++++++.[-]>>>> + + ] + + * + * normalize the loop variable + * + + >>>>>> + [>>[->>>>>+<<<<<[->>>>>+<<<<< + [->>>>>+<<<<<[->>>>>+<<<<< + [->>>>>+<<<<<[->>>>>+<<<<< + [->>>>>+<<<<<[->>>>>+<<<<< + [->>>>>+<<<<<[->>>>>--------->>>>>+<<<<<<<<<< + [->>>>>+<<<<<]]]]]]]]]]]>>>>>>>>] + <<<<<<<<<<[>>>>>>>[-<<<<<+>>>>>]<<<<<<<<<<<<<<<<<] + >>>>>>>>> + + ]< + +]>> + +* +* display the number and end +* + +[>>>>>>>>>>]<<<<<<<<<<[+>[>>>>>>>>>+>]<-<<<<<<<<<<]- +[>++++++++++++++++++++++++++++++++++++++++++++++++.<<<<<<<<<<<] +++++++++++. diff --git a/samples/Brainfuck/fib100.bf b/samples/Brainfuck/fib100.bf new file mode 100644 index 00000000..3359588a --- /dev/null +++ b/samples/Brainfuck/fib100.bf @@ -0,0 +1,13 @@ +# Calculate and output all fibonacci numbers under 100 + ++++++++++++ +>+>>>>++++++++++++++++++++++++++++++++++++++++++++ +>++++++++++++++++++++++++++++++++<<<<<<[>[>>>>>>+> ++<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[>++++++++++[- +<-[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<[>>>+<<< +-]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]] +>[<<+>>[-]]<<<<<<<]>>>>>[+++++++++++++++++++++++++ ++++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++ +++++++++++++++++++++++++++++++++++++++++++++.[-]<< +<<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<< +[-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-] \ No newline at end of file diff --git a/samples/Brainfuck/hello.bf b/samples/Brainfuck/hello.bf new file mode 100644 index 00000000..6a93a155 --- /dev/null +++ b/samples/Brainfuck/hello.bf @@ -0,0 +1,4 @@ +// More complex version of hello world + +>++++++++[<+++++++++>-]<.>>+>+>++>[-]+<[>[->+<<++++>]<<]>.+++++++..+++.> +>+++++++.<<<[[-]<[-]>]<+++++++++++++++.>>.+++.------.--------.>>+.>++++. \ No newline at end of file diff --git a/samples/Brainfuck/helloworld.bf b/samples/Brainfuck/helloworld.bf new file mode 100644 index 00000000..c7bde23a --- /dev/null +++ b/samples/Brainfuck/helloworld.bf @@ -0,0 +1,3 @@ +// Hello World + +++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++. \ No newline at end of file diff --git a/samples/Brainfuck/rot13.bf b/samples/Brainfuck/rot13.bf new file mode 100644 index 00000000..3b9d8e7f --- /dev/null +++ b/samples/Brainfuck/rot13.bf @@ -0,0 +1,30 @@ +# ROT13 cipher + +-,+[ Read first character and start outer character reading loop + -[ Skip forward if character is 0 + >>++++[>++++++++<-] Set up divisor (32) for division loop + (MEMORY LAYOUT: dividend copy remainder divisor quotient zero zero) + <+<-[ Set up dividend (x minus 1) and enter division loop + >+>+>-[>>>] Increase copy and remainder / reduce divisor / Normal case: skip forward + <[[>+<-]>>+>] Special case: move remainder back to divisor and increase quotient + <<<<<- Decrement dividend + ] End division loop + ]>>>[-]+ End skip loop; zero former divisor and reuse space for a flag + >--[-[<->+++[-]]]<[ Zero that flag unless quotient was 2 or 3; zero quotient; check flag + ++++++++++++<[ If flag then set up divisor (13) for second division loop + (MEMORY LAYOUT: zero copy dividend divisor remainder quotient zero zero) + >-[>+>>] Reduce divisor; Normal case: increase remainder + >[+[<+>-]>+>>] Special case: increase remainder / move it back to divisor / increase quotient + <<<<<- Decrease dividend + ] End division loop + >>[<+>-] Add remainder back to divisor to get a useful 13 + >[ Skip forward if quotient was 0 + -[ Decrement quotient and skip forward if quotient was 1 + -<<[-]>> Zero quotient and divisor if quotient was 2 + ]<<[<<->>-]>> Zero divisor and subtract 13 from copy if quotient was 1 + ]<<[<<+>>-] Zero divisor and add 13 to copy if quotient was 0 + ] End outer skip loop (jump to here if ((character minus 1)/32) was not 2 or 3) + <[-] Clear remainder from first division if second division was skipped + <.[-] Output ROT13ed character from copy and clear it + <-,+ Read next character +] End character reading loop \ No newline at end of file diff --git a/samples/C#/AssemblyInfo.cs b/samples/C#/AssemblyInfo.cs new file mode 100644 index 00000000..1ef68427 --- /dev/null +++ b/samples/C#/AssemblyInfo.cs @@ -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("")] diff --git a/samples/C#/BsonPropertyValue.cs b/samples/C#/BsonPropertyValue.cs new file mode 100644 index 00000000..94d27c88 --- /dev/null +++ b/samples/C#/BsonPropertyValue.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/samples/C#/MongoExpressionVisitor.cs b/samples/C#/MongoExpressionVisitor.cs new file mode 100644 index 00000000..b7a1effe --- /dev/null +++ b/samples/C#/MongoExpressionVisitor.cs @@ -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 VisitOrderBy(ReadOnlyCollection orderBys) + { + if (orderBys != null) + { + List 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 VisitFieldDeclarationList(ReadOnlyCollection fields) + { + if (fields == null) + return fields; + + List 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; + } + } +} \ No newline at end of file diff --git a/samples/C++/16F88.h b/samples/C++/16F88.h new file mode 100644 index 00000000..28f51ce4 --- /dev/null +++ b/samples/C++/16F88.h @@ -0,0 +1,86 @@ +/* + * This file is part of PIC + * Copyright © 2012 Rachel Mant (dx-mon@users.sourceforge.net) + * + * PIC is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIC 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +enum PIC16F88Instruction +{ + ADDWF, + ANDWF, + CLRF, + CLRW, + COMF, + DECF, + DECFSZ, + INCF, + INCFSZ, + IORWF, + MOVF, + MOVWF, + NOP, + RLF, + RRF, + SUBWF, + SWAPF, + XORWF, + BCF, + BSF, + BTFSC, + BTFSS, + ADDLW, + ANDLW, + CALL, + CLRWDT, + GOTO, + IORLW, + MOVLW, + RETFIE, + RETLW, + RETURN, + SLEEP, + SUBLW, + XORLW +}; + +class PIC16F88 +{ +public: + PIC16F88(ROM *ProgramMemory); + void Step(); + +private: + uint8_t q; + bool nextIsNop, trapped; + Memory *memory; + ROM *program; + Stack *CallStack; + Register *PC; + Register<> *WREG, *PCL, *STATUS, *PCLATCH; + PIC16F88Instruction inst; + uint16_t instrWord; + +private: + void DecodeInstruction(); + void ProcessInstruction(); + + uint8_t GetBank(); + uint8_t GetMemoryContents(uint8_t partialAddress); + void SetMemoryContents(uint8_t partialAddress, uint8_t newVal); + void CheckZero(uint8_t value); + void StoreValue(uint8_t value, bool updateZero); + uint8_t SetCarry(bool val); + uint16_t GetPCHFinalBits(); +}; diff --git a/samples/C++/Entity.h b/samples/C++/Entity.h new file mode 100644 index 00000000..619fc1d1 --- /dev/null +++ b/samples/C++/Entity.h @@ -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 `_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 \ No newline at end of file diff --git a/samples/C++/Memory16F88.h b/samples/C++/Memory16F88.h new file mode 100644 index 00000000..ced2ef13 --- /dev/null +++ b/samples/C++/Memory16F88.h @@ -0,0 +1,32 @@ +/* + * This file is part of PIC + * Copyright © 2012 Rachel Mant (dx-mon@users.sourceforge.net) + * + * PIC is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PIC 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#include "Memory.h" + +class Memory16F88 : public Memory +{ +private: + uint8_t memory[512]; + std::map memoryMap; + +public: + Memory16F88(); + uint8_t Dereference(uint8_t bank, uint8_t partialAddress); + uint8_t *Reference(uint8_t bank, uint8_t partialAddress); + uint8_t *operator [](uint32_t ref); +}; diff --git a/samples/C++/ThreadedQueue.h b/samples/C++/ThreadedQueue.h new file mode 100644 index 00000000..6b2fbaad --- /dev/null +++ b/samples/C++/ThreadedQueue.h @@ -0,0 +1,76 @@ +/* + * This file is part of IRCBot + * Copyright © 2014 Rachel Mant (dx-mon@users.sourceforge.net) + * + * IRCBot 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. + * + * IRCBot 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 . + */ + +#ifndef __THREADED_QUEUE_H__ +#define __THREADED_QUEUE_H__ + +#include +#include + +template +class ThreadedQueue : public std::queue +{ +private: + pthread_mutex_t queueMutex; + pthread_cond_t queueCond; + +public: + ThreadedQueue() + { + pthread_mutexattr_t mutexAttrs; + pthread_condattr_t condAttrs; + + pthread_mutexattr_init(&mutexAttrs); + pthread_mutexattr_settype(&mutexAttrs, PTHREAD_MUTEX_ERRORCHECK); + pthread_mutex_init(&queueMutex, &mutexAttrs); + pthread_mutexattr_destroy(&mutexAttrs); + + pthread_condattr_init(&condAttrs); + pthread_condattr_setpshared(&condAttrs, PTHREAD_PROCESS_PRIVATE); + pthread_cond_init(&queueCond, &condAttrs); + pthread_condattr_destroy(&condAttrs); + } + + ~ThreadedQueue() + { + pthread_cond_destroy(&queueCond); + pthread_mutex_destroy(&queueMutex); + } + + void waitItems() + { + pthread_mutex_lock(&queueMutex); + pthread_cond_wait(&queueCond, &queueMutex); + pthread_mutex_unlock(&queueMutex); + } + + void signalItems() + { + pthread_mutex_lock(&queueMutex); + pthread_cond_broadcast(&queueCond); + pthread_mutex_unlock(&queueMutex); + } + + void push(T item) + { + std::queue::push(item); + signalItems(); + } +}; + +#endif /*__THREADED_QUEUE_H__*/ diff --git a/samples/C++/bar.hh b/samples/C++/bar.hh new file mode 100644 index 00000000..a87343c2 --- /dev/null +++ b/samples/C++/bar.hh @@ -0,0 +1,10 @@ +class Bar +{ + protected: + + char *name; + + public: + + void hello(); +} diff --git a/samples/C++/qsciprinter.cp b/samples/C++/qsciprinter.cp new file mode 100644 index 00000000..f30d6454 --- /dev/null +++ b/samples/C++/qsciprinter.cp @@ -0,0 +1,116 @@ +// This module defines interface to the QsciPrinter class. +// +// Copyright (c) 2011 Riverbank Computing Limited +// +// This file is part of QScintilla. +// +// This file may be used under the terms of the GNU General Public +// License versions 2.0 or 3.0 as published by the Free Software +// Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3 +// included in the packaging of this file. Alternatively you may (at +// your option) use any later version of the GNU General Public +// License if such license has been publicly approved by Riverbank +// Computing Limited (or its successors, if any) and the KDE Free Qt +// Foundation. In addition, as a special exception, Riverbank gives you +// certain additional rights. These rights are described in the Riverbank +// GPL Exception version 1.1, which can be found in the file +// GPL_EXCEPTION.txt in this package. +// +// If you are unsure which license is appropriate for your use, please +// contact the sales department at sales@riverbankcomputing.com. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + +#ifndef QSCIPRINTER_H +#define QSCIPRINTER_H + +#ifdef __APPLE__ +extern "C++" { +#endif + +#include + +#include +#include + + +QT_BEGIN_NAMESPACE +class QRect; +class QPainter; +QT_END_NAMESPACE + +class QsciScintillaBase; + + +//! \brief The QsciPrinter class is a sub-class of the Qt QPrinter class that +//! is able to print the text of a Scintilla document. +//! +//! The class can be further sub-classed to alter to layout of the text, adding +//! headers and footers for example. +class QSCINTILLA_EXPORT QsciPrinter : public QPrinter +{ +public: + //! Constructs a printer paint device with mode \a mode. + QsciPrinter(PrinterMode mode = ScreenResolution); + + //! Destroys the QsciPrinter instance. + virtual ~QsciPrinter(); + + //! Format a page, by adding headers and footers for example, before the + //! document text is drawn on it. \a painter is the painter to be used to + //! add customised text and graphics. \a drawing is true if the page is + //! actually being drawn rather than being sized. \a painter drawing + //! methods must only be called when \a drawing is true. \a area is the + //! area of the page that will be used to draw the text. This should be + //! modified if it is necessary to reserve space for any customised text or + //! graphics. By default the area is relative to the printable area of the + //! page. Use QPrinter::setFullPage() because calling printRange() if you + //! want to try and print over the whole page. \a pagenr is the number of + //! the page. The first page is numbered 1. + virtual void formatPage(QPainter &painter, bool drawing, QRect &area, + int pagenr); + + //! Return the number of points to add to each font when printing. + //! + //! \sa setMagnification() + int magnification() const {return mag;} + + //! Sets the number of points to add to each font when printing to \a + //! magnification. + //! + //! \sa magnification() + virtual void setMagnification(int magnification); + + //! Print a range of lines from the Scintilla instance \a qsb. \a from is + //! the first line to print and a negative value signifies the first line + //! of text. \a to is the last line to print and a negative value + //! signifies the last line of text. true is returned if there was no + //! error. + virtual int printRange(QsciScintillaBase *qsb, int from = -1, int to = -1); + + //! Return the line wrap mode used when printing. The default is + //! QsciScintilla::WrapWord. + //! + //! \sa setWrapMode() + QsciScintilla::WrapMode wrapMode() const {return wrap;} + + //! Sets the line wrap mode used when printing to \a wmode. + //! + //! \sa wrapMode() + virtual void setWrapMode(QsciScintilla::WrapMode wmode); + +private: + int mag; + QsciScintilla::WrapMode wrap; + + QsciPrinter(const QsciPrinter &); + QsciPrinter &operator=(const QsciPrinter &); +}; + +#ifdef __APPLE__ +} +#endif + +#endif diff --git a/samples/C/2D.C b/samples/C/2D.C new file mode 100644 index 00000000..b3d45015 --- /dev/null +++ b/samples/C/2D.C @@ -0,0 +1,145 @@ +#include "2D.h" +#include + +void set_vgabasemem(void) +{ + ULONG vgabase; + SELECTOR tmp; + asm mov [tmp], ds + dpmi_get_sel_base(&vgabase, tmp); + vgabasemem = (char *)(-vgabase + 0xa0000); +} + +void drw_chdis(int mode) // change the display! +{ + regs.b.ah = 0x00; // seet theh display moode + regs.b.al = mode; // change it to the mode like innit + regs.h.flags = 0x72;// Set the dingoes kidneys out of FLAGS eh? + regs.h.ss = 0; // Like, totally set the stack segment + regs.h.sp = 0; // Set tha stack pointaaaaahhhhh!!! + dpmi_simulate_real_interrupt(0x10, ®s); +} + +void drw_pix(int x, int y, enum COLORS col) +{ + *VGAPIX(x, y) = col; +} + +void drw_line(int x0, int y0, int x1, int y1, enum COLORS col) +{ + // Going for the optimized version of bresenham's line algo. + int stp = (abs(y0 - y1) > abs(x0 - x1)); + int tmp, dx, dy, err, yi, i, j; // yi = y excrement + if (stp) { + // swappity swap + tmp = y0; + y0 = x0; + x0 = tmp; + + tmp = y1; + y1 = x1; + x1 = tmp; + } + // AAAAND NOW WE MUST DO ZEES AGAIN :( + // I'm sure there was a func somewhere that does this? :P + if (x0 > x1) { + tmp = x0; + x0 = x1; + x1 = tmp; + + tmp = y0; + y0 = y1; + y1 = tmp; + } + dx = (x1 - x0); + dy = (abs(y1 - y0)); + err = (dx / 2); + + if (y0 < y1) + yi = 1; + else + yi = -1; + j = y0; + for (i = x0; i < x1; i++) + { + if (stp) + *VGAPIX(j, i) = col; + else + *VGAPIX(i, j) = col; + + err -= dy; + if (err < 0) { + j += yi; + err += dx; + } + } +} + +void drw_rectl(int x, int y, int w, int h, enum COLORS col) +{ + drw_line(x, y, x+w, y, col); + drw_line(x+w, y, x+w, y+h, col); + + drw_line(x, y, x, y+h, col); + drw_line(x, y+h, x+w+1, y+h, col); +} + +void drw_rectf(int x, int y, int w, int h, enum COLORS col) +{ + int i, j; + for (j = y; j < x+h; j++) { + for (i = x; i < y+w; i++) { + *VGAPIX(i, j) = col; + } + } +} + +void drw_circl(int x, int y, int rad, enum COLORS col) +{ + int mang, i; // max angle, haha + int px, py; + mang = 360; // Yeah yeah I'll switch to rad later + for (i = 0; i <= mang; i++) + { + px = cos(i)*rad + x; // + px; // causes some really cools effects! :D + py = sin(i)*rad + y; // + py; + *VGAPIX(px, py) = col; + } +} + +void drw_tex(int x, int y, int w, int h, enum COLORS tex[]) +{ // i*w+j + int i, j; + for (i = 0; i < w; i++) + { + for (j = 0; j < h; j++) + { + *VGAPIX(x+i, y+j) = tex[j*w+i]; + } + } +} + +void 2D_init(void) +{ + set_vgabasemem(); + drw_chdis(0x13); +} + +void 2D_exit(void) +{ + drw_chdis(3); +} +/* +int main() +{ + set_vgabasemem(); + drw_chdis(0x13); + + while(!kbhit()) { + if ((getch()) == 0x1b) // escape + break; + } + drw_chdis(3); + return 0; +} +*/ diff --git a/samples/C/2D.H b/samples/C/2D.H new file mode 100644 index 00000000..e3354986 --- /dev/null +++ b/samples/C/2D.H @@ -0,0 +1,29 @@ +#ifndef __2DGFX +#define __2DGFX +// Includes +#include +#include +#include +#include + +// Defines +#define VGAPIX(x,y) (vgabasemem + (x) + (y) * 320) + +// Variables +char * vgabasemem; +DPMI_REGS regs; + +// Drawing functions: +//void setvgabasemem(void); +void drw_chdis(int mode); // draw_func_change_display +void drw_pix(int x, int y, enum COLORS col); +void drw_line(int x0, int y0, int x1, int y1, enum COLORS col); +void drw_rectl(int x, int y, int w, int h, enum COLORS col); +void drw_rectf(int x, int y, int w, int h, enum COLORS col); +void drw_cirl(int x, int y, int rad, enum COLORS col); +void drw_tex(int x, int y, int w, int h, enum COLORS tex[]); +void 2D_init(void); +void 2D_exit(void); + + +#endif diff --git a/samples/C/ArrowLeft.h b/samples/C/ArrowLeft.h new file mode 100644 index 00000000..b3577c0e --- /dev/null +++ b/samples/C/ArrowLeft.h @@ -0,0 +1,93 @@ +/* + * This file is part of GTK++ (libGTK++) + * Copyright © 2012 Rachel Mant (dx-mon@users.sourceforge.net) + * + * GTK++ is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GTK++ 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/* GdkPixbuf RGBA C-Source image dump */ + +#ifdef __SUNPRO_C +#pragma align 4 (ArrowLeft) +#endif +#ifdef __GNUC__ +static const uint8_t ArrowLeft[] __attribute__ ((__aligned__ (4))) = +#else +static const uint8_t ArrowLeft[] = +#endif +{ "" + /* Pixbuf magic (0x47646b50) */ + "GdkP" + /* length: header (24) + pixel_data (1600) */ + "\0\0\6X" + /* pixdata_type (0x1010002) */ + "\1\1\0\2" + /* rowstride (80) */ + "\0\0\0P" + /* width (20) */ + "\0\0\0\24" + /* height (20) */ + "\0\0\0\24" + /* pixel_data: */ + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\377" + "\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377" + "\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\377\0" + "\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0"}; + + diff --git a/samples/C/GLKMatrix4.h b/samples/C/GLKMatrix4.h new file mode 100644 index 00000000..41eb5afd --- /dev/null +++ b/samples/C/GLKMatrix4.h @@ -0,0 +1,903 @@ +// +// GLKMatrix4.h +// GLKit +// +// Copyright (c) 2011, Apple Inc. All rights reserved. +// + +#ifndef __GLK_MATRIX_4_H +#define __GLK_MATRIX_4_H + +#include +#include +#include + +#if defined(__ARM_NEON__) +#include +#endif + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#pragma mark - +#pragma mark Prototypes +#pragma mark - + +extern const GLKMatrix4 GLKMatrix4Identity; + +/* + m30, m31, and m32 correspond to the translation values tx, ty, tz, respectively. + */ +static __inline__ GLKMatrix4 GLKMatrix4Make(float m00, float m01, float m02, float m03, + float m10, float m11, float m12, float m13, + float m20, float m21, float m22, float m23, + float m30, float m31, float m32, float m33); + +/* + m03, m13, and m23 correspond to the translation values tx, ty, tz, respectively. + */ +static __inline__ GLKMatrix4 GLKMatrix4MakeAndTranspose(float m00, float m01, float m02, float m03, + float m10, float m11, float m12, float m13, + float m20, float m21, float m22, float m23, + float m30, float m31, float m32, float m33); + +/* + m[12], m[13], and m[14] correspond to the translation values tx, ty, and tz, respectively. + */ +static __inline__ GLKMatrix4 GLKMatrix4MakeWithArray(float values[16]); + +/* + m[3], m[7], and m[11] correspond to the translation values tx, ty, and tz, respectively. + */ +static __inline__ GLKMatrix4 GLKMatrix4MakeWithArrayAndTranspose(float values[16]); + +/* + row0, row1, and row2's last component should correspond to the translation values tx, ty, and tz, respectively. + */ +static __inline__ GLKMatrix4 GLKMatrix4MakeWithRows(GLKVector4 row0, + GLKVector4 row1, + GLKVector4 row2, + GLKVector4 row3); + +/* + column3's first three components should correspond to the translation values tx, ty, and tz. + */ +static __inline__ GLKMatrix4 GLKMatrix4MakeWithColumns(GLKVector4 column0, + GLKVector4 column1, + GLKVector4 column2, + GLKVector4 column3); + +/* + The quaternion will be normalized before conversion. + */ +static __inline__ GLKMatrix4 GLKMatrix4MakeWithQuaternion(GLKQuaternion quaternion); + +static __inline__ GLKMatrix4 GLKMatrix4MakeTranslation(float tx, float ty, float tz); +static __inline__ GLKMatrix4 GLKMatrix4MakeScale(float sx, float sy, float sz); +static __inline__ GLKMatrix4 GLKMatrix4MakeRotation(float radians, float x, float y, float z); + +static __inline__ GLKMatrix4 GLKMatrix4MakeXRotation(float radians); +static __inline__ GLKMatrix4 GLKMatrix4MakeYRotation(float radians); +static __inline__ GLKMatrix4 GLKMatrix4MakeZRotation(float radians); + +/* + Equivalent to gluPerspective. + */ +static __inline__ GLKMatrix4 GLKMatrix4MakePerspective(float fovyRadians, float aspect, float nearZ, float farZ); + +/* + Equivalent to glFrustum. + */ +static __inline__ GLKMatrix4 GLKMatrix4MakeFrustum(float left, float right, + float bottom, float top, + float nearZ, float farZ); + +/* + Equivalent to glOrtho. + */ +static __inline__ GLKMatrix4 GLKMatrix4MakeOrtho(float left, float right, + float bottom, float top, + float nearZ, float farZ); + +/* + Equivalent to gluLookAt. + */ +static __inline__ GLKMatrix4 GLKMatrix4MakeLookAt(float eyeX, float eyeY, float eyeZ, + float centerX, float centerY, float centerZ, + float upX, float upY, float upZ); + +/* + Returns the upper left 3x3 portion of the 4x4 matrix. + */ +static __inline__ GLKMatrix3 GLKMatrix4GetMatrix3(GLKMatrix4 matrix); +/* + Returns the upper left 2x2 portion of the 4x4 matrix. + */ +static __inline__ GLKMatrix2 GLKMatrix4GetMatrix2(GLKMatrix4 matrix); + +/* + GLKMatrix4GetRow returns vectors for rows 0, 1, and 2 whose last component will be the translation value tx, ty, and tz, respectively. + Valid row values range from 0 to 3, inclusive. + */ +static __inline__ GLKVector4 GLKMatrix4GetRow(GLKMatrix4 matrix, int row); +/* + GLKMatrix4GetColumn returns a vector for column 3 whose first three components will be the translation values tx, ty, and tz. + Valid column values range from 0 to 3, inclusive. + */ +static __inline__ GLKVector4 GLKMatrix4GetColumn(GLKMatrix4 matrix, int column); + +/* + GLKMatrix4SetRow expects that the vector for row 0, 1, and 2 will have a translation value as its last component. + Valid row values range from 0 to 3, inclusive. + */ +static __inline__ GLKMatrix4 GLKMatrix4SetRow(GLKMatrix4 matrix, int row, GLKVector4 vector); +/* + GLKMatrix4SetColumn expects that the vector for column 3 will contain the translation values tx, ty, and tz as its first three components, respectively. + Valid column values range from 0 to 3, inclusive. + */ +static __inline__ GLKMatrix4 GLKMatrix4SetColumn(GLKMatrix4 matrix, int column, GLKVector4 vector); + +static __inline__ GLKMatrix4 GLKMatrix4Transpose(GLKMatrix4 matrix); + +GLKMatrix4 GLKMatrix4Invert(GLKMatrix4 matrix, bool *isInvertible); +GLKMatrix4 GLKMatrix4InvertAndTranspose(GLKMatrix4 matrix, bool *isInvertible); + +static __inline__ GLKMatrix4 GLKMatrix4Multiply(GLKMatrix4 matrixLeft, GLKMatrix4 matrixRight); + +static __inline__ GLKMatrix4 GLKMatrix4Add(GLKMatrix4 matrixLeft, GLKMatrix4 matrixRight); +static __inline__ GLKMatrix4 GLKMatrix4Subtract(GLKMatrix4 matrixLeft, GLKMatrix4 matrixRight); + +static __inline__ GLKMatrix4 GLKMatrix4Translate(GLKMatrix4 matrix, float tx, float ty, float tz); +static __inline__ GLKMatrix4 GLKMatrix4TranslateWithVector3(GLKMatrix4 matrix, GLKVector3 translationVector); +/* + The last component of the GLKVector4, translationVector, is ignored. + */ +static __inline__ GLKMatrix4 GLKMatrix4TranslateWithVector4(GLKMatrix4 matrix, GLKVector4 translationVector); + +static __inline__ GLKMatrix4 GLKMatrix4Scale(GLKMatrix4 matrix, float sx, float sy, float sz); +static __inline__ GLKMatrix4 GLKMatrix4ScaleWithVector3(GLKMatrix4 matrix, GLKVector3 scaleVector); +/* + The last component of the GLKVector4, scaleVector, is ignored. + */ +static __inline__ GLKMatrix4 GLKMatrix4ScaleWithVector4(GLKMatrix4 matrix, GLKVector4 scaleVector); + +static __inline__ GLKMatrix4 GLKMatrix4Rotate(GLKMatrix4 matrix, float radians, float x, float y, float z); +static __inline__ GLKMatrix4 GLKMatrix4RotateWithVector3(GLKMatrix4 matrix, float radians, GLKVector3 axisVector); +/* + The last component of the GLKVector4, axisVector, is ignored. + */ +static __inline__ GLKMatrix4 GLKMatrix4RotateWithVector4(GLKMatrix4 matrix, float radians, GLKVector4 axisVector); + +static __inline__ GLKMatrix4 GLKMatrix4RotateX(GLKMatrix4 matrix, float radians); +static __inline__ GLKMatrix4 GLKMatrix4RotateY(GLKMatrix4 matrix, float radians); +static __inline__ GLKMatrix4 GLKMatrix4RotateZ(GLKMatrix4 matrix, float radians); + +/* + Assumes 0 in the w component. + */ +static __inline__ GLKVector3 GLKMatrix4MultiplyVector3(GLKMatrix4 matrixLeft, GLKVector3 vectorRight); +/* + Assumes 1 in the w component. + */ +static __inline__ GLKVector3 GLKMatrix4MultiplyVector3WithTranslation(GLKMatrix4 matrixLeft, GLKVector3 vectorRight); +/* + Assumes 1 in the w component and divides the resulting vector by w before returning. + */ +static __inline__ GLKVector3 GLKMatrix4MultiplyAndProjectVector3(GLKMatrix4 matrixLeft, GLKVector3 vectorRight); + +/* + Assumes 0 in the w component. + */ +static __inline__ void GLKMatrix4MultiplyVector3Array(GLKMatrix4 matrix, GLKVector3 *vectors, size_t vectorCount); +/* + Assumes 1 in the w component. + */ +static __inline__ void GLKMatrix4MultiplyVector3ArrayWithTranslation(GLKMatrix4 matrix, GLKVector3 *vectors, size_t vectorCount); +/* + Assumes 1 in the w component and divides the resulting vector by w before returning. + */ +static __inline__ void GLKMatrix4MultiplyAndProjectVector3Array(GLKMatrix4 matrix, GLKVector3 *vectors, size_t vectorCount); + +static __inline__ GLKVector4 GLKMatrix4MultiplyVector4(GLKMatrix4 matrixLeft, GLKVector4 vectorRight); + +static __inline__ void GLKMatrix4MultiplyVector4Array(GLKMatrix4 matrix, GLKVector4 *vectors, size_t vectorCount); + +#pragma mark - +#pragma mark Implementations +#pragma mark - + +static __inline__ GLKMatrix4 GLKMatrix4Make(float m00, float m01, float m02, float m03, + float m10, float m11, float m12, float m13, + float m20, float m21, float m22, float m23, + float m30, float m31, float m32, float m33) +{ + GLKMatrix4 m = { m00, m01, m02, m03, + m10, m11, m12, m13, + m20, m21, m22, m23, + m30, m31, m32, m33 }; + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4MakeAndTranspose(float m00, float m01, float m02, float m03, + float m10, float m11, float m12, float m13, + float m20, float m21, float m22, float m23, + float m30, float m31, float m32, float m33) +{ + GLKMatrix4 m = { m00, m10, m20, m30, + m01, m11, m21, m31, + m02, m12, m22, m32, + m03, m13, m23, m33 }; + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4MakeWithArray(float values[16]) +{ + GLKMatrix4 m = { values[0], values[1], values[2], values[3], + values[4], values[5], values[6], values[7], + values[8], values[9], values[10], values[11], + values[12], values[13], values[14], values[15] }; + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4MakeWithArrayAndTranspose(float values[16]) +{ +#if defined(__ARM_NEON__) + float32x4x4_t m = vld4q_f32(values); + return *(GLKMatrix4 *)&m; +#else + GLKMatrix4 m = { values[0], values[4], values[8], values[12], + values[1], values[5], values[9], values[13], + values[2], values[6], values[10], values[14], + values[3], values[7], values[11], values[15] }; + return m; +#endif +} + +static __inline__ GLKMatrix4 GLKMatrix4MakeWithRows(GLKVector4 row0, + GLKVector4 row1, + GLKVector4 row2, + GLKVector4 row3) +{ + GLKMatrix4 m = { row0.v[0], row1.v[0], row2.v[0], row3.v[0], + row0.v[1], row1.v[1], row2.v[1], row3.v[1], + row0.v[2], row1.v[2], row2.v[2], row3.v[2], + row0.v[3], row1.v[3], row2.v[3], row3.v[3] }; + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4MakeWithColumns(GLKVector4 column0, + GLKVector4 column1, + GLKVector4 column2, + GLKVector4 column3) +{ +#if defined(__ARM_NEON__) + float32x4x4_t m; + m.val[0] = vld1q_f32(column0.v); + m.val[1] = vld1q_f32(column1.v); + m.val[2] = vld1q_f32(column2.v); + m.val[3] = vld1q_f32(column3.v); + return *(GLKMatrix4 *)&m; +#else + GLKMatrix4 m = { column0.v[0], column0.v[1], column0.v[2], column0.v[3], + column1.v[0], column1.v[1], column1.v[2], column1.v[3], + column2.v[0], column2.v[1], column2.v[2], column2.v[3], + column3.v[0], column3.v[1], column3.v[2], column3.v[3] }; + return m; +#endif +} + +static __inline__ GLKMatrix4 GLKMatrix4MakeWithQuaternion(GLKQuaternion quaternion) +{ + quaternion = GLKQuaternionNormalize(quaternion); + + float x = quaternion.q[0]; + float y = quaternion.q[1]; + float z = quaternion.q[2]; + float w = quaternion.q[3]; + + float _2x = x + x; + float _2y = y + y; + float _2z = z + z; + float _2w = w + w; + + GLKMatrix4 m = { 1.0f - _2y * y - _2z * z, + _2x * y + _2w * z, + _2x * z - _2w * y, + 0.0f, + _2x * y - _2w * z, + 1.0f - _2x * x - _2z * z, + _2y * z + _2w * x, + 0.0f, + _2x * z + _2w * y, + _2y * z - _2w * x, + 1.0f - _2x * x - _2y * y, + 0.0f, + 0.0f, + 0.0f, + 0.0f, + 1.0f }; + + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4MakeTranslation(float tx, float ty, float tz) +{ + GLKMatrix4 m = GLKMatrix4Identity; + m.m[12] = tx; + m.m[13] = ty; + m.m[14] = tz; + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4MakeScale(float sx, float sy, float sz) +{ + GLKMatrix4 m = GLKMatrix4Identity; + m.m[0] = sx; + m.m[5] = sy; + m.m[10] = sz; + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4MakeRotation(float radians, float x, float y, float z) +{ + GLKVector3 v = GLKVector3Normalize(GLKVector3Make(x, y, z)); + float cos = cosf(radians); + float cosp = 1.0f - cos; + float sin = sinf(radians); + + GLKMatrix4 m = { cos + cosp * v.v[0] * v.v[0], + cosp * v.v[0] * v.v[1] + v.v[2] * sin, + cosp * v.v[0] * v.v[2] - v.v[1] * sin, + 0.0f, + cosp * v.v[0] * v.v[1] - v.v[2] * sin, + cos + cosp * v.v[1] * v.v[1], + cosp * v.v[1] * v.v[2] + v.v[0] * sin, + 0.0f, + cosp * v.v[0] * v.v[2] + v.v[1] * sin, + cosp * v.v[1] * v.v[2] - v.v[0] * sin, + cos + cosp * v.v[2] * v.v[2], + 0.0f, + 0.0f, + 0.0f, + 0.0f, + 1.0f }; + + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4MakeXRotation(float radians) +{ + float cos = cosf(radians); + float sin = sinf(radians); + + GLKMatrix4 m = { 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, cos, sin, 0.0f, + 0.0f, -sin, cos, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f }; + + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4MakeYRotation(float radians) +{ + float cos = cosf(radians); + float sin = sinf(radians); + + GLKMatrix4 m = { cos, 0.0f, -sin, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + sin, 0.0f, cos, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f }; + + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4MakeZRotation(float radians) +{ + float cos = cosf(radians); + float sin = sinf(radians); + + GLKMatrix4 m = { cos, sin, 0.0f, 0.0f, + -sin, cos, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f }; + + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4MakePerspective(float fovyRadians, float aspect, float nearZ, float farZ) +{ + float cotan = 1.0f / tanf(fovyRadians / 2.0f); + + GLKMatrix4 m = { cotan / aspect, 0.0f, 0.0f, 0.0f, + 0.0f, cotan, 0.0f, 0.0f, + 0.0f, 0.0f, (farZ + nearZ) / (nearZ - farZ), -1.0f, + 0.0f, 0.0f, (2.0f * farZ * nearZ) / (nearZ - farZ), 0.0f }; + + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4MakeFrustum(float left, float right, + float bottom, float top, + float nearZ, float farZ) +{ + float ral = right + left; + float rsl = right - left; + float tsb = top - bottom; + float tab = top + bottom; + float fan = farZ + nearZ; + float fsn = farZ - nearZ; + + GLKMatrix4 m = { 2.0f * nearZ / rsl, 0.0f, 0.0f, 0.0f, + 0.0f, 2.0f * nearZ / tsb, 0.0f, 0.0f, + ral / rsl, tab / tsb, -fan / fsn, -1.0f, + 0.0f, 0.0f, (-2.0f * farZ * nearZ) / fsn, 0.0f }; + + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4MakeOrtho(float left, float right, + float bottom, float top, + float nearZ, float farZ) +{ + float ral = right + left; + float rsl = right - left; + float tab = top + bottom; + float tsb = top - bottom; + float fan = farZ + nearZ; + float fsn = farZ - nearZ; + + GLKMatrix4 m = { 2.0f / rsl, 0.0f, 0.0f, 0.0f, + 0.0f, 2.0f / tsb, 0.0f, 0.0f, + 0.0f, 0.0f, -2.0f / fsn, 0.0f, + -ral / rsl, -tab / tsb, -fan / fsn, 1.0f }; + + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4MakeLookAt(float eyeX, float eyeY, float eyeZ, + float centerX, float centerY, float centerZ, + float upX, float upY, float upZ) +{ + GLKVector3 ev = { eyeX, eyeY, eyeZ }; + GLKVector3 cv = { centerX, centerY, centerZ }; + GLKVector3 uv = { upX, upY, upZ }; + GLKVector3 n = GLKVector3Normalize(GLKVector3Add(ev, GLKVector3Negate(cv))); + GLKVector3 u = GLKVector3Normalize(GLKVector3CrossProduct(uv, n)); + GLKVector3 v = GLKVector3CrossProduct(n, u); + + GLKMatrix4 m = { u.v[0], v.v[0], n.v[0], 0.0f, + u.v[1], v.v[1], n.v[1], 0.0f, + u.v[2], v.v[2], n.v[2], 0.0f, + GLKVector3DotProduct(GLKVector3Negate(u), ev), + GLKVector3DotProduct(GLKVector3Negate(v), ev), + GLKVector3DotProduct(GLKVector3Negate(n), ev), + 1.0f }; + + return m; +} + +static __inline__ GLKMatrix3 GLKMatrix4GetMatrix3(GLKMatrix4 matrix) +{ + GLKMatrix3 m = { matrix.m[0], matrix.m[1], matrix.m[2], + matrix.m[4], matrix.m[5], matrix.m[6], + matrix.m[8], matrix.m[9], matrix.m[10] }; + return m; +} + +static __inline__ GLKMatrix2 GLKMatrix4GetMatrix2(GLKMatrix4 matrix) +{ + GLKMatrix2 m = { matrix.m[0], matrix.m[1], + matrix.m[4], matrix.m[5] }; + return m; +} + +static __inline__ GLKVector4 GLKMatrix4GetRow(GLKMatrix4 matrix, int row) +{ + GLKVector4 v = { matrix.m[row], matrix.m[4 + row], matrix.m[8 + row], matrix.m[12 + row] }; + return v; +} + +static __inline__ GLKVector4 GLKMatrix4GetColumn(GLKMatrix4 matrix, int column) +{ +#if defined(__ARM_NEON__) + float32x4_t v = vld1q_f32(&(matrix.m[column * 4])); + return *(GLKVector4 *)&v; +#else + GLKVector4 v = { matrix.m[column * 4 + 0], matrix.m[column * 4 + 1], matrix.m[column * 4 + 2], matrix.m[column * 4 + 3] }; + return v; +#endif +} + +static __inline__ GLKMatrix4 GLKMatrix4SetRow(GLKMatrix4 matrix, int row, GLKVector4 vector) +{ + matrix.m[row] = vector.v[0]; + matrix.m[row + 4] = vector.v[1]; + matrix.m[row + 8] = vector.v[2]; + matrix.m[row + 12] = vector.v[3]; + + return matrix; +} + +static __inline__ GLKMatrix4 GLKMatrix4SetColumn(GLKMatrix4 matrix, int column, GLKVector4 vector) +{ +#if defined(__ARM_NEON__) + float *dst = &(matrix.m[column * 4]); + vst1q_f32(dst, vld1q_f32(vector.v)); + return matrix; +#else + matrix.m[column * 4 + 0] = vector.v[0]; + matrix.m[column * 4 + 1] = vector.v[1]; + matrix.m[column * 4 + 2] = vector.v[2]; + matrix.m[column * 4 + 3] = vector.v[3]; + + return matrix; +#endif +} + +static __inline__ GLKMatrix4 GLKMatrix4Transpose(GLKMatrix4 matrix) +{ +#if defined(__ARM_NEON__) + float32x4x4_t m = vld4q_f32(matrix.m); + return *(GLKMatrix4 *)&m; +#else + GLKMatrix4 m = { matrix.m[0], matrix.m[4], matrix.m[8], matrix.m[12], + matrix.m[1], matrix.m[5], matrix.m[9], matrix.m[13], + matrix.m[2], matrix.m[6], matrix.m[10], matrix.m[14], + matrix.m[3], matrix.m[7], matrix.m[11], matrix.m[15] }; + return m; +#endif +} + +static __inline__ GLKMatrix4 GLKMatrix4Multiply(GLKMatrix4 matrixLeft, GLKMatrix4 matrixRight) +{ +#if defined(__ARM_NEON__) + float32x4x4_t iMatrixLeft = *(float32x4x4_t *)&matrixLeft; + float32x4x4_t iMatrixRight = *(float32x4x4_t *)&matrixRight; + float32x4x4_t m; + + m.val[0] = vmulq_n_f32(iMatrixLeft.val[0], vgetq_lane_f32(iMatrixRight.val[0], 0)); + m.val[1] = vmulq_n_f32(iMatrixLeft.val[0], vgetq_lane_f32(iMatrixRight.val[1], 0)); + m.val[2] = vmulq_n_f32(iMatrixLeft.val[0], vgetq_lane_f32(iMatrixRight.val[2], 0)); + m.val[3] = vmulq_n_f32(iMatrixLeft.val[0], vgetq_lane_f32(iMatrixRight.val[3], 0)); + + m.val[0] = vmlaq_n_f32(m.val[0], iMatrixLeft.val[1], vgetq_lane_f32(iMatrixRight.val[0], 1)); + m.val[1] = vmlaq_n_f32(m.val[1], iMatrixLeft.val[1], vgetq_lane_f32(iMatrixRight.val[1], 1)); + m.val[2] = vmlaq_n_f32(m.val[2], iMatrixLeft.val[1], vgetq_lane_f32(iMatrixRight.val[2], 1)); + m.val[3] = vmlaq_n_f32(m.val[3], iMatrixLeft.val[1], vgetq_lane_f32(iMatrixRight.val[3], 1)); + + m.val[0] = vmlaq_n_f32(m.val[0], iMatrixLeft.val[2], vgetq_lane_f32(iMatrixRight.val[0], 2)); + m.val[1] = vmlaq_n_f32(m.val[1], iMatrixLeft.val[2], vgetq_lane_f32(iMatrixRight.val[1], 2)); + m.val[2] = vmlaq_n_f32(m.val[2], iMatrixLeft.val[2], vgetq_lane_f32(iMatrixRight.val[2], 2)); + m.val[3] = vmlaq_n_f32(m.val[3], iMatrixLeft.val[2], vgetq_lane_f32(iMatrixRight.val[3], 2)); + + m.val[0] = vmlaq_n_f32(m.val[0], iMatrixLeft.val[3], vgetq_lane_f32(iMatrixRight.val[0], 3)); + m.val[1] = vmlaq_n_f32(m.val[1], iMatrixLeft.val[3], vgetq_lane_f32(iMatrixRight.val[1], 3)); + m.val[2] = vmlaq_n_f32(m.val[2], iMatrixLeft.val[3], vgetq_lane_f32(iMatrixRight.val[2], 3)); + m.val[3] = vmlaq_n_f32(m.val[3], iMatrixLeft.val[3], vgetq_lane_f32(iMatrixRight.val[3], 3)); + + return *(GLKMatrix4 *)&m; +#else + GLKMatrix4 m; + + m.m[0] = matrixLeft.m[0] * matrixRight.m[0] + matrixLeft.m[4] * matrixRight.m[1] + matrixLeft.m[8] * matrixRight.m[2] + matrixLeft.m[12] * matrixRight.m[3]; + m.m[4] = matrixLeft.m[0] * matrixRight.m[4] + matrixLeft.m[4] * matrixRight.m[5] + matrixLeft.m[8] * matrixRight.m[6] + matrixLeft.m[12] * matrixRight.m[7]; + m.m[8] = matrixLeft.m[0] * matrixRight.m[8] + matrixLeft.m[4] * matrixRight.m[9] + matrixLeft.m[8] * matrixRight.m[10] + matrixLeft.m[12] * matrixRight.m[11]; + m.m[12] = matrixLeft.m[0] * matrixRight.m[12] + matrixLeft.m[4] * matrixRight.m[13] + matrixLeft.m[8] * matrixRight.m[14] + matrixLeft.m[12] * matrixRight.m[15]; + + m.m[1] = matrixLeft.m[1] * matrixRight.m[0] + matrixLeft.m[5] * matrixRight.m[1] + matrixLeft.m[9] * matrixRight.m[2] + matrixLeft.m[13] * matrixRight.m[3]; + m.m[5] = matrixLeft.m[1] * matrixRight.m[4] + matrixLeft.m[5] * matrixRight.m[5] + matrixLeft.m[9] * matrixRight.m[6] + matrixLeft.m[13] * matrixRight.m[7]; + m.m[9] = matrixLeft.m[1] * matrixRight.m[8] + matrixLeft.m[5] * matrixRight.m[9] + matrixLeft.m[9] * matrixRight.m[10] + matrixLeft.m[13] * matrixRight.m[11]; + m.m[13] = matrixLeft.m[1] * matrixRight.m[12] + matrixLeft.m[5] * matrixRight.m[13] + matrixLeft.m[9] * matrixRight.m[14] + matrixLeft.m[13] * matrixRight.m[15]; + + m.m[2] = matrixLeft.m[2] * matrixRight.m[0] + matrixLeft.m[6] * matrixRight.m[1] + matrixLeft.m[10] * matrixRight.m[2] + matrixLeft.m[14] * matrixRight.m[3]; + m.m[6] = matrixLeft.m[2] * matrixRight.m[4] + matrixLeft.m[6] * matrixRight.m[5] + matrixLeft.m[10] * matrixRight.m[6] + matrixLeft.m[14] * matrixRight.m[7]; + m.m[10] = matrixLeft.m[2] * matrixRight.m[8] + matrixLeft.m[6] * matrixRight.m[9] + matrixLeft.m[10] * matrixRight.m[10] + matrixLeft.m[14] * matrixRight.m[11]; + m.m[14] = matrixLeft.m[2] * matrixRight.m[12] + matrixLeft.m[6] * matrixRight.m[13] + matrixLeft.m[10] * matrixRight.m[14] + matrixLeft.m[14] * matrixRight.m[15]; + + m.m[3] = matrixLeft.m[3] * matrixRight.m[0] + matrixLeft.m[7] * matrixRight.m[1] + matrixLeft.m[11] * matrixRight.m[2] + matrixLeft.m[15] * matrixRight.m[3]; + m.m[7] = matrixLeft.m[3] * matrixRight.m[4] + matrixLeft.m[7] * matrixRight.m[5] + matrixLeft.m[11] * matrixRight.m[6] + matrixLeft.m[15] * matrixRight.m[7]; + m.m[11] = matrixLeft.m[3] * matrixRight.m[8] + matrixLeft.m[7] * matrixRight.m[9] + matrixLeft.m[11] * matrixRight.m[10] + matrixLeft.m[15] * matrixRight.m[11]; + m.m[15] = matrixLeft.m[3] * matrixRight.m[12] + matrixLeft.m[7] * matrixRight.m[13] + matrixLeft.m[11] * matrixRight.m[14] + matrixLeft.m[15] * matrixRight.m[15]; + + return m; +#endif +} + +static __inline__ GLKMatrix4 GLKMatrix4Add(GLKMatrix4 matrixLeft, GLKMatrix4 matrixRight) +{ +#if defined(__ARM_NEON__) + float32x4x4_t iMatrixLeft = *(float32x4x4_t *)&matrixLeft; + float32x4x4_t iMatrixRight = *(float32x4x4_t *)&matrixRight; + float32x4x4_t m; + + m.val[0] = vaddq_f32(iMatrixLeft.val[0], iMatrixRight.val[0]); + m.val[1] = vaddq_f32(iMatrixLeft.val[1], iMatrixRight.val[1]); + m.val[2] = vaddq_f32(iMatrixLeft.val[2], iMatrixRight.val[2]); + m.val[3] = vaddq_f32(iMatrixLeft.val[3], iMatrixRight.val[3]); + + return *(GLKMatrix4 *)&m; +#else + GLKMatrix4 m; + + m.m[0] = matrixLeft.m[0] + matrixRight.m[0]; + m.m[1] = matrixLeft.m[1] + matrixRight.m[1]; + m.m[2] = matrixLeft.m[2] + matrixRight.m[2]; + m.m[3] = matrixLeft.m[3] + matrixRight.m[3]; + + m.m[4] = matrixLeft.m[4] + matrixRight.m[4]; + m.m[5] = matrixLeft.m[5] + matrixRight.m[5]; + m.m[6] = matrixLeft.m[6] + matrixRight.m[6]; + m.m[7] = matrixLeft.m[7] + matrixRight.m[7]; + + m.m[8] = matrixLeft.m[8] + matrixRight.m[8]; + m.m[9] = matrixLeft.m[9] + matrixRight.m[9]; + m.m[10] = matrixLeft.m[10] + matrixRight.m[10]; + m.m[11] = matrixLeft.m[11] + matrixRight.m[11]; + + m.m[12] = matrixLeft.m[12] + matrixRight.m[12]; + m.m[13] = matrixLeft.m[13] + matrixRight.m[13]; + m.m[14] = matrixLeft.m[14] + matrixRight.m[14]; + m.m[15] = matrixLeft.m[15] + matrixRight.m[15]; + + return m; +#endif +} + +static __inline__ GLKMatrix4 GLKMatrix4Subtract(GLKMatrix4 matrixLeft, GLKMatrix4 matrixRight) +{ +#if defined(__ARM_NEON__) + float32x4x4_t iMatrixLeft = *(float32x4x4_t *)&matrixLeft; + float32x4x4_t iMatrixRight = *(float32x4x4_t *)&matrixRight; + float32x4x4_t m; + + m.val[0] = vsubq_f32(iMatrixLeft.val[0], iMatrixRight.val[0]); + m.val[1] = vsubq_f32(iMatrixLeft.val[1], iMatrixRight.val[1]); + m.val[2] = vsubq_f32(iMatrixLeft.val[2], iMatrixRight.val[2]); + m.val[3] = vsubq_f32(iMatrixLeft.val[3], iMatrixRight.val[3]); + + return *(GLKMatrix4 *)&m; +#else + GLKMatrix4 m; + + m.m[0] = matrixLeft.m[0] - matrixRight.m[0]; + m.m[1] = matrixLeft.m[1] - matrixRight.m[1]; + m.m[2] = matrixLeft.m[2] - matrixRight.m[2]; + m.m[3] = matrixLeft.m[3] - matrixRight.m[3]; + + m.m[4] = matrixLeft.m[4] - matrixRight.m[4]; + m.m[5] = matrixLeft.m[5] - matrixRight.m[5]; + m.m[6] = matrixLeft.m[6] - matrixRight.m[6]; + m.m[7] = matrixLeft.m[7] - matrixRight.m[7]; + + m.m[8] = matrixLeft.m[8] - matrixRight.m[8]; + m.m[9] = matrixLeft.m[9] - matrixRight.m[9]; + m.m[10] = matrixLeft.m[10] - matrixRight.m[10]; + m.m[11] = matrixLeft.m[11] - matrixRight.m[11]; + + m.m[12] = matrixLeft.m[12] - matrixRight.m[12]; + m.m[13] = matrixLeft.m[13] - matrixRight.m[13]; + m.m[14] = matrixLeft.m[14] - matrixRight.m[14]; + m.m[15] = matrixLeft.m[15] - matrixRight.m[15]; + + return m; +#endif +} + +static __inline__ GLKMatrix4 GLKMatrix4Translate(GLKMatrix4 matrix, float tx, float ty, float tz) +{ + GLKMatrix4 m = { matrix.m[0], matrix.m[1], matrix.m[2], matrix.m[3], + matrix.m[4], matrix.m[5], matrix.m[6], matrix.m[7], + matrix.m[8], matrix.m[9], matrix.m[10], matrix.m[11], + matrix.m[0] * tx + matrix.m[4] * ty + matrix.m[8] * tz + matrix.m[12], + matrix.m[1] * tx + matrix.m[5] * ty + matrix.m[9] * tz + matrix.m[13], + matrix.m[2] * tx + matrix.m[6] * ty + matrix.m[10] * tz + matrix.m[14], + matrix.m[15] }; + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4TranslateWithVector3(GLKMatrix4 matrix, GLKVector3 translationVector) +{ + GLKMatrix4 m = { matrix.m[0], matrix.m[1], matrix.m[2], matrix.m[3], + matrix.m[4], matrix.m[5], matrix.m[6], matrix.m[7], + matrix.m[8], matrix.m[9], matrix.m[10], matrix.m[11], + matrix.m[0] * translationVector.v[0] + matrix.m[4] * translationVector.v[1] + matrix.m[8] * translationVector.v[2] + matrix.m[12], + matrix.m[1] * translationVector.v[0] + matrix.m[5] * translationVector.v[1] + matrix.m[9] * translationVector.v[2] + matrix.m[13], + matrix.m[2] * translationVector.v[0] + matrix.m[6] * translationVector.v[1] + matrix.m[10] * translationVector.v[2] + matrix.m[14], + matrix.m[15] }; + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4TranslateWithVector4(GLKMatrix4 matrix, GLKVector4 translationVector) +{ + GLKMatrix4 m = { matrix.m[0], matrix.m[1], matrix.m[2], matrix.m[3], + matrix.m[4], matrix.m[5], matrix.m[6], matrix.m[7], + matrix.m[8], matrix.m[9], matrix.m[10], matrix.m[11], + matrix.m[0] * translationVector.v[0] + matrix.m[4] * translationVector.v[1] + matrix.m[8] * translationVector.v[2] + matrix.m[12], + matrix.m[1] * translationVector.v[0] + matrix.m[5] * translationVector.v[1] + matrix.m[9] * translationVector.v[2] + matrix.m[13], + matrix.m[2] * translationVector.v[0] + matrix.m[6] * translationVector.v[1] + matrix.m[10] * translationVector.v[2] + matrix.m[14], + matrix.m[15] }; + return m; +} + +static __inline__ GLKMatrix4 GLKMatrix4Scale(GLKMatrix4 matrix, float sx, float sy, float sz) +{ +#if defined(__ARM_NEON__) + float32x4x4_t iMatrix = *(float32x4x4_t *)&matrix; + float32x4x4_t m; + + m.val[0] = vmulq_n_f32(iMatrix.val[0], (float32_t)sx); + m.val[1] = vmulq_n_f32(iMatrix.val[1], (float32_t)sy); + m.val[2] = vmulq_n_f32(iMatrix.val[2], (float32_t)sz); + m.val[3] = iMatrix.val[3]; + + return *(GLKMatrix4 *)&m; +#else + GLKMatrix4 m = { matrix.m[0] * sx, matrix.m[1] * sx, matrix.m[2] * sx, matrix.m[3] * sx, + matrix.m[4] * sy, matrix.m[5] * sy, matrix.m[6] * sy, matrix.m[7] * sy, + matrix.m[8] * sz, matrix.m[9] * sz, matrix.m[10] * sz, matrix.m[11] * sz, + matrix.m[12], matrix.m[13], matrix.m[14], matrix.m[15] }; + return m; +#endif +} + +static __inline__ GLKMatrix4 GLKMatrix4ScaleWithVector3(GLKMatrix4 matrix, GLKVector3 scaleVector) +{ +#if defined(__ARM_NEON__) + float32x4x4_t iMatrix = *(float32x4x4_t *)&matrix; + float32x4x4_t m; + + m.val[0] = vmulq_n_f32(iMatrix.val[0], (float32_t)scaleVector.v[0]); + m.val[1] = vmulq_n_f32(iMatrix.val[1], (float32_t)scaleVector.v[1]); + m.val[2] = vmulq_n_f32(iMatrix.val[2], (float32_t)scaleVector.v[2]); + m.val[3] = iMatrix.val[3]; + + return *(GLKMatrix4 *)&m; +#else + GLKMatrix4 m = { matrix.m[0] * scaleVector.v[0], matrix.m[1] * scaleVector.v[0], matrix.m[2] * scaleVector.v[0], matrix.m[3] * scaleVector.v[0], + matrix.m[4] * scaleVector.v[1], matrix.m[5] * scaleVector.v[1], matrix.m[6] * scaleVector.v[1], matrix.m[7] * scaleVector.v[1], + matrix.m[8] * scaleVector.v[2], matrix.m[9] * scaleVector.v[2], matrix.m[10] * scaleVector.v[2], matrix.m[11] * scaleVector.v[2], + matrix.m[12], matrix.m[13], matrix.m[14], matrix.m[15] }; + return m; +#endif +} + +static __inline__ GLKMatrix4 GLKMatrix4ScaleWithVector4(GLKMatrix4 matrix, GLKVector4 scaleVector) +{ +#if defined(__ARM_NEON__) + float32x4x4_t iMatrix = *(float32x4x4_t *)&matrix; + float32x4x4_t m; + + m.val[0] = vmulq_n_f32(iMatrix.val[0], (float32_t)scaleVector.v[0]); + m.val[1] = vmulq_n_f32(iMatrix.val[1], (float32_t)scaleVector.v[1]); + m.val[2] = vmulq_n_f32(iMatrix.val[2], (float32_t)scaleVector.v[2]); + m.val[3] = iMatrix.val[3]; + + return *(GLKMatrix4 *)&m; +#else + GLKMatrix4 m = { matrix.m[0] * scaleVector.v[0], matrix.m[1] * scaleVector.v[0], matrix.m[2] * scaleVector.v[0], matrix.m[3] * scaleVector.v[0], + matrix.m[4] * scaleVector.v[1], matrix.m[5] * scaleVector.v[1], matrix.m[6] * scaleVector.v[1], matrix.m[7] * scaleVector.v[1], + matrix.m[8] * scaleVector.v[2], matrix.m[9] * scaleVector.v[2], matrix.m[10] * scaleVector.v[2], matrix.m[11] * scaleVector.v[2], + matrix.m[12], matrix.m[13], matrix.m[14], matrix.m[15] }; + return m; +#endif +} + +static __inline__ GLKMatrix4 GLKMatrix4Rotate(GLKMatrix4 matrix, float radians, float x, float y, float z) +{ + GLKMatrix4 rm = GLKMatrix4MakeRotation(radians, x, y, z); + return GLKMatrix4Multiply(matrix, rm); +} + +static __inline__ GLKMatrix4 GLKMatrix4RotateWithVector3(GLKMatrix4 matrix, float radians, GLKVector3 axisVector) +{ + GLKMatrix4 rm = GLKMatrix4MakeRotation(radians, axisVector.v[0], axisVector.v[1], axisVector.v[2]); + return GLKMatrix4Multiply(matrix, rm); +} + +static __inline__ GLKMatrix4 GLKMatrix4RotateWithVector4(GLKMatrix4 matrix, float radians, GLKVector4 axisVector) +{ + GLKMatrix4 rm = GLKMatrix4MakeRotation(radians, axisVector.v[0], axisVector.v[1], axisVector.v[2]); + return GLKMatrix4Multiply(matrix, rm); +} + +static __inline__ GLKMatrix4 GLKMatrix4RotateX(GLKMatrix4 matrix, float radians) +{ + GLKMatrix4 rm = GLKMatrix4MakeXRotation(radians); + return GLKMatrix4Multiply(matrix, rm); +} + +static __inline__ GLKMatrix4 GLKMatrix4RotateY(GLKMatrix4 matrix, float radians) +{ + GLKMatrix4 rm = GLKMatrix4MakeYRotation(radians); + return GLKMatrix4Multiply(matrix, rm); +} + +static __inline__ GLKMatrix4 GLKMatrix4RotateZ(GLKMatrix4 matrix, float radians) +{ + GLKMatrix4 rm = GLKMatrix4MakeZRotation(radians); + return GLKMatrix4Multiply(matrix, rm); +} + +static __inline__ GLKVector3 GLKMatrix4MultiplyVector3(GLKMatrix4 matrixLeft, GLKVector3 vectorRight) +{ + GLKVector4 v4 = GLKMatrix4MultiplyVector4(matrixLeft, GLKVector4Make(vectorRight.v[0], vectorRight.v[1], vectorRight.v[2], 0.0f)); + return GLKVector3Make(v4.v[0], v4.v[1], v4.v[2]); +} + +static __inline__ GLKVector3 GLKMatrix4MultiplyVector3WithTranslation(GLKMatrix4 matrixLeft, GLKVector3 vectorRight) +{ + GLKVector4 v4 = GLKMatrix4MultiplyVector4(matrixLeft, GLKVector4Make(vectorRight.v[0], vectorRight.v[1], vectorRight.v[2], 1.0f)); + return GLKVector3Make(v4.v[0], v4.v[1], v4.v[2]); +} + +static __inline__ GLKVector3 GLKMatrix4MultiplyAndProjectVector3(GLKMatrix4 matrixLeft, GLKVector3 vectorRight) +{ + GLKVector4 v4 = GLKMatrix4MultiplyVector4(matrixLeft, GLKVector4Make(vectorRight.v[0], vectorRight.v[1], vectorRight.v[2], 1.0f)); + return GLKVector3MultiplyScalar(GLKVector3Make(v4.v[0], v4.v[1], v4.v[2]), 1.0f / v4.v[3]); +} + +static __inline__ void GLKMatrix4MultiplyVector3Array(GLKMatrix4 matrix, GLKVector3 *vectors, size_t vectorCount) +{ + size_t i; + for (i=0; i < vectorCount; i++) + vectors[i] = GLKMatrix4MultiplyVector3(matrix, vectors[i]); +} + +static __inline__ void GLKMatrix4MultiplyVector3ArrayWithTranslation(GLKMatrix4 matrix, GLKVector3 *vectors, size_t vectorCount) +{ + size_t i; + for (i=0; i < vectorCount; i++) + vectors[i] = GLKMatrix4MultiplyVector3WithTranslation(matrix, vectors[i]); +} + +static __inline__ void GLKMatrix4MultiplyAndProjectVector3Array(GLKMatrix4 matrix, GLKVector3 *vectors, size_t vectorCount) +{ + size_t i; + for (i=0; i < vectorCount; i++) + vectors[i] = GLKMatrix4MultiplyAndProjectVector3(matrix, vectors[i]); +} + +static __inline__ GLKVector4 GLKMatrix4MultiplyVector4(GLKMatrix4 matrixLeft, GLKVector4 vectorRight) +{ +#if defined(__ARM_NEON__) + float32x4x4_t iMatrix = *(float32x4x4_t *)&matrixLeft; + float32x4_t v; + + iMatrix.val[0] = vmulq_n_f32(iMatrix.val[0], (float32_t)vectorRight.v[0]); + iMatrix.val[1] = vmulq_n_f32(iMatrix.val[1], (float32_t)vectorRight.v[1]); + iMatrix.val[2] = vmulq_n_f32(iMatrix.val[2], (float32_t)vectorRight.v[2]); + iMatrix.val[3] = vmulq_n_f32(iMatrix.val[3], (float32_t)vectorRight.v[3]); + + iMatrix.val[0] = vaddq_f32(iMatrix.val[0], iMatrix.val[1]); + iMatrix.val[2] = vaddq_f32(iMatrix.val[2], iMatrix.val[3]); + + v = vaddq_f32(iMatrix.val[0], iMatrix.val[2]); + + return *(GLKVector4 *)&v; +#else + GLKVector4 v = { matrixLeft.m[0] * vectorRight.v[0] + matrixLeft.m[4] * vectorRight.v[1] + matrixLeft.m[8] * vectorRight.v[2] + matrixLeft.m[12] * vectorRight.v[3], + matrixLeft.m[1] * vectorRight.v[0] + matrixLeft.m[5] * vectorRight.v[1] + matrixLeft.m[9] * vectorRight.v[2] + matrixLeft.m[13] * vectorRight.v[3], + matrixLeft.m[2] * vectorRight.v[0] + matrixLeft.m[6] * vectorRight.v[1] + matrixLeft.m[10] * vectorRight.v[2] + matrixLeft.m[14] * vectorRight.v[3], + matrixLeft.m[3] * vectorRight.v[0] + matrixLeft.m[7] * vectorRight.v[1] + matrixLeft.m[11] * vectorRight.v[2] + matrixLeft.m[15] * vectorRight.v[3] }; + return v; +#endif +} + +static __inline__ void GLKMatrix4MultiplyVector4Array(GLKMatrix4 matrix, GLKVector4 *vectors, size_t vectorCount) +{ + size_t i; + for (i=0; i < vectorCount; i++) + vectors[i] = GLKMatrix4MultiplyVector4(matrix, vectors[i]); +} + +#ifdef __cplusplus +} +#endif + +#endif /* __GLK_MATRIX_4_H */ diff --git a/samples/C/NWMan.h b/samples/C/NWMan.h new file mode 100644 index 00000000..abcd2ddb --- /dev/null +++ b/samples/C/NWMan.h @@ -0,0 +1,99 @@ +#ifndef _NME_WMAN_H +#define _NME_WMAN_H + +// Internal window manager API + +#include "NCompat.h" + +START_HEAD + +#include "NPos.h" +#include "NUtil.h" +#include "NTypes.h" + +NTS(NWMan_event); + +NSTRUCT(NWMan, { + // Init stuff + bool (*init)(); + bool (*destroy)(); + + // Window stuff + bool (*create_window)(); + bool (*destroy_window)(); + + void (*swap_buffers)(); + + // Event stuff + bool (*next_event)(NWMan_event* event); + + // Time stuff + uint (*get_millis)(); + void (*sleep)(uint millis); + + // Info + int rshift_key; + int lshift_key; + int left_key; + int right_key; +}); + +NENUM(NWMan_event_type, { + N_WMAN_MOUSE_MOVE = 0, + N_WMAN_MOUSE_BUTTON = 1, + N_WMAN_MOUSE_WHEEL = 2, + + N_WMAN_KEYBOARD = 10, + + N_WMAN_QUIT = 20, + N_WMAN_RESIZE = 21, + N_WMAN_FOCUS = 22 +}); + +#define N_WMAN_MOUSE_LEFT 0 +#define N_WMAN_MOUSE_RIGHT 1 +#define N_WMAN_MOUSE_MIDDLE 2 + +NSTRUCT(NWMan_event, { + NWMan_event_type type; + + union { + // Mouse + + NPos2i mouse_pos; + + struct { + short id; + bool state; + } mouse_button; + + signed char mouse_wheel; // 1 if up, -1 if down + + // Keyboard + + struct { + int key; + bool state; + } keyboard; + + // Window + + bool window_quit; // Will always be true if WM_QUIT + + NPos2i window_size; + + bool window_focus; + }; +}); + +NWMan_event NWMan_event_new(NWMan_event_type type); + + +bool NWMan_init(); +bool NWMan_destroy(); + +extern NWMan N_WMan; + +END_HEAD + +#endif diff --git a/samples/C/Nightmare.h b/samples/C/Nightmare.h new file mode 100644 index 00000000..3b639c20 --- /dev/null +++ b/samples/C/Nightmare.h @@ -0,0 +1,27 @@ +#ifndef _NMEX_NIGHTMARE_H +#define _NMEX_NIGHTMARE_H + +//#define NMEX + +#include "../src/NCompat.h" + +START_HEAD + +#include "../src/NTypes.h" +#include "../src/NUtil.h" +#include "../src/NPorting.h" +#include "../src/NGlobals.h" +#include "../src/NLog.h" +#include "../src/NWMan.h" +#include "../src/NRsc.h" +#include "../src/NShader.h" +#include "../src/NSquare.h" +#include "../src/NImage.h" +#include "../src/NSprite.h" +#include "../src/NSpritesheet.h" +#include "../src/NEntity.h" +#include "../src/Game.h" + +END_HEAD + +#endif diff --git a/samples/C/bitmap.h b/samples/C/bitmap.h new file mode 100644 index 00000000..30ab99ea --- /dev/null +++ b/samples/C/bitmap.h @@ -0,0 +1,47 @@ +#pragma once + +/* Copyright © 2010 Christoph Sünderhauf + * + * This file is part of Xelix. + * + * Xelix 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. + * + * Xelix 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 Xelix. If not, see . + */ + +#include "generic.h" + +typedef struct { + uint32_t numbits; + /* an array large enough for numbits to fit in. Might + * (if numbits%8!=0) have some spare bits at the end + */ + uint32_t* bits; +} bitmap_t; + + +// creates a new bitmap. +// CONTENT IS RANDOM! - use bitmap_clearall() to clear the bitmap. +bitmap_t bitmap_init(uint32_t numbits); + +// returns 1 or 0 +uint8_t bitmap_get(bitmap_t bitmap, uint32_t bitnum); +// sets a bit (to 1) +void bitmap_set(bitmap_t bitmap, uint32_t bitnum); +// clears a bit (to 0) +void bitmap_clear(bitmap_t bitmap, uint32_t bitnum); + +// clears every bit to 0 +void bitmap_clearAll(bitmap_t bitmap); + +// finds the first bit set to 0 returns 0 if no cleared bit found (0 is also returned if the first bit is cleared) +uint32_t bitmap_findFirstClear(bitmap_t bitmap); diff --git a/samples/C/color.h b/samples/C/color.h new file mode 100644 index 00000000..5c60b480 --- /dev/null +++ b/samples/C/color.h @@ -0,0 +1,44 @@ +#pragma once + +/* Copyright © 2011 Fritz Grimpen + * + * This file is part of Xelix. + * + * Xelix 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. + * + * Xelix 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 Xelix. If not, see . + */ + +#include + +typedef struct { + uint32_t background; + uint32_t foreground; +} console_color_t; + +#define CONSOLE_COLOR_BLACK 0x0 +#define CONSOLE_COLOR_BLUE 0x1 +#define CONSOLE_COLOR_GREEN 0x2 +#define CONSOLE_COLOR_CYAN 0x3 +#define CONSOLE_COLOR_RED 0x4 +#define CONSOLE_COLOR_MAGENTA 0x5 +#define CONSOLE_COLOR_BROWN 0x6 +#define CONSOLE_COLOR_LGREY 0x7 +#define CONSOLE_COLOR_DGREY 0x8 +#define CONSOLE_COLOR_LBLUE 0x9 +#define CONSOLE_COLOR_LGREEN 0xa +#define CONSOLE_COLOR_LCYAN 0xb +#define CONSOLE_COLOR_LRED 0xc +#define CONSOLE_COLOR_LMAGENTA 0xd +#define CONSOLE_COLOR_YELLOW 0xe +#define CONSOLE_COLOR_WHITE 0xf + diff --git a/samples/C/driver.h b/samples/C/driver.h new file mode 100644 index 00000000..e376c97d --- /dev/null +++ b/samples/C/driver.h @@ -0,0 +1,52 @@ +#pragma once + +/* Copyright © 2011 Fritz Grimpen + * + * This file is part of Xelix. + * + * Xelix 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. + * + * Xelix 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 Xelix. If not, see . + */ + +#include +#include + +#define CONSOLE_DRV_CAP_CLEAR 0x01 +#define CONSOLE_DRV_CAP_SCROLL 0x02 +#define CONSOLE_DRV_CAP_SET_CURSOR 0x04 + +// Input modifier keys +typedef struct { + bool shift_left:1; + bool shift_right:1; + bool control_left:1; + bool control_right:1; + bool alt:1; + bool super:1; +} console_modifiers_t; + +typedef struct { + char character; + console_modifiers_t* modifiers; +} console_read_t; + +typedef struct { + int (*write)(console_info_t*, char); + console_read_t* (*read)(console_info_t*); + + int capabilities; + + int (*_clear)(console_info_t*); + int (*scroll)(console_info_t*, int32_t); + void (*setCursor)(console_info_t*, uint32_t, uint32_t); +} console_driver_t; diff --git a/samples/C/elf.h b/samples/C/elf.h new file mode 100644 index 00000000..a270eb14 --- /dev/null +++ b/samples/C/elf.h @@ -0,0 +1,70 @@ +#pragma once + +/* Copyright © 2011 Lukas Martini + * + * This file is part of Xelix. + * + * Xelix 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. + * + * Xelix 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 Xelix. If not, see . + */ + +#include +#include + +#define ELF_TYPE_NONE 0 +#define ELF_TYPE_REL 1 +#define ELF_TYPE_EXEC 2 +#define ELF_TYPE_DYN 3 +#define ELF_TYPE_CORE 4 + +#define ELF_ARCH_NONE 0 +#define ELF_ARCH_386 3 + +#define ELF_VERSION_CURRENT 1 + +typedef struct { + unsigned char magic[4]; + /* Note: There _is_ other stuff in here, but we don't need it */ + unsigned char pad[12]; +} __attribute__((packed)) elf_ident_t; + +typedef struct { + uint32_t type; + uint32_t offset; + void* virtaddr; + void* physaddr; + uint32_t filesize; + uint32_t memsize; + uint32_t flags; + uint32_t alignment; +} __attribute__((packed)) elf_program_t; + +typedef struct { + elf_ident_t ident; + uint16_t type; /* Object file type */ + uint16_t machine; /* Architecture */ + uint32_t version; /* Object file version */ + void* entry; /* Entry point virtual address */ + uint32_t phoff; /* Program header table file offset */ + uint32_t shoff; /* Section header table file offset */ + uint32_t flags; /* Processor-specific flags */ + uint16_t ehsize; /* ELF header size in bytes */ + uint16_t phentsize; /* Program header table entry size */ + uint16_t phnum; /* Program header table entry count */ + uint16_t shentsize; /* Section header table entry size */ + uint16_t shnum; /* Section header table entry count */ + uint16_t shstrndx; /* Section header string table index */ +} __attribute__((packed)) elf_t; + +task_t* elf_load(elf_t* bin, char* name, char** environ, char** argv, int argc); +task_t* elf_load_file(char* path, char** environ, char** argv, int argc); diff --git a/samples/Zephir/filenames/exception.zep.c b/samples/C/exception.zep.c similarity index 100% rename from samples/Zephir/filenames/exception.zep.c rename to samples/C/exception.zep.c diff --git a/samples/Zephir/filenames/exception.zep.h b/samples/C/exception.zep.h similarity index 100% rename from samples/Zephir/filenames/exception.zep.h rename to samples/C/exception.zep.h diff --git a/samples/C/filenames/script b/samples/C/filenames/script new file mode 100755 index 00000000..53006397 --- /dev/null +++ b/samples/C/filenames/script @@ -0,0 +1,2310 @@ +#!/usr/bin/tcc -run -lm +// +// ZyklonB scripting plugin, using a custom stack-based language +// +// Copyright 2014 Přemysl Janouch. All rights reserved. +// See the file LICENSE for licensing information. +// +// Just compile this file as usual (sans #!) if you don't feel like using TCC. +// It is a very basic and portable C99 application. It's not supposed to be +// very sophisticated, for it'd get extremely big. +// +// The main influences of the language were Factor and Joy, stripped of all +// even barely complex stuff. In its current state, it's only really useful as +// a calculator but it's got great potential for extending. +// +// If you don't like something, just change it; this is just an experiment. +// +// NOTE: it is relatively easy to abuse. Be careful. +// + +#define _XOPEN_SOURCE 500 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define ADDRESS_SPACE_LIMIT (100 * 1024 * 1024) +#include + +#if defined __GNUC__ +#define ATTRIBUTE_PRINTF(x, y) __attribute__ ((format (printf, x, y))) +#else // ! __GNUC__ +#define ATTRIBUTE_PRINTF(x, y) +#endif // ! __GNUC__ + +#define N_ELEMENTS(a) (sizeof (a) / sizeof ((a)[0])) + +// --- Utilities --------------------------------------------------------------- + +static char *strdup_printf (const char *format, ...) ATTRIBUTE_PRINTF (1, 2); + +static char * +strdup_vprintf (const char *format, va_list ap) +{ + va_list aq; + va_copy (aq, ap); + int size = vsnprintf (NULL, 0, format, aq); + va_end (aq); + if (size < 0) + return NULL; + + char buf[size + 1]; + size = vsnprintf (buf, sizeof buf, format, ap); + if (size < 0) + return NULL; + + return strdup (buf); +} + +static char * +strdup_printf (const char *format, ...) +{ + va_list ap; + va_start (ap, format); + char *result = strdup_vprintf (format, ap); + va_end (ap); + return result; +} + +// --- Generic buffer ---------------------------------------------------------- + +struct buffer +{ + char *s; ///< Buffer data + size_t alloc; ///< Number of bytes allocated + size_t len; ///< Number of bytes used + bool memory_failure; ///< Memory allocation failed +}; + +#define BUFFER_INITIALIZER { NULL, 0, 0, false } + +static bool +buffer_append (struct buffer *self, const void *s, size_t n) +{ + if (self->memory_failure) + return false; + + if (!self->s) + self->s = malloc (self->alloc = 8); + while (self->len + n > self->alloc) + self->s = realloc (self->s, self->alloc <<= 1); + + if (!self->s) + { + self->memory_failure = true; + return false; + } + + memcpy (self->s + self->len, s, n); + self->len += n; + return true; +} + +inline static bool +buffer_append_c (struct buffer *self, char c) +{ + return buffer_append (self, &c, 1); +} + +// --- Data types -------------------------------------------------------------- + +enum item_type +{ + ITEM_STRING, + ITEM_WORD, + ITEM_INTEGER, + ITEM_FLOAT, + ITEM_LIST +}; + +struct item +{ +#define ITEM_HEADER \ + enum item_type type; /**< The type of this object */ \ + struct item *next; /**< Next item on the list/stack */ + + ITEM_HEADER +}; + +struct item_string +{ + ITEM_HEADER + size_t len; ///< Length of the string (sans '\0') + char value[]; ///< The null-terminated string value +}; + +#define get_string(item) \ + (assert ((item)->type == ITEM_STRING), \ + ((struct item_string *)(item))->value) + +/// It looks like a string but it doesn't quack like a string +#define item_word item_string + +#define get_word(item) \ + (assert ((item)->type == ITEM_WORD), \ + ((struct item_word *)(item))->value) + +struct item_integer +{ + ITEM_HEADER + long long value; ///< The integer value +}; + +#define get_integer(item) \ + (assert ((item)->type == ITEM_INTEGER), \ + ((struct item_integer *)(item))->value) + +struct item_float +{ + ITEM_HEADER + long double value; ///< The floating point value +}; + +#define get_float(item) \ + (assert ((item)->type == ITEM_FLOAT), \ + ((struct item_float *)(item))->value) + +struct item_list +{ + ITEM_HEADER + struct item *head; ///< The head of the list +}; + +#define get_list(item) \ + (assert ((item)->type == ITEM_LIST), \ + ((struct item_list *)(item))->head) + +#define set_list(item, head_) \ + (assert ((item)->type == ITEM_LIST), \ + item_free_list (((struct item_list *)(item))->head), \ + ((struct item_list *)(item))->head = (head_)) + +const char * +item_type_to_str (enum item_type type) +{ + switch (type) + { + case ITEM_STRING: return "string"; + case ITEM_WORD: return "word"; + case ITEM_INTEGER: return "integer"; + case ITEM_FLOAT: return "float"; + case ITEM_LIST: return "list"; + } + abort (); +} + +// --- Item management --------------------------------------------------------- + +static void item_free_list (struct item *); +static struct item *new_clone_list (const struct item *); + +static void +item_free (struct item *item) +{ + if (item->type == ITEM_LIST) + item_free_list (get_list (item)); + free (item); +} + +static void +item_free_list (struct item *item) +{ + while (item) + { + struct item *link = item; + item = item->next; + item_free (link); + } +} + +static struct item * +new_clone (const struct item *item) +{ + size_t size; + switch (item->type) + { + case ITEM_STRING: + case ITEM_WORD: + { + const struct item_string *x = (const struct item_string *) item; + size = sizeof *x + x->len + 1; + break; + } + case ITEM_INTEGER: size = sizeof (struct item_integer); break; + case ITEM_FLOAT: size = sizeof (struct item_float); break; + case ITEM_LIST: size = sizeof (struct item_list); break; + } + + struct item *clone = malloc (size); + if (!clone) + return NULL; + + memcpy (clone, item, size); + if (item->type == ITEM_LIST) + { + struct item_list *x = (struct item_list *) clone; + if (x->head && !(x->head = new_clone_list (x->head))) + { + free (clone); + return NULL; + } + } + clone->next = NULL; + return clone; +} + +static struct item * +new_clone_list (const struct item *item) +{ + struct item *head = NULL, *clone; + for (struct item **out = &head; item; item = item->next) + { + if (!(clone = *out = new_clone (item))) + { + item_free_list (head); + return NULL; + } + clone->next = NULL; + out = &clone->next; + } + return head; +} + +static struct item * +new_string (const char *s, ssize_t len) +{ + if (len < 0) + len = strlen (s); + + struct item_string *item = calloc (1, sizeof *item + len + 1); + if (!item) + return NULL; + + item->type = ITEM_STRING; + item->len = len; + memcpy (item->value, s, len); + item->value[len] = '\0'; + return (struct item *) item; +} + +static struct item * +new_word (const char *s, ssize_t len) +{ + struct item *item = new_string (s, len); + if (!item) + return NULL; + + item->type = ITEM_WORD; + return item; +} + +static struct item * +new_integer (long long value) +{ + struct item_integer *item = calloc (1, sizeof *item); + if (!item) + return NULL; + + item->type = ITEM_INTEGER; + item->value = value; + return (struct item *) item; +} + +static struct item * +new_float (long double value) +{ + struct item_float *item = calloc (1, sizeof *item); + if (!item) + return NULL; + + item->type = ITEM_FLOAT; + item->value = value; + return (struct item *) item; +} + +static struct item * +new_list (struct item *head) +{ + struct item_list *item = calloc (1, sizeof *item); + if (!item) + return NULL; + + item->type = ITEM_LIST; + item->head = head; + return (struct item *) item; +} + +// --- Parsing ----------------------------------------------------------------- + +#define PARSE_ERROR_TABLE(XX) \ + XX( OK, NULL ) \ + XX( EOF, "unexpected end of input" ) \ + XX( INVALID_HEXA_ESCAPE, "invalid hexadecimal escape sequence" ) \ + XX( INVALID_ESCAPE, "unrecognized escape sequence" ) \ + XX( MEMORY, "memory allocation failure" ) \ + XX( FLOAT_RANGE, "floating point value out of range" ) \ + XX( INTEGER_RANGE, "integer out of range" ) \ + XX( INVALID_INPUT, "invalid input" ) \ + XX( UNEXPECTED_INPUT, "unexpected input" ) + +enum tokenizer_error +{ +#define XX(x, y) PARSE_ERROR_ ## x, + PARSE_ERROR_TABLE (XX) +#undef XX + PARSE_ERROR_COUNT +}; + +struct tokenizer +{ + const char *cursor; + enum tokenizer_error error; +}; + +static bool +decode_hexa_escape (struct tokenizer *self, struct buffer *buf) +{ + int i; + char c, code = 0; + + for (i = 0; i < 2; i++) + { + c = tolower (*self->cursor); + if (c >= '0' && c <= '9') + code = (code << 4) | (c - '0'); + else if (c >= 'a' && c <= 'f') + code = (code << 4) | (c - 'a' + 10); + else + break; + + self->cursor++; + } + + if (!i) + return false; + + buffer_append_c (buf, code); + return true; +} + +static bool +decode_octal_escape (struct tokenizer *self, struct buffer *buf) +{ + int i; + char c, code = 0; + + for (i = 0; i < 3; i++) + { + c = *self->cursor; + if (c < '0' || c > '7') + break; + + code = (code << 3) | (c - '0'); + self->cursor++; + } + + if (!i) + return false; + + buffer_append_c (buf, code); + return true; +} + +static bool +decode_escape_sequence (struct tokenizer *self, struct buffer *buf) +{ + // Support some basic escape sequences from the C language + char c; + switch ((c = *self->cursor)) + { + case '\0': + self->error = PARSE_ERROR_EOF; + return false; + case 'x': + case 'X': + self->cursor++; + if (decode_hexa_escape (self, buf)) + return true; + + self->error = PARSE_ERROR_INVALID_HEXA_ESCAPE; + return false; + default: + if (decode_octal_escape (self, buf)) + return true; + + self->cursor++; + const char *from = "abfnrtv\"\\", *to = "\a\b\f\n\r\t\v\"\\", *x; + if ((x = strchr (from, c))) + { + buffer_append_c (buf, to[x - from]); + return true; + } + + self->error = PARSE_ERROR_INVALID_ESCAPE; + return false; + } +} + +static struct item * +parse_string (struct tokenizer *self) +{ + struct buffer buf = BUFFER_INITIALIZER; + struct item *item = NULL; + char c; + + while (true) + switch ((c = *self->cursor++)) + { + case '\0': + self->cursor--; + self->error = PARSE_ERROR_EOF; + goto end; + case '"': + if (buf.memory_failure + || !(item = new_string (buf.s, buf.len))) + self->error = PARSE_ERROR_MEMORY; + goto end; + case '\\': + if (decode_escape_sequence (self, &buf)) + break; + goto end; + default: + buffer_append_c (&buf, c); + } + +end: + free (buf.s); + return item; +} + +static struct item * +try_parse_number (struct tokenizer *self) +{ + // These two standard library functions can digest a lot of various inputs, + // including NaN and +/- infinity. That may get a bit confusing. + char *float_end; + errno = 0; + long double float_value = strtold (self->cursor, &float_end); + int float_errno = errno; + + char *int_end; + errno = 0; + long long int_value = strtoll (self->cursor, &int_end, 10); + int int_errno = errno; + + // If they both fail, then this is most probably not a number. + if (float_end == int_end && float_end == self->cursor) + return NULL; + + // Only use the floating point result if it parses more characters: + struct item *item; + if (float_end > int_end) + { + if (float_errno == ERANGE) + { + self->error = PARSE_ERROR_FLOAT_RANGE; + return NULL; + } + self->cursor = float_end; + if (!(item = new_float (float_value))) + self->error = PARSE_ERROR_MEMORY; + return item; + } + else + { + if (int_errno == ERANGE) + { + self->error = PARSE_ERROR_INTEGER_RANGE; + return NULL; + } + self->cursor = int_end; + if (!(item = new_integer (int_value))) + self->error = PARSE_ERROR_MEMORY; + return item; + } +} + +static struct item * +parse_word (struct tokenizer *self) +{ + struct buffer buf = BUFFER_INITIALIZER; + struct item *item = NULL; + char c; + + // Here we accept almost anything that doesn't break the grammar + while (!strchr (" []\"", (c = *self->cursor++)) && (unsigned char) c > ' ') + buffer_append_c (&buf, c); + self->cursor--; + + if (buf.memory_failure) + self->error = PARSE_ERROR_MEMORY; + else if (!buf.len) + self->error = PARSE_ERROR_INVALID_INPUT; + else if (!(item = new_word (buf.s, buf.len))) + self->error = PARSE_ERROR_MEMORY; + + free (buf.s); + return item; +} + +static struct item *parse_item_list (struct tokenizer *); + +static struct item * +parse_list (struct tokenizer *self) +{ + struct item *list = parse_item_list (self); + if (self->error) + { + assert (list == NULL); + return NULL; + } + if (!*self->cursor) + { + self->error = PARSE_ERROR_EOF; + item_free_list (list); + return NULL; + } + assert (*self->cursor == ']'); + self->cursor++; + return new_list (list); +} + +static struct item * +parse_item (struct tokenizer *self) +{ + char c; + switch ((c = *self->cursor++)) + { + case '[': return parse_list (self); + case '"': return parse_string (self); + default:; + } + + self->cursor--; + struct item *item = try_parse_number (self); + if (!item && !self->error) + item = parse_word (self); + return item; +} + +static struct item * +parse_item_list (struct tokenizer *self) +{ + struct item *head = NULL; + struct item **tail = &head; + + char c; + bool expected = true; + while ((c = *self->cursor) && c != ']') + { + if (isspace (c)) + { + self->cursor++; + expected = true; + continue; + } + else if (!expected) + { + self->error = PARSE_ERROR_UNEXPECTED_INPUT; + goto fail; + } + + if (!(*tail = parse_item (self))) + goto fail; + tail = &(*tail)->next; + expected = false; + } + return head; + +fail: + item_free_list (head); + return NULL; +} + +static struct item * +parse (const char *s, const char **error) +{ + struct tokenizer self = { .cursor = s, .error = PARSE_ERROR_OK }; + struct item *list = parse_item_list (&self); + if (!self.error && *self.cursor != '\0') + { + self.error = PARSE_ERROR_UNEXPECTED_INPUT; + item_free_list (list); + list = NULL; + } + +#define XX(x, y) y, + static const char *strings[PARSE_ERROR_COUNT] = + { PARSE_ERROR_TABLE (XX) }; +#undef XX + + static char error_buf[128]; + if (self.error && error) + { + snprintf (error_buf, sizeof error_buf, "at character %d: %s", + (int) (self.cursor - s) + 1, strings[self.error]); + *error = error_buf; + } + return list; +} + +// --- Runtime ----------------------------------------------------------------- + +// TODO: try to think of a _simple_ way to do preemptive multitasking + +struct context +{ + struct item *stack; ///< The current top of the stack + size_t stack_size; ///< Number of items on the stack + + size_t reduction_count; ///< # of function calls so far + size_t reduction_limit; ///< The hard limit on function calls + + char *error; ///< Error information + bool error_is_fatal; ///< Whether the error can be catched + bool memory_failure; ///< Memory allocation failure + + void *user_data; ///< User data +}; + +/// Internal handler for a function +typedef bool (*handler_fn) (struct context *); + +struct fn +{ + struct fn *next; ///< The next link in the chain + + handler_fn handler; ///< Internal C handler, or NULL + struct item *script; ///< Alternatively runtime code + char name[]; ///< The name of the function +}; + +struct fn *g_functions; ///< Maps words to functions + +static void +context_init (struct context *ctx) +{ + ctx->stack = NULL; + ctx->stack_size = 0; + + ctx->reduction_count = 0; + ctx->reduction_limit = 2000; + + ctx->error = NULL; + ctx->error_is_fatal = false; + ctx->memory_failure = false; + + ctx->user_data = NULL; +} + +static void +context_free (struct context *ctx) +{ + item_free_list (ctx->stack); + ctx->stack = NULL; + + free (ctx->error); + ctx->error = NULL; +} + +static bool +set_error (struct context *ctx, const char *format, ...) +{ + free (ctx->error); + + va_list ap; + va_start (ap, format); + ctx->error = strdup_vprintf (format, ap); + va_end (ap); + + if (!ctx->error) + ctx->memory_failure = true; + return false; +} + +static bool +push (struct context *ctx, struct item *item) +{ + // The `item' is typically a result from new_(), thus when it is null, + // that function must have failed. This is a shortcut for convenience. + if (!item) + { + ctx->memory_failure = true; + return false; + } + + assert (item->next == NULL); + item->next = ctx->stack; + ctx->stack = item; + ctx->stack_size++; + return true; +} + +static bool +bump_reductions (struct context *ctx) +{ + if (++ctx->reduction_count >= ctx->reduction_limit) + { + ctx->error_is_fatal = true; + return set_error (ctx, "reduction limit reached"); + } + return true; +} + +static bool execute (struct context *, struct item *); + +static bool +call_function (struct context *ctx, const char *name) +{ + struct fn *iter; + for (iter = g_functions; iter; iter = iter->next) + if (!strcmp (name, iter->name)) + goto found; + return set_error (ctx, "unknown function: %s", name); + +found: + if (!bump_reductions (ctx)) + return false; + + if (iter->handler + ? iter->handler (ctx) + : execute (ctx, iter->script)) + return true; + + // In this case, `error' is NULL + if (ctx->memory_failure) + return false; + + // This creates some form of a stack trace + char *tmp = ctx->error; + ctx->error = NULL; + set_error (ctx, "%s -> %s", name, tmp); + free (tmp); + return false; +} + +static void +free_function (struct fn *fn) +{ + item_free_list (fn->script); + free (fn); +} + +static void +unregister_function (const char *name) +{ + for (struct fn **iter = &g_functions; *iter; iter = &(*iter)->next) + if (!strcmp ((*iter)->name, name)) + { + struct fn *tmp = *iter; + *iter = tmp->next; + free_function (tmp); + break; + } +} + +static struct fn * +prepend_new_fn (const char *name) +{ + struct fn *fn = calloc (1, sizeof *fn + strlen (name) + 1); + if (!fn) + return NULL; + + strcpy (fn->name, name); + fn->next = g_functions; + return g_functions = fn; +} + +static bool +register_handler (const char *name, handler_fn handler) +{ + unregister_function (name); + struct fn *fn = prepend_new_fn (name); + if (!fn) + return false; + fn->handler = handler; + return true; +} + +static bool +register_script (const char *name, struct item *script) +{ + unregister_function (name); + struct fn *fn = prepend_new_fn (name); + if (!fn) + return false; + fn->script = script; + return true; +} + +static bool +execute (struct context *ctx, struct item *script) +{ + for (; script; script = script->next) + { + if (script->type != ITEM_WORD) + { + if (!bump_reductions (ctx) + || !push (ctx, new_clone (script))) + return false; + } + else if (!call_function (ctx, get_word (script))) + return false; + } + return true; +} + +// --- Runtime library --------------------------------------------------------- + +#define defn(name) static bool name (struct context *ctx) + +#define check_stack(n) \ + if (ctx->stack_size < n) { \ + set_error (ctx, "stack underflow"); \ + return 0; \ + } + +inline static bool +check_stack_safe (struct context *ctx, size_t n) +{ + check_stack (n); + return true; +} + +static bool +check_type (struct context *ctx, const void *item_, enum item_type type) +{ + const struct item *item = item_; + if (item->type == type) + return true; + + return set_error (ctx, "invalid type: expected `%s', got `%s'", + item_type_to_str (type), item_type_to_str (item->type)); +} + +static struct item * +pop (struct context *ctx) +{ + check_stack (1); + struct item *top = ctx->stack; + ctx->stack = top->next; + top->next = NULL; + ctx->stack_size--; + return top; +} + +// - - Types - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +#define defn_is_type(name, item_type) \ + defn (fn_is_##name) { \ + check_stack (1); \ + struct item *top = pop (ctx); \ + push (ctx, new_integer (top->type == (item_type))); \ + item_free (top); \ + return true; \ + } + +defn_is_type (string, ITEM_STRING) +defn_is_type (word, ITEM_WORD) +defn_is_type (integer, ITEM_INTEGER) +defn_is_type (float, ITEM_FLOAT) +defn_is_type (list, ITEM_LIST) + +defn (fn_to_string) +{ + check_stack (1); + struct item *item = pop (ctx); + char *value; + + switch (item->type) + { + case ITEM_WORD: + item->type = ITEM_STRING; + case ITEM_STRING: + return push (ctx, item); + + case ITEM_FLOAT: + value = strdup_printf ("%Lf", get_float (item)); + break; + case ITEM_INTEGER: + value = strdup_printf ("%lld", get_integer (item)); + break; + + default: + set_error (ctx, "cannot convert `%s' to `%s'", + item_type_to_str (item->type), item_type_to_str (ITEM_STRING)); + item_free (item); + return false; + } + + item_free (item); + if (!value) + { + ctx->memory_failure = true; + return false; + } + + item = new_string (value, -1); + free (value); + return push (ctx, item); +} + +defn (fn_to_integer) +{ + check_stack (1); + struct item *item = pop (ctx); + long long value; + + switch (item->type) + { + case ITEM_INTEGER: + return push (ctx, item); + case ITEM_FLOAT: + value = get_float (item); + break; + + case ITEM_STRING: + { + char *end; + const char *s = get_string (item); + value = strtoll (s, &end, 10); + if (end != s && *s == '\0') + break; + + item_free (item); + return set_error (ctx, "integer conversion error"); + } + + default: + set_error (ctx, "cannot convert `%s' to `%s'", + item_type_to_str (item->type), item_type_to_str (ITEM_INTEGER)); + item_free (item); + return false; + } + + item_free (item); + return push (ctx, new_integer (value)); +} + +defn (fn_to_float) +{ + check_stack (1); + struct item *item = pop (ctx); + long double value; + + switch (item->type) + { + case ITEM_FLOAT: + return push (ctx, item); + case ITEM_INTEGER: + value = get_integer (item); + break; + + case ITEM_STRING: + { + char *end; + const char *s = get_string (item); + value = strtold (s, &end); + if (end != s && *s == '\0') + break; + + item_free (item); + return set_error (ctx, "float conversion error"); + } + + default: + set_error (ctx, "cannot convert `%s' to `%s'", + item_type_to_str (item->type), item_type_to_str (ITEM_FLOAT)); + item_free (item); + return false; + } + + item_free (item); + return push (ctx, new_float (value)); +} + +// - - Miscellaneous - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +defn (fn_length) +{ + check_stack (1); + struct item *item = pop (ctx); + bool success = true; + switch (item->type) + { + case ITEM_STRING: + success = push (ctx, new_integer (((struct item_string *) item)->len)); + break; + case ITEM_LIST: + { + long long length = 0; + struct item *iter; + for (iter = get_list (item); iter; iter = iter->next) + length++; + success = push (ctx, new_integer (length)); + break; + } + default: + success = set_error (ctx, "invalid type"); + } + item_free (item); + return success; +} + +// - - Stack operations - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +defn (fn_dup) +{ + check_stack (1); + return push (ctx, new_clone (ctx->stack)); +} + +defn (fn_drop) +{ + check_stack (1); + item_free (pop (ctx)); + return true; +} + +defn (fn_swap) +{ + check_stack (2); + struct item *second = pop (ctx), *first = pop (ctx); + return push (ctx, second) && push (ctx, first); +} + +defn (fn_call) +{ + check_stack (1); + struct item *script = pop (ctx); + bool success = check_type (ctx, script, ITEM_LIST) + && execute (ctx, get_list (script)); + item_free (script); + return success; +} + +defn (fn_dip) +{ + check_stack (2); + struct item *script = pop (ctx); + struct item *item = pop (ctx); + bool success = check_type (ctx, script, ITEM_LIST) + && execute (ctx, get_list (script)); + item_free (script); + if (!success) + { + item_free (item); + return false; + } + return push (ctx, item); +} + +defn (fn_unit) +{ + check_stack (1); + struct item *item = pop (ctx); + return push (ctx, new_list (item)); +} + +defn (fn_cons) +{ + check_stack (2); + struct item *list = pop (ctx); + struct item *item = pop (ctx); + if (!check_type (ctx, list, ITEM_LIST)) + { + item_free (list); + item_free (item); + return false; + } + item->next = get_list (list); + ((struct item_list *) list)->head = item; + return push (ctx, list); +} + +defn (fn_cat) +{ + check_stack (2); + struct item *scnd = pop (ctx); + struct item *frst = pop (ctx); + if (!check_type (ctx, frst, ITEM_LIST) + || !check_type (ctx, scnd, ITEM_LIST)) + { + item_free (frst); + item_free (scnd); + return false; + } + + // XXX: we shouldn't have to do this in O(n) + struct item **tail = &((struct item_list *) frst)->head; + while (*tail) + tail = &(*tail)->next; + *tail = get_list (scnd); + + ((struct item_list *) scnd)->head = NULL; + item_free (scnd); + return push (ctx, frst); +} + +defn (fn_uncons) +{ + check_stack (1); + struct item *list = pop (ctx); + if (!check_type (ctx, list, ITEM_LIST)) + goto fail; + struct item *first = get_list (list); + if (!first) + { + set_error (ctx, "list is empty"); + goto fail; + } + ((struct item_list *) list)->head = first->next; + first->next = NULL; + return push (ctx, first) && push (ctx, list); +fail: + item_free (list); + return false; +} + +// - - Logical - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +static bool +to_boolean (struct context *ctx, struct item *item, bool *ok) +{ + switch (item->type) + { + case ITEM_STRING: + return *get_string (item) != '\0'; + case ITEM_INTEGER: + return get_integer (item) != 0; + case ITEM_FLOAT: + return get_float (item) != 0.; + default: + return (*ok = set_error (ctx, "cannot convert `%s' to boolean", + item_type_to_str (item->type))); + } +} + +defn (fn_not) +{ + check_stack (1); + struct item *item = pop (ctx); + bool ok = true; + bool result = !to_boolean (ctx, item, &ok); + item_free (item); + return ok && push (ctx, new_integer (result)); +} + +defn (fn_and) +{ + check_stack (2); + struct item *op1 = pop (ctx); + struct item *op2 = pop (ctx); + bool ok = true; + bool result = to_boolean (ctx, op1, &ok) && to_boolean (ctx, op2, &ok); + item_free (op1); + item_free (op2); + return ok && push (ctx, new_integer (result)); +} + +defn (fn_or) +{ + check_stack (2); + struct item *op1 = pop (ctx); + struct item *op2 = pop (ctx); + bool ok = true; + bool result = to_boolean (ctx, op1, &ok) + || !ok || to_boolean (ctx, op2, &ok); + item_free (op1); + item_free (op2); + return ok && push (ctx, new_integer (result)); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +defn (fn_if) +{ + check_stack (3); + struct item *else_ = pop (ctx); + struct item *then_ = pop (ctx); + struct item *cond_ = pop (ctx); + + bool ok = true; + bool condition = to_boolean (ctx, cond_, &ok); + item_free (cond_); + + bool success = false; + if (ok + && check_type (ctx, then_, ITEM_LIST) + && check_type (ctx, else_, ITEM_LIST)) + success = execute (ctx, condition + ? get_list (then_) + : get_list (else_)); + + item_free (then_); + item_free (else_); + return success; +} + +defn (fn_try) +{ + check_stack (2); + struct item *catch = pop (ctx); + struct item *try = pop (ctx); + bool success = false; + if (!check_type (ctx, try, ITEM_LIST) + || !check_type (ctx, catch, ITEM_LIST)) + goto fail; + + if (!execute (ctx, get_list (try))) + { + if (ctx->memory_failure || ctx->error_is_fatal) + goto fail; + + success = push (ctx, new_string (ctx->error, -1)); + free (ctx->error); + ctx->error = NULL; + + if (success) + success = execute (ctx, get_list (catch)); + } + +fail: + item_free (try); + item_free (catch); + return success; +} + +defn (fn_map) +{ + check_stack (2); + struct item *fn = pop (ctx); + struct item *list = pop (ctx); + if (!check_type (ctx, fn, ITEM_LIST) + || !check_type (ctx, list, ITEM_LIST)) + { + item_free (fn); + item_free (list); + return false; + } + + bool success = false; + struct item *result = NULL, **tail = &result; + for (struct item *iter = get_list (list); iter; iter = iter->next) + { + if (!push (ctx, new_clone (iter)) + || !execute (ctx, get_list (fn)) + || !check_stack_safe (ctx, 1)) + goto fail; + + struct item *item = pop (ctx); + *tail = item; + tail = &item->next; + } + success = true; + +fail: + set_list (list, result); + item_free (fn); + if (!success) + { + item_free (list); + return false; + } + return push (ctx, list); +} + +defn (fn_filter) +{ + check_stack (2); + struct item *fn = pop (ctx); + struct item *list = pop (ctx); + if (!check_type (ctx, fn, ITEM_LIST) + || !check_type (ctx, list, ITEM_LIST)) + { + item_free (fn); + item_free (list); + return false; + } + + bool success = false; + bool ok = true; + struct item *result = NULL, **tail = &result; + for (struct item *iter = get_list (list); iter; iter = iter->next) + { + if (!push (ctx, new_clone (iter)) + || !execute (ctx, get_list (fn)) + || !check_stack_safe (ctx, 1)) + goto fail; + + struct item *item = pop (ctx); + bool survived = to_boolean (ctx, item, &ok); + item_free (item); + if (!ok) + goto fail; + if (!survived) + continue; + + if (!(item = new_clone (iter))) + goto fail; + *tail = item; + tail = &item->next; + } + success = true; + +fail: + set_list (list, result); + item_free (fn); + if (!success) + { + item_free (list); + return false; + } + return push (ctx, list); +} + +defn (fn_fold) +{ + check_stack (3); + struct item *op = pop (ctx); + struct item *null = pop (ctx); + struct item *list = pop (ctx); + bool success = false; + if (!check_type (ctx, op, ITEM_LIST) + || !check_type (ctx, list, ITEM_LIST)) + { + item_free (null); + goto fail; + } + + push (ctx, null); + for (struct item *iter = get_list (list); iter; iter = iter->next) + if (!push (ctx, new_clone (iter)) + || !execute (ctx, get_list (op))) + goto fail; + success = true; + +fail: + item_free (op); + item_free (list); + return success; +} + +defn (fn_each) +{ + check_stack (2); + struct item *op = pop (ctx); + struct item *list = pop (ctx); + bool success = false; + if (!check_type (ctx, op, ITEM_LIST) + || !check_type (ctx, list, ITEM_LIST)) + goto fail; + + for (struct item *iter = get_list (list); iter; iter = iter->next) + if (!push (ctx, new_clone (iter)) + || !execute (ctx, get_list (op))) + goto fail; + success = true; + +fail: + item_free (op); + item_free (list); + return success; +} + +// - - Arithmetic - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// XXX: why not a `struct item_string *` argument? +static bool +push_repeated_string (struct context *ctx, struct item *op1, struct item *op2) +{ + struct item_string *string = (struct item_string *) op1; + struct item_integer *repeat = (struct item_integer *) op2; + assert (string->type == ITEM_STRING); + assert (repeat->type == ITEM_INTEGER); + + if (repeat->value < 0) + return set_error (ctx, "cannot multiply a string by a negative value"); + + char *buf = NULL; + size_t len = string->len * repeat->value; + if (len < string->len && repeat->value != 0) + goto allocation_fail; + + buf = malloc (len); + if (!buf) + goto allocation_fail; + + for (size_t i = 0; i < len; i += string->len) + memcpy (buf + i, string->value, string->len); + struct item *item = new_string (buf, len); + free (buf); + return push (ctx, item); + +allocation_fail: + ctx->memory_failure = true; + return false; +} + +defn (fn_times) +{ + check_stack (2); + struct item *op2 = pop (ctx); + struct item *op1 = pop (ctx); + + bool ok; + if (op1->type == ITEM_INTEGER && op2->type == ITEM_INTEGER) + ok = push (ctx, new_integer (get_integer (op1) * get_integer (op2))); + else if (op1->type == ITEM_INTEGER && op2->type == ITEM_FLOAT) + ok = push (ctx, new_float (get_integer (op1) * get_float (op2))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_FLOAT) + ok = push (ctx, new_float (get_float (op1) * get_float (op2))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_INTEGER) + ok = push (ctx, new_float (get_float (op1) * get_integer (op2))); + else if (op1->type == ITEM_INTEGER && op2->type == ITEM_STRING) + ok = push_repeated_string (ctx, op2, op1); + else if (op1->type == ITEM_STRING && op2->type == ITEM_INTEGER) + ok = push_repeated_string (ctx, op1, op2); + else + ok = set_error (ctx, "cannot multiply `%s' and `%s'", + item_type_to_str (op1->type), item_type_to_str (op2->type)); + + item_free (op1); + item_free (op2); + return ok; +} + +defn (fn_pow) +{ + check_stack (2); + struct item *op2 = pop (ctx); + struct item *op1 = pop (ctx); + + bool ok; + if (op1->type == ITEM_INTEGER && op2->type == ITEM_INTEGER) + // TODO: implement this properly, outputting an integer + ok = push (ctx, new_float (powl (get_integer (op1), get_integer (op2)))); + else if (op1->type == ITEM_INTEGER && op2->type == ITEM_FLOAT) + ok = push (ctx, new_float (powl (get_integer (op1), get_float (op2)))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_FLOAT) + ok = push (ctx, new_float (powl (get_float (op1), get_float (op2)))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_INTEGER) + ok = push (ctx, new_float (powl (get_float (op1), get_integer (op2)))); + else + ok = set_error (ctx, "cannot exponentiate `%s' and `%s'", + item_type_to_str (op1->type), item_type_to_str (op2->type)); + + item_free (op1); + item_free (op2); + return ok; +} + +defn (fn_div) +{ + check_stack (2); + struct item *op2 = pop (ctx); + struct item *op1 = pop (ctx); + + bool ok; + if (op1->type == ITEM_INTEGER && op2->type == ITEM_INTEGER) + { + if (get_integer (op2) == 0) + ok = set_error (ctx, "division by zero"); + else + ok = push (ctx, new_integer (get_integer (op1) / get_integer (op2))); + } + else if (op1->type == ITEM_INTEGER && op2->type == ITEM_FLOAT) + ok = push (ctx, new_float (get_integer (op1) / get_float (op2))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_FLOAT) + ok = push (ctx, new_float (get_float (op1) / get_float (op2))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_INTEGER) + ok = push (ctx, new_float (get_float (op1) / get_integer (op2))); + else + ok = set_error (ctx, "cannot divide `%s' and `%s'", + item_type_to_str (op1->type), item_type_to_str (op2->type)); + + item_free (op1); + item_free (op2); + return ok; +} + +defn (fn_mod) +{ + check_stack (2); + struct item *op2 = pop (ctx); + struct item *op1 = pop (ctx); + + bool ok; + if (op1->type == ITEM_INTEGER && op2->type == ITEM_INTEGER) + { + if (get_integer (op2) == 0) + ok = set_error (ctx, "division by zero"); + else + ok = push (ctx, new_integer (get_integer (op1) % get_integer (op2))); + } + else if (op1->type == ITEM_INTEGER && op2->type == ITEM_FLOAT) + ok = push (ctx, new_float (fmodl (get_integer (op1), get_float (op2)))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_FLOAT) + ok = push (ctx, new_float (fmodl (get_float (op1), get_float (op2)))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_INTEGER) + ok = push (ctx, new_float (fmodl (get_float (op1), get_integer (op2)))); + else + ok = set_error (ctx, "cannot divide `%s' and `%s'", + item_type_to_str (op1->type), item_type_to_str (op2->type)); + + item_free (op1); + item_free (op2); + return ok; +} + +static bool +push_concatenated_string (struct context *ctx, + struct item *op1, struct item *op2) +{ + struct item_string *s1 = (struct item_string *) op1; + struct item_string *s2 = (struct item_string *) op2; + assert (s1->type == ITEM_STRING); + assert (s2->type == ITEM_STRING); + + char *buf = NULL; + size_t len = s1->len + s2->len; + if (len < s1->len || len < s2->len) + goto allocation_fail; + + buf = malloc (len); + if (!buf) + goto allocation_fail; + + memcpy (buf, s1->value, s1->len); + memcpy (buf + s1->len, s2->value, s2->len); + struct item *item = new_string (buf, len); + free (buf); + return push (ctx, item); + +allocation_fail: + ctx->memory_failure = true; + return false; + +} + +defn (fn_plus) +{ + check_stack (2); + struct item *op2 = pop (ctx); + struct item *op1 = pop (ctx); + + bool ok; + if (op1->type == ITEM_INTEGER && op2->type == ITEM_INTEGER) + ok = push (ctx, new_integer (get_integer (op1) + get_integer (op2))); + else if (op1->type == ITEM_INTEGER && op2->type == ITEM_FLOAT) + ok = push (ctx, new_float (get_integer (op1) + get_float (op2))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_FLOAT) + ok = push (ctx, new_float (get_float (op1) + get_float (op2))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_INTEGER) + ok = push (ctx, new_float (get_float (op1) + get_integer (op2))); + else if (op1->type == ITEM_STRING && op2->type == ITEM_STRING) + ok = push_concatenated_string (ctx, op1, op2); + else + ok = set_error (ctx, "cannot add `%s' and `%s'", + item_type_to_str (op1->type), item_type_to_str (op2->type)); + + item_free (op1); + item_free (op2); + return ok; +} + +defn (fn_minus) +{ + check_stack (2); + struct item *op2 = pop (ctx); + struct item *op1 = pop (ctx); + + bool ok; + if (op1->type == ITEM_INTEGER && op2->type == ITEM_INTEGER) + ok = push (ctx, new_integer (get_integer (op1) - get_integer (op2))); + else if (op1->type == ITEM_INTEGER && op2->type == ITEM_FLOAT) + ok = push (ctx, new_float (get_integer (op1) - get_float (op2))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_FLOAT) + ok = push (ctx, new_float (get_float (op1) - get_float (op2))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_INTEGER) + ok = push (ctx, new_float (get_float (op1) - get_integer (op2))); + else + ok = set_error (ctx, "cannot subtract `%s' and `%s'", + item_type_to_str (op1->type), item_type_to_str (op2->type)); + + item_free (op1); + item_free (op2); + return ok; +} + +// - - Comparison - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +static int +compare_strings (struct item_string *s1, struct item_string *s2) +{ + // XXX: not entirely correct wrt. null bytes + size_t len = (s1->len < s2->len ? s1->len : s2->len) + 1; + return memcmp (s1->value, s2->value, len); +} + +static bool compare_lists (struct item *, struct item *); + +static bool +compare_list_items (struct item *op1, struct item *op2) +{ + if (op1->type != op2->type) + return false; + + switch (op1->type) + { + case ITEM_STRING: + case ITEM_WORD: + return !compare_strings ((struct item_string *) op1, + (struct item_string *) op2); + case ITEM_FLOAT: + return get_float (op1) == get_float (op2); + case ITEM_INTEGER: + return get_integer (op1) == get_integer (op2); + case ITEM_LIST: + return compare_lists (get_list (op1), get_list (op2)); + } + abort (); +} + +static bool +compare_lists (struct item *op1, struct item *op2) +{ + while (op1 && op2) + { + if (!compare_list_items (op1, op2)) + return false; + + op1 = op1->next; + op2 = op2->next; + } + return !op1 && !op2; +} + +defn (fn_eq) +{ + check_stack (2); + struct item *op2 = pop (ctx); + struct item *op1 = pop (ctx); + + bool ok; + if (op1->type == ITEM_INTEGER && op2->type == ITEM_INTEGER) + ok = push (ctx, new_integer (get_integer (op1) == get_integer (op2))); + else if (op1->type == ITEM_INTEGER && op2->type == ITEM_FLOAT) + ok = push (ctx, new_integer (get_integer (op1) == get_float (op2))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_FLOAT) + ok = push (ctx, new_integer (get_float (op1) == get_float (op2))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_INTEGER) + ok = push (ctx, new_integer (get_float (op1) == get_integer (op2))); + else if (op1->type == ITEM_LIST && op2->type == ITEM_LIST) + ok = push (ctx, new_integer (compare_lists + (get_list (op1), get_list (op2)))); + else if (op1->type == ITEM_STRING && op2->type == ITEM_STRING) + ok = push (ctx, new_integer (compare_strings + ((struct item_string *)(op1), (struct item_string *)(op2)) == 0)); + else + ok = set_error (ctx, "cannot compare `%s' and `%s'", + item_type_to_str (op1->type), item_type_to_str (op2->type)); + + item_free (op1); + item_free (op2); + return ok; +} + +defn (fn_lt) +{ + check_stack (2); + struct item *op2 = pop (ctx); + struct item *op1 = pop (ctx); + + bool ok; + if (op1->type == ITEM_INTEGER && op2->type == ITEM_INTEGER) + ok = push (ctx, new_integer (get_integer (op1) < get_integer (op2))); + else if (op1->type == ITEM_INTEGER && op2->type == ITEM_FLOAT) + ok = push (ctx, new_integer (get_integer (op1) < get_float (op2))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_FLOAT) + ok = push (ctx, new_integer (get_float (op1) < get_float (op2))); + else if (op1->type == ITEM_FLOAT && op2->type == ITEM_INTEGER) + ok = push (ctx, new_integer (get_float (op1) < get_integer (op2))); + else if (op1->type == ITEM_STRING && op2->type == ITEM_STRING) + ok = push (ctx, new_integer (compare_strings + ((struct item_string *)(op1), (struct item_string *)(op2)) < 0)); + else + ok = set_error (ctx, "cannot compare `%s' and `%s'", + item_type_to_str (op1->type), item_type_to_str (op2->type)); + + item_free (op1); + item_free (op2); + return ok; +} + +// - - Utilities - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +defn (fn_rand) +{ + return push (ctx, new_float ((long double) rand () + / ((long double) RAND_MAX + 1))); +} + +defn (fn_time) +{ + return push (ctx, new_integer (time (NULL))); +} + +// XXX: this is a bit too constrained; combines strftime() with gmtime() +defn (fn_strftime) +{ + check_stack (2); + struct item *format = pop (ctx); + struct item *time_ = pop (ctx); + bool success = false; + if (!check_type (ctx, time_, ITEM_INTEGER) + || !check_type (ctx, format, ITEM_STRING)) + goto fail; + + if (get_integer (time_) < 0) + { + set_error (ctx, "invalid time value"); + goto fail; + } + + char buf[128]; + time_t time__ = get_integer (time_); + struct tm tm; + gmtime_r (&time__, &tm); + buf[strftime (buf, sizeof buf, get_string (format), &tm)] = '\0'; + success = push (ctx, new_string (buf, -1)); + +fail: + item_free (time_); + item_free (format); + return success; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +static void item_list_to_str (const struct item *, struct buffer *); + +static void +string_to_str (const struct item_string *string, struct buffer *buf) +{ + buffer_append_c (buf, '"'); + for (size_t i = 0; i < string->len; i++) + { + char c = string->value[i]; + if (c == '\n') buffer_append (buf, "\\n", 2); + else if (c == '\r') buffer_append (buf, "\\r", 2); + else if (c == '\t') buffer_append (buf, "\\t", 2); + else if (!isprint (c)) + { + char tmp[8]; + snprintf (tmp, sizeof tmp, "\\x%02x", (unsigned char) c); + buffer_append (buf, tmp, strlen (tmp)); + } + else if (c == '\\') buffer_append (buf, "\\\\", 2); + else if (c == '"') buffer_append (buf, "\\\"", 2); + else buffer_append_c (buf, c); + } + buffer_append_c (buf, '"'); +} + +static void +item_to_str (const struct item *item, struct buffer *buf) +{ + switch (item->type) + { + char *x; + case ITEM_STRING: + string_to_str ((struct item_string *) item, buf); + break; + case ITEM_WORD: + { + struct item_word *word = (struct item_word *) item; + buffer_append (buf, word->value, word->len); + break; + } + case ITEM_INTEGER: + if (!(x = strdup_printf ("%lld", get_integer (item)))) + goto alloc_failure; + buffer_append (buf, x, strlen (x)); + free (x); + break; + case ITEM_FLOAT: + if (!(x = strdup_printf ("%Lf", get_float (item)))) + goto alloc_failure; + buffer_append (buf, x, strlen (x)); + free (x); + break; + case ITEM_LIST: + buffer_append_c (buf, '['); + item_list_to_str (get_list (item), buf); + buffer_append_c (buf, ']'); + break; + } + return; + +alloc_failure: + // This is a bit hackish but it simplifies stuff + buf->memory_failure = true; + free (buf->s); + buf->s = NULL; +} + +static void +item_list_to_str (const struct item *script, struct buffer *buf) +{ + if (!script) + return; + + item_to_str (script, buf); + while ((script = script->next)) + { + buffer_append_c (buf, ' '); + item_to_str (script, buf); + } +} + +// --- IRC protocol ------------------------------------------------------------ + +struct message +{ + char *prefix; ///< Message prefix + char *command; ///< IRC command + char *params[16]; ///< Command parameters (0-terminated) + size_t n_params; ///< Number of parameters present +}; + +inline static char * +cut_word (char **s) +{ + char *start = *s, *end = *s + strcspn (*s, " "); + *s = end + strspn (end, " "); + *end = '\0'; + return start; +} + +static bool +parse_message (char *s, struct message *msg) +{ + memset (msg, 0, sizeof *msg); + + // Ignore IRC 3.2 message tags, if present + if (*s == '@') + { + s += strcspn (s, " "); + s += strspn (s, " "); + } + + // Prefix + if (*s == ':') + msg->prefix = cut_word (&s) + 1; + + // Command + if (!*(msg->command = cut_word (&s))) + return false; + + // Parameters + while (*s) + { + size_t n = msg->n_params++; + if (msg->n_params >= N_ELEMENTS (msg->params)) + return false; + if (*s == ':') + { + msg->params[n] = ++s; + break; + } + msg->params[n] = cut_word (&s); + } + return true; +} + +static struct message * +read_message (void) +{ + static bool discard = false; + static char buf[1025]; + static struct message msg; + + bool discard_this; + do + { + if (!fgets (buf, sizeof buf, stdin)) + return NULL; + size_t len = strlen (buf); + + // Just to be on the safe side, if the line overflows our buffer, + // ignore everything up until the next line. + discard_this = discard; + if (len >= 2 && !strcmp (buf + len - 2, "\r\n")) + { + buf[len -= 2] = '\0'; + discard = false; + } + else + discard = true; + } + // Invalid messages are silently ignored + while (discard_this || !parse_message (buf, &msg)); + return &msg; +} + +// --- Interfacing with the bot ------------------------------------------------ + +#define BOT_PRINT "ZYKLONB print :script: " + +static const char * +get_config (const char *key) +{ + printf ("ZYKLONB get_config :%s\r\n", key); + struct message *msg = read_message (); + if (!msg || msg->n_params <= 0) + exit (EXIT_FAILURE); + return msg->params[0]; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// TODO: implement more functions; try to avoid writing them in C + +static bool +init_runtime_library_scripts (void) +{ + bool ok = true; + + // It's much cheaper (and more fun) to define functions in terms of other + // ones. The "unit tests" serve a secondary purpose of showing the usage. + struct script + { + const char *name; ///< Name of the function + const char *definition; ///< The defining script + const char *unit_test; ///< Trivial unit test, must return 1 + } + scripts[] = + { + { "nip", "swap drop", "1 2 nip 2 =" }, + { "over", "[dup] dip swap", "1 2 over nip nip 1 =" }, + { "swons", "swap cons", "[2] 1 swons [1 2] =" }, + { "first", "uncons drop", "[1 2 3] first 1 =" }, + { "rest", "uncons swap drop", "[1 2 3] rest [2 3] =" }, + { "reverse", "[] swap [swap cons] each", "[1 2] reverse [2 1] =" }, + { "curry", "cons", "1 2 [+] curry call 3 =" }, + + { "xor", "not swap not + 1 =", "1 1 xor 0 =" }, + { "min", "over over < [drop] [nip] if", "1 2 min 1 =" }, + { "max", "over over > [drop] [nip] if", "1 2 max 2 =" }, + + { "all?", "[and] cat 1 swap fold", "[3 4 5] [> 3] all? 0 =" }, + { "any?", "[or] cat 0 swap fold", "[3 4 5] [> 3] any? 1 =" }, + + { ">", "swap <", "1 2 > 0 =" }, + { "!=", "= not", "1 2 != 1 =" }, + { "<=", "> not", "1 2 <= 1 =" }, + { ">=", "< not", "1 2 >= 0 =" }, + + // XXX: this is a bit crazy and does not work with an empty list + { "join", "[uncons] dip swap [[dup] dip swap [+ +] dip] each drop", + "[1 2 3] [>string] map \" -> \" join \"1 -> 2 -> 3\" =" }, + }; + + for (size_t i = 0; i < N_ELEMENTS (scripts); i++) + { + const char *error = NULL; + struct item *script = parse (scripts[i].definition, &error); + if (error) + { + printf (BOT_PRINT "error parsing internal script `%s': %s\r\n", + scripts[i].definition, error); + ok = false; + } + else + ok &= register_script (scripts[i].name, script); + } + + struct context ctx; + for (size_t i = 0; i < N_ELEMENTS (scripts); i++) + { + const char *error = NULL; + struct item *script = parse (scripts[i].unit_test, &error); + if (error) + { + printf (BOT_PRINT "error parsing unit test for `%s': %s\r\n", + scripts[i].name, error); + ok = false; + continue; + } + context_init (&ctx); + execute (&ctx, script); + item_free_list (script); + + const char *failure = NULL; + if (ctx.memory_failure) + failure = "memory allocation failure"; + else if (ctx.error) + failure = ctx.error; + else if (ctx.stack_size != 1) + failure = "too many results on the stack"; + else if (ctx.stack->type != ITEM_INTEGER) + failure = "result is not an integer"; + else if (get_integer (ctx.stack) != 1) + failure = "wrong test result"; + if (failure) + { + printf (BOT_PRINT "error executing unit test for `%s': %s\r\n", + scripts[i].name, failure); + ok = false; + } + context_free (&ctx); + } + return ok; +} + +static bool +init_runtime_library (void) +{ + bool ok = true; + + // Type detection + ok &= register_handler ("string?", fn_is_string); + ok &= register_handler ("word?", fn_is_word); + ok &= register_handler ("integer?", fn_is_integer); + ok &= register_handler ("float?", fn_is_float); + ok &= register_handler ("list?", fn_is_list); + + // Type conversion + ok &= register_handler (">string", fn_to_string); + ok &= register_handler (">integer", fn_to_integer); + ok &= register_handler (">float", fn_to_float); + + // Miscellaneous + ok &= register_handler ("length", fn_length); + + // Basic stack manipulation + ok &= register_handler ("dup", fn_dup); + ok &= register_handler ("drop", fn_drop); + ok &= register_handler ("swap", fn_swap); + + // Calling stuff + ok &= register_handler ("call", fn_call); + ok &= register_handler ("dip", fn_dip); + + // Control flow + ok &= register_handler ("if", fn_if); + ok &= register_handler ("try", fn_try); + + // List processing + ok &= register_handler ("map", fn_map); + ok &= register_handler ("filter", fn_filter); + ok &= register_handler ("fold", fn_fold); + ok &= register_handler ("each", fn_each); + + // List manipulation + ok &= register_handler ("unit", fn_unit); + ok &= register_handler ("cons", fn_cons); + ok &= register_handler ("cat", fn_cat); + ok &= register_handler ("uncons", fn_uncons); + + // Arithmetic operations + ok &= register_handler ("+", fn_plus); + ok &= register_handler ("-", fn_minus); + ok &= register_handler ("*", fn_times); + ok &= register_handler ("^", fn_pow); + ok &= register_handler ("/", fn_div); + ok &= register_handler ("%", fn_mod); + + // Comparison + ok &= register_handler ("=", fn_eq); + ok &= register_handler ("<", fn_lt); + + // Logical operations + ok &= register_handler ("not", fn_not); + ok &= register_handler ("and", fn_and); + ok &= register_handler ("or", fn_or); + + // Utilities + ok &= register_handler ("rand", fn_rand); + ok &= register_handler ("time", fn_time); + ok &= register_handler ("strftime", fn_strftime); + + ok &= init_runtime_library_scripts (); + return ok; +} + +static void +free_runtime_library (void) +{ + struct fn *next, *iter; + for (iter = g_functions; iter; iter = next) + { + next = iter->next; + free_function (iter); + } +} + +// --- Function database ------------------------------------------------------- + +// TODO: a global variable storing the various procedures (db) +// XXX: defining procedures would ideally need some kind of an ACL + +static void +read_db (void) +{ + // TODO +} + +static void +write_db (void) +{ + // TODO +} + +// --- Main -------------------------------------------------------------------- + +static char *g_prefix; + +struct user_info +{ + char *ctx; ///< Context: channel or user + char *ctx_quote; ///< Reply quotation +}; + +defn (fn_dot) +{ + check_stack (1); + struct item *item = pop (ctx); + struct user_info *info = ctx->user_data; + + struct buffer buf = BUFFER_INITIALIZER; + item_to_str (item, &buf); + item_free (item); + buffer_append_c (&buf, '\0'); + if (buf.memory_failure) + { + ctx->memory_failure = true; + return false; + } + + if (buf.len > 255) + buf.s[255] = '\0'; + + printf ("PRIVMSG %s :%s%s\r\n", info->ctx, info->ctx_quote, buf.s); + free (buf.s); + return true; +} + +static void +process_message (struct message *msg) +{ + if (!msg->prefix + || strcasecmp (msg->command, "PRIVMSG") + || msg->n_params < 2) + return; + char *line = msg->params[1]; + + // Filter out only our commands + size_t prefix_len = strlen (g_prefix); + if (strncmp (line, g_prefix, prefix_len)) + return; + line += prefix_len; + + char *command = cut_word (&line); + if (strcasecmp (command, "script")) + return; + + // Retrieve information on how to respond back + char *msg_ctx = msg->prefix, *x; + if ((x = strchr (msg_ctx, '!'))) + *x = '\0'; + + char *msg_ctx_quote; + if (strchr ("#+&!", *msg->params[0])) + { + msg_ctx_quote = strdup_printf ("%s: ", msg_ctx); + msg_ctx = msg->params[0]; + } + else + msg_ctx_quote = strdup (""); + + if (!msg_ctx_quote) + { + printf (BOT_PRINT "%s\r\n", "memory allocation failure"); + return; + } + + struct user_info info; + info.ctx = msg_ctx; + info.ctx_quote = msg_ctx_quote; + + // Finally parse and execute the macro + const char *error = NULL; + struct item *script = parse (line, &error); + if (error) + { + printf ("PRIVMSG %s :%s%s: %s\r\n", + msg_ctx, msg_ctx_quote, "parse error", error); + goto end; + } + + struct context ctx; + context_init (&ctx); + ctx.user_data = &info; + execute (&ctx, script); + item_free_list (script); + + const char *failure = NULL; + if (ctx.memory_failure) + failure = "memory allocation failure"; + else if (ctx.error) + failure = ctx.error; + if (failure) + printf ("PRIVMSG %s :%s%s: %s\r\n", + msg_ctx, msg_ctx_quote, "runtime error", failure); + context_free (&ctx); +end: + free (msg_ctx_quote); +} + +int +main (int argc, char *argv[]) +{ + freopen (NULL, "rb", stdin); setvbuf (stdin, NULL, _IOLBF, BUFSIZ); + freopen (NULL, "wb", stdout); setvbuf (stdout, NULL, _IOLBF, BUFSIZ); + + struct rlimit limit = + { + .rlim_cur = ADDRESS_SPACE_LIMIT, + .rlim_max = ADDRESS_SPACE_LIMIT + }; + + // Lower the memory limits to something sensible to prevent abuse + (void) setrlimit (RLIMIT_AS, &limit); + + read_db (); + if (!init_runtime_library () + || !register_handler (".", fn_dot)) + printf (BOT_PRINT "%s\r\n", "runtime library initialization failed"); + + g_prefix = strdup (get_config ("prefix")); + printf ("ZYKLONB register\r\n"); + struct message *msg; + while ((msg = read_message ())) + process_message (msg); + + free_runtime_library (); + free (g_prefix); + return 0; +} + diff --git a/samples/C/filter.h b/samples/C/filter.h new file mode 100644 index 00000000..a1a13c9f --- /dev/null +++ b/samples/C/filter.h @@ -0,0 +1,45 @@ +#pragma once + +/* Copyright © 2011 Fritz Grimpen + * + * This file is part of Xelix. + * + * Xelix 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. + * + * Xelix 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 Xelix. If not, see . + */ + +#include +#include +#include + +struct console_filter { + // General callback for all actions etc. + // Preferred prototype: + // char (char c, console_info_t *info, console_driver_t *input, console_driver_t *output); + char (*callback)(char, console_info_t*, console_driver_t*, console_driver_t*); + + // Specific callbacks for read and write + // Preferred prototype: + // char (char c, console_info_t *info, console_driver_t *input); + char (*read_callback)(char, console_info_t*, console_driver_t*); + + // Preferred prototype: + // char (char c, console_info_t *info, console_driver_t *output); + char (*write_callback)(char, console_info_t*, console_driver_t*); + + // The next filter in the filter chain + struct console_filter* next; +}; + +typedef struct console_filter console_filter_t; + diff --git a/samples/C/info.h b/samples/C/info.h new file mode 100644 index 00000000..50be7b69 --- /dev/null +++ b/samples/C/info.h @@ -0,0 +1,44 @@ +#pragma once + +/* Copyright © 2011 Fritz Grimpen + * + * This file is part of Xelix. + * + * Xelix 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. + * + * Xelix 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 Xelix. If not, see . + */ + +#include +#include + +typedef struct { + uint32_t cursor_x; + uint32_t cursor_y; + + uint32_t rows; + uint32_t columns; + + uint32_t tabstop; + + console_color_t default_color; + console_color_t current_color; + + uint8_t nonblocking; + uint8_t reverse_video; + uint8_t bold; + uint8_t blink; + uint8_t underline; + uint8_t newline_mode; + uint8_t auto_echo; + uint8_t handle_backspace; +} console_info_t; diff --git a/samples/C/interface.h b/samples/C/interface.h new file mode 100644 index 00000000..2c3bfeff --- /dev/null +++ b/samples/C/interface.h @@ -0,0 +1,47 @@ +#pragma once + +/* Copyright © 2011 Fritz Grimpen + * + * This file is part of Xelix. + * + * Xelix 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. + * + * Xelix 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 Xelix. If not, see . + */ + +#include +#include +#include +#include + +typedef struct { + console_info_t info; + + console_filter_t* input_filter; + console_filter_t* output_filter; + + console_driver_t* input_driver; + console_driver_t* output_driver; +} console_t; + +console_t* default_console; + +// Generate raw console, connected to the Display, Keyboard and the +// ECMA-48-Filter +void console_init(); + +size_t console_write(console_t* console, const char* buffer, int32_t length); +#define console_write2(console, buffer) console_write(console, buffer, strlen(buffer)) +size_t console_read(console_t* console, char* buffer, size_t length); +size_t console_scroll(console_t* console, int32_t pages); + +void console_clear(console_t* console); diff --git a/samples/C/ip4.h b/samples/C/ip4.h new file mode 100644 index 00000000..b2c8a2a8 --- /dev/null +++ b/samples/C/ip4.h @@ -0,0 +1,50 @@ +#pragma once + +/* Copyright © 2011 Lukas Martini + * + * This file is part of Xelix. + * + * Xelix 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. + * + * Xelix 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 Xelix. If not, see . + */ + +#include +#include + +#define IP4_TOS_ICMP 0 + +typedef uint32_t ip4_addr_t; + +typedef struct { + unsigned int hl:4; /* both fields are 4 bits */ + unsigned int version:4; + uint8_t tos; + uint16_t len; + uint16_t id; + uint16_t off; + uint8_t ttl; + uint8_t p; + uint16_t checksum; + ip4_addr_t src; + ip4_addr_t dst; +} ip4_header_t; + +typedef struct { + uint8_t type; + uint8_t code; + uint16_t checksum; + uint16_t id; + uint16_t sequence; +} ip4_icmp_header_t; + +void ip4_receive(net_device_t* origin, net_l2proto_t proto, size_t size, void* raw); diff --git a/samples/C/multiboot.h b/samples/C/multiboot.h new file mode 100644 index 00000000..fcbc13e1 --- /dev/null +++ b/samples/C/multiboot.h @@ -0,0 +1,110 @@ +#pragma once + +/* Copyright © 2010, 2011 Lukas Martini + * + * This file is part of Xelix. + * + * Xelix 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. + * + * Xelix 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 Xelix. If not, see . + */ + +#include + +#define MULTIBOOT_KERNELMAGIC 0x2BADB002 + +#define MULTIBOOT_FLAG_MEM 0x001 +#define MULTIBOOT_FLAG_DEVICE 0x002 +#define MULTIBOOT_FLAG_CMDLINE 0x004 +#define MULTIBOOT_FLAG_MODS 0x008 +#define MULTIBOOT_FLAG_AOUT 0x010 +#define MULTIBOOT_FLAG_ELF 0x020 +#define MULTIBOOT_FLAG_MMAP 0x040 +#define MULTIBOOT_FLAG_CONFIG 0x080 +#define MULTIBOOT_FLAG_LOADER 0x100 +#define MULTIBOOT_FLAG_APM 0x200 +#define MULTIBOOT_FLAG_VBE 0x400 + +// The symbol table for a.out. +typedef struct +{ + uint32_t tabSize; + uint32_t strSize; + uint32_t addr; + uint32_t reserved; +} __attribute__((packed)) multiboot_aoutSymbolTable_t; + +// The section header table for ELF. +typedef struct +{ + uint32_t num; + uint32_t size; + uint32_t addr; + uint32_t shndx; +} __attribute__((packed)) multiboot_elfSectionHeaderTable_t; + +typedef struct +{ + uint32_t size; + uint64_t addr; + uint64_t length; + uint32_t type; +} __attribute__((packed)) multiboot_memoryMap_t; + +typedef struct +{ + uint32_t start; + uint32_t end; + char* cmdLine; + uint32_t reserved; +} __attribute__((packed)) multiboot_module_t; + +typedef struct +{ + uint32_t flags; + uint32_t memLower; + uint32_t memUpper; + uint32_t bootDevice; + char* cmdLine; + uint32_t modsCount; + multiboot_module_t* modsAddr; + + union + { + multiboot_aoutSymbolTable_t aoutSym; + multiboot_elfSectionHeaderTable_t elfSec; + } u; + + uint32_t mmapLength; + uint32_t mmapAddr; + + uint32_t drivesLength; + uint32_t drivesAddr; + + // ROM configuration table + uint32_t configTable; + + char* bootLoaderName; + uint32_t apmTable; + + // Video + uint32_t vbeControlInfo; + uint32_t vbeModeInfo; + uint16_t vbeMode; + uint16_t vbeInterfaceSeg; + uint16_t vbeInterfaceOff; + uint16_t vbeInterfaceLen; +} __attribute__((packed)) multiboot_info_t; + +multiboot_info_t* multiboot_info; + +void arch_multiboot_printInfo(); diff --git a/samples/C/ntru_encrypt.h b/samples/C/ntru_encrypt.h new file mode 100644 index 00000000..4893f6f9 --- /dev/null +++ b/samples/C/ntru_encrypt.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2014 FH Bielefeld + * + * This file is part of a FH Bielefeld project. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +/** + * @file ntru_encrypt.h + * Header for the internal API of ntru_encrypt.c. + * @brief header for encrypt.c + */ + +#ifndef PQC_ENCRYPT_H +#define PQC_ENCRYPT_H + + +#include "ntru_params.h" +#include "ntru_poly.h" +#include "ntru_string.h" + +#include +#include + + +/** + * encrypt the msg, using the math: + * e = (h ∗ r) + m (mod q) + * + * e = the encrypted poly + * + * h = the public key + * + * r = the random poly + * + * m = the message poly + * + * q = large mod + * + * @param msg_tern the message to encrypt, in ternary format + * @param pub_key the public key + * @param rnd the random poly (should have relatively small + * coefficients, but not restricted to {-1, 0, 1}) + * @param out the output poly which is in the range {0, q-1} + * (not ternary!) [out] + * @param params ntru_params the ntru context + */ +void +ntru_encrypt_poly( + const fmpz_poly_t msg_tern, + const fmpz_poly_t pub_key, + const fmpz_poly_t rnd, + fmpz_poly_t out, + const ntru_params *params); + +/** + * Encrypt a message in the form of a null-terminated char array and + * return a string. + * + * @param msg the message + * @param pub_key the public key + * @param rnd the random poly (should have relatively small + * coefficients, but not restricted to {-1, 0, 1}) + * @param params ntru_params the ntru context + * @return the newly allocated encrypted string + */ +string * +ntru_encrypt_string( + const string *msg, + const fmpz_poly_t pub_key, + const fmpz_poly_t rnd, + const ntru_params *params); + + +#endif /* PQC_ENCRYPT_H */ diff --git a/samples/C/portio.h b/samples/C/portio.h new file mode 100644 index 00000000..8a805680 --- /dev/null +++ b/samples/C/portio.h @@ -0,0 +1,43 @@ +#pragma once + +/* Copyright © 2011 Lukas Martini + * + * This file is part of Xelix. + * + * Xelix 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. + * + * Xelix 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 Xelix. If not, see . + */ + +#include +#include + +// Legacy +#define outb(args...) portio_out8(args) +#define outw(args...) portio_out16(args) +#define outl(args...) portio_out32(args) +#define outq(args...) portio_out64(args) + +#define inb(args...) portio_in8(args) +#define inw(args...) portio_in16(args) +#define inl(args...) portio_in32(args) +#define inq(args...) portio_in64(args) + +void portio_out8(uint16_t port, uint8_t value); +void portio_out16(uint16_t port, uint16_t value); +void portio_out32(uint16_t port, uint32_t value); +void portio_out64(uint16_t port, uint64_t value); + +uint8_t portio_in8(uint16_t port); +uint16_t portio_in16(uint16_t port); +uint32_t portio_in32(uint16_t port); +uint64_t portio_in64(uint16_t port); diff --git a/samples/C/pqiv.h b/samples/C/pqiv.h new file mode 100644 index 00000000..ea535125 --- /dev/null +++ b/samples/C/pqiv.h @@ -0,0 +1,166 @@ +/** + * pqiv + * + * Copyright (c) 2013-2014, Phillip Berndt + * + * 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 . + * + */ + +// This file contains the definition of files, image types and +// the plugin infrastructure. It should be included in file type +// handlers. + +#ifndef _PQIV_H_INCLUDED +#define _PQIV_H_INCLUDED + +#include +#include +#include +#include "lib/bostree.h" + +#ifndef PQIV_VERSION +#define PQIV_VERSION "2.3" +#endif + +#define FILE_FLAGS_ANIMATION (guint)(1) +#define FILE_FLAGS_MEMORY_IMAGE (guint)(1<<1) + +// The structure for images {{{ +typedef struct file_type_handler_struct_t file_type_handler_t; +typedef struct { + // File type + const file_type_handler_t *file_type; + + // Special flags + // FILE_FLAGS_ANIMATION -> Animation functions are invoked + // Set by file type handlers + // FILE_FLAGS_MEMORY_IMAGE -> File lives in memory + guint file_flags; + + // The file name to display and to sort by + gchar *display_name; + + // The URI or file name of the file + gchar *file_name; + + // If the file is a memory image, the actual image data + GBytes *file_data; + + // The file monitor structure is used for inotify-watching of + // the files + GFileMonitor *file_monitor; + + // This flag stores whether this image is currently loaded + // and valid. i.e. if it is set, you can assume that + // private_data contains a representation of the image; + // if not, you can NOT assume that it does not. + gboolean is_loaded; + + // Cached image size + guint width; + guint height; + + // File-type specific data, allocated and freed by the file type handlers + void *private; +} file_t; +// }}} +// Definition of the built-in file types {{{ + +// If you want to implement your own file type, you'll have to implement the +// following functions and a non-static initialization function named +// file_type_NAME_initializer that fills a file_type_handler_t with pointers to +// the functions. Store the file in backends/NAME.c and adjust the Makefile to +// add the required libraries if your backend is listed in the $(BACKENDS) +// variable. + +typedef enum { PARAMETER, RECURSION, INOTIFY, BROWSE_ORIGINAL_PARAMETER, FILTER_OUTPUT } load_images_state_t; +// Allocation function: Allocate the ->private structure within a file and add the +// image(s) to the list of available images via load_images_handle_parameter_add_file() +// If an image is not to be loaded for any reason, the file structure should be +// deallocated using file_free() +// Returns a pointer to the first added image +// Optional, you can also set the pointer to this function to NULL. +typedef BOSNode *(*file_type_alloc_fn_t)(load_images_state_t state, file_t *file); + +// Deallocation, if a file is removed from the images list. Free the ->private structure. +// Only called if ->private is non-NULL. +typedef void (*file_type_free_fn_t)(file_t *file); + +// Actually load a file into memory +typedef void (*file_type_load_fn_t)(file_t *file, GInputStream *data, GError **error_pointer); + +// Unload a file +typedef void (*file_type_unload_fn_t)(file_t *file); + +// Animation support: Initialize memory for animations, return ms until first frame +// Optional, you can also set the pointer to this function to NULL. +typedef double (*file_type_animation_initialize_fn_t)(file_t *file); + +// Animation support: Advance to the next frame, return ms until next frame +// Optional, you can also set the pointer to this function to NULL. +typedef double (*file_type_animation_next_frame_fn_t)(file_t *file); + +// Draw the current view to a cairo context +typedef void (*file_type_draw_fn_t)(file_t *file, cairo_t *cr); + +struct file_type_handler_struct_t { + // All files will be filtered with this filter. If it lets it pass, + // a handler is assigned to a file. If none do, the file is + // discarded if it was found during directory traversal or + // loaded using the first image backend if it was an explicit + // parameter. + GtkFileFilter *file_types_handled; + + // Pointers to the functions defined above + file_type_alloc_fn_t alloc_fn; + file_type_free_fn_t free_fn; + file_type_load_fn_t load_fn; + file_type_unload_fn_t unload_fn; + file_type_animation_initialize_fn_t animation_initialize_fn; + file_type_animation_next_frame_fn_t animation_next_frame_fn; + file_type_draw_fn_t draw_fn; +}; + +// Initialization function: Tell pqiv about a backend +typedef void (*file_type_initializer_fn_t)(file_type_handler_t *info); + +// pqiv symbols available to plugins {{{ + +// Global cancellable that should be used for every i/o operation +extern GCancellable *image_loader_cancellable; + +// Current scale level. For backends that don't support cairo natively. +extern gdouble current_scale_level; + +// Load a file from disc/memory/network +GInputStream *image_loader_stream_file(file_t *file, GError **error_pointer); + +// Add a file to the list of loaded files +// Should be called at least once in a file_type_alloc_fn_t, with the state being +// forwarded unaltered. +BOSNode *load_images_handle_parameter_add_file(load_images_state_t state, file_t *file); + +// Load all data from an input stream into memory, conveinience function +GBytes *g_input_stream_read_completely(GInputStream *input_stream, GCancellable *cancellable, GError **error_pointer); + +// Free a file +void file_free(file_t *file); + +// }}} + +// File type handlers, used in the initializer and file type guessing +extern file_type_handler_t file_type_handlers[]; + +/* }}} */ + +#endif diff --git a/samples/C/scheduler.h b/samples/C/scheduler.h new file mode 100644 index 00000000..a886003c --- /dev/null +++ b/samples/C/scheduler.h @@ -0,0 +1,69 @@ +#pragma once + +/* Copyright © 2011 Lukas Martini + * + * This file is part of Xelix. + * + * Xelix 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. + * + * Xelix 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 Xelix. If not, see . + */ + +#include +#include +#include + +#define SCHEDULER_MAXNAME 256 +#define SCHEDULER_TASK_PATH_MAX 256 + +// Single linked list +typedef struct task { + uint32_t pid; + char name[SCHEDULER_MAXNAME]; + struct task *parent; + cpu_state_t* state; + struct task* next; + struct task* previous; + + void* stack; + void* entry; + struct vmem_context *memory_context; + + // Current task state + enum { + TASK_STATE_KILLED, + TASK_STATE_TERMINATED, + TASK_STATE_BLOCKING, + TASK_STATE_STOPPED, + TASK_STATE_RUNNING + } task_state; + + char** environ; + char** argv; + int argc; + + // TODO Is this actually the same as PATH_MAX in our toolchain? + char cwd[SCHEDULER_TASK_PATH_MAX + 1]; +} task_t; + +int scheduler_state; + +task_t* scheduler_new(void* entry, task_t* parent, char name[SCHEDULER_MAXNAME], + char** environ, char** argv, int argc, struct vmem_context* memory_context, bool map_structs); +void scheduler_add(task_t *task); +void scheduler_terminate_current(); +task_t* scheduler_get_current(); +task_t* scheduler_select(cpu_state_t* lastRegs); +void scheduler_init(); +void scheduler_yield(); +void scheduler_remove(task_t *t); +task_t* scheduler_fork(task_t* to_fork, cpu_state_t* state); \ No newline at end of file diff --git a/samples/C/syscalls.h b/samples/C/syscalls.h new file mode 100644 index 00000000..dc054e2b --- /dev/null +++ b/samples/C/syscalls.h @@ -0,0 +1,95 @@ +#pragma once + +/* Copyright © 2011 Fritz Grimpen + * + * This file is part of Xelix. + * + * Xelix 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. + * + * Xelix 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 Xelix. If not, see . + */ + +#include +#include + +#include "syscalls/write.h" +#include "syscalls/exit.h" +#include "syscalls/getpid.h" +#include "syscalls/getppid.h" +#include "syscalls/read.h" +#include "syscalls/brk.h" +#include "syscalls/mmap.h" +#include "syscalls/munmap.h" +#include "syscalls/test.h" +#include "syscalls/hostname.h" +#include "syscalls/uname.h" +#include "syscalls/open.h" +#include "syscalls/execve.h" +#include "syscalls/seek.h" +#include "syscalls/opendir.h" +#include "syscalls/readdir.h" +#include "syscalls/kill.h" +#include "syscalls/getexecdata.h" +#include "syscalls/cwd.h" +#include "syscalls/fork.h" + +syscall_t syscall_table[] = { + NULL, + sys_exit, // 1 + sys_read, // 2 + sys_write, // 3 + sys_getpid, // 4 + sys_brk, // 5 + sys_getppid, // 6 + sys_mmap, // 7 + sys_munmap, // 8 + sys_test, // 9 + sys_get_hostname, // 10 + sys_set_hostname, // 11 + sys_uname, // 12 + sys_open, // 13 + sys_execve, // 14 + sys_seek, // 15 + sys_opendir, // 16 + sys_readdir, // 17 + sys_kill, // 18 + sys_getexecdata, // 19 + sys_chdir, // 20 + sys_getcwd, // 21 + sys_fork, // 22 +}; + +char* syscall_name_table[] = { + NULL, + "exit", // 1 + "read", // 2 + "write", // 3 + "getpid", // 4 + "brk", // 5 + "getppid", // 6 + "mmap", // 7 + "munmap", // 8 + "test", // 9 + "get_hostname", // 10 + "set_hostname", // 11 + "uname", // 12 + "open", // 13 + "execve", // 14 + "seek", // 15 + "opendir", // 16 + "readdir", // 17 + "kill", // 18 + "getexecdata", // 19 + "chdir", // 20 + "getcwd", // 21 + "fork", // 22 +}; diff --git a/samples/C/vfs.h b/samples/C/vfs.h new file mode 100644 index 00000000..3502460d --- /dev/null +++ b/samples/C/vfs.h @@ -0,0 +1,56 @@ +#pragma once + +/* Copyright © 2010, 2011 Lukas Martini + * + * This file is part of Xelix. + * + * Xelix 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. + * + * Xelix 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 Xelix. If not, see . + */ + +#include + +#define VFS_SEEK_SET 0 +#define VFS_SEEK_CUR 1 +#define VFS_SEEK_END 2 + +typedef struct { + uint64_t num; + char path[512]; + char mount_path[512]; + uint32_t offset; + uint32_t mountpoint; +} vfs_file_t; + +typedef struct { + uint64_t num; + char path[512]; + char mount_path[512]; + uint32_t mountpoint; +} vfs_dir_t; + +typedef void* (*vfs_read_callback_t)(char* path, uint32_t offset, uint32_t size); +typedef char* (*vfs_read_dir_callback_t)(char* path, uint32_t offset); + + +// Used to always store the last read/write attempt (used for kernel panic debugging) +char vfs_last_read_attempt[512]; + +vfs_file_t* vfs_get_from_id(uint32_t id); +vfs_dir_t* vfs_get_dir_from_id(uint32_t id); +void* vfs_read(vfs_file_t* fp, uint32_t size); +char* vfs_dir_read(vfs_dir_t* dir, uint32_t offset); +void vfs_seek(vfs_file_t* fp, uint32_t offset, int origin); +vfs_file_t* vfs_open(char* path); +vfs_dir_t* vfs_dir_open(char* path); +int vfs_mount(char* path, vfs_read_callback_t read_callback, vfs_read_dir_callback_t read_dir_callback); diff --git a/samples/C/vmem.h b/samples/C/vmem.h new file mode 100644 index 00000000..82bd29be --- /dev/null +++ b/samples/C/vmem.h @@ -0,0 +1,94 @@ +#pragma once + +/* Copyright © 2011 Fritz Grimpen + * Copyright © 2013 Lukas Martini + * + * This file is part of Xelix. + * + * Xelix 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. + * + * Xelix 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 Xelix. If not, see . + */ + +#include + +struct vmem_context; + +struct vmem_page +{ + enum + { + VMEM_SECTION_STACK, /* Initial stack */ + VMEM_SECTION_CODE, /* Contains program code and is read-only */ + VMEM_SECTION_DATA, /* Contains static data */ + VMEM_SECTION_HEAP, /* Allocated by brk(2) at runtime */ + VMEM_SECTION_MMAP, /* Allocated by mmap(2) at runtime */ + VMEM_SECTION_KERNEL, /* Contains kernel-internal data */ + VMEM_SECTION_UNMAPPED /* Unmapped */ + } section; + + bool readonly:1; + bool cow:1; /* Copy-on-Write mechanism */ + bool allocated:1; + + void *cow_src_addr; + void *virt_addr; + void *phys_addr; +}; + +typedef void (*vmem_iterator_t)(struct vmem_context *, struct vmem_page *, uint32_t); + +/* Initialize vmem_kernelContext for paging_init() */ +void vmem_init(); +struct vmem_context *vmem_kernelContext; +struct vmem_context *vmem_currentContext; +struct vmem_context *vmem_processContext; +void *vmem_faultAddress; + +/* Some callbacks for magic functions */ +void (*vmem_applyPage)(struct vmem_context *, struct vmem_page *); + +/* Generate new page context */ +struct vmem_context *vmem_new(); +struct vmem_page *vmem_new_page(); + +int vmem_add_page(struct vmem_context *ctx, struct vmem_page *pg); + +struct vmem_page *vmem_get_page_phys(struct vmem_context *ctx, void *phys_addr); +struct vmem_page *vmem_get_page_virt(struct vmem_context *ctx, void *virt_addr); +struct vmem_page *vmem_get_page(struct vmem_context *ctx, uint32_t offset); + +/* Remove pages in a specific context by physical or virtual address */ +struct vmem_page *vmem_rm_page_phys(struct vmem_context *ctx, void *phys_addr); +struct vmem_page *vmem_rm_page_virt(struct vmem_context *ctx, void *virt_addr); + +/* Iterator */ +int vmem_iterate(struct vmem_context *ctx, vmem_iterator_t callback); + +uint32_t vmem_count_pages(struct vmem_context *ctx); +void vmem_dump_page(struct vmem_page *pg); +void vmem_dump(struct vmem_context *ctx); +void vmem_handle_fault(uint32_t code, void *addr, void *instruction); + +/* Get/Set cached paging context */ +void vmem_set_cache(struct vmem_context *ctx, void *cache); +void *vmem_get_cache(struct vmem_context *ctx); + +#ifdef __i386__ + #define PAGE_SIZE 4096 + #define VMEM_ALIGN(x) (typeof(x))(((intptr_t)(x) & 0xFFFFF000) + 0x1000) + #define VMEM_ALIGN_DOWN(x) (typeof(x))( \ + ((intptr_t)(x) - ((intptr_t)(x) % PAGE_SIZE))) +#else + #define PAGE_SIZE 0 + #define VMEM_ALIGN(x) (x) +#endif diff --git a/samples/CLIPS/demo.clp b/samples/CLIPS/demo.clp new file mode 100644 index 00000000..45cb4828 --- /dev/null +++ b/samples/CLIPS/demo.clp @@ -0,0 +1,343 @@ +;;;*************************** +;;;* DEFFACTS KNOWLEDGE BASE * +;;;*************************** + +(deffacts MAIN::knowledge-base + (welcome (message WelcomeMessage)) + (goal (variable type.animal)) + (legalanswers (values yes no)) + (displayanswers (values "Yes" "No")) + (rule (if backbone is yes) + (then superphylum is backbone)) + (rule (if backbone is no) + (then superphylum is jellyback)) + (question (variable backbone) + (query backbone.query)) + (rule (if superphylum is backbone and + warm.blooded is yes) + (then phylum is warm)) + (rule (if superphylum is backbone and + warm.blooded is no) + (then phylum is cold)) + (question (variable warm.blooded) + (query warm.blooded.query)) + (rule (if superphylum is jellyback and + live.prime.in.soil is yes) + (then phylum is soil)) + (rule (if superphylum is jellyback and + live.prime.in.soil is no) + (then phylum is elsewhere)) + (question (variable live.prime.in.soil) + (query live.prime.in.soil.query)) + (rule (if phylum is warm and + has.breasts is yes) + (then class is breasts)) + (rule (if phylum is warm and + has.breasts is no) + (then type.animal is bird)) + (question (variable has.breasts) + (query has.breasts.query)) + (rule (if phylum is cold and + always.in.water is yes) + (then class is water)) + (rule (if phylum is cold and + always.in.water is no) + (then class is dry)) + (question (variable always.in.water) + (query always.in.water.query)) + (rule (if phylum is soil and + flat.bodied is yes) + (then type.animal is flatworm)) + (rule (if phylum is soil and + flat.bodied is no) + (then type.animal is worm.leech)) + (question (variable flat.bodied) + (query flat.bodied.query)) + (rule (if phylum is elsewhere and + body.in.segments is yes) + (then class is segments)) + (rule (if phylum is elsewhere and + body.in.segments is no) + (then class is unified)) + (question (variable body.in.segments) + (query body.in.segments.query)) + (rule (if class is breasts and + can.eat.meat is yes) + (then order is meat)) + (rule (if class is breasts and + can.eat.meat is no) + (then order is vegy)) + (question (variable can.eat.meat) + (query can.eat.meat.query)) + (rule (if class is water and + boney is yes) + (then type.animal is fish)) + (rule (if class is water and + boney is no) + (then type.animal is shark.ray)) + (question (variable boney) + (query boney.query)) + (rule (if class is dry and + scaly is yes) + (then order is scales)) + (rule (if class is dry and + scaly is no) + (then order is soft)) + (question (variable scaly) + (query scaly.query)) + (rule (if class is segments and + shell is yes) + (then order is shell)) + (rule (if class is segments and + shell is no) + (then type.animal is centipede.millipede.insect)) + (question (variable shell) + (query shell.query)) + (rule (if class is unified and + digest.cells is yes) + (then order is cells)) + (rule (if class is unified and + digest.cells is no) + (then order is stomach)) + (question (variable digest.cells) + (query digest.cells.query)) + (rule (if order is meat and + fly is yes) + (then type.animal is bat)) + (rule (if order is meat and + fly is no) + (then family is nowings)) + (question (variable fly) + (query fly.query)) + (rule (if order is vegy and + hooves is yes) + (then family is hooves)) + (rule (if order is vegy and + hooves is no) + (then family is feet)) + (question (variable hooves) + (query hooves.query)) + (rule (if order is scales and + rounded.shell is yes) + (then type.animal is turtle)) + (rule (if order is scales and + rounded.shell is no) + (then family is noshell)) + (question (variable rounded.shell) + (query rounded.shell.query)) + (rule (if order is soft and + jump is yes) + (then type.animal is frog)) + (rule (if order is soft and + jump is no) + (then type.animal is salamander)) + (question (variable jump) + (query jump.query)) + (rule (if order is shell and + tail is yes) + (then type.animal is lobster)) + (rule (if order is shell and + tail is no) + (then type.animal is crab)) + (question (variable tail) + (query tail.query)) + (rule (if order is cells and + stationary is yes) + (then family is stationary)) + (rule (if order is cells and + stationary is no) + (then type.animal is jellyfish)) + (question (variable stationary) + (query stationary.query)) + (rule (if order is stomach and + multicelled is yes) + (then family is multicelled)) + (rule (if order is stomach and + multicelled is no) + (then type.animal is protozoa)) + (question (variable multicelled) + (query multicelled.query)) + (rule (if family is nowings and + opposing.thumb is yes) + (then genus is thumb)) + (rule (if family is nowings and + opposing.thumb is no) + (then genus is nothumb)) + (question (variable opposing.thumb) + (query opposing.thumb.query)) + (rule (if family is hooves and + two.toes is yes) + (then genus is twotoes)) + (rule (if family is hooves and + two.toes is no) + (then genus is onetoe)) + (question (variable two.toes) + (query two.toes.query)) + (rule (if family is feet and + live.in.water is yes) + (then genus is water)) + (rule (if family is feet and + live.in.water is no) + (then genus is dry)) + (question (variable live.in.water) + (query live.in.water.query)) + (rule (if family is noshell and + limbs is yes) + (then type.animal is crocodile.alligator)) + (rule (if family is noshell and + limbs is no) + (then type.animal is snake)) + (question (variable limbs) + (query limbs.query)) + (rule (if family is stationary and + spikes is yes) + (then type.animal is sea.anemone)) + (rule (if family is stationary and + spikes is no) + (then type.animal is coral.sponge)) + (question (variable spikes) + (query spikes.query)) + (rule (if family is multicelled and + spiral.shell is yes) + (then type.animal is snail)) + (rule (if family is multicelled and + spiral.shell is no) + (then genus is noshell)) + (question (variable spiral.shell) + (query spiral.shell.query)) + (rule (if genus is thumb and + prehensile.tail is yes) + (then type.animal is monkey)) + (rule (if genus is thumb and + prehensile.tail is no) + (then species is notail)) + (question (variable prehensile.tail) + (query prehensile.tail.query)) + (rule (if genus is nothumb and + over.400 is yes) + (then species is 400)) + (rule (if genus is nothumb and + over.400 is no) + (then species is under400)) + (question (variable over.400) + (query over.400.query)) + (rule (if genus is twotoes and + horns is yes) + (then species is horns)) + (rule (if genus is twotoes and + horns is no) + (then species is nohorns)) + (question (variable horns) + (query horns.query)) + (rule (if genus is onetoe and + plating is yes) + (then type.animal is rhinoceros)) + (rule (if genus is onetoe and + plating is no) + (then type.animal is horse.zebra)) + (question (variable plating) + (query plating.query)) + (rule (if genus is water and + hunted is yes) + (then type.animal is whale)) + (rule (if genus is water and + hunted is no) + (then type.animal is dolphin.porpoise)) + (question (variable hunted) + (query hunted.query)) + (rule (if genus is dry and + front.teeth is yes) + (then species is teeth)) + (rule (if genus is dry and + front.teeth is no) + (then species is noteeth)) + (question (variable front.teeth) + (query front.teeth.query)) + (rule (if genus is noshell and + bivalve is yes) + (then type.animal is clam.oyster)) + (rule (if genus is noshell and + bivalve is no) + (then type.animal is squid.octopus)) + (question (variable bivalve) + (query bivalve.query)) + (rule (if species is notail and + nearly.hairless is yes) + (then type.animal is man)) + (rule (if species is notail and + nearly.hairless is no) + (then subspecies is hair)) + (question (variable nearly.hairless) + (query nearly.hairless.query)) + (rule (if species is 400 and + land.based is yes) + (then type.animal is bear.tiger.lion)) + (rule (if species is 400 and + land.based is no) + (then type.animal is walrus)) + (question (variable land.based) + (query land.based.query)) + (rule (if species is under400 and + thintail is yes) + (then type.animal is cat)) + (rule (if species is under400 and + thintail is no) + (then type.animal is coyote.wolf.fox.dog)) + (question (variable thintail) + (query thintail.query)) + (rule (if species is nohorns and + lives.in.desert is yes) + (then type.animal is camel)) + (rule (if species is nohorns and + lives.in.desert is no and + semi.aquatic is no) + (then type.animal is giraffe)) + (rule (if species is nohorns and + lives.in.desert is no and + semi.aquatic is yes) + (then type.animal is hippopotamus)) + (question (variable lives.in.desert) + (query lives.in.desert.query)) + (question (variable semi.aquatic) + (query semi.aquatic.query)) + (rule (if species is teeth and + large.ears is yes) + (then type.animal is rabbit)) + (rule (if species is teeth and + large.ears is no) + (then type.animal is rat.mouse.squirrel.beaver.porcupine)) + (question (variable large.ears) + (query large.ears.query)) + (rule (if species is noteeth and + pouch is yes) + (then type.animal is kangaroo.koala.bear)) + (rule (if species is noteeth and + pouch is no) + (then type.animal is mole.shrew.elephant)) + (question (variable pouch) + (query pouch.query)) + (rule (if subspecies is hair and + long.powerful.arms is yes) + (then type.animal is orangutan.gorilla.chimpanzee)) + (rule (if subspecies is hair and + long.powerful.arms is no) + (then type.animal is baboon)) + (question (variable long.powerful.arms) + (query long.powerful.arms.query)) + (rule (if species is horns and + fleece is yes) + (then type.animal is sheep.goat)) + (rule (if species is horns and + fleece is no) + (then subsubspecies is nofleece)) + (question (variable fleece) + (query fleece.query)) + (rule (if subsubspecies is nofleece and + domesticated is yes) + (then type.animal is cow)) + (rule (if subsubspecies is nofleece and + domesticated is no) + (then type.animal is deer.moose.antelope)) + (question (variable domesticated) + (query domesticated.query)) + (answer (prefix "I think your animal is a ") (variable type.animal) (postfix "."))) diff --git a/samples/CLIPS/sudoku.clp b/samples/CLIPS/sudoku.clp new file mode 100644 index 00000000..cbdbb92d --- /dev/null +++ b/samples/CLIPS/sudoku.clp @@ -0,0 +1,281 @@ +;;; http://www.angusj.com/sudoku/hints +;;; http://www.scanraid.com/BasicStrategies.htm +;;; http://www.sudokuoftheday.com/pages/techniques-overview +;;; http://www.sudokuonline.us/sudoku_solving_techniques +;;; http://www.sadmansoftware.com/sudoku/techniques.htm +;;; http://www.krazydad.com/blog/2005/09/29/an-index-of-sudoku-strategies/ + +;;; ####################### +;;; DEFTEMPLATES & DEFFACTS +;;; ####################### + +(deftemplate possible + (slot row) + (slot column) + (slot value) + (slot group) + (slot id)) + +(deftemplate impossible + (slot id) + (slot value) + (slot priority) + (slot reason)) + +(deftemplate technique-employed + (slot reason) + (slot priority)) + +(deftemplate technique + (slot name) + (slot priority)) + +(deffacts startup + (phase grid-values)) + +(deftemplate size-value + (slot size) + (slot value)) + +(deffacts values + (size-value (size 1) (value 1)) + (size-value (size 2) (value 2)) + (size-value (size 2) (value 3)) + (size-value (size 2) (value 4)) + (size-value (size 3) (value 5)) + (size-value (size 3) (value 6)) + (size-value (size 3) (value 7)) + (size-value (size 3) (value 8)) + (size-value (size 3) (value 9)) + (size-value (size 4) (value 10)) + (size-value (size 4) (value 11)) + (size-value (size 4) (value 12)) + (size-value (size 4) (value 13)) + (size-value (size 4) (value 14)) + (size-value (size 4) (value 15)) + (size-value (size 4) (value 16)) + (size-value (size 5) (value 17)) + (size-value (size 5) (value 18)) + (size-value (size 5) (value 19)) + (size-value (size 5) (value 20)) + (size-value (size 5) (value 21)) + (size-value (size 5) (value 22)) + (size-value (size 5) (value 23)) + (size-value (size 5) (value 24)) + (size-value (size 5) (value 25))) + +;;; ########### +;;; SETUP RULES +;;; ########### + +;;; *********** +;;; stress-test +;;; *********** + +(defrule stress-test + + (declare (salience 10)) + + (phase match) + + (stress-test) + + (priority ?last) + + (not (priority ?p&:(> ?p ?last))) + + (technique (priority ?next&:(> ?next ?last))) + + (not (technique (priority ?p&:(> ?p ?last)&:(< ?p ?next)))) + + => + + (assert (priority ?next))) + +;;; ***************** +;;; enable-techniques +;;; ***************** + +(defrule enable-techniques + + (declare (salience 10)) + + (phase match) + + (size ?) + + (not (possible (value any))) + + => + + (assert (priority 1))) + +;;; ********** +;;; expand-any +;;; ********** + +(defrule expand-any + + (declare (salience 10)) + + (phase expand-any) + + ?f <- (possible (row ?r) (column ?c) (value any) (group ?g) (id ?id)) + + (not (possible (value any) (id ?id2&:(< ?id2 ?id)))) + + (size ?s) + + (size-value (size ?as&:(<= ?as ?s)) (value ?v)) + + (not (possible (row ?r) (column ?c) (value ?v))) + + (not (and (size-value (value ?v2&:(< ?v2 ?v))) + + (not (possible (row ?r) (column ?c) (value ?v2))))) + + => + + (assert (possible (row ?r) (column ?c) (value ?v) (group ?g) (id ?id)))) + +;;; ***************** +;;; position-expanded +;;; ***************** + +(defrule position-expanded + + (declare (salience 10)) + + (phase expand-any) + + ?f <- (possible (row ?r) (column ?c) (value any) (group ?g) (id ?id)) + + (size ?s) + + (not (and (size-value (size ?as&:(<= ?as ?s)) (value ?v)) + + (not (possible (row ?r) (column ?c) (value ?v))))) + + => + + (retract ?f)) + +;;; ########### +;;; PHASE RULES +;;; ########### + +;;; *************** +;;; expand-any-done +;;; *************** + +(defrule expand-any-done + + (declare (salience 10)) + + ?f <- (phase expand-any) + + (not (possible (value any))) + + => + + (retract ?f) + + (assert (phase initial-output)) + (assert (print-position 1 1))) + +;;; *********** +;;; begin-match +;;; *********** + +(defrule begin-match + + (declare (salience -20)) + + ?f <- (phase initial-output) + + => + + (retract ?f) + + (assert (phase match))) + +;;; ***************** +;;; begin-elimination +;;; ***************** + +(defrule begin-elimination + + (declare (salience -20)) + + ?f <- (phase match) + + (not (not (impossible))) + + => + + (retract ?f) + + (assert (phase elimination))) + +;;; ************* +;;; next-priority +;;; ************* + +(defrule next-priority + + (declare (salience -20)) + + (phase match) + + (not (impossible)) + + (priority ?last) + + (not (priority ?p&:(> ?p ?last))) + + (technique (priority ?next&:(> ?next ?last))) + + (not (technique (priority ?p&:(> ?p ?last)&:(< ?p ?next)))) + + => + + (assert (priority ?next))) + +;;; ************ +;;; begin-output +;;; ************ + +(defrule begin-output + + (declare (salience -20)) + + ?f <- (phase match) + + (not (impossible)) + + (priority ?last) + + (not (priority ?p&:(> ?p ?last))) + + (not (technique (priority ?next&:(> ?next ?last)))) + + => + + (retract ?f) + + (assert (phase final-output)) + (assert (print-position 1 1))) + + + + + + + + + + + + + + diff --git a/samples/CMake/filenames/CMakeLists.txt b/samples/CMake/filenames/CMakeLists.txt new file mode 100644 index 00000000..27f3b3a7 --- /dev/null +++ b/samples/CMake/filenames/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 2.8) + +project(Foo) + +set(CMAKE_SKIP_RPATH TRUE) +set(CMAKE_INSTALL_PREFIX "/usr/local") + +add_subdirectory(bar) + +add_executable(foo foo.c) +target_link_libraries(foo pthread) +install(TARGETS foo DESTINATION bin) diff --git a/samples/CMake/sample1.cmake b/samples/CMake/sample1.cmake new file mode 100644 index 00000000..c4b23485 --- /dev/null +++ b/samples/CMake/sample1.cmake @@ -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}) diff --git a/samples/CMake/sample2.cmake b/samples/CMake/sample2.cmake new file mode 100644 index 00000000..7411b5d6 --- /dev/null +++ b/samples/CMake/sample2.cmake @@ -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}) \ No newline at end of file diff --git a/samples/CMake/sample3.cmake b/samples/CMake/sample3.cmake new file mode 100644 index 00000000..7bd9ea77 --- /dev/null +++ b/samples/CMake/sample3.cmake @@ -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 +) + diff --git a/samples/CMake/sample4.cmake b/samples/CMake/sample4.cmake new file mode 100644 index 00000000..e3c123a0 --- /dev/null +++ b/samples/CMake/sample4.cmake @@ -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}) diff --git a/samples/CMake/sample5.cmake b/samples/CMake/sample5.cmake new file mode 100644 index 00000000..f87136e7 --- /dev/null +++ b/samples/CMake/sample5.cmake @@ -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) diff --git a/samples/CMake/uninstall.cmake.in b/samples/CMake/uninstall.cmake.in new file mode 100644 index 00000000..a5b7436f --- /dev/null +++ b/samples/CMake/uninstall.cmake.in @@ -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) + diff --git a/samples/CartoCSS/amenity-points.mss b/samples/CartoCSS/amenity-points.mss new file mode 100644 index 00000000..a7b94ea0 --- /dev/null +++ b/samples/CartoCSS/amenity-points.mss @@ -0,0 +1,1879 @@ +@marina-text: #576ddf; // also swimming_pool +@wetland-text: darken(#017fff, 10%); /* Also for marsh */ +@mud-text: darken(#aea397, 20%); +@shop-icon: #ac39ac; +@transportation-icon: #0092da; +@transportation-text: #0066ff; +@airtransport: #8461C4; + +@landcover-font-size: 10; +@landcover-font-size-big: 12; +@landcover-font-size-bigger: 15; +@landcover-wrap-width-size: 25; +@landcover-wrap-width-size-big: 35; +@landcover-wrap-width-size-bigger: 45; +@landcover-face-name: @oblique-fonts; + +@standard-wrap-width: 30; + +.points { + [feature = 'tourism_alpine_hut'][zoom >= 13] { + point-file: url('symbols/alpinehut.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_shelter'][zoom >= 16] { + point-file: url('symbols/shelter2.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_atm'][zoom >= 17] { + point-file: url('symbols/atm2.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_bank'][zoom >= 17] { + point-file: url('symbols/bank2.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_bar'][zoom >= 17] { + point-file: url('symbols/bar.p.20.png'); + point-placement: interior; + } + + [feature = 'amenity_bicycle_rental'][zoom >= 17] { + point-file: url('symbols/rental_bicycle.p.20.png'); + point-placement: interior; + } + + [feature = 'highway_bus_stop'] { + [zoom >= 16] { + marker-file: url('symbols/square.svg'); + marker-fill: @transportation-icon; + marker-placement: interior; + marker-width: 6; + } + [zoom >= 17] { + marker-file: url('symbols/bus_stop.p.12.png'); + marker-width: 12; + } + } + + [feature = 'amenity_bus_station'][zoom >= 16] { + point-file: url('symbols/bus_station.n.16.png'); + point-placement: interior; + } + + [feature = 'highway_traffic_signals'][zoom >= 17] { + marker-file: url('symbols/traffic_light.svg'); + marker-fill: #0a0a0a; + marker-placement: interior; + } + + [feature = 'amenity_cafe'][zoom >= 17] { + point-file: url('symbols/cafe.p.16.png'); + point-placement: interior; + } + + [feature = 'tourism_camp_site'][zoom >= 16] { + point-file: url('symbols/camping.n.16.png'); + point-placement: interior; + } + + [feature = 'highway_ford'][zoom >= 16] { + point-file: url('symbols/transport_ford.p.16.png'); + point-placement: interior; + } + + [feature = 'tourism_caravan_site'][zoom >= 16] { + point-file: url('symbols/caravan_park.p.24.png'); + point-placement: interior; + } + + [feature = 'amenity_car_sharing'][zoom >= 16] { + point-file: url('symbols/car_share.p.16.png'); + point-placement: interior; + } + + [feature = 'tourism_chalet'][zoom >= 17] { + point-file: url('symbols/chalet.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_cinema'][zoom >= 16] { + point-file: url('symbols/cinema.p.24.png'); + point-placement: interior; + } + + [feature = 'amenity_fire_station'][zoom >= 16] { + point-file: url('symbols/firestation.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_fuel'][zoom >= 17] { + point-file: url('symbols/fuel.p.16.png'); + point-placement: interior; + } + + [feature = 'tourism_guest_house'][zoom >= 17] { + point-file: url('symbols/guest_house.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_hospital'][zoom >= 15] { + point-file: url('symbols/hospital.p.16.png'); + point-placement: interior; + } + + [feature = 'tourism_hostel'][zoom >= 17] { + point-file: url('symbols/hostel.p.20.png'); + point-placement: interior; + } + + [feature = 'tourism_hotel'][zoom >= 17] { + point-file: url('symbols/hotel2.p.20.png'); + point-placement: interior; + } + + [feature = 'tourism_motel'][zoom >= 17] { + point-file: url('symbols/motel.p.20.png'); + point-placement: interior; + } + + [feature = 'tourism_information'][zoom >= 17] { + point-file: url('symbols/information.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_embassy'][zoom >= 17] { + point-file: url('symbols/embassy.png'); + point-placement: interior; + } + + [feature = 'amenity_library'][zoom >= 16] { + point-file: url('symbols/library.p.20.png'); + point-placement: interior; + } + + [feature = 'amenity_courthouse'][zoom > 16] { + point-file: url('symbols/amenity_court.p.20.png'); + point-placement: interior; + } + + [feature = 'waterway_lock'], + [feature = 'lock_yes'] { + [zoom >= 15] { + marker-fill: #969494; + marker-width: 9; + marker-line-width: 0; + marker-placement: interior; + } + } + + [feature = 'man_made_mast'][zoom >= 17] { + point-file: url('symbols/communications.p.20.png'); + point-placement: interior; + } + + [feature = 'tourism_museum'][zoom >= 16] { + point-file: url('symbols/museum.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_parking'][zoom >= 16] { + marker-file: url('symbols/parking.svg'); + marker-placement: interior; + marker-clip: false; + marker-fill: @transportation-icon; + [access != ''][access != 'public'][access != 'yes'] { + marker-opacity: 0.33; + } + } + + [feature = 'amenity_pharmacy'][zoom >= 17] { + point-file: url('symbols/pharmacy.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_place_of_worship'][zoom >= 16] { + point-file: url('symbols/place_of_worship3.p.16.png'); + point-placement: interior; + [religion = 'christian'] { + point-file: url('symbols/christian3.p.14.png'); + [denomination = 'jehovahs_witness']{ + point-file: url('symbols/place_of_worship3.p.16.png'); + } + } + [religion = 'muslim'] { + point-file: url('symbols/islamic3.p.16.png'); + } + [religion = 'sikh'] { + point-file: url('symbols/sikh3.p.16.png'); + } + [religion = 'jewish'] { + point-file: url('symbols/jewish3.p.16.png'); + } + [religion = 'hindu'] { + point-file: url('symbols/hindu.png'); + } + [religion = 'buddhist'] { + point-file: url('symbols/buddhist.png'); + } + [religion = 'shinto'] { + point-file: url('symbols/shinto.png'); + } + [religion = 'taoist'] { + point-file: url('symbols/taoist.png'); + } + } + + [feature = 'amenity_police'][zoom >= 16] { + point-file: url('symbols/police.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_post_box'][zoom >= 17] { + point-file: url('symbols/post_box.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_post_office'][zoom >= 17] { + point-file: url('symbols/post_office.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_pub'][zoom >= 17] { + point-file: url('symbols/pub.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_biergarten'][zoom >= 17] { + point-file: url('symbols/biergarten.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_recycling'][zoom >= 16] { + point-file: url('symbols/recycling.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_restaurant'][zoom >= 17] { + point-file: url('symbols/restaurant.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_fast_food'][zoom >= 17] { + point-file: url('symbols/fast_food.png'); + point-placement: interior; + } + + [feature = 'amenity_telephone'][zoom >= 17] { + point-file: url('symbols/telephone.p.16.png'); + point-placement: interior; + } + + [feature = 'amenity_emergency_phone'][zoom >= 17] { + point-file: url('symbols/sosphone.png'); + point-placement: interior; + } + + [feature = 'amenity_theatre'][zoom >= 16] { + point-file: url('symbols/theatre.p.20.png'); + point-placement: interior; + } + + [feature = 'amenity_toilets'][zoom >= 17] { + point-file: url('symbols/toilets.p.20.png'); + point-placement: interior; + } + + [feature = 'amenity_drinking_water'][zoom >= 17] { + point-file: url('symbols/food_drinkingtap.p.20.png'); + point-placement: interior; + } + + [feature = 'amenity_prison'][zoom >= 17] { + point-file: url('symbols/amenity_prison.p.20.png'); + point-placement: interior; + } + + [feature = 'tourism_viewpoint'][zoom >= 16] { + point-file: url('symbols/view_point.p.16.png'); + point-placement: interior; + } + + [feature = 'man_made_water_tower'][zoom >= 17] { + point-file: url('symbols/tower_water.p.20.png'); + point-placement: interior; + } + + [feature = 'historic_memorial'][zoom >= 17] { + point-file: url('symbols/tourist_memorial.p.20.png'); + point-placement: interior; + } + + [feature = 'historic_archaeological_site'][zoom >= 16] { + point-file: url('symbols/tourist_archaeological2.glow.24.png'); + point-placement: interior; + } + + [feature = 'shop_other'][zoom >= 17] { + marker-fill: @shop-icon; + marker-width: 6; + marker-line-width: 0; + marker-placement: interior; + marker-clip: false; + } + + [feature = 'shop_supermarket'][zoom >= 16] { + marker-file: url('symbols/shop_supermarket.svg'); + marker-placement: interior; + marker-clip: false; + marker-fill: @shop-icon; + } + + [feature = 'shop_bakery'][zoom >= 17] { + marker-file: url('symbols/shop_bakery.p.16.png'); + marker-placement: interior; + marker-clip: false; + } + + [feature = 'shop_butcher'][zoom >= 17] { + marker-file: url('symbols/shop_butcher.png'); + marker-placement: interior; + marker-clip: false; + } + + [feature = 'shop_clothes'], + [feature = 'shop_fashion'] { + [zoom >= 17] { + marker-file: url('symbols/shop_clothes.svg'); + marker-placement: interior; + marker-clip: false; + marker-fill: @shop-icon; + } + } + + [feature = 'shop_convenience'][zoom >= 17] { + marker-file: url('symbols/shop_convenience.svg'); + marker-placement: interior; + marker-clip: false; + marker-fill: @shop-icon; + } + + [feature = 'shop_department_store'][zoom >= 16] { + point-file: url('symbols/department_store.p.16.png'); + point-placement: interior; + } + + [feature = 'shop_doityourself'][zoom >= 17] { + marker-file: url('symbols/shop_diy.p.16.png'); + marker-placement: interior; + marker-clip: false; + } + + [feature = 'shop_florist'][zoom >= 17] { + marker-file: url('symbols/florist.p.16.png'); + marker-placement: interior; + marker-clip: false; + } + + [feature = 'shop_hairdresser'][zoom >= 17] { + marker-file: url('symbols/shop_hairdresser.p.16.png'); + marker-placement: interior; + marker-clip: false; + } + + [feature = 'shop_car'][zoom >= 17] { + marker-file: url('symbols/shop_car.svg'); + marker-placement: interior; + marker-clip: false; + marker-fill: @shop-icon; + } + + [feature = 'shop_car_repair'][zoom >= 17] { + marker-file: url('symbols/shopping_car_repair.p.16.png'); + marker-placement: interior; + marker-clip: false; + } + + [feature = 'shop_bicycle'][zoom >= 17] { + marker-file: url('symbols/shopping_bicycle.p.16.png'); + marker-placement: interior; + marker-clip: false; + } + + [feature = 'leisure_playground'][zoom >= 17] { + point-file: url('symbols/playground.p.20.png'); + point-placement: interior; + } + + [feature = 'tourism_picnic_site'][zoom >= 16] { + point-file: url('symbols/picnic.p.16.png'); + point-placement: interior; + } + + [feature = 'leisure_picnic_table'][zoom >= 17] { + point-file: url('symbols/picnic.p.16.png'); + point-placement: interior; + } + + [feature = 'leisure_slipway'][zoom >= 17] { + point-file: url('symbols/transport_slipway.p.20.png'); + point-placement: interior; + } + + [feature = 'aeroway_helipad'][zoom >= 16]::aeroway { + marker-file: url('symbols/helipad.svg'); + marker-clip: false; + marker-fill: @airtransport; + } + + [feature = 'aeroway_aerodrome'][zoom >= 10][zoom < 14]::aeroway { + marker-file: url('symbols/aerodrome.svg'); + marker-clip: false; + marker-fill: @airtransport; + } + + [feature = 'man_made_lighthouse'][zoom >= 15]::man_made { + point-file: url('symbols/lighthouse.p.20.png'); + point-placement: interior; + } + + [feature = 'natural_peak'][zoom >= 11]::natural { + marker-file: url('symbols/peak.svg'); + marker-fill: #d08f55; + marker-placement: interior; + } + + [feature = 'natural_volcano'][zoom >= 11]::natural { + marker-file: url('symbols/peak.svg'); + marker-fill: #d40000; + marker-placement: interior; + } + + [feature = 'natural_saddle'][zoom >= 15]::natural { + marker-file: url('symbols/saddle.svg'); + marker-fill: #d08f55; + marker-placement: interior; + } + + [feature = 'natural_cave_entrance'][zoom >= 15]::natural { + point-file: url('symbols/poi_cave.p.16.png'); + point-placement: interior; + } + + [feature = 'natural_spring'][zoom >= 14]::natural { + marker-file: url('symbols/spring.svg'); + marker-placement: interior; + } + + [feature = 'natural_tree'][zoom >= 16]::natural { + marker-placement: interior; + marker-ignore-placement: true; + marker-line-width: 0; + marker-width: 3; + marker-fill: #239c45; + [zoom >= 17] { + marker-line-width: 1; + marker-line-color: #8ef2ab; + marker-width: 4; + } + } + + [feature = 'power_generator']['generator:source' = 'wind']::power, + [feature = 'power_generator'][power_source = 'wind']::power { + [zoom >= 15] { + point-file: url('symbols/power_wind.png'); + point-placement: interior; + } + } + + [feature = 'man_made_windmill'][zoom >= 16]::man_made { + point-file: url('symbols/windmill.png'); + point-placement: interior; + } + + [feature = 'man_made_mast'][zoom >= 17]::man_made { + point-file: url('symbols/communications.p.20.png'); + point-placement: interior; + } +} + +.amenity-low-priority { + [railway = 'level_crossing'][zoom >= 14]::railway { + point-file: url('symbols/level_crossing.svg'); + point-placement: interior; + [zoom >= 16] { + point-file: url('symbols/level_crossing2.svg'); + } + } + + [highway = 'mini_roundabout'][zoom >= 16]::highway { + marker-file: url('symbols/mini_roundabout.svg'); + marker-placement: interior; + } + + [barrier = 'gate']::barrier { + [zoom >= 16] { + marker-file: url('symbols/gate.svg'); + marker-placement: interior; + } + } + + [barrier = 'lift_gate'][zoom >= 16]::barrier { + marker-file: url('symbols/liftgate.svg'); + marker-fill: #3f3f3f; + marker-placement: interior + } + + [barrier = 'bollard'], + [barrier = 'block'] { + [zoom >= 16] { + marker-width: 3; + marker-line-width: 0; + marker-fill: #7d7c7c; + marker-placement: interior; + + [zoom >= 18] { + marker-width: 4; + } + } + } +} + +.text-low-zoom[zoom < 10], +.text[zoom >= 10] { + [feature = 'place_island'][zoom >= 7][way_pixels > 3000], + [feature = 'place_island'][zoom >= 16], + [feature = 'place_islet'][zoom >= 14][way_pixels > 3000], + [feature = 'place_islet'][zoom >= 17] { + text-name: "[name]"; + text-fill: #000; + text-size: 10; + [way_pixels > 12000] { text-size: 12; } + [way_pixels > 48000] { text-size: 15; } + text-face-name: @oblique-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'amenity_pub'], + [feature = 'amenity_restaurant'], + [feature = 'amenity_cafe'], + [feature = 'amenity_fast_food'], + [feature = 'amenity_biergarten'], + [feature = 'amenity_bar'] { + [zoom >= 17] { + text-name: "[name]"; + text-fill: #734a08; + text-size: 10; + text-dy: 11; + text-face-name: @bold-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + [feature = 'amenity_bar']{ + text-dy: 13; + } + } + } + + [feature = 'amenity_library'], + [feature = 'amenity_theatre'], + [feature = 'amenity_courthouse'], + [feature = 'amenity_cinema'] { + [zoom >= 17] { + text-name: "[name]"; + text-size: 10; + text-fill: #734a08; + text-dy: 13; + text-face-name: @bold-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + [feature = 'amenity_cinema'] { + text-dy: 15; + } + } + } + + [feature = 'amenity_parking'][zoom >= 17] { + text-name: "[name]"; + text-size: 9; + text-fill: @transportation-text; + text-dy: 9; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + [access != ''][access != 'public'][access != 'yes'] { + text-fill: #66ccaf; + } + } + + [feature = 'amenity_police'][zoom >= 17] { + text-name: "[name]"; + text-size: 10; + text-fill: #734a08; + text-dy: 11; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'amenity_fire_station'][zoom >= 17] { + text-name: "[name]"; + text-size: 10; + text-fill: #734a08; + text-dy: 11; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'amenity_place_of_worship'][zoom >= 17] { + text-name: "[name]"; + text-size: 10; + text-fill: #000033; + text-dy: 12; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'natural_wood'][is_building = 'no'] { + [zoom >= 8][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@wood, 40%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'natural_peak'], + [feature = 'natural_volcano'] { + [zoom >= 13] { + text-name: "[name]"; + text-size: 10; + text-fill: brown; + text-dy: 7; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + ele/text-name: "[ele]"; + ele/text-size: 9; + ele/text-fill: brown; + ele/text-dy: 6; + ele/text-face-name: @oblique-fonts; + ele/text-halo-radius: 1; + ele/text-placement: interior; + [name != ''] { + ele/text-dy: 19; + } + } + } + + [feature = 'natural_saddle'] { + [zoom >= 15] { + text-name: "[name]"; + text-size: 10; + text-fill: brown; + text-dy: 7; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + ele/text-name: "[ele]"; + ele/text-size: 9; + ele/text-fill: brown; + ele/text-dy: 6; + ele/text-face-name: @oblique-fonts; + ele/text-halo-radius: 1; + ele/text-placement: interior; + [name != ''] { + ele/text-dy: 19; + } + } + } + + [feature = 'natural_cave_entrance'][zoom >= 15] { + text-name: "[name]"; + text-size: 10; + text-fill: brown; + text-dy: 11; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'historic_memorial'][zoom >= 17] { + text-name: "[name]"; + text-size: 9; + text-fill: brown; + text-dy: 13; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'historic_archaeological_site'][zoom >= 17] { + text-name: "[name]"; + text-size: 9; + text-fill: brown; + text-dy: 15; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'natural_water'], + [feature = 'natural_lake'], + [feature = 'landuse_reservoir'], + [feature = 'landuse_basin'] { + [way_area >= 40000000][zoom >= 10], + [way_area >= 10000000][zoom >= 11], + [way_area >= 2400000][zoom >= 12], + [way_area >= 600000][zoom >= 13], + [way_area >= 150000][zoom >= 14], + [way_area >= 80000][zoom >= 15], + [way_area >= 20000][zoom >= 16], + [zoom >= 17] { + text-name: "[name]"; + text-size: 12; + text-fill: @water-text; + text-face-name: @oblique-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + } + + [feature = 'natural_mud'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: @mud-text; + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'natural_wetland'][is_building = 'no'], + [feature = 'natural_marsh'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: @wetland-text; + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'leisure_swimming_pool'][is_building = 'no'] { + [zoom >= 14][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: @marina-text; + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'leisure_sports_centre'][is_building = 'no'], + [feature = 'leisure_stadium'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@stadium, 30%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'leisure_track'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@track, 40%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'leisure_pitch'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@pitch, 40%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'leisure_playground'] { + [way_area >= 150000][zoom >= 14], + [way_area >= 80000][zoom >= 15], + [way_area >= 20000][zoom >= 16], + [zoom >= 17] { + text-name: "[name]"; + text-size: 11; + text-dy: 13; + text-fill: darken(@park, 60%); + text-face-name: @book-fonts; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + } + + [feature = 'leisure_park'][is_building = 'no'], + [feature = 'leisure_recreation_ground'][is_building = 'no'], + [feature = 'landuse_recreation_ground'][is_building = 'no'], + [feature = 'landuse_conservation'][is_building = 'no'], + [feature = 'landuse_village_green'][is_building = 'no'], + [feature = 'leisure_common'][is_building = 'no'], + [feature = 'leisure_garden'][is_building = 'no'], + [feature = 'leisure_golf_course'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@park, 60%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'boundary_national_park'][is_building = 'no'], + [feature = 'leisure_nature_reserve'][is_building = 'no'] { + [zoom >= 8][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@park, 70%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'landuse_quarry'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@quarry, 60%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'landuse_vineyard'][is_building = 'no'], + [feature = 'landuse_orchard'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@vineyard, 50%); + text-face-name: @landcover-face-name; + text-halo-radius: 1.5; /* extra halo needed to overpower the vineyard polygon pattern */ + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'landuse_cemetery'][is_building = 'no'], + [feature = 'amenity_grave_yard'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@cemetery, 50%); + text-face-name: @landcover-face-name; + text-halo-radius: 1.5; /* extra halo needed to overpower the cemetery polygon pattern */ + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'landuse_residential'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@residential, 50%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'landuse_garages'][is_building = 'no'] { + [zoom >= 13][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@garages, 50%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'landuse_field'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@field, 50%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'landuse_meadow'][is_building = 'no'], + [feature = 'landuse_grass'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@grass, 50%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'landuse_allotments'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@allotments, 50%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'landuse_forest'][is_building = 'no'] { + [zoom >= 8][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@forest, 30%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'landuse_farmyard'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@farmyard, 50%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + [feature = 'landuse_farm'][is_building = 'no'], + [feature = 'landuse_farmland'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@farmland, 50%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'shop_mall'], + [feature = 'landuse_retail'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@retail, 50%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'landuse_industrial'][is_building = 'no'], + [feature = 'landuse_railway'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@industrial, 60%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'landuse_commercial'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@commercial, 60%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'landuse_brownfield'][is_building = 'no'], + [feature = 'landuse_landfill'][is_building = 'no'], + [feature = 'landuse_construction'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@construction, 50%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'natural_bay'][zoom >= 14] { + text-name: "[name]"; + text-size: 10; + text-fill: #6699cc; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'natural_spring'][zoom >= 16] { + text-name: "[name]"; + text-size: 10; + text-fill: #6699cc; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + text-dy: 6; + } + + [feature = 'tourism_alpine_hut'][zoom >= 15] { + text-name: "[name]"; + text-size: 9; + text-fill: #6699cc; + text-dy: 11; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + [zoom >= 16] { + ele/text-name: "[ele]"; + ele/text-size: 8; + ele/text-fill: #6699cc; + ele/text-dy: 23; + ele/text-face-name: @oblique-fonts; + ele/text-halo-radius: 1; + ele/text-placement: interior; + } + } + + [feature = 'amenity_shelter'][zoom >= 17] { + text-name: "[name]"; + text-size: 9; + text-fill: #6699cc; + text-dy: 11; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + ele/text-name: "[ele]"; + ele/text-size: 8; + ele/text-fill: #6699cc; + ele/text-dy: 23; + ele/text-face-name: @oblique-fonts; + ele/text-halo-radius: 1; + ele/text-placement: interior; + } + + [feature = 'amenity_bank'][zoom >= 17] { + text-name: "[name]"; + text-size: 9; + text-fill: black; + text-dy: 12; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + text-face-name: @book-fonts; + } + + [feature = 'tourism_hotel'], + [feature = 'tourism_motel'], + [feature = 'tourism_hostel'], + [feature = 'tourism_chalet'] { + [zoom >= 17] { + text-name: "[name]"; + text-size: 10; + text-fill: #0066ff; + text-dy: 13; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + [feature = 'tourism_chalet'] { + text-dy: 11; + } + } + } + + [feature = 'amenity_embassy'][zoom >= 17] { + text-name: "[name]"; + text-size: 9; + text-fill: #0066ff; + text-dy: 9; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'tourism_guest_house'][zoom >= 17] { + text-name: "[name]"; + text-size: 8; + text-fill: #0066ff; + text-dy: 10; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'highway_bus_stop'], + [feature = 'amenity_fuel'], + [feature = 'amenity_bus_station'] { + [zoom >= 17] { + text-name: "[name]"; + text-size: 9; + text-fill: @transportation-text; + text-dy: 11; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + [feature = 'highway_bus_stop'] { + text-dy: 9; + } + } + } + + [feature = 'tourism_camp_site'][zoom >= 17] { + text-name: "[name]"; + text-size: 10; + text-fill: #0066ff; + text-dy: 15; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'tourism_caravan_site'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@campsite, 50%); + text-dy: 15; + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'waterway_lock'][zoom >= 15] { + text-name: "[name]"; + text-size: 9; + text-dy: 10; + text-fill: #0066ff; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'leisure_marina'][zoom >= 15] { + text-name: "[name]"; + text-size: 8; + text-fill: @marina-text; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + [zoom >= 17] { + text-size: 10; + } + } + + [feature = 'tourism_theme_park'][is_building = 'no'] { + [zoom >= 13][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: @theme_park; + text-face-name: @bold-fonts; /*rendered bold to improve visibility since theme parks tend to have crowded backgrounds*/ + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'tourism_museum'][zoom >= 17] { + text-name: "[name]"; + text-size: 10; + text-dy: 11; + text-fill: #734a08; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'amenity_prison'][zoom >= 17] { + text-name: "[name]"; + text-size: 10; + text-fill: #734a08; + text-dy: 16; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'tourism_attraction'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: #660033; + text-face-name: @book-fonts; + text-halo-radius: 2; + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'amenity_university'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@school, 70%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'amenity_school'][is_building = 'no'], + [feature = 'amenity_college'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@school, 70%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'amenity_kindergarten'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@school, 65%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'man_made_lighthouse'][zoom >= 15] { + text-name: "[name]"; + text-size: 9; + text-fill: #000033; + text-dy: 16; + text-face-name: @book-fonts; + text-halo-radius: 2; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'man_made_windmill'][zoom >= 17] { + text-name: "[name]"; + text-size: 9; + text-fill: #734a08; + text-dy: 12; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'amenity_hospital'][zoom >= 16] { + text-name: "[name]"; + text-fill: #da0092; + text-size: 8; + text-dy: 10; + text-face-name: @book-fonts; + text-halo-radius: 2; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'amenity_pharmacy'][zoom >= 17] { + text-name: "[name]"; + text-size: 8; + text-dy: 10; + text-fill: #da0092; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'shop_bakery'], + [feature = 'shop_clothes'], + [feature = 'shop_fashion'], + [feature = 'shop_convenience'], + [feature = 'shop_doityourself'], + [feature = 'shop_hairdresser'], + [feature = 'shop_butcher'], + [feature = 'shop_car'], + [feature = 'shop_car_repair'], + [feature = 'shop_bicycle'], + [feature = 'shop_florist'], + [feature = 'shop_other']{ + [zoom >= 17] { + text-name: "[name]"; + text-size: 10; + text-dy: 12; + text-fill: #939; + text-face-name: @book-fonts; + text-halo-radius: 1.5; + text-halo-fill: rgba(255, 255, 255, 0.8); + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + } + + [feature = 'shop_supermarket'], + [feature = 'shop_department_store'] { + [zoom >= 16] { + text-name: "[name]"; + text-size: 10; + text-dy: 12; + text-fill: #939; + text-face-name: @book-fonts; + text-halo-radius: 1.5; + text-halo-fill: rgba(255, 255, 255, 0.8); + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + } + + [feature = 'military_danger_area'][is_building = 'no'] { + [zoom >= 9][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@danger_area, 40%); + text-face-name: @bold-fonts; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'landuse_military'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@military, 40%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'aeroway_gate'][zoom >= 17] { + text-name: "[ref]"; + text-size: 10; + text-fill: #aa66cc; + text-face-name: @book-fonts; + text-halo-radius: 1; + text-wrap-width: @standard-wrap-width; + text-placement: interior; + } + + [feature = 'military_barracks'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@barracks, 40%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'tourism_zoo'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@zoo, 40%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'power_station'][is_building = 'no'][zoom >= 10], + [feature = 'power_generator'][is_building = 'no'][zoom >= 10], + [feature = 'power_sub_station'][is_building = 'no'][zoom >= 13], + [feature = 'power_substation'][is_building = 'no'][zoom >= 13]{ + [way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@power, 40%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'natural_desert'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@desert, 40%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'natural_sand'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@sand, 50%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'natural_heath'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@heath, 40%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + + [feature = 'natural_grassland'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@grassland, 60%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'natural_scrub'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@scrub, 60%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'aeroway_apron'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@apron, 60%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'natural_beach'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@beach, 60%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + text-placement: interior; + } + } + + [feature = 'highway_services'][is_building = 'no'], + [feature = 'highway_rest_area'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@rest_area, 40%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + } + } + + [feature = 'natural_glacier'][is_building = 'no'] { + [zoom >= 10][way_pixels > 3000], + [zoom >= 17] { + text-name: "[name]"; + text-size: @landcover-font-size; + [way_pixels > 12000] { text-size: @landcover-font-size-big; } + [way_pixels > 48000] { text-size: @landcover-font-size-bigger; } + text-fill: darken(@glacier, 40%); + text-face-name: @landcover-face-name; + text-halo-radius: 1; + text-halo-fill: rgba(255,255,255,0.6); + text-wrap-width: @landcover-wrap-width-size; + [way_pixels > 12000] {text-wrap-width: @landcover-wrap-width-size-big; } + [way_pixels > 48000] {text-wrap-width: @landcover-wrap-width-size-bigger; } + } + } + + [feature = 'aeroway_helipad'][zoom >= 16]::aeroway { + text-name: "[name]"; + text-size: 8; + text-fill: @airtransport; + text-dy: -10; + text-face-name: @bold-fonts; + text-halo-radius: 1; + text-placement: interior; + text-wrap-width: 30; + } + + [feature = 'aeroway_aerodrome'][zoom >= 10][zoom < 14]::aeroway { + text-name: "[name]"; + text-size: 8; + text-fill: darken(@airtransport, 15%); + text-dy: -10; + text-face-name: @oblique-fonts; + text-halo-radius: 1; + text-placement: interior; + text-wrap-width: 30; + } +} diff --git a/samples/Clarion/CStringClass.clw b/samples/Clarion/CStringClass.clw new file mode 100644 index 00000000..7fa3ba98 --- /dev/null +++ b/samples/Clarion/CStringClass.clw @@ -0,0 +1,172 @@ + Member() + omit('***$***',_VER_C55) +_ABCDllMode_ EQUATE(0) +_ABCLinkMode_ EQUATE(1) + ***$*** + Include('Equates.CLW'),ONCE + Include('Keycodes.CLW'),ONCE + Include('Errors.CLW'),ONCE + Map + End ! map + Include('CStringClass.inc'),ONCE +CStringClass.Construct PROCEDURE ! Declare Procedure + CODE + SELF.bufferSize = DEFAULT_CS_BUFFER_SIZE + SELF.CS &= New(CSTRING(SELF.bufferSize)) +CStringClass.Destruct PROCEDURE ! Declare Procedure + CODE + Dispose(SELF.cs) +CStringClass.Cat PROCEDURE (STRING pStr) !,*CSTRING,PROC ! Declare Procedure +newLen LONG,AUTO +oldCS &CSTRING + CODE + newLen = Len(pStr) + IF (newLen+SELF.strLength+2) > SELF.newStrSize + ! Only grow the internal string if the result of the cat will be larger than the string currently is. + ! The reason for the "+2" is because this is used in the string slicing outside this IF. Without this matching +2 there is potential for an out of bounds slice which would be bad! + + ! Save a temporary copy of the old string so we can us it in the concatination after we have grown it! + oldCS &= New(CSTRING(SELF.strLength+1)) + oldCS = SELF.CS + Dispose(SELF.CS) + + SELF.newStrSize = newLen + SELF.strLength + 1 + SELF.bufferSize + SELF.CS &= New(CSTRING(SELF.newStrSize)) + SELF.CS = oldCS + Dispose(oldCS) + END + + ! Append the new string directly to the end of the old one. + SELF.CS[SELF.strLength+1 : SELF.strLength+newLen] = pStr + ! And terminate the CSTRING manually + SELF.CS[SELF.strLength+newLen+1] = '<0>' + + ! This is the same as doing "SELF.strLength = Len(SELF.CS)" but the Len() is _really_ slow on large strings. This is much faster! + SELF.strLength += newLen + + ! This is what it used to be: + ! SELF.Str(SELF.Str() & s) + ! It is a nice and neat solution but performance, especially on large strings was terrible! + + RETURN SELF.Str() +CStringClass.Str PROCEDURE (STRING pStr) !,*CSTRING, PROC ! Declare Procedure + CODE + IF Len(pStr) > SELF.newStrSize + ! Only Dispose/New the internal string if the new one requires it. + ! This might be slightly innefficient in terms of memory usage when the string gets smaller + ! But it is _vasty_ better for performance when the string gets added to a lot. + Dispose(SELF.CS) + SELF.newStrSize = Len(pStr) + 1 + SELF.bufferSize + SELF.CS &= New(CSTRING(SELF.newStrSize)) + END + + SELF.CS = pStr + SELF.strLength = Len(SELF.CS) + + RETURN SELF.CS +CStringClass.Len PROCEDURE !,LONG ! Declare Procedure + CODE + RETURN SELF.strLength +CStringClass.Replace PROCEDURE (STRING pFind, STRING pReplace) !,*CSTRING,PROC ! Declare Procedure +! FindString , ReplaceWith +locate LONG,AUTO +lastLocate LONG + CODE + LOOP + locate = InString(Upper(pFind), Upper(SELF.Str()), 1, lastLocate+1) + IF ~locate + BREAK + END + + ! So we dont end up having recursive replacement. + lastLocate = locate + Len(pReplace)-1 + + SELF.Str(Sub(SELF.Str(), 1, locate-1) & | + pReplace & | + Sub(SELF.Str(), locate+Len(pFind), SELF.Len()) | + ) + END + + RETURN SELF.Str() +CStringClass.Str PROCEDURE () !,*CSTRING ! Declare Procedure 3 + CODE + RETURN SELF.CS +!------------------------------------------------------------------------------ +CStringClass.Contains PROCEDURE (STRING pFind, BYTE pCaseSensitive=TRUE) !,BYTE ! Declare Procedure +! Returns a value (TRUE) indicating whether the specified String occurs within this string. +! Second parameter defaults to a case sensitive search. + CODE + IF pCaseSensitive = TRUE + IF InString(pFind, SELF.Str(), 1 , 1) > 0 + RETURN TRUE + END + ELSE + IF InString(Lower(pFind), SELF.Lower(), 1 , 1) > 0 + RETURN TRUE + END + END + + RETURN FALSE +CStringClass.Lower PROCEDURE () !,STRING ! Declare Procedure +! Returns a "Lowered" version of the self.cs doesnt change the self.cs + CODE + RETURN Lower(SELF.CS) +CStringClass.SubString PROCEDURE (LONG pPosition, LONG pLength) !,STRING,PROC ! Declare Procedure + CODE + RETURN Sub(SELF.Str(), pPosition, pLength) +CStringClass.ToLower PROCEDURE () !,*CSTRING,PROC ! Declare Procedure +! Converts this string to lowercase and returns the converted string + + CODE + RETURN SELF.Str(SELF.Lower()) +CStringClass.ToUpper PROCEDURE () !,*CSTRING,PROC ! Declare Procedure +! Converts this string to uppercase and returns the converted string + + CODE + RETURN SELF.Str(SELF.Upper()) +CStringClass.Trim PROCEDURE () !,*CSTRING,PROC ! Declare Procedure + CODE + SELF.Str(Left(SELF.Str())) + SELF.Str(Clip(SELF.Str())) + RETURN SELF.Str() +CStringClass.Upper PROCEDURE () !,STRING ! Declare Procedure + CODE + RETURN Upper(SELF.Str()) +CStringClass.IndexOf PROCEDURE (STRING pLookIn, BYTE pCaseSensitive=TRUE) !,LONG ! Declare Procedure +! Returns the index of the first parameter (pLookIn) is found within the SELF.CS +! zero if it is not found + CODE + IF pCaseSensitive = TRUE + RETURN InString(SELF.Str(), pLookIn, 1 , 1) + ELSE + RETURN InString(SELF.Lower(), Lower(pLookIn), 1 , 1) + END +CStringClass.FoundIn PROCEDURE (STRING pLookIn, BYTE pCaseSensitive=TRUE) !,BYTE ! Declare Procedure +! Returns TRUE if the first parameter (pLookIn) is found within the SELF.CS +! FALSE if it is no + CODE + IF SELF.IndexOf(pLookIn, pCaseSensitive) > 0 + RETURN TRUE + ELSE + RETURN FALSE + END +CStringClass.SetBuffer PROCEDURE (LONG pNewBuffer) ! Declare Procedure + CODE + SELF.bufferSize = pNewBuffer +CStringClass.EscapeXml PROCEDURE () !,STRING ! Declare Procedure +CS CStringClass + CODE + IF Omitted(pStr)=FALSE + CS.Str(pStr) + ELSE + ! Make a copy so we don't alter the original + CS.Str(SELF.Str()) + END + CS.Replace('&', '&') + CS.Replace('<', '<') + CS.Replace('>', '>') + CS.Replace('"', '"') + CS.Replace('''', ''') + + RETURN CS.Str() + diff --git a/samples/Clarion/ConsoleSupport.clw b/samples/Clarion/ConsoleSupport.clw new file mode 100644 index 00000000..c7eac1e1 --- /dev/null +++ b/samples/Clarion/ConsoleSupport.clw @@ -0,0 +1,68 @@ + Member() + Include('ConsoleSupport.inc'),ONCE + Map + MODULE('32-bit Windows API') + ! General functions + GetLastError(),DWORD,PASCAL + + ! Console functions + GetStdHandle(DWORD),HANDLE,PASCAL,PROC,RAW + WriteConsole(Handle,Long,Dword,long,long),bool,Raw,Pascal,name('WriteConsoleA') + ReadConsole(Handle,Long,Dword,long,long),bool,Raw,Pascal,name('ReadConsoleA') + SetConsoleTitle(Long),Bool,Raw,Pascal,name('SetConsoleTitleA') + GetConsoleTitle(Long,dword),Bool,Raw,Pascal,name('GetConsoleTitleA') + SetConsoleMode(Handle,dWord),BOOL,RAW,PASCAL + GetConsoleMode(Handle,Long),BOOL,RAW,PASCAL + End + End + +ConsoleSupport.Construct PROCEDURE + + CODE + +ConsoleSupport.Destruct PROCEDURE + + CODE + +ConsoleSupport.Init PROCEDURE () !,BYTE,VIRTUAL + CODE + + SELF.OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE) + If SELF.OutputHandle = INVALID_HANDLE_VALUE + Halt(1,'Unable to get output handle (' & GetLastError() & ')') + RETURN INVALID_HANDLE_VALUE + End + + SELF.InputHandle = GetStdHandle(STD_INPUT_HANDLE) + if SELF.InputHandle = INVALID_HANDLE_VALUE + Halt(2,'Unable to get console input handle (' & GetLastError() & ')') + RETURN INVALID_HANDLE_VALUE + End + + If ~SetConsoleMode(SELF.InputHandle,ENABLE_PROCESSED_INPUT ) + Halt(3,'Unable to set console mode (' & GetLastError() & ')') + RETURN INVALID_OTHER + End + + RETURN FALSE + +ConsoleSupport.WriteLine PROCEDURE (STRING pText) !,BYTE,PROC,VIRTUAL + CODE + SELF.TextBuffer = SELF.Prefix & pText & '<13,10>' + If WriteConsole(SELF.OutputHandle, ADDRESS(SELF.TextBuffer), LEN(SELF.TextBuffer),ADDRESS(SELF.BytesWritten), NULL) = 0 + Halt(4,'WriteConsoleError (' & GetLastError() & ')') + RETURN -1 + End + RETURN FALSE + +Consolesupport.ReadKey PROCEDURE () !,STRING,PROC,VIRTUAL + CODE + SELF.WriteLine('Press any key to continue...') + Clear(SELF.InBuffer) + Loop + IF ReadConsole(SELF.InputHandle,Address(SELF.InBuffer),100,Address(SELF.BytesRead),NULL) = 0 THEN + Halt(5,'Error on read console (' & GetLastError() & ')') + Break + End + Until SELF.BytesRead > 0 + RETURN SELF.InBuffer \ No newline at end of file diff --git a/samples/Clarion/HelloWorld.clw b/samples/Clarion/HelloWorld.clw new file mode 100644 index 00000000..8cad46dc --- /dev/null +++ b/samples/Clarion/HelloWorld.clw @@ -0,0 +1,10 @@ + PROGRAM + + MAP + END + + CODE + + MESSAGE('Hello World!') + + RETURN \ No newline at end of file diff --git a/samples/Clarion/hello.clw b/samples/Clarion/hello.clw new file mode 100644 index 00000000..14328c84 --- /dev/null +++ b/samples/Clarion/hello.clw @@ -0,0 +1,12 @@ + MEMBER() + INCLUDE('HelloClass.inc'),ONCE + MAP + END + +HelloClass.Construct PROCEDURE + CODE +HelloClass.Destruct PROCEDURE() !,VIRTUAL + CODE +HelloClass.SayHello PROCEDURE + CODE + MESSAGE('Hello World!') diff --git a/samples/Clean/GenHylo.dcl b/samples/Clean/GenHylo.dcl new file mode 100644 index 00000000..eb95e68c --- /dev/null +++ b/samples/Clean/GenHylo.dcl @@ -0,0 +1,11 @@ +definition module GenHylo + +import StdGeneric, GenMap + +:: Fix f = In (f .(Fix f)) +Out :: !u:(Fix v:a) -> v:(a w:(Fix v:a)), [u <= w] + +hylo :: ((.f .b) -> .b) (.a -> (.f .a)) -> (.a -> .b) | gMap{|*->*|} f +cata :: (u:(f .a) -> .a) -> (Fix u:f) -> .a | gMap{|*->*|} f +ana :: (.a -> u:(f .a)) -> .a -> (Fix u:f) | gMap{|*->*|} f + diff --git a/samples/Clean/GenMap.dcl b/samples/Clean/GenMap.dcl new file mode 100644 index 00000000..bab284b8 --- /dev/null +++ b/samples/Clean/GenMap.dcl @@ -0,0 +1,9 @@ +definition module GenMap + +import StdGeneric + +generic gMap a b :: .a -> .b +derive gMap c, UNIT, PAIR, EITHER, CONS, FIELD, OBJECT, {}, {!} + +derive gMap [], (,), (,,), (,,,), (,,,,), (,,,,,), (,,,,,,), (,,,,,,,) + diff --git a/samples/Clean/GenMap.icl b/samples/Clean/GenMap.icl new file mode 100644 index 00000000..1b06f9ae --- /dev/null +++ b/samples/Clean/GenMap.icl @@ -0,0 +1,19 @@ +implementation module GenMap + +import StdClass, StdArray, StdInt, StdFunc +import StdGeneric, _Array + +generic gMap a b :: .a -> .b +gMap{|c|} x = x +gMap{|UNIT|} x = x +gMap{|PAIR|} fx fy (PAIR x y) = PAIR (fx x) (fy y) +gMap{|EITHER|} fl fr (LEFT x) = LEFT (fl x) +gMap{|EITHER|} fl fr (RIGHT x) = RIGHT (fr x) +gMap{|CONS|} f (CONS x) = CONS (f x) +gMap{|FIELD|} f (FIELD x) = FIELD (f x) +gMap{|OBJECT|} f (OBJECT x) = OBJECT (f x) +gMap{|{}|} f xs = mapArray f xs +gMap{|{!}|} f xs = mapArray f xs + +derive gMap [], (,), (,,), (,,,), (,,,,), (,,,,,), (,,,,,,), (,,,,,,,) + diff --git a/samples/Clean/fsieve.icl b/samples/Clean/fsieve.icl new file mode 100644 index 00000000..fed72660 --- /dev/null +++ b/samples/Clean/fsieve.icl @@ -0,0 +1,54 @@ +module fsieve + +/* +The Fast Sieve of Eratosthenes. + +A sequential and optimized version of the sieve of Eratosthenes. +The program calculates a list of the first NrOfPrime primes. +The result of the program is the NrOfPrimes'th prime. + +Strictness annotations have been added because the strictness analyser +is not able to deduce all strictness information. Removal of these !'s +will make the program about 20% slower. + +On a machine without a math coprocessor the execution of this +program might take a (very) long time. Set NrOfPrimes to a smaller value. +*/ + +import StdClass; // RWS +import StdInt, StdReal + +NrOfPrimes :== 3000 + +// The sieve algorithm: generate an infinite list of all primes. + +Primes::[Int] +Primes = pr where pr = [5 : Sieve 7 4 pr] + +Sieve::Int !Int [Int] -> [Int] +Sieve g i prs + | IsPrime prs g (toInt (sqrt (toReal g))) = [g : Sieve` g i prs] + = Sieve (g + i) (6 - i) prs + +Sieve`::Int Int [Int] -> [Int] +Sieve` g i prs = Sieve (g + i) (6 - i) prs + +IsPrime::[Int] !Int Int -> Bool +IsPrime [f:r] pr bd | f>bd = True + | pr rem f==0 = False + = IsPrime r pr bd + +// Select is used to get the NrOfPrimes'th prime from the infinite list. + +Select::[x] Int -> x +Select [f:r] 1 = f +Select [f:r] n = Select r (n - 1) + + +/* The Start rule: Select the NrOfPrimes'th prime from the list of primes + generated by Primes. +*/ + +Start::Int +Start = Select [2, 3 : Primes] NrOfPrimes + diff --git a/samples/Clean/sem.icl b/samples/Clean/sem.icl new file mode 100644 index 00000000..8dce1cbe --- /dev/null +++ b/samples/Clean/sem.icl @@ -0,0 +1,99 @@ +module monadicSemantics + +import StdEnv, StdGeneric, GenMap, GenHylo + +/* For fun I implemented the recursive datastructre Exp and Stm as fixpoints + This helps us define recursive functions on them (only a little bit though) + However deriving gMap for Fix did not works out of the box + I had to remove some uniqueness typing in GenMap and GenHylo */ +:: Op = Plus | Minus | Times | Rem | Equal | LessThan +:: Var :== String + +:: ExpP a = Int Int | Var Var | Op Op a a +:: Exp :== Fix ExpP + +:: StmP a = Assign Var Exp | If Exp a a | While Exp a | Seq a a | Cont +:: Stm :== Fix StmP + +derive gMap ExpP, StmP, Fix + +// Environment. Semantics is basically Env -> Env +:: Env :== Var -> Int +:: Sem :== Env -> (Int, Env) +empty = \v . 0 + +// return +rtn :: Int -> Sem +rtn i = \e. (i, e) + +// the usual bind +(>>=) infixl 1 :: Sem (Int->Sem) -> Sem +(>>=) x y = \e. (\(i,e2).y i e2) (x e) +(>>|) infixl 1 :: Sem Sem -> Sem +(>>|) x y = x >>= \_. y + +// read variable from environment +read :: Var -> Sem +read v = \e. (e v, e) + +// assign value to give variable in environment +write :: Var Int -> Sem +write v i = \e. (i, \w. if (w==v) i (e w)) + +// semantics +class sem a :: a -> Sem + +operator :: Op -> Int -> Int -> Int +operator Plus = (+) +operator Minus = (-) +operator Times = (*) +operator Rem = rem +operator Equal = \x y . if (x==y) 1 0 +operator LessThan = \x y . if (x< y) 1 0 + +// semantics of expressions +instance sem Exp where + sem x = cata phi x where + phi (Int n) = rtn n + phi (Var v) = read v + phi (Op op x y) = x >>= \v1. y >>= return o (operator op v1) + +// semantics of statments +// NOTE: while will always return 0, as it might not even be executed +instance sem Stm where + sem x = cata phi x where + phi (Assign v e) = sem e >>= write v + phi (If e s1 s2) = sem e >>= \b . if (b<>0) s1 s2 + phi stm=:(While e s) = sem e >>= \b . if (b<>0) (s >>| phi stm) (phi Cont) + phi (Seq s1 s2) = s1 >>| s2 // Here the cata *finally* pays off :D + phi Cont = rtn 0 + +// convenience functions +int = In o Int +var = In o Var +op o = In o2 (Op o) +assign = In o2 Assign +ifte e = In o2 (If e) +while = In o2 While +seq = In o2 Seq +cont = In Cont + +// test case, also testing the new operator < +pEuclides = + while (op LessThan (int 0) (var "b"))( + seq (assign "r" (op Rem (var "a") (var "b"))) + (seq (assign "a" (var "b")) + ( (assign "b" (var "r"))) + ) + ) + +Start = fst (program start) where + program = sem pEuclides >>| read "a" + start "a" = 9 + start "b" = 12 + start _ = 0 + +// Helper +(o2) infixr 9 +(o2) f g x :== f o (g x) + diff --git a/samples/Clean/stack.dcl b/samples/Clean/stack.dcl new file mode 100644 index 00000000..21ca03c0 --- /dev/null +++ b/samples/Clean/stack.dcl @@ -0,0 +1,14 @@ +definition module stack + +:: Stack a + +newStack :: (Stack a) +push :: a (Stack a) -> Stack a +pushes :: [a] (Stack a) -> Stack a +pop :: (Stack a) -> Stack a +popn :: Int (Stack a) -> Stack a +top :: (Stack a) -> a +topn :: Int (Stack a) -> [a] +elements :: (Stack a) -> [a] +count :: (Stack a) -> Int + diff --git a/samples/Clean/stack.icl b/samples/Clean/stack.icl new file mode 100644 index 00000000..6175585a --- /dev/null +++ b/samples/Clean/stack.icl @@ -0,0 +1,33 @@ +implementation module stack +import StdEnv + +:: Stack a :== [a] + +newStack :: (Stack a) +newStack = [] + +push :: a (Stack a) -> Stack a +push x s = [x:s] + +pushes :: [a] (Stack a) -> Stack a +pushes x s = x ++ s + +pop :: (Stack a) -> Stack a +pop [] = abort "Cannot use pop on an empty stack" +pop [e:s] = s + +popn :: Int (Stack a) -> Stack a +popn n s = drop n s + +top :: (Stack a) -> a +top [] = abort "Cannot use top on an empty stack" +top [e:s] = e + +topn :: Int (Stack a) -> [a] +topn n s = take n s +elements :: (Stack a) -> [a] +elements s = s + +count :: (Stack a) -> Int +count s = length s + diff --git a/samples/Clean/streams.dcl b/samples/Clean/streams.dcl new file mode 100644 index 00000000..953a640a --- /dev/null +++ b/samples/Clean/streams.dcl @@ -0,0 +1,16 @@ +definition module streams + +import StdEnv + +instance zero [Real] +instance one [Real] +instance + [Real] +instance - [Real] +instance * [Real] +instance / [Real] + +X :: [Real] +invert :: [Real] -> [Real] +pow :: [Real] Int -> [Real] +(shuffle) infixl 7 :: [Real] [Real] -> [Real] + diff --git a/samples/Clean/streams.icl b/samples/Clean/streams.icl new file mode 100644 index 00000000..7f1fd849 --- /dev/null +++ b/samples/Clean/streams.icl @@ -0,0 +1,49 @@ +implementation module streams + +import StdEnv + +instance zero [Real] +where + zero = [] //Infinite row of zeroes represented as empty list to ease computation + +instance one [Real] +where + one = [1.0:zero] + +instance + [Real] +where + (+) [s:s`] [t:t`] = [s+t:s`+t`] + (+) [s:s`] [] = [s:s`] + (+) [] [t:t`] = [t:t`] + (+) [] [] = [] + +instance - [Real] +where + (-) [s:s`] [t:t`] = [s-t:s`-t`] + (-) [s:s`] [] = [s:s`] + (-) [] [t:t`] = [-1.0] * [t:t`] + (-) [] [] = [] + +instance * [Real] +where + (*) [s:s`] [t:t`] = [s*t:s`*[t:t`]+[s]*t`] + (*) _ _ = [] + +instance / [Real] +where + (/) s t = s * (invert t) + +X :: [Real] +X = [0.0:one] + +invert :: [Real] -> [Real] +invert [s:s`] = [1.0/s:(invert [s:s`]) * s` * [-1.0/s]] + +pow :: [Real] Int -> [Real] +pow s 0 = one +pow s n = s * pow s (n-1) + +(shuffle) infixl 7 :: [Real] [Real] -> [Real] +(shuffle) [s:s`] [t:t`] = [s*t:s` shuffle [t:t`] + [s:s`] shuffle t`] +(shuffle) _ _ = [] + diff --git a/samples/Clojure/build.boot b/samples/Clojure/build.boot new file mode 100644 index 00000000..6de0bfca --- /dev/null +++ b/samples/Clojure/build.boot @@ -0,0 +1,15 @@ +;; from: https://github.com/boot-clj/boot#configure-task-options + +(set-env! + :source-paths #{"src"} + :dependencies '[[me.raynes/conch "0.8.0"]]) + +(task-options! + pom {:project 'my-project + :version "0.1.0"} + jar {:manifest {"Foo" "bar"}}) + +(deftask build + "Build my project." + [] + (comp (pom) (jar) (install))) diff --git a/samples/CoffeeScript/example.cjsx b/samples/CoffeeScript/example.cjsx new file mode 100644 index 00000000..def9cf2f --- /dev/null +++ b/samples/CoffeeScript/example.cjsx @@ -0,0 +1,40 @@ +###* @cjsx React.DOM ### +define 'myProject.ReactExampleComponent', [ + 'React' + 'myProject.ExampleStore' + 'myProject.ExampleActions' + 'myProject.ReactExampleTable' +], (React, ExampleStore, ExampleActions, ReactExampleTable ) -> + + ReactExampleComponent = React.createClass + mixins: [ListenMixin] + + getInitialState: -> + rows: ExampleStore.getRows() + meta: ExampleStore.getMeta() + + componentWillMount: -> + @listenTo ExampleStore + + componentDidMount: -> + ExampleActions.getExampleData() + + onStoreChange: -> + if this.isMounted() + @setState + rows: ExampleStore.getRows() + meta: ExampleStore.getMeta() + + componentWillUnmount: -> + @stopListening ExampleStore + + render: -> +
+
+ {@state.title} +
+ +
diff --git a/samples/Common Lisp/sample.lsp b/samples/Common Lisp/sample.lsp new file mode 100644 index 00000000..9bef6781 --- /dev/null +++ b/samples/Common Lisp/sample.lsp @@ -0,0 +1,21 @@ +;;;; -*- lisp -*- + +(in-package :foo) + +;;; Header comment. +(defvar *foo*) + +(eval-when (:execute :compile-toplevel :load-toplevel) + (defun add (x &optional y &key z) + (declare (ignore z)) + ;; Inline comment. + (+ x (or y 1)))) + +#| +Multi-line comment. +|# + +(defmacro foo (x &body b) + (if x + `(1+ ,x) ;After-line comment. + 42)) diff --git a/samples/Cool/list.cl b/samples/Cool/list.cl new file mode 100644 index 00000000..3d44813e --- /dev/null +++ b/samples/Cool/list.cl @@ -0,0 +1,26 @@ +(* This simple example of a list class is adapted from an example in the + Cool distribution. *) + +class List { + isNil() : Bool { true }; + head() : Int { { abort(); 0; } }; + tail() : List { { abort(); self; } }; + cons(i : Int) : List { + (new Cons).init(i, self) + }; +}; + +class Cons inherits List { + car : Int; -- The element in this list cell + cdr : List; -- The rest of the list + isNil() : Bool { false }; + head() : Int { car }; + tail() : List { cdr }; + init(i : Int, rest : List) : List { + { + car <- i; + cdr <- rest; + self; + } + }; +}; diff --git a/samples/Cool/sample.cl b/samples/Cool/sample.cl new file mode 100644 index 00000000..e8884990 --- /dev/null +++ b/samples/Cool/sample.cl @@ -0,0 +1,71 @@ +(* Refer to Alex Aiken, "The Cool Reference Manual": + http://theory.stanford.edu/~aiken/software/cool/cool-manual.pdf + for language specification. +*) + +-- Exhibit various language constructs +class Sample { + testCondition(x: Int): Bool { + if x = 0 + then false + else + if x < (1 + 2) * 3 + then true + else false + fi + fi + }; + + testLoop(y: Int): Bool { + while y > 0 loop + { + if not condition(y) + then y <- y / 2 + else y <- y - 1; + } + pool + }; + + testAssign(z: Int): Bool { + i : Int; + i <- ~z; + }; + + testCase(var: Sample): SELF_TYPE { + io : IO <- new IO; + case var of + a : A => io.out_string("Class type is A\n"); + b : B => io.out_string("Class type is B\n"); + s : Sample => io.out_string("Class type is Sample\n"); + o : Object => io.out_string("Class type is object\n"); + esac + }; + + testLet(i: Int): Int { + let (a: Int in + let(b: Int <- 3, c: Int <- 4 in + { + a <- 2; + a * b * 2 / c; + } + ) + ) + }; +}; + +-- Used to test subclasses +class A inherits Sample {}; +class B inherits A {}; + +class C { + main() : Int { + (new Sample).testLet(1) + }; +}; + +-- "Hello, world" example +class Main inherits IO { + main(): SELF_TYPE { + out_string("Hello, World.\n") + }; +}; diff --git a/samples/D/mpq.d b/samples/D/mpq.d new file mode 100644 index 00000000..d72c2d2a --- /dev/null +++ b/samples/D/mpq.d @@ -0,0 +1,318 @@ +/* + * mpq.d -- D programming language module for libmpq + * + * Copyright (c) 2008 Georg Lukas + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * This module is written to support Phobos. Patches to allow binding to + * Tango are welcome. + */ + +module mpq; + +/* the following pragma does not work on DMD/Linux, generates a warning on + * GDC/Linux and has not been tested on Windows. Commented out for now. */ +// pragma(lib, "libmpq"); + +import std.string; // for format() and toStringz() +import std.traits; // for ParameterTypeTuple!() + +/* XXX: this assumes that libmpq is compiled with Large File Support on */ +alias long off_t; + +/* libmpq error return values */ +const LIBMPQ_ERROR_OPEN = -1; /* open error on file. */ +const LIBMPQ_ERROR_CLOSE = -2; /* close error on file. */ +const LIBMPQ_ERROR_SEEK = -3; /* lseek error on file. */ +const LIBMPQ_ERROR_READ = -4; /* read error on file. */ +const LIBMPQ_ERROR_WRITE = -5; /* write error on file. */ +const LIBMPQ_ERROR_MALLOC = -6; /* memory allocation error. */ +const LIBMPQ_ERROR_FORMAT = -7; /* format errror. */ +const LIBMPQ_ERROR_NOT_INITIALIZED = -8; /* init() wasn't called. */ +const LIBMPQ_ERROR_SIZE = -9; /* buffer size is to small. */ +const LIBMPQ_ERROR_EXIST = -10; /* file or block does not exist in archive. */ +const LIBMPQ_ERROR_DECRYPT = -11; /* we don't know the decryption seed. */ +const LIBMPQ_ERROR_UNPACK = -12; /* error on unpacking file. */ + +/** libmpq internal meta-data for an archive */ +extern struct mpq_archive_s; + +extern(C) { + +/* libmpq__generic information about library. */ +char *libmpq__version(); + +/* libmpq__generic mpq archive information. */ +int libmpq__archive_open(mpq_archive_s **mpq_archive, char *mpq_filename, off_t archive_offset); +int libmpq__archive_close(mpq_archive_s *mpq_archive); +int libmpq__archive_packed_size(mpq_archive_s *mpq_archive, off_t *packed_size); +int libmpq__archive_unpacked_size(mpq_archive_s *mpq_archive, off_t *unpacked_size); +int libmpq__archive_offset(mpq_archive_s *mpq_archive, off_t *offset); +int libmpq__archive_version(mpq_archive_s *mpq_archive, uint *version_); +int libmpq__archive_files(mpq_archive_s *mpq_archive, uint *files); + +/* libmpq__generic file processing functions. */ +int libmpq__file_packed_size(mpq_archive_s *mpq_archive, uint file_number, off_t *packed_size); +int libmpq__file_unpacked_size(mpq_archive_s *mpq_archive, uint file_number, off_t *unpacked_size); +int libmpq__file_offset(mpq_archive_s *mpq_archive, uint file_number, off_t *offset); +int libmpq__file_blocks(mpq_archive_s *mpq_archive, uint file_number, uint *blocks); +int libmpq__file_encrypted(mpq_archive_s *mpq_archive, uint file_number, uint *encrypted); +int libmpq__file_compressed(mpq_archive_s *mpq_archive, uint file_number, uint *compressed); +int libmpq__file_imploded(mpq_archive_s *mpq_archive, uint file_number, uint *imploded); +int libmpq__file_number(mpq_archive_s *mpq_archive, char *filename, uint *number); +int libmpq__file_read(mpq_archive_s *mpq_archive, uint file_number, ubyte *out_buf, off_t out_size, off_t *transferred); + +/* libmpq__generic block processing functions. */ +int libmpq__block_open_offset(mpq_archive_s *mpq_archive, uint file_number); +int libmpq__block_close_offset(mpq_archive_s *mpq_archive, uint file_number); +int libmpq__block_unpacked_size(mpq_archive_s *mpq_archive, uint file_number, uint block_number, off_t *unpacked_size); +int libmpq__block_read(mpq_archive_s *mpq_archive, uint file_number, uint block_number, ubyte *out_buf, off_t out_size, off_t *transferred); + +} + + +/** exception class for failed libmpq calls */ +class MPQException : Exception { + const string[] Errors = [ + "unknown error", + "open error on file", + "close error on file", + "lseek error on file", + "read error on file", + "write error on file", + "memory allocation error", + "format errror", + "init() wasn't called", + "buffer size is to small", + "file or block does not exist in archive", + "we don't know the decryption seed", + "error on unpacking file"]; + + public int errno; + this(char[] fnname = "unknown_function", int errno = 0) { + + this.errno = errno; + if (-errno >= Errors.length) + errno = 0; + super(std.string.format("Error in %s(): %s (%d)", + fnname, Errors[-errno], errno)); + } +} + + +/** template to wrap function calls and throw exceptions in case of error + * + * thanks for the idea to while(nan) blog, + * http://while-nan.blogspot.com/2007/06/wrapping-functions-for-fun-and-profit.html + * + * use: MPQ_CHECKERR(libmpq__archive_open)(&m, "foo.mpq", -1); + * returns the retval of archive_open on success; + * throws an MPQException on failure. + * + * @param Fn libmpq__function reference + * @param args libmpq__function parameters + * @return return value of libmpq__function on success + * @throw MPQException on error + */ +int MPQ_CHECKERR(alias Fn)(ParameterTypeTuple!(Fn) args) +{ + int result = Fn(args); + if (result < 0) { + /* XXX: relying on non-specified stringof() behaviour */ + throw new MPQException((&Fn).stringof[2..$], result); + } + return result; +} + + +/** mixin alias to wrap library functions into MPQ_CHECKERR. + * + * alias mpq.func_name(...) to MPQ_CHECKERR(libmpq__func_name)(...) + * @param func_name name of the function to be wrapped + */ +template MPQ_FUNC(char[] func_name) { + const char[] MPQ_FUNC = "alias MPQ_CHECKERR!(libmpq__" ~ func_name ~ ") " ~ func_name ~ ";"; +} + +alias libmpq__version libversion; /* must be direct alias because it returns char*, not error int */ +mixin(MPQ_FUNC!("archive_open")); +mixin(MPQ_FUNC!("archive_close")); +mixin(MPQ_FUNC!("archive_packed_size")); +mixin(MPQ_FUNC!("archive_unpacked_size")); +mixin(MPQ_FUNC!("archive_offset")); +mixin(MPQ_FUNC!("archive_version")); +mixin(MPQ_FUNC!("archive_files")); +mixin(MPQ_FUNC!("file_packed_size")); +mixin(MPQ_FUNC!("file_unpacked_size")); +mixin(MPQ_FUNC!("file_offset")); +mixin(MPQ_FUNC!("file_blocks")); +mixin(MPQ_FUNC!("file_encrypted")); +mixin(MPQ_FUNC!("file_compressed")); +mixin(MPQ_FUNC!("file_imploded")); +mixin(MPQ_FUNC!("file_number")); +mixin(MPQ_FUNC!("file_read")); +mixin(MPQ_FUNC!("block_open_offset")); +mixin(MPQ_FUNC!("block_close_offset")); +mixin(MPQ_FUNC!("block_unpacked_size")); +mixin(MPQ_FUNC!("block_read")); + +/** getter function named name for returning archive_* single values: + * + * Archive.() { return libmpq__archive_() } + * + * @param type return type for the original function reference + * @param name name of the original function + * @param name2 name for the prototype (defaults to name, used for "version") + * @return getter function mixin + */ +template MPQ_A_GET(char[] type, char[] name, char[] name2 = name) { + const char[] MPQ_A_GET = type ~ " " ~ name2 ~ "() { " ~ + type ~ " ret; " ~ + "archive_" ~ name ~ "(m, &ret); return ret;" ~ + "}"; +} + +/** wrapper class for an MPQ Archive + * + * syntax: auto a = new mpq.Archive("somefile.mpq"); + */ +class Archive { + mpq_archive_s *m; + File listfile; + char[][] listfiledata; + + this(char[] archivename, off_t offset = -1) { + archive_open(&m, toStringz(archivename), offset); + } + + mixin(MPQ_A_GET!("off_t", "packed_size")); + mixin(MPQ_A_GET!("off_t", "unpacked_size")); + mixin(MPQ_A_GET!("off_t", "offset")); + mixin(MPQ_A_GET!("uint", "version", "version_")); + mixin(MPQ_A_GET!("uint", "files")); + + ~this() { + archive_close(m); + } + + mpq_archive_s* archive() { + return m; + } + + File opIndex(char[] fname) { + return new File(this, fname); + } + File opIndex(int fno) { + return new File(this, fno); + } + + char[][] filelist() { + try { + if (!listfile) { + listfile = this["(listfile)"]; + listfiledata = (cast(char[])listfile.read()).splitlines(); + } + return listfiledata; + } catch (MPQException e) { + return []; + } + } + + /+uint filenumber(char[] filename) { + try { + if (!listfile) { + listfile = this["(listfile)"]; + listfiledata = (cast(char[])listfile.read()).splitlines(); + } + return listfiledata; + } catch (MPQException e) { + return []; + } + }+/ + +} + + +/** getter function named name for returning file_* single values: + * + * File.() { return libmpq__file_() } + * + * @param type return type for the original function reference + * @param name name of the original function + * @param name2 name for the prototype (defaults to name, used for "version") + * @return getter function mixin + */ +template MPQ_F_GET(char[] type, char[] name, char[] name2 = name) { + const char[] MPQ_F_GET = type ~ " " ~ name2 ~ "() { " ~ + type ~ " ret; " ~ + "file_" ~ name ~ "(am, fileno, &ret); " ~ + "return ret;" ~ + "}"; +} + +/** wrapper class for a single file in an MPQ Archive + * + * syntax: + * auto a = new mpq.Archive("somefile.mpq"); + * auto f = a["(listfile)"]; + * auto f2 = a[0]; + * auto f3 = new File(a, "(listfile)"); + */ +class File { + Archive a; + mpq_archive_s* am; + char[] filename; + uint fileno; + + this(Archive a, int fileno) { + this.a = a; + this.am = a.archive(); + if (fileno >= a.files) { + throw new MPQException(format("File(%d)", fileno), + LIBMPQ_ERROR_EXIST); + } + this.filename = format("file%04d.xxx", fileno); + this.fileno = fileno; + } + + this(Archive a, char[] filename) { + this.a = a; + this.am = a.archive(); + this.filename = filename; + /* this line will throw an exception when the file is not there */ + mpq.file_number(am, toStringz(filename), &this.fileno); + } + + mixin(MPQ_F_GET!("off_t", "packed_size")); + mixin(MPQ_F_GET!("off_t", "unpacked_size")); + mixin(MPQ_F_GET!("off_t", "offset")); + mixin(MPQ_F_GET!("uint", "blocks")); + mixin(MPQ_F_GET!("uint", "encrypted")); + mixin(MPQ_F_GET!("uint", "compressed")); + mixin(MPQ_F_GET!("uint", "imploded")); + + uint no() { return fileno; } + char[] name() { return filename; } + + ubyte[] read() { + ubyte[] content; + content.length = this.unpacked_size(); + off_t trans; + mpq.file_read(am, fileno, content.ptr, content.length, &trans); + content.length = trans; + return content; + } +} diff --git a/samples/DTrace/counts.d b/samples/DTrace/counts.d new file mode 100644 index 00000000..13725d99 --- /dev/null +++ b/samples/DTrace/counts.d @@ -0,0 +1,23 @@ +/* + * This software is in the public domain. + * + * $Id: counts.d 10510 2005-08-15 01:46:19Z kateturner $ + */ + +#pragma D option quiet + +self int tottime; +BEGIN { + tottime = timestamp; +} + +php$target:::function-entry + @counts[copyinstr(arg0)] = count(); +} + +END { + printf("Total time: %dus\n", (timestamp - tottime) / 1000); + printf("# calls by function:\n"); + printa("%-40s %@d\n", @counts); +} + diff --git a/samples/DTrace/javascript-trace.d b/samples/DTrace/javascript-trace.d new file mode 100644 index 00000000..0acbaa97 --- /dev/null +++ b/samples/DTrace/javascript-trace.d @@ -0,0 +1,73 @@ +/* -*- Mode: dtrace-script; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Copyright (C) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * javascript provider probes + * + * function-entry (filename, classname, funcname) + * function-info (filename, classname, funcname, lineno, + * runfilename, runlineno) + * function-args (filename, classname, funcname, argc, argv, argv0, + * argv1, argv2, argv3, argv4) + * function-rval (filename, classname, funcname, lineno, rval, rval0) + * function-return (filename, classname, funcname) + * object-create-start (filename, classname) + * object-create (filename, classname, *object, rlineno) + * object-create-done (filename, classname) + * object-finalize (NULL, classname, *object) + * execute-start (filename, lineno) + * execute-done (filename, lineno) + */ + +provider javascript { + probe function__entry(char *, char *, char *); + probe function__info(char *, char *, char *, int, char *, int); + probe function__args(char *, char *, char *, int, void *, void *, void *, + void *, void *, void *); + probe function__rval(char *, char *, char *, int, void *, void *); + probe function__return(char *, char *, char *); + probe object__create__start(char *, char *); + probe object__create__done(char *, char *); + /* XXX must use unsigned longs here instead of uintptr_t for OS X + (Apple radar: 5194316 & 5565198) */ + probe object__create(char *, char *, unsigned long, int); + probe object__finalize(char *, char *, unsigned long); + probe execute__start(char *, int); + probe execute__done(char *, int); +}; + +/* +#pragma D attributes Unstable/Unstable/Common provider mozilla provider +#pragma D attributes Private/Private/Unknown provider mozilla module +#pragma D attributes Private/Private/Unknown provider mozilla function +#pragma D attributes Unstable/Unstable/Common provider mozilla name +#pragma D attributes Unstable/Unstable/Common provider mozilla args +*/ + diff --git a/samples/DTrace/probes.d b/samples/DTrace/probes.d new file mode 100644 index 00000000..483f174d --- /dev/null +++ b/samples/DTrace/probes.d @@ -0,0 +1,93 @@ +/* ---------- + * DTrace probes for PostgreSQL backend + * + * Copyright (c) 2006-2009, PostgreSQL Global Development Group + * + * $PostgreSQL: pgsql/src/backend/utils/probes.d,v 1.11 2009/04/02 20:59:10 momjian Exp $ + * ---------- + */ + + +/* + * Typedefs used in PostgreSQL. + * + * NOTE: Do not use system-provided typedefs (e.g. uintptr_t, uint32_t, etc) + * in probe definitions, as they cause compilation errors on Mac OS X 10.5. + */ +#define LocalTransactionId unsigned int +#define LWLockId int +#define LWLockMode int +#define LOCKMODE int +#define BlockNumber unsigned int +#define Oid unsigned int +#define ForkNumber int +#define bool char + +provider postgresql { + + probe transaction__start(LocalTransactionId); + probe transaction__commit(LocalTransactionId); + probe transaction__abort(LocalTransactionId); + + probe lwlock__acquire(LWLockId, LWLockMode); + probe lwlock__release(LWLockId); + probe lwlock__wait__start(LWLockId, LWLockMode); + probe lwlock__wait__done(LWLockId, LWLockMode); + probe lwlock__condacquire(LWLockId, LWLockMode); + probe lwlock__condacquire__fail(LWLockId, LWLockMode); + + probe lock__wait__start(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, LOCKMODE); + probe lock__wait__done(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, LOCKMODE); + + probe query__parse__start(const char *); + probe query__parse__done(const char *); + probe query__rewrite__start(const char *); + probe query__rewrite__done(const char *); + probe query__plan__start(); + probe query__plan__done(); + probe query__execute__start(); + probe query__execute__done(); + probe query__start(const char *); + probe query__done(const char *); + probe statement__status(const char *); + + probe sort__start(int, bool, int, int, bool); + probe sort__done(bool, long); + + probe buffer__read__start(ForkNumber, BlockNumber, Oid, Oid, Oid, bool, bool); + probe buffer__read__done(ForkNumber, BlockNumber, Oid, Oid, Oid, bool, bool, bool); + probe buffer__flush__start(ForkNumber, BlockNumber, Oid, Oid, Oid); + probe buffer__flush__done(ForkNumber, BlockNumber, Oid, Oid, Oid); + + probe buffer__checkpoint__start(int); + probe buffer__checkpoint__sync__start(); + probe buffer__checkpoint__done(); + probe buffer__sync__start(int, int); + probe buffer__sync__written(int); + probe buffer__sync__done(int, int, int); + probe buffer__write__dirty__start(ForkNumber, BlockNumber, Oid, Oid, Oid); + probe buffer__write__dirty__done(ForkNumber, BlockNumber, Oid, Oid, Oid); + + probe deadlock__found(); + + probe checkpoint__start(int); + probe checkpoint__done(int, int, int, int, int); + probe clog__checkpoint__start(bool); + probe clog__checkpoint__done(bool); + probe subtrans__checkpoint__start(bool); + probe subtrans__checkpoint__done(bool); + probe multixact__checkpoint__start(bool); + probe multixact__checkpoint__done(bool); + probe twophase__checkpoint__start(); + probe twophase__checkpoint__done(); + + probe smgr__md__read__start(ForkNumber, BlockNumber, Oid, Oid, Oid); + probe smgr__md__read__done(ForkNumber, BlockNumber, Oid, Oid, Oid, int, int); + probe smgr__md__write__start(ForkNumber, BlockNumber, Oid, Oid, Oid); + probe smgr__md__write__done(ForkNumber, BlockNumber, Oid, Oid, Oid, int, int); + + probe xlog__insert(unsigned char, unsigned char); + probe xlog__switch(); + probe wal__buffer__write__dirty__start(); + probe wal__buffer__write__dirty__done(); +}; diff --git a/samples/Shell/filenames/Dockerfile b/samples/Dockerfile/filenames/Dockerfile similarity index 100% rename from samples/Shell/filenames/Dockerfile rename to samples/Dockerfile/filenames/Dockerfile diff --git a/samples/Eiffel/application.e b/samples/Eiffel/application.e new file mode 100644 index 00000000..16426905 --- /dev/null +++ b/samples/Eiffel/application.e @@ -0,0 +1,44 @@ +note + description : "nino application root class" + date : "$Date$" + revision : "$Revision$" + +class + APPLICATION + +inherit + ARGUMENTS + + HTTP_SERVER_SHARED_CONFIGURATION + +create + make + +feature {NONE} -- Initialization + + make + -- Run application. + local + l_server : HTTP_SERVER + l_cfg: HTTP_SERVER_CONFIGURATION + l_http_handler : HTTP_HANDLER + do + create l_cfg.make + l_cfg.http_server_port := 9_000 + l_cfg.document_root := default_document_root + set_server_configuration (l_cfg) + debug ("nino") + l_cfg.set_is_verbose (True) + end + + create l_server.make (l_cfg) + create {APPLICATION_CONNECTION_HANDLER} l_http_handler.make (l_server) + l_server.setup (l_http_handler) + end + +feature -- Access + + default_document_root: STRING = "webroot" + +end + diff --git a/samples/Eiffel/book_collection.e b/samples/Eiffel/book_collection.e new file mode 100644 index 00000000..8959455a --- /dev/null +++ b/samples/Eiffel/book_collection.e @@ -0,0 +1,82 @@ +class + BOOK_COLLECTION + +create + make + +feature {NONE} -- Initialization + + make (a_name: STRING_32) + -- Create a book collection with `a_name' as `name'. + do + set_name (a_name) + create book_index.make (10) + ensure + name_set: name = a_name + end + +feature -- Access + + name: STRING_32 + -- Name. + + books: LIST [BOOK] + -- collection of book. + do + create {LINKED_LIST [BOOK]} Result.make + across + book_index as it + loop + Result.append (it.item) + end + end + + books_by_author (a_author: STRING_32): LIST [BOOK] + -- Books wrote by `a_author' in this collection. + do + if attached book_index [a_author] as l_result then + Result := l_result + else + create {LINKED_LIST [BOOK]} Result.make + end + end + +feature -- Change + + set_name (a_name: STRING_32) + -- Set `name' with `a_name'. + do + name := a_name + ensure + name_set: name = a_name + end + + add_book (a_book: BOOK) + -- Extend collection with `a_book'. + local + l: detachable LIST [BOOK] + do + l := book_index.at (a_book.author.name) + if l = Void then + create {LINKED_LIST [BOOK]} l.make + book_index.put (l, a_book.author.name) + end + l.force (a_book) + end + + add_books (book_list: like books) + -- Append collection with `book_list'. + do + across + book_list as it + loop + add_book (it.item) + end + end + +feature {NONE} -- Implementation + + book_index: HASH_TABLE [LIST [BOOK], STRING_32] + -- Association of author name and its books. + +end -- class BOOK_COLLECTION diff --git a/samples/Eiffel/git_checkout_command.e b/samples/Eiffel/git_checkout_command.e new file mode 100644 index 00000000..f78747d2 --- /dev/null +++ b/samples/Eiffel/git_checkout_command.e @@ -0,0 +1,41 @@ +note + description: "Git checkout command." + author: "Olivier Ligot" + +class + GIT_CHECKOUT_COMMAND + +inherit + GIT_COMMAND + +create + make, + make_master + +feature {NONE} -- Initialization + + make (a_branch: STRING) + -- Checkout the branch `a_branch'. + do + initialize + arguments.force_last (a_branch) + branch := a_branch + ensure + branch_set: branch = a_branch + end + + make_master + -- Checkout the master branch. + do + make ("master") + end + +feature -- Access + + branch: STRING + -- Branch to checkout + + name: STRING = "checkout" + -- Git subcommand name + +end diff --git a/samples/Elixir/filenames/mix.lock b/samples/Elixir/filenames/mix.lock new file mode 100644 index 00000000..830b074c --- /dev/null +++ b/samples/Elixir/filenames/mix.lock @@ -0,0 +1,10 @@ +%{"cowboy": {:hex, :cowboy, "1.0.0"}, + "cowlib": {:hex, :cowlib, "1.0.1"}, + "hackney": {:hex, :hackney, "0.14.3"}, + "hound": {:hex, :hound, "0.6.0"}, + "httpoison": {:hex, :httpoison, "0.5.0"}, + "idna": {:hex, :idna, "1.0.1"}, + "phoenix": {:hex, :phoenix, "0.10.0"}, + "plug": {:hex, :plug, "0.11.1"}, + "poison": {:hex, :poison, "1.3.1"}, + "ranch": {:hex, :ranch, "1.0.0"}} diff --git a/samples/Emacs Lisp/.emacs.desktop b/samples/Emacs Lisp/.emacs.desktop new file mode 100644 index 00000000..499e44bb --- /dev/null +++ b/samples/Emacs Lisp/.emacs.desktop @@ -0,0 +1,29 @@ +;; -*- mode: emacs-lisp; coding: emacs-mule; -*- +;; -------------------------------------------------------------------------- +;; Desktop File for Emacs +;; -------------------------------------------------------------------------- +;; Created Sat Jan 3 12:46:35 2015 +;; Desktop file format version 206 +;; Emacs version 24.3.1 + +;; Global section: +(setq desktop-missing-file-warning nil) +(setq tags-file-name nil) +(setq tags-table-list nil) +(setq search-ring nil) +(setq regexp-search-ring nil) +(setq register-alist nil) +(setq file-name-history nil) + +;; Buffer section -- buffers listed in same order as in buffer list: +(desktop-create-buffer 206 + "/home/foo/bar" + "bar" + 'fundamental-mode + nil + 11572 + '(11554 nil) + nil + nil + '((buffer-file-coding-system . undecided-unix))) + diff --git a/samples/Erlang/filenames/rebar.config b/samples/Erlang/filenames/rebar.config new file mode 100644 index 00000000..91d3dff4 --- /dev/null +++ b/samples/Erlang/filenames/rebar.config @@ -0,0 +1,260 @@ +%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% ex: ts=4 sw=4 ft=erlang et +%% This is a sample rebar.conf file that shows examples of some of rebar's +%% options. + +%% == Core == + +%% Extend list of always recursive commands +{recursive_cmds, []}. + +%% Check required ERTS or OTP release version +{require_erts_vsn, ".*"}. +{require_otp_vsn, ".*"}. +{require_min_otp_vsn, ".*"}. + +%% Additional library directories to add to the code path +{lib_dirs, []}. + +%% == Erlang Compiler == + +%% Erlang files to compile before the rest. Rebar automatically compiles +%% parse_transforms and custom behaviours before anything other than the files +%% in this list. +{erl_first_files, ["src/mymib1.erl", "src/mymib2.erl"]}. + +%% Erlang compiler options +{erl_opts, [no_debug_info, + {i, "myinclude"}, + {src_dirs, ["src", "src2", "src3"]}, + {platform_define, + "(linux|solaris|freebsd|darwin)", 'HAVE_SENDFILE'}, + {platform_define, "(linux|freebsd)", 'BACKLOG', 128}, + {platform_define, "R13", 'old_inets'}]}. + +%% MIB Options? +{mib_opts, []}. + +%% SNMP mibs to compile first? +{mib_first_files, []}. + +%% leex options +{xrl_opts, []}. + +%% leex files to compile first +{xrl_first_files, []}. + +%% yecc options +{yrl_opts, []}. + +%% yecc files to compile first +{yrl_first_files, []}. + +%% == EDoc == + +%% EDoc options +{edoc_opts, []}. + +%% == Port Compiler == + +%% Port compilation environment variables. See rebar_port_compiler.erl for +%% more info. Default is `[]' +{port_env, [{"CFLAGS", "$CFLAGS -Ifoo"}, + {"freebsd", "LDFLAGS", "$LDFLAGS -lfoo"}]}. + +%% port_specs +%% List of filenames or wildcards to be compiled. May also contain a tuple +%% consisting of a regular expression to be applied against the system +%% architecture as a filter. +{port_specs, [{"priv/so_name.so", ["c_src/*.c"]}, + {"linux", "priv/hello_linux", ["c_src/hello_linux.c"]}, + {"linux", "priv/hello_linux", ["c_src/*.c"], [{env, []}]}]}. + +%% == escriptize == +{escript_name, "application"}. +{escript_incl_apps, []}. +{escript_shebang, "#!/usr/bin/env escript\n"}. +{escript_comment, "%%\n"}. +{escript_emu_args, "%%! -pa application/application/ebin\n"}. + +%% == LFE Compiler == + +%% LFE files to compile before the rest +{lfe_first_files, []}. + +%% Options for the LFE compiler: reuse {erl_opts, []} + +%% == ErlyDTL Compiler == + +%% Options for the ErlyDTL compiler +{erlydtl_opts, []}. + +%% == Proto compiler == +{proto_opts, [ + {compiler, protobuffs}, + {src_dirs, ["src"]} +]}. +%% Available compilers for protocol buffer files (*.proto): +%% protobuffs (default) +%% gpb +%% Optional src_dirs which is a list of directories where +%% to look for .proto files, default is src + +%% Options for the gpb protocol buffer compiler, +%% if selected by the proto_compiler option +{gpb_opts, []}. + +%% == EUnit == + +%% Options for eunit:test() +{eunit_opts, []}. + +%% Additional compile options for eunit. erl_opts is also used +{eunit_compile_opts, []}. + +%% Same as erl_first_files, but used only when running 'eunit' +{eunit_first_files, []}. + +%% == Cover == + +%% Whether to enable coverage reporting. Default is `false' +{cover_enabled, false}. + +%% Whether to print coverage report to console. Default is `false' +{cover_print_enabled, false}. + +%% Whether to export coverage report to file. Default is `false' +{cover_export_enabled, false}. + +%% == Common Test == + +%% Override the default "test" directory in which SUITEs are located +{ct_dir, "itest"}. + +%% Override the default "logs" directory in which SUITEs are logged +{ct_log_dir, "test/logs"}. + +%% Option to pass extra parameters when launching Common Test +{ct_extra_params, "-boot start_sasl -s myapp"}. + +%% Option to use short names (i.e., -sname test) when starting ct +{ct_use_short_names, true}. + +%% == QuickCheck == + +%% If qc_mod is unspecified, rebar tries to detect Triq or EQC +{qc_opts, [{qc_mod, module()}, Options]}. + +%% Additional compile options for qc. erl_opts is also used +{qc_compile_opts, []}. + +%% Same as erl_first_files, but used only when running 'qc' +{qc_first_files, []}. + +%% == Cleanup == + +%% Which files to cleanup +{clean_files, ["file", "file2"]}. + +%% == OTP Applications == + +%% Enable validation of the OTP app module list. Default is 'true' +{validate_app_modules, true}. + +%% == Dependencies == + +%% Where to put any downloaded dependencies. Default is "deps" +{deps_dir, "deps"}. + +%% What dependencies we have, dependencies can be of 3 forms, an application +%% name as an atom, eg. mochiweb, a name and a version (from the .app file), or +%% an application name, a version and the SCM details on how to fetch it (SCM +%% type, location and revision). +%% Rebar currently supports git, hg, bzr, svn, rsync, fossil, and p4. +{deps, [app_name, + {rebar, "1.0.*"}, + {rebar, ".*", + {git, "git://github.com/rebar/rebar.git"}}, + {rebar, ".*", + {git, "git://github.com/rebar/rebar.git", "Rev"}}, + {rebar, "1.0.*", + {git, "git://github.com/rebar/rebar.git", {branch, "master"}}}, + {rebar, "1.0.0", + {git, "git://github.com/rebar/rebar.git", {tag, "1.0.0"}}}, + %% Dependencies can be marked as 'raw'. Rebar does not require + %% such dependencies to have a standard Erlang/OTP layout + %% which assumes the presence of either + %% "src/dependency_name.app.src" or "ebin/dependency_name.app" + %% files. + %% + %% 'raw' dependencies can still contain 'rebar.config' and + %% even can have the proper OTP directory layout, but they + %% won't be compiled. + %% + %% Only a subset of rebar commands will be executed on the + %% 'raw' subdirectories: get-deps, update-deps, check-deps, + %% list-deps and delete-deps. + {rebar, "", + {git, "git://github.com/rebar/rebar.git", {branch, "master"}}, + [raw]}, + {app_name, ".*", {hg, "https://www.example.org/url"}}, + {app_name, ".*", {rsync, "Url"}}, + {app_name, ".*", {svn, "https://www.example.org/url"}}, + {app_name, ".*", {svn, "svn://svn.example.org/url"}}, + {app_name, ".*", {bzr, "https://www.example.org/url", "Rev"}}, + {app_name, ".*", {fossil, "https://www.example.org/url"}}, + {app_name, ".*", {fossil, "https://www.example.org/url", "Vsn"}}, + {app_name, ".*", {p4, "//depot/subdir/app_dir"}}]}. + +%% == Subdirectories == + +%% Subdirectories? +{sub_dirs, ["dir1", "dir2"]}. + +%% == Plugins == + +%% Plugins you wish to include. +%% These can include any module on the code path, including deps. +%% Alternatively, plugins can be placed as source files in the plugin_dir, in +%% which case they will be compiled and loaded dynamically at runtime. +{plugins, [plugin1, plugin2]}. + +%% Override the directory in which plugin sources can be found. +%% Defaults to ./plugins +{plugin_dir, "some_other_directory"}. + + +%% == Pre/Post Command Hooks == + +{pre_hooks, [{clean, "./prepare_package_files.sh"}, + {"linux", compile, "c_src/build_linux.sh"}, + {compile, "escript generate_headers"}, + {compile, "escript check_headers"}]}. + +{post_hooks, [{clean, "touch file1.out"}, + {"freebsd", compile, "c_src/freebsd_tweaks.sh"}, + {eunit, "touch file2.out"}, + {compile, "touch postcompile.out"}]}. + +%% == xref == + +{xref_warnings, false}. + +%% optional extra paths to include in xref:set_library_path/2. +%% specified relative location of rebar.config. +%% e.g. {xref_extra_paths,["../gtknode/src"]} +{xref_extra_paths,[]}. + +%% xref checks to run +{xref_checks, [undefined_function_calls, undefined_functions, + locals_not_used, exports_not_used, + deprecated_function_calls, deprecated_functions]}. + +%% Optional custom xref queries (xref manual has details) specified as +%% {xref_queries, [{query_string(), expected_query_result()},...]} +%% The following for example removes all references to mod:*foo/4 +%% functions from undefined external function calls as those are in a +%% generated module +{xref_queries, + [{"(XC - UC) || (XU - X - B" + " - (\"mod\":\".*foo\"/\"4\"))",[]}]}. diff --git a/samples/Erlang/filenames/rebar.config.lock b/samples/Erlang/filenames/rebar.config.lock new file mode 100644 index 00000000..1627a9b1 --- /dev/null +++ b/samples/Erlang/filenames/rebar.config.lock @@ -0,0 +1,158 @@ +%% THIS FILE IS GENERATED. DO NOT EDIT IT MANUALLY %% + +{sub_dirs,["rel","apps/riak"]}. +{require_otp_vsn,"R16|17"}. +{cover_enabled,true}. +{lib_dirs,["apps/riak"]}. +{erl_opts,[debug_info,fail_on_warning]}. +{eunit_opts,[verbose]}. +{erlydtl_opts,[{compiler_options,[report,return,debug_info]}]}. +{deps,[{rebar_lock_deps_plugin,".*", + {git,"git://github.com/seth/rebar_lock_deps_plugin.git", + "7a5835029c42b8138325405237ea7e8516a84800"}}, + {node_package,".*", + {git,"git://github.com/basho/node_package.git", + "a829631eccebe3c1d7657a0075584f55bf342977"}}, + {goldrush,".*", + {git,"git://github.com/DeadZen/goldrush.git", + "71e63212f12c25827e0c1b4198d37d5d018a7fec"}}, + {lager,".*", + {git,"git://github.com/basho/lager.git", + "b6b6cebcb27ccff8acc59ae775acebc2f52e4926"}}, + {syslog,".*", + {git,"git://github.com/Vagabond/erlang-syslog.git", + "918c9b453e0811b24f2c99b35b712b0ef9f29c7e"}}, + {lager_syslog,".*", + {git,"git://github.com/basho/lager_syslog.git", + "fa2e7e3daee0d0a59dadb820fd3381eac4a65770"}}, + {cluster_info,".*", + {git,"git://github.com/basho/cluster_info.git", + "e231144ca32dc83317be3360a4a259c73826b08a"}}, + {sidejob,".*", + {git,"git://github.com/basho/sidejob.git", + "c5aabba2d7daa80c340e110902bbcfcb552ccdcf"}}, + {erlang_js,".*", + {git,"git://github.com/basho/erlang_js.git", + "07467d899ab90a2b719ad19ab0be0048c1c8d873"}}, + {meck,".*", + {git,"git://github.com/basho/meck.git", + "dde759050eff19a1a80fd854d7375174b191665d"}}, + {getopt,".*", + {git,"git://github.com/jcomellas/getopt.git", + "659a28f4145bc9843598972854299dc4ea77e4cb"}}, + {neotoma,".*", + {git,"git://github.com/seancribbs/neotoma.git", + "760928ec8870da02eb11bccb501e2700925d06c6"}}, + {cuttlefish,".*", + {git,"git://github.com/basho/cuttlefish.git", + "c92c8325aeaea6b6ba7516bbd434f8e408f87d60"}}, + {bitcask,".*", + {git,"git://github.com/basho/bitcask.git", + "c74d0c43fdefdd435f7621ddf1fc2995b5bd123c"}}, + {eper,".*", + {git,"git://github.com/basho/eper.git", + "7222ecaebceb5422e74a9c1503043bbc6036f6b7"}}, + {edown,".*", + {git,"git://github.com/uwiger/edown.git", + "d62ec85281e451a46ba30045917c119d65b72a84"}}, + {sext,".*", + {git,"git://github.com/basho/sext.git", + "846b9cc22456287a572efd4c924203d77778670f"}}, + {poolboy,".*", + {git,"git://github.com/basho/poolboy.git", + "8bb45fbc715c5f493642a1cc572ec7017d0d5fa3"}}, + {basho_stats,".*", + {git,"git://github.com/basho/basho_stats.git", + "19c532af235ae675439d491b329c55c2f9b02deb"}}, + {riak_sysmon,".*", + {git,"git://github.com/basho/riak_sysmon.git", + "26a58bcaba96d07df885f7b3db4d4306f995ce14"}}, + {eleveldb,".*", + {git,"git://github.com/basho/eleveldb.git", + "0e4e4e7cf3ddc26523a77f853ea9409c1707b26c"}}, + {riak_ensemble,".*", + {git,"git://github.com/basho/riak_ensemble", + "78dc8f623353a212ca3cf12236d1e9ac824bde16"}}, + {pbkdf2,".*", + {git,"git://github.com/basho/erlang-pbkdf2.git", + "7076584f5377e98600a7e2cb81980b2992fb2f71"}}, + {parse_trans,".*", + {git,"git://github.com/uwiger/parse_trans.git", + "82cc00264aa1bad8fc5c0739b7541feb4a843432"}}, + {bear,".*", + {git,"git://github.com/basho/bear.git", + "da820a13c607c3f816ee8b83c587266da5389761"}}, + {folsom,".*", + {git,"git://github.com/basho/folsom.git", + "72944523b6467c9f7add5f1c96dd5020424a2681"}}, + {setup,".*", + {git,"git://github.com/uwiger/setup.git", + "51ee7c9f64d2bbe9dcbb58c278e8fbfd4d0ca5e2"}}, + {exometer_core,".*", + {git,"git://github.com/basho/exometer_core.git", + "b47a5d65d9500c2b8f6ccc50e34005503589ef77"}}, + {clique,".*", + {git,"git://github.com/basho/clique.git", + "3af4db8ea0f74aca42f6713446dcd5915c795a74"}}, + {riak_core,".*", + {git,"git://github.com/basho/riak_core.git", + "044c4e7f8dbfe8c49c45f2f7090adff4cd5aba50"}}, + {riak_pipe,".*", + {git,"git://github.com/basho/riak_pipe.git", + "3c0abc7ba301d57940c5a9c5de368b70429c28ff"}}, + {protobuffs,".*", + {git,"git://github.com/basho/erlang_protobuffs.git", + "f88fc3c6881687432ddd5546b3c7b08009dfb26f"}}, + {riak_pb,".*", + {git,"git://github.com/basho/riak_pb.git", + "78c50efa698f33f7d6ab1c7f5fa4666ec03b46b4"}}, + {mochiweb,".*", + {git,"git://github.com/basho/mochiweb.git", + "ade2a9b29a11034eb550c1d79b4f991bf5ca05ba"}}, + {webmachine,".*", + {git,"git://github.com/basho/webmachine.git", + "7677c240f4a7ed020f4bab48278224966bb42311"}}, + {riak_api,".*", + {git,"git://github.com/basho/riak_api.git", + "2781e66796903bc6847bffcf71a6ba7a05d69275"}}, + {riak_dt,".*", + {git,"git://github.com/basho/riak_dt.git", + "f7981d4ad7407ddc085f133f204dd71bf9d50c56"}}, + {eunit_formatters,".*", + {git,"git://github.com/seancribbs/eunit_formatters", + "96b6ced4d45ba641cbf2c8a8ae9b350dd300bc10"}}, + {riak_kv,".*", + {git,"git://github.com/basho/riak_kv.git", + "404619cb57574cd43e2dc0dc0453884ec6732a99"}}, + {merge_index,".*", + {git,"git://github.com/basho/merge_index.git", + "b701dde5c28956c3b629411e5ff7e50cbb5cb4b3"}}, + {riak_search,".*", + {git,"git://github.com/basho/riak_search.git", + "8fe4a8c020a74c52ee877bf6dd410824b4f79f8b"}}, + {erlydtl,".*", + {git,"git://github.com/evanmiller/erlydtl.git", + "d20b53f04837a1053ed18987f645cb60eae82453"}}, + {riak_control,".*", + {git,"git://github.com/basho/riak_control.git", + "09073ce672260e1ec0ba3999fabed7f319624ba1"}}, + {riaknostic,".*", + {git,"git://github.com/basho/riaknostic.git", + "101d95bddff4b70afcd1dd5442b8c6651887e0a4"}}, + {kvc,".*", + {git,"git://github.com/etrepum/kvc.git", + "5565fe51857747662410cc3c06362ebcf48a2f04"}}, + {ibrowse,".*", + {git,"git://github.com/cmullaparthi/ibrowse.git", + "e8ae353c16d4f0897abb9f80025b52925b974dd1"}}, + {yokozuna,".*", + {git,"git://github.com/basho/yokozuna.git", + "5868266b11f131d14c85495e50f899f3fe8158ba"}}, + {canola,".*", + {git,"git://github.com/basho/canola.git", + "9bdfee88fce20b3a01b7003696b53eb21913d6fb"}}, + {riak_auth_mods,".*", + {git,"git://github.com/basho/riak_auth_mods.git", + "31b8b30e6c215418522eaa615264ae9769a87410"}}]}. +{plugins,[rebar_lock_deps_plugin]}. + diff --git a/samples/Erlang/filenames/rebar.lock b/samples/Erlang/filenames/rebar.lock new file mode 100644 index 00000000..1d3a3982 --- /dev/null +++ b/samples/Erlang/filenames/rebar.lock @@ -0,0 +1,16 @@ +[{<<"goldrush">>, + {git,"git://github.com/DeadZen/goldrush.git", + {ref,"71e63212f12c25827e0c1b4198d37d5d018a7fec"}}, + 1}, + {<<"riak_dt">>, + {git,"git://github.com/helium/riak_dt.git", + {ref,"15d66cb26c2028c1ad1271c359b1d5da213825c3"}}, + 0}, + {<<"lager">>, + {git,"git://github.com/basho/lager.git", + {ref,"d33ccf3b69de09a628fe38b4d7981bb8671b8a4f"}}, + 0}, + {<<"eleveldb">>, + {git,"git://github.com/helium/eleveldb.git", + {ref,"29a5360dc0365b3330dd0cd45b0b8166f3b854be"}}, + 0}]. diff --git a/samples/F#/Combinators.fs b/samples/F#/Combinators.fs new file mode 100644 index 00000000..409c524d --- /dev/null +++ b/samples/F#/Combinators.fs @@ -0,0 +1,49 @@ +namespace Nessos.FsPickler.Combinators + + open Nessos.FsPickler + open Nessos.FsPickler.Json + + /// Json pickling methods + [] + module Json = + + let private jsonSerializer = lazy(FsPickler.CreateJson(omitHeader = true)) + + /// + /// Pickles a value to Json. + /// + /// utilized pickler. + /// input value. + let pickle (pickler : Pickler<'T>) (value : 'T) : string = + jsonSerializer.Value.PickleToString (pickler, value) + + /// + /// Unpickles a value from Json. + /// + /// utilized pickler. + /// input pickle. + let unpickle (pickler : Pickler<'T>) (pickle : string) : 'T = + jsonSerializer.Value.UnPickleOfString (pickler, pickle) + + + /// Bson pickling methods + [] + module Bson = + + let private bsonPickler = lazy(FsPickler.CreateBson()) + + /// + /// Pickles a value to Bson. + /// + /// utilized pickler. + /// input value. + let pickle (pickler : Pickler<'T>) (value : 'T) : byte [] = + bsonPickler.Value.Pickle (pickler, value) + + /// + /// Unpickles a value from bson. + /// + /// utilized pickler. + /// input pickle. + let unpickle (pickler : Pickler<'T>) (pickle : byte []) : 'T = + bsonPickler.Value.UnPickle (pickler, pickle) \ No newline at end of file diff --git a/samples/F#/JsonFormat.fs b/samples/F#/JsonFormat.fs new file mode 100644 index 00000000..cf6aac61 --- /dev/null +++ b/samples/F#/JsonFormat.fs @@ -0,0 +1,65 @@ +namespace Nessos.FsPickler.Json + + open System + open System.IO + open System.Text + + open Newtonsoft.Json + + open Nessos.FsPickler + + /// + /// Factory methods for the Json serialization format. + /// + type JsonPickleFormatProvider internal (indent, omitHeader) as self = + + let isCustomSeq isTopLevelSequence = + isTopLevelSequence && self.OmitHeader && self.UseCustomTopLevelSequenceSeparator + + let mutable sequenceSeparator = " " + + member val Indent = indent with get,set + member val OmitHeader = omitHeader with get,set + member val UseCustomTopLevelSequenceSeparator = false with get,set + + member __.SequenceSeparator + with get () = sequenceSeparator + and set sep = + if sep <> null && String.IsNullOrWhiteSpace sep then + sequenceSeparator <- sep + else + invalidArg "SequenceSeparator" "should be non-null whitespace." + + interface ITextPickleFormatProvider with + member __.Name = "Json" + + // see discussion : https://github.com/nessos/FsPickler/issues/17 + member __.DefaultEncoding = new UTF8Encoding(false) :> Encoding + + member __.CreateWriter (stream, encoding, isTopLevelSequence, leaveOpen) = +#if NET40 + if leaveOpen then raise <| new NotSupportedException("'leaveOpen' not supported in .NET 40.") + let sw = new StreamWriter(stream, encoding) +#else + let sw = new StreamWriter(stream, encoding, 1024, leaveOpen) +#endif + let jw = new JsonTextWriter(sw) + new JsonPickleWriter(jw, __.OmitHeader, __.Indent, isCustomSeq isTopLevelSequence, sequenceSeparator, leaveOpen) :> _ + + member __.CreateReader (stream, encoding, isTopLevelSequence, leaveOpen) = +#if NET40 + if leaveOpen then raise <| new NotSupportedException("'leaveOpen' not supported in .NET 40.") + let sr = new StreamReader(stream, encoding) +#else + let sr = new StreamReader(stream, encoding, true, 1024, leaveOpen) +#endif + let jr = new JsonTextReader(sr) + new JsonPickleReader(jr, __.OmitHeader, isCustomSeq isTopLevelSequence, leaveOpen) :> _ + + member __.CreateWriter (textWriter, isTopLevelSequence, leaveOpen) = + let jw = new JsonTextWriter(textWriter) + new JsonPickleWriter(jw, __.OmitHeader, __.Indent, isCustomSeq isTopLevelSequence, sequenceSeparator, leaveOpen) :> _ + + member __.CreateReader (textReader, isTopLevelSequence, leaveOpen) = + let jr = new JsonTextReader(textReader) + new JsonPickleReader(jr, __.OmitHeader, isCustomSeq isTopLevelSequence, leaveOpen) :> _ \ No newline at end of file diff --git a/samples/F#/JsonReader.fs b/samples/F#/JsonReader.fs new file mode 100644 index 00000000..fdd90d3c --- /dev/null +++ b/samples/F#/JsonReader.fs @@ -0,0 +1,202 @@ +namespace Nessos.FsPickler.Json + + open System + open System.Collections.Generic + open System.Globalization + open System.IO + open System.Numerics + open System.Text + + open Newtonsoft.Json + + open Nessos.FsPickler + + /// + /// Json format deserializer + /// + type internal JsonPickleReader (jsonReader : JsonReader, omitHeader, isTopLevelSequence, leaveOpen) = + + do + jsonReader.CloseInput <- not leaveOpen + jsonReader.SupportMultipleContent <- isTopLevelSequence + + let isBsonReader = match jsonReader with :? Bson.BsonReader -> true | _ -> false + + let mutable depth = 0 + let arrayStack = new Stack () + do arrayStack.Push Int32.MinValue + + // do not write tag if omitting header or array element + let omitTag () = (omitHeader && depth = 0) || arrayStack.Peek() = depth - 1 + + interface IPickleFormatReader with + + member __.BeginReadRoot (tag : string) = + do jsonReader.Read() |> ignore + + if omitHeader then () else + + if jsonReader.TokenType <> JsonToken.StartObject then raise <| new FormatException("invalid json root object.") + else + do jsonReader.MoveNext() + let version = jsonReader.ReadPrimitiveAs false "FsPickler" + if version <> jsonFormatVersion then + let v = Version(version) + raise <| new FormatException(sprintf "Invalid FsPickler format version %O." version) + + let sTag = jsonReader.ReadPrimitiveAs false "type" + if tag <> sTag then + raise <| new InvalidPickleTypeException(tag, sTag) + + member __.EndReadRoot () = + if not omitHeader then jsonReader.Read() |> ignore + + member __.BeginReadObject (tag : string) = + + if not <| omitTag () then + jsonReader.ReadProperty tag + jsonReader.MoveNext () + + if isTopLevelSequence && depth = 0 then + arrayStack.Push depth + depth <- depth + 1 + ObjectFlags.IsSequenceHeader + + else + match jsonReader.TokenType with + | JsonToken.Null -> ObjectFlags.IsNull + | JsonToken.StartArray -> + jsonReader.MoveNext() + arrayStack.Push depth + depth <- depth + 1 + ObjectFlags.IsSequenceHeader + + | JsonToken.StartObject -> + do jsonReader.MoveNext() + depth <- depth + 1 + + if jsonReader.ValueAs () = "_flags" then + jsonReader.MoveNext() + let csvFlags = jsonReader.ValueAs() + jsonReader.MoveNext() + parseFlagCsv csvFlags + else + ObjectFlags.None + + | token -> raise <| new FormatException(sprintf "expected start of Json object but was '%O'." token) + + + member __.EndReadObject () = + if isTopLevelSequence && depth = 1 then + arrayStack.Pop () |> ignore + depth <- depth - 1 + jsonReader.Read() |> ignore + else + match jsonReader.TokenType with + | JsonToken.Null -> () + | JsonToken.EndObject -> depth <- depth - 1 + | JsonToken.EndArray -> + arrayStack.Pop() |> ignore + depth <- depth - 1 + + | token -> raise <| new FormatException(sprintf "expected end of Json object but was '%O'." token) + + if omitHeader && depth = 0 then () + else jsonReader.Read() |> ignore + + member __.SerializeUnionCaseNames = true + + member __.PreferLengthPrefixInSequences = false + member __.ReadNextSequenceElement () = + if isTopLevelSequence && depth = 1 then + jsonReader.TokenType <> JsonToken.None + else + jsonReader.TokenType <> JsonToken.EndArray + + member __.ReadCachedObjectId () = jsonReader.ReadPrimitiveAs false "id" + + member __.ReadBoolean tag = jsonReader.ReadPrimitiveAs (omitTag ()) tag + member __.ReadByte tag = jsonReader.ReadPrimitiveAs (omitTag ()) tag |> byte + member __.ReadSByte tag = jsonReader.ReadPrimitiveAs (omitTag ()) tag |> sbyte + + member __.ReadInt16 tag = jsonReader.ReadPrimitiveAs (omitTag ()) tag |> int16 + member __.ReadInt32 tag = jsonReader.ReadPrimitiveAs (omitTag ()) tag |> int + member __.ReadInt64 tag = jsonReader.ReadPrimitiveAs (omitTag ()) tag + + member __.ReadUInt16 tag = jsonReader.ReadPrimitiveAs (omitTag ()) tag |> uint16 + member __.ReadUInt32 tag = jsonReader.ReadPrimitiveAs (omitTag ()) tag |> uint32 + member __.ReadUInt64 tag = jsonReader.ReadPrimitiveAs (omitTag ()) tag |> uint64 + + member __.ReadSingle tag = + if not <| omitTag () then + jsonReader.ReadProperty tag + jsonReader.MoveNext() + + let value = + match jsonReader.TokenType with + | JsonToken.Float -> jsonReader.ValueAs () |> single + | JsonToken.String -> Single.Parse(jsonReader.ValueAs(), CultureInfo.InvariantCulture) + | _ -> raise <| new FormatException("not a float.") + + jsonReader.Read() |> ignore + value + + member __.ReadDouble tag = + if not <| omitTag () then + jsonReader.ReadProperty tag + jsonReader.MoveNext() + + let value = + match jsonReader.TokenType with + | JsonToken.Float -> jsonReader.ValueAs () + | JsonToken.String -> Double.Parse(jsonReader.ValueAs(), CultureInfo.InvariantCulture) + | _ -> raise <| new FormatException("not a float.") + + jsonReader.Read() |> ignore + value + + member __.ReadChar tag = let value = jsonReader.ReadPrimitiveAs (omitTag ()) tag in value.[0] + member __.ReadString tag = jsonReader.ReadPrimitiveAs (omitTag ()) tag + member __.ReadBigInteger tag = jsonReader.ReadPrimitiveAs (omitTag ()) tag |> BigInteger.Parse + + member __.ReadGuid tag = + if isBsonReader then + jsonReader.ReadPrimitiveAs (omitTag ()) tag + else + jsonReader.ReadPrimitiveAs (omitTag ()) tag |> Guid.Parse + + member __.ReadTimeSpan tag = jsonReader.ReadPrimitiveAs (omitTag ()) tag |> TimeSpan.Parse + member __.ReadDecimal tag = jsonReader.ReadPrimitiveAs (omitTag ()) tag |> decimal + + // BSON spec mandates the use of Unix time; + // this has millisecond precision which results in loss of accuracy w.r.t. ticks + // since the goal of FsPickler is to offer faithful representations of .NET objects + // we choose to override the spec and serialize ticks outright. + // see also https://json.codeplex.com/discussions/212067 + member __.ReadDate tag = + if isBsonReader then + let ticks = jsonReader.ReadPrimitiveAs (omitTag ()) tag + DateTime(ticks) + else + jsonReader.ReadPrimitiveAs (omitTag ()) tag + + member __.ReadBytes tag = + if not <| omitTag () then + jsonReader.ReadProperty tag + jsonReader.Read() |> ignore + + let bytes = + if jsonReader.TokenType = JsonToken.Null then null + elif isBsonReader then jsonReader.ValueAs () + else + let base64 = jsonReader.ValueAs () + Convert.FromBase64String base64 + + jsonReader.Read() |> ignore + + bytes + + member __.IsPrimitiveArraySerializationSupported = false + member __.ReadPrimitiveArray _ _ = raise <| new NotImplementedException() + + member __.Dispose () = (jsonReader :> IDisposable).Dispose() \ No newline at end of file diff --git a/samples/F#/JsonSerializer.fs b/samples/F#/JsonSerializer.fs new file mode 100644 index 00000000..15f4929a --- /dev/null +++ b/samples/F#/JsonSerializer.fs @@ -0,0 +1,85 @@ +namespace Nessos.FsPickler.Json + + open System + + open Nessos.FsPickler + + type internal OAttribute = System.Runtime.InteropServices.OptionalAttribute + type internal DAttribute = System.Runtime.InteropServices.DefaultParameterValueAttribute + + /// + /// Json pickler instance. + /// + type JsonSerializer = + inherit FsPicklerTextSerializer + + val private format : JsonPickleFormatProvider + + /// + /// Initializes a new Json pickler instance. + /// + /// indent out Json pickles. + /// omit FsPickler header in Json pickles. + /// specify a custom type name converter. + new ([] ?indent, [] ?omitHeader, [] ?typeConverter) = + let indent = defaultArg indent false + let omitHeader = defaultArg omitHeader false + let json = new JsonPickleFormatProvider(indent, omitHeader) + { + inherit FsPicklerTextSerializer(json, ?typeConverter = typeConverter) + format = json + } + + /// + /// Gets or sets whether Json output should be indented. + /// + member x.Indent + with get () = x.format.Indent + and set b = x.format.Indent <- b + + /// + /// Gets or sets whether FsPickler headers should be ignored in pickle format. + /// + member x.OmitHeader + with get () = x.format.OmitHeader + and set b = x.format.OmitHeader <- b + + /// + /// Gets or sets a non-null whitespace string that serves as a custom, top-level sequence separator. + /// + member x.SequenceSeparator + with get () = x.format.SequenceSeparator + and set sep = x.format.SequenceSeparator <- sep + + /// + /// Gets or sets whether top-level sequences should be serialized using the custom separator. + /// + member x.UseCustomTopLevelSequenceSeparator + with get () = x.format.UseCustomTopLevelSequenceSeparator + and set e = x.format.UseCustomTopLevelSequenceSeparator <- e + + /// + /// BSON pickler instance. + /// + type BsonSerializer([] ?typeConverter) = + inherit FsPicklerSerializer(new BsonPickleFormatProvider(), ?typeConverter = typeConverter) + + + /// FsPickler static methods. + type FsPickler = + + /// + /// Initializes a new Json pickler instance. + /// + /// indent out Json pickles. + /// omit FsPickler header in Json pickles. + /// specify a custom type name converter. + static member CreateJson([] ?indent, [] ?omitHeader, [] ?typeConverter) = + new JsonSerializer(?indent = indent, ?omitHeader = omitHeader, ?typeConverter = typeConverter) + + /// + /// Initializes a new Bson pickler instance. + /// + /// specify a custom type name converter. + static member CreateBson([] ?typeConverter) = + new BsonSerializer(?typeConverter = typeConverter) \ No newline at end of file diff --git a/samples/F#/JsonWriter.fs b/samples/F#/JsonWriter.fs new file mode 100644 index 00000000..bbb6ff24 --- /dev/null +++ b/samples/F#/JsonWriter.fs @@ -0,0 +1,142 @@ +namespace Nessos.FsPickler.Json + + open System + open System.IO + open System.Collections.Generic + + open Newtonsoft.Json + + open Nessos.FsPickler + + /// + /// Json format serializer. + /// + type internal JsonPickleWriter (jsonWriter : JsonWriter, omitHeader, indented, isTopLevelSequence, separator, leaveOpen) = + + do + jsonWriter.Formatting <- if indented then Formatting.Indented else Formatting.None + jsonWriter.CloseOutput <- not leaveOpen + + let isBsonWriter = match jsonWriter with :? Bson.BsonWriter -> true | _ -> false + + let mutable depth = 0 + let mutable isTopLevelSequenceHead = false + let mutable currentValueIsNull = false + + let arrayStack = new Stack () + do arrayStack.Push Int32.MinValue + + // do not write tag if omitting header or array element + let omitTag () = (omitHeader && depth = 0) || arrayStack.Peek() = depth - 1 + + interface IPickleFormatWriter with + + member __.BeginWriteRoot (tag : string) = + if omitHeader then () else + + jsonWriter.WriteStartObject() + writePrimitive jsonWriter false "FsPickler" jsonFormatVersion + writePrimitive jsonWriter false "type" tag + + member __.EndWriteRoot () = + if not omitHeader then jsonWriter.WriteEnd() + + member __.BeginWriteObject (tag : string) (flags : ObjectFlags) = + + if not <| omitTag () then + jsonWriter.WritePropertyName tag + + if flags.HasFlag ObjectFlags.IsNull then + currentValueIsNull <- true + jsonWriter.WriteNull() + + elif flags.HasFlag ObjectFlags.IsSequenceHeader then + if isTopLevelSequence && depth = 0 then + isTopLevelSequenceHead <- true + else + jsonWriter.WriteStartArray() + + arrayStack.Push depth + depth <- depth + 1 + else + jsonWriter.WriteStartObject() + depth <- depth + 1 + + if flags = ObjectFlags.None then () + else + let flagCsv = mkFlagCsv flags + writePrimitive jsonWriter false "_flags" flagCsv + + member __.EndWriteObject () = + if currentValueIsNull then + currentValueIsNull <- false + else + depth <- depth - 1 + if arrayStack.Peek () = depth then + if isTopLevelSequence && depth = 0 then () + else + jsonWriter.WriteEndArray() + + arrayStack.Pop () |> ignore + else + jsonWriter.WriteEndObject() + + member __.SerializeUnionCaseNames = true + + member __.PreferLengthPrefixInSequences = false + member __.WriteNextSequenceElement hasNext = + if isTopLevelSequence && depth = 1 then + if isTopLevelSequenceHead then + isTopLevelSequenceHead <- false + else + jsonWriter.WriteWhitespace separator + + member __.WriteCachedObjectId id = writePrimitive jsonWriter false "id" id + + member __.WriteBoolean (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value + member __.WriteByte (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value + member __.WriteSByte (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value + + member __.WriteInt16 (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value + member __.WriteInt32 (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value + member __.WriteInt64 (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value + + member __.WriteUInt16 (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value + member __.WriteUInt32 (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value + member __.WriteUInt64 (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value + + member __.WriteSingle (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value + member __.WriteDouble (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value + member __.WriteDecimal (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag (string value) + + member __.WriteChar (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value + member __.WriteString (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value + member __.WriteBigInteger (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag (string value) + + member __.WriteGuid (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value + member __.WriteTimeSpan (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag (string value) + + // BSON spec mandates the use of Unix time; + // this has millisecond precision which results in loss of accuracy w.r.t. ticks + // since the goal of FsPickler is to offer faithful representations of .NET objects + // we choose to override the spec and serialize ticks outright. + // see also https://json.codeplex.com/discussions/212067 + member __.WriteDate (tag : string) value = + if isBsonWriter then + writePrimitive jsonWriter (omitTag ()) tag value.Ticks + else + writePrimitive jsonWriter (omitTag ()) tag value + + member __.WriteBytes (tag : string) (value : byte []) = + if not <| omitTag () then + jsonWriter.WritePropertyName tag + + if obj.ReferenceEquals(value, null) then + jsonWriter.WriteNull() + else + jsonWriter.WriteValue value + + member __.IsPrimitiveArraySerializationSupported = false + member __.WritePrimitiveArray _ _ = raise <| NotSupportedException() + + member __.Dispose () = jsonWriter.Flush() \ No newline at end of file diff --git a/samples/F#/PerformanceTesters.fs b/samples/F#/PerformanceTesters.fs new file mode 100644 index 00000000..c5eb20d2 --- /dev/null +++ b/samples/F#/PerformanceTesters.fs @@ -0,0 +1,68 @@ +namespace Nessos.FsPickler.Tests + + open PerfUtil + open PerfUtil.NUnit + + open NUnit.Framework + + open Nessos.FsPickler + open Nessos.FsPickler.Json + + [] + type PerfTester () = + inherit NUnitPerf () + + let tests = PerfTest.OfModuleMarker () + + override __.PerfTests = tests + + + type ``Serializer Comparison`` () = + inherit PerfTester() + + let fsp = FsPickler.initBinary() + let bfs = new BinaryFormatterSerializer() :> Serializer + let ndc = new NetDataContractSerializer() :> Serializer + let jdn = new JsonDotNetSerializer() :> Serializer + let bdn = new JsonDotNetBsonSerializer () :> Serializer + let pbn = new ProtoBufSerializer() :> Serializer + let ssj = new ServiceStackJsonSerializer() :> Serializer + let sst = new ServiceStackTypeSerializer() :> Serializer + + let comparer = new WeightedComparer(spaceFactor = 0.2, leastAcceptableImprovementFactor = 1.) + let tester = new ImplementationComparer<_>(fsp, [bfs;ndc;jdn;bdn;pbn;ssj;sst], throwOnError = true, warmup = true, comparer = comparer) + + override __.PerfTester = tester :> _ + + + type ``FsPickler Formats Comparison`` () = + inherit PerfTester () + + let binary = FsPickler.initBinary() + let json = FsPickler.initJson() + let bson = FsPickler.initBson() + let xml = FsPickler.initXml() + + let tester = new ImplementationComparer<_>(binary, [json ; bson; xml], warmup = true, throwOnError = false) + + override __.PerfTester = tester :> _ + + + type ``Past FsPickler Versions Comparison`` () = + inherit PerfTester () + + let persistResults = true + let persistenceFile = "fspPerf.xml" + + let fsp = FsPickler.initBinary() + let version = typeof.Assembly.GetName().Version + let comparer = new WeightedComparer(spaceFactor = 0.2, leastAcceptableImprovementFactor = 0.8) + let tester = + new PastImplementationComparer( + fsp, version, historyFile = persistenceFile, throwOnError = true, warmup = true, comparer = comparer) + + override __.PerfTester = tester :> _ + + [] + member __.Persist() = + if persistResults then tester.PersistCurrentResults () \ No newline at end of file diff --git a/samples/F#/PerformanceTests.fs b/samples/F#/PerformanceTests.fs new file mode 100644 index 00000000..c3d01356 --- /dev/null +++ b/samples/F#/PerformanceTests.fs @@ -0,0 +1,207 @@ +namespace Nessos.FsPickler.Tests + + open System + open System.Collections.Generic + + open PerfUtil + + open Nessos.FsPickler + open Nessos.FsPickler.Tests.Serializer + open Nessos.FsPickler.Tests.TestTypes + + module PerformanceTests = + + type Marker = class end + + let guid = Guid.NewGuid() + + [] + let ``Value: Guid`` s = roundtrip guid s + + let date = DateTime.Now + + [] + let ``Value: DateTime`` s = roundtrip date s + + [] + let ``Value: String`` s = roundtrip stringValue s + + + let boxed = box ([| 1 .. 1000 |], "lorem ipsum") + + [] + let ``Boxed Object`` s = roundtrip boxed s + + let fsClass = new Class(42, stringValue) + + [] + let ``Class: Simple F# Class`` s = roundtrip fsClass s + + let serializableClass = new SerializableClass<_>(42, stringValue, [|1..1000|]) + + [] + let ``Class: ISerializable`` s = roundtrip serializableClass s + + let boxedClass = box(Some 42) + + [] + let ``Subtype Resolution`` s = roundtrip boxedClass s + + let floatArray = Array.init 100000 (fun i -> float i) + + [] + let ``Array: Float`` s = roundtrip floatArray s + + let intArray = Array.init 100000 id + + [] + let ``Array: Int`` s = roundtrip intArray s + + let stringArray = Array.init 10000 (fun i -> stringValue + string i) + + [] + let ``Array: String`` s = roundtrip stringArray s + + let kvarr = [|1..10000|] |> Array.map (fun i -> i, string i) + + [] + let ``Array: Key-Value Pairs`` s = roundtrip kvarr s + + let duArray = [| for i in 1 .. 10000 -> (Something ("asdasdasdas", i)) |] + + [] + let ``Array: Discriminated Unions`` s = roundtrip duArray s + + let objArray = + [| + box 2; box 3; box "hello" ; box <| Some 3; box(2,3) ; + box <| new Class(2, stringValue) ; box <| new SerializableClass(2, stringValue, Some 12); + box stringValue + |] + + [] + let ``Array: Objects`` s = roundtrip objArray s + + + let array3D = Array3D.init 100 100 100 (fun i j k -> float (i * j + k)) + + [] + let ``Array: Rank-3 Float`` s = roundtrip array3D s + + let bclDict = dict [ for i in 1 .. 1000 -> (string i, i)] + + [] + let ``.NET Dictionary`` s = roundtrip bclDict s + + let bclStack = new Stack([for i in 1 .. 1000 -> string i]) + + [] + let ``.NET Stack`` s = roundtrip bclStack s + + let bclList = new List([for i in 1 .. 1000 -> string i, i]) + + [] + let ``.NET List`` s = roundtrip bclList s + + let bclSet = new SortedSet<_>([for i in 1 .. 1000 -> string i]) + + [] + let ``.NET Set`` s = roundtrip bclSet s + + let smallTuple = (1, DateTime.Now,"hello") + + [] + let ``FSharp: Tuple Small`` s = roundtrip smallTuple s + + let largeTuple = (stringValue, 1, 2, 3, true, "", Some(3.14, [2]), 3, 2, 1, stringValue) + + [] + let ``FSharp: Tuple Large`` s = + roundtrip largeTuple s + + let intList = [1..1000] + + [] + let ``FSharp: List Int`` s = roundtrip intList s + + let stringList = [ for i in 1 .. 1000 -> stringValue + string i ] + + [] + let ``FSharp: List String`` s = roundtrip stringList s + + let pairList = [ for i in 1 .. 1000 -> (string i, i) ] + + [] + let ``FSharp: List Key-Value`` s = roundtrip pairList s + + let nestedLst = let n = [1..1000] in [for _ in 1 .. 100 -> n] + + [] + let ``FSharp: List Nested`` s = roundtrip nestedLst s + + let union = SomethingElse(stringValue, 42, box (Some 42)) + + [] + let ``FSharp: Union`` s = roundtrip union s + + let record = { Int = 42 ; String = stringValue ; Tuple = (13, "") } + + [] + let ``FSharp: Record`` s = roundtrip record s + + let peano = int2Peano 100 + + [] + let ``FSharp: Peano Rectype`` s = roundtrip peano s + + let closure = (@) [ Some([1..100], Set.ofList [1..100]) ] + + [] + let ``FSharp: Curried Function`` s = roundtrip closure s + + let binTree = mkTree 10 + + [] + let ``FSharp: Binary Tree`` s = roundtrip binTree s + + let intSet = [1..1000] |> List.map string |> set + + [] + let ``FSharp: Set`` s = roundtrip intSet s + + let fsMap = [1..1000] |> Seq.map (fun i -> (string i,i)) |> Map.ofSeq + + [] + let ``FSharp: Map`` s = roundtrip fsMap s + + let testType = typeof> + + [] + let ``Reflection: Type`` s = roundtrip testType s + + let quotationSmall = <@ fun x -> pown 2 x @> + + let quotationLarge = + <@ + async { + let rec fibAsync n = + async { + match n with + | _ when n < 0 -> return invalidArg "negative" "n" + | _ when n < 2 -> return n + | n -> + let! fn = fibAsync (n-1) + let! fnn = fibAsync (n-2) + return fn + fnn + } + + let! values = [1..100] |> Seq.map fibAsync |> Async.Parallel + return Seq.sum values + } + @> + + [] + let ``FSharp: Quotation Small`` s = roundtrip quotationSmall s + + [] + let ``FSharp: Quotation Large`` s = roundtrip quotationLarge s \ No newline at end of file diff --git a/samples/F#/sample.fs b/samples/F#/sample.fs new file mode 100644 index 00000000..2b690f10 --- /dev/null +++ b/samples/F#/sample.fs @@ -0,0 +1,15 @@ +module Sample + +open System + +type Foo = + { + Bar : string + } + +type Baz = interface end + +let Sample1(xs : int list) : string = + xs + |> List.map (fun x -> string x) + |> String.concat "," diff --git a/samples/FORTRAN/sample1.f b/samples/FORTRAN/sample1.f new file mode 100644 index 00000000..39ba97cb --- /dev/null +++ b/samples/FORTRAN/sample1.f @@ -0,0 +1,25 @@ +c comment +* comment + + program main + + end + + subroutine foo( i, x, b ) + INTEGER i + REAL x + LOGICAL b + + if( i.ne.0 ) then + call bar( -i ) + end if + + return + end + + double complex function baz() + + baz = (0.0d0,0.0d0) + + return + end diff --git a/samples/FORTRAN/sample1.for b/samples/FORTRAN/sample1.for new file mode 100644 index 00000000..39ba97cb --- /dev/null +++ b/samples/FORTRAN/sample1.for @@ -0,0 +1,25 @@ +c comment +* comment + + program main + + end + + subroutine foo( i, x, b ) + INTEGER i + REAL x + LOGICAL b + + if( i.ne.0 ) then + call bar( -i ) + end if + + return + end + + double complex function baz() + + baz = (0.0d0,0.0d0) + + return + end diff --git a/samples/FORTRAN/sample2.f b/samples/FORTRAN/sample2.f new file mode 100644 index 00000000..19538ac7 --- /dev/null +++ b/samples/FORTRAN/sample2.f @@ -0,0 +1,25 @@ + PROGRAM MAIN + + END + +C comment +* comment + + SUBROUTINE foo( i, x, b ) + INTEGER i + REAL x + LOGICAL b + + IF( i.NE.0 ) THEN + CALL bar( -i ) + END IF + + RETURN + END + + DOUBLE COMPLEX FUNCTION baz() + + baz = (0.0d0,0.0d0) + + RETURN + END diff --git a/samples/FORTRAN/sample3.F b/samples/FORTRAN/sample3.F new file mode 100644 index 00000000..39ba97cb --- /dev/null +++ b/samples/FORTRAN/sample3.F @@ -0,0 +1,25 @@ +c comment +* comment + + program main + + end + + subroutine foo( i, x, b ) + INTEGER i + REAL x + LOGICAL b + + if( i.ne.0 ) then + call bar( -i ) + end if + + return + end + + double complex function baz() + + baz = (0.0d0,0.0d0) + + return + end diff --git a/samples/Filterscript/colormatrix.fs b/samples/Filterscript/colormatrix.fs new file mode 100644 index 00000000..86fb2482 --- /dev/null +++ b/samples/Filterscript/colormatrix.fs @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * 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. + */ + +#include "ip.rsh" + +static rs_matrix4x4 Mat; + +void init() { + rsMatrixLoadIdentity(&Mat); +} + +void setMatrix(rs_matrix4x4 m) { + Mat = m; +} + +uchar4 __attribute__((kernel)) root(uchar4 in) { + float4 f = convert_float4(in); + f = rsMatrixMultiply(&Mat, f); + f = clamp(f, 0.f, 255.f); + return convert_uchar4(f); +} + diff --git a/samples/Filterscript/fs_kernel.fs b/samples/Filterscript/fs_kernel.fs new file mode 100644 index 00000000..d8f0c4d6 --- /dev/null +++ b/samples/Filterscript/fs_kernel.fs @@ -0,0 +1,18 @@ +#pragma version(1) +#pragma rs java_package_name(foo) + +int __attribute__((kernel)) root(uint32_t ain) { + return 0; +} + +void __attribute__((kernel)) in_only(uint32_t ain) { +} + +int __attribute__((kernel)) out_only() { + return 0; +} + +int __attribute__((kernel)) everything(uint32_t ain, uint32_t x, uint32_t y) { + return 0; +} + diff --git a/samples/Formatted/long_seq.for b/samples/Formatted/long_seq.for new file mode 100644 index 00000000..eadf8036 --- /dev/null +++ b/samples/Formatted/long_seq.for @@ -0,0 +1,919 @@ +ACCEPTABLE LEFT PRIMERS + 1-based # self self hair- qual- + # sequence start ln N GC% Tm any_th end_th pin lity + 0 tgctagctaggcgatgctag 411 20 0 55.00 60.028 23.16 23.16 38.59 0.028 + 1 actgatacgcgatgctagct 476 20 0 50.00 59.957 17.69 1.35 0.00 0.043 + 2 gatcgatgctagctaggcga 405 20 0 55.00 60.100 16.30 16.30 0.00 0.100 + 3 tcgatcgatgctagctaggc 403 20 0 55.00 60.100 18.63 8.45 0.00 0.100 + 4 tagctgatcgatcgtagcgg 565 20 0 55.00 60.101 25.02 17.36 0.00 0.101 + 5 gctgactgatcgatcgatgc 113 20 0 55.00 59.826 24.08 17.09 35.21 0.174 + 6 tatcatctctgcgcgatcga 361 20 0 50.00 59.747 22.07 1.72 38.48 0.253 + 7 agctaggcgatgctagctag 415 20 0 55.00 59.742 17.46 17.46 41.54 0.258 + 8 ctagctaggcgatgctagct 413 20 0 55.00 59.742 18.68 17.35 43.53 0.258 + 9 ggcgatctagctagctgact 583 20 0 55.00 59.671 17.44 7.44 37.58 0.329 + 10 tcgatgctagctaggcgatg 407 20 0 55.00 60.382 14.03 0.00 0.00 0.382 + 11 gctgatcgatcgatgctagc 398 20 0 55.00 59.618 25.97 24.79 35.21 0.382 + 12 gctagctgatcgatcgatgc 394 20 0 55.00 59.618 24.08 21.09 35.21 0.382 + 13 atcatctctgcgcgatcgat 362 20 0 50.00 60.382 22.07 5.02 38.48 0.382 + 14 gactgatacgcgatgctagc 475 20 0 55.00 59.551 8.61 8.61 0.00 0.449 + 15 atcgatgctagctaggcgat 406 20 0 50.00 59.452 18.43 18.43 0.00 0.548 + 16 gctagctgactgatacgcga 468 20 0 55.00 60.589 16.29 0.00 0.00 0.589 + 17 agctagctgactgatacgcg 467 20 0 55.00 60.590 17.99 3.89 0.00 0.590 + 18 atgctagctaggcgatgcta 410 20 0 50.00 59.375 10.59 8.91 0.00 0.625 + 19 ctatcatctctgcgcgatcg 360 20 0 55.00 59.347 12.19 12.19 39.07 0.653 + 20 gatgctagctaggcgatgct 409 20 0 55.00 60.668 7.01 7.53 0.00 0.668 + 21 gctactatcatctctgcgcg 356 20 0 55.00 59.273 0.00 0.00 0.00 0.727 + 22 cgtagcggcgatctagctag 577 20 0 60.00 60.791 15.64 15.64 37.58 0.791 + 23 cggcgatctagctagctgac 582 20 0 60.00 61.003 14.84 7.25 38.70 1.003 + 24 gctagctgatcgatcgtagc 563 20 0 55.00 58.995 23.70 23.70 0.00 1.005 + 25 gatcgatcgatgtgcggcta 81 20 0 55.00 61.006 19.16 0.00 41.65 1.006 + 26 atcgatcgatgtgcggctag 82 20 0 55.00 61.008 29.65 0.00 41.65 1.008 + 27 gctgactgatacgcgatgc 472 19 0 57.89 60.025 0.00 0.00 0.00 1.025 + 28 agctagctgatcatcgatgct 190 21 0 47.62 60.035 17.99 11.09 0.00 1.035 + 29 gctagctagctgactgatcga 105 21 0 52.38 60.037 34.38 0.00 46.11 1.037 + 30 tcatctctgcgcgatcgat 363 19 0 52.63 59.946 22.07 0.12 38.48 1.054 + 31 atcatctctgcgcgatcga 362 19 0 52.63 59.946 22.07 1.72 38.48 1.054 + 32 atcgatcgatgtgcggcta 82 19 0 52.63 59.945 29.65 0.00 41.65 1.055 + 33 gtagcggcgatctagctagc 578 20 0 60.00 61.071 16.97 7.15 39.86 1.071 + 34 gctagctgactgatcgatcg 109 20 0 55.00 58.924 16.84 13.89 0.00 1.076 + 35 gctgatcgatcgatgtgcg 78 19 0 57.89 60.097 29.87 18.15 42.69 1.097 + 36 tatcatctctgcgcgatcgat 361 21 0 47.62 60.172 22.07 11.47 38.48 1.172 + 37 gctagctagctgatcgatcga 390 21 0 52.38 60.172 34.38 22.52 46.11 1.172 + 38 gctagctagctgatcgatcga 70 21 0 52.38 60.172 34.38 22.52 46.11 1.172 + 39 catctctgcgcgatcgatg 364 19 0 57.89 59.810 13.74 13.74 38.48 1.190 + 40 tcgtagcggcgatctagcta 576 20 0 55.00 61.231 11.55 9.27 36.40 1.231 + 41 actgatacgcgatgctagcta 476 21 0 47.62 59.765 17.69 3.08 0.00 1.235 + 42 actgatcgatcgatgctagct 117 21 0 47.62 59.763 23.29 11.70 35.21 1.237 + 43 agctagctgatcgatcgatgt 73 21 0 47.62 59.763 17.99 2.62 35.21 1.237 + 44 tagcggcgatctagctagct 579 20 0 55.00 61.243 23.74 23.74 46.60 1.243 + 45 cgtagcggcgatctagcta 577 19 0 57.89 59.729 11.55 9.27 37.58 1.271 + 46 ctagctgatcgatcgtagcg 564 20 0 55.00 58.727 25.02 15.05 0.00 1.273 + 47 tagcggcgatctagctagc 579 19 0 57.89 59.725 16.97 9.14 39.86 1.275 + 48 catcgatcgatgcatgcatg 442 20 0 50.00 58.722 37.80 23.31 44.93 1.278 + 49 tcatctctgcgcgatcgatg 363 20 0 55.00 61.279 18.01 18.01 38.48 1.279 + 50 gctagctagctgatcgatcg 559 20 0 55.00 58.714 34.38 11.90 46.11 1.286 + 51 gctagctagctgatcgatcg 390 20 0 55.00 58.714 34.38 11.90 46.11 1.286 + 52 gctagctagctgatcgatcg 70 20 0 55.00 58.714 34.38 11.90 46.11 1.286 + 53 agcatcggattagctagctga 3 21 0 47.62 59.689 28.29 20.88 0.00 1.311 + 54 agctgatcgatcgtagcgg 566 19 0 57.89 60.315 25.02 17.36 0.00 1.315 + 55 cggcgatctagctagctga 582 19 0 57.89 59.650 21.57 16.66 38.70 1.350 + 56 ctagctgatcgatcgatgtgc 75 21 0 52.38 59.643 31.83 30.04 35.21 1.357 + 57 gctagctgatcgatcgatgtg 74 21 0 52.38 59.643 12.06 6.93 35.21 1.357 + 58 gctagctaggcgatgctagc 412 20 0 60.00 61.357 30.41 30.41 46.19 1.357 + 59 tagctagctgactgatacgcg 466 21 0 52.38 60.373 28.29 3.89 0.00 1.373 + 60 gctagctgactgatcgatcga 109 21 0 52.38 60.374 22.52 22.52 0.00 1.374 + 61 agctagctgactgatcgatcg 108 21 0 52.38 60.374 17.99 13.89 0.00 1.374 + 62 cgatcgatgctagctaggcg 404 20 0 60.00 61.409 15.59 9.14 0.00 1.409 + 63 gctagctagctgactgatcg 105 20 0 55.00 58.563 34.38 1.84 46.11 1.437 + 64 atgctagctaggcgatgct 410 19 0 52.63 59.561 10.59 7.53 0.00 1.439 + 65 agctagctgatcgatcgtagc 562 21 0 52.38 60.441 26.87 26.87 0.00 1.441 + 66 gctagctagctgatcgatcgt 559 21 0 52.38 60.441 34.38 2.65 46.11 1.441 + 67 tagctaggcgatgctagctag 414 21 0 52.38 59.559 18.42 17.46 42.44 1.441 + 68 ctagctaggcgatgctagcta 413 21 0 52.38 59.559 18.69 17.64 42.44 1.441 + 69 tagctgatcgatcgatgtgc 76 20 0 50.00 58.558 31.83 30.04 35.21 1.442 + 70 gatgctagctaggcgatgcta 409 21 0 52.38 60.444 9.82 8.91 0.00 1.444 + 71 atgctagctaggcgatgctag 410 21 0 52.38 60.444 23.16 23.16 38.59 1.444 + 72 gctagctgatcatcgatgct 191 20 0 50.00 58.539 16.29 12.14 0.00 1.461 + 73 agctagctgatcatcgatgc 190 20 0 50.00 58.539 21.42 9.22 0.00 1.461 + 74 gctgactgatacgcgatgct 472 20 0 55.00 61.494 2.33 0.00 0.00 1.494 + 75 agctgactgatacgcgatgc 471 20 0 55.00 61.494 3.47 0.00 0.00 1.494 + 76 ggcgatctagctagctgacta 583 21 0 52.38 59.491 17.44 5.40 37.58 1.509 + 77 gatcgatgctagctaggcgat 405 21 0 52.38 60.510 21.61 21.61 0.00 1.510 + 78 atcgatcgatgctagctaggc 402 21 0 52.38 60.510 29.65 8.45 33.56 1.510 + 79 ctgatcgatcgatgtgcgg 79 19 0 57.89 59.447 15.54 5.83 41.65 1.553 + 80 agctgatcgatcgatgtgcg 77 20 0 55.00 61.556 31.92 20.26 42.69 1.556 + 81 cgatcatcgatgctagctagc 548 21 0 52.38 59.444 34.89 34.89 46.99 1.556 + 82 tagctaggcgatgctagcta 414 20 0 50.00 58.433 19.37 17.81 42.44 1.567 + 83 agctagctactgatcgatgct 303 21 0 47.62 59.415 17.56 11.51 0.00 1.585 + 84 tcgatcgatgtgcggctag 83 19 0 57.89 60.606 18.63 0.00 41.65 1.606 + 85 gactgatcgatcgatgctagc 116 21 0 52.38 59.378 15.86 8.45 35.21 1.622 + 86 agctagctgactgatcgatca 260 21 0 47.62 59.347 26.99 26.99 35.44 1.653 + 87 ctgactgatacgcgatgctag 473 21 0 52.38 59.312 1.70 0.00 0.00 1.688 + 88 ctagctgactgatacgcgatg 469 21 0 52.38 59.312 0.00 0.00 0.00 1.688 + 89 gctactatcatctctgcgcga 356 21 0 52.38 60.707 2.71 2.71 0.00 1.707 + 90 agctactatcatctctgcgcg 355 21 0 52.38 60.709 0.00 0.00 0.00 1.709 + 91 actatcatctctgcgcgatc 359 20 0 50.00 58.270 4.99 0.00 0.00 1.730 + 92 actgatcgatcgatgctagc 117 20 0 50.00 58.270 23.29 13.61 35.21 1.730 + 93 gctagctgatcgatcgatgt 74 20 0 50.00 58.270 14.29 2.62 35.21 1.730 + 94 ctatcatctctgcgcgatcga 360 21 0 52.38 60.771 22.07 1.72 38.48 1.771 + 95 atcgatgctagctaggcgatg 406 21 0 52.38 60.779 21.16 4.37 0.00 1.779 + 96 tgactgatacgcgatgctag 474 20 0 50.00 58.207 1.70 0.00 0.00 1.793 + 97 ctgactgatacgcgatgcta 473 20 0 50.00 58.207 2.33 0.00 0.00 1.793 + 98 tagctgactgatacgcgatg 470 20 0 50.00 58.207 0.00 0.00 0.00 1.793 + 99 ctgactgatcgatcgatgct 114 20 0 50.00 58.197 26.44 12.40 35.21 1.803 + 100 agctgactgatcgatcgatg 112 20 0 50.00 58.197 23.05 13.21 35.21 1.803 + 101 tcggattagctagctgatgc 7 20 0 50.00 58.176 17.46 17.46 40.05 1.824 + 102 gcatcggattagctagctga 4 20 0 50.00 58.176 28.29 20.88 0.00 1.824 + 103 agcatcggattagctagctg 3 20 0 50.00 58.171 28.29 10.80 0.00 1.829 + 104 gatgctagctaggcgatgc 409 19 0 57.89 59.141 4.18 0.00 0.00 1.859 + 105 ctgatacgcgatgctagctag 477 21 0 52.38 59.113 17.46 17.46 0.00 1.887 + 106 gctagctgactgatacgcg 468 19 0 57.89 59.086 8.21 3.89 0.00 1.914 + 107 ctctgcgcgatcgatgctag 367 20 0 60.00 61.946 21.94 18.16 38.48 1.946 + 108 tctgcgcgatcgatgctag 368 19 0 57.89 60.966 21.94 18.16 38.48 1.966 + 109 ctctgcgcgatcgatgcta 367 19 0 57.89 60.966 26.61 17.10 38.48 1.966 + 110 cgatgctagctaggcgatgc 408 20 0 60.00 61.968 11.09 0.00 0.00 1.968 + 111 gactgatacgcgatgctagct 475 21 0 52.38 60.975 17.69 1.35 0.00 1.975 + 112 gctagctgactgatacgcgat 468 21 0 52.38 60.975 8.21 0.00 0.00 1.975 + 113 tgatacgcgatgctagctag 478 20 0 50.00 57.994 17.46 17.46 0.00 2.006 + 114 ctgatacgcgatgctagcta 477 20 0 50.00 57.994 17.69 3.08 0.00 2.006 + 115 cgcgatcgatgctagctagc 372 20 0 60.00 62.011 34.89 34.89 43.67 2.011 + 116 gcgcgatcgatgctagctag 371 20 0 60.00 62.011 21.66 17.46 38.48 2.011 + 117 ctgatcgatcgatgctagct 399 20 0 50.00 57.983 19.70 2.01 35.21 2.017 + 118 agctgatcgatcgatgctag 397 20 0 50.00 57.983 27.33 18.05 34.69 2.017 + 119 ctagctgatcgatcgatgct 395 20 0 50.00 57.983 33.87 33.38 38.16 2.017 + 120 agctagctgatcgatcgatg 393 20 0 50.00 57.983 21.99 11.03 35.21 2.017 + 121 ctgatcgatcgatgctagct 118 20 0 50.00 57.983 19.70 2.01 35.21 2.017 + 122 agctagctgatcgatcgatg 73 20 0 50.00 57.983 21.99 11.03 35.21 2.017 + 123 catcggattagctagctgatgc 5 22 0 50.00 59.982 24.41 24.41 40.05 2.018 + 124 gcatcggattagctagctgatg 4 22 0 50.00 59.982 27.81 27.81 33.28 2.018 + 125 tcgatgctagctaggcgat 407 19 0 52.63 58.964 14.03 3.01 0.00 2.036 + 126 atcgatgctagctaggcga 406 19 0 52.63 58.964 16.30 16.30 0.00 2.036 + 127 actatcatctctgcgcgatcg 359 21 0 52.38 61.037 12.19 12.19 39.07 2.037 + 128 gcgcgatcgatgctagcta 371 19 0 57.89 61.037 21.66 3.08 38.48 2.037 + 129 gctgatcgatcgatgctagct 398 21 0 52.38 61.044 27.88 12.70 35.21 2.044 + 130 agctgatcgatcgatgctagc 397 21 0 52.38 61.044 27.33 27.90 34.69 2.044 + 131 gctagctgatcgatcgatgct 394 21 0 52.38 61.044 33.87 33.38 38.16 2.044 + 132 agctagctgatcgatcgatgc 393 21 0 52.38 61.044 24.08 21.09 35.21 2.044 + 133 cgcgatcgatgctagctag 372 19 0 57.89 58.947 22.07 17.46 38.48 2.053 + 134 tcgtagcggcgatctagc 576 18 0 61.11 59.936 4.70 0.00 36.40 2.064 + 135 cgtagcggcgatctagct 577 18 0 61.11 59.935 11.03 11.03 37.58 2.065 + 136 gcggcgatctagctagct 581 18 0 61.11 59.933 23.74 23.74 38.05 2.067 + 137 agcggcgatctagctagc 580 18 0 61.11 59.933 16.97 7.15 39.86 2.067 + 138 ctagctgactgatacgcgat 469 20 0 50.00 57.918 1.43 0.00 0.00 2.082 + 139 ctagctgatcgatcgtagcgg 564 21 0 57.14 61.096 20.31 16.15 0.00 2.096 + 140 agctactatcatctctgcgc 355 20 0 50.00 57.898 0.00 0.00 0.00 2.102 + 141 gctagctactgatcgatgct 304 20 0 50.00 57.898 11.51 11.51 0.00 2.102 + 142 agctagctactgatcgatgc 303 20 0 50.00 57.898 17.56 1.76 0.00 2.102 + 143 agcatcggattagctagctgat 3 22 0 45.45 60.108 17.84 15.13 0.00 2.108 + 144 tgctagctaggcgatgcta 411 19 0 52.63 58.881 17.69 8.91 0.00 2.119 + 145 aagcatcggattagctagctg 2 21 0 47.62 58.879 28.29 10.80 0.00 2.121 + 146 tctgcgcgatcgatgcta 368 18 0 55.56 59.857 26.61 16.13 38.48 2.143 + 147 cgatgctagctaggcgatg 408 19 0 57.89 58.856 11.09 0.00 0.00 2.144 + 148 agctagctgatcatcgatgcta 190 22 0 45.45 59.845 17.99 13.09 0.00 2.155 + 149 tagctagctgatcatcgatgct 189 22 0 45.45 59.845 16.29 15.30 0.00 2.155 + 150 atcgatcgatgtgcggct 82 18 0 55.56 60.166 29.65 4.36 41.65 2.166 + 151 gctagctgactgatcgatca 261 20 0 50.00 57.829 26.99 26.99 35.44 2.171 + 152 tagctagctgactgatcgatcg 107 22 0 50.00 60.174 28.29 13.89 0.00 2.174 + 153 agctgatcatcatcgatgct 515 20 0 45.00 57.788 11.25 0.72 40.32 2.212 + 154 agctagctgactgatcgatcat 260 22 0 45.45 59.778 26.67 18.02 36.62 2.222 + 155 tgactgatacgcgatgctagc 474 21 0 52.38 61.238 8.61 8.61 0.00 2.238 + 156 gctgactgatacgcgatgcta 472 21 0 52.38 61.238 2.33 0.00 0.00 2.238 + 157 tagctgactgatacgcgatgc 470 21 0 52.38 61.238 3.47 0.00 0.00 2.238 + 158 tagctagctgatcgatcgtagc 561 22 0 50.00 60.238 26.87 26.87 0.00 2.238 + 159 gctagctagctgatcgatcgta 559 22 0 50.00 60.238 34.38 3.07 46.11 2.238 + 160 tgatcgatcgatgctagctagg 400 22 0 50.00 60.239 26.44 6.29 35.21 2.239 + 161 gctgactgatcgatcgatgct 113 21 0 52.38 61.244 26.44 12.40 35.21 2.244 + 162 agctgactgatcgatcgatgc 112 21 0 52.38 61.244 24.08 19.43 35.21 2.244 + 163 gatcgatcgatgtgcggct 81 19 0 57.89 61.263 19.16 0.00 41.65 2.263 + 164 gctgatcatcgatgctactagc 195 22 0 50.00 59.727 18.08 16.44 45.61 2.273 + 165 gctagctgatcatcgatgctac 191 22 0 50.00 59.727 9.57 5.47 0.00 2.273 + 166 gatcgatcgatgtgcggc 81 18 0 61.11 59.714 18.10 0.95 41.65 2.286 + 167 ctagctagctgactgatacgc 465 21 0 52.38 58.703 14.90 0.00 0.00 2.297 + 168 tagctgatcgatcgatgtgcg 76 21 0 52.38 61.299 31.92 20.26 42.69 2.299 + 169 agctgatcgatcgatgtgc 77 19 0 52.63 58.698 31.83 30.04 35.21 2.302 + 170 gctgatcatcatcgatgctagc 516 22 0 50.00 60.302 10.80 10.34 40.32 2.302 + 171 gctagctgatcatcatcgatgc 512 22 0 50.00 60.302 21.42 7.40 40.32 2.302 + 172 aagcatcggattagctagctga 2 22 0 45.45 60.306 28.29 20.88 0.00 2.306 + 173 gatcgatcgtagcggcga 570 18 0 61.11 60.318 13.01 8.51 45.59 2.318 + 174 atcggattagctagctgatgc 6 21 0 47.62 58.673 17.46 17.46 40.05 2.327 + 175 gcatcggattagctagctgat 4 21 0 47.62 58.673 17.84 15.13 0.00 2.327 + 176 gcggcgatctagctagctg 581 19 0 63.16 61.329 17.07 8.17 38.05 2.329 + 177 tgctagtgatgcatgctagt 24 20 0 45.00 57.636 24.96 11.17 35.89 2.364 + 178 ctactatcatctctgcgcga 357 20 0 50.00 57.636 2.71 2.71 0.00 2.364 + 179 actagctagctgactgatacgc 464 22 0 50.00 60.368 21.52 0.00 0.00 2.368 + 180 gctagctagctgatcatcga 187 20 0 50.00 57.613 34.38 0.24 46.11 2.387 + 181 tctctgcgcgatcgatgcta 366 20 0 55.00 62.413 26.61 17.10 38.48 2.413 + 182 tgatcgatcgatgctagctagt 119 22 0 45.45 59.586 26.44 5.69 35.21 2.414 + 183 actgatcgatcgatgctagcta 117 22 0 45.45 59.586 23.29 7.65 35.21 2.414 + 184 tagctagctgatcgatcgatgt 72 22 0 45.45 59.586 14.29 2.62 35.21 2.414 + 185 agctaggcgatgctagcta 415 19 0 52.63 58.572 17.69 3.08 41.54 2.428 + 186 tagctaggcgatgctagct 414 19 0 52.63 58.572 17.35 17.35 43.53 2.428 + 187 gatcgatcgatgctagctagg 401 21 0 52.38 58.567 23.89 6.29 35.21 2.433 + 188 gctagctagctgactgatcgat 105 22 0 50.00 60.434 34.38 0.00 46.11 2.434 + 189 gatcgatgctagctaggcg 405 19 0 57.89 58.563 15.59 9.02 0.00 2.437 + 190 cgatcgatgctagctaggc 404 19 0 57.89 58.563 14.87 8.45 0.00 2.437 + 191 tagctagctgactgatacgc 466 20 0 50.00 57.549 28.29 0.00 0.00 2.451 + 192 agctagctgactgatcgatc 260 20 0 50.00 57.536 19.32 19.32 0.00 2.464 + 193 agctagctgactgatcgatc 108 20 0 50.00 57.536 19.32 19.32 0.00 2.464 + 194 aaagcatcggattagctagctg 1 22 0 45.45 59.524 28.29 10.80 0.00 2.476 + 195 gctgactgatcgatcatcatgc 265 22 0 50.00 60.493 25.66 25.12 41.77 2.493 + 196 tagctactatcatctctgcgcg 354 22 0 50.00 60.495 0.00 0.00 0.00 2.495 + 197 ctgatcgatcgatgtgcggc 79 20 0 60.00 62.497 15.54 4.15 41.65 2.497 + 198 gctgatcgatcgatgtgcgg 78 20 0 60.00 62.497 29.87 22.23 41.65 2.497 + 199 tcgtagcggcgatctagct 576 19 0 57.89 61.503 11.03 11.03 36.40 2.503 + 200 agcggcgatctagctagct 580 19 0 57.89 61.519 23.74 23.74 42.96 2.519 + 201 ctagctagctgatcatcgatgc 188 22 0 50.00 59.470 21.42 9.22 0.00 2.530 + 202 gctagctagctgatcatcgatg 187 22 0 50.00 59.470 34.38 20.23 46.11 2.530 + 203 tcatctctgcgcgatcga 363 18 0 55.56 59.468 22.07 0.00 38.48 2.532 + 204 tcgatcgatgtgcggcta 83 18 0 55.56 59.465 18.63 0.00 41.65 2.535 + 205 tgatcgatcgatgtgcggc 80 19 0 57.89 61.549 21.27 8.44 41.65 2.549 + 206 ctagctaggcgatgctagctag 413 22 0 54.55 60.561 22.99 22.99 46.84 2.561 + 207 gctagctagctgatcgatcgat 390 22 0 50.00 60.561 34.38 30.53 46.11 2.561 + 208 gctagctagctgatcgatcgat 70 22 0 50.00 60.561 34.38 30.53 46.11 2.561 + 209 ctgcgcgatcgatgctag 369 18 0 61.11 59.415 19.79 13.97 38.48 2.585 + 210 aagcatcggattagctagct 2 20 0 45.00 57.413 23.74 23.74 0.00 2.587 + 211 gctagctgatcatcgatgcta 191 21 0 47.62 58.410 16.61 13.09 0.00 2.590 + 212 tagctagctgatcatcgatgc 189 21 0 47.62 58.410 21.42 9.22 0.00 2.590 + 213 actgatacgcgatgctagc 476 19 0 52.63 58.407 8.61 8.61 0.00 2.593 + 214 gctagctgactgatcgatcatc 261 22 0 50.00 59.406 23.93 21.92 36.62 2.594 + 215 atcgatcgatgctagctagg 402 20 0 50.00 57.396 29.65 6.29 33.56 2.604 + 216 atctctgcgcgatcgatgc 365 19 0 57.89 61.618 22.01 22.01 38.48 2.618 + 217 tgatcgatcgtagcggcg 569 18 0 61.11 60.621 20.58 0.86 0.00 2.621 + 218 atcatctctgcgcgatcgatg 362 21 0 52.38 61.633 18.01 18.01 38.48 2.633 + 219 agctagctgatcgatcgtag 562 20 0 50.00 57.344 17.99 16.86 0.00 2.656 + 220 ctagctagctgatcgatcgt 560 20 0 50.00 57.344 16.40 2.65 0.00 2.656 + 221 gctagctgactgatcgatcat 261 21 0 47.62 58.339 26.67 18.02 36.62 2.661 + 222 ctgatcgatcgtagcggcg 568 19 0 63.16 61.664 14.21 0.86 0.00 2.664 + 223 ctgactgatacgcgatgct 473 19 0 52.63 58.330 2.33 0.00 0.00 2.670 + 224 agctgactgatacgcgatg 471 19 0 52.63 58.330 0.00 0.00 0.00 2.670 + 225 gctagctgatcgatcgtagcg 563 21 0 57.14 61.676 24.18 16.49 0.00 2.676 + 226 ctagctgactgatcgatcga 110 20 0 50.00 57.276 22.52 22.52 0.00 2.724 + 227 agctagctactgatcgatgcta 303 22 0 45.45 59.252 17.56 12.23 0.00 2.748 + 228 tagctagctactgatcgatgct 302 22 0 45.45 59.252 27.80 11.51 0.00 2.748 + 229 gactgatacgcgatgctagcta 475 22 0 50.00 60.751 17.69 3.08 0.00 2.751 + 230 actgatacgcgatgctagctag 476 22 0 50.00 60.752 17.46 17.46 0.00 2.752 + 231 gactgatcgatcgatgctagct 116 22 0 50.00 60.753 18.04 9.56 35.21 2.753 + 232 gctagctgactgatcgatcgat 109 22 0 50.00 60.753 30.53 30.53 37.90 2.753 + 233 tgcgcgatcgatgctagcta 370 20 0 55.00 62.756 26.61 9.85 38.48 2.756 + 234 gcggcgatctagctagctga 581 20 0 60.00 62.765 21.57 16.66 38.70 2.765 + 235 agcggcgatctagctagctg 580 20 0 60.00 62.771 17.07 8.17 44.87 2.771 + 236 ctactatcatctctgcgcgatc 357 22 0 50.00 59.220 4.99 0.00 0.00 2.780 + 237 tatcatctctgcgcgatcg 361 19 0 52.63 58.199 12.19 12.19 39.07 2.801 + 238 tactatcatctctgcgcgatcg 358 22 0 50.00 60.811 12.19 12.19 39.07 2.811 + 239 tagctagctgactgatcgatca 259 22 0 45.45 59.187 28.29 26.99 35.44 2.813 + 240 gctgatcgatcgatgctagcta 398 22 0 50.00 60.816 27.88 12.57 35.21 2.816 + 241 tagctgatcgatcgatgctagc 396 22 0 50.00 60.816 30.84 27.90 36.80 2.816 + 242 gctagctgatcgatcgatgcta 394 22 0 50.00 60.816 34.11 32.56 36.80 2.816 + 243 tagctagctgatcgatcgatgc 392 22 0 50.00 60.816 24.08 21.09 35.21 2.816 + 244 gctaggcgatgctagctag 416 19 0 57.89 58.179 17.46 17.46 35.42 2.821 + 245 ctagctaggcgatgctagc 413 19 0 57.89 58.179 18.68 9.44 36.95 2.821 + 246 gctagctaggcgatgctag 412 19 0 57.89 58.179 23.16 23.16 38.59 2.821 + 247 catctctgcgcgatcgatgc 364 20 0 60.00 62.823 22.01 22.01 38.48 2.823 + 248 aaagcatcggattagctagct 1 21 0 42.86 58.168 23.74 23.74 0.00 2.832 + 249 ctgactgatcgatcgatgctag 114 22 0 50.00 59.155 22.81 19.44 35.21 2.845 + 250 ctagctgactgatcgatcgatg 110 22 0 50.00 59.155 23.05 13.21 35.21 2.845 + 251 tactatcatctctgcgcgatc 358 21 0 47.62 58.155 4.99 0.00 0.00 2.845 + 252 gctagctactgatcgatgctac 304 22 0 50.00 59.151 8.57 4.26 0.00 2.849 + 253 ctactatcatctctgcgcgat 357 21 0 47.62 58.150 4.99 2.52 0.00 2.850 + 254 agctgatcatcgatgctact 194 20 0 45.00 57.134 17.14 8.95 0.00 2.866 + 255 gctagctagctgatcatcgat 187 21 0 47.62 58.132 34.38 0.00 46.11 2.868 + 256 ctgatacgcgatgctagct 477 19 0 52.63 58.107 17.69 1.35 0.00 2.893 + 257 ggcgatctagctagctgac 583 19 0 57.89 58.106 14.84 7.25 37.58 2.894 + 258 tgactgatcgatcgatgctag 115 21 0 47.62 58.084 22.81 19.44 35.21 2.916 + 259 ctgactgatcgatcgatgcta 114 21 0 47.62 58.084 26.44 14.64 35.21 2.916 + 260 tagctgactgatcgatcgatg 111 21 0 47.62 58.084 23.05 13.21 35.21 2.916 + 261 actgatcgatcatcatgctagc 269 22 0 45.45 59.071 26.67 8.61 41.77 2.929 + 262 agctgactgatcgatcatca 264 20 0 45.00 57.064 26.49 26.49 39.98 2.936 + 263 ctagctagctgatcgatcga 391 20 0 50.00 57.060 22.52 22.52 0.00 2.940 + 264 ctagctagctgatcgatcga 71 20 0 50.00 57.060 22.52 22.52 0.00 2.940 + 265 gatcgatcgatgtgcggctag 81 21 0 57.14 61.947 19.16 0.00 41.65 2.947 + 266 tgctagctaggcgatgct 411 18 0 55.56 59.050 17.69 7.53 0.00 2.950 + 267 gctgatcgatcgtagcggc 567 19 0 63.16 61.960 20.49 19.38 0.00 2.960 + 268 cgatcgatgtgcggctag 84 18 0 61.11 59.032 10.82 0.00 41.65 2.968 + 269 tgatcgatcgatgtgcggct 80 20 0 55.00 62.987 22.21 0.00 41.65 2.987 + 270 ctgactgatcgatcatcatgct 266 22 0 45.45 59.004 20.99 6.82 41.77 2.996 + 271 agctgactgatcgatcatcatg 264 22 0 45.45 59.004 22.70 19.51 41.77 2.996 + 272 agctagctgactgatacgcga 467 21 0 52.38 62.000 17.99 0.00 0.00 3.000 + 273 tgactgatcgatcgatgctagc 115 22 0 50.00 61.008 18.17 12.52 35.21 3.008 + 274 gctgactgatcgatcgatgcta 113 22 0 50.00 61.008 26.44 14.64 35.21 3.008 + 275 tagctgactgatcgatcgatgc 111 22 0 50.00 61.008 24.08 19.43 35.21 3.008 + 276 agctagctgatcgatcgatgtg 73 22 0 50.00 61.010 17.99 6.93 35.21 3.010 + 277 ctgatcgatcgatgctagctag 399 22 0 50.00 58.963 19.70 17.46 35.21 3.037 + 278 ctagctgatcgatcgatgctag 395 22 0 50.00 58.963 37.86 37.86 43.17 3.037 + 279 ctagctagctgatcgatcgatg 391 22 0 50.00 58.963 21.99 11.03 35.21 3.037 + 280 ctgatcgatcgatgctagctag 118 22 0 50.00 58.963 19.70 17.46 35.21 3.037 + 281 ctagctagctgatcgatcgatg 71 22 0 50.00 58.963 21.99 11.03 35.21 3.037 + 282 gactgatcgatcatcatgctagc 268 23 0 47.83 60.053 24.51 9.03 41.77 3.053 + 283 gctagtgatgcatgctagtagtg 25 23 0 47.83 59.929 24.96 10.54 0.00 3.071 + 284 gctactatcatctctgcgcgat 356 22 0 50.00 61.073 4.99 2.52 0.00 3.073 + 285 gtagcggcgatctagctag 578 19 0 57.89 57.903 15.64 15.64 37.58 3.097 + 286 tgactgatcgatcatcatgct 267 21 0 42.86 57.900 26.79 12.28 41.77 3.100 + 287 ctagctactatcatctctgcgc 353 22 0 50.00 58.892 0.00 0.00 0.00 3.108 + 288 gctagctactatcatctctgcg 352 22 0 50.00 58.892 8.21 0.00 0.00 3.108 + 289 ctagctagctactgatcgatgc 301 22 0 50.00 58.892 14.00 1.76 0.00 3.108 + 290 gctagctagctactgatcgatg 300 22 0 50.00 58.892 34.38 7.78 46.11 3.108 + 291 catcgatcgatgctagtatgct 325 22 0 45.45 58.885 37.80 10.02 44.93 3.115 + 292 tgatcgatcgatgctagctag 400 21 0 47.62 57.879 26.44 17.46 35.21 3.121 + 293 ctgatcgatcgatgctagcta 399 21 0 47.62 57.879 19.70 3.77 35.21 3.121 + 294 tagctgatcgatcgatgctag 396 21 0 47.62 57.879 34.03 27.12 36.80 3.121 + 295 ctagctgatcgatcgatgcta 395 21 0 47.62 57.879 34.11 32.56 36.80 3.121 + 296 tagctagctgatcgatcgatg 392 21 0 47.62 57.879 21.99 11.03 35.21 3.121 + 297 tgatcgatcgatgctagctag 119 21 0 47.62 57.879 26.44 17.46 35.21 3.121 + 298 ctgatcgatcgatgctagcta 118 21 0 47.62 57.879 19.70 3.77 35.21 3.121 + 299 tagctagctgatcgatcgatg 72 21 0 47.62 57.879 21.99 11.03 35.21 3.121 + 300 gatcgatcgatgctagctagt 120 21 0 47.62 57.878 23.89 3.56 35.21 3.122 + 301 ctatcatctctgcgcgatcgat 360 22 0 50.00 61.132 22.07 11.47 38.48 3.132 + 302 tgatcgatcgtagcggcga 569 19 0 57.89 62.144 20.58 8.51 45.59 3.144 + 303 tcgtagcggcgatctagctag 576 21 0 57.14 62.173 15.64 15.64 36.40 3.173 + 304 tactagctagctgactgatacgc 463 23 0 47.83 60.176 13.17 0.00 0.00 3.176 + 305 ctgatcatcatcgatgctagct 517 22 0 45.45 58.807 17.69 1.76 40.32 3.193 + 306 agctgatcatcatcgatgctag 515 22 0 45.45 58.807 5.93 2.76 40.32 3.193 + 307 ctagctgatcatcatcgatgct 513 22 0 45.45 58.807 14.14 8.34 40.32 3.193 + 308 agctagctgatcatcatcgatg 511 22 0 45.45 58.807 20.23 20.23 41.48 3.193 + 309 ctgatcgatcatcatgctagct 270 22 0 45.45 58.807 26.67 0.00 41.77 3.193 + 310 ctagctgactgatcgatcgat 110 21 0 47.62 57.806 30.53 30.53 37.90 3.194 + 311 ttagctagctgactgatcgatca 258 23 0 43.48 59.798 28.29 26.99 35.44 3.202 + 312 tagctactatcatctctgcgc 354 21 0 47.62 57.798 0.00 0.00 0.00 3.202 + 313 gctagctactgatcgatgcta 304 21 0 47.62 57.798 12.99 12.23 0.00 3.202 + 314 tagctagctactgatcgatgc 302 21 0 47.62 57.798 27.80 1.76 0.00 3.202 + 315 tctctgcgcgatcgatgc 366 18 0 61.11 61.229 22.01 22.01 38.48 3.229 + 316 ctctgcgcgatcgatgct 367 18 0 61.11 61.232 26.61 0.00 38.48 3.232 + 317 agctagctactatcatctctgcg 351 23 0 47.83 60.238 17.56 0.00 0.00 3.238 + 318 ctagctagctactgatcgatgct 301 23 0 47.83 60.238 14.00 11.51 0.00 3.238 + 319 ctgatcgatcgtagcggc 568 18 0 61.11 58.727 14.21 0.00 0.00 3.273 + 320 gctgatcgatcgtagcgg 567 18 0 61.11 58.727 20.49 15.03 0.00 3.273 + 321 agctaggcgatgctagct 415 18 0 55.56 58.725 17.69 13.00 39.84 3.275 + 322 tgctagtgatgcatgctagtagt 24 23 0 43.48 60.302 24.96 12.98 35.89 3.302 + 323 gcgcgatcgatgctagct 371 18 0 61.11 61.306 21.66 1.35 38.48 3.306 + 324 tgatcatcatcgatgctagct 518 21 0 42.86 57.691 17.69 1.76 40.32 3.309 + 325 agctgatcatcatcgatgcta 515 21 0 42.86 57.691 0.24 0.00 40.32 3.309 + 326 tagctgatcatcatcgatgct 514 21 0 42.86 57.691 14.14 8.34 40.32 3.309 + 327 tgatcgatcatcatgctagct 271 21 0 42.86 57.691 27.48 0.00 37.38 3.309 + 328 ctagctagctgactgatacgcg 465 22 0 54.55 61.313 14.90 3.89 0.00 3.313 + 329 tgctagtgatgcatgctagtag 24 22 0 45.45 58.673 24.96 19.76 35.89 3.327 + 330 gctagtgatgcatgctagtagt 25 22 0 45.45 58.672 24.96 12.98 0.00 3.328 + 331 tagctagctgatcatcgatgcta 189 23 0 43.48 59.671 17.82 15.89 0.00 3.329 + 332 agctagctgactgatacgc 467 19 0 52.63 57.642 17.99 0.00 0.00 3.358 + 333 tatcatctctgcgcgatcgatg 361 22 0 50.00 61.383 18.01 18.01 38.48 3.383 + 334 agctgactgatcgatcatcat 264 21 0 42.86 57.616 26.31 18.90 41.77 3.384 + 335 actagctagctgatcatcatcga 508 23 0 43.48 59.607 22.43 0.00 0.00 3.393 + 336 tagctagctgactgatcgatcat 259 23 0 43.48 59.607 28.29 18.02 36.62 3.393 + 337 gatgctagctaggcgatgctag 409 22 0 54.55 61.393 23.16 23.16 38.59 3.393 + 338 cggcgatctagctagctgact 582 21 0 57.14 62.394 17.44 7.44 38.70 3.394 + 339 ctagctagctgatcgatcgat 391 21 0 47.62 57.600 30.53 30.53 37.90 3.400 + 340 ctagctagctgatcgatcgat 71 21 0 47.62 57.600 30.53 30.53 37.90 3.400 + 341 actgatcgatcatcatgctagct 269 23 0 43.48 60.428 26.67 4.70 41.77 3.428 + 342 ctagctagctgactgatcgatc 106 22 0 50.00 58.567 19.32 19.32 0.00 3.433 + 343 ctgactgatcgatcatcatgc 266 21 0 47.62 57.562 20.99 12.19 41.77 3.438 + 344 gctgactgatcgatcatcatg 265 21 0 47.62 57.562 22.70 19.51 41.77 3.438 + 345 gatcgatcgatgctagctaggc 401 22 0 54.55 61.448 23.89 8.45 35.21 3.448 + 346 gtgatgcatgctagtagtgatgt 29 23 0 43.48 59.551 11.60 0.00 0.00 3.449 + 347 tgctagtgatgcatgctagta 24 21 0 42.86 57.546 24.96 21.25 35.89 3.454 + 348 tagcggcgatctagctagctg 579 21 0 57.14 62.457 18.98 9.30 45.57 3.457 + 349 gtagcggcgatctagctagct 578 21 0 57.14 62.458 23.74 23.74 46.60 3.458 + 350 tagctgatcgatcgtagcg 565 19 0 52.63 57.539 25.02 11.96 0.00 3.461 + 351 gctagctagctactgatcgat 300 21 0 47.62 57.517 34.38 0.00 46.11 3.483 + 352 agctagctactgatcgatgctac 303 23 0 47.83 60.487 17.56 7.81 0.00 3.487 + 353 atcgatcgatgctagtatgct 326 21 0 42.86 57.502 29.65 2.17 33.56 3.498 + 354 agctactgatcgatgctacatc 307 22 0 45.45 58.484 7.41 0.00 37.97 3.516 + 355 agtgatgcatgctagtagtga 28 21 0 42.86 57.471 0.00 0.00 0.00 3.529 + 356 gactgatcgatcgatgctagcta 116 23 0 47.83 60.546 18.04 4.19 35.21 3.546 + 357 ctgatcgatcgatgctagctagt 118 23 0 47.83 60.547 22.18 3.56 35.21 3.547 + 358 actgatcgatcgatgctagctag 117 23 0 47.83 60.547 23.29 17.46 35.21 3.547 + 359 ctagctagctgatcgatcgatgt 71 23 0 47.83 60.547 14.29 2.62 35.21 3.547 + 360 catcgatcgatgctagtatgc 325 21 0 47.62 57.452 37.80 0.00 44.93 3.548 + 361 tagctagctgactgatcgatc 259 21 0 47.62 57.451 28.29 19.32 0.00 3.549 + 362 tagctagctgactgatcgatc 107 21 0 47.62 57.451 28.29 19.32 0.00 3.549 + 363 ctagctagctgactgatcgat 106 21 0 47.62 57.445 14.90 0.00 0.00 3.555 + 364 tcgatgctagctaggcga 407 18 0 55.56 58.427 15.59 13.52 0.00 3.573 + 365 tgatcgatcgatgctagctagta 119 23 0 43.48 59.424 26.44 18.77 35.21 3.576 + 366 ctgcgcgatcgatgctagc 369 19 0 63.16 62.586 20.26 12.12 38.48 3.586 + 367 agctagctgatcatcatcgat 511 21 0 42.86 57.405 17.99 0.00 0.00 3.595 + 368 tgcgcgatcgatgctagc 370 18 0 61.11 61.605 26.61 17.77 38.48 3.605 + 369 ctagctagctgatcgatcgtag 560 22 0 50.00 58.387 16.86 16.86 0.00 3.613 + 370 actagctagctgactgatacg 464 21 0 47.62 57.384 21.52 2.77 0.00 3.616 + 371 ctagctgactgatacgcga 469 19 0 52.63 57.370 16.29 0.00 0.00 3.630 + 372 gctactagctagctgactgat 461 21 0 47.62 57.360 15.96 3.00 44.92 3.640 + 373 ctgatcatcatcgatgctagc 517 21 0 47.62 57.358 8.61 8.61 40.32 3.642 + 374 gctgatcatcatcgatgctag 516 21 0 47.62 57.358 5.93 2.76 40.32 3.642 + 375 ctagctgatcatcatcgatgc 513 21 0 47.62 57.358 21.42 7.40 40.32 3.642 + 376 gctagctgatcatcatcgatg 512 21 0 47.62 57.358 20.23 20.23 41.48 3.642 + 377 ctgatcgatcatcatgctagc 270 21 0 47.62 57.358 26.67 8.61 41.77 3.642 + 378 agctactgatcgatgctacat 307 21 0 42.86 57.344 7.41 0.00 0.00 3.656 + 379 tgatcgatcgatgtgcggcta 80 21 0 52.38 62.663 22.21 0.24 41.65 3.663 + 380 atctctgcgcgatcgatg 365 18 0 55.56 58.327 12.03 4.19 38.48 3.673 + 381 catctctgcgcgatcgat 364 18 0 55.56 58.327 22.07 1.26 38.48 3.673 + 382 atcatctctgcgcgatcg 362 18 0 55.56 58.327 12.19 12.19 39.07 3.673 + 383 aagcatcggattagctagctgat 2 23 0 43.48 60.682 17.84 15.13 0.00 3.682 + 384 agtgatgcatgctagtagtgatg 28 23 0 43.48 59.299 7.49 7.49 0.00 3.701 + 385 gatcgatgctagctaggcgatg 405 22 0 54.55 61.702 24.26 6.24 0.00 3.702 + 386 atctctgcgcgatcgatgcta 365 21 0 52.38 62.723 26.61 17.10 38.48 3.723 + 387 tagctagctgactgatacgcga 466 22 0 50.00 61.730 28.29 0.00 0.00 3.730 + 388 tagctagctgatcgatcgtag 561 21 0 47.62 57.269 16.86 16.86 0.00 3.731 + 389 ctagctagctgatcgatcgta 560 21 0 47.62 57.269 11.68 3.07 0.00 3.731 + 390 tcgatcgatgctagctagtag 122 21 0 47.62 57.269 18.63 2.63 0.00 3.731 + 391 gctagctactgatcgatgctaca 304 23 0 47.83 60.734 11.21 0.06 0.00 3.734 + 392 agctagctgactgatcgatcatc 260 23 0 47.83 60.736 23.93 21.92 36.62 3.736 + 393 agctagctgactgatcgatcga 108 22 0 50.00 61.737 22.52 22.52 0.00 3.737 + 394 tctctgcgcgatcgatgct 366 19 0 57.89 62.740 26.61 0.00 38.48 3.740 + 395 tgatgcatgctagtagtgatgt 30 22 0 40.91 58.256 11.60 0.00 0.00 3.744 + 396 tgatcgatcgatgtgcgg 80 18 0 55.56 58.244 21.27 0.00 41.65 3.756 + 397 cgatcgatgctagctaggcga 404 21 0 57.14 62.770 16.30 16.30 0.00 3.770 + 398 tcgatcgatgctagctaggcg 403 21 0 57.14 62.770 18.63 11.67 0.00 3.770 + 399 atcgatcgatgcatgcatg 443 19 0 47.37 57.226 29.65 23.31 37.30 3.774 + 400 catcgatcgatgcatgcat 442 19 0 47.37 57.226 37.80 33.45 44.93 3.774 + 401 actagctagctgatcatcatcg 508 22 0 45.45 58.219 22.43 3.40 0.00 3.781 + 402 ctgatcatcgatgctactagct 196 22 0 45.45 58.219 10.86 0.00 45.92 3.781 + 403 agctgatcatcgatgctactag 194 22 0 45.45 58.219 13.67 9.68 0.00 3.781 + 404 ctagctgatcatcgatgctact 192 22 0 45.45 58.219 14.85 7.80 0.00 3.781 + 405 tttagctagctgactgatcga 257 21 0 42.86 57.216 0.38 0.00 0.00 3.784 + 406 tagctagctgatcgatcgatgtg 72 23 0 47.83 60.793 10.14 4.94 35.21 3.793 + 407 gctagctagctgatcatcatct 146 22 0 45.45 58.203 34.38 0.00 46.11 3.797 + 408 ctagctagctgatcatcgatgct 188 23 0 47.83 60.799 16.29 15.30 0.00 3.799 + 409 agctagctactatcatcgatcga 429 23 0 43.48 59.170 22.52 22.52 0.00 3.830 + 410 ttagctagctgactgatcgatc 258 22 0 45.45 58.159 28.29 19.32 0.00 3.841 + 411 ctagctgactgatcgatcatca 262 22 0 45.45 58.155 26.49 26.49 39.98 3.845 + 412 aaagcatcggattagctagctga 1 23 0 43.48 60.870 28.29 20.88 0.00 3.870 + 413 agctgactgatacgcgatgct 471 21 0 52.38 62.876 7.57 2.13 0.00 3.876 + 414 tagctagctactgatcgatgcta 302 23 0 43.48 59.102 27.80 12.23 0.00 3.898 + 415 tcatcatcgatgctagctagt 521 21 0 42.86 57.067 22.18 3.56 40.32 3.933 + 416 tcgatcatcatgctagctact 274 21 0 42.86 57.067 0.00 0.00 0.00 3.933 + 417 tgatcatcgatgctactagct 197 21 0 42.86 57.067 17.14 0.00 45.92 3.933 + 418 agctgatcatcgatgctacta 194 21 0 42.86 57.067 17.14 4.89 0.00 3.933 + 419 tagctgatcatcgatgctact 193 21 0 42.86 57.067 14.85 7.80 0.00 3.933 + 420 tcgatcgatgctagtatgctag 327 22 0 45.45 58.044 18.63 13.77 46.09 3.956 + 421 gcgatctagctagctgact 584 19 0 52.63 57.034 17.44 7.44 0.00 3.966 + 422 gctactgatcgatgctacatc 308 21 0 47.62 57.028 2.44 0.00 37.97 3.972 + 423 cggcgatctagctagctg 582 18 0 61.11 58.018 17.07 8.17 37.58 3.982 + 424 gctagctgactgatcgatcatca 261 23 0 47.83 60.983 26.49 26.49 39.98 3.983 + 425 actatcatctctgcgcgat 359 19 0 47.37 57.015 4.99 2.52 0.00 3.985 + 426 catcggattagctagctgatg 5 21 0 47.62 57.003 23.69 23.29 0.00 3.997 + 427 tagctgactgatcgatcatca 263 21 0 42.86 57.000 26.49 26.49 39.98 4.000 + 428 actagctagctgatcatcatcgat 508 24 0 41.67 59.995 22.43 0.00 0.00 4.005 + 429 agtgatgcatgctagtagtgat 28 22 0 40.91 57.984 0.00 0.00 0.00 4.016 + 430 ctagctagctgatcatcatcga 509 22 0 45.45 57.958 11.68 0.00 0.00 4.042 + 431 gctgatcatcgatgctactagct 195 23 0 47.83 61.046 20.91 5.24 45.92 4.046 + 432 agctgatcatcgatgctactagc 194 23 0 47.83 61.046 20.78 20.78 45.61 4.046 + 433 gctagctgatcatcgatgctact 191 23 0 47.83 61.046 12.59 8.92 0.00 4.046 + 434 agctagctgatcatcgatgctac 190 23 0 47.83 61.046 17.99 7.99 0.00 4.046 + 435 tagctagctactatcatctctgcg 350 24 0 45.83 60.058 27.80 0.00 0.00 4.058 + 436 ctagctagctactgatcgatgcta 301 24 0 45.83 60.058 14.00 12.23 0.00 4.058 + 437 agctactatcatctctgcgcga 355 22 0 50.00 62.058 2.71 2.71 0.00 4.058 + 438 gctatttagctagctgactgatcg 253 24 0 45.83 60.060 7.27 0.00 46.11 4.060 + 439 tgatcgatcatcatgctagctac 271 23 0 43.48 58.931 27.48 0.00 37.38 4.069 + 440 gtgatgcatgctagtagtgatg 29 22 0 45.45 57.921 7.49 7.49 0.00 4.079 + 441 ctagctagctgactgatcgatcg 106 23 0 52.17 61.091 16.84 13.89 0.00 4.091 + 442 ctagctactgatcgatgctaca 305 22 0 45.45 57.898 13.79 1.61 0.00 4.102 + 443 cggcgatctagctagctgacta 582 22 0 54.55 62.109 17.44 5.40 38.70 4.109 + 444 atgctagctaggcgatgc 410 18 0 55.56 57.890 10.59 0.00 0.00 4.110 + 445 ctgatcgatcatcatgctagctac 270 24 0 45.83 59.882 26.67 0.00 41.77 4.118 + 446 gctactagctagctgatcatca 505 22 0 45.45 57.879 14.37 0.00 44.92 4.121 + 447 gctactagctagctgatcatca 208 22 0 45.45 57.879 14.37 0.00 44.92 4.121 + 448 ctgactgatacgcgatgctagc 473 22 0 54.55 62.128 8.61 8.61 0.00 4.128 + 449 gctgactgatacgcgatgctag 472 22 0 54.55 62.128 1.70 0.00 0.00 4.128 + 450 ctagctgactgatacgcgatgc 469 22 0 54.55 62.128 3.47 0.00 0.00 4.128 + 451 gctagctgactgatacgcgatg 468 22 0 54.55 62.128 8.21 0.00 0.00 4.128 + 452 tgactgatcgatcatcatgctag 267 23 0 43.48 58.866 26.79 18.40 41.77 4.134 + 453 ctgactgatcgatcatcatgcta 266 23 0 43.48 58.866 20.99 8.89 41.77 4.134 + 454 tagctgactgatcgatcatcatg 263 23 0 43.48 58.866 22.70 19.51 41.77 4.134 + 455 ctagctagctgatcgatcgtagc 560 23 0 52.17 61.151 26.87 26.87 0.00 4.151 + 456 gctagctagctgatcgatcgtag 559 23 0 52.17 61.151 34.38 16.86 46.11 4.151 + 457 ctgatcgatcgatgctagctagg 399 23 0 52.17 61.158 22.67 6.29 35.21 4.158 + 458 gatcgatcgatgctagctagtag 120 23 0 47.83 58.829 23.89 2.63 35.21 4.171 + 459 ttagctagctgactgatcgatcat 258 24 0 41.67 60.177 28.29 18.02 36.62 4.177 + 460 ctgactgatcgatcatcatgctag 266 24 0 45.83 59.822 20.99 12.80 41.77 4.178 + 461 ctagctgactgatcgatcatcatg 262 24 0 45.83 59.822 22.70 19.51 41.77 4.178 + 462 ctagctgatcgatcgatgtgcg 75 22 0 54.55 62.180 31.92 20.85 42.69 4.180 + 463 tttagctagctgactgatcgatc 257 23 0 43.48 58.807 19.32 19.32 0.00 4.193 + 464 tgactgatcgatcatcatgcta 267 22 0 40.91 57.803 26.79 13.11 41.77 4.197 + 465 gctagctactatcatcgatcga 430 22 0 45.45 57.783 22.52 22.52 0.00 4.217 + 466 gatcgatcgatgctagctagta 120 22 0 45.45 57.783 23.89 18.77 35.21 4.217 + 467 agctagctactatcatcgatcg 429 22 0 45.45 57.777 17.56 9.87 0.00 4.223 + 468 atcgatcgatgctagctagtag 121 22 0 45.45 57.777 29.65 2.63 33.56 4.223 + 469 tgatcatcatcgatgctagctagt 518 24 0 41.67 60.238 22.18 3.56 40.32 4.238 + 470 tgatcgatcatcatgctagctact 271 24 0 41.67 60.238 27.48 0.00 37.38 4.238 + 471 actgatcgatcatcatgctagcta 269 24 0 41.67 60.238 26.67 2.76 41.77 4.238 + 472 catcgatcgatgctagtatgcta 325 23 0 43.48 58.753 37.80 6.23 44.93 4.247 + 473 tttagctagctgactgatcgat 257 22 0 40.91 57.736 0.38 0.00 0.00 4.264 + 474 atttagctagctgactgatcga 256 22 0 40.91 57.736 4.16 0.00 0.00 4.264 + 475 cgcgatcgatgctagcta 372 18 0 55.56 57.717 22.07 3.08 38.48 4.283 + 476 catcgatcgatgctagtatgctag 325 24 0 45.83 59.708 37.80 16.01 44.93 4.292 + 477 tagctagctactgatcgatgctac 302 24 0 45.83 60.297 27.80 7.81 0.00 4.297 + 478 agcatcggattagctagctgatg 3 23 0 47.83 61.299 27.81 27.81 33.28 4.299 + 479 agctagctgactgatacgcgat 467 22 0 50.00 62.317 17.99 0.00 0.00 4.317 + 480 tgatcatcatcgatgctagctag 518 23 0 43.48 58.678 17.46 17.46 40.32 4.322 + 481 ctgatcatcatcgatgctagcta 517 23 0 43.48 58.678 17.69 2.41 40.32 4.322 + 482 tagctgatcatcatcgatgctag 514 23 0 43.48 58.678 9.90 2.76 40.32 4.322 + 483 ctagctgatcatcatcgatgcta 513 23 0 43.48 58.678 14.58 9.63 40.32 4.322 + 484 tagctagctgatcatcatcgatg 510 23 0 43.48 58.678 20.23 20.23 41.48 4.322 + 485 ctgatcgatcatcatgctagcta 270 23 0 43.48 58.678 26.67 2.76 41.77 4.322 + 486 gatcatcatcgatgctagctagt 519 23 0 43.48 58.677 22.18 3.56 40.32 4.323 + 487 gatcgatcatcatgctagctact 272 23 0 43.48 58.677 21.11 0.00 0.00 4.323 + 488 gctagctagctgactgatcgatc 105 23 0 52.17 61.341 34.38 19.32 46.11 4.341 + 489 tgatcgatcgatgctagctagtag 119 24 0 45.83 60.356 26.44 2.63 35.21 4.356 + 490 ctgatcgatcgatgctagctagta 118 24 0 45.83 60.356 22.18 18.77 35.21 4.356 + 491 ctgatcatcatcgatgctagctag 517 24 0 45.83 59.644 17.46 17.46 40.32 4.356 + 492 ctagctgatcatcatcgatgctag 513 24 0 45.83 59.644 19.54 18.30 42.07 4.356 + 493 ctagctagctgatcatcatcgatg 509 24 0 45.83 59.644 20.23 20.23 41.48 4.356 + 494 tttagctagctgactgatcgatca 257 24 0 41.67 60.358 26.99 26.99 35.44 4.358 + 495 actatcatctctgcgcgatcga 359 22 0 50.00 62.365 22.07 1.72 38.48 4.365 + 496 agctgatcgatcgtagcg 566 18 0 55.56 57.634 25.02 11.96 0.00 4.366 + 497 gctactagctagctgactgatac 461 23 0 47.83 58.626 15.96 1.42 44.92 4.374 + 498 agctgatcgatcgatgctagct 397 22 0 50.00 62.388 30.32 30.32 38.42 4.388 + 499 agctagctgatcgatcgatgct 393 22 0 50.00 62.388 33.87 33.38 38.16 4.388 + 500 ctagctgactgatcgatcatcat 262 23 0 43.48 58.612 26.31 20.43 41.77 4.388 + 501 agctagctactatcatctctgc 351 22 0 45.45 57.608 17.56 0.00 0.00 4.392 + 502 ctagctactatcatctctgcgcg 353 23 0 52.17 61.393 0.00 0.00 0.00 4.393 + 503 tgatcatcatcgatgctagcta 518 22 0 40.91 57.602 17.69 3.08 40.32 4.398 + 504 tagctgatcatcatcgatgcta 514 22 0 40.91 57.602 15.95 9.16 40.32 4.398 + 505 tgatcgatcatcatgctagcta 271 22 0 40.91 57.602 27.48 3.08 37.38 4.398 + 506 atcatcatcgatgctagctagt 520 22 0 40.91 57.595 22.18 3.56 40.32 4.405 + 507 atcgatcatcatgctagctact 273 22 0 40.91 57.595 0.00 0.00 0.00 4.405 + 508 agctagctactatcatcgatcgat 429 24 0 41.67 59.573 25.37 25.37 35.13 4.427 + 509 gctagctgatcgatcgatgtgc 74 22 0 54.55 62.443 31.83 30.04 35.21 4.443 + 510 tagctgactgatcgatcatcat 263 22 0 40.91 57.531 26.31 20.43 41.77 4.469 + 511 tagctagctgactgatcgatcga 107 23 0 47.83 61.487 28.29 22.52 0.00 4.487 + 512 atcgatcgatgctagtatgctag 326 23 0 43.48 58.501 29.65 13.77 46.09 4.499 + 513 ctagtgatgcatgctagtagtga 26 23 0 43.48 58.483 20.00 1.46 0.00 4.517 + 514 tagctagctgactgatcgatcatc 259 24 0 45.83 60.536 28.29 21.92 36.62 4.536 + 515 tactagctagctgatcatcatcga 507 24 0 41.67 59.449 0.00 0.00 0.00 4.551 + 516 gctagctagctactatcatcga 426 22 0 45.45 57.437 34.38 0.00 46.11 4.563 + 517 tgactgatacgcgatgctagct 474 22 0 50.00 62.569 17.69 1.35 0.00 4.569 + 518 agctgactgatacgcgatgcta 471 22 0 50.00 62.569 7.57 0.00 0.00 4.569 + 519 tagctgactgatacgcgatgct 470 22 0 50.00 62.569 10.87 8.44 0.00 4.569 + 520 atcgatcgatgctagtatgcta 326 22 0 40.91 57.423 29.65 0.00 33.56 4.577 + 521 ctagctagctgatcatcatcgat 509 23 0 43.48 58.422 11.68 0.00 0.00 4.578 + 522 agctgactgatcgatcgatgct 112 22 0 50.00 62.580 26.44 23.13 35.21 4.580 + 523 ctagctagctgatcatcgatgcta 188 24 0 45.83 60.596 16.78 15.81 0.00 4.596 + 524 gtgatgcatgctagtagtgatgta 29 24 0 41.67 59.398 11.60 8.84 0.00 4.602 + 525 gctgatcatcatcgatgctagct 516 23 0 47.83 61.603 20.15 8.14 40.32 4.603 + 526 agctgatcatcatcgatgctagc 515 23 0 47.83 61.603 20.04 19.26 40.32 4.603 + 527 gctagctgatcatcatcgatgct 512 23 0 47.83 61.603 14.14 8.34 40.32 4.603 + 528 agctagctgatcatcatcgatgc 511 23 0 47.83 61.603 21.42 7.40 40.32 4.603 + 529 tagtgatgcatgctagtagtga 27 22 0 40.91 57.391 0.01 0.00 0.00 4.609 + 530 ctactagctagctgactgatacg 462 23 0 47.83 58.387 3.12 0.00 0.00 4.613 + 531 tagctactgatcgatgctacatc 306 23 0 43.48 58.368 13.79 0.00 37.97 4.632 + 532 gactgatacgcgatgctagctag 475 23 0 52.17 61.633 17.46 17.46 0.00 4.633 + 533 ctagctactgatcgatgctacat 305 23 0 43.48 58.364 13.79 0.09 0.00 4.636 + 534 gctagctactatcatctctgcgc 352 23 0 52.17 61.644 8.21 0.00 0.00 4.644 + 535 gctagctagctactgatcgatgc 300 23 0 52.17 61.644 34.38 12.71 46.11 4.644 + 536 gctactagctagctgatcatcat 505 23 0 43.48 58.350 14.37 0.00 44.92 4.650 + 537 gctactagctagctgatcatcat 208 23 0 43.48 58.350 14.37 0.00 44.92 4.650 + 538 ctagctactgatcgatgctacatc 305 24 0 45.83 59.349 13.79 0.00 37.97 4.651 + 539 gctactagctagctgatcatcatc 505 24 0 45.83 59.343 14.37 0.00 44.92 4.657 + 540 gctactagctagctgatcatcatc 208 24 0 45.83 59.343 14.37 0.00 44.92 4.657 + 541 gctgatcatcatctagctagtagc 154 24 0 45.83 59.343 15.25 15.25 45.79 4.657 + 542 tagctagctgatcatcatcgat 510 22 0 40.91 57.329 10.14 0.00 0.00 4.671 + 543 ctactatcatctctgcgcgatcg 357 23 0 52.17 61.686 12.19 12.19 39.07 4.686 + 544 tactagctagctgactgatacg 463 22 0 45.45 57.310 13.17 0.00 0.00 4.690 + 545 gctgatcgatcgatgctagctag 398 23 0 52.17 61.697 27.88 18.22 35.21 4.697 + 546 ctagctgatcgatcgatgctagc 395 23 0 52.17 61.697 38.64 35.38 43.05 4.697 + 547 gctagctgatcgatcgatgctag 394 23 0 52.17 61.697 41.07 41.07 46.89 4.697 + 548 ctagctagctgatcgatcgatgc 391 23 0 52.17 61.697 24.08 21.09 35.21 4.697 + 549 gctagctagctgatcgatcgatg 390 23 0 52.17 61.697 34.38 11.03 46.11 4.697 + 550 gctagctagctgatcgatcgatg 70 23 0 52.17 61.697 34.38 11.03 46.11 4.697 + 551 gctactagctagctgactgata 461 22 0 45.45 57.286 15.96 3.69 44.92 4.714 + 552 gatcgatcatcatgctagctac 272 22 0 45.45 57.284 21.11 0.00 0.00 4.716 + 553 cgatgctagctaggcgat 408 18 0 55.56 57.277 10.81 3.01 0.00 4.723 + 554 atcgatgctagctaggcg 406 18 0 55.56 57.277 15.59 9.02 0.00 4.723 + 555 tagctactgatcgatgctacat 306 22 0 40.91 57.270 13.79 0.09 0.00 4.730 + 556 gctagctactatcatcgatcgat 430 23 0 43.48 58.251 25.37 25.37 35.13 4.749 + 557 tgcatgctagtagtgatgtatacg 33 24 0 41.67 59.224 20.79 0.00 0.00 4.776 + 558 gcatgctagtagtgatgtatacgt 34 24 0 41.67 59.223 11.60 0.00 0.00 4.777 + 559 atttagctagctgactgatcgatc 256 24 0 41.67 59.219 19.32 19.32 0.00 4.781 + 560 gactgatcgatcatcatgctag 268 22 0 45.45 57.215 24.51 15.87 41.77 4.785 + 561 atttagctagctgactgatcgat 256 23 0 39.13 58.215 4.16 0.00 0.00 4.785 + 562 gctgactgatcgatcatcatgct 265 23 0 47.83 61.788 27.72 15.10 41.77 4.788 + 563 agctgactgatcgatcatcatgc 264 23 0 47.83 61.788 27.74 27.74 41.77 4.788 + 564 tagctactatcatctctgcgcga 354 23 0 47.83 61.796 2.71 2.71 0.00 4.796 + 565 gctgatcatcgatgctactagcta 195 24 0 45.83 60.834 20.91 7.37 45.92 4.834 + 566 tagctgatcatcgatgctactagc 193 24 0 45.83 60.834 20.78 20.78 45.61 4.834 + 567 gctagctgatcatcgatgctacta 191 24 0 45.83 60.834 11.65 8.83 0.00 4.834 + 568 tagctagctgatcatcgatgctac 189 24 0 45.83 60.834 17.82 12.06 0.00 4.834 + 569 tagtgatgcatgctagtagtgatg 27 24 0 41.67 59.155 11.56 7.49 0.00 4.845 + 570 agtgatgcatgctagtagtgatgt 28 24 0 41.67 60.846 11.60 0.00 0.00 4.846 + 571 tgatgcatgctagtagtgatgta 30 23 0 39.13 58.147 11.60 8.84 0.00 4.853 + 572 ctgactgatcgatcgatgctagc 114 23 0 52.17 61.878 18.17 12.52 35.21 4.878 + 573 gctgactgatcgatcgatgctag 113 23 0 52.17 61.878 22.81 19.44 35.21 4.878 + 574 ctagctgactgatcgatcgatgc 110 23 0 52.17 61.878 24.08 19.43 35.21 4.878 + 575 gctagctgactgatcgatcgatg 109 23 0 52.17 61.878 23.05 13.21 35.21 4.878 + 576 tcatcatcgatgctagctagtag 521 23 0 43.48 58.114 2.81 0.00 40.32 4.886 + 577 tactagctagctgatcatcatcg 507 23 0 43.48 58.114 0.00 0.00 0.00 4.886 + 578 tcgatcatcatgctagctactag 274 23 0 43.48 58.114 0.00 0.00 37.62 4.886 + 579 tgatcatcgatgctactagctag 197 23 0 43.48 58.114 20.04 20.04 45.92 4.886 + 580 ctgatcatcgatgctactagcta 196 23 0 43.48 58.114 10.86 0.00 45.92 4.886 + 581 tagctgatcatcgatgctactag 193 23 0 43.48 58.114 13.67 9.68 0.00 4.886 + 582 ctagctgatcatcgatgctacta 192 23 0 43.48 58.114 11.65 8.83 0.00 4.886 + 583 ctactagctagctgatcatcatcg 506 24 0 45.83 59.110 1.08 0.00 0.00 4.890 + 584 ctgatcatcgatgctactagctag 196 24 0 45.83 59.110 20.04 20.04 45.92 4.890 + 585 ctagctgatcatcgatgctactag 192 24 0 45.83 59.110 15.68 15.68 0.00 4.890 + 586 gctagctagctgatcatcatctag 146 24 0 45.83 59.102 34.38 13.13 44.71 4.898 + 587 gctagctagctgatcatcatcta 146 23 0 43.48 58.097 34.38 0.00 46.11 4.903 + 588 ctagtgatgcatgctagtagtg 26 22 0 45.45 57.072 20.00 3.96 0.00 4.928 + 589 gctactatcatctctgcgcgatc 356 23 0 52.17 61.936 4.99 0.00 0.00 4.936 + 590 gctgatcgatcgatgtgc 78 18 0 55.56 57.052 29.71 26.38 35.21 4.948 + 591 tagctagctactatcatcgatcga 428 24 0 41.67 59.031 27.80 22.52 0.00 4.969 + 592 agctagctgatcgatcgtagcg 562 22 0 54.55 62.971 27.20 18.31 0.00 4.971 + 593 tgactgatacgcgatgct 474 18 0 50.00 57.028 2.33 0.00 0.00 4.972 + 594 gatcatcatcgatgctagctag 519 22 0 45.45 57.019 17.46 17.46 40.32 4.981 + 595 tcatcatcgatgctagctagta 521 22 0 40.91 57.005 22.18 18.77 40.32 4.995 + 596 tcgatcatcatgctagctacta 274 22 0 40.91 57.005 0.00 0.00 0.00 4.995 + 597 tgatcatcgatgctactagcta 197 22 0 40.91 57.005 17.14 1.01 45.92 4.995 + 598 tagctgatcatcgatgctacta 193 22 0 40.91 57.005 12.62 8.42 0.00 4.995 + 599 tagctagctgactgatacgcgat 466 23 0 47.83 62.044 28.29 0.00 0.00 5.044 + 600 ctagctagctactatcatcgatcga 427 25 0 44.00 59.949 27.80 22.52 0.00 5.051 + 601 agctagctgactgatcgatcgat 108 23 0 47.83 62.053 30.53 30.53 37.90 5.053 + 602 ctactagctagctgactgatacgc 462 24 0 50.00 61.062 3.61 0.00 0.00 5.062 + 603 gctactagctagctgactgatacg 461 24 0 50.00 61.062 14.37 0.00 44.92 5.062 + 604 tgatcatcatcgatgctagctagta 518 25 0 40.00 60.062 22.18 18.77 40.32 5.062 + 605 tgatcgatcatcatgctagctacta 271 25 0 40.00 60.062 27.48 0.00 37.38 5.062 + 606 ctagtgatgcatgctagtagtgatg 26 25 0 44.00 60.064 20.00 7.49 0.00 5.064 + 607 gctagctagctactatcatcgatc 426 24 0 45.83 58.932 34.38 4.20 46.11 5.068 + 608 gctagctactgatcgatgctacat 304 24 0 45.83 61.072 11.21 0.00 0.00 5.072 + 609 gctagctagctactatcatcgat 426 23 0 43.48 57.922 34.38 0.00 46.11 5.078 + 610 ctagtgatgcatgctagtagtgat 26 24 0 41.67 58.911 20.00 4.64 0.00 5.089 + 611 tactatcatctctgcgcgatcga 358 23 0 47.83 62.092 22.07 1.72 38.48 5.092 + 612 agctgatcgatcgatgctagcta 397 23 0 47.83 62.111 31.26 14.51 40.03 5.111 + 613 tagctgatcgatcgatgctagct 396 23 0 47.83 62.111 33.22 33.22 42.08 5.111 + 614 agctagctgatcgatcgatgcta 393 23 0 47.83 62.111 34.11 32.56 36.80 5.111 + 615 tagctagctgatcgatcgatgct 392 23 0 47.83 62.111 33.87 33.38 38.16 5.111 + 616 tagtgatgcatgctagtagtgat 27 23 0 39.13 57.886 11.56 0.00 0.00 5.114 + 617 tactagctagctgatcatcatcgat 507 25 0 40.00 59.828 0.00 0.00 0.00 5.172 + 618 gctagctagctgatcatcgatgc 187 23 0 52.17 62.193 34.38 9.22 46.11 5.193 + 619 gctagtgatgcatgctagtagtga 25 24 0 45.83 61.195 24.96 4.57 0.00 5.195 + 620 aaagcatcggattagctagctgat 1 24 0 41.67 61.209 17.84 15.13 0.00 5.209 + 621 gtgatgcatgctagtagtgatgtat 29 25 0 40.00 59.774 1.07 1.07 0.00 5.226 + 622 ctatcatctctgcgcgatcgatg 360 23 0 52.17 62.227 18.01 18.01 38.48 5.227 + 623 tgactgatacgcgatgctagcta 474 23 0 47.83 62.287 17.69 3.08 0.00 5.287 + 624 tagctgactgatacgcgatgcta 470 23 0 47.83 62.287 12.64 9.09 0.00 5.287 + 625 tgctagtagtgatgtatacgtagct 37 25 0 40.00 59.713 9.37 8.73 0.00 5.287 + 626 tgactgatcgatcgatgctagct 115 23 0 47.83 62.296 20.19 11.59 35.21 5.296 + 627 agctgactgatcgatcgatgcta 112 23 0 47.83 62.296 26.44 14.64 35.21 5.296 + 628 tagctgactgatcgatcgatgct 111 23 0 47.83 62.296 31.98 30.27 35.21 5.296 + 629 ctagctagctactatcatcgatcg 427 24 0 45.83 58.703 12.49 9.87 0.00 5.297 + 630 tagctagctactatcatcgatcg 428 23 0 43.48 57.691 27.80 9.87 0.00 5.309 + 631 gactgatcgatcatcatgctagct 268 24 0 45.83 61.313 24.51 7.81 41.77 5.313 + 632 gctagctgactgatcgatcatcat 261 24 0 45.83 61.313 26.31 20.43 41.77 5.313 + 633 ctatttagctagctgactgatcga 254 24 0 41.67 58.679 0.00 0.00 0.00 5.321 + 634 gcatgctagtagtgatgtatacg 34 23 0 43.48 57.659 11.60 0.00 0.00 5.341 + 635 tatttagctagctgactgatcga 255 23 0 39.13 57.650 0.00 0.00 0.00 5.350 + 636 ctactagctagctgatcatcatcga 506 25 0 44.00 60.352 1.08 0.00 0.00 5.352 + 637 agctactatcatctctgcgcgat 355 23 0 47.83 62.360 4.99 2.52 0.00 5.360 + 638 gctgatcatcatcgatgctagcta 516 24 0 45.83 61.370 20.15 8.49 40.32 5.370 + 639 tagctgatcatcatcgatgctagc 514 24 0 45.83 61.370 20.04 19.26 40.32 5.370 + 640 gctagctgatcatcatcgatgcta 512 24 0 45.83 61.370 14.58 9.63 40.32 5.370 + 641 tagctagctgatcatcatcgatgc 510 24 0 45.83 61.370 21.42 7.40 40.32 5.370 + 642 atgcatgctagtagtgatgtatacg 32 25 0 40.00 59.604 11.70 0.00 0.00 5.396 + 643 tgatgcatgctagtagtgatgtat 30 24 0 37.50 58.592 12.66 12.66 0.00 5.408 + 644 gactgatcgatcgatgctagctag 116 24 0 50.00 61.409 18.04 17.46 35.21 5.409 + 645 gctatttagctagctgactgatc 253 23 0 43.48 57.572 7.27 0.00 46.11 5.428 + 646 tgctagtgatgcatgctagtagtg 24 24 0 45.83 61.434 24.96 10.54 35.89 5.434 + 647 ctagctagctactatcatctctgc 349 24 0 45.83 58.562 27.80 0.00 0.00 5.438 + 648 gctagctagctactatcatctctg 348 24 0 45.83 58.562 34.38 6.79 46.11 5.438 + 649 gatcatcatcgatgctagctagta 519 24 0 41.67 58.557 22.18 18.77 40.32 5.443 + 650 gatcgatcatcatgctagctacta 272 24 0 41.67 58.557 21.11 0.00 0.00 5.443 + 651 atcatcatcgatgctagctagtag 520 24 0 41.67 58.554 2.13 0.00 40.32 5.446 + 652 atcgatcatcatgctagctactag 273 24 0 41.67 58.554 0.00 0.00 37.62 5.446 + 653 tagctagctactatcatctctgc 350 23 0 43.48 57.527 27.80 0.00 0.00 5.473 + 654 atcatcatcgatgctagctagta 520 23 0 39.13 57.514 22.18 18.77 40.32 5.486 + 655 atcgatcatcatgctagctacta 273 23 0 39.13 57.514 0.00 0.00 0.00 5.486 + 656 gatcatcatcgatgctagctagtag 519 25 0 44.00 59.494 0.21 0.00 40.32 5.506 + 657 gatcgatcatcatgctagctactag 272 25 0 44.00 59.494 21.11 0.00 37.62 5.506 + 658 actagctagctgatcatcatctact 211 25 0 40.00 59.471 22.43 6.99 0.00 5.529 + 659 tgactgatcgatcatcatgctagc 267 24 0 45.83 61.547 26.79 14.13 41.77 5.547 + 660 gctgactgatcgatcatcatgcta 265 24 0 45.83 61.547 27.72 16.42 41.77 5.547 + 661 tagctgactgatcgatcatcatgc 263 24 0 45.83 61.547 27.74 27.74 41.77 5.547 + 662 tgctagtagtgatgtatacgtagc 37 24 0 41.67 58.446 4.93 4.93 0.00 5.554 + 663 ctagctagctgactgatacgcga 465 23 0 52.17 62.571 14.90 0.00 0.00 5.571 + 664 tagctagctactatcatcgatcgat 428 25 0 40.00 59.423 27.80 25.37 35.13 5.577 + 665 gctactagctagctgatcatcatct 208 25 0 44.00 60.585 14.37 0.00 44.92 5.585 + 666 agctgatcatcatctagctagtagc 153 25 0 44.00 60.585 15.25 15.25 40.45 5.585 + 667 ctagctagctgatcgatcgatgtg 71 24 0 50.00 61.642 11.68 4.94 35.21 5.642 + 668 agtgatgcatgctagtagtgatgta 28 25 0 40.00 60.646 11.60 8.84 0.00 5.646 + 669 tagtgatgcatgctagtagtgatgt 27 25 0 40.00 60.646 11.60 0.00 0.00 5.646 + 670 actatcatctctgcgcgatcgat 359 23 0 47.83 62.652 22.07 11.47 38.48 5.652 + 671 ctatttagctagctgactgatcg 254 23 0 43.48 57.339 0.00 0.00 0.00 5.661 + 672 tagctagctgatcgatcgtagcg 561 23 0 52.17 62.677 27.20 18.31 0.00 5.677 + 673 gcatcggattagctagctgatgc 4 23 0 52.17 62.687 34.10 34.10 41.15 5.687 + 674 tgcatgctagtagtgatgtatacgt 33 25 0 40.00 60.700 20.79 0.00 0.00 5.700 + 675 tttagctagctgactgatcgatcat 257 25 0 40.00 60.702 26.67 18.02 36.62 5.702 + 676 atttagctagctgactgatcgatca 256 25 0 40.00 60.702 26.99 26.99 35.44 5.702 + 677 gctagctagctactatcatctct 348 23 0 43.48 57.266 34.38 0.00 46.11 5.734 + 678 aagcatcggattagctagctgatg 2 24 0 45.83 61.794 27.81 27.81 33.28 5.794 + 679 agtgatgtatacgtagctagtagc 44 24 0 41.67 58.201 15.25 15.25 45.79 5.799 + 680 gctagtagtgatgtatacgtagct 38 24 0 41.67 58.201 5.92 5.92 0.00 5.799 + 681 tagctagctgactgatcgatcgat 107 24 0 45.83 61.800 30.53 30.53 37.90 5.800 + 682 actagctagctgactgatacgcg 464 23 0 52.17 62.816 21.52 3.89 0.00 5.816 + 683 actagctagctgatcatcatctac 211 24 0 41.67 58.178 22.43 0.00 0.00 5.822 + 684 tagctgatcgatcgatgctagcta 396 24 0 45.83 61.857 34.98 33.55 41.05 5.857 + 685 tagctagctgatcgatcgatgcta 392 24 0 45.83 61.857 34.11 32.56 36.80 5.857 + 686 tatttagctagctgactgatcgat 255 24 0 37.50 58.112 1.68 0.00 0.00 5.888 + 687 gcatgctagtagtgatgtatacgta 34 25 0 40.00 59.089 11.60 0.00 0.00 5.911 + 688 tatttagctagctgactgatcgatc 255 25 0 40.00 59.084 19.32 19.32 0.00 5.916 + 689 ctatttagctagctgactgatcgat 254 25 0 40.00 59.082 0.00 0.00 0.00 5.918 + 690 ctagctagctactatcatctctgcg 349 25 0 48.00 60.920 27.80 5.75 0.00 5.920 + 691 tgatcgatcgatgctagctaggc 400 23 0 52.17 62.955 26.44 12.49 35.21 5.955 + 692 agctagctactgatcgatgctaca 303 24 0 45.83 61.988 17.56 3.03 0.00 5.988 + 693 tgactgatcgatcgatgctagcta 115 24 0 45.83 62.034 20.19 11.16 35.21 6.034 + 694 tagctgactgatcgatcgatgcta 111 24 0 45.83 62.034 33.43 30.74 35.21 6.034 + 695 catgctagtagtgatgtatacgtagc 35 26 0 42.31 59.961 4.93 4.93 0.00 6.039 + 696 gcatgctagtagtgatgtatacgtag 34 26 0 42.31 59.961 11.60 0.00 0.00 6.039 + 697 actgatcgatcgatgctagctagt 117 24 0 45.83 62.039 23.29 15.07 35.21 6.039 + 698 ctatttagctagctgactgatcgatc 254 26 0 42.31 59.960 19.32 19.32 0.00 6.040 + 699 ttagctagctgactgatcgatcatc 258 25 0 44.00 61.041 28.29 21.92 36.62 6.041 + 700 atgctagtagtgatgtatacgtagct 36 26 0 38.46 60.068 9.37 8.73 0.00 6.068 + 701 ctagctagctgatcatcatctact 212 24 0 41.67 57.930 11.68 6.99 0.00 6.070 + 702 ctactagctagctgatcatcatct 209 24 0 41.67 57.930 1.08 0.00 0.00 6.070 + 703 agctgatcatcatctagctagtag 153 24 0 41.67 57.930 7.49 3.73 40.45 6.070 + 704 ctagctgatcatcatctagctagt 151 24 0 41.67 57.930 21.70 5.56 46.15 6.070 + 705 tagctactatcatctctgcgcgat 354 24 0 45.83 62.096 4.99 2.52 0.00 6.096 + 706 gactgatcgatcatcatgctagcta 268 25 0 44.00 61.099 24.51 4.57 41.77 6.099 + 707 ctgatcatcatcgatgctagctagt 517 25 0 44.00 61.101 22.18 3.56 40.32 6.101 + 708 actagctagctgatcatcatcgatg 508 25 0 44.00 61.101 22.43 20.23 41.48 6.101 + 709 ctgatcgatcatcatgctagctact 270 25 0 44.00 61.101 26.67 0.00 41.77 6.101 + 710 atgctagtagtgatgtatacgtagc 36 25 0 40.00 58.855 4.93 4.93 0.00 6.145 + 711 ctagctagctactgatcgatgctac 301 25 0 48.00 61.145 14.00 7.81 0.00 6.145 + 712 gctagctagctactatcatctctgc 348 25 0 48.00 61.152 34.38 11.74 46.11 6.152 + 713 agctagctgatcatcatctactatca 214 26 0 38.46 59.840 17.99 0.00 0.00 6.160 + 714 ctgatcgatcgatgctagctagtag 118 25 0 48.00 61.197 19.70 5.49 35.21 6.197 + 715 agctagctgactgatcgatcatca 260 24 0 45.83 62.232 26.49 26.49 39.98 6.232 + 716 gctagctagctactatcatcgatcg 426 25 0 48.00 61.252 34.38 9.87 46.11 6.252 + 717 gctatttagctagctgactgatcga 253 25 0 44.00 61.268 7.27 0.00 46.11 6.268 + 718 ctagctagctactatcatcgatcgat 427 26 0 42.31 60.291 27.80 25.37 35.13 6.291 + 719 agctgatcatcgatgctactagct 194 24 0 45.83 62.294 24.11 23.60 45.92 6.294 + 720 agctagctgatcatcgatgctact 190 24 0 45.83 62.294 17.99 10.88 0.00 6.294 + 721 ctagctagctgactgatcgatcga 106 24 0 50.00 62.312 22.52 22.52 0.00 6.312 + 722 actgatcgatcatcatgctagctac 269 25 0 44.00 61.328 26.67 0.00 41.77 6.328 + 723 tgatgcatgctagtagtgatgtatac 30 26 0 38.46 59.623 9.19 6.43 0.00 6.377 + 724 gtgatgcatgctagtagtgatgtata 29 26 0 38.46 59.623 4.23 0.00 0.00 6.377 + 725 tactatcatctctgcgcgatcgat 358 24 0 45.83 62.379 22.07 11.47 38.48 6.379 + 726 gctagctgatcatcatctactatca 215 25 0 40.00 58.607 8.21 0.00 0.00 6.393 + 727 gctactagctagctgatcatcatcta 208 26 0 42.31 60.404 14.37 0.00 44.92 6.404 + 728 tagctgatcatcatctagctagtagc 152 26 0 42.31 60.404 15.25 15.25 41.48 6.404 + 729 tgctagtagtgatgtatacgtagcta 37 26 0 38.46 59.564 10.00 8.05 0.00 6.436 + 730 gatgcatgctagtagtgatgtatacg 31 26 0 42.31 60.453 7.40 0.00 0.00 6.453 + 731 tagtgatgcatgctagtagtgatgta 27 26 0 38.46 60.461 11.60 8.84 0.00 6.461 + 732 gctagtgatgcatgctagtagtgat 25 25 0 44.00 61.506 24.96 8.51 0.00 6.506 + 733 tgcatgctagtagtgatgtatacgta 33 26 0 38.46 60.515 20.79 0.00 0.00 6.515 + 734 tatttagctagctgactgatcgatca 255 26 0 38.46 60.516 26.99 26.99 35.44 6.516 + 735 tgatgcatgctagtagtgatgtata 30 25 0 36.00 58.479 4.13 0.00 0.00 6.521 + 736 tactagctagctgactgatacgcg 463 24 0 50.00 62.538 13.17 3.89 0.00 6.538 + 737 ctagctactatcatctctgcgcga 353 24 0 50.00 62.603 2.71 2.71 0.00 6.603 + 738 agctagctgatcatcatctactatc 214 25 0 40.00 58.369 17.99 0.00 0.00 6.631 + 739 agctagctgatcatcatctactat 214 24 0 37.50 57.345 17.99 0.00 0.00 6.655 + 740 gctactagctagctgatcatcatcg 505 25 0 48.00 61.656 14.37 0.00 44.92 6.656 + 741 gctgatcatcgatgctactagctag 195 25 0 48.00 61.656 20.91 20.04 45.92 6.656 + 742 ctagctgatcatcgatgctactagc 192 25 0 48.00 61.656 20.78 20.78 45.61 6.656 + 743 gctagctgatcatcgatgctactag 191 25 0 48.00 61.656 20.13 20.13 0.00 6.656 + 744 ctagctagctgatcatcgatgctac 188 25 0 48.00 61.656 17.82 12.06 0.00 6.656 + 745 actagctagctgatcatcatctacta 211 26 0 38.46 59.328 22.43 8.11 0.00 6.672 + 746 tactagctagctgatcatcatctact 210 26 0 38.46 59.328 6.99 6.99 0.00 6.672 + 747 ctactagctagctgatcatcatcgat 506 26 0 42.31 60.681 1.08 0.00 0.00 6.681 + 748 tagctagctactgatcgatgctaca 302 25 0 44.00 61.746 27.80 5.02 0.00 6.746 + 749 gtagtgatgtatacgtagctagtagc 42 26 0 42.31 59.249 15.25 15.25 45.79 6.751 + 750 actgatcgatcgatgctagctagta 117 25 0 44.00 61.797 23.29 18.77 35.21 6.797 + 751 gatgcatgctagtagtgatgtatac 31 25 0 40.00 58.175 20.79 1.70 0.00 6.825 + 752 agctgatcatcatcgatgctagct 515 24 0 45.83 62.835 23.00 22.41 41.74 6.835 + 753 agctagctgatcatcatcgatgct 511 24 0 45.83 62.835 17.99 8.34 40.32 6.835 + 754 ctagctagctgactgatacgcgat 465 24 0 50.00 62.838 14.90 0.00 0.00 6.838 + 755 atgcatgctagtagtgatgtatac 32 24 0 37.50 57.161 11.70 0.53 0.00 6.839 + 756 agctagctactatcatctctgcgc 351 24 0 50.00 62.858 17.56 0.00 0.00 6.858 + 757 gctagctagctactgatcgatgct 300 24 0 50.00 62.858 34.38 11.51 46.11 6.858 + 758 ctactatcatctctgcgcgatcga 357 24 0 50.00 62.878 22.07 1.72 38.48 6.878 + 759 gctagctactgatcgatgctacatc 304 25 0 48.00 61.879 11.21 4.40 37.97 6.879 + 760 tagtgatgtatacgtagctagtagc 43 25 0 40.00 58.104 15.25 15.25 45.79 6.896 + 761 gctagtagtgatgtatacgtagcta 38 25 0 40.00 58.104 7.24 5.34 0.00 6.896 + 762 tgatcatcatcgatgctagctagtag 518 26 0 42.31 60.902 14.93 0.00 40.32 6.902 + 763 ctgatcatcatcgatgctagctagta 517 26 0 42.31 60.902 22.18 18.77 40.32 6.902 + 764 tactagctagctgatcatcatcgatg 507 26 0 42.31 60.902 20.23 20.23 41.48 6.902 + 765 tgatcgatcatcatgctagctactag 271 26 0 42.31 60.902 27.48 0.00 37.38 6.902 + 766 ctgatcgatcatcatgctagctacta 270 26 0 42.31 60.902 26.67 1.37 41.77 6.902 + 767 agctgatcgatcgatgctagctag 397 24 0 50.00 62.904 31.26 19.90 40.03 6.904 + 768 ctagctgatcgatcgatgctagct 395 24 0 50.00 62.904 35.51 33.22 43.05 6.904 + 769 agctagctgatcgatcgatgctag 393 24 0 50.00 62.904 41.07 41.07 46.89 6.904 + 770 ctagctagctgatcgatcgatgct 391 24 0 50.00 62.904 33.87 33.38 38.16 6.904 + 771 tactagctagctgatcatcatctac 210 25 0 40.00 58.081 0.00 0.00 0.00 6.919 + 772 gctagctgatcatcatctactatc 215 24 0 41.67 57.062 8.21 0.00 0.00 6.938 + 773 agtgatgcatgctagtagtgatgtat 28 26 0 38.46 60.969 1.07 1.07 0.00 6.969 + 774 gctagtagtgatgtatacgtagctag 38 26 0 42.31 59.027 8.99 8.99 0.00 6.973 + 775 tagctagctgactgatcgatcatca 259 25 0 44.00 61.981 28.29 26.49 39.98 6.981 + 776 ctactagctagctgatcatcatctac 209 26 0 42.31 59.015 1.08 0.00 0.00 6.985 + 777 agtagtgatgtatacgtagctagt 41 24 0 37.50 57.012 8.68 8.68 0.00 6.988 + 778 gctagctgatcatcatctactatcat 215 26 0 38.46 59.001 8.21 0.00 0.00 6.999 + 779 agctgatcatcatctactatcatca 218 25 0 36.00 57.993 0.00 0.00 0.00 7.007 + 780 atgcatgctagtagtgatgtatacgt 32 26 0 38.46 61.018 11.70 0.00 0.00 7.018 + 781 atttagctagctgactgatcgatcat 256 26 0 38.46 61.022 26.67 18.02 36.62 7.022 + 782 agctgatcatcgatgctactagcta 194 25 0 44.00 62.040 24.59 9.79 45.92 7.040 + 783 tagctgatcatcgatgctactagct 193 25 0 44.00 62.040 27.00 27.00 45.92 7.040 + 784 agctagctgatcatcgatgctacta 190 25 0 44.00 62.040 17.99 11.59 0.00 7.040 + 785 tagctagctgatcatcgatgctact 189 25 0 44.00 62.040 17.55 15.53 0.00 7.040 + 786 atgctagtagtgatgtatacgtagcta 36 27 0 37.04 59.911 10.00 8.05 0.00 7.089 + 787 gctagctgatcatcatctactatcatc 215 27 0 40.74 59.861 8.21 0.00 0.00 7.139 + 788 ctagctagctgatcatcatctacta 212 25 0 40.00 57.842 11.68 8.11 0.00 7.158 + 789 ctactagctagctgatcatcatcta 209 25 0 40.00 57.842 1.08 0.00 0.00 7.158 + 790 tagctgatcatcatctagctagtag 152 25 0 40.00 57.842 13.40 3.73 41.48 7.158 + 791 ctagctgatcatcatctagctagta 151 25 0 40.00 57.842 21.70 7.13 46.15 7.158 + 792 gctgatcatcatcgatgctagctag 516 25 0 48.00 62.165 20.15 17.46 40.32 7.165 + 793 ctagctgatcatcatcgatgctagc 513 25 0 48.00 62.165 19.27 19.26 41.96 7.165 + 794 gctagctgatcatcatcgatgctag 512 25 0 48.00 62.165 23.70 23.70 45.51 7.165 + 795 ctagctagctgatcatcatcgatgc 509 25 0 48.00 62.165 21.42 7.40 40.32 7.165 + 796 agctagctgatcatcatctactatcat 214 27 0 37.04 60.181 17.99 0.00 0.00 7.181 + 797 ctactagctagctgatcatcatctact 209 27 0 40.74 60.181 6.99 6.99 0.00 7.181 + 798 ctagctgatcatcatctagctagtag 151 26 0 42.31 58.789 21.70 10.73 46.15 7.211 + 799 aaagcatcggattagctagctgatg 1 25 0 44.00 62.249 27.81 27.81 33.28 7.249 + 800 agctagctactgatcgatgctacat 303 25 0 44.00 62.272 17.56 6.16 0.00 7.272 + 801 tagctagctgatcatcatctactatca 213 27 0 37.04 59.689 8.31 0.00 0.00 7.311 + 802 actagctagctgatcatcatctactat 211 27 0 37.04 59.688 22.43 2.36 0.00 7.312 + 803 ctgactgatcgatcatcatgctagc 266 25 0 48.00 62.333 20.99 8.86 41.77 7.333 + 804 gctgactgatcgatcatcatgctag 265 25 0 48.00 62.333 27.72 21.73 41.77 7.333 + 805 ctagctgactgatcgatcatcatgc 262 25 0 48.00 62.333 27.74 27.74 41.77 7.333 + 806 gctagctgactgatcgatcatcatg 261 25 0 48.00 62.333 22.70 19.51 41.77 7.333 + 807 tgctagtagtgatgtatacgtagctag 37 27 0 40.74 60.395 8.99 8.99 0.00 7.395 + 808 agtagtgatgtatacgtagctagtagc 41 27 0 40.74 60.395 15.25 15.25 45.79 7.395 + 809 gctagtagtgatgtatacgtagctagt 38 27 0 40.74 60.395 15.55 15.55 0.00 7.395 + 810 ctagtgatgcatgctagtagtgatgt 26 26 0 42.31 61.460 20.00 0.00 0.00 7.460 + 811 gctgatcatcatctactatcatcatca 219 27 0 37.04 59.533 0.00 0.00 0.00 7.467 + 812 agctagctgactgatcgatcatcat 260 25 0 44.00 62.507 26.31 20.43 41.77 7.507 + 813 tttagctagctgactgatcgatcatc 257 26 0 42.31 61.507 23.93 21.92 36.62 7.507 + 814 catgctagtagtgatgtatacgtag 35 25 0 40.00 57.441 4.74 0.00 0.00 7.559 + 815 agctgatcatcatcgatgctagcta 515 25 0 44.00 62.561 23.50 10.90 43.19 7.561 + 816 tagctgatcatcatcgatgctagct 514 25 0 44.00 62.561 26.21 26.21 44.79 7.561 + 817 agctagctgatcatcatcgatgcta 511 25 0 44.00 62.561 17.99 9.63 40.32 7.561 + 818 tagctagctgatcatcatcgatgct 510 25 0 44.00 62.561 14.14 10.38 40.32 7.561 + 819 gctatttagctagctgactgatcgat 253 26 0 42.31 61.564 7.27 0.00 46.11 7.564 + 820 ctagctagctgactgatcgatcgat 106 25 0 48.00 62.579 30.53 30.53 37.90 7.579 + 821 agctgatcatcatctactatcatcat 218 26 0 34.62 58.415 0.00 0.00 0.00 7.585 + 822 tagctagctactatcatctctgcgc 350 25 0 48.00 62.587 27.80 0.00 0.00 7.587 + 823 gctagctagctactgatcgatgcta 300 25 0 48.00 62.587 34.38 12.23 46.11 7.587 + 824 tgctagtgatgcatgctagtagtga 24 25 0 44.00 62.622 24.96 13.57 35.89 7.622 + 825 tagctgatcgatcgatgctagctag 396 25 0 48.00 62.632 33.71 21.46 41.05 7.632 + 826 ctagctgatcgatcgatgctagcta 395 25 0 48.00 62.632 35.51 32.61 43.05 7.632 + 827 tagctagctgatcgatcgatgctag 392 25 0 48.00 62.632 41.07 41.07 46.89 7.632 + 828 ctagctagctgatcgatcgatgcta 391 25 0 48.00 62.632 34.11 32.56 36.80 7.632 + 829 gtgatgcatgctagtagtgatgtatac 29 27 0 40.74 60.659 9.56 7.17 0.00 7.659 + 830 agctgatcatcatctactatcatcatc 218 27 0 37.04 59.314 0.00 0.00 0.00 7.686 + 831 tagctagctgatcatcatctactat 213 25 0 36.00 57.279 8.31 0.00 0.00 7.721 + 832 tagctagctgatcatcatctactatc 213 26 0 38.46 58.269 8.31 0.00 0.00 7.731 + 833 tgactgatcgatcatcatgctagct 267 25 0 44.00 62.733 26.79 10.55 41.77 7.733 + 834 agctgactgatcgatcatcatgcta 264 25 0 44.00 62.733 30.60 18.10 41.77 7.733 + 835 tagctgactgatcgatcatcatgct 263 25 0 44.00 62.733 32.31 32.31 41.77 7.733 + 836 ctagctagctgatcatcatctactat 212 26 0 38.46 58.265 9.41 0.00 0.00 7.735 + 837 agtgatgcatgctagtagtgatgtata 28 27 0 37.04 60.779 4.23 0.00 0.00 7.779 + 838 tagtgatgcatgctagtagtgatgtat 27 27 0 37.04 60.779 11.56 0.00 0.00 7.779 + 839 tgactgatcgatcgatgctagctag 115 25 0 48.00 62.800 20.19 17.46 35.21 7.800 + 840 ctgactgatcgatcgatgctagcta 114 25 0 48.00 62.800 20.19 11.97 35.21 7.800 + 841 tagctgactgatcgatcgatgctag 111 25 0 48.00 62.800 31.45 26.34 35.21 7.800 + 842 ctagctgactgatcgatcgatgcta 110 25 0 48.00 62.800 31.54 29.68 35.21 7.800 + 843 tagctagctgactgatcgatcgatg 107 25 0 48.00 62.800 28.29 13.21 35.21 7.800 + 844 gactgatcgatcgatgctagctagt 116 25 0 48.00 62.802 22.18 12.64 35.21 7.802 + 845 tactagctagctgatcatcatctacta 210 27 0 37.04 59.196 8.79 8.11 0.00 7.804 + 846 tagctgatcatcgatgctactagcta 193 26 0 42.31 61.805 28.86 27.39 45.92 7.805 + 847 tagctagctgatcatcgatgctacta 189 26 0 42.31 61.805 18.93 16.03 0.00 7.805 + 848 atgcatgctagtagtgatgtatacgta 32 27 0 37.04 60.828 11.70 0.00 0.00 7.828 + 849 tatttagctagctgactgatcgatcat 255 27 0 37.04 60.831 26.67 18.02 36.62 7.831 + 850 ctagctagctgatcatcatctactatc 212 27 0 40.74 59.162 9.41 0.06 0.00 7.838 + 851 tagctactatcatctctgcgcgatc 354 25 0 48.00 62.854 0.00 0.00 0.00 7.854 + 852 gctgatcatcatctactatcatcat 219 25 0 36.00 57.142 0.00 0.00 0.00 7.858 + 853 ctagctactatcatctctgcgcgat 353 25 0 48.00 62.859 4.99 2.52 0.00 7.859 + 854 gctgatcatcatctactatcatcatc 219 26 0 38.46 58.126 0.00 0.00 0.00 7.874 + 855 tagctagctactgatcgatgctacat 302 26 0 42.31 62.028 27.80 3.08 0.00 8.028 + 856 agtagtgatgtatacgtagctagtag 41 26 0 38.46 57.950 9.92 1.30 0.00 8.050 + 857 ctagtagtgatgtatacgtagctagt 39 26 0 38.46 57.950 15.52 15.52 0.00 8.050 + 858 catgctagtagtgatgtatacgtagct 35 27 0 40.74 61.089 9.37 8.73 0.00 8.089 + 859 gactgatcgatcatcatgctagctac 268 26 0 46.15 62.094 24.51 8.36 41.77 8.094 + 860 tagctgatcatcatctactatcatca 217 26 0 34.62 57.906 0.00 0.00 0.00 8.094 + 861 ctagctgatcatcatctactatcatca 216 27 0 37.04 58.826 0.00 0.00 0.00 8.174 + 862 ctagctgatcatcatctagctagtagc 151 27 0 44.44 61.196 21.70 15.25 46.15 8.196 + 863 tagctagctgactgatcgatcatcat 259 26 0 42.31 62.255 28.29 20.43 41.77 8.255 + 864 ctagtgatgcatgctagtagtgatgta 26 27 0 40.74 61.255 20.00 8.84 0.00 8.255 + 865 tgcatgctagtagtgatgtatacgtag 33 27 0 40.74 61.300 20.79 0.00 0.00 8.300 + 866 ctatttagctagctgactgatcgatca 254 27 0 40.74 61.304 26.99 26.99 35.44 8.304 + 867 tagctgatcatcatcgatgctagcta 514 26 0 42.31 62.307 28.23 26.63 43.19 8.307 + 868 tagctagctgatcatcatcgatgcta 510 26 0 42.31 62.307 14.58 11.03 40.32 8.307 + 869 gctagctagctactatcatcgatcga 426 26 0 46.15 62.381 34.38 22.52 46.11 8.381 + 870 gctactagctagctgatcatcatctac 208 27 0 44.44 61.407 14.37 0.00 44.92 8.407 + 871 ttagctagctgactgatcgatcatca 258 26 0 42.31 62.416 28.29 26.49 39.98 8.416 + 872 tgactgatcgatcatcatgctagcta 267 26 0 42.31 62.472 26.79 11.24 41.77 8.472 + 873 tagctgactgatcgatcatcatgcta 263 26 0 42.31 62.472 33.83 32.61 41.77 8.472 + 874 actgatcgatcatcatgctagctact 269 26 0 42.31 62.478 26.67 0.00 41.77 8.478 + 875 gctagtgatgcatgctagtagtgatg 25 26 0 46.15 62.484 24.96 9.07 0.00 8.484 + 876 ctagctagctactgatcgatgctaca 301 26 0 46.15 62.503 14.00 5.87 0.00 8.503 + 877 gactgatcgatcgatgctagctagta 116 26 0 46.15 62.543 22.18 18.77 35.21 8.543 + 878 actgatcgatcgatgctagctagtag 117 26 0 46.15 62.548 23.29 12.42 35.21 8.548 + 879 ctagctgatcatcatctactatcatc 216 26 0 38.46 57.395 0.00 0.00 0.00 8.605 + 880 ctgatcatcatcgatgctagctagtag 517 27 0 44.44 61.665 10.30 1.36 40.32 8.665 + 881 ctactagctagctgatcatcatcgatg 506 27 0 44.44 61.665 20.23 20.23 41.48 8.665 + 882 ctgatcgatcatcatgctagctactag 270 27 0 44.44 61.665 26.67 8.14 41.77 8.665 + 883 tagctgatcatcatctactatcatcat 217 27 0 33.33 58.315 0.00 0.00 0.00 8.685 + 884 tgatgcatgctagtagtgatgtatacg 30 27 0 40.74 61.778 9.81 0.00 0.00 8.778 + 885 gatgcatgctagtagtgatgtatacgt 31 27 0 40.74 61.779 7.40 0.00 0.00 8.779 + 886 gctactagctagctgatcatcatcga 505 26 0 46.15 62.779 14.37 0.00 44.92 8.779 + 887 agctgatcatcgatgctactagctag 194 26 0 46.15 62.784 24.59 20.04 45.92 8.784 + 888 ctagctgatcatcgatgctactagct 192 26 0 46.15 62.784 27.00 27.00 45.92 8.784 + 889 agctagctgatcatcgatgctactag 190 26 0 46.15 62.784 20.13 20.13 0.00 8.784 + 890 ctagctagctgatcatcgatgctact 188 26 0 46.15 62.784 17.55 15.53 0.00 8.784 + 891 atttagctagctgactgatcgatcatc 256 27 0 40.74 61.785 23.93 21.92 36.62 8.785 + 892 tctactatcatcatcatctactagct 230 26 0 34.62 57.155 0.00 0.00 0.00 8.845 + 893 tgctagtgatgcatgctagtagtgat 24 26 0 42.31 62.874 24.96 8.51 35.89 8.874 + 894 ctgatcatcatctactatcatcatca 220 26 0 34.62 57.026 0.00 0.00 0.00 8.974 + 895 agctagctactgatcgatgctacatc 303 26 0 46.15 62.999 17.56 7.89 37.97 8.999 + 896 tagtagtgatgtatacgtagctagtag 40 27 0 37.04 57.869 16.78 1.30 0.00 9.131 + 897 ctagtagtgatgtatacgtagctagta 39 27 0 37.04 57.869 16.85 15.97 0.00 9.131 + 898 actgatcgatcatcatgctagctacta 269 27 0 40.74 62.236 26.67 1.37 41.77 9.236 + 899 gcatgctagtagtgatgtatacgtagc 34 27 0 44.44 62.283 11.60 4.93 0.00 9.283 + 900 gctatttagctagctgactgatcgatc 253 27 0 44.44 62.291 19.32 19.32 46.11 9.291 + 901 atctactatcatcatcatctactagct 229 27 0 33.33 57.592 0.00 0.00 0.00 9.408 + 902 catctactatcatcatcatctactagc 228 27 0 37.04 57.549 0.00 0.00 0.00 9.451 + 903 tgatcatcatctactatcatcatcatc 221 27 0 33.33 57.467 0.00 0.00 0.00 9.533 + 904 tagctgatcatcgatgctactagctag 193 27 0 44.44 62.534 27.70 20.04 45.92 9.534 + 905 ctagctgatcatcgatgctactagcta 192 27 0 44.44 62.534 27.76 26.73 45.92 9.534 + 906 tagctagctgatcatcgatgctactag 189 27 0 44.44 62.534 20.13 20.13 0.00 9.534 + 907 ctagctagctgatcatcgatgctacta 188 27 0 44.44 62.534 17.74 15.95 0.00 9.534 + 908 ctgatcatcatctactatcatcatcat 220 27 0 33.33 57.462 0.00 0.00 0.00 9.538 + 909 gctagctagctactatcatcgatcgat 426 27 0 44.44 62.627 34.38 25.37 46.11 9.627 + 910 ttagctagctgactgatcgatcatcat 258 27 0 40.74 62.665 28.29 20.43 41.77 9.665 + 911 tagctagctactgatcgatgctacatc 302 27 0 44.44 62.742 27.80 7.89 37.97 9.742 + 912 ctagctagctactgatcgatgctacat 301 27 0 44.44 62.747 14.00 2.51 0.00 9.747 + 913 gatcatcatctactatcatcatcatct 222 27 0 33.33 57.242 0.00 0.00 0.00 9.758 + 914 tttagctagctgactgatcgatcatca 257 27 0 40.74 62.820 26.49 26.49 39.98 9.820 + 915 tctactatcatcatcatctactagcta 230 27 0 33.33 57.100 0.00 0.00 0.00 9.900 diff --git a/samples/Formatted/wksst8110.for b/samples/Formatted/wksst8110.for new file mode 100644 index 00000000..1ee1a489 --- /dev/null +++ b/samples/Formatted/wksst8110.for @@ -0,0 +1,1317 @@ + Weekly SST data starts week centered on 3Jan1990 + + Nino1+2 Nino3 Nino34 Nino4 + Week SST SSTA SST SSTA SST SSTA SST SSTA + 03JAN1990 23.4-0.4 25.1-0.3 26.6 0.0 28.6 0.3 + 10JAN1990 23.4-0.8 25.2-0.3 26.6 0.1 28.6 0.3 + 17JAN1990 24.2-0.3 25.3-0.3 26.5-0.1 28.6 0.3 + 24JAN1990 24.4-0.5 25.5-0.4 26.5-0.1 28.4 0.2 + 31JAN1990 25.1-0.2 25.8-0.2 26.7 0.1 28.4 0.2 + 07FEB1990 25.8 0.2 26.1-0.1 26.8 0.1 28.4 0.3 + 14FEB1990 25.9-0.1 26.4 0.0 26.9 0.2 28.5 0.4 + 21FEB1990 26.1-0.1 26.7 0.2 27.1 0.3 28.9 0.8 + 28FEB1990 26.1-0.2 26.7-0.1 27.2 0.3 29.0 0.8 + 07MAR1990 26.7 0.3 26.7-0.2 27.3 0.2 28.9 0.7 + 14MAR1990 26.1-0.4 26.9-0.2 27.3 0.1 28.6 0.4 + 21MAR1990 26.1-0.2 27.2 0.0 27.6 0.3 28.7 0.5 + 28MAR1990 25.7-0.4 27.5 0.2 27.8 0.3 28.8 0.5 + 04APR1990 25.6-0.3 27.6 0.3 27.9 0.4 28.8 0.4 + 11APR1990 25.1-0.6 27.6 0.2 27.9 0.2 28.8 0.3 + 18APR1990 25.3 0.0 27.7 0.2 28.0 0.2 28.9 0.4 + 25APR1990 25.1 0.0 27.7 0.4 28.2 0.4 29.2 0.6 + 02MAY1990 24.6-0.2 27.6 0.3 28.1 0.3 29.0 0.4 + 09MAY1990 24.2-0.2 27.5 0.3 28.1 0.3 28.9 0.2 + 16MAY1990 24.3 0.1 27.4 0.3 28.0 0.2 28.8 0.1 + 23MAY1990 23.7-0.2 27.2 0.2 28.1 0.3 29.0 0.2 + 30MAY1990 23.4-0.1 27.1 0.3 27.9 0.2 28.9 0.1 + 06JUN1990 23.2 0.0 26.7 0.1 27.7 0.0 28.9 0.1 + 13JUN1990 22.8-0.2 26.6 0.1 27.7 0.0 29.0 0.1 + 20JUN1990 22.5-0.1 26.4 0.0 27.5-0.1 29.0 0.1 + 27JUN1990 22.1-0.3 26.0-0.1 27.3-0.2 28.9 0.1 + 04JUL1990 21.7-0.4 25.8-0.2 27.3-0.1 28.9 0.1 + 11JUL1990 21.3-0.5 25.4-0.3 27.2-0.1 28.8 0.0 + 18JUL1990 21.0-0.5 25.7 0.1 27.4 0.2 29.1 0.3 + 25JUL1990 20.2-1.1 25.1-0.4 27.3 0.1 29.1 0.3 + 01AUG1990 20.6-0.6 25.1-0.2 27.1 0.1 29.0 0.3 + 08AUG1990 20.4-0.5 25.2 0.1 27.2 0.3 29.3 0.6 + 15AUG1990 20.4-0.3 25.1 0.1 27.0 0.2 29.2 0.5 + 22AUG1990 19.8-0.7 24.9 0.0 27.0 0.2 29.2 0.5 + 29AUG1990 20.2-0.3 25.0 0.1 26.9 0.2 29.0 0.4 + 05SEP1990 19.7-0.8 24.9 0.0 26.7 0.0 28.9 0.3 + 12SEP1990 20.1-0.3 24.7-0.2 26.7 0.0 29.1 0.4 + 19SEP1990 20.3-0.1 24.9 0.1 26.8 0.0 29.1 0.4 + 26SEP1990 20.3-0.2 24.8-0.1 26.7 0.0 29.0 0.3 + 03OCT1990 20.8 0.1 25.1 0.2 26.9 0.2 29.2 0.5 + 10OCT1990 20.1-0.6 24.9 0.0 27.0 0.3 29.1 0.5 + 17OCT1990 20.3-0.6 24.9 0.0 27.0 0.3 29.3 0.6 + 24OCT1990 20.1-0.9 24.9-0.1 27.0 0.4 29.3 0.6 + 31OCT1990 20.2-1.0 24.7-0.2 26.9 0.2 29.2 0.6 + 07NOV1990 20.5-0.8 25.0 0.1 26.9 0.3 29.1 0.5 + 14NOV1990 20.8-0.8 24.8-0.1 26.7 0.0 29.0 0.4 + 21NOV1990 20.9-0.9 24.6-0.4 26.6 0.0 29.0 0.4 + 28NOV1990 21.5-0.6 24.8-0.3 26.5-0.1 28.9 0.4 + 05DEC1990 22.2-0.2 25.2 0.1 26.9 0.3 29.2 0.7 + 12DEC1990 22.1-0.5 25.0-0.1 26.8 0.3 29.3 0.8 + 19DEC1990 22.2-0.8 24.9-0.3 26.9 0.4 29.2 0.7 + 26DEC1990 23.3 0.0 25.3 0.0 27.0 0.4 29.0 0.6 + 02JAN1991 23.2-0.5 25.3-0.1 26.9 0.4 28.9 0.5 + 09JAN1991 23.5-0.6 25.4-0.1 27.0 0.4 29.1 0.8 + 16JAN1991 23.7-0.7 25.7 0.1 27.0 0.5 29.0 0.8 + 23JAN1991 24.2-0.6 25.8 0.0 27.1 0.5 29.0 0.8 + 30JAN1991 24.7-0.5 26.0 0.0 27.0 0.3 28.9 0.7 + 06FEB1991 25.4-0.2 26.1 0.0 27.0 0.3 28.8 0.6 + 13FEB1991 26.0 0.0 26.3 0.0 27.0 0.3 28.8 0.7 + 20FEB1991 26.5 0.3 26.3-0.2 26.9 0.1 28.7 0.6 + 27FEB1991 26.5 0.2 26.5-0.2 26.8-0.1 28.5 0.4 + 06MAR1991 26.5 0.2 26.6-0.3 26.8-0.2 28.5 0.3 + 13MAR1991 26.8 0.4 27.0-0.1 27.1-0.1 28.5 0.3 + 20MAR1991 26.6 0.2 27.1-0.1 27.4 0.1 28.6 0.4 + 27MAR1991 26.2 0.1 27.4 0.1 27.7 0.3 28.9 0.6 + 03APR1991 25.8-0.1 27.3 0.0 27.8 0.2 28.9 0.5 + 10APR1991 25.2-0.5 27.0-0.4 27.8 0.1 29.1 0.7 + 17APR1991 24.9-0.5 27.5 0.0 28.2 0.4 29.2 0.7 + 24APR1991 24.3-0.8 27.4 0.0 28.1 0.3 29.2 0.6 + 01MAY1991 24.6-0.2 27.6 0.4 28.1 0.3 29.1 0.4 + 08MAY1991 24.4-0.2 27.5 0.3 28.3 0.5 29.3 0.6 + 15MAY1991 24.5 0.2 27.5 0.4 28.4 0.5 29.5 0.7 + 22MAY1991 24.3 0.4 27.7 0.7 28.5 0.7 29.5 0.7 + 29MAY1991 24.2 0.5 27.6 0.8 28.5 0.7 29.5 0.7 + 05JUN1991 23.7 0.4 27.5 0.8 28.3 0.6 29.3 0.5 + 12JUN1991 23.2 0.2 27.4 0.9 28.3 0.6 29.3 0.5 + 19JUN1991 23.0 0.3 27.2 0.9 28.4 0.8 29.4 0.5 + 26JUN1991 22.2-0.2 27.3 1.1 28.4 0.9 29.4 0.6 + 03JUL1991 22.8 0.7 27.0 1.0 28.1 0.7 29.2 0.4 + 10JUL1991 22.3 0.4 26.8 1.0 28.1 0.8 29.2 0.4 + 17JUL1991 21.9 0.3 26.6 1.0 27.9 0.7 29.3 0.5 + 24JUL1991 21.6 0.3 26.2 0.7 27.7 0.5 29.2 0.5 + 31JUL1991 21.6 0.5 26.1 0.8 27.9 0.9 29.5 0.7 + 07AUG1991 21.2 0.3 25.6 0.4 27.5 0.6 29.3 0.6 + 14AUG1991 21.3 0.5 25.4 0.4 27.6 0.7 29.3 0.6 + 21AUG1991 20.9 0.3 25.4 0.5 27.4 0.6 29.3 0.6 + 28AUG1991 20.7 0.2 25.2 0.3 27.0 0.3 29.0 0.3 + 04SEP1991 20.9 0.4 25.1 0.2 27.1 0.3 29.1 0.5 + 11SEP1991 20.7 0.3 24.7-0.1 26.9 0.1 29.0 0.4 + 18SEP1991 20.7 0.3 25.1 0.2 27.2 0.5 29.4 0.7 + 25SEP1991 20.8 0.3 25.2 0.3 27.1 0.4 29.2 0.5 + 02OCT1991 20.8 0.2 25.3 0.4 27.2 0.5 29.3 0.6 + 09OCT1991 21.1 0.4 25.6 0.7 27.7 1.0 29.5 0.8 + 16OCT1991 20.7-0.1 25.5 0.6 27.8 1.1 29.6 1.0 + 23OCT1991 21.2 0.2 25.7 0.8 27.6 0.9 29.4 0.7 + 30OCT1991 21.9 0.7 25.9 1.0 27.8 1.1 29.4 0.8 + 06NOV1991 22.0 0.7 25.8 0.9 27.8 1.1 29.5 0.8 + 13NOV1991 21.9 0.4 25.9 1.0 27.8 1.1 29.5 0.9 + 20NOV1991 22.5 0.7 26.1 1.1 27.9 1.3 29.4 0.8 + 27NOV1991 22.3 0.3 26.1 1.1 28.0 1.4 29.4 0.9 + 04DEC1991 22.8 0.5 26.2 1.1 28.1 1.5 29.4 0.9 + 11DEC1991 23.4 0.8 26.5 1.4 28.3 1.7 29.4 0.9 + 18DEC1991 23.7 0.8 26.6 1.5 28.5 2.0 29.5 1.0 + 25DEC1991 23.6 0.3 26.7 1.4 28.5 1.9 29.6 1.2 + 01JAN1992 24.0 0.3 26.7 1.3 28.5 1.9 29.3 1.0 + 08JAN1992 24.2 0.2 26.8 1.3 28.5 1.9 29.2 0.9 + 15JAN1992 24.6 0.2 26.9 1.3 28.4 1.9 29.1 0.8 + 22JAN1992 25.3 0.5 27.1 1.3 28.4 1.8 29.0 0.7 + 29JAN1992 25.9 0.7 27.4 1.4 28.3 1.7 28.7 0.6 + 05FEB1992 26.3 0.8 27.5 1.3 28.4 1.7 28.8 0.7 + 12FEB1992 26.4 0.5 27.6 1.3 28.6 1.9 29.0 0.9 + 19FEB1992 26.8 0.6 27.8 1.3 28.8 2.0 29.2 1.1 + 26FEB1992 27.3 1.1 27.9 1.2 28.8 1.9 29.1 1.0 + 04MAR1992 27.3 1.0 27.9 1.1 28.6 1.6 29.1 0.9 + 11MAR1992 27.7 1.2 28.1 1.0 28.7 1.6 29.2 1.0 + 18MAR1992 27.9 1.4 28.5 1.3 28.8 1.6 28.9 0.7 + 25MAR1992 28.1 1.9 28.7 1.4 29.0 1.6 29.1 0.8 + 01APR1992 27.9 1.9 28.7 1.3 29.1 1.6 29.4 1.0 + 08APR1992 28.3 2.6 28.8 1.4 29.3 1.6 29.6 1.2 + 15APR1992 28.0 2.5 28.8 1.3 29.2 1.4 29.5 1.0 + 22APR1992 27.1 1.9 28.6 1.2 29.0 1.2 29.3 0.8 + 29APR1992 27.0 2.1 28.8 1.5 29.1 1.2 29.2 0.6 + 06MAY1992 27.0 2.4 28.8 1.6 29.2 1.3 29.4 0.7 + 13MAY1992 26.6 2.3 28.6 1.5 29.1 1.2 29.5 0.8 + 20MAY1992 25.8 1.8 28.2 1.2 29.0 1.1 29.5 0.8 + 27MAY1992 25.9 2.2 28.1 1.3 28.8 1.1 29.5 0.7 + 03JUN1992 24.2 0.9 27.5 0.8 28.6 0.9 29.4 0.6 + 10JUN1992 24.2 1.2 26.8 0.3 28.3 0.6 29.4 0.6 + 17JUN1992 23.9 1.1 26.6 0.2 27.8 0.2 29.2 0.4 + 24JUN1992 23.5 1.0 26.2 0.0 27.6 0.1 29.2 0.4 + 01JUL1992 22.3 0.1 25.8-0.2 27.6 0.1 29.2 0.4 + 08JUL1992 23.0 1.1 26.2 0.4 28.0 0.7 29.5 0.7 + 15JUL1992 21.4-0.3 25.7 0.0 27.7 0.5 29.5 0.7 + 22JUL1992 21.6 0.2 25.1-0.4 27.2 0.0 29.2 0.5 + 29JUL1992 21.5 0.3 24.9-0.5 27.1 0.1 29.2 0.5 + 05AUG1992 20.8-0.2 24.6-0.6 26.7-0.2 29.1 0.4 + 12AUG1992 20.8 0.0 24.9-0.2 26.6-0.3 28.8 0.1 + 19AUG1992 20.3-0.4 24.6-0.4 26.6-0.3 28.8 0.2 + 26AUG1992 20.3-0.3 24.8-0.2 26.7-0.1 28.9 0.3 + 02SEP1992 20.3-0.2 24.4-0.5 26.3-0.4 28.6 0.0 + 09SEP1992 19.7-0.8 24.4-0.5 26.4-0.3 28.7 0.1 + 16SEP1992 20.1-0.2 24.5-0.3 26.5-0.2 28.9 0.2 + 23SEP1992 20.1-0.3 24.6-0.3 26.5-0.2 28.9 0.2 + 30SEP1992 20.2-0.4 24.7-0.2 26.6-0.1 28.7 0.0 + 07OCT1992 20.5-0.2 24.5-0.4 26.4-0.3 28.8 0.1 + 14OCT1992 20.7 0.0 24.6-0.3 26.4-0.3 28.6-0.1 + 21OCT1992 20.9 0.0 24.6-0.4 26.2-0.5 28.8 0.1 + 28OCT1992 21.5 0.4 24.8-0.1 26.2-0.4 28.5-0.1 + 04NOV1992 21.2-0.1 24.7-0.2 26.3-0.4 28.6 0.0 + 11NOV1992 21.2-0.3 24.8-0.1 26.6-0.1 28.8 0.2 + 18NOV1992 21.2-0.5 24.7-0.3 26.4-0.2 28.5-0.1 + 25NOV1992 22.1 0.2 24.9-0.2 26.7 0.0 28.8 0.2 + 02DEC1992 22.2 0.0 24.9-0.2 26.7 0.1 28.9 0.4 + 09DEC1992 22.2-0.3 25.1 0.0 26.8 0.2 28.7 0.2 + 16DEC1992 22.3-0.5 24.9-0.3 26.7 0.1 28.7 0.3 + 23DEC1992 22.5-0.7 25.1-0.2 26.8 0.2 28.9 0.4 + 30DEC1992 23.3-0.2 25.1-0.3 26.6 0.0 28.6 0.2 + 06JAN1993 23.6-0.3 25.4-0.1 26.7 0.1 28.5 0.2 + 13JAN1993 24.4 0.1 25.6 0.0 26.8 0.2 28.7 0.4 + 20JAN1993 24.5-0.2 25.5-0.2 26.6 0.0 28.6 0.3 + 27JAN1993 25.2 0.1 25.8-0.2 26.7 0.0 28.6 0.4 + 03FEB1993 26.2 0.8 26.3 0.2 26.9 0.3 28.5 0.3 + 10FEB1993 26.6 0.7 26.4 0.2 26.8 0.1 28.3 0.2 + 17FEB1993 26.6 0.4 26.9 0.5 27.0 0.2 28.3 0.2 + 24FEB1993 26.6 0.4 26.7 0.1 27.1 0.2 28.5 0.4 + 03MAR1993 26.9 0.6 26.9 0.1 27.2 0.2 28.4 0.3 + 10MAR1993 27.2 0.7 27.3 0.3 27.4 0.3 28.4 0.3 + 17MAR1993 27.1 0.6 27.5 0.3 27.7 0.4 28.6 0.4 + 24MAR1993 27.2 1.0 28.0 0.7 28.0 0.7 28.8 0.5 + 31MAR1993 27.7 1.7 28.3 1.0 28.2 0.7 28.9 0.6 + 07APR1993 26.6 0.9 28.4 1.0 28.3 0.6 28.7 0.3 + 14APR1993 26.3 0.7 28.5 1.0 28.8 1.1 29.0 0.5 + 21APR1993 26.3 1.0 28.4 1.0 28.7 0.9 29.0 0.5 + 28APR1993 26.0 1.1 28.5 1.2 28.8 1.0 29.0 0.4 + 05MAY1993 25.9 1.2 28.5 1.2 28.8 1.0 28.9 0.3 + 12MAY1993 25.6 1.2 28.3 1.2 28.9 1.0 29.1 0.4 + 19MAY1993 24.9 0.8 28.1 1.1 28.8 1.0 29.2 0.4 + 26MAY1993 24.3 0.6 27.9 1.0 28.9 1.1 29.2 0.4 + 02JUN1993 24.5 1.1 27.7 0.9 28.6 0.9 29.2 0.4 + 09JUN1993 23.9 0.7 27.2 0.6 28.3 0.6 29.1 0.2 + 16JUN1993 23.6 0.8 27.1 0.6 28.2 0.6 29.1 0.2 + 23JUN1993 23.8 1.3 26.9 0.7 28.2 0.7 29.3 0.5 + 30JUN1993 23.0 0.7 26.7 0.6 28.1 0.6 29.3 0.5 + 07JUL1993 22.4 0.4 26.1 0.3 27.9 0.6 29.3 0.5 + 14JUL1993 22.2 0.5 25.8 0.1 27.4 0.2 29.2 0.4 + 21JUL1993 22.0 0.6 25.6 0.1 27.5 0.4 29.2 0.4 + 28JUL1993 21.3 0.0 25.3-0.1 27.2 0.1 29.1 0.4 + 04AUG1993 21.2 0.2 25.0-0.3 26.8-0.2 28.9 0.2 + 11AUG1993 20.8 0.0 25.0-0.1 26.9 0.0 29.0 0.3 + 18AUG1993 21.1 0.5 24.8-0.1 26.8 0.0 28.7 0.1 + 25AUG1993 21.2 0.6 24.9 0.0 26.9 0.1 29.1 0.4 + 01SEP1993 20.9 0.4 24.9 0.0 26.9 0.2 29.1 0.4 + 08SEP1993 20.8 0.3 25.0 0.1 26.8 0.1 29.0 0.4 + 15SEP1993 20.8 0.4 24.9 0.0 26.9 0.2 29.1 0.5 + 22SEP1993 21.0 0.5 25.0 0.2 27.0 0.3 29.1 0.4 + 29SEP1993 20.7 0.2 25.1 0.2 27.0 0.3 29.0 0.3 + 06OCT1993 20.6-0.1 25.2 0.3 26.9 0.2 28.8 0.1 + 13OCT1993 20.8 0.0 25.3 0.4 27.0 0.3 29.0 0.3 + 20OCT1993 21.2 0.3 25.0 0.1 26.6 0.0 28.9 0.2 + 27OCT1993 21.3 0.2 25.3 0.4 27.1 0.4 29.0 0.3 + 03NOV1993 22.0 0.8 25.4 0.4 27.2 0.5 29.0 0.3 + 10NOV1993 21.4 0.0 25.1 0.1 26.9 0.2 28.8 0.2 + 17NOV1993 21.7 0.0 25.1 0.2 26.9 0.2 28.9 0.3 + 24NOV1993 21.4-0.5 25.1 0.0 26.7 0.1 29.0 0.5 + 01DEC1993 21.8-0.4 25.3 0.2 26.9 0.3 29.2 0.6 + 08DEC1993 22.1-0.3 25.3 0.2 26.9 0.4 29.0 0.5 + 15DEC1993 23.1 0.4 25.3 0.2 26.8 0.3 28.9 0.4 + 22DEC1993 23.0-0.2 25.3 0.1 26.6 0.1 28.9 0.4 + 29DEC1993 23.3-0.2 25.4 0.0 26.5-0.1 28.6 0.2 + 05JAN1994 23.8 0.0 25.7 0.2 26.7 0.1 28.7 0.3 + 12JAN1994 23.9-0.3 25.7 0.1 26.7 0.2 28.5 0.2 + 19JAN1994 24.6 0.0 25.7-0.1 26.5-0.1 28.5 0.2 + 26JAN1994 24.8-0.2 25.8-0.1 26.5-0.2 28.2 0.0 + 02FEB1994 25.4 0.0 25.9-0.1 26.6 0.0 28.2 0.0 + 09FEB1994 25.9 0.1 26.2 0.0 26.7 0.0 28.1 0.0 + 16FEB1994 25.6-0.5 26.1-0.3 26.6-0.1 28.0 0.0 + 23FEB1994 26.1-0.1 25.9-0.7 26.4-0.5 27.9-0.2 + 02MAR1994 26.2-0.1 26.6-0.2 26.6-0.3 27.9-0.2 + 09MAR1994 25.5-0.9 27.0 0.1 27.2 0.1 28.2 0.1 + 16MAR1994 25.7-0.9 27.0-0.1 27.4 0.2 28.4 0.2 + 23MAR1994 25.0-1.2 26.8-0.4 27.3-0.1 28.3 0.0 + 30MAR1994 24.8-1.3 27.0-0.3 27.7 0.2 28.3 0.0 + 06APR1994 24.9-0.9 27.0-0.4 27.6 0.0 28.5 0.1 + 13APR1994 24.7-0.9 27.2-0.3 28.0 0.2 28.6 0.2 + 20APR1994 24.2-1.1 27.0-0.4 28.0 0.2 28.6 0.1 + 27APR1994 23.4-1.6 27.1-0.2 28.1 0.3 28.7 0.2 + 04MAY1994 23.4-1.3 27.0-0.3 27.9 0.1 28.8 0.1 + 11MAY1994 23.6-0.8 26.8-0.3 27.8 0.0 28.9 0.2 + 18MAY1994 23.0-1.1 27.2 0.1 28.2 0.4 29.0 0.2 + 25MAY1994 23.0-0.8 26.9 0.0 28.1 0.3 29.1 0.3 + 01JUN1994 22.8-0.7 26.9 0.1 28.3 0.5 29.3 0.5 + 08JUN1994 22.7-0.5 26.7 0.1 28.0 0.3 29.1 0.3 + 15JUN1994 22.7-0.1 26.8 0.4 28.2 0.6 29.1 0.3 + 22JUN1994 22.2-0.4 26.2-0.1 27.9 0.3 29.2 0.4 + 29JUN1994 21.7-0.6 25.9-0.2 27.6 0.1 29.2 0.4 + 06JUL1994 21.9-0.1 25.6-0.3 27.4 0.1 29.3 0.5 + 13JUL1994 21.3-0.4 25.2-0.5 27.3 0.1 29.4 0.6 + 20JUL1994 20.9-0.6 25.1-0.4 27.4 0.2 29.5 0.8 + 27JUL1994 20.8-0.5 24.8-0.6 27.2 0.1 29.4 0.6 + 03AUG1994 20.1-1.0 24.5-0.8 27.3 0.3 29.4 0.7 + 10AUG1994 19.2-1.6 24.8-0.3 27.6 0.7 29.5 0.8 + 17AUG1994 19.6-1.1 24.8-0.2 27.4 0.6 29.5 0.9 + 24AUG1994 20.0-0.5 24.8-0.2 27.3 0.5 29.5 0.8 + 31AUG1994 19.6-0.9 24.7-0.2 27.1 0.3 29.4 0.7 + 07SEP1994 20.1-0.4 24.6-0.3 26.9 0.2 29.3 0.6 + 14SEP1994 20.0-0.3 24.6-0.2 26.9 0.1 29.2 0.5 + 21SEP1994 20.5 0.1 24.9 0.0 27.0 0.2 29.2 0.5 + 28SEP1994 20.2-0.3 25.2 0.3 27.2 0.5 29.2 0.6 + 05OCT1994 21.0 0.3 25.4 0.5 27.3 0.6 29.4 0.8 + 12OCT1994 21.7 0.9 25.6 0.7 27.5 0.8 29.4 0.8 + 19OCT1994 21.8 0.9 25.6 0.6 27.5 0.8 29.4 0.8 + 26OCT1994 21.7 0.7 25.6 0.6 27.6 1.0 29.5 0.9 + 02NOV1994 22.1 0.9 25.7 0.7 27.8 1.1 29.6 1.0 + 09NOV1994 22.1 0.7 26.0 1.0 27.9 1.3 29.5 0.9 + 16NOV1994 22.3 0.7 25.8 0.8 27.8 1.1 29.6 1.0 + 23NOV1994 22.8 0.9 25.9 0.9 27.9 1.2 29.7 1.1 + 30NOV1994 22.9 0.7 26.0 0.9 28.0 1.4 29.8 1.3 + 07DEC1994 23.3 0.9 26.0 0.9 27.9 1.3 29.6 1.1 + 14DEC1994 23.4 0.7 25.9 0.8 27.9 1.3 29.5 1.1 + 21DEC1994 23.7 0.6 26.2 1.0 27.9 1.3 29.3 0.9 + 28DEC1994 24.3 0.9 26.3 0.9 27.8 1.3 29.3 0.9 + 04JAN1995 24.7 0.8 26.1 0.7 27.6 1.1 29.3 0.9 + 11JAN1995 25.1 0.9 26.2 0.7 27.6 1.0 29.2 0.9 + 18JAN1995 25.3 0.8 26.4 0.7 27.6 1.0 29.3 1.0 + 25JAN1995 25.9 0.9 26.5 0.6 27.5 0.8 29.1 0.8 + 01FEB1995 26.2 0.9 26.7 0.7 27.4 0.8 29.0 0.9 + 08FEB1995 26.7 0.9 26.9 0.7 27.4 0.7 29.1 1.0 + 15FEB1995 26.5 0.4 26.8 0.4 27.3 0.5 28.9 0.8 + 22FEB1995 26.4 0.2 26.9 0.3 27.5 0.7 29.0 0.9 + 01MAR1995 26.0-0.2 26.9 0.2 27.7 0.7 29.0 0.9 + 08MAR1995 26.0-0.4 26.7-0.2 27.4 0.4 28.9 0.7 + 15MAR1995 26.6 0.1 27.1 0.0 27.7 0.5 29.0 0.9 + 22MAR1995 26.4 0.1 27.2-0.1 27.7 0.3 29.0 0.8 + 29MAR1995 25.4-0.6 27.4 0.1 27.7 0.2 28.8 0.5 + 05APR1995 24.9-1.0 27.2-0.2 27.9 0.3 28.8 0.5 + 12APR1995 24.9-0.7 27.3-0.2 27.8 0.1 28.8 0.4 + 19APR1995 24.6-0.7 27.3-0.2 28.2 0.4 28.9 0.3 + 26APR1995 23.5-1.5 26.6-0.7 27.9 0.1 28.9 0.3 + 03MAY1995 23.3-1.4 26.6-0.6 28.0 0.2 29.2 0.6 + 10MAY1995 23.0-1.4 26.3-0.8 27.7-0.1 29.1 0.4 + 17MAY1995 23.0-1.2 26.2-0.8 27.7-0.2 29.2 0.4 + 24MAY1995 23.2-0.6 26.4-0.5 27.6-0.2 29.1 0.3 + 31MAY1995 22.8-0.7 26.4-0.3 27.7 0.0 29.0 0.2 + 07JUN1995 22.9-0.3 26.4-0.2 27.7 0.0 29.1 0.3 + 14JUN1995 22.9 0.0 26.4-0.1 27.7 0.1 29.1 0.3 + 21JUN1995 21.9-0.7 26.0-0.3 27.5 0.0 28.9 0.1 + 28JUN1995 21.8-0.5 25.8-0.3 27.3-0.1 28.8 0.0 + 05JUL1995 22.0 0.0 25.7-0.2 27.3-0.1 29.0 0.2 + 12JUL1995 21.2-0.5 25.6-0.1 27.1-0.2 28.8 0.0 + 19JUL1995 21.0-0.5 25.3-0.2 26.9-0.3 28.7-0.1 + 26JUL1995 20.8-0.5 25.1-0.3 26.8-0.3 28.6-0.1 + 02AUG1995 20.3-0.8 24.8-0.5 26.7-0.3 28.5-0.2 + 09AUG1995 19.9-1.0 24.3-0.8 26.3-0.6 28.3-0.4 + 16AUG1995 20.0-0.7 24.3-0.7 26.4-0.4 28.5-0.2 + 23AUG1995 19.9-0.7 24.3-0.7 26.3-0.5 28.4-0.2 + 30AUG1995 20.1-0.5 24.0-0.9 25.9-0.8 28.2-0.5 + 06SEP1995 20.4 0.0 24.1-0.8 26.0-0.8 28.2-0.5 + 13SEP1995 19.9-0.5 24.1-0.8 26.0-0.7 28.0-0.6 + 20SEP1995 20.2-0.2 24.0-0.9 26.1-0.7 28.4-0.3 + 27SEP1995 20.2-0.3 23.9-1.0 25.9-0.8 28.4-0.3 + 04OCT1995 19.6-1.0 23.9-1.0 25.6-1.1 28.1-0.5 + 11OCT1995 20.2-0.5 24.1-0.8 25.6-1.1 28.0-0.6 + 18OCT1995 20.0-0.8 24.1-0.9 25.8-0.9 28.2-0.5 + 25OCT1995 20.3-0.7 24.0-0.9 25.6-1.1 27.9-0.8 + 01NOV1995 21.0-0.2 24.1-0.8 25.6-1.0 28.0-0.7 + 08NOV1995 20.6-0.8 23.9-1.1 25.8-0.9 28.1-0.5 + 15NOV1995 21.3-0.2 24.1-0.9 25.7-1.0 27.8-0.8 + 22NOV1995 21.4-0.4 24.1-0.9 25.5-1.1 27.7-0.9 + 29NOV1995 21.6-0.5 24.1-1.0 25.7-0.9 28.1-0.5 + 06DEC1995 21.5-0.9 24.1-1.0 25.6-1.0 27.9-0.6 + 13DEC1995 21.7-1.0 24.0-1.1 25.4-1.2 27.9-0.5 + 20DEC1995 22.0-1.0 24.1-1.1 25.6-1.0 28.1-0.3 + 27DEC1995 22.8-0.6 24.5-0.8 25.7-0.9 28.1-0.3 + 03JAN1996 23.4-0.4 24.6-0.8 25.6-1.0 28.1-0.3 + 10JAN1996 23.6-0.6 24.9-0.6 25.6-1.0 27.9-0.4 + 17JAN1996 24.0-0.5 25.2-0.5 25.9-0.7 27.8-0.5 + 24JAN1996 23.9-1.0 25.0-0.8 25.9-0.7 27.9-0.4 + 31JAN1996 24.6-0.7 25.2-0.8 25.8-0.9 27.8-0.4 + 07FEB1996 25.4-0.3 25.4-0.8 25.6-1.1 27.5-0.6 + 14FEB1996 25.9-0.1 25.7-0.6 25.8-0.9 27.5-0.5 + 21FEB1996 26.0-0.2 25.9-0.6 25.8-1.0 27.4-0.7 + 28FEB1996 26.1-0.2 26.3-0.5 26.3-0.6 27.5-0.6 + 06MAR1996 26.6 0.2 26.5-0.4 26.2-0.8 27.5-0.6 + 13MAR1996 26.1-0.3 26.9-0.2 26.6-0.6 27.7-0.5 + 20MAR1996 26.3-0.1 27.0-0.2 26.8-0.5 27.7-0.5 + 27MAR1996 25.7-0.4 26.7-0.6 26.8-0.6 27.8-0.4 + 03APR1996 24.4-1.5 26.5-0.9 27.0-0.6 27.9-0.5 + 10APR1996 23.9-1.7 27.0-0.4 27.4-0.3 27.9-0.5 + 17APR1996 23.8-1.6 26.8-0.7 27.3-0.4 28.0-0.5 + 24APR1996 23.6-1.5 26.7-0.7 27.6-0.1 28.2-0.3 + 01MAY1996 23.0-1.9 26.4-0.9 27.4-0.4 28.2-0.4 + 08MAY1996 23.0-1.6 26.5-0.7 27.6-0.2 28.4-0.3 + 15MAY1996 23.0-1.3 26.3-0.8 27.3-0.5 28.3-0.4 + 22MAY1996 23.0-0.9 26.2-0.7 27.2-0.6 28.5-0.3 + 29MAY1996 22.6-1.1 26.2-0.6 27.3-0.4 28.6-0.2 + 05JUN1996 22.3-1.0 26.0-0.6 27.3-0.4 28.6-0.3 + 12JUN1996 21.9-1.0 26.0-0.5 27.3-0.4 28.5-0.4 + 19JUN1996 21.4-1.3 25.8-0.6 27.3-0.3 28.4-0.4 + 26JUN1996 20.6-1.8 25.7-0.5 27.3-0.2 28.6-0.2 + 03JUL1996 20.4-1.7 25.9 0.0 27.6 0.2 28.6-0.2 + 10JUL1996 20.1-1.8 25.4-0.3 27.1-0.2 28.5-0.3 + 17JUL1996 20.0-1.6 25.4-0.2 27.1-0.1 28.3-0.5 + 24JUL1996 20.2-1.2 25.1-0.4 26.9-0.2 28.5-0.3 + 31JUL1996 19.2-1.9 24.7-0.6 26.6-0.4 28.4-0.3 + 07AUG1996 19.2-1.7 24.8-0.4 26.7-0.3 28.5-0.2 + 14AUG1996 20.0-0.8 24.6-0.5 26.5-0.4 28.6 0.0 + 21AUG1996 20.1-0.5 24.6-0.3 26.5-0.3 28.6-0.1 + 28AUG1996 18.9-1.6 24.4-0.6 26.5-0.2 28.4-0.3 + 04SEP1996 19.1-1.3 24.3-0.6 26.4-0.4 28.5-0.2 + 11SEP1996 19.4-1.0 24.4-0.5 26.2-0.5 28.3-0.4 + 18SEP1996 19.1-1.3 24.3-0.5 26.4-0.3 28.5-0.2 + 25SEP1996 19.3-1.2 24.4-0.4 26.3-0.4 28.4-0.3 + 02OCT1996 19.5-1.2 24.5-0.4 26.2-0.5 28.3-0.4 + 09OCT1996 19.5-1.3 24.3-0.6 26.2-0.5 28.5-0.2 + 16OCT1996 20.2-0.6 24.4-0.5 26.3-0.3 28.5-0.1 + 23OCT1996 20.5-0.5 24.4-0.6 26.2-0.5 28.3-0.3 + 30OCT1996 20.0-1.1 24.3-0.7 26.1-0.5 28.3-0.3 + 06NOV1996 20.2-1.2 24.4-0.6 26.1-0.5 28.1-0.5 + 13NOV1996 20.1-1.4 24.4-0.6 26.2-0.5 28.3-0.3 + 20NOV1996 20.3-1.5 24.4-0.6 26.3-0.3 28.4-0.1 + 27NOV1996 20.4-1.6 24.3-0.7 26.2-0.4 28.3-0.2 + 04DEC1996 20.8-1.5 24.4-0.7 26.3-0.3 28.5 0.0 + 11DEC1996 21.6-1.0 24.1-1.0 26.1-0.5 28.6 0.1 + 18DEC1996 21.6-1.3 24.2-1.0 25.9-0.6 28.3-0.1 + 25DEC1996 22.1-1.1 24.1-1.1 25.9-0.7 28.3-0.1 + 01JAN1997 22.5-1.2 24.3-1.1 25.8-0.8 28.2-0.2 + 08JAN1997 23.0-1.0 24.5-1.0 25.9-0.6 28.4 0.1 + 15JAN1997 23.6-0.8 24.6-1.0 25.8-0.7 28.4 0.1 + 22JAN1997 24.3-0.5 24.8-1.0 25.9-0.7 28.4 0.2 + 29JAN1997 24.6-0.6 25.1-0.8 26.3-0.4 28.4 0.2 + 05FEB1997 25.3-0.2 25.2-0.9 26.2-0.5 28.4 0.2 + 12FEB1997 25.4-0.6 25.8-0.5 26.4-0.3 28.3 0.2 + 19FEB1997 26.3 0.1 25.9-0.6 26.4-0.4 28.2 0.1 + 26FEB1997 26.2-0.1 26.2-0.4 26.5-0.4 28.2 0.1 + 05MAR1997 26.8 0.5 26.6-0.3 26.6-0.4 28.1 0.0 + 12MAR1997 26.9 0.5 26.8-0.3 26.8-0.4 28.3 0.1 + 19MAR1997 27.0 0.6 27.3 0.1 27.4 0.1 28.5 0.3 + 26MAR1997 27.2 1.0 27.4 0.1 27.3-0.1 28.9 0.7 + 02APR1997 27.0 1.1 27.3-0.1 27.5 0.0 29.2 0.8 + 09APR1997 26.4 0.7 27.3-0.1 27.8 0.2 29.2 0.8 + 16APR1997 26.5 1.1 27.6 0.1 28.0 0.3 29.3 0.8 + 23APR1997 26.6 1.4 27.8 0.4 28.4 0.6 29.5 0.9 + 30APR1997 26.8 1.9 28.0 0.7 28.4 0.6 29.5 0.8 + 07MAY1997 26.8 2.2 28.2 1.0 28.6 0.8 29.4 0.8 + 14MAY1997 26.7 2.4 28.0 0.9 28.5 0.6 29.3 0.6 + 21MAY1997 26.6 2.6 27.9 1.0 28.6 0.8 29.5 0.7 + 28MAY1997 26.8 3.1 28.1 1.3 28.8 1.0 29.5 0.7 + 04JUN1997 26.4 3.1 28.0 1.3 28.8 1.1 29.4 0.6 + 11JUN1997 26.5 3.5 28.1 1.6 28.9 1.2 29.3 0.5 + 18JUN1997 26.0 3.3 28.2 1.8 29.0 1.4 29.4 0.6 + 25JUN1997 26.2 3.7 28.2 2.0 29.1 1.6 29.5 0.7 + 02JUL1997 25.9 3.7 28.1 2.1 29.0 1.5 29.4 0.6 + 09JUL1997 25.7 3.8 28.0 2.2 28.9 1.6 29.5 0.7 + 16JUL1997 25.7 4.1 28.1 2.5 29.0 1.8 29.5 0.7 + 23JUL1997 25.5 4.1 27.9 2.4 28.8 1.7 29.5 0.8 + 30JUL1997 25.2 4.0 27.9 2.6 28.9 1.9 29.5 0.8 + 06AUG1997 25.3 4.3 27.8 2.6 28.8 1.8 29.4 0.7 + 13AUG1997 25.4 4.6 27.9 2.9 28.9 2.0 29.3 0.6 + 20AUG1997 24.2 3.6 27.9 2.9 28.9 2.1 29.2 0.5 + 27AUG1997 24.3 3.7 27.7 2.7 28.8 2.0 29.2 0.5 + 03SEP1997 24.6 4.2 27.8 2.9 28.9 2.1 29.2 0.6 + 10SEP1997 24.6 4.2 27.8 2.9 28.9 2.2 29.3 0.6 + 17SEP1997 24.2 3.8 27.8 2.9 28.9 2.2 29.3 0.6 + 24SEP1997 24.4 3.9 27.9 3.0 28.9 2.2 29.5 0.8 + 01OCT1997 24.1 3.5 28.0 3.1 29.1 2.4 29.4 0.7 + 08OCT1997 24.5 3.8 28.1 3.2 29.2 2.6 29.3 0.6 + 15OCT1997 24.5 3.7 28.1 3.2 29.2 2.5 29.3 0.7 + 22OCT1997 24.9 3.9 28.2 3.3 29.3 2.6 29.5 0.8 + 29OCT1997 24.7 3.6 28.3 3.4 29.2 2.6 29.2 0.6 + 05NOV1997 25.0 3.7 28.4 3.4 29.2 2.6 29.2 0.6 + 12NOV1997 25.8 4.3 28.5 3.6 29.3 2.7 29.5 0.8 + 19NOV1997 25.8 4.1 28.6 3.6 29.3 2.7 29.7 1.1 + 26NOV1997 25.9 3.9 28.7 3.7 29.4 2.8 29.7 1.1 + 03DEC1997 26.2 3.9 28.6 3.6 29.2 2.6 29.4 0.9 + 10DEC1997 26.7 4.2 28.7 3.6 29.2 2.7 29.4 0.9 + 17DEC1997 27.0 4.1 28.8 3.6 29.3 2.7 29.3 0.8 + 24DEC1997 27.2 4.0 28.8 3.5 29.3 2.7 29.3 0.9 + 31DEC1997 27.7 4.1 28.9 3.5 29.2 2.7 29.2 0.8 + 07JAN1998 28.0 4.0 28.9 3.4 29.2 2.6 29.1 0.8 + 14JAN1998 28.4 4.0 28.9 3.3 29.1 2.5 29.0 0.7 + 21JAN1998 28.4 3.7 28.9 3.2 29.0 2.4 28.9 0.7 + 28JAN1998 28.3 3.2 29.1 3.1 29.1 2.4 28.9 0.7 + 04FEB1998 28.9 3.4 29.1 3.0 29.2 2.5 29.0 0.9 + 11FEB1998 28.9 3.0 29.0 2.7 29.0 2.3 29.0 0.9 + 18FEB1998 29.1 3.0 28.8 2.3 28.7 1.9 28.8 0.7 + 25FEB1998 29.1 2.9 28.9 2.2 28.6 1.7 28.8 0.7 + 04MAR1998 29.2 2.8 29.0 2.2 28.5 1.5 28.6 0.4 + 11MAR1998 29.2 2.8 29.1 2.1 28.7 1.6 28.8 0.7 + 18MAR1998 29.2 2.7 29.1 2.0 28.6 1.4 28.6 0.4 + 25MAR1998 29.1 2.8 29.2 2.0 28.8 1.5 28.6 0.4 + 01APR1998 29.1 3.1 29.3 1.9 28.7 1.2 28.6 0.2 + 08APR1998 28.8 3.0 29.2 1.8 28.6 1.0 28.5 0.0 + 15APR1998 28.6 3.1 29.1 1.6 28.4 0.6 28.5 0.0 + 22APR1998 28.4 3.2 29.0 1.6 28.5 0.7 28.5-0.1 + 29APR1998 28.3 3.4 28.9 1.6 28.7 0.8 28.7 0.1 + 06MAY1998 27.8 3.2 29.4 2.1 29.1 1.3 28.7 0.1 + 13MAY1998 28.1 3.8 28.7 1.6 28.8 0.9 28.7-0.1 + 20MAY1998 27.9 3.9 27.6 0.7 28.3 0.5 28.6-0.2 + 27MAY1998 27.0 3.3 27.1 0.2 27.9 0.1 28.8 0.0 + 03JUN1998 26.2 2.8 26.1-0.6 27.1-0.6 28.7-0.1 + 10JUN1998 26.1 3.0 26.2-0.3 26.9-0.8 28.6-0.2 + 17JUN1998 24.6 1.8 25.8-0.6 26.7-1.0 28.7-0.1 + 24JUN1998 24.5 2.0 26.0-0.2 26.4-1.1 28.5-0.3 + 01JUL1998 24.1 1.9 25.7-0.3 26.4-1.1 28.3-0.5 + 08JUL1998 23.6 1.7 25.6-0.2 26.2-1.2 28.2-0.6 + 15JUL1998 23.6 2.0 25.3-0.4 25.9-1.4 28.1-0.7 + 22JUL1998 23.0 1.5 24.9-0.6 25.7-1.4 28.0-0.8 + 29JUL1998 23.2 2.0 24.9-0.5 25.7-1.4 27.8-1.0 + 05AUG1998 22.6 1.7 24.8-0.4 25.6-1.4 27.9-0.8 + 12AUG1998 21.8 1.1 24.6-0.5 25.5-1.4 27.8-0.9 + 19AUG1998 21.3 0.7 24.4-0.6 25.2-1.6 27.6-1.0 + 26AUG1998 21.2 0.7 24.7-0.3 25.6-1.2 27.6-1.0 + 02SEP1998 21.1 0.6 24.5-0.4 25.6-1.2 27.8-0.8 + 09SEP1998 20.9 0.5 24.3-0.6 25.9-0.8 28.3-0.4 + 16SEP1998 21.0 0.7 24.2-0.7 25.7-1.0 28.0-0.7 + 23SEP1998 20.5 0.1 24.1-0.7 25.5-1.2 27.6-1.1 + 30SEP1998 20.9 0.3 23.7-1.2 25.1-1.6 27.2-1.4 + 07OCT1998 20.9 0.2 23.9-1.0 25.3-1.4 27.5-1.2 + 14OCT1998 21.2 0.4 24.1-0.8 25.4-1.3 27.3-1.4 + 21OCT1998 21.1 0.1 24.1-0.8 25.3-1.4 27.2-1.5 + 28OCT1998 21.6 0.5 24.2-0.7 25.5-1.2 27.3-1.3 + 04NOV1998 21.4 0.1 24.4-0.6 25.2-1.5 27.2-1.4 + 11NOV1998 21.0-0.4 24.0-0.9 25.2-1.5 27.2-1.4 + 18NOV1998 21.7 0.0 24.1-0.9 25.2-1.4 27.1-1.5 + 25NOV1998 21.5-0.5 24.0-1.0 25.1-1.5 27.2-1.4 + 02DEC1998 21.7-0.5 23.9-1.2 25.1-1.5 27.3-1.2 + 09DEC1998 22.0-0.5 23.8-1.3 24.8-1.8 27.2-1.2 + 16DEC1998 22.5-0.3 23.9-1.3 24.7-1.8 27.1-1.4 + 23DEC1998 23.3 0.2 23.8-1.4 24.6-1.9 27.0-1.4 + 30DEC1998 23.2-0.4 23.9-1.5 24.7-1.9 26.7-1.7 + 06JAN1999 23.4-0.5 24.1-1.4 24.7-1.9 26.7-1.7 + 13JAN1999 23.7-0.6 24.2-1.4 25.0-1.6 26.8-1.5 + 20JAN1999 23.3-1.4 24.5-1.3 25.0-1.6 26.4-1.8 + 27JAN1999 24.5-0.6 24.9-1.0 25.0-1.6 26.2-2.0 + 03FEB1999 24.8-0.6 25.1-1.0 25.2-1.5 26.6-1.6 + 10FEB1999 25.1-0.7 25.0-1.2 25.2-1.5 26.5-1.6 + 17FEB1999 25.5-0.6 25.5-0.9 25.5-1.3 26.3-1.7 + 24FEB1999 26.8 0.6 26.4-0.2 25.7-1.2 26.4-1.7 + 03MAR1999 27.4 1.1 26.7-0.1 26.1-0.9 26.8-1.3 + 10MAR1999 27.0 0.6 26.6-0.4 26.1-1.0 26.7-1.5 + 17MAR1999 26.4 0.0 26.7-0.4 26.2-1.0 26.9-1.2 + 24MAR1999 26.3 0.0 26.7-0.6 26.5-0.9 27.0-1.2 + 31MAR1999 25.8-0.3 26.6-0.7 26.5-1.0 27.0-1.3 + 07APR1999 24.4-1.3 26.7-0.7 26.7-0.9 27.1-1.3 + 14APR1999 24.6-0.9 26.5-0.9 26.8-0.9 27.3-1.1 + 21APR1999 23.8-1.4 26.7-0.7 27.0-0.8 27.4-1.1 + 28APR1999 23.7-1.3 26.8-0.6 27.0-0.8 27.5-1.1 + 05MAY1999 23.6-1.1 26.6-0.6 27.0-0.8 27.8-0.9 + 12MAY1999 23.7-0.7 26.7-0.4 27.1-0.7 27.9-0.8 + 19MAY1999 23.7-0.4 26.5-0.5 26.9-0.9 27.8-0.9 + 26MAY1999 23.2-0.6 26.1-0.8 26.9-0.9 27.9-0.9 + 02JUN1999 22.5-0.9 25.8-0.9 26.7-1.1 28.0-0.8 + 09JUN1999 22.4-0.8 25.8-0.7 26.6-1.1 27.9-0.9 + 16JUN1999 21.6-1.2 25.6-0.9 26.6-1.1 28.0-0.9 + 23JUN1999 21.3-1.2 25.4-0.8 26.5-1.0 28.0-0.8 + 30JUN1999 21.3-1.0 25.3-0.8 26.6-0.8 28.1-0.7 + 07JUL1999 20.4-1.5 25.2-0.7 26.6-0.7 28.1-0.7 + 14JUL1999 20.4-1.3 24.9-0.7 26.4-0.8 27.8-1.0 + 21JUL1999 20.3-1.1 24.8-0.7 26.2-0.9 27.8-1.0 + 28JUL1999 20.2-1.0 24.4-1.0 26.0-1.0 27.8-0.9 + 04AUG1999 20.2-0.8 24.3-0.9 26.0-1.0 27.8-0.9 + 11AUG1999 19.7-1.1 24.1-1.0 25.6-1.3 27.7-1.0 + 18AUG1999 19.5-1.1 23.9-1.1 25.4-1.4 27.8-0.9 + 25AUG1999 19.7-0.9 24.0-1.0 25.5-1.3 27.6-1.1 + 01SEP1999 19.5-1.0 23.6-1.3 25.4-1.4 27.6-1.0 + 08SEP1999 19.2-1.2 23.7-1.2 25.7-1.1 27.7-0.9 + 15SEP1999 18.9-1.5 23.6-1.3 25.7-1.0 27.7-0.9 + 22SEP1999 19.3-1.2 23.8-1.1 25.8-0.9 27.9-0.7 + 29SEP1999 19.5-1.1 24.0-0.8 25.9-0.8 27.8-0.8 + 06OCT1999 19.7-0.9 23.6-1.3 25.7-1.0 27.9-0.8 + 13OCT1999 20.1-0.7 23.7-1.2 25.8-0.9 28.0-0.6 + 20OCT1999 20.0-1.0 23.7-1.2 25.6-1.0 27.8-0.9 + 27OCT1999 20.6-0.5 23.8-1.1 25.4-1.3 27.7-1.0 + 03NOV1999 20.1-1.2 23.6-1.3 25.4-1.3 27.6-1.0 + 10NOV1999 20.1-1.3 23.7-1.2 25.4-1.3 27.5-1.1 + 17NOV1999 20.6-1.0 23.5-1.5 25.2-1.5 27.6-1.0 + 24NOV1999 20.9-1.1 23.1-1.9 24.7-1.9 27.4-1.1 + 01DEC1999 21.0-1.2 23.1-1.9 24.9-1.7 27.3-1.2 + 08DEC1999 21.1-1.4 23.6-1.5 25.1-1.4 27.3-1.2 + 15DEC1999 21.3-1.4 23.4-1.7 24.9-1.7 27.1-1.4 + 22DEC1999 22.0-1.1 23.8-1.4 24.9-1.6 27.1-1.3 + 29DEC1999 23.0-0.5 23.6-1.8 24.6-1.9 27.2-1.2 + 05JAN2000 23.2-0.6 23.4-2.1 24.5-2.0 27.0-1.3 + 12JAN2000 23.8-0.4 23.9-1.7 24.7-1.9 26.9-1.4 + 19JAN2000 23.7-0.9 24.0-1.7 24.8-1.8 26.9-1.4 + 26JAN2000 24.0-1.0 24.0-1.8 24.6-2.0 26.9-1.3 + 02FEB2000 25.0-0.4 24.7-1.3 24.8-1.9 26.7-1.5 + 09FEB2000 25.1-0.7 25.3-0.9 25.1-1.6 26.6-1.5 + 16FEB2000 25.6-0.5 25.5-0.9 25.4-1.4 26.7-1.4 + 23FEB2000 26.2 0.0 25.4-1.2 25.2-1.6 26.6-1.5 + 01MAR2000 26.4 0.1 25.7-1.0 25.5-1.5 26.5-1.6 + 08MAR2000 26.6 0.2 26.2-0.8 25.7-1.4 26.6-1.5 + 15MAR2000 26.2-0.3 26.5-0.6 26.0-1.2 26.7-1.5 + 22MAR2000 25.3-1.0 26.9-0.3 26.3-1.1 26.7-1.5 + 29MAR2000 25.6-0.5 27.5 0.2 26.8-0.7 27.0-1.3 + 05APR2000 25.7-0.1 27.6 0.2 27.0-0.6 27.2-1.2 + 12APR2000 26.1 0.5 27.4-0.1 26.9-0.8 27.3-1.2 + 19APR2000 25.6 0.3 27.5 0.0 27.0-0.8 27.4-1.1 + 26APR2000 25.3 0.3 27.5 0.1 27.1-0.7 27.5-1.0 + 03MAY2000 24.9 0.2 27.3 0.0 27.1-0.7 27.5-1.1 + 10MAY2000 24.3-0.1 27.2 0.0 27.1-0.7 27.7-1.0 + 17MAY2000 23.9-0.3 26.6-0.4 27.1-0.8 27.8-1.0 + 24MAY2000 23.2-0.6 26.4-0.5 27.1-0.7 28.0-0.8 + 31MAY2000 23.2-0.3 26.3-0.4 27.2-0.5 28.1-0.7 + 07JUN2000 22.6-0.6 26.0-0.7 27.0-0.7 28.0-0.8 + 14JUN2000 22.4-0.5 25.9-0.6 27.1-0.6 28.1-0.7 + 21JUN2000 21.7-0.9 25.8-0.5 27.0-0.6 28.2-0.7 + 28JUN2000 21.4-0.9 25.5-0.6 26.9-0.6 28.0-0.8 + 05JUL2000 21.0-1.0 25.6-0.3 26.9-0.5 28.0-0.8 + 12JUL2000 20.6-1.2 25.2-0.5 26.8-0.5 28.1-0.7 + 19JUL2000 20.3-1.2 24.9-0.6 26.7-0.5 28.2-0.5 + 26JUL2000 20.2-1.1 24.9-0.5 26.5-0.6 28.3-0.4 + 02AUG2000 20.2-0.8 24.7-0.5 26.6-0.4 28.4-0.3 + 09AUG2000 20.1-0.8 24.5-0.6 26.6-0.3 28.4-0.3 + 16AUG2000 20.5-0.2 24.4-0.6 26.4-0.4 28.3-0.3 + 23AUG2000 20.1-0.5 24.3-0.7 26.3-0.5 28.1-0.5 + 30AUG2000 19.3-1.2 24.5-0.4 26.4-0.4 28.2-0.4 + 06SEP2000 20.2-0.3 24.4-0.4 26.3-0.5 28.4-0.2 + 13SEP2000 19.7-0.7 24.3-0.6 26.1-0.6 28.4-0.2 + 20SEP2000 20.1-0.3 24.2-0.6 26.1-0.6 28.5-0.2 + 27SEP2000 19.9-0.6 24.4-0.5 26.3-0.4 28.4-0.3 + 04OCT2000 20.2-0.5 24.7-0.2 26.1-0.6 28.1-0.5 + 11OCT2000 20.2-0.5 24.4-0.5 26.0-0.6 28.2-0.4 + 18OCT2000 20.5-0.3 24.3-0.6 25.9-0.8 28.1-0.5 + 25OCT2000 20.7-0.4 24.3-0.6 25.9-0.8 28.1-0.6 + 01NOV2000 20.6-0.6 24.2-0.8 25.6-1.1 28.0-0.6 + 08NOV2000 20.6-0.8 24.0-1.0 25.6-1.1 28.1-0.6 + 15NOV2000 20.3-1.3 24.2-0.7 25.9-0.7 28.2-0.4 + 22NOV2000 20.2-1.7 24.1-0.9 25.9-0.7 28.1-0.5 + 29NOV2000 21.4-0.7 24.4-0.6 25.9-0.7 27.8-0.7 + 06DEC2000 21.8-0.6 24.4-0.7 25.6-1.0 27.5-1.1 + 13DEC2000 22.4-0.2 24.5-0.6 25.6-1.0 27.6-0.9 + 20DEC2000 22.4-0.6 24.4-0.8 25.6-1.0 27.6-0.8 + 27DEC2000 22.2-1.2 24.4-1.0 25.5-1.0 27.5-0.9 + 03JAN2001 22.8-0.9 24.5-0.9 25.6-1.0 27.5-0.8 + 10JAN2001 23.3-0.8 24.7-0.8 25.6-1.0 27.5-0.9 + 17JAN2001 23.7-0.8 25.1-0.6 25.8-0.8 27.5-0.8 + 24JAN2001 24.6-0.3 25.3-0.5 25.9-0.8 27.4-0.8 + 31JAN2001 25.2 0.0 25.4-0.6 26.0-0.7 27.3-0.9 + 07FEB2001 25.6-0.1 25.8-0.4 25.9-0.8 27.1-1.0 + 14FEB2001 25.6-0.4 25.9-0.5 26.0-0.7 27.2-0.9 + 21FEB2001 26.0-0.2 26.4-0.1 26.3-0.6 27.3-0.8 + 28FEB2001 26.7 0.4 26.7 0.0 26.4-0.5 27.4-0.8 + 07MAR2001 27.2 0.8 27.1 0.2 26.6-0.5 27.4-0.7 + 14MAR2001 27.3 0.8 27.2 0.1 26.8-0.4 27.6-0.6 + 21MAR2001 27.6 1.3 27.4 0.2 27.1-0.2 27.7-0.6 + 28MAR2001 27.7 1.6 27.4 0.2 27.0-0.4 27.8-0.5 + 04APR2001 27.3 1.5 27.6 0.2 27.3-0.3 27.9-0.4 + 11APR2001 27.2 1.6 27.7 0.3 27.6-0.1 28.1-0.3 + 18APR2001 26.2 0.8 27.7 0.2 27.7-0.1 28.3-0.2 + 25APR2001 25.9 0.8 27.2-0.1 27.6-0.2 28.2-0.3 + 02MAY2001 24.2-0.6 27.1-0.2 27.5-0.3 28.3-0.3 + 09MAY2001 23.9-0.6 27.0-0.1 27.6-0.2 28.6-0.1 + 16MAY2001 23.6-0.6 26.7-0.4 27.5-0.3 28.6-0.1 + 23MAY2001 23.3-0.6 26.9-0.1 27.7-0.1 28.8 0.0 + 30MAY2001 23.1-0.5 26.7 0.0 27.7-0.1 28.8 0.0 + 06JUN2001 22.1-1.2 26.7 0.1 27.8 0.1 28.8 0.0 + 13JUN2001 21.7-1.3 26.3-0.1 27.7 0.0 28.8 0.0 + 20JUN2001 21.5-1.2 26.3 0.0 27.7 0.1 28.8-0.1 + 27JUN2001 20.7-1.6 25.9-0.2 27.6 0.1 28.9 0.1 + 04JUL2001 20.7-1.4 25.6-0.3 27.5 0.1 29.0 0.2 + 11JUL2001 21.2-0.6 25.5-0.2 27.4 0.1 29.0 0.2 + 18JUL2001 20.9-0.7 25.5-0.1 27.3 0.1 29.1 0.3 + 25JUL2001 20.7-0.6 25.2-0.2 27.2 0.1 29.1 0.3 + 01AUG2001 20.3-0.8 25.0-0.3 27.2 0.1 29.1 0.4 + 08AUG2001 20.1-0.8 25.0-0.1 27.0 0.1 28.9 0.2 + 15AUG2001 19.8-0.9 24.7-0.3 26.8 0.0 28.9 0.2 + 22AUG2001 19.8-0.8 24.6-0.3 26.8 0.0 28.9 0.2 + 29AUG2001 19.7-0.9 24.3-0.6 26.6-0.2 29.0 0.4 + 05SEP2001 19.6-0.8 24.4-0.5 26.6-0.1 29.2 0.5 + 12SEP2001 19.1-1.3 24.2-0.7 26.6-0.2 29.1 0.4 + 19SEP2001 19.4-1.0 24.2-0.6 26.5-0.2 29.2 0.5 + 26SEP2001 19.6-0.9 24.3-0.6 26.5-0.2 29.1 0.4 + 03OCT2001 19.2-1.4 24.4-0.5 26.5-0.2 28.9 0.3 + 10OCT2001 19.6-1.1 24.4-0.5 26.5-0.2 29.0 0.4 + 17OCT2001 19.4-1.4 24.5-0.4 26.6 0.0 29.0 0.3 + 24OCT2001 19.6-1.4 24.5-0.4 26.6 0.0 29.1 0.4 + 31OCT2001 19.9-1.3 24.5-0.5 26.6 0.0 28.9 0.3 + 07NOV2001 20.3-1.1 24.3-0.7 26.6-0.1 29.1 0.5 + 14NOV2001 20.1-1.5 24.3-0.7 26.5-0.1 29.0 0.4 + 21NOV2001 20.6-1.2 24.3-0.7 26.3-0.3 28.8 0.2 + 28NOV2001 21.4-0.7 24.4-0.6 26.3-0.3 28.7 0.2 + 05DEC2001 21.4-1.0 24.5-0.6 26.1-0.5 28.6 0.1 + 12DEC2001 21.6-1.1 24.5-0.7 26.1-0.4 28.6 0.1 + 19DEC2001 22.0-0.9 24.6-0.5 26.2-0.4 28.5 0.0 + 26DEC2001 22.5-0.8 24.8-0.5 26.2-0.3 28.6 0.2 + 02JAN2002 23.2-0.5 24.8-0.7 26.2-0.4 28.6 0.2 + 09JAN2002 23.3-0.8 25.0-0.5 26.5-0.1 28.8 0.5 + 16JAN2002 23.5-1.0 25.0-0.7 26.4-0.1 28.9 0.6 + 23JAN2002 23.8-1.1 25.3-0.5 26.6 0.0 28.9 0.6 + 30JAN2002 24.3-0.9 25.5-0.5 26.7 0.1 28.7 0.6 + 06FEB2002 25.4-0.2 26.0-0.2 26.9 0.3 28.8 0.7 + 13FEB2002 25.9-0.1 26.2-0.2 27.0 0.3 28.9 0.8 + 20FEB2002 26.3 0.1 26.4-0.1 26.8 0.0 28.6 0.5 + 27FEB2002 27.4 1.1 26.7 0.0 27.1 0.1 28.6 0.5 + 06MAR2002 27.1 0.8 27.1 0.2 27.2 0.1 28.5 0.4 + 13MAR2002 27.6 1.2 27.2 0.1 27.3 0.1 28.6 0.4 + 20MAR2002 27.8 1.4 27.3 0.1 27.4 0.1 28.8 0.6 + 27MAR2002 27.4 1.3 27.4 0.2 27.4 0.0 28.7 0.5 + 03APR2002 27.1 1.2 27.6 0.2 27.7 0.2 28.8 0.5 + 10APR2002 27.1 1.5 27.8 0.4 28.0 0.3 29.0 0.6 + 17APR2002 26.3 0.9 27.6 0.1 27.9 0.2 29.1 0.6 + 24APR2002 25.4 0.3 27.3 0.0 28.0 0.2 29.3 0.7 + 01MAY2002 25.4 0.6 27.4 0.1 28.0 0.2 29.2 0.6 + 08MAY2002 25.0 0.5 27.3 0.1 28.0 0.2 29.2 0.5 + 15MAY2002 24.5 0.2 27.2 0.1 28.0 0.1 29.4 0.6 + 22MAY2002 24.4 0.5 27.1 0.2 28.3 0.4 29.6 0.8 + 29MAY2002 24.5 0.9 27.4 0.5 28.4 0.7 29.7 0.9 + 05JUN2002 23.5 0.2 27.3 0.6 28.6 0.9 29.8 1.0 + 12JUN2002 22.7-0.3 27.1 0.6 28.6 0.9 29.7 0.9 + 19JUN2002 22.1-0.6 27.0 0.6 28.4 0.8 29.6 0.8 + 26JUN2002 22.0-0.4 26.9 0.8 28.2 0.7 29.4 0.6 + 03JUL2002 21.8-0.3 26.6 0.6 28.0 0.6 29.4 0.6 + 10JUL2002 21.1-0.8 26.3 0.5 28.0 0.7 29.4 0.6 + 17JUL2002 21.2-0.4 26.0 0.4 28.0 0.8 29.5 0.7 + 24JUL2002 20.5-0.8 25.7 0.2 27.9 0.8 29.5 0.8 + 31JUL2002 20.3-0.8 25.5 0.2 27.9 0.9 29.6 0.9 + 07AUG2002 20.0-0.9 25.3 0.1 27.8 0.9 29.4 0.7 + 14AUG2002 20.3-0.4 25.5 0.5 27.8 0.9 29.4 0.7 + 21AUG2002 19.8-0.8 25.5 0.5 27.8 1.0 29.3 0.7 + 28AUG2002 19.8-0.7 25.6 0.7 27.8 1.0 29.4 0.7 + 04SEP2002 19.3-1.2 25.4 0.5 27.7 0.9 29.3 0.7 + 11SEP2002 20.2-0.2 25.5 0.6 27.8 1.0 29.4 0.7 + 18SEP2002 20.1-0.3 25.5 0.7 27.9 1.2 29.5 0.9 + 25SEP2002 20.1-0.4 25.7 0.8 27.9 1.2 29.5 0.8 + 02OCT2002 20.1-0.5 25.7 0.8 28.0 1.3 29.5 0.8 + 09OCT2002 20.7 0.0 25.6 0.7 27.9 1.2 29.4 0.7 + 16OCT2002 21.7 0.9 25.7 0.8 27.9 1.2 29.4 0.7 + 23OCT2002 21.6 0.6 26.0 1.1 28.2 1.6 29.8 1.2 + 30OCT2002 21.9 0.7 26.3 1.4 28.3 1.7 29.9 1.2 + 06NOV2002 22.0 0.6 26.2 1.3 28.2 1.6 29.8 1.2 + 13NOV2002 21.9 0.4 26.3 1.4 28.3 1.7 29.9 1.3 + 20NOV2002 22.5 0.7 26.5 1.5 28.3 1.7 29.9 1.3 + 27NOV2002 22.6 0.6 26.4 1.4 28.2 1.6 29.7 1.2 + 04DEC2002 23.0 0.7 26.6 1.6 28.2 1.6 29.6 1.0 + 11DEC2002 23.5 0.9 26.5 1.4 28.1 1.5 29.4 1.0 + 18DEC2002 23.3 0.4 26.5 1.3 28.1 1.5 29.4 1.0 + 25DEC2002 23.5 0.2 26.3 1.0 28.0 1.4 29.5 1.1 + 01JAN2003 24.2 0.6 26.6 1.2 28.1 1.5 29.4 1.1 + 08JAN2003 23.9-0.1 26.3 0.8 27.9 1.3 29.2 0.9 + 15JAN2003 24.1-0.3 26.3 0.7 27.7 1.2 29.3 1.0 + 22JAN2003 24.4-0.4 26.5 0.7 27.7 1.1 29.3 1.0 + 29JAN2003 24.9-0.3 26.3 0.3 27.5 0.8 29.1 0.9 + 05FEB2003 25.3-0.3 26.4 0.3 27.3 0.6 28.9 0.7 + 12FEB2003 25.7-0.3 26.6 0.3 27.4 0.7 28.9 0.9 + 19FEB2003 26.2 0.0 27.0 0.6 27.7 0.9 29.1 1.0 + 26FEB2003 26.0-0.3 26.8 0.1 27.6 0.7 29.2 1.1 + 05MAR2003 25.7-0.7 27.0 0.2 27.6 0.6 29.0 0.9 + 12MAR2003 25.7-0.8 27.2 0.1 27.7 0.6 29.0 0.8 + 19MAR2003 26.5 0.1 27.6 0.4 28.0 0.8 29.1 0.9 + 26MAR2003 25.5-0.7 27.4 0.2 27.9 0.5 29.0 0.7 + 02APR2003 25.7-0.3 27.2-0.1 27.8 0.3 28.9 0.6 + 09APR2003 24.8-0.9 27.3-0.1 27.8 0.2 29.0 0.6 + 16APR2003 24.3-1.1 27.3-0.2 27.9 0.1 28.9 0.5 + 23APR2003 23.6-1.6 27.2-0.2 27.8 0.0 28.9 0.4 + 30APR2003 23.2-1.6 26.5-0.8 27.7-0.1 28.9 0.3 + 07MAY2003 23.0-1.6 26.3-0.9 27.4-0.4 28.9 0.2 + 14MAY2003 22.5-1.8 26.2-0.9 27.3-0.5 28.8 0.1 + 21MAY2003 22.3-1.7 26.0-1.0 27.3-0.6 28.8 0.1 + 28MAY2003 22.0-1.6 26.0-0.9 27.4-0.4 29.0 0.2 + 04JUN2003 21.9-1.4 25.7-0.9 27.4-0.3 29.0 0.2 + 11JUN2003 21.6-1.5 25.7-0.8 27.4-0.2 29.1 0.2 + 18JUN2003 21.1-1.6 25.9-0.5 27.5-0.1 29.1 0.3 + 25JUN2003 21.6-0.8 25.9-0.2 27.6 0.0 29.1 0.3 + 02JUL2003 21.4-0.7 25.9-0.1 27.5 0.1 29.2 0.4 + 09JUL2003 21.1-0.8 25.9 0.0 27.6 0.3 29.2 0.4 + 16JUL2003 20.8-0.8 25.8 0.1 27.5 0.3 29.1 0.3 + 23JUL2003 20.2-1.2 25.7 0.2 27.3 0.2 29.1 0.3 + 30JUL2003 20.3-0.9 25.5 0.2 27.1 0.1 29.0 0.3 + 06AUG2003 20.2-0.8 25.3 0.1 27.0 0.0 29.0 0.3 + 13AUG2003 20.0-0.8 25.0 0.0 26.9 0.1 29.1 0.5 + 20AUG2003 20.6 0.0 24.9-0.1 26.7-0.1 29.0 0.4 + 27AUG2003 20.0-0.5 24.8-0.2 26.7-0.1 29.0 0.3 + 03SEP2003 20.4-0.1 25.0 0.1 26.9 0.1 29.0 0.3 + 10SEP2003 19.9-0.5 24.8-0.1 26.8 0.0 28.9 0.2 + 17SEP2003 19.5-0.8 25.0 0.1 26.9 0.2 28.9 0.3 + 24SEP2003 20.5 0.0 25.0 0.2 27.1 0.4 29.1 0.5 + 01OCT2003 20.1-0.5 25.3 0.4 27.3 0.6 29.1 0.4 + 08OCT2003 20.9 0.2 25.5 0.6 27.4 0.7 29.1 0.5 + 15OCT2003 20.9 0.1 25.2 0.3 27.1 0.4 29.1 0.5 + 22OCT2003 21.5 0.6 25.3 0.3 27.1 0.4 29.3 0.6 + 29OCT2003 21.4 0.3 25.4 0.4 27.2 0.5 29.3 0.7 + 05NOV2003 21.6 0.3 25.3 0.4 27.0 0.4 29.4 0.7 + 12NOV2003 21.8 0.3 25.3 0.4 26.9 0.3 29.3 0.7 + 19NOV2003 22.0 0.3 25.4 0.4 27.1 0.4 29.3 0.7 + 26NOV2003 22.3 0.3 25.5 0.5 27.2 0.5 29.2 0.6 + 03DEC2003 22.5 0.2 25.6 0.5 27.1 0.5 29.2 0.6 + 10DEC2003 22.9 0.3 25.5 0.4 27.0 0.4 29.1 0.6 + 17DEC2003 23.0 0.1 25.4 0.3 26.8 0.3 29.0 0.5 + 24DEC2003 23.0-0.2 25.6 0.3 26.8 0.2 28.9 0.4 + 31DEC2003 23.8 0.2 25.7 0.4 26.7 0.1 28.7 0.4 + 07JAN2004 24.2 0.2 25.7 0.2 26.6 0.0 28.7 0.3 + 14JAN2004 24.6 0.2 25.9 0.3 26.6 0.0 28.9 0.6 + 21JAN2004 24.8 0.0 26.0 0.3 27.0 0.4 28.9 0.7 + 28JAN2004 24.7-0.4 26.1 0.1 26.9 0.2 28.8 0.6 + 04FEB2004 25.0-0.5 26.0-0.1 26.8 0.1 28.7 0.6 + 11FEB2004 25.4-0.5 26.4 0.1 26.8 0.1 28.5 0.4 + 18FEB2004 26.1 0.0 26.7 0.2 26.9 0.1 28.5 0.4 + 25FEB2004 26.3 0.1 26.7 0.1 27.0 0.1 28.5 0.4 + 03MAR2004 25.8-0.6 26.7-0.1 26.9-0.1 28.5 0.4 + 10MAR2004 25.4-1.0 27.1 0.1 26.9-0.2 28.3 0.1 + 17MAR2004 25.6-0.8 27.4 0.2 27.1-0.1 28.3 0.1 + 24MAR2004 26.0-0.3 27.4 0.1 27.3-0.1 28.4 0.2 + 31MAR2004 26.1 0.1 27.4 0.1 27.5 0.0 28.5 0.2 + 07APR2004 26.0 0.2 27.4 0.0 27.7 0.1 28.6 0.2 + 14APR2004 25.2-0.3 27.4 0.0 27.8 0.1 28.7 0.2 + 21APR2004 24.8-0.4 27.4 0.0 28.0 0.2 28.8 0.3 + 28APR2004 24.1-0.9 27.2-0.1 28.1 0.3 28.9 0.3 + 05MAY2004 23.6-1.0 26.7-0.5 27.9 0.1 29.0 0.3 + 12MAY2004 23.1-1.3 26.6-0.6 28.0 0.1 29.0 0.3 + 19MAY2004 22.8-1.3 26.8-0.3 28.2 0.4 29.2 0.4 + 26MAY2004 22.7-1.0 26.7-0.2 28.1 0.3 29.4 0.6 + 02JUN2004 22.1-1.4 26.7 0.0 28.1 0.3 29.2 0.4 + 09JUN2004 21.7-1.4 26.6 0.0 28.0 0.3 29.2 0.4 + 16JUN2004 21.5-1.3 26.4-0.1 27.8 0.1 29.2 0.4 + 23JUN2004 21.3-1.2 26.0-0.3 27.5 0.0 29.1 0.2 + 30JUN2004 21.0-1.2 25.6-0.4 27.3-0.1 29.1 0.3 + 07JUL2004 20.8-1.2 25.4-0.4 27.6 0.3 29.4 0.6 + 14JUL2004 20.9-0.8 25.5-0.2 27.7 0.4 29.4 0.6 + 21JUL2004 20.7-0.7 25.2-0.3 27.7 0.6 29.4 0.7 + 28JUL2004 20.3-0.9 25.4 0.0 27.9 0.8 29.4 0.6 + 04AUG2004 19.9-1.1 25.2 0.0 27.8 0.8 29.4 0.7 + 11AUG2004 19.7-1.1 25.1 0.0 27.6 0.7 29.2 0.6 + 18AUG2004 19.6-1.0 24.9 0.0 27.4 0.6 29.2 0.5 + 25AUG2004 19.2-1.4 24.9 0.0 27.4 0.7 29.3 0.7 + 01SEP2004 20.1-0.4 25.0 0.1 27.4 0.7 29.6 0.9 + 08SEP2004 19.8-0.6 25.0 0.1 27.4 0.6 29.6 0.9 + 15SEP2004 19.8-0.5 25.1 0.3 27.5 0.7 29.6 0.9 + 22SEP2004 20.4-0.1 25.3 0.4 27.6 0.9 29.6 0.9 + 29SEP2004 20.5-0.1 25.4 0.5 27.5 0.8 29.5 0.8 + 06OCT2004 20.8 0.1 25.2 0.4 27.4 0.7 29.5 0.8 + 13OCT2004 20.5-0.2 25.2 0.3 27.3 0.6 29.4 0.8 + 20OCT2004 21.4 0.5 25.4 0.5 27.4 0.7 29.6 1.0 + 27OCT2004 21.3 0.2 25.4 0.5 27.4 0.7 29.7 1.0 + 03NOV2004 21.5 0.3 25.4 0.5 27.3 0.6 29.6 1.0 + 10NOV2004 22.0 0.5 25.5 0.5 27.3 0.6 29.5 0.9 + 17NOV2004 22.2 0.5 25.5 0.5 27.3 0.7 29.6 1.0 + 24NOV2004 21.9 0.0 25.4 0.4 27.3 0.7 29.5 1.0 + 01DEC2004 22.4 0.2 25.6 0.6 27.4 0.8 29.4 0.9 + 08DEC2004 22.3-0.2 25.7 0.6 27.4 0.8 29.4 0.8 + 15DEC2004 22.9 0.2 25.8 0.6 27.3 0.7 29.2 0.8 + 22DEC2004 22.9-0.2 25.9 0.6 27.3 0.7 29.5 1.1 + 29DEC2004 23.6 0.2 25.8 0.5 27.2 0.6 29.5 1.1 + 05JAN2005 23.7-0.2 25.7 0.3 27.1 0.5 29.3 0.9 + 12JAN2005 24.2 0.0 25.9 0.3 27.1 0.5 29.2 0.9 + 19JAN2005 25.0 0.3 26.0 0.3 27.1 0.5 29.2 0.9 + 26JAN2005 24.9-0.1 26.0 0.1 27.1 0.5 29.2 1.0 + 02FEB2005 24.6-0.8 25.9-0.2 26.9 0.2 29.0 0.8 + 09FEB2005 25.1-0.6 26.2-0.1 27.0 0.3 28.8 0.7 + 16FEB2005 25.8-0.3 26.4 0.0 27.0 0.3 28.8 0.7 + 23FEB2005 25.7-0.5 26.3-0.3 27.0 0.1 28.7 0.6 + 02MAR2005 25.2-1.1 26.2-0.6 27.0 0.0 28.8 0.6 + 09MAR2005 25.9-0.5 26.7-0.2 27.2 0.1 28.8 0.6 + 16MAR2005 25.9-0.6 27.3 0.2 27.6 0.4 29.0 0.8 + 23MAR2005 25.0-1.3 27.3 0.0 27.9 0.5 28.9 0.7 + 30MAR2005 24.9-1.1 27.4 0.1 28.0 0.5 29.0 0.7 + 06APR2005 24.8-1.0 27.4 0.0 28.0 0.4 28.9 0.5 + 13APR2005 24.6-0.9 27.7 0.2 27.9 0.1 28.8 0.3 + 20APR2005 24.8-0.5 27.9 0.5 28.2 0.4 28.9 0.4 + 27APR2005 25.4 0.4 28.1 0.8 28.3 0.5 29.1 0.5 + 04MAY2005 25.2 0.5 28.1 0.9 28.3 0.4 29.1 0.4 + 11MAY2005 24.6 0.2 27.6 0.5 28.2 0.4 29.1 0.3 + 18MAY2005 24.5 0.4 27.4 0.3 28.2 0.4 29.3 0.5 + 25MAY2005 23.5-0.3 27.1 0.2 28.2 0.4 29.2 0.4 + 01JUN2005 23.0-0.5 26.8 0.0 28.1 0.3 29.2 0.4 + 08JUN2005 22.6-0.5 26.9 0.3 28.1 0.4 29.2 0.4 + 15JUN2005 22.3-0.5 26.8 0.3 28.1 0.4 29.2 0.4 + 22JUN2005 22.2-0.3 26.9 0.6 28.0 0.5 29.1 0.3 + 29JUN2005 21.6-0.7 26.7 0.6 28.0 0.5 29.1 0.3 + 06JUL2005 21.5-0.5 26.3 0.4 27.8 0.4 29.2 0.4 + 13JUL2005 21.5-0.3 26.2 0.5 27.6 0.3 29.1 0.3 + 20JUL2005 20.7-0.8 25.8 0.2 27.3 0.2 29.0 0.2 + 27JUL2005 20.8-0.5 25.4 0.0 27.1 0.1 28.9 0.1 + 03AUG2005 20.8-0.2 25.2-0.1 26.9-0.1 28.8 0.1 + 10AUG2005 20.6-0.2 25.2 0.1 26.9 0.0 28.7 0.0 + 17AUG2005 20.4-0.2 25.4 0.4 27.0 0.2 28.9 0.2 + 24AUG2005 20.8 0.3 25.2 0.3 26.9 0.1 28.9 0.3 + 31AUG2005 20.4-0.1 24.8-0.1 26.7-0.1 28.9 0.2 + 07SEP2005 20.0-0.5 24.5-0.3 26.5-0.3 28.7 0.1 + 14SEP2005 19.7-0.7 24.5-0.4 26.4-0.3 28.7 0.0 + 21SEP2005 19.6-0.9 24.7-0.2 26.8 0.1 28.9 0.3 + 28SEP2005 19.6-0.9 24.5-0.4 26.7 0.0 28.9 0.3 + 05OCT2005 19.4-1.2 24.6-0.3 26.9 0.2 29.0 0.3 + 12OCT2005 20.0-0.8 24.9 0.0 26.9 0.2 28.9 0.3 + 19OCT2005 19.8-1.1 24.7-0.2 26.7 0.0 28.8 0.2 + 26OCT2005 19.9-1.2 24.7-0.2 26.6-0.1 28.8 0.1 + 02NOV2005 19.8-1.4 24.3-0.7 26.5-0.2 28.7 0.1 + 09NOV2005 20.2-1.2 24.2-0.7 26.3-0.4 28.6 0.0 + 16NOV2005 21.0-0.6 24.3-0.7 26.5-0.2 28.6 0.0 + 23NOV2005 21.2-0.7 24.3-0.7 26.3-0.3 28.7 0.1 + 30NOV2005 21.2-0.9 24.2-0.9 26.1-0.5 28.6 0.1 + 07DEC2005 21.4-1.1 24.1-1.0 26.0-0.6 28.6 0.0 + 14DEC2005 21.8-0.9 24.0-1.1 25.8-0.7 28.5 0.0 + 21DEC2005 23.1 0.1 24.3-0.9 25.8-0.8 28.1-0.3 + 28DEC2005 23.3-0.2 24.7-0.6 25.9-0.7 28.0-0.4 + 04JAN2006 23.4-0.4 25.0-0.5 25.8-0.7 27.9-0.5 + 11JAN2006 24.2 0.0 25.0-0.6 25.7-0.9 27.8-0.5 + 18JAN2006 24.3-0.2 24.8-0.9 25.5-1.1 27.6-0.7 + 25JAN2006 24.8-0.1 25.1-0.8 25.5-1.1 27.4-0.8 + 01FEB2006 25.0-0.3 25.5-0.6 25.8-0.9 27.4-0.7 + 08FEB2006 25.9 0.2 25.8-0.4 26.0-0.7 27.3-0.9 + 15FEB2006 27.1 1.0 26.3 0.0 26.1-0.6 27.3-0.8 + 22FEB2006 26.8 0.6 26.4-0.2 26.3-0.5 27.4-0.7 + 01MAR2006 27.0 0.7 26.2-0.6 26.1-0.9 27.4-0.7 + 08MAR2006 26.9 0.5 26.5-0.4 26.4-0.7 27.6-0.6 + 15MAR2006 26.7 0.2 26.5-0.6 26.5-0.7 27.7-0.5 + 22MAR2006 26.6 0.3 26.6-0.6 26.7-0.6 28.0-0.3 + 29MAR2006 26.0-0.1 26.8-0.5 27.0-0.5 28.1-0.2 + 05APR2006 24.9-0.9 27.1-0.3 27.3-0.3 28.1-0.2 + 12APR2006 24.0-1.5 27.6 0.1 27.7 0.0 28.3-0.1 + 19APR2006 23.4-2.0 27.2-0.2 27.7-0.1 28.4-0.1 + 26APR2006 23.1-1.9 27.2-0.2 27.7-0.1 28.5 0.0 + 03MAY2006 23.9-0.8 27.2-0.1 27.7-0.1 28.6-0.1 + 10MAY2006 24.1-0.4 27.1 0.0 27.8 0.0 28.8 0.1 + 17MAY2006 23.8-0.3 27.1 0.0 28.1 0.2 29.1 0.3 + 24MAY2006 23.5-0.3 26.9 0.0 28.0 0.2 29.0 0.2 + 31MAY2006 23.4-0.1 26.8 0.0 28.0 0.3 29.2 0.4 + 07JUN2006 22.6-0.6 26.6 0.0 28.0 0.3 29.2 0.4 + 14JUN2006 22.8-0.1 26.5 0.1 27.9 0.3 29.2 0.3 + 21JUN2006 22.5-0.1 26.3 0.0 27.8 0.2 29.2 0.3 + 28JUN2006 22.4 0.0 26.1 0.0 27.6 0.1 29.0 0.2 + 05JUL2006 22.2 0.1 26.0 0.1 27.5 0.1 29.0 0.1 + 12JUL2006 22.0 0.2 25.8 0.0 27.3 0.0 29.0 0.2 + 19JUL2006 22.3 0.8 25.8 0.2 27.3 0.1 29.1 0.3 + 26JUL2006 22.0 0.7 25.7 0.3 27.3 0.2 29.2 0.4 + 02AUG2006 21.9 0.8 25.5 0.3 27.2 0.2 29.2 0.5 + 09AUG2006 21.7 0.8 25.3 0.2 27.1 0.2 29.1 0.4 + 16AUG2006 21.6 0.9 25.4 0.4 27.2 0.4 29.2 0.6 + 23AUG2006 21.5 1.0 25.5 0.5 27.3 0.5 29.3 0.6 + 30AUG2006 21.1 0.6 25.6 0.6 27.3 0.5 29.3 0.7 + 06SEP2006 21.6 1.2 25.6 0.7 27.4 0.6 29.4 0.8 + 13SEP2006 21.3 0.9 25.8 0.9 27.3 0.6 29.4 0.7 + 20SEP2006 21.2 0.8 25.9 1.1 27.4 0.7 29.4 0.8 + 27SEP2006 21.7 1.1 25.7 0.8 27.2 0.5 29.3 0.7 + 04OCT2006 21.7 1.0 25.7 0.8 27.2 0.5 29.2 0.6 + 11OCT2006 22.2 1.4 26.1 1.2 27.5 0.8 29.4 0.8 + 18OCT2006 22.4 1.5 26.0 1.1 27.5 0.8 29.5 0.8 + 25OCT2006 22.7 1.6 26.1 1.1 27.6 0.9 29.6 1.0 + 01NOV2006 22.4 1.2 25.9 1.0 27.6 0.9 29.5 0.9 + 08NOV2006 22.5 1.1 25.9 0.9 27.6 0.9 29.6 1.0 + 15NOV2006 22.6 1.0 26.1 1.1 27.8 1.2 29.7 1.1 + 22NOV2006 22.7 0.8 26.3 1.2 27.8 1.2 29.6 1.1 + 29NOV2006 23.0 0.9 26.1 1.1 27.8 1.2 29.6 1.0 + 06DEC2006 22.9 0.5 26.1 1.1 27.9 1.3 29.6 1.1 + 13DEC2006 22.9 0.2 26.3 1.2 27.8 1.2 29.5 1.0 + 20DEC2006 23.7 0.6 26.5 1.3 27.7 1.2 29.4 1.0 + 27DEC2006 24.0 0.6 26.6 1.3 27.7 1.1 29.4 1.0 + 03JAN2007 24.3 0.5 26.4 0.9 27.5 0.9 29.2 0.8 + 10JAN2007 24.9 0.7 26.7 1.1 27.5 0.9 29.1 0.8 + 17JAN2007 25.0 0.4 26.4 0.7 27.2 0.6 28.8 0.6 + 24JAN2007 25.2 0.3 26.5 0.7 27.1 0.5 28.7 0.5 + 31JAN2007 25.6 0.3 26.6 0.6 27.0 0.3 28.7 0.5 + 07FEB2007 26.0 0.4 26.6 0.4 26.9 0.2 28.6 0.4 + 14FEB2007 26.3 0.3 26.3-0.1 26.7 0.0 28.6 0.6 + 21FEB2007 26.4 0.3 26.4-0.1 26.8-0.1 28.6 0.5 + 28FEB2007 25.7-0.6 26.4-0.3 26.9 0.0 28.5 0.4 + 07MAR2007 25.8-0.5 26.6-0.3 26.9-0.2 28.5 0.4 + 14MAR2007 26.0-0.5 27.3 0.2 27.3 0.1 28.6 0.4 + 21MAR2007 25.6-0.8 26.8-0.4 27.2-0.1 28.5 0.3 + 28MAR2007 25.1-1.0 26.6-0.7 27.4 0.0 28.5 0.2 + 04APR2007 24.5-1.4 26.7-0.7 27.5 0.0 28.7 0.3 + 11APR2007 24.4-1.2 27.2-0.2 27.8 0.1 28.7 0.3 + 18APR2007 23.9-1.4 27.4-0.1 27.9 0.2 28.7 0.2 + 25APR2007 24.1-1.0 27.3-0.1 27.8 0.0 28.7 0.1 + 02MAY2007 23.6-1.2 26.9-0.4 27.7-0.1 28.6 0.0 + 09MAY2007 23.0-1.5 26.3-0.9 27.4-0.4 28.7 0.0 + 16MAY2007 22.9-1.3 26.3-0.8 27.5-0.4 28.8 0.1 + 23MAY2007 22.3-1.6 26.3-0.6 27.7-0.1 29.0 0.2 + 30MAY2007 21.8-1.8 26.1-0.7 27.6-0.2 29.0 0.2 + 06JUN2007 21.6-1.6 25.8-0.9 27.6-0.1 29.0 0.2 + 13JUN2007 22.2-0.7 26.1-0.4 27.7 0.1 29.1 0.3 + 20JUN2007 21.8-0.8 25.9-0.5 27.6 0.0 28.9 0.1 + 27JUN2007 20.7-1.7 25.5-0.6 27.3-0.1 28.8 0.0 + 04JUL2007 21.2-0.9 25.3-0.6 27.0-0.4 28.7-0.1 + 11JUL2007 20.1-1.7 24.9-0.9 26.8-0.5 28.8 0.0 + 18JUL2007 19.9-1.7 24.8-0.8 26.9-0.3 28.9 0.1 + 25JUL2007 20.3-1.0 24.5-1.0 26.6-0.5 28.9 0.1 + 01AUG2007 19.6-1.5 24.1-1.2 26.4-0.6 28.7 0.0 + 08AUG2007 19.3-1.6 23.8-1.3 26.2-0.7 28.6-0.1 + 15AUG2007 19.7-1.0 24.0-1.0 26.3-0.6 28.6-0.1 + 22AUG2007 19.2-1.4 23.8-1.2 26.1-0.7 28.5-0.1 + 29AUG2007 18.4-2.1 23.7-1.3 26.1-0.7 28.4-0.2 + 05SEP2007 19.4-1.1 23.7-1.2 26.0-0.8 28.3-0.4 + 12SEP2007 18.6-1.8 23.6-1.3 25.8-1.0 28.0-0.6 + 19SEP2007 18.5-2.0 23.6-1.2 25.8-0.9 28.0-0.7 + 26SEP2007 18.4-2.1 23.2-1.7 25.6-1.1 28.0-0.7 + 03OCT2007 18.3-2.3 23.2-1.7 25.4-1.3 27.9-0.7 + 10OCT2007 18.8-1.9 23.3-1.6 24.9-1.8 27.7-1.0 + 17OCT2007 18.6-2.2 23.5-1.4 25.3-1.4 27.9-0.7 + 24OCT2007 19.2-1.8 23.5-1.4 25.3-1.4 27.8-0.8 + 31OCT2007 19.7-1.5 23.2-1.8 25.2-1.5 27.8-0.8 + 07NOV2007 19.3-2.1 23.0-2.0 25.0-1.6 27.5-1.1 + 14NOV2007 19.2-2.3 23.2-1.7 25.2-1.5 27.3-1.3 + 21NOV2007 19.8-2.0 23.2-1.8 24.9-1.7 27.1-1.5 + 28NOV2007 19.8-2.2 23.3-1.8 25.1-1.6 27.4-1.1 + 05DEC2007 20.6-1.8 23.5-1.5 25.1-1.5 27.5-1.0 + 12DEC2007 20.3-2.4 23.3-1.8 24.9-1.7 27.5-1.0 + 19DEC2007 21.3-1.6 23.7-1.5 25.0-1.6 27.2-1.3 + 26DEC2007 21.9-1.4 23.7-1.6 24.9-1.6 27.0-1.4 + 02JAN2008 22.6-1.1 23.9-1.5 25.0-1.6 26.8-1.6 + 09JAN2008 23.3-0.8 24.0-1.5 24.8-1.8 26.6-1.7 + 16JAN2008 24.1-0.4 24.0-1.6 24.6-2.0 26.6-1.7 + 23JAN2008 24.1-0.7 24.1-1.7 24.4-2.2 26.4-1.8 + 30JAN2008 25.1-0.1 24.7-1.3 24.9-1.7 26.5-1.7 + 06FEB2008 25.9 0.3 24.8-1.4 24.6-2.1 26.4-1.8 + 13FEB2008 25.9-0.1 24.7-1.7 24.5-2.2 26.4-1.7 + 20FEB2008 26.7 0.6 25.1-1.4 24.9-2.0 26.4-1.7 + 27FEB2008 27.2 0.9 25.8-0.9 25.3-1.6 26.3-1.8 + 05MAR2008 27.3 1.0 26.3-0.6 25.7-1.3 26.6-1.5 + 12MAR2008 27.2 0.7 26.5-0.5 26.0-1.1 26.7-1.4 + 19MAR2008 27.3 0.9 26.7-0.5 26.2-1.1 26.8-1.4 + 26MAR2008 27.1 0.9 26.8-0.5 26.3-1.0 27.0-1.2 + 02APR2008 27.2 1.2 26.9-0.4 26.5-1.0 27.2-1.2 + 09APR2008 25.9 0.2 27.3-0.2 26.7-1.0 27.3-1.1 + 16APR2008 25.5 0.0 27.3-0.2 26.9-0.9 27.4-1.1 + 23APR2008 25.5 0.4 27.1-0.3 26.9-0.9 27.5-1.1 + 30APR2008 24.5-0.3 27.3 0.0 27.1-0.7 27.7-0.9 + 07MAY2008 24.1-0.5 26.8-0.4 27.0-0.9 27.7-1.0 + 14MAY2008 24.5 0.2 27.1-0.1 27.1-0.7 27.8-0.9 + 21MAY2008 24.1 0.1 27.2 0.2 27.3-0.5 28.0-0.7 + 28MAY2008 24.1 0.5 27.2 0.4 27.3-0.5 28.0-0.8 + 04JUN2008 24.0 0.7 27.0 0.3 27.3-0.4 28.0-0.8 + 11JUN2008 23.7 0.7 26.7 0.2 27.2-0.5 28.0-0.8 + 18JUN2008 23.3 0.6 26.3-0.1 27.1-0.5 28.1-0.8 + 25JUN2008 23.0 0.6 26.2 0.0 27.1-0.4 28.1-0.7 + 02JUL2008 22.7 0.5 26.3 0.4 27.2-0.2 28.2-0.6 + 09JUL2008 22.7 0.8 26.3 0.5 27.3-0.1 28.3-0.5 + 16JUL2008 22.7 1.1 26.2 0.5 27.3 0.0 28.3-0.5 + 23JUL2008 22.6 1.2 25.9 0.5 27.1 0.0 28.2-0.6 + 30JUL2008 22.2 1.1 25.9 0.5 27.1 0.0 28.2-0.5 + 06AUG2008 22.0 1.1 25.9 0.7 27.0 0.1 28.2-0.5 + 13AUG2008 22.5 1.8 25.8 0.8 27.0 0.2 28.2-0.5 + 20AUG2008 21.1 0.5 25.5 0.5 26.7-0.1 28.1-0.6 + 27AUG2008 21.3 0.8 25.3 0.4 26.6-0.2 28.1-0.6 + 03SEP2008 21.3 0.8 25.3 0.4 26.6-0.2 28.1-0.6 + 10SEP2008 21.0 0.6 25.2 0.3 26.6-0.2 28.1-0.6 + 17SEP2008 21.1 0.8 24.9 0.1 26.4-0.4 28.1-0.6 + 24SEP2008 21.3 0.8 25.1 0.2 26.4-0.4 28.1-0.6 + 01OCT2008 21.0 0.4 24.7-0.2 26.2-0.5 28.3-0.4 + 08OCT2008 20.6-0.1 24.9 0.0 26.3-0.4 28.3-0.4 + 15OCT2008 20.7-0.1 24.9-0.1 26.4-0.3 28.3-0.4 + 22OCT2008 21.0 0.0 24.8-0.2 26.3-0.4 28.2-0.4 + 29OCT2008 20.5-0.7 24.6-0.3 26.4-0.2 28.2-0.4 + 05NOV2008 21.3 0.0 24.6-0.3 26.3-0.3 28.2-0.4 + 12NOV2008 21.8 0.3 24.9-0.1 26.5-0.2 28.1-0.5 + 19NOV2008 21.5-0.2 24.9-0.1 26.3-0.3 28.0-0.6 + 26NOV2008 21.2-0.8 24.6-0.4 26.1-0.5 27.9-0.6 + 03DEC2008 21.4-0.9 24.8-0.3 26.0-0.6 27.9-0.6 + 10DEC2008 22.1-0.4 24.6-0.5 25.8-0.8 27.7-0.7 + 17DEC2008 22.6-0.3 24.6-0.6 25.8-0.8 27.7-0.8 + 24DEC2008 22.8-0.5 24.5-0.8 25.6-1.0 27.5-0.9 + 31DEC2008 23.3-0.3 24.4-1.0 25.4-1.2 27.5-0.9 + 07JAN2009 23.4-0.6 24.5-0.9 25.4-1.2 27.4-1.0 + 14JAN2009 24.0-0.3 24.8-0.8 25.4-1.1 27.4-0.9 + 21JAN2009 25.3 0.5 25.5-0.2 25.8-0.8 27.4-0.8 + 28JAN2009 25.3 0.2 25.5-0.4 25.7-1.0 27.3-0.9 + 04FEB2009 25.1-0.4 25.4-0.7 25.7-0.9 27.2-0.9 + 11FEB2009 25.8 0.0 25.6-0.6 25.9-0.8 27.3-0.8 + 18FEB2009 26.3 0.2 26.1-0.4 26.2-0.6 27.4-0.7 + 25FEB2009 26.5 0.2 26.4-0.3 26.3-0.6 27.4-0.7 + 04MAR2009 26.5 0.2 26.1-0.7 26.4-0.7 27.5-0.6 + 11MAR2009 26.1-0.3 26.1-0.9 26.7-0.5 27.7-0.4 + 18MAR2009 26.0-0.4 26.4-0.7 26.7-0.6 27.8-0.4 + 25MAR2009 26.3 0.1 26.7-0.5 26.8-0.6 27.9-0.4 + 01APR2009 26.4 0.5 27.2-0.1 27.1-0.4 28.1-0.2 + 08APR2009 25.7 0.0 27.4 0.0 27.4-0.2 28.3-0.1 + 15APR2009 26.1 0.7 27.5 0.0 27.5-0.2 28.3-0.2 + 22APR2009 25.4 0.2 27.3-0.1 27.6-0.2 28.4-0.2 + 29APR2009 25.3 0.4 27.5 0.2 27.7-0.1 28.6 0.0 + 06MAY2009 25.3 0.7 27.6 0.4 27.9 0.1 28.8 0.1 + 13MAY2009 24.8 0.5 27.4 0.3 28.0 0.2 29.0 0.2 + 20MAY2009 24.4 0.4 27.4 0.4 28.2 0.4 29.1 0.3 + 27MAY2009 24.3 0.6 27.2 0.4 28.1 0.3 29.1 0.3 + 03JUN2009 23.7 0.4 27.1 0.4 27.9 0.2 29.0 0.2 + 10JUN2009 23.7 0.6 27.2 0.6 28.1 0.4 29.1 0.3 + 17JUN2009 23.9 1.1 27.2 0.8 28.2 0.5 29.2 0.4 + 24JUN2009 23.5 1.0 27.1 0.9 28.2 0.7 29.3 0.5 + 01JUL2009 22.9 0.7 26.9 0.9 28.2 0.7 29.3 0.5 + 08JUL2009 23.0 1.1 26.7 0.9 28.0 0.7 29.2 0.4 + 15JUL2009 22.7 1.0 26.6 1.0 28.0 0.7 29.2 0.4 + 22JUL2009 22.2 0.8 26.5 1.0 27.9 0.8 29.2 0.4 + 29JUL2009 22.1 0.9 26.2 0.8 27.7 0.6 29.1 0.4 + 05AUG2009 22.2 1.2 26.0 0.8 27.6 0.6 29.1 0.4 + 12AUG2009 21.4 0.6 25.9 0.8 27.4 0.6 29.1 0.4 + 19AUG2009 21.6 0.9 25.8 0.9 27.4 0.6 29.2 0.6 + 26AUG2009 21.5 1.0 25.9 1.0 27.6 0.8 29.3 0.7 + 02SEP2009 21.4 0.9 25.9 1.0 27.6 0.8 29.3 0.6 + 09SEP2009 21.1 0.6 25.7 0.8 27.5 0.8 29.3 0.6 + 16SEP2009 20.8 0.4 25.6 0.8 27.5 0.8 29.3 0.6 + 23SEP2009 20.5 0.0 25.6 0.7 27.4 0.7 29.2 0.6 + 30SEP2009 20.4-0.2 25.4 0.6 27.3 0.6 29.2 0.6 + 07OCT2009 20.1-0.5 25.5 0.6 27.3 0.6 29.4 0.7 + 14OCT2009 21.0 0.2 25.6 0.7 27.5 0.8 29.6 1.0 + 21OCT2009 21.2 0.3 25.8 0.8 27.7 1.0 29.8 1.2 + 28OCT2009 21.6 0.5 26.1 1.2 28.1 1.4 30.0 1.3 + 04NOV2009 21.8 0.5 26.2 1.3 28.2 1.6 29.9 1.3 + 11NOV2009 22.1 0.6 26.2 1.2 28.2 1.5 29.9 1.3 + 18NOV2009 22.2 0.5 26.2 1.2 28.2 1.6 29.8 1.2 + 25NOV2009 22.2 0.3 26.3 1.2 28.2 1.6 29.9 1.3 + 02DEC2009 22.7 0.4 26.5 1.4 28.2 1.6 29.7 1.2 + 09DEC2009 22.7 0.2 26.6 1.5 28.2 1.7 29.6 1.1 + 16DEC2009 22.6-0.2 26.7 1.5 28.3 1.8 29.7 1.2 + 23DEC2009 23.7 0.5 26.8 1.5 28.4 1.9 29.7 1.3 + 30DEC2009 24.3 0.7 26.7 1.4 28.3 1.7 29.6 1.2 + 06JAN2010 24.3 0.4 26.7 1.2 28.3 1.7 29.7 1.3 + 13JAN2010 24.6 0.3 26.7 1.1 28.2 1.6 29.6 1.3 + 20JAN2010 24.7 0.1 26.5 0.8 28.0 1.4 29.5 1.2 + 27JAN2010 25.5 0.4 26.6 0.7 27.8 1.2 29.3 1.1 + 03FEB2010 25.4 0.0 26.7 0.6 27.8 1.2 29.1 1.0 + 10FEB2010 25.7-0.2 27.0 0.7 27.9 1.2 29.0 0.9 + 17FEB2010 26.4 0.3 27.2 0.8 27.9 1.2 29.0 1.0 + 24FEB2010 26.5 0.3 27.4 0.8 28.0 1.1 29.2 1.1 + 03MAR2010 26.3-0.1 27.5 0.7 28.1 1.1 29.2 1.0 + 10MAR2010 26.0-0.4 27.5 0.5 28.3 1.2 29.3 1.1 + 17MAR2010 26.2-0.3 27.8 0.7 28.4 1.1 29.2 1.1 + 24MAR2010 26.3 0.0 27.9 0.7 28.4 1.0 29.2 0.9 + 31MAR2010 25.9-0.1 28.1 0.8 28.4 0.9 29.2 0.8 + 07APR2010 26.0 0.3 28.1 0.7 28.4 0.8 29.3 0.9 + 14APR2010 26.6 1.0 28.2 0.8 28.5 0.7 29.2 0.7 + 21APR2010 26.0 0.8 28.0 0.6 28.4 0.6 29.2 0.7 + 28APR2010 25.2 0.3 27.8 0.4 28.2 0.4 29.3 0.7 + 05MAY2010 24.8 0.2 27.7 0.5 28.0 0.2 29.1 0.4 + 12MAY2010 24.8 0.5 27.1 0.0 27.7-0.2 29.0 0.3 + 19MAY2010 24.0 0.0 26.8-0.3 27.5-0.3 29.0 0.2 + 26MAY2010 23.2-0.5 26.4-0.4 27.5-0.3 29.0 0.2 + 02JUN2010 23.4 0.0 26.1-0.6 27.3-0.5 28.8 0.0 + 09JUN2010 23.1 0.0 26.0-0.6 27.1-0.6 28.7-0.1 + 16JUN2010 22.3-0.5 25.8-0.6 27.0-0.7 28.6-0.2 + 23JUN2010 22.4-0.2 25.5-0.8 26.9-0.7 28.5-0.3 + 30JUN2010 21.6-0.7 25.3-0.8 26.7-0.8 28.3-0.5 + 07JUL2010 20.9-1.1 24.8-1.0 26.4-0.9 28.2-0.6 + 14JUL2010 20.0-1.6 24.6-1.1 26.1-1.1 28.2-0.6 + 21JUL2010 19.6-1.9 24.4-1.1 26.0-1.2 28.0-0.8 + 28JUL2010 19.5-1.7 24.0-1.4 25.6-1.4 27.8-1.0 + 04AUG2010 19.5-1.5 24.0-1.3 25.8-1.2 27.7-1.0 + 11AUG2010 19.6-1.2 24.1-1.0 25.7-1.2 27.5-1.2 + 18AUG2010 19.2-1.4 23.8-1.1 25.6-1.2 27.5-1.1 + 25AUG2010 19.2-1.4 23.7-1.3 25.2-1.6 27.1-1.5 + 01SEP2010 18.8-1.7 23.4-1.5 25.1-1.7 27.2-1.5 + 08SEP2010 19.1-1.3 23.5-1.4 25.2-1.6 27.1-1.6 + 15SEP2010 18.6-1.8 23.4-1.5 25.1-1.6 27.1-1.6 + 22SEP2010 19.3-1.2 24.0-0.8 25.1-1.6 27.1-1.6 + 29SEP2010 19.2-1.4 23.5-1.3 24.8-1.9 27.1-1.6 + 06OCT2010 18.7-1.9 23.2-1.7 24.8-1.9 27.1-1.6 + 13OCT2010 18.9-1.9 23.0-2.0 25.1-1.6 27.1-1.6 + 20OCT2010 19.1-1.8 23.2-1.7 25.1-1.6 27.0-1.7 + 27OCT2010 19.8-1.3 23.6-1.4 25.2-1.5 27.0-1.6 + 03NOV2010 19.7-1.6 23.4-1.6 25.2-1.4 27.0-1.6 + 10NOV2010 19.5-1.9 23.5-1.5 25.2-1.4 27.2-1.5 + 17NOV2010 20.2-1.5 23.5-1.5 25.0-1.6 27.1-1.5 + 24NOV2010 20.6-1.3 23.3-1.7 24.9-1.7 26.9-1.7 + 01DEC2010 20.5-1.7 23.3-1.7 25.0-1.7 27.0-1.5 + 08DEC2010 20.9-1.5 23.4-1.7 25.0-1.6 26.9-1.6 + 15DEC2010 21.1-1.7 23.5-1.7 25.0-1.5 26.9-1.6 + 22DEC2010 21.7-1.4 23.4-1.8 24.8-1.8 26.8-1.6 + 29DEC2010 22.9-0.6 23.8-1.5 25.0-1.5 26.7-1.7 + 05JAN2011 23.1-0.7 24.1-1.3 25.0-1.5 26.7-1.7 + 12JAN2011 23.6-0.7 24.1-1.5 24.7-1.8 26.6-1.7 + 19JAN2011 24.2-0.5 24.4-1.3 25.0-1.6 26.7-1.6 + 26JAN2011 25.0 0.0 24.5-1.4 24.9-1.7 26.8-1.4 + 02FEB2011 25.3-0.1 24.9-1.1 25.1-1.5 26.6-1.5 + 09FEB2011 25.9 0.2 25.5-0.8 25.5-1.2 26.8-1.3 + 16FEB2011 26.8 0.7 25.6-0.8 25.4-1.3 27.0-1.1 + 23FEB2011 26.4 0.2 25.9-0.7 25.6-1.3 27.0-1.1 + 02MAR2011 25.7-0.6 26.0-0.8 25.7-1.3 27.1-1.1 + 09MAR2011 26.3-0.2 26.2-0.8 26.0-1.1 27.3-0.9 + 16MAR2011 26.6 0.1 26.3-0.8 26.4-0.9 27.5-0.7 + 23MAR2011 25.8-0.5 26.6-0.6 26.4-0.9 27.5-0.7 + 30MAR2011 25.6-0.4 26.9-0.4 26.6-0.9 27.5-0.8 + 06APR2011 25.4-0.4 27.1-0.2 26.9-0.7 27.7-0.6 + 13APR2011 25.8 0.3 27.3-0.2 27.1-0.7 27.9-0.6 + 20APR2011 25.4 0.1 27.2-0.3 27.1-0.7 27.8-0.7 + 27APR2011 25.8 0.8 27.2-0.1 27.1-0.7 27.9-0.7 + 04MAY2011 25.1 0.4 27.0-0.3 27.2-0.6 28.0-0.7 + 11MAY2011 25.3 0.9 27.0-0.2 27.4-0.5 28.3-0.5 + 18MAY2011 24.6 0.5 27.0-0.1 27.6-0.3 28.4-0.4 + 25MAY2011 24.0 0.3 26.8 0.0 27.5-0.3 28.3-0.5 + 01JUN2011 24.3 0.8 26.8 0.1 27.5-0.2 28.4-0.4 + 08JUN2011 24.2 1.1 26.7 0.1 27.5-0.2 28.4-0.4 + 15JUN2011 23.8 1.0 26.6 0.1 27.4-0.2 28.4-0.4 + 22JUN2011 23.2 0.6 26.5 0.2 27.4-0.1 28.4-0.4 + 29JUN2011 22.9 0.6 26.1 0.1 27.4-0.1 28.6-0.2 + 06JUL2011 22.2 0.2 25.8-0.1 27.1-0.3 28.5-0.3 + 13JUL2011 21.9 0.2 25.7 0.0 27.1-0.2 28.5-0.3 + 20JUL2011 22.1 0.6 25.6 0.0 26.9-0.3 28.4-0.4 + 27JUL2011 21.9 0.7 25.3-0.1 26.8-0.3 28.4-0.4 + 03AUG2011 21.5 0.4 25.0-0.3 26.4-0.6 28.3-0.4 + 10AUG2011 20.9 0.0 24.6-0.5 26.3-0.6 28.4-0.3 + 17AUG2011 20.5-0.1 24.5-0.5 26.0-0.8 28.2-0.4 + 24AUG2011 20.2-0.4 24.3-0.6 26.1-0.7 28.3-0.4 + 31AUG2011 20.0-0.5 24.4-0.5 26.1-0.7 28.3-0.4 + 07SEP2011 19.7-0.7 24.2-0.7 26.1-0.7 28.2-0.5 + 14SEP2011 19.6-0.8 24.1-0.7 26.0-0.8 28.0-0.7 + 21SEP2011 19.8-0.6 24.3-0.6 25.9-0.9 27.8-0.9 + 28SEP2011 19.9-0.6 24.1-0.7 26.0-0.7 28.0-0.7 + 05OCT2011 19.8-0.8 24.1-0.8 25.7-1.0 27.7-0.9 + 12OCT2011 19.7-1.0 24.1-0.8 25.8-0.9 27.9-0.8 + 19OCT2011 20.0-0.9 23.9-1.1 25.8-0.8 28.1-0.6 + 26OCT2011 21.2 0.2 23.8-1.1 25.4-1.2 28.0-0.7 + 02NOV2011 20.5-0.8 23.9-1.1 25.6-1.0 27.9-0.8 + 09NOV2011 20.5-0.9 23.9-1.1 25.7-0.9 27.9-0.7 + 16NOV2011 20.5-1.1 23.8-1.1 25.6-1.0 27.9-0.7 + 23NOV2011 21.4-0.5 24.0-1.0 25.6-1.0 27.8-0.8 + 30NOV2011 21.0-1.2 23.8-1.3 25.4-1.2 27.7-0.9 + 07DEC2011 21.4-1.0 23.9-1.2 25.5-1.1 27.5-1.0 + 14DEC2011 21.5-1.2 24.1-1.0 25.6-1.0 27.4-1.1 + 21DEC2011 22.1-1.0 24.5-0.7 25.6-1.0 27.2-1.3 + 28DEC2011 22.6-0.9 24.4-0.9 25.5-1.1 27.1-1.3 + 04JAN2012 22.7-1.1 24.6-0.8 25.5-1.0 27.2-1.2 + 11JAN2012 23.7-0.5 24.8-0.7 25.6-1.0 27.1-1.2 + 18JAN2012 24.0-0.6 24.9-0.8 25.4-1.2 27.1-1.2 + 25JAN2012 24.6-0.4 25.2-0.7 25.5-1.2 26.9-1.3 + 01FEB2012 24.6-0.8 25.2-0.8 25.5-1.2 27.0-1.2 + 08FEB2012 25.2-0.5 25.6-0.6 25.7-1.0 27.1-1.0 + 15FEB2012 26.9 0.8 26.3-0.1 26.1-0.7 27.1-1.0 + 22FEB2012 26.9 0.8 26.8 0.2 26.5-0.4 27.4-0.7 + 29FEB2012 27.3 1.0 27.1 0.4 26.4-0.6 27.2-0.9 + 07MAR2012 26.6 0.2 26.7-0.2 26.4-0.7 27.3-0.9 + 14MAR2012 26.6 0.2 26.6-0.4 26.6-0.6 27.5-0.7 + 21MAR2012 26.7 0.4 27.0-0.2 26.7-0.6 27.8-0.5 + 28MAR2012 26.9 0.8 27.5 0.3 27.1-0.3 27.7-0.6 + 04APR2012 26.2 0.3 27.6 0.3 27.2-0.3 27.9-0.5 + 11APR2012 27.4 1.8 27.8 0.4 27.3-0.4 28.1-0.3 + 18APR2012 26.8 1.4 27.5 0.0 27.3-0.5 28.1-0.4 + 25APR2012 26.6 1.5 27.5 0.1 27.6-0.2 28.4-0.2 + 02MAY2012 26.3 1.6 27.4 0.1 27.7-0.1 28.4-0.2 + 09MAY2012 25.7 1.2 27.3 0.1 27.8 0.0 28.4-0.3 + 16MAY2012 25.2 1.0 27.2 0.1 27.8 0.0 28.5-0.3 + 23MAY2012 24.8 0.9 27.1 0.2 27.8 0.0 28.6-0.2 + 30MAY2012 24.5 0.9 27.2 0.4 27.9 0.2 28.7-0.1 + 06JUN2012 24.7 1.5 27.1 0.4 27.8 0.1 28.6-0.2 + 13JUN2012 24.4 1.5 27.1 0.6 27.9 0.3 28.6-0.2 + 20JUN2012 24.3 1.7 27.1 0.8 28.0 0.4 28.8 0.0 + 27JUN2012 23.8 1.5 27.1 0.9 28.1 0.6 28.9 0.0 + 04JUL2012 23.2 1.1 26.8 0.8 27.9 0.5 28.8 0.0 + 11JUL2012 22.6 0.8 26.6 0.8 27.7 0.4 28.8 0.0 + 18JUL2012 22.6 1.1 26.5 0.9 27.7 0.5 28.8 0.0 + 25JUL2012 22.0 0.7 26.4 1.0 27.7 0.6 28.9 0.1 + 01AUG2012 21.6 0.5 26.1 0.9 27.6 0.6 29.0 0.3 + 08AUG2012 20.9 0.0 25.9 0.8 27.7 0.8 29.1 0.4 + 15AUG2012 20.8 0.1 25.6 0.6 27.4 0.6 29.1 0.4 + 22AUG2012 21.0 0.4 25.5 0.5 27.4 0.6 29.1 0.4 + 29AUG2012 20.3-0.2 25.6 0.7 27.7 0.9 29.1 0.5 + 05SEP2012 20.7 0.3 25.5 0.6 27.5 0.8 29.2 0.5 + 12SEP2012 20.9 0.5 25.3 0.4 27.3 0.5 29.1 0.4 + 19SEP2012 21.0 0.5 25.2 0.3 27.0 0.3 29.0 0.4 + 26SEP2012 21.0 0.5 25.1 0.2 26.9 0.2 29.1 0.4 + 03OCT2012 20.5-0.1 24.8-0.1 26.8 0.1 29.0 0.3 + 10OCT2012 20.2-0.6 24.7-0.2 26.8 0.1 29.1 0.4 + 17OCT2012 20.5-0.4 25.0 0.1 27.0 0.3 29.1 0.5 + 24OCT2012 21.0 0.0 25.0 0.1 27.2 0.5 29.3 0.7 + 31OCT2012 21.5 0.3 25.2 0.2 27.1 0.4 29.2 0.6 + 07NOV2012 21.5 0.2 25.1 0.1 27.0 0.4 29.2 0.6 + 14NOV2012 21.0-0.5 25.2 0.2 27.2 0.5 29.3 0.7 + 21NOV2012 21.1-0.7 25.1 0.1 26.9 0.3 29.1 0.5 + 28NOV2012 20.7-1.4 24.9-0.1 26.8 0.2 28.9 0.4 + 05DEC2012 21.5-0.9 24.9-0.2 26.5-0.1 28.6 0.1 + 12DEC2012 21.8-0.8 24.8-0.3 26.5-0.1 28.8 0.4 + 19DEC2012 22.4-0.6 24.9-0.3 26.4-0.2 28.6 0.2 + 26DEC2012 22.7-0.6 25.0-0.3 26.4-0.1 28.6 0.2 + 02JAN2013 23.3-0.4 25.0-0.4 26.3-0.3 28.4 0.1 + 09JAN2013 23.7-0.4 24.8-0.7 26.0-0.6 28.3 0.0 + 16JAN2013 24.1-0.4 25.0-0.6 26.0-0.6 28.1-0.2 + 23JAN2013 24.2-0.6 25.3-0.5 26.4-0.2 28.2 0.0 + 30JAN2013 24.8-0.5 25.1-0.9 26.1-0.5 28.1 0.0 + 06FEB2013 25.4-0.2 25.5-0.7 26.2-0.5 28.1-0.1 + 13FEB2013 25.9-0.1 25.9-0.4 26.4-0.3 28.1 0.0 + 20FEB2013 25.6-0.6 26.2-0.3 26.3-0.5 27.9-0.1 + 27FEB2013 25.8-0.4 26.5-0.2 26.6-0.3 27.9-0.2 + 06MAR2013 26.7 0.4 27.0 0.1 26.9-0.1 27.9-0.2 + 13MAR2013 27.0 0.5 27.1 0.0 26.8-0.3 27.7-0.4 + 20MAR2013 26.6 0.2 27.6 0.4 27.1-0.1 28.0-0.2 + 27MAR2013 25.6-0.5 27.6 0.3 27.3-0.1 28.1-0.2 + 03APR2013 25.0-0.9 27.3 0.0 27.6 0.1 28.3 0.0 + 10APR2013 24.8-0.9 27.5 0.0 27.7 0.0 28.5 0.1 + 17APR2013 24.6-0.8 27.5 0.0 27.7-0.1 28.5 0.0 + 24APR2013 24.5-0.6 27.3-0.1 27.7-0.1 28.4-0.1 + 01MAY2013 23.6-1.2 26.9-0.4 27.8 0.0 28.7 0.0 + 08MAY2013 22.9-1.6 26.7-0.5 27.7-0.1 28.7 0.0 + 15MAY2013 23.2-1.1 26.5-0.6 27.5-0.4 28.6-0.2 + 22MAY2013 22.3-1.6 25.9-1.0 27.4-0.4 28.7-0.1 + 29MAY2013 21.5-2.1 25.9-0.9 27.5-0.2 28.8 0.0 + 05JUN2013 22.0-1.3 25.9-0.8 27.5-0.2 28.8 0.0 + 12JUN2013 21.9-1.1 25.9-0.6 27.5-0.2 28.8-0.1 + 19JUN2013 21.1-1.6 25.7-0.7 27.3-0.3 28.6-0.2 + 26JUN2013 20.5-1.9 25.6-0.6 27.4-0.1 28.8 0.0 + 03JUL2013 20.6-1.5 25.4-0.5 27.2-0.2 28.8 0.0 + 10JUL2013 20.5-1.3 25.0-0.8 26.9-0.4 28.8 0.0 + 17JUL2013 20.1-1.5 24.8-0.8 26.8-0.4 28.7-0.1 + 24JUL2013 20.3-1.1 24.9-0.6 26.8-0.3 28.7-0.1 + 31JUL2013 19.8-1.3 24.6-0.8 26.8-0.2 28.7 0.0 + 07AUG2013 19.8-1.1 24.5-0.7 26.7-0.3 28.6-0.1 + 14AUG2013 19.6-1.1 24.4-0.7 26.4-0.4 28.7 0.0 + 21AUG2013 19.9-0.8 24.4-0.6 26.4-0.4 28.7 0.0 + 28AUG2013 19.4-1.1 24.5-0.5 26.7-0.1 28.8 0.2 + 04SEP2013 19.6-0.9 24.6-0.3 26.8 0.0 28.8 0.1 + 11SEP2013 20.0-0.4 24.7-0.2 26.8 0.0 28.7 0.0 + 18SEP2013 19.9-0.5 24.9 0.1 26.7-0.1 28.6-0.1 + 25SEP2013 20.1-0.4 24.7-0.2 26.5-0.2 28.5-0.1 + 02OCT2013 19.7-0.9 24.6-0.2 26.4-0.3 28.7 0.0 + 09OCT2013 20.1-0.7 24.6-0.3 26.3-0.3 28.6 0.0 + 16OCT2013 20.3-0.5 24.8-0.1 26.3-0.4 28.6-0.1 + 23OCT2013 20.5-0.4 24.7-0.2 26.3-0.4 28.7 0.1 + 30OCT2013 20.5-0.7 24.8-0.1 26.5-0.2 28.8 0.2 + 06NOV2013 21.0-0.4 24.8-0.1 26.6 0.0 28.9 0.3 + 13NOV2013 21.1-0.4 24.7-0.2 26.6 0.0 28.9 0.3 + 20NOV2013 21.3-0.5 24.8-0.2 26.7 0.1 28.9 0.3 + 27NOV2013 21.7-0.4 24.9-0.1 26.7 0.1 28.8 0.2 + 04DEC2013 22.0-0.3 24.9-0.2 26.8 0.2 28.8 0.3 + 11DEC2013 22.4-0.2 25.1 0.0 26.6 0.0 28.7 0.2 + 18DEC2013 22.4-0.5 25.2 0.0 26.5-0.1 28.6 0.1 + 25DEC2013 22.8-0.4 25.2-0.1 26.4-0.2 28.5 0.1 + 01JAN2014 23.7 0.0 25.2-0.2 26.3-0.3 28.2-0.2 + 08JAN2014 24.2 0.1 25.1-0.5 26.0-0.5 28.2-0.2 + 15JAN2014 25.0 0.6 25.2-0.4 25.9-0.7 28.0-0.3 + 22JAN2014 25.4 0.6 25.6-0.2 26.2-0.4 28.1-0.1 + 29JAN2014 25.4 0.2 25.3-0.7 25.9-0.7 27.9-0.2 + 05FEB2014 25.1-0.4 25.3-0.8 25.9-0.7 28.1 0.0 + 12FEB2014 25.4-0.6 25.4-0.9 26.2-0.5 28.5 0.4 + 19FEB2014 25.1-1.1 25.7-0.7 26.4-0.4 28.5 0.4 + 26FEB2014 25.5-0.7 26.0-0.6 26.3-0.6 28.2 0.1 + 05MAR2014 26.1-0.3 26.4-0.5 26.6-0.4 28.5 0.3 + 12MAR2014 25.8-0.6 26.8-0.3 26.8-0.4 28.7 0.6 + 19MAR2014 25.2-1.2 27.3 0.1 27.4 0.1 28.8 0.6 + 26MAR2014 25.4-0.7 27.6 0.4 27.6 0.2 29.0 0.7 + 02APR2014 25.2-0.7 27.8 0.5 27.8 0.3 29.0 0.7 + 09APR2014 24.9-0.8 27.6 0.1 27.9 0.2 29.1 0.7 + 16APR2014 24.8-0.7 27.7 0.2 28.0 0.2 29.1 0.6 + 23APR2014 25.3 0.1 27.8 0.4 28.2 0.4 29.2 0.6 + 30APR2014 25.7 0.8 27.8 0.5 28.2 0.4 29.3 0.7 + 07MAY2014 25.8 1.2 27.8 0.6 28.3 0.5 29.5 0.8 + 14MAY2014 25.5 1.3 27.7 0.6 28.3 0.4 29.5 0.8 + 21MAY2014 25.4 1.5 27.6 0.7 28.3 0.5 29.6 0.8 + 28MAY2014 25.3 1.6 27.6 0.7 28.4 0.6 29.7 0.9 + 04JUN2014 24.8 1.4 27.5 0.8 28.3 0.5 29.6 0.8 + 11JUN2014 24.6 1.6 27.3 0.8 28.1 0.4 29.5 0.6 + 18JUN2014 24.8 2.1 27.4 1.0 28.1 0.5 29.4 0.5 + 25JUN2014 24.0 1.6 27.2 1.0 28.0 0.5 29.3 0.5 + 02JUL2014 23.6 1.4 27.0 1.0 27.8 0.4 29.1 0.3 + 09JUL2014 23.0 1.1 26.5 0.6 27.6 0.3 29.1 0.3 + 16JUL2014 23.1 1.5 26.2 0.6 27.4 0.2 29.1 0.4 + 23JUL2014 22.9 1.6 26.0 0.5 27.1-0.1 28.9 0.2 + 30JUL2014 21.8 0.6 25.5 0.2 26.9-0.1 29.0 0.3 + 06AUG2014 22.2 1.2 25.6 0.4 27.0 0.0 29.2 0.5 + 13AUG2014 21.9 1.2 25.5 0.5 26.9 0.0 29.0 0.4 + 20AUG2014 22.1 1.4 25.5 0.5 27.1 0.3 29.1 0.4 + 27AUG2014 21.3 0.8 25.4 0.4 27.2 0.4 29.2 0.5 + 03SEP2014 21.7 1.2 25.3 0.4 27.1 0.4 29.2 0.5 + 10SEP2014 21.1 0.7 25.3 0.4 27.3 0.5 29.4 0.7 + 17SEP2014 21.0 0.7 25.2 0.4 27.2 0.5 29.4 0.8 + 24SEP2014 21.2 0.8 25.4 0.5 27.1 0.4 29.3 0.6 + 01OCT2014 21.7 1.1 25.4 0.5 27.1 0.3 29.2 0.5 + 08OCT2014 21.3 0.6 25.5 0.6 27.1 0.4 29.1 0.5 + 15OCT2014 21.5 0.7 25.5 0.5 27.2 0.5 29.4 0.7 + 22OCT2014 21.8 0.8 25.8 0.8 27.2 0.5 29.4 0.7 + 29OCT2014 21.8 0.6 25.8 0.9 27.3 0.6 29.4 0.8 + 05NOV2014 21.9 0.5 25.8 0.9 27.4 0.8 29.5 0.9 + 12NOV2014 22.4 0.9 25.8 0.9 27.5 0.8 29.5 0.9 + 19NOV2014 22.6 0.8 26.0 1.0 27.5 0.9 29.5 0.9 + 26NOV2014 22.4 0.4 25.9 0.9 27.6 1.0 29.5 0.9 + 03DEC2014 22.3 0.0 25.8 0.7 27.4 0.8 29.4 0.9 + 10DEC2014 22.8 0.2 26.0 0.9 27.5 0.9 29.4 0.9 + 17DEC2014 22.9 0.1 26.0 0.8 27.4 0.8 29.4 1.0 + 24DEC2014 23.1-0.2 26.0 0.7 27.3 0.7 29.3 0.9 + 31DEC2014 23.6 0.0 25.9 0.6 27.1 0.5 29.2 0.8 + 07JAN2015 23.7-0.2 25.9 0.4 27.0 0.4 29.1 0.7 + 14JAN2015 24.0-0.4 25.9 0.3 27.1 0.5 29.1 0.9 + 21JAN2015 24.3-0.4 26.1 0.3 27.2 0.6 29.2 1.0 + 28JAN2015 24.8-0.3 26.2 0.3 27.2 0.5 29.1 0.9 + 04FEB2015 25.0-0.5 26.2 0.1 27.2 0.5 29.1 0.9 + 11FEB2015 25.1-0.8 26.6 0.3 27.2 0.5 29.0 0.9 + 18FEB2015 26.1-0.1 26.7 0.3 27.3 0.5 29.0 1.0 + 25FEB2015 26.1-0.1 26.8 0.1 27.5 0.6 29.3 1.2 diff --git a/samples/Forth/asm.fr b/samples/Forth/asm.fr new file mode 100644 index 00000000..73faf776 --- /dev/null +++ b/samples/Forth/asm.fr @@ -0,0 +1,244 @@ +\ Copyright 2013-2014 Lars Brinkhoff + +\ Assembler for x86. + +\ Adds to FORTH vocabulary: ASSEMBLER CODE ;CODE. +\ Creates ASSEMBLER vocabulary with: END-CODE and x86 opcodes. + +\ Conventional prefix syntax: " ,". +\ Addressing modes: +\ - immediate: "n #" +\ - direct: n +\ - register: +\ - indirect: " )" +\ - indirect with displacement: "n )#" +\ - indexed: not supported yet + +require lib/common.fth +require search.fth + +vocabulary assembler +also assembler definitions + +\ Access to the target image. +' header, defer header, is header, +' cell defer cell is cell +' dp defer dp is dp +0 value delta + +: aligned cell + 1 - cell negate nand invert ; +: align dp @ aligned dp ! ; +: allot dp +! ; +: here dp @ ; +: cells cell * ; +: c! delta + c! ; +: c, here c! 1 allot ; +: h, dup c, 8 rshift c, ; +: , dup h, 16 rshift h, ; + +base @ hex + +\ This constant signals that an operand is not a direct address. +deadbeef constant -addr + +\ Assembler state. +variable opcode +variable d +variable s +variable dir? +variable mrrm defer ?mrrm, +variable sib defer ?sib, +variable disp defer ?disp, +variable imm defer ?imm, +defer imm, +defer immediate-opcode +defer reg +defer ?opsize + +\ Set opcode. And destination: register or memory. +: opcode! 3@ is immediate-opcode >r opcode ! ; +: !reg dir? @ if 2 d ! then dir? off ; +: !mem dir? off ; + +\ Set bits in mod/reg/rm byte. +: -mrrm ['] nop is ?mrrm, ; +: mod! mrrm c0 !bits ; +: reg@ mrrm 38 @bits ; +: reg! mrrm 38 !bits ; +: rm@ mrrm 7 @bits ; +: rm! rm@ 3 lshift reg! mrrm 7 !bits ; +: reg>opcode rm@ opcode 07 !bits ; +: opcode>reg opcode @ dup 3 rshift rm! 8 rshift opcode ! ; + +\ Write parts of instruction to memory. +: ds d @ s @ + ; +: ?twobyte dup FF > if dup 8 rshift c, then ; +: opcode, opcode @ ?twobyte ds + c, ; +: mrrm, mrrm @ c, ; +: sib, sib @ c, ; +: imm8, imm @ c, ; +: imm16, imm @ h, ; +: imm32, imm @ , ; +: disp8, disp @ c, ; +: disp32, disp @ , ; + +\ Set operand size. +: -opsize 2drop r> drop ; +: opsize! is imm, s ! ['] -opsize is ?opsize ; +: !op8 0 ['] imm8, ?opsize ; +: !op32 1 ['] imm32, ?opsize ; +: !op16 1 ['] imm16, ?opsize 66 c, ; + +\ Set SIB byte. +: !sib ['] sib, is ?sib, ; +: sib! 3 lshift + sib ! !sib ; + +\ Set displacement. +: byte? -80 80 within ; +: disp! is ?disp, disp ! ; +: !disp8 ['] disp8, disp! ; +: !disp32 ['] disp32, disp! ; +: !disp ( a -- u ) dup byte? if !disp8 40 else !disp32 80 then ; +: -pc here 5 + negate ; +: relative -pc disp +! ; + +\ Set immediate operand. +: imm! imm ! ['] imm, is ?imm, ; + +\ Implements addressing modes: register, indirect, indexed, and direct. +: reg1 rm! !reg ; +: reg2 3 lshift reg! ; +: !reg2 ['] reg2 is reg ; +: ind dup mod! rm! !mem !reg2 ; +: ind# swap !disp + ind ; +: idx 04 ind sib! ; +: idx# rot !disp 04 + ind sib! ; +: addr !disp32 05 ind ; + +\ Reset assembler state. +: 0opsize ['] opsize! is ?opsize ; +: 0ds d off s off ; +: 0reg ['] reg1 is reg ; +: 0mrrm c0 mrrm ! ['] mrrm, is ?mrrm, ; +: 0sib ['] nop is ?sib, ; +: 0disp ['] nop is ?disp, ; +: 0imm imm off ['] nop is ?imm, 0 is imm, ; +: 0asm 0imm 0disp 0reg 0ds 0mrrm 0sib 0opsize dir? on ; + +\ Enter and exit assembler mode. +: start-code also assembler 0asm ; +: end-code align previous ; + +\ Implements addressing mode: immediate. +: imm8? imm @ byte? ; +: ?sign-extend d off imm8? if 2 d ! ['] imm8, is ?imm, then ; +: alu# opcode @ reg! 80 opcode ! ?sign-extend ; +: mov# B0 s @ 3 lshift + rm@ + opcode ! 0ds -mrrm ; +: push# imm8? if ['] imm8, 6A else ['] imm32, 68 then dup opcode ! rm! is ?imm, ; +: test# F6 opcode ! ; +: imm-op imm! immediate-opcode ; + +\ Process one operand. All operands except a direct address +\ have the stack picture ( n*x xt -addr ). +: addr? dup -addr <> ; +: op addr? if addr else drop execute then ; + +\ Define instruction formats. +: instruction, opcode! opcode, ?mrrm, ?sib, ?disp, ?imm, 0asm ; +: mnemonic ( u a "name" -- ) create ['] nop 3, does> instruction, ; +: format: create ] !csp does> mnemonic ; +: immediate: ' latestxt >body ! ; + +\ Instruction formats. +format: 0op -mrrm ; +format: 1reg op reg>opcode 0ds -mrrm ; +format: 1op opcode>reg op d off ; +format: 2op op op ; +format: 2op-d op op d off ; +format: 2op-ds op op 0ds ; +format: 1addr op relative -mrrm ; +format: 1imm8 !op8 op -mrrm ; + +\ Instruction mnemonics. +00 2op add, immediate: alu# +08 2op or, immediate: alu# +0F44 2op-ds cmove, \ Todo: other condition codes. +0FB6 2op-ds movzx, +0FBE 2op-ds movsx, +10 2op adc, immediate: alu# +18 2op sbb, immediate: alu# +20 2op and, immediate: alu# +26 0op es, +28 2op sub, immediate: alu# +2E 0op cs, +30 2op xor, immediate: alu# +36 0op ss, +38 2op cmp, immediate: alu# +3E 0op ds, +50 1reg push, immediate: push# +58 1reg pop, +64 0op fs, +65 0op gs, +\ 70 jcc +84 2op-d test, immediate: test# +86 2op-d xchg, +88 2op mov, immediate: mov# +8D 2op-ds lea, +\ 8F/0 pop, rm +90 0op nop, +C3 0op ret, +\ C6/0 immediate mov to r/m +\ C7/0 immediate mov to r/m +CD 1imm8 int, +E8 1addr call, +E9 1addr jmp, +\ EB jmp rel8 +F0 0op lock, +F2 0op rep, +F3 0op repz, +F4 0op hlt, +F5 0op cmc, +F610 1op not, +F618 1op neg, +F8 0op clc, +F9 0op stc, +FA 0op cli, +FB 0op sti, +FC 0op cld, +FD 0op std, +\ FE 0 inc rm +\ FF 1 dec rm +\ FF 2 call rm +\ FF 4 jmp rm +\ FF 6 push rm + +: sp? dup 4 = ; + +\ Addressing mode syntax: immediate, indirect, and displaced indirect. +: # ['] imm-op -addr ; +: ) 2drop sp? if 4 ['] idx else ['] ind then -addr 0reg 0opsize ; +: )# 2drop sp? if 4 ['] idx# else ['] ind# then -addr 0reg 0opsize ; + +\ Define registers. +: reg8 create , does> @ ['] reg -addr !op8 ; +: reg16 create , does> @ ['] reg -addr !op16 ; +: reg32 create , does> @ ['] reg -addr !op32 ; +: reg: dup reg8 dup reg16 dup reg32 1+ ; + +\ Register names. +0 +reg: al ax eax reg: cl cx ecx reg: dl dx edx reg: bl bx ebx +reg: ah sp esp reg: ch bp ebp reg: dh si esi reg: bh di edi +drop + +\ Runtime for ;CODE. CODE! is defined elsewhere. +: (;code) r> code! ; + +base ! only forth definitions also assembler + +\ Standard assembler entry points. +: code parse-name header, ?code, start-code ; +: ;code postpone (;code) reveal postpone [ ?csp start-code ; immediate + +0asm +previous diff --git a/samples/Forth/core.f b/samples/Forth/core.f new file mode 100644 index 00000000..4a13e217 --- /dev/null +++ b/samples/Forth/core.f @@ -0,0 +1,252 @@ +: immediate lastxt @ dup c@ negate swap c! ; + +: \ source nip >in ! ; immediate \ Copyright 2004, 2012 Lars Brinkhoff + +: char \ ( "word" -- char ) + bl-word here 1+ c@ ; + +: ahead here 0 , ; + +: resolve here swap ! ; + +: ' bl-word here find 0branch [ ahead ] exit [ resolve ] 0 ; + +: postpone-nonimmediate [ ' literal , ' compile, ] literal , ; + +: create dovariable_code header, reveal ; + +create postponers + ' postpone-nonimmediate , + ' abort , + ' , , + +: word \ ( char "string" -- caddr ) + drop bl-word here ; + +: postpone \ ( C: "word" -- ) + bl word find 1+ cells postponers + @ execute ; immediate + +: unresolved \ ( C: "word" -- orig ) + postpone postpone postpone ahead ; immediate + +: chars \ ( n1 -- n2 ) + ; + +: else \ ( -- ) ( C: orig1 -- orig2 ) + unresolved branch swap resolve ; immediate + +: if \ ( flag -- ) ( C: -- orig ) + unresolved 0branch ; immediate + +: then \ ( -- ) ( C: orig -- ) + resolve ; immediate + +: [char] \ ( "word" -- ) + char postpone literal ; immediate + +: (does>) lastxt @ dodoes_code over >code ! r> swap >does ! ; + +: does> postpone (does>) ; immediate + +: begin \ ( -- ) ( C: -- dest ) + here ; immediate + +: while \ ( x -- ) ( C: dest -- orig dest ) + unresolved 0branch swap ; immediate + +: repeat \ ( -- ) ( C: orig dest -- ) + postpone branch , resolve ; immediate + +: until \ ( x -- ) ( C: dest -- ) + postpone 0branch , ; immediate + +: recurse lastxt @ compile, ; immediate + +: pad \ ( -- addr ) + here 1024 + ; + +: parse \ ( char "string" -- addr n ) + pad >r begin + source? if else 0 0 then + while + r@ c! r> 1+ >r + repeat 2drop pad r> over - ; + +: ( \ ( "string" -- ) + [ char ) ] literal parse 2drop ; immediate + \ TODO: If necessary, refill and keep parsing. + +: string, ( addr n -- ) + here over allot align swap cmove ; + +: (s") ( -- addr n ) ( R: ret1 -- ret2 ) + r> dup @ swap cell+ 2dup + aligned >r swap ; + +create squote 128 allot + +: s" ( "string" -- addr n ) + state @ if + postpone (s") [char] " parse dup , string, + else + [char] " parse >r squote r@ cmove squote r> + then ; immediate + +: (abort") ( ... addr n -- ) ( R: ... -- ) + cr type cr abort ; + +: abort" ( ... x "string" -- ) ( R: ... -- ) + postpone if postpone s" postpone (abort") postpone then ; immediate + +\ ---------------------------------------------------------------------- + +( Core words. ) + +\ TODO: # +\ TODO: #> +\ TODO: #s + +: and ( x y -- x&y ) nand invert ; + +: * 1 2>r 0 swap begin r@ while + r> r> swap 2dup dup + 2>r and if swap over + swap then dup + + repeat r> r> 2drop drop ; + +\ TODO: */mod + +: +loop ( -- ) ( C: nest-sys -- ) + postpone (+loop) postpone 0branch , postpone unloop ; immediate + +: space bl emit ; + +: ?.- dup 0 < if [char] - emit negate then ; + +: digit [char] 0 + emit ; + +: (.) base @ /mod ?dup if recurse then digit ; + +: ." ( "string" -- ) postpone s" postpone type ; immediate + +: . ( x -- ) ?.- (.) space ; + +: postpone-number ( caddr -- ) + 0 0 rot count >number dup 0= if + 2drop nip + postpone (literal) postpone (literal) postpone , + postpone literal postpone , + else + ." Undefined: " type cr abort + then ; + +' postpone-number postponers cell+ ! + +: / ( x y -- x/y ) /mod nip ; + +: 0< ( n -- flag ) 0 < ; + +: 1- ( n -- n-1 ) -1 + ; + +: 2! ( x1 x2 addr -- ) swap over ! cell+ ! ; + +: 2* ( n -- 2n ) dup + ; + +\ Kernel: 2/ + +: 2@ ( addr -- x1 x2 ) dup cell+ @ swap @ ; + +\ Kernel: 2drop +\ Kernel: 2dup + +\ TODO: 2over ( x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2 ) +\ 3 pick 3 pick ; + +\ TODO: 2swap + +\ TODO: <# + +: abs ( n -- |n| ) + dup 0< if negate then ; + +\ TODO: accept + +: c, ( n -- ) + here c! 1 chars allot ; + +: char+ ( n1 -- n2 ) + 1+ ; + +: constant create , does> @ ; + +: decimal ( -- ) + 10 base ! ; + +: depth ( -- n ) + data_stack 100 cells + 'SP @ - /cell / 2 - ; + +: do ( n1 n2 -- ) ( R: -- loop-sys ) ( C: -- do-sys ) + postpone 2>r here ; immediate + +\ TODO: environment? +\ TODO: evaluate +\ TODO: fill +\ TODO: fm/mod ) +\ TODO: hold + +: j ( -- x1 ) ( R: x1 x2 x3 -- x1 x2 x3 ) + 'RP @ 3 cells + @ ; + +\ TODO: leave + +: loop ( -- ) ( C: nest-sys -- ) + postpone 1 postpone (+loop) + postpone 0branch , + postpone unloop ; immediate + +: lshift begin ?dup while 1- swap dup + swap repeat ; + +: rshift 1 begin over while dup + swap 1- swap repeat nip + 2>r 0 1 begin r@ while + r> r> 2dup swap dup + 2>r and if swap over + swap then dup + + repeat r> r> 2drop drop ; + +: max ( x y -- max[x,y] ) + 2dup > if drop else nip then ; + +\ Kernel: min +\ TODO: mod +\ TODO: move + +: (quit) ( R: ... -- ) + return_stack 100 cells + 'RP ! + 0 'source-id ! tib ''source ! #tib ''#source ! + postpone [ + begin + refill + while + interpret state @ 0= if ." ok" cr then + repeat + bye ; + +' (quit) ' quit >body cell+ ! + +\ TODO: s>d +\ TODO: sign +\ TODO: sm/rem + +: spaces ( n -- ) + 0 do space loop ; + +\ TODO: u. + +: signbit ( -- n ) -1 1 rshift invert ; + +: xor ( x y -- x^y ) 2dup nand >r r@ nand swap r> nand nand ; + +: u< ( x y -- flag ) signbit xor swap signbit xor > ; + +\ TODO: um/mod + +: variable ( "word" -- ) + create /cell allot ; + +: ['] \ ( C: "word" -- ) + ' postpone literal ; immediate diff --git a/samples/Forth/core.for b/samples/Forth/core.for new file mode 100644 index 00000000..4a13e217 --- /dev/null +++ b/samples/Forth/core.for @@ -0,0 +1,252 @@ +: immediate lastxt @ dup c@ negate swap c! ; + +: \ source nip >in ! ; immediate \ Copyright 2004, 2012 Lars Brinkhoff + +: char \ ( "word" -- char ) + bl-word here 1+ c@ ; + +: ahead here 0 , ; + +: resolve here swap ! ; + +: ' bl-word here find 0branch [ ahead ] exit [ resolve ] 0 ; + +: postpone-nonimmediate [ ' literal , ' compile, ] literal , ; + +: create dovariable_code header, reveal ; + +create postponers + ' postpone-nonimmediate , + ' abort , + ' , , + +: word \ ( char "string" -- caddr ) + drop bl-word here ; + +: postpone \ ( C: "word" -- ) + bl word find 1+ cells postponers + @ execute ; immediate + +: unresolved \ ( C: "word" -- orig ) + postpone postpone postpone ahead ; immediate + +: chars \ ( n1 -- n2 ) + ; + +: else \ ( -- ) ( C: orig1 -- orig2 ) + unresolved branch swap resolve ; immediate + +: if \ ( flag -- ) ( C: -- orig ) + unresolved 0branch ; immediate + +: then \ ( -- ) ( C: orig -- ) + resolve ; immediate + +: [char] \ ( "word" -- ) + char postpone literal ; immediate + +: (does>) lastxt @ dodoes_code over >code ! r> swap >does ! ; + +: does> postpone (does>) ; immediate + +: begin \ ( -- ) ( C: -- dest ) + here ; immediate + +: while \ ( x -- ) ( C: dest -- orig dest ) + unresolved 0branch swap ; immediate + +: repeat \ ( -- ) ( C: orig dest -- ) + postpone branch , resolve ; immediate + +: until \ ( x -- ) ( C: dest -- ) + postpone 0branch , ; immediate + +: recurse lastxt @ compile, ; immediate + +: pad \ ( -- addr ) + here 1024 + ; + +: parse \ ( char "string" -- addr n ) + pad >r begin + source? if else 0 0 then + while + r@ c! r> 1+ >r + repeat 2drop pad r> over - ; + +: ( \ ( "string" -- ) + [ char ) ] literal parse 2drop ; immediate + \ TODO: If necessary, refill and keep parsing. + +: string, ( addr n -- ) + here over allot align swap cmove ; + +: (s") ( -- addr n ) ( R: ret1 -- ret2 ) + r> dup @ swap cell+ 2dup + aligned >r swap ; + +create squote 128 allot + +: s" ( "string" -- addr n ) + state @ if + postpone (s") [char] " parse dup , string, + else + [char] " parse >r squote r@ cmove squote r> + then ; immediate + +: (abort") ( ... addr n -- ) ( R: ... -- ) + cr type cr abort ; + +: abort" ( ... x "string" -- ) ( R: ... -- ) + postpone if postpone s" postpone (abort") postpone then ; immediate + +\ ---------------------------------------------------------------------- + +( Core words. ) + +\ TODO: # +\ TODO: #> +\ TODO: #s + +: and ( x y -- x&y ) nand invert ; + +: * 1 2>r 0 swap begin r@ while + r> r> swap 2dup dup + 2>r and if swap over + swap then dup + + repeat r> r> 2drop drop ; + +\ TODO: */mod + +: +loop ( -- ) ( C: nest-sys -- ) + postpone (+loop) postpone 0branch , postpone unloop ; immediate + +: space bl emit ; + +: ?.- dup 0 < if [char] - emit negate then ; + +: digit [char] 0 + emit ; + +: (.) base @ /mod ?dup if recurse then digit ; + +: ." ( "string" -- ) postpone s" postpone type ; immediate + +: . ( x -- ) ?.- (.) space ; + +: postpone-number ( caddr -- ) + 0 0 rot count >number dup 0= if + 2drop nip + postpone (literal) postpone (literal) postpone , + postpone literal postpone , + else + ." Undefined: " type cr abort + then ; + +' postpone-number postponers cell+ ! + +: / ( x y -- x/y ) /mod nip ; + +: 0< ( n -- flag ) 0 < ; + +: 1- ( n -- n-1 ) -1 + ; + +: 2! ( x1 x2 addr -- ) swap over ! cell+ ! ; + +: 2* ( n -- 2n ) dup + ; + +\ Kernel: 2/ + +: 2@ ( addr -- x1 x2 ) dup cell+ @ swap @ ; + +\ Kernel: 2drop +\ Kernel: 2dup + +\ TODO: 2over ( x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2 ) +\ 3 pick 3 pick ; + +\ TODO: 2swap + +\ TODO: <# + +: abs ( n -- |n| ) + dup 0< if negate then ; + +\ TODO: accept + +: c, ( n -- ) + here c! 1 chars allot ; + +: char+ ( n1 -- n2 ) + 1+ ; + +: constant create , does> @ ; + +: decimal ( -- ) + 10 base ! ; + +: depth ( -- n ) + data_stack 100 cells + 'SP @ - /cell / 2 - ; + +: do ( n1 n2 -- ) ( R: -- loop-sys ) ( C: -- do-sys ) + postpone 2>r here ; immediate + +\ TODO: environment? +\ TODO: evaluate +\ TODO: fill +\ TODO: fm/mod ) +\ TODO: hold + +: j ( -- x1 ) ( R: x1 x2 x3 -- x1 x2 x3 ) + 'RP @ 3 cells + @ ; + +\ TODO: leave + +: loop ( -- ) ( C: nest-sys -- ) + postpone 1 postpone (+loop) + postpone 0branch , + postpone unloop ; immediate + +: lshift begin ?dup while 1- swap dup + swap repeat ; + +: rshift 1 begin over while dup + swap 1- swap repeat nip + 2>r 0 1 begin r@ while + r> r> 2dup swap dup + 2>r and if swap over + swap then dup + + repeat r> r> 2drop drop ; + +: max ( x y -- max[x,y] ) + 2dup > if drop else nip then ; + +\ Kernel: min +\ TODO: mod +\ TODO: move + +: (quit) ( R: ... -- ) + return_stack 100 cells + 'RP ! + 0 'source-id ! tib ''source ! #tib ''#source ! + postpone [ + begin + refill + while + interpret state @ 0= if ." ok" cr then + repeat + bye ; + +' (quit) ' quit >body cell+ ! + +\ TODO: s>d +\ TODO: sign +\ TODO: sm/rem + +: spaces ( n -- ) + 0 do space loop ; + +\ TODO: u. + +: signbit ( -- n ) -1 1 rshift invert ; + +: xor ( x y -- x^y ) 2dup nand >r r@ nand swap r> nand nand ; + +: u< ( x y -- flag ) signbit xor swap signbit xor > ; + +\ TODO: um/mod + +: variable ( "word" -- ) + create /cell allot ; + +: ['] \ ( C: "word" -- ) + ' postpone literal ; immediate diff --git a/samples/Forth/core.fs b/samples/Forth/core.fs new file mode 100644 index 00000000..4a13e217 --- /dev/null +++ b/samples/Forth/core.fs @@ -0,0 +1,252 @@ +: immediate lastxt @ dup c@ negate swap c! ; + +: \ source nip >in ! ; immediate \ Copyright 2004, 2012 Lars Brinkhoff + +: char \ ( "word" -- char ) + bl-word here 1+ c@ ; + +: ahead here 0 , ; + +: resolve here swap ! ; + +: ' bl-word here find 0branch [ ahead ] exit [ resolve ] 0 ; + +: postpone-nonimmediate [ ' literal , ' compile, ] literal , ; + +: create dovariable_code header, reveal ; + +create postponers + ' postpone-nonimmediate , + ' abort , + ' , , + +: word \ ( char "string" -- caddr ) + drop bl-word here ; + +: postpone \ ( C: "word" -- ) + bl word find 1+ cells postponers + @ execute ; immediate + +: unresolved \ ( C: "word" -- orig ) + postpone postpone postpone ahead ; immediate + +: chars \ ( n1 -- n2 ) + ; + +: else \ ( -- ) ( C: orig1 -- orig2 ) + unresolved branch swap resolve ; immediate + +: if \ ( flag -- ) ( C: -- orig ) + unresolved 0branch ; immediate + +: then \ ( -- ) ( C: orig -- ) + resolve ; immediate + +: [char] \ ( "word" -- ) + char postpone literal ; immediate + +: (does>) lastxt @ dodoes_code over >code ! r> swap >does ! ; + +: does> postpone (does>) ; immediate + +: begin \ ( -- ) ( C: -- dest ) + here ; immediate + +: while \ ( x -- ) ( C: dest -- orig dest ) + unresolved 0branch swap ; immediate + +: repeat \ ( -- ) ( C: orig dest -- ) + postpone branch , resolve ; immediate + +: until \ ( x -- ) ( C: dest -- ) + postpone 0branch , ; immediate + +: recurse lastxt @ compile, ; immediate + +: pad \ ( -- addr ) + here 1024 + ; + +: parse \ ( char "string" -- addr n ) + pad >r begin + source? if else 0 0 then + while + r@ c! r> 1+ >r + repeat 2drop pad r> over - ; + +: ( \ ( "string" -- ) + [ char ) ] literal parse 2drop ; immediate + \ TODO: If necessary, refill and keep parsing. + +: string, ( addr n -- ) + here over allot align swap cmove ; + +: (s") ( -- addr n ) ( R: ret1 -- ret2 ) + r> dup @ swap cell+ 2dup + aligned >r swap ; + +create squote 128 allot + +: s" ( "string" -- addr n ) + state @ if + postpone (s") [char] " parse dup , string, + else + [char] " parse >r squote r@ cmove squote r> + then ; immediate + +: (abort") ( ... addr n -- ) ( R: ... -- ) + cr type cr abort ; + +: abort" ( ... x "string" -- ) ( R: ... -- ) + postpone if postpone s" postpone (abort") postpone then ; immediate + +\ ---------------------------------------------------------------------- + +( Core words. ) + +\ TODO: # +\ TODO: #> +\ TODO: #s + +: and ( x y -- x&y ) nand invert ; + +: * 1 2>r 0 swap begin r@ while + r> r> swap 2dup dup + 2>r and if swap over + swap then dup + + repeat r> r> 2drop drop ; + +\ TODO: */mod + +: +loop ( -- ) ( C: nest-sys -- ) + postpone (+loop) postpone 0branch , postpone unloop ; immediate + +: space bl emit ; + +: ?.- dup 0 < if [char] - emit negate then ; + +: digit [char] 0 + emit ; + +: (.) base @ /mod ?dup if recurse then digit ; + +: ." ( "string" -- ) postpone s" postpone type ; immediate + +: . ( x -- ) ?.- (.) space ; + +: postpone-number ( caddr -- ) + 0 0 rot count >number dup 0= if + 2drop nip + postpone (literal) postpone (literal) postpone , + postpone literal postpone , + else + ." Undefined: " type cr abort + then ; + +' postpone-number postponers cell+ ! + +: / ( x y -- x/y ) /mod nip ; + +: 0< ( n -- flag ) 0 < ; + +: 1- ( n -- n-1 ) -1 + ; + +: 2! ( x1 x2 addr -- ) swap over ! cell+ ! ; + +: 2* ( n -- 2n ) dup + ; + +\ Kernel: 2/ + +: 2@ ( addr -- x1 x2 ) dup cell+ @ swap @ ; + +\ Kernel: 2drop +\ Kernel: 2dup + +\ TODO: 2over ( x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2 ) +\ 3 pick 3 pick ; + +\ TODO: 2swap + +\ TODO: <# + +: abs ( n -- |n| ) + dup 0< if negate then ; + +\ TODO: accept + +: c, ( n -- ) + here c! 1 chars allot ; + +: char+ ( n1 -- n2 ) + 1+ ; + +: constant create , does> @ ; + +: decimal ( -- ) + 10 base ! ; + +: depth ( -- n ) + data_stack 100 cells + 'SP @ - /cell / 2 - ; + +: do ( n1 n2 -- ) ( R: -- loop-sys ) ( C: -- do-sys ) + postpone 2>r here ; immediate + +\ TODO: environment? +\ TODO: evaluate +\ TODO: fill +\ TODO: fm/mod ) +\ TODO: hold + +: j ( -- x1 ) ( R: x1 x2 x3 -- x1 x2 x3 ) + 'RP @ 3 cells + @ ; + +\ TODO: leave + +: loop ( -- ) ( C: nest-sys -- ) + postpone 1 postpone (+loop) + postpone 0branch , + postpone unloop ; immediate + +: lshift begin ?dup while 1- swap dup + swap repeat ; + +: rshift 1 begin over while dup + swap 1- swap repeat nip + 2>r 0 1 begin r@ while + r> r> 2dup swap dup + 2>r and if swap over + swap then dup + + repeat r> r> 2drop drop ; + +: max ( x y -- max[x,y] ) + 2dup > if drop else nip then ; + +\ Kernel: min +\ TODO: mod +\ TODO: move + +: (quit) ( R: ... -- ) + return_stack 100 cells + 'RP ! + 0 'source-id ! tib ''source ! #tib ''#source ! + postpone [ + begin + refill + while + interpret state @ 0= if ." ok" cr then + repeat + bye ; + +' (quit) ' quit >body cell+ ! + +\ TODO: s>d +\ TODO: sign +\ TODO: sm/rem + +: spaces ( n -- ) + 0 do space loop ; + +\ TODO: u. + +: signbit ( -- n ) -1 1 rshift invert ; + +: xor ( x y -- x^y ) 2dup nand >r r@ nand swap r> nand nand ; + +: u< ( x y -- flag ) signbit xor swap signbit xor > ; + +\ TODO: um/mod + +: variable ( "word" -- ) + create /cell allot ; + +: ['] \ ( C: "word" -- ) + ' postpone literal ; immediate diff --git a/samples/Forth/core1.F b/samples/Forth/core1.F new file mode 100644 index 00000000..4a13e217 --- /dev/null +++ b/samples/Forth/core1.F @@ -0,0 +1,252 @@ +: immediate lastxt @ dup c@ negate swap c! ; + +: \ source nip >in ! ; immediate \ Copyright 2004, 2012 Lars Brinkhoff + +: char \ ( "word" -- char ) + bl-word here 1+ c@ ; + +: ahead here 0 , ; + +: resolve here swap ! ; + +: ' bl-word here find 0branch [ ahead ] exit [ resolve ] 0 ; + +: postpone-nonimmediate [ ' literal , ' compile, ] literal , ; + +: create dovariable_code header, reveal ; + +create postponers + ' postpone-nonimmediate , + ' abort , + ' , , + +: word \ ( char "string" -- caddr ) + drop bl-word here ; + +: postpone \ ( C: "word" -- ) + bl word find 1+ cells postponers + @ execute ; immediate + +: unresolved \ ( C: "word" -- orig ) + postpone postpone postpone ahead ; immediate + +: chars \ ( n1 -- n2 ) + ; + +: else \ ( -- ) ( C: orig1 -- orig2 ) + unresolved branch swap resolve ; immediate + +: if \ ( flag -- ) ( C: -- orig ) + unresolved 0branch ; immediate + +: then \ ( -- ) ( C: orig -- ) + resolve ; immediate + +: [char] \ ( "word" -- ) + char postpone literal ; immediate + +: (does>) lastxt @ dodoes_code over >code ! r> swap >does ! ; + +: does> postpone (does>) ; immediate + +: begin \ ( -- ) ( C: -- dest ) + here ; immediate + +: while \ ( x -- ) ( C: dest -- orig dest ) + unresolved 0branch swap ; immediate + +: repeat \ ( -- ) ( C: orig dest -- ) + postpone branch , resolve ; immediate + +: until \ ( x -- ) ( C: dest -- ) + postpone 0branch , ; immediate + +: recurse lastxt @ compile, ; immediate + +: pad \ ( -- addr ) + here 1024 + ; + +: parse \ ( char "string" -- addr n ) + pad >r begin + source? if else 0 0 then + while + r@ c! r> 1+ >r + repeat 2drop pad r> over - ; + +: ( \ ( "string" -- ) + [ char ) ] literal parse 2drop ; immediate + \ TODO: If necessary, refill and keep parsing. + +: string, ( addr n -- ) + here over allot align swap cmove ; + +: (s") ( -- addr n ) ( R: ret1 -- ret2 ) + r> dup @ swap cell+ 2dup + aligned >r swap ; + +create squote 128 allot + +: s" ( "string" -- addr n ) + state @ if + postpone (s") [char] " parse dup , string, + else + [char] " parse >r squote r@ cmove squote r> + then ; immediate + +: (abort") ( ... addr n -- ) ( R: ... -- ) + cr type cr abort ; + +: abort" ( ... x "string" -- ) ( R: ... -- ) + postpone if postpone s" postpone (abort") postpone then ; immediate + +\ ---------------------------------------------------------------------- + +( Core words. ) + +\ TODO: # +\ TODO: #> +\ TODO: #s + +: and ( x y -- x&y ) nand invert ; + +: * 1 2>r 0 swap begin r@ while + r> r> swap 2dup dup + 2>r and if swap over + swap then dup + + repeat r> r> 2drop drop ; + +\ TODO: */mod + +: +loop ( -- ) ( C: nest-sys -- ) + postpone (+loop) postpone 0branch , postpone unloop ; immediate + +: space bl emit ; + +: ?.- dup 0 < if [char] - emit negate then ; + +: digit [char] 0 + emit ; + +: (.) base @ /mod ?dup if recurse then digit ; + +: ." ( "string" -- ) postpone s" postpone type ; immediate + +: . ( x -- ) ?.- (.) space ; + +: postpone-number ( caddr -- ) + 0 0 rot count >number dup 0= if + 2drop nip + postpone (literal) postpone (literal) postpone , + postpone literal postpone , + else + ." Undefined: " type cr abort + then ; + +' postpone-number postponers cell+ ! + +: / ( x y -- x/y ) /mod nip ; + +: 0< ( n -- flag ) 0 < ; + +: 1- ( n -- n-1 ) -1 + ; + +: 2! ( x1 x2 addr -- ) swap over ! cell+ ! ; + +: 2* ( n -- 2n ) dup + ; + +\ Kernel: 2/ + +: 2@ ( addr -- x1 x2 ) dup cell+ @ swap @ ; + +\ Kernel: 2drop +\ Kernel: 2dup + +\ TODO: 2over ( x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2 ) +\ 3 pick 3 pick ; + +\ TODO: 2swap + +\ TODO: <# + +: abs ( n -- |n| ) + dup 0< if negate then ; + +\ TODO: accept + +: c, ( n -- ) + here c! 1 chars allot ; + +: char+ ( n1 -- n2 ) + 1+ ; + +: constant create , does> @ ; + +: decimal ( -- ) + 10 base ! ; + +: depth ( -- n ) + data_stack 100 cells + 'SP @ - /cell / 2 - ; + +: do ( n1 n2 -- ) ( R: -- loop-sys ) ( C: -- do-sys ) + postpone 2>r here ; immediate + +\ TODO: environment? +\ TODO: evaluate +\ TODO: fill +\ TODO: fm/mod ) +\ TODO: hold + +: j ( -- x1 ) ( R: x1 x2 x3 -- x1 x2 x3 ) + 'RP @ 3 cells + @ ; + +\ TODO: leave + +: loop ( -- ) ( C: nest-sys -- ) + postpone 1 postpone (+loop) + postpone 0branch , + postpone unloop ; immediate + +: lshift begin ?dup while 1- swap dup + swap repeat ; + +: rshift 1 begin over while dup + swap 1- swap repeat nip + 2>r 0 1 begin r@ while + r> r> 2dup swap dup + 2>r and if swap over + swap then dup + + repeat r> r> 2drop drop ; + +: max ( x y -- max[x,y] ) + 2dup > if drop else nip then ; + +\ Kernel: min +\ TODO: mod +\ TODO: move + +: (quit) ( R: ... -- ) + return_stack 100 cells + 'RP ! + 0 'source-id ! tib ''source ! #tib ''#source ! + postpone [ + begin + refill + while + interpret state @ 0= if ." ok" cr then + repeat + bye ; + +' (quit) ' quit >body cell+ ! + +\ TODO: s>d +\ TODO: sign +\ TODO: sm/rem + +: spaces ( n -- ) + 0 do space loop ; + +\ TODO: u. + +: signbit ( -- n ) -1 1 rshift invert ; + +: xor ( x y -- x^y ) 2dup nand >r r@ nand swap r> nand nand ; + +: u< ( x y -- flag ) signbit xor swap signbit xor > ; + +\ TODO: um/mod + +: variable ( "word" -- ) + create /cell allot ; + +: ['] \ ( C: "word" -- ) + ' postpone literal ; immediate diff --git a/samples/Forth/tools.4TH b/samples/Forth/tools.4TH new file mode 100644 index 00000000..b08a29fe --- /dev/null +++ b/samples/Forth/tools.4TH @@ -0,0 +1,133 @@ +\ -*- forth -*- Copyright 2004, 2013 Lars Brinkhoff + +( Tools words. ) + +: .s ( -- ) + [char] < emit depth (.) ." > " + 'SP @ >r r@ depth 1- cells + + begin + dup r@ <> + while + dup @ . + /cell - + repeat r> 2drop ; + +: ? @ . ; + +: c? c@ . ; + +: dump bounds do i ? /cell +loop cr ; + +: cdump bounds do i c? loop cr ; + +: again postpone branch , ; immediate + +: see-find ( caddr -- end xt ) + >r here lastxt @ + begin + dup 0= abort" Undefined word" + dup r@ word= if r> drop exit then + nip dup >nextxt + again ; + +: cabs ( char -- |char| ) dup 127 > if 256 swap - then ; + +: xt. ( xt -- ) + ( >name ) count cabs type ; + +: xt? ( xt -- flag ) + >r lastxt @ begin + ?dup + while + dup r@ = if r> 2drop -1 exit then + >nextxt + repeat r> drop 0 ; + +: disassemble ( x -- ) + dup xt? if + ( >name ) count + dup 127 > if ." postpone " then + cabs type + else + . + then ; + +: .addr dup . ; + +: see-line ( addr -- ) + cr ." ( " .addr ." ) " @ disassemble ; + +: see-word ( end xt -- ) + >r ." : " r@ xt. + r@ >body do i see-line /cell +loop + ." ;" r> c@ 127 > if ." immediate" then ; + +: see bl word see-find see-word cr ; + +: #body bl word see-find >body - ; + +: type-word ( end xt -- flag ) + xt. space drop 0 ; + +: traverse-dictionary ( in.. xt -- out.. ) + \ xt execution: ( in.. end xt2 -- in.. 0 | in.. end xt2 -- out.. true ) + >r here lastxt @ begin + ?dup + while + r> 2dup >r >r execute + if r> r> 2drop exit then + r> dup >nextxt + repeat r> 2drop ; + +: words ( -- ) + ['] type-word traverse-dictionary cr ; + +\ ---------------------------------------------------------------------- + +( Tools extension words. ) + +\ ;code + +\ assembler + +\ in kernel: bye + +\ code + +\ cs-pick + +\ cs-roll + +\ editor + +: forget ' dup >nextxt lastxt ! 'here ! reveal ; + +\ Kernel: state + +\ [else] + +\ [if] + +\ [then] + +\ ---------------------------------------------------------------------- + +( Forth2012 tools extension words. ) + +\ TODO: n>r + +\ TODO: nr> + +\ TODO: synonym + +: [undefined] bl-word find nip 0= ; immediate + +: [defined] postpone [undefined] invert ; immediate + +\ ---------------------------------------------------------------------- + +: @+ ( addr -- addr+/cell x ) dup cell+ swap @ ; + +: !+ ( x addr -- addr+/cell ) tuck ! cell+ ; + +: -rot swap >r swap r> ; diff --git a/samples/GAP/bugfix.tst b/samples/GAP/bugfix.tst new file mode 100644 index 00000000..be4bd975 --- /dev/null +++ b/samples/GAP/bugfix.tst @@ -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"); + +gap> x := F.1;; y := F.2;; +gap> G := F/[x^2/y^24, y^24, y^x/y^23]; + +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); diff --git a/samples/GAP/factor.tst b/samples/GAP/factor.tst new file mode 100644 index 00000000..115fe921 --- /dev/null +++ b/samples/GAP/factor.tst @@ -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); diff --git a/samples/GLSL/recurse1.fs b/samples/GLSL/recurse1.fs new file mode 100644 index 00000000..66b4c3fe --- /dev/null +++ b/samples/GLSL/recurse1.fs @@ -0,0 +1,48 @@ +#version 330 core + +// cross-unit recursion + +void main() {} + +// two-level recursion + +float cbar(int); + +void cfoo(float) +{ + cbar(2); +} + +// four-level, out of order + +void CB(); +void CD(); +void CA() { CB(); } +void CC() { CD(); } + +// high degree + +void CBT(); +void CDT(); +void CAT() { CBT(); CBT(); CBT(); } +void CCT() { CDT(); CDT(); CBT(); } + +// not recursive + +void norA() {} +void norB() { norA(); } +void norC() { norA(); } +void norD() { norA(); } +void norE() { norB(); } +void norF() { norB(); } +void norG() { norE(); } +void norH() { norE(); } +void norI() { norE(); } + +// not recursive, but with a call leading into a cycle if ignoring direction + +void norcA() { } +void norcB() { norcA(); } +void norcC() { norcB(); } +void norcD() { norcC(); norcB(); } // head of cycle +void norcE() { norcD(); } // lead into cycle diff --git a/samples/Go/api.pb.go b/samples/Go/api.pb.go new file mode 100644 index 00000000..a4fe4921 --- /dev/null +++ b/samples/Go/api.pb.go @@ -0,0 +1,1157 @@ +// Code generated by protoc-gen-gogo. +// source: api.proto +// DO NOT EDIT! + +/* + Package proto is a generated protocol buffer package. + + It is generated from these files: + api.proto + config.proto + data.proto + errors.proto + gossip.proto + heartbeat.proto + internal.proto + + It has these top-level messages: + ClientCmdID + RequestHeader + ResponseHeader + ContainsRequest + ContainsResponse + GetRequest + GetResponse + PutRequest + PutResponse + ConditionalPutRequest + ConditionalPutResponse + IncrementRequest + IncrementResponse + DeleteRequest + DeleteResponse + DeleteRangeRequest + DeleteRangeResponse + ScanRequest + ScanResponse + EndTransactionRequest + EndTransactionResponse + ReapQueueRequest + ReapQueueResponse + EnqueueUpdateRequest + EnqueueUpdateResponse + EnqueueMessageRequest + EnqueueMessageResponse + RequestUnion + ResponseUnion + BatchRequest + BatchResponse + AdminSplitRequest + AdminSplitResponse + AdminMergeRequest + AdminMergeResponse +*/ +package proto + +import proto1 "github.com/gogo/protobuf/proto" +import math "math" + +// discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto/gogo.pb" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto1.Marshal +var _ = math.Inf + +// ClientCmdID provides a unique ID for client commands. Clients which +// provide ClientCmdID gain operation idempotence. In other words, +// clients can submit the same command multiple times and always +// receive the same response. This is common on retries over flaky +// networks. However, the system imposes a limit on how long +// idempotence is provided. Retries over an hour old are not +// guaranteed idempotence and may be executed more than once with +// potentially different results. +// +// ClientCmdID contains the client's timestamp and a client-generated +// random number. The client Timestamp is specified in unix +// nanoseconds and is used for some uniqueness but also to provide a +// rough ordering of requests, useful for data locality on the +// server. The Random is specified for additional uniqueness. +// NOTE: An accurate time signal IS NOT required for correctness. +type ClientCmdID struct { + // Nanoseconds since Unix epoch. + WallTime int64 `protobuf:"varint,1,opt,name=wall_time" json:"wall_time"` + Random int64 `protobuf:"varint,2,opt,name=random" json:"random"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ClientCmdID) Reset() { *m = ClientCmdID{} } +func (m *ClientCmdID) String() string { return proto1.CompactTextString(m) } +func (*ClientCmdID) ProtoMessage() {} + +func (m *ClientCmdID) GetWallTime() int64 { + if m != nil { + return m.WallTime + } + return 0 +} + +func (m *ClientCmdID) GetRandom() int64 { + if m != nil { + return m.Random + } + return 0 +} + +// RequestHeader is supplied with every storage node request. +type RequestHeader struct { + // Timestamp specifies time at which read or writes should be + // performed. If the timestamp is set to zero value, its value + // is initialized to the wall time of the receiving node. + Timestamp Timestamp `protobuf:"bytes,1,opt,name=timestamp" json:"timestamp"` + // CmdID is optionally specified for request idempotence + // (i.e. replay protection). + CmdID ClientCmdID `protobuf:"bytes,2,opt,name=cmd_id" json:"cmd_id"` + // The key for request. If the request operates on a range, this + // represents the starting key for the range. + Key Key `protobuf:"bytes,3,opt,name=key,customtype=Key" json:"key"` + // End key is empty if request spans only a single key. + EndKey Key `protobuf:"bytes,4,opt,name=end_key,customtype=Key" json:"end_key"` + // User is the originating user. Used to lookup priority when + // scheduling queued operations at target node. + User string `protobuf:"bytes,5,opt,name=user" json:"user"` + // Replica specifies the destination for the request. This is a specific + // instance of the available replicas belonging to RangeID. + Replica Replica `protobuf:"bytes,6,opt,name=replica" json:"replica"` + // RaftID specifies the ID of the Raft consensus group which the key + // range belongs to. This is used by the receiving node to route the + // request to the correct range. + RaftID int64 `protobuf:"varint,7,opt,name=raft_id" json:"raft_id"` + // UserPriority specifies priority multiple for non-transactional + // commands. This value should be a positive integer [1, 2^31-1). + // It's properly viewed as a multiple for how likely this + // transaction will be to prevail if a write conflict occurs. + // Commands with UserPriority=100 will be 100x less likely to be + // aborted as conflicting transactions or non-transactional commands + // with UserPriority=1. This value is ignored if Txn is + // specified. If neither this value nor Txn is specified, the value + // defaults to 1. + UserPriority *int32 `protobuf:"varint,8,opt,name=user_priority,def=1" json:"user_priority,omitempty"` + // Txn is set non-nil if a transaction is underway. To start a txn, + // the first request should set this field to non-nil with name and + // isolation level set as desired. The response will contain the + // fully-initialized transaction with txn ID, priority, initial + // timestamp, and maximum timestamp. + Txn *Transaction `protobuf:"bytes,9,opt,name=txn" json:"txn,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *RequestHeader) Reset() { *m = RequestHeader{} } +func (m *RequestHeader) String() string { return proto1.CompactTextString(m) } +func (*RequestHeader) ProtoMessage() {} + +const Default_RequestHeader_UserPriority int32 = 1 + +func (m *RequestHeader) GetTimestamp() Timestamp { + if m != nil { + return m.Timestamp + } + return Timestamp{} +} + +func (m *RequestHeader) GetCmdID() ClientCmdID { + if m != nil { + return m.CmdID + } + return ClientCmdID{} +} + +func (m *RequestHeader) GetUser() string { + if m != nil { + return m.User + } + return "" +} + +func (m *RequestHeader) GetReplica() Replica { + if m != nil { + return m.Replica + } + return Replica{} +} + +func (m *RequestHeader) GetRaftID() int64 { + if m != nil { + return m.RaftID + } + return 0 +} + +func (m *RequestHeader) GetUserPriority() int32 { + if m != nil && m.UserPriority != nil { + return *m.UserPriority + } + return Default_RequestHeader_UserPriority +} + +func (m *RequestHeader) GetTxn() *Transaction { + if m != nil { + return m.Txn + } + return nil +} + +// ResponseHeader is returned with every storage node response. +type ResponseHeader struct { + // Error is non-nil if an error occurred. + Error *Error `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"` + // Timestamp specifies time at which read or write actually was + // performed. In the case of both reads and writes, if the timestamp + // supplied to the request was 0, the wall time of the node + // servicing the request will be set here. Additionally, in the case + // of writes, this value may be increased from the timestamp passed + // with the RequestHeader if the key being written was either read + // or written more recently. + Timestamp Timestamp `protobuf:"bytes,2,opt,name=timestamp" json:"timestamp"` + // Transaction is non-nil if the request specified a non-nil + // transaction. The transaction timestamp and/or priority may have + // been updated, depending on the outcome of the request. + Txn *Transaction `protobuf:"bytes,3,opt,name=txn" json:"txn,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ResponseHeader) Reset() { *m = ResponseHeader{} } +func (m *ResponseHeader) String() string { return proto1.CompactTextString(m) } +func (*ResponseHeader) ProtoMessage() {} + +func (m *ResponseHeader) GetError() *Error { + if m != nil { + return m.Error + } + return nil +} + +func (m *ResponseHeader) GetTimestamp() Timestamp { + if m != nil { + return m.Timestamp + } + return Timestamp{} +} + +func (m *ResponseHeader) GetTxn() *Transaction { + if m != nil { + return m.Txn + } + return nil +} + +// A ContainsRequest is arguments to the Contains() method. +type ContainsRequest struct { + RequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ContainsRequest) Reset() { *m = ContainsRequest{} } +func (m *ContainsRequest) String() string { return proto1.CompactTextString(m) } +func (*ContainsRequest) ProtoMessage() {} + +// A ContainsResponse is the return value of the Contains() method. +type ContainsResponse struct { + ResponseHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + Exists bool `protobuf:"varint,2,opt,name=exists" json:"exists"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ContainsResponse) Reset() { *m = ContainsResponse{} } +func (m *ContainsResponse) String() string { return proto1.CompactTextString(m) } +func (*ContainsResponse) ProtoMessage() {} + +func (m *ContainsResponse) GetExists() bool { + if m != nil { + return m.Exists + } + return false +} + +// A GetRequest is arguments to the Get() method. +type GetRequest struct { + RequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetRequest) Reset() { *m = GetRequest{} } +func (m *GetRequest) String() string { return proto1.CompactTextString(m) } +func (*GetRequest) ProtoMessage() {} + +// A GetResponse is the return value from the Get() method. +// If the key doesn't exist, returns nil for Value.Bytes. +type GetResponse struct { + ResponseHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + Value *Value `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetResponse) Reset() { *m = GetResponse{} } +func (m *GetResponse) String() string { return proto1.CompactTextString(m) } +func (*GetResponse) ProtoMessage() {} + +func (m *GetResponse) GetValue() *Value { + if m != nil { + return m.Value + } + return nil +} + +// A PutRequest is arguments to the Put() method. Note that to write +// an empty value, the value parameter is still specified, but both +// Bytes and Integer are set to nil. +type PutRequest struct { + RequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + Value Value `protobuf:"bytes,2,opt,name=value" json:"value"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PutRequest) Reset() { *m = PutRequest{} } +func (m *PutRequest) String() string { return proto1.CompactTextString(m) } +func (*PutRequest) ProtoMessage() {} + +func (m *PutRequest) GetValue() Value { + if m != nil { + return m.Value + } + return Value{} +} + +// A PutResponse is the return value from the Put() method. +type PutResponse struct { + ResponseHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PutResponse) Reset() { *m = PutResponse{} } +func (m *PutResponse) String() string { return proto1.CompactTextString(m) } +func (*PutResponse) ProtoMessage() {} + +// A ConditionalPutRequest is arguments to the ConditionalPut() method. +// +// - Returns true and sets value if ExpValue equals existing value. +// - If key doesn't exist and ExpValue is nil, sets value. +// - If key exists, but value is empty and ExpValue is not nil but empty, sets value. +// - Otherwise, returns error and the actual value of the key in the response. +type ConditionalPutRequest struct { + RequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + // The value to put. + Value Value `protobuf:"bytes,2,opt,name=value" json:"value"` + // ExpValue.Bytes empty to test for non-existence. Specify as nil + // to indicate there should be no existing entry. This is different + // from the expectation that the value exists but is empty. + ExpValue *Value `protobuf:"bytes,3,opt,name=exp_value" json:"exp_value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ConditionalPutRequest) Reset() { *m = ConditionalPutRequest{} } +func (m *ConditionalPutRequest) String() string { return proto1.CompactTextString(m) } +func (*ConditionalPutRequest) ProtoMessage() {} + +func (m *ConditionalPutRequest) GetValue() Value { + if m != nil { + return m.Value + } + return Value{} +} + +func (m *ConditionalPutRequest) GetExpValue() *Value { + if m != nil { + return m.ExpValue + } + return nil +} + +// A ConditionalPutResponse is the return value from the +// ConditionalPut() method. +type ConditionalPutResponse struct { + ResponseHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ConditionalPutResponse) Reset() { *m = ConditionalPutResponse{} } +func (m *ConditionalPutResponse) String() string { return proto1.CompactTextString(m) } +func (*ConditionalPutResponse) ProtoMessage() {} + +// An IncrementRequest is arguments to the Increment() method. It +// increments the value for key, and returns the new value. If no +// value exists for a key, incrementing by 0 is not a noop, but will +// create a zero value. IncrementRequest cannot be called on a key set +// by Put() or ConditionalPut(). Similarly, Get(), Put() and +// ConditionalPut() cannot be invoked on an incremented key. +type IncrementRequest struct { + RequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + Increment int64 `protobuf:"varint,2,opt,name=increment" json:"increment"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *IncrementRequest) Reset() { *m = IncrementRequest{} } +func (m *IncrementRequest) String() string { return proto1.CompactTextString(m) } +func (*IncrementRequest) ProtoMessage() {} + +func (m *IncrementRequest) GetIncrement() int64 { + if m != nil { + return m.Increment + } + return 0 +} + +// An IncrementResponse is the return value from the Increment +// method. The new value after increment is specified in NewValue. If +// the value could not be decoded as specified, Error will be set. +type IncrementResponse struct { + ResponseHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + NewValue int64 `protobuf:"varint,2,opt,name=new_value" json:"new_value"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *IncrementResponse) Reset() { *m = IncrementResponse{} } +func (m *IncrementResponse) String() string { return proto1.CompactTextString(m) } +func (*IncrementResponse) ProtoMessage() {} + +func (m *IncrementResponse) GetNewValue() int64 { + if m != nil { + return m.NewValue + } + return 0 +} + +// A DeleteRequest is arguments to the Delete() method. +type DeleteRequest struct { + RequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *DeleteRequest) Reset() { *m = DeleteRequest{} } +func (m *DeleteRequest) String() string { return proto1.CompactTextString(m) } +func (*DeleteRequest) ProtoMessage() {} + +// A DeleteResponse is the return value from the Delete() method. +type DeleteResponse struct { + ResponseHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *DeleteResponse) Reset() { *m = DeleteResponse{} } +func (m *DeleteResponse) String() string { return proto1.CompactTextString(m) } +func (*DeleteResponse) ProtoMessage() {} + +// A DeleteRangeRequest is arguments to the DeleteRange method. It +// specifies the range of keys to delete. +type DeleteRangeRequest struct { + RequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + // If 0, *all* entries between Key (inclusive) and EndKey + // (exclusive) are deleted. Must be >= 0 + MaxEntriesToDelete int64 `protobuf:"varint,2,opt,name=max_entries_to_delete" json:"max_entries_to_delete"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *DeleteRangeRequest) Reset() { *m = DeleteRangeRequest{} } +func (m *DeleteRangeRequest) String() string { return proto1.CompactTextString(m) } +func (*DeleteRangeRequest) ProtoMessage() {} + +func (m *DeleteRangeRequest) GetMaxEntriesToDelete() int64 { + if m != nil { + return m.MaxEntriesToDelete + } + return 0 +} + +// A DeleteRangeResponse is the return value from the DeleteRange() +// method. +type DeleteRangeResponse struct { + ResponseHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + // Number of entries removed. + NumDeleted int64 `protobuf:"varint,2,opt,name=num_deleted" json:"num_deleted"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *DeleteRangeResponse) Reset() { *m = DeleteRangeResponse{} } +func (m *DeleteRangeResponse) String() string { return proto1.CompactTextString(m) } +func (*DeleteRangeResponse) ProtoMessage() {} + +func (m *DeleteRangeResponse) GetNumDeleted() int64 { + if m != nil { + return m.NumDeleted + } + return 0 +} + +// A ScanRequest is arguments to the Scan() method. It specifies the +// start and end keys for the scan and the maximum number of results. +type ScanRequest struct { + RequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + // Must be > 0. + MaxResults int64 `protobuf:"varint,2,opt,name=max_results" json:"max_results"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ScanRequest) Reset() { *m = ScanRequest{} } +func (m *ScanRequest) String() string { return proto1.CompactTextString(m) } +func (*ScanRequest) ProtoMessage() {} + +func (m *ScanRequest) GetMaxResults() int64 { + if m != nil { + return m.MaxResults + } + return 0 +} + +// A ScanResponse is the return value from the Scan() method. +type ScanResponse struct { + ResponseHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + // Empty if no rows were scanned. + Rows []KeyValue `protobuf:"bytes,2,rep,name=rows" json:"rows"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ScanResponse) Reset() { *m = ScanResponse{} } +func (m *ScanResponse) String() string { return proto1.CompactTextString(m) } +func (*ScanResponse) ProtoMessage() {} + +func (m *ScanResponse) GetRows() []KeyValue { + if m != nil { + return m.Rows + } + return nil +} + +// An EndTransactionRequest is arguments to the EndTransaction() method. +// It specifies whether to commit or roll back an extant transaction. +type EndTransactionRequest struct { + RequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + // False to abort and rollback. + Commit bool `protobuf:"varint,2,opt,name=commit" json:"commit"` + // Optional commit triggers. Note that commit triggers are for + // internal use only and will be ignored if requested through the + // public-facing KV API. + SplitTrigger *SplitTrigger `protobuf:"bytes,3,opt,name=split_trigger" json:"split_trigger,omitempty"` + MergeTrigger *MergeTrigger `protobuf:"bytes,4,opt,name=merge_trigger" json:"merge_trigger,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EndTransactionRequest) Reset() { *m = EndTransactionRequest{} } +func (m *EndTransactionRequest) String() string { return proto1.CompactTextString(m) } +func (*EndTransactionRequest) ProtoMessage() {} + +func (m *EndTransactionRequest) GetCommit() bool { + if m != nil { + return m.Commit + } + return false +} + +func (m *EndTransactionRequest) GetSplitTrigger() *SplitTrigger { + if m != nil { + return m.SplitTrigger + } + return nil +} + +func (m *EndTransactionRequest) GetMergeTrigger() *MergeTrigger { + if m != nil { + return m.MergeTrigger + } + return nil +} + +// An EndTransactionResponse is the return value from the +// EndTransaction() method. The final transaction record is returned +// as part of the response header. In particular, transaction status +// and timestamp will be updated to reflect final committed +// values. Clients may propagate the transaction timestamp as the +// final txn commit timestamp in order to preserve causal ordering +// between subsequent transactions. CommitWait specifies the commit +// wait, which is the remaining time the client MUST wait before +// signalling completion of the transaction to another distributed +// node to maintain consistency. +type EndTransactionResponse struct { + ResponseHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + // Remaining time (ns). + CommitWait int64 `protobuf:"varint,2,opt,name=commit_wait" json:"commit_wait"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EndTransactionResponse) Reset() { *m = EndTransactionResponse{} } +func (m *EndTransactionResponse) String() string { return proto1.CompactTextString(m) } +func (*EndTransactionResponse) ProtoMessage() {} + +func (m *EndTransactionResponse) GetCommitWait() int64 { + if m != nil { + return m.CommitWait + } + return 0 +} + +// A ReapQueueRequest is arguments to the ReapQueue() method. It +// specifies the recipient inbox key to which messages are waiting +// to be reapted and also the maximum number of results to return. +type ReapQueueRequest struct { + RequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + // Maximum results to return; must be > 0. + MaxResults int64 `protobuf:"varint,2,opt,name=max_results" json:"max_results"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ReapQueueRequest) Reset() { *m = ReapQueueRequest{} } +func (m *ReapQueueRequest) String() string { return proto1.CompactTextString(m) } +func (*ReapQueueRequest) ProtoMessage() {} + +func (m *ReapQueueRequest) GetMaxResults() int64 { + if m != nil { + return m.MaxResults + } + return 0 +} + +// A ReapQueueResponse is the return value from the ReapQueue() method. +type ReapQueueResponse struct { + ResponseHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + Messages []Value `protobuf:"bytes,2,rep,name=messages" json:"messages"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ReapQueueResponse) Reset() { *m = ReapQueueResponse{} } +func (m *ReapQueueResponse) String() string { return proto1.CompactTextString(m) } +func (*ReapQueueResponse) ProtoMessage() {} + +func (m *ReapQueueResponse) GetMessages() []Value { + if m != nil { + return m.Messages + } + return nil +} + +// An EnqueueUpdateRequest is arguments to the EnqueueUpdate() method. +// It specifies the update to enqueue for asynchronous execution. +// Update is an instance of one of the following messages: PutRequest, +// IncrementRequest, DeleteRequest, DeleteRangeRequest, or +// AccountingRequest. +type EnqueueUpdateRequest struct { + RequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EnqueueUpdateRequest) Reset() { *m = EnqueueUpdateRequest{} } +func (m *EnqueueUpdateRequest) String() string { return proto1.CompactTextString(m) } +func (*EnqueueUpdateRequest) ProtoMessage() {} + +// An EnqueueUpdateResponse is the return value from the +// EnqueueUpdate() method. +type EnqueueUpdateResponse struct { + ResponseHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EnqueueUpdateResponse) Reset() { *m = EnqueueUpdateResponse{} } +func (m *EnqueueUpdateResponse) String() string { return proto1.CompactTextString(m) } +func (*EnqueueUpdateResponse) ProtoMessage() {} + +// An EnqueueMessageRequest is arguments to the EnqueueMessage() method. +// It specifies the recipient inbox key and the message (an arbitrary +// byte slice value). +type EnqueueMessageRequest struct { + RequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + // Message value to delivery to inbox. + Msg Value `protobuf:"bytes,2,opt,name=msg" json:"msg"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EnqueueMessageRequest) Reset() { *m = EnqueueMessageRequest{} } +func (m *EnqueueMessageRequest) String() string { return proto1.CompactTextString(m) } +func (*EnqueueMessageRequest) ProtoMessage() {} + +func (m *EnqueueMessageRequest) GetMsg() Value { + if m != nil { + return m.Msg + } + return Value{} +} + +// An EnqueueMessageResponse is the return value from the +// EnqueueMessage() method. +type EnqueueMessageResponse struct { + ResponseHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EnqueueMessageResponse) Reset() { *m = EnqueueMessageResponse{} } +func (m *EnqueueMessageResponse) String() string { return proto1.CompactTextString(m) } +func (*EnqueueMessageResponse) ProtoMessage() {} + +// A RequestUnion contains exactly one of the optional requests. +type RequestUnion struct { + Contains *ContainsRequest `protobuf:"bytes,1,opt,name=contains" json:"contains,omitempty"` + Get *GetRequest `protobuf:"bytes,2,opt,name=get" json:"get,omitempty"` + Put *PutRequest `protobuf:"bytes,3,opt,name=put" json:"put,omitempty"` + ConditionalPut *ConditionalPutRequest `protobuf:"bytes,4,opt,name=conditional_put" json:"conditional_put,omitempty"` + Increment *IncrementRequest `protobuf:"bytes,5,opt,name=increment" json:"increment,omitempty"` + Delete *DeleteRequest `protobuf:"bytes,6,opt,name=delete" json:"delete,omitempty"` + DeleteRange *DeleteRangeRequest `protobuf:"bytes,7,opt,name=delete_range" json:"delete_range,omitempty"` + Scan *ScanRequest `protobuf:"bytes,8,opt,name=scan" json:"scan,omitempty"` + EndTransaction *EndTransactionRequest `protobuf:"bytes,9,opt,name=end_transaction" json:"end_transaction,omitempty"` + ReapQueue *ReapQueueRequest `protobuf:"bytes,10,opt,name=reap_queue" json:"reap_queue,omitempty"` + EnqueueUpdate *EnqueueUpdateRequest `protobuf:"bytes,11,opt,name=enqueue_update" json:"enqueue_update,omitempty"` + EnqueueMessage *EnqueueMessageRequest `protobuf:"bytes,12,opt,name=enqueue_message" json:"enqueue_message,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *RequestUnion) Reset() { *m = RequestUnion{} } +func (m *RequestUnion) String() string { return proto1.CompactTextString(m) } +func (*RequestUnion) ProtoMessage() {} + +func (m *RequestUnion) GetContains() *ContainsRequest { + if m != nil { + return m.Contains + } + return nil +} + +func (m *RequestUnion) GetGet() *GetRequest { + if m != nil { + return m.Get + } + return nil +} + +func (m *RequestUnion) GetPut() *PutRequest { + if m != nil { + return m.Put + } + return nil +} + +func (m *RequestUnion) GetConditionalPut() *ConditionalPutRequest { + if m != nil { + return m.ConditionalPut + } + return nil +} + +func (m *RequestUnion) GetIncrement() *IncrementRequest { + if m != nil { + return m.Increment + } + return nil +} + +func (m *RequestUnion) GetDelete() *DeleteRequest { + if m != nil { + return m.Delete + } + return nil +} + +func (m *RequestUnion) GetDeleteRange() *DeleteRangeRequest { + if m != nil { + return m.DeleteRange + } + return nil +} + +func (m *RequestUnion) GetScan() *ScanRequest { + if m != nil { + return m.Scan + } + return nil +} + +func (m *RequestUnion) GetEndTransaction() *EndTransactionRequest { + if m != nil { + return m.EndTransaction + } + return nil +} + +func (m *RequestUnion) GetReapQueue() *ReapQueueRequest { + if m != nil { + return m.ReapQueue + } + return nil +} + +func (m *RequestUnion) GetEnqueueUpdate() *EnqueueUpdateRequest { + if m != nil { + return m.EnqueueUpdate + } + return nil +} + +func (m *RequestUnion) GetEnqueueMessage() *EnqueueMessageRequest { + if m != nil { + return m.EnqueueMessage + } + return nil +} + +// A ResponseUnion contains exactly one of the optional responses. +type ResponseUnion struct { + Contains *ContainsResponse `protobuf:"bytes,1,opt,name=contains" json:"contains,omitempty"` + Get *GetResponse `protobuf:"bytes,2,opt,name=get" json:"get,omitempty"` + Put *PutResponse `protobuf:"bytes,3,opt,name=put" json:"put,omitempty"` + ConditionalPut *ConditionalPutResponse `protobuf:"bytes,4,opt,name=conditional_put" json:"conditional_put,omitempty"` + Increment *IncrementResponse `protobuf:"bytes,5,opt,name=increment" json:"increment,omitempty"` + Delete *DeleteResponse `protobuf:"bytes,6,opt,name=delete" json:"delete,omitempty"` + DeleteRange *DeleteRangeResponse `protobuf:"bytes,7,opt,name=delete_range" json:"delete_range,omitempty"` + Scan *ScanResponse `protobuf:"bytes,8,opt,name=scan" json:"scan,omitempty"` + EndTransaction *EndTransactionResponse `protobuf:"bytes,9,opt,name=end_transaction" json:"end_transaction,omitempty"` + ReapQueue *ReapQueueResponse `protobuf:"bytes,10,opt,name=reap_queue" json:"reap_queue,omitempty"` + EnqueueUpdate *EnqueueUpdateResponse `protobuf:"bytes,11,opt,name=enqueue_update" json:"enqueue_update,omitempty"` + EnqueueMessage *EnqueueMessageResponse `protobuf:"bytes,12,opt,name=enqueue_message" json:"enqueue_message,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ResponseUnion) Reset() { *m = ResponseUnion{} } +func (m *ResponseUnion) String() string { return proto1.CompactTextString(m) } +func (*ResponseUnion) ProtoMessage() {} + +func (m *ResponseUnion) GetContains() *ContainsResponse { + if m != nil { + return m.Contains + } + return nil +} + +func (m *ResponseUnion) GetGet() *GetResponse { + if m != nil { + return m.Get + } + return nil +} + +func (m *ResponseUnion) GetPut() *PutResponse { + if m != nil { + return m.Put + } + return nil +} + +func (m *ResponseUnion) GetConditionalPut() *ConditionalPutResponse { + if m != nil { + return m.ConditionalPut + } + return nil +} + +func (m *ResponseUnion) GetIncrement() *IncrementResponse { + if m != nil { + return m.Increment + } + return nil +} + +func (m *ResponseUnion) GetDelete() *DeleteResponse { + if m != nil { + return m.Delete + } + return nil +} + +func (m *ResponseUnion) GetDeleteRange() *DeleteRangeResponse { + if m != nil { + return m.DeleteRange + } + return nil +} + +func (m *ResponseUnion) GetScan() *ScanResponse { + if m != nil { + return m.Scan + } + return nil +} + +func (m *ResponseUnion) GetEndTransaction() *EndTransactionResponse { + if m != nil { + return m.EndTransaction + } + return nil +} + +func (m *ResponseUnion) GetReapQueue() *ReapQueueResponse { + if m != nil { + return m.ReapQueue + } + return nil +} + +func (m *ResponseUnion) GetEnqueueUpdate() *EnqueueUpdateResponse { + if m != nil { + return m.EnqueueUpdate + } + return nil +} + +func (m *ResponseUnion) GetEnqueueMessage() *EnqueueMessageResponse { + if m != nil { + return m.EnqueueMessage + } + return nil +} + +// A BatchRequest contains one or more requests to be executed in +// parallel, or if applicable (based on write-only commands and +// range-locality), as a single update. +type BatchRequest struct { + RequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + Requests []RequestUnion `protobuf:"bytes,2,rep,name=requests" json:"requests"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *BatchRequest) Reset() { *m = BatchRequest{} } +func (m *BatchRequest) String() string { return proto1.CompactTextString(m) } +func (*BatchRequest) ProtoMessage() {} + +func (m *BatchRequest) GetRequests() []RequestUnion { + if m != nil { + return m.Requests + } + return nil +} + +// A BatchResponse contains one or more responses, one per request +// corresponding to the requests in the matching BatchRequest. The +// error in the response header is set to the first error from the +// slice of responses, if applicable. +type BatchResponse struct { + ResponseHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + Responses []ResponseUnion `protobuf:"bytes,2,rep,name=responses" json:"responses"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *BatchResponse) Reset() { *m = BatchResponse{} } +func (m *BatchResponse) String() string { return proto1.CompactTextString(m) } +func (*BatchResponse) ProtoMessage() {} + +func (m *BatchResponse) GetResponses() []ResponseUnion { + if m != nil { + return m.Responses + } + return nil +} + +// An AdminSplitRequest is arguments to the AdminSplit() method. The +// existing range which contains RequestHeader.Key is split by +// split_key. If split_key is not specified, then this method will +// determine a split key that is roughly halfway through the +// range. The existing range is resized to cover only its start key to +// the split key. The new range created by the split starts at the +// split key and extends to the original range's end key. If split_key +// is known, header.key should also be set to split_key. +// +// New range IDs for each of the split range's replica and a new Raft +// ID are generated by the operation. Split requests are done in the +// context of a distributed transaction which updates range addressing +// records, range metadata and finally, provides a commit trigger to +// update bookkeeping and instantiate the new range on commit. +// +// The new range contains range replicas located on the same stores; +// no range data is moved during this operation. The split can be +// thought of as a mostly logical operation, though some other +// metadata (e.g. response cache and range stats must be copied or +// recomputed). +type AdminSplitRequest struct { + RequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + SplitKey Key `protobuf:"bytes,2,opt,name=split_key,customtype=Key" json:"split_key"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *AdminSplitRequest) Reset() { *m = AdminSplitRequest{} } +func (m *AdminSplitRequest) String() string { return proto1.CompactTextString(m) } +func (*AdminSplitRequest) ProtoMessage() {} + +// An AdminSplitResponse is the return value from the AdminSplit() +// method. +type AdminSplitResponse struct { + ResponseHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *AdminSplitResponse) Reset() { *m = AdminSplitResponse{} } +func (m *AdminSplitResponse) String() string { return proto1.CompactTextString(m) } +func (*AdminSplitResponse) ProtoMessage() {} + +// An AdminMergeRequest is arguments to the AdminMerge() method. A +// merge is always performed by calling AdminMerge on the range +// that is subsuming the passed in subsumed_range. The ranges must +// be consecutive in the key space, such that the end_key of the +// subsuming range must match the start_key of the range being subsumed. +// After the merge operation, the subsumed_range will no longer exist and +// the subsuming range will now encompass all keys from its original +// start_key to the end_key of the subsumed_range. +type AdminMergeRequest struct { + RequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + SubsumedRange RangeDescriptor `protobuf:"bytes,2,opt,name=subsumed_range" json:"subsumed_range"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *AdminMergeRequest) Reset() { *m = AdminMergeRequest{} } +func (m *AdminMergeRequest) String() string { return proto1.CompactTextString(m) } +func (*AdminMergeRequest) ProtoMessage() {} + +func (m *AdminMergeRequest) GetSubsumedRange() RangeDescriptor { + if m != nil { + return m.SubsumedRange + } + return RangeDescriptor{} +} + +// An AdminMergeResponse is the return value from the AdminMerge() +// method. +type AdminMergeResponse struct { + ResponseHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *AdminMergeResponse) Reset() { *m = AdminMergeResponse{} } +func (m *AdminMergeResponse) String() string { return proto1.CompactTextString(m) } +func (*AdminMergeResponse) ProtoMessage() {} + +func init() { +} +func (this *RequestUnion) GetValue() interface{} { + if this.Contains != nil { + return this.Contains + } + if this.Get != nil { + return this.Get + } + if this.Put != nil { + return this.Put + } + if this.ConditionalPut != nil { + return this.ConditionalPut + } + if this.Increment != nil { + return this.Increment + } + if this.Delete != nil { + return this.Delete + } + if this.DeleteRange != nil { + return this.DeleteRange + } + if this.Scan != nil { + return this.Scan + } + if this.EndTransaction != nil { + return this.EndTransaction + } + if this.ReapQueue != nil { + return this.ReapQueue + } + if this.EnqueueUpdate != nil { + return this.EnqueueUpdate + } + if this.EnqueueMessage != nil { + return this.EnqueueMessage + } + return nil +} + +func (this *RequestUnion) SetValue(value interface{}) bool { + switch vt := value.(type) { + case *ContainsRequest: + this.Contains = vt + case *GetRequest: + this.Get = vt + case *PutRequest: + this.Put = vt + case *ConditionalPutRequest: + this.ConditionalPut = vt + case *IncrementRequest: + this.Increment = vt + case *DeleteRequest: + this.Delete = vt + case *DeleteRangeRequest: + this.DeleteRange = vt + case *ScanRequest: + this.Scan = vt + case *EndTransactionRequest: + this.EndTransaction = vt + case *ReapQueueRequest: + this.ReapQueue = vt + case *EnqueueUpdateRequest: + this.EnqueueUpdate = vt + case *EnqueueMessageRequest: + this.EnqueueMessage = vt + default: + return false + } + return true +} +func (this *ResponseUnion) GetValue() interface{} { + if this.Contains != nil { + return this.Contains + } + if this.Get != nil { + return this.Get + } + if this.Put != nil { + return this.Put + } + if this.ConditionalPut != nil { + return this.ConditionalPut + } + if this.Increment != nil { + return this.Increment + } + if this.Delete != nil { + return this.Delete + } + if this.DeleteRange != nil { + return this.DeleteRange + } + if this.Scan != nil { + return this.Scan + } + if this.EndTransaction != nil { + return this.EndTransaction + } + if this.ReapQueue != nil { + return this.ReapQueue + } + if this.EnqueueUpdate != nil { + return this.EnqueueUpdate + } + if this.EnqueueMessage != nil { + return this.EnqueueMessage + } + return nil +} + +func (this *ResponseUnion) SetValue(value interface{}) bool { + switch vt := value.(type) { + case *ContainsResponse: + this.Contains = vt + case *GetResponse: + this.Get = vt + case *PutResponse: + this.Put = vt + case *ConditionalPutResponse: + this.ConditionalPut = vt + case *IncrementResponse: + this.Increment = vt + case *DeleteResponse: + this.Delete = vt + case *DeleteRangeResponse: + this.DeleteRange = vt + case *ScanResponse: + this.Scan = vt + case *EndTransactionResponse: + this.EndTransaction = vt + case *ReapQueueResponse: + this.ReapQueue = vt + case *EnqueueUpdateResponse: + this.EnqueueUpdate = vt + case *EnqueueMessageResponse: + this.EnqueueMessage = vt + default: + return false + } + return true +} diff --git a/samples/Golo/adapters.golo b/samples/Golo/adapters.golo new file mode 100755 index 00000000..20c7d031 --- /dev/null +++ b/samples/Golo/adapters.golo @@ -0,0 +1,67 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.Adapters + +local function list_sample = |fabric| { + println(">>> list_sample()") + let carbonCopy = list[] + let conf = map[ + ["extends", "java.util.ArrayList"], + ["overrides", map[ + ["*", |super, name, args| { + if name == "add" { + if args: length() == 2 { + carbonCopy: add(args: get(1)) + } else { + carbonCopy: add(args: get(1), args: get(2)) + } + } + return super: invokeWithArguments(args) + } + ]] + ]] + let list = fabric: maker(conf): newInstance() + list: add("bar") + list: add(0, "foo") + list: add("baz") + println(" list: " + list + " " + list: getClass()) + println("carbonCopy: " + carbonCopy + " " + carbonCopy: getClass()) +} + +local function runnable_sample = |fabric| { + println(">>> runnable_sample") + let result = array[1, 2, 3] + let conf = map[ + ["interfaces", ["java.io.Serializable", "java.lang.Runnable"]], + ["implements", map[ + ["run", |this| { + for (var i = 0, i < result: length(), i = i + 1) { + result: set(i, result: get(i) + 10) + } + }] + ]] + ] + let runner = fabric: maker(conf): newInstance() + runner: run() + println(" result: " + result: toString()) + println("serializable? " + (runner oftype java.io.Serializable.class)) + println(" runnable? " + (runner oftype java.lang.Runnable.class)) +} + +function main = |args| { + let fabric = AdapterFabric() + list_sample(fabric) + runnable_sample(fabric) +} diff --git a/samples/Golo/async.golo b/samples/Golo/async.golo new file mode 100755 index 00000000..432f8c94 --- /dev/null +++ b/samples/Golo/async.golo @@ -0,0 +1,84 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.AsyncHelpers + +import gololang.Async +import java.util.concurrent.TimeUnit +import java.util.concurrent.Executors + +local function fib = |n| { + if n <= 1 { + return n + } else { + return fib(n - 1) + fib(n - 2) + } +} + +function main = |args| { + + let executor = newCachedThreadPool() + println("Let's do some useless asynchronous operations...") + + var f = executor: enqueue({ + Thread.sleep(1000_L) + return 666 + }) + f: + onSet(|v| -> println(">>> #slow -> " + v)): + onFail(|e| -> println(">>> #fail -> " + e)) + f: + cancel(true) + + f = executor: enqueue({ + Thread.sleep(1000_L) + return 666 + }) + f: + onSet(|v| -> println(">>> #ok -> " + v)): + onFail(|e| -> println(">>> #wtf? -> " + e)) + + let fib_10 = promise() + let fib_20 = promise() + let fib_30 = promise() + let fib_40 = promise() + + let futures = [ + fib_10: future(), fib_20: future(), + fib_30: future(), fib_40: future() + ] + + executor: submit(-> fib_10: set(fib(10))) + executor: submit(-> fib_20: set(fib(20))) + executor: submit(-> fib_30: set(fib(30))) + executor: submit(-> fib_40: set(fib(40))) + + all(futures): onSet(|results| -> println(">>> Fibs: " + results)) + + let truth = promise() + truth: + future(): + map(|v| -> "truth=" + v): + onSet(|v| -> executor: submit(-> println(">>> (another thread) " + v))): + onSet(|v| -> println(">>> (same thread) " + v)) + executor: submit({ + Thread.sleep(500_L) + truth: set(42) + }) + + Thread.sleep(1000_L) + executor: shutdown() + executor: awaitTermination(2_L, SECONDS()) + println("Bye!") +} diff --git a/samples/Golo/augmentations.golo b/samples/Golo/augmentations.golo new file mode 100755 index 00000000..bed289a4 --- /dev/null +++ b/samples/Golo/augmentations.golo @@ -0,0 +1,37 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.Augmentations + +import java.util.LinkedList + +augment java.util.List { + function with = |this, value| { + this: add(value) + return this + } +} + +augment java.util.Collection { + function doToEach = |this, func| { + foreach (element in this) { + func(element) + } + } +} + +function main = |args| { + let list = LinkedList(): with("foo"): with("bar"): with("baz") + list: doToEach(|value| -> println(">>> " + value)) +} diff --git a/samples/Golo/closures.golo b/samples/Golo/closures.golo new file mode 100755 index 00000000..32378017 --- /dev/null +++ b/samples/Golo/closures.golo @@ -0,0 +1,43 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module Closures + +local function sayHello = |who| -> "Hello " + who + "!" + +function main = |args| { + let adder = |a, b| -> a + b + println(adder: invokeWithArguments(1, 2)) + println(adder(1, 2)) + + let addToTen = adder: bindTo(10) + println(addToTen: invokeWithArguments(2)) + println(addToTen(2)) + + let adding = |x| -> |y| -> adder(x, y) + let addingTen = adding(10) + println(addingTen(4)) + println(adding(2)(4)) + + println(sayHello("Julien")) + + let list = java.util.LinkedList() + let pump_it = { + list: add("I heard you say") + list: add("Hey!") + list: add("Hey!") + } + pump_it() + println(list) +} diff --git a/samples/Golo/coin-change.golo b/samples/Golo/coin-change.golo new file mode 100755 index 00000000..fe82bb04 --- /dev/null +++ b/samples/Golo/coin-change.golo @@ -0,0 +1,34 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module CoinChange + +import java.util.LinkedList + +function change = |money, coins| -> match { + when money == 0 then 1 + when (money < 0) or (coins: isEmpty()) then 0 + otherwise change(money - coins: head(), coins) + change(money, coins: tail()) +} + +function main = |args| { + let coins = LinkedList(): append(1, 2, 5, 10, 20) + println("Coins: " + coins) + println("0: " + change(0, coins)) + println("1: " + change(1, coins)) + println("2: " + change(2, coins)) + println("10: " + change(10, coins)) + println("12: " + change(12, coins)) + println("6: " + change(6, coins)) +} diff --git a/samples/Golo/collection-literals.golo b/samples/Golo/collection-literals.golo new file mode 100755 index 00000000..ac19b35e --- /dev/null +++ b/samples/Golo/collection-literals.golo @@ -0,0 +1,55 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.CollectionLiterals + +local function play_with_tuples = { + let hello = ["Hello", "world", "!"] + foreach str in hello { + print(str + " ") + } + println("") + + println(hello: get(0) + "-" + hello: get(1) + "-" + hello: get(2)) + + println(hello: join("/")) +} + +local function play_with_literals = { + let data = [ + [1, 2, 3], + tuple[1, 2, 3], + array[1, 2, 3], + set[1, 2, 3, 3, 1], + map[ + ["a", 10], + ["b", 20] + ], + vector[1, 2, 3], + list[1, 2, 3] + ] + + data: each(|element| { + println(element: toString()) + println(" type: " + element: getClass()) + }) +} + +function main = |args| { + println(">>> Literals") + play_with_literals() + println("\n>>> Tuples") + play_with_tuples() +} + diff --git a/samples/Golo/context-decorator.golo b/samples/Golo/context-decorator.golo new file mode 100755 index 00000000..6a3bb889 --- /dev/null +++ b/samples/Golo/context-decorator.golo @@ -0,0 +1,53 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.ContextDecorator + +import gololang.Decorators + +let myContext = defaultContext(): + count(0): + define("entry", |this, args| { + this: count(this: count() + 1) + println("hello:" + this: count()) + return args + }): + define("exit", |this, result| { + require(result >= 3, "wrong value") + println("goobye") + return result + }): + define("catcher", |this, e| { + println("Caught " + e) + throw e + }): + define("finallizer", |this| {println("do some cleanup")}) + + +@withContext(myContext) +function foo = |a, b| { + println("Hard computation") + return a + b +} + +function main = |args| { + println(foo(1,2)) + println("====") + println(withContext(myContext)(|a| -> 2*a)(3)) + println("====") + try { + println(foo(1, 1)) + } catch (e) { } +} + diff --git a/samples/Golo/decorators.golo b/samples/Golo/decorators.golo new file mode 100755 index 00000000..c3acbfc4 --- /dev/null +++ b/samples/Golo/decorators.golo @@ -0,0 +1,83 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.Decorators + +import java.util.LinkedList + +function simple_decorator = |func| { + return |a,b| -> func(a+1,b+1) +} + +@simple_decorator +function simple_adder = |x,y| -> x + y + +function decorator_with_params = |param1, param2|{ + return |func| { + return |a,b| -> func(a+param1,b+param2) + } +} + +@decorator_with_params(10,2) +function parametrized_adder = |x,y| -> x + y + +function generic_decorator = |func| { + return |args...| { + println("number of params : "+args: length()) + return func: invokeWithArguments(args) + } +} + +@generic_decorator +function generic_adder0 = -> 42 + +@generic_decorator +function generic_adder1 = |x| -> x + +@generic_decorator +function generic_adder2 = |x,y| -> x + y + +@generic_decorator +function generic_adder3 = |x,y,z| -> x + y + z + +function list_sum_decorator = |func| { + return |this| -> func(this) - 8 +} + +augment java.util.List { + + @list_sum_decorator + function sum = |this| { + var acc = 0 + foreach elem in this { + acc = acc + elem + } + return acc + } +} + +function main = |args| { + println(simple_adder(10,30)) + println(parametrized_adder(10,20)) + println(generic_adder0()) + println(generic_adder1(42)) + println(generic_adder2(20,22)) + println(generic_adder3(10,12,20)) + let list = LinkedList() + list: add(5) + list: add(10) + list: add(15) + list: add(20) + println(list: sum()) +} \ No newline at end of file diff --git a/samples/Golo/dynamic-evaluation.golo b/samples/Golo/dynamic-evaluation.golo new file mode 100755 index 00000000..af5351f4 --- /dev/null +++ b/samples/Golo/dynamic-evaluation.golo @@ -0,0 +1,88 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.DynamicEvaluation + +import gololang.EvaluationEnvironment + +local function test_asModule = |env| { + let code = +""" +module foo + +function a = -> "a!" +function b = -> "b!" +""" + let mod = env: asModule(code) + let a = fun("a", mod) + let b = fun("b", mod) + println(">>> asModule()") + println(a()) + println(b()) +} + +local function test_anonymousModule = |env| { + let code = +""" +function a = -> "a." +function b = -> "b." +""" + let mod = env: anonymousModule(code) + let a = fun("a", mod) + let b = fun("b", mod) + println(">>> anonymousModule()") + println(a()) + println(b()) +} + +local function test_asFunction = |env| { + let code = "return (a + b) * 2" + let f = env: asFunction(code, "a", "b") + println(">>> asFunction") + println(f(10, 20)) +} + +local function test_def = |env| { + let code = "|a, b| -> (a + b) * 2" + let f = env: def(code) + println(">>> def") + println(f(10, 20)) +} + +local function test_run = |env| { + let code = """println(">>> run") + foreach (i in range(0, 3)) { + println("w00t") + }""" + env: run(code) +} + +local function test_run_map = |env| { + let code = """println(">>> run_map") + println(a) + println(b) + """ + let values = java.util.TreeMap(): add("a", 1): add("b", 2) + env: run(code, values) +} + +function main = |args| { + let env = EvaluationEnvironment() + test_asModule(env) + test_anonymousModule(env) + test_asFunction(env) + test_def(env) + test_run(env) + test_run_map(env) +} diff --git a/samples/Golo/dynamic-object-person.golo b/samples/Golo/dynamic-object-person.golo new file mode 100755 index 00000000..27f3ab6d --- /dev/null +++ b/samples/Golo/dynamic-object-person.golo @@ -0,0 +1,29 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.DynamicObjectPerson + +local function mrbean = -> DynamicObject(): + name("Mr Bean"): + email("mrbean@gmail.com"): + define("toString", |this| -> this: name() + " <" + this: email() + ">") + +function main = |args| { + + let bean = mrbean() + println(bean: toString()) + + bean: email("mrbean@outlook.com") + println(bean: toString()) +} diff --git a/samples/Golo/echo-args.golo b/samples/Golo/echo-args.golo new file mode 100755 index 00000000..7bf1e093 --- /dev/null +++ b/samples/Golo/echo-args.golo @@ -0,0 +1,34 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module EchoArgs + +function main = |args| { + + println("With a for loop and an index:") + for (var i = 0, i < args: length(), i = i + 1) { + println(" #" + i + " -> " + args: get(i)) + } + + println("With a foreach loop:") + foreach arg in args { + println(" " + arg) + } + + println("With a foreach over a range:") + foreach i in range(0, args: length()) { + println(" #" + i + " -> " + args: get(i)) + } +} + diff --git a/samples/Golo/enums-thread-state.golo b/samples/Golo/enums-thread-state.golo new file mode 100755 index 00000000..4310ea26 --- /dev/null +++ b/samples/Golo/enums-thread-state.golo @@ -0,0 +1,31 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module sample.EnumsThreadState + +import java.lang.Thread$State + +function main = |args| { + + # Call the enum entry like a function + let new = Thread$State.NEW() + println("name=" + new: name() + ", ordinal=" + new: ordinal()) + println("-----------") + + # Walk through all enum entries + foreach element in Thread$State.values() { + println("name=" + element: name() + ", ordinal=" + element: ordinal()) + } +} + diff --git a/samples/Golo/fibonacci.golo b/samples/Golo/fibonacci.golo new file mode 100755 index 00000000..53455a7d --- /dev/null +++ b/samples/Golo/fibonacci.golo @@ -0,0 +1,39 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.Fibonacci + +import java.lang.System + +function fib = |n| { + if n <= 1 { + return n + } else { + return fib(n - 1) + fib(n - 2) + } +} + +local function run = { + let start = System.currentTimeMillis() + let result = fib(40) + let duration = System.currentTimeMillis() - start + println(">>> " + result + " (took " + duration + "ms)") +} + +function main = |args| { + while true { + run() + } +} + diff --git a/samples/Golo/helloworld.golo b/samples/Golo/helloworld.golo new file mode 100755 index 00000000..4800de6d --- /dev/null +++ b/samples/Golo/helloworld.golo @@ -0,0 +1,20 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module hello.World + +function main = |args| { + println("Hello world!") +} + diff --git a/samples/Golo/http-server.golo b/samples/Golo/http-server.golo new file mode 100755 index 00000000..ce4ff857 --- /dev/null +++ b/samples/Golo/http-server.golo @@ -0,0 +1,53 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.WebServer + +import java.lang +import java.net.InetSocketAddress +import com.sun.net.httpserver +import com.sun.net.httpserver.HttpServer + +function main = |args| { + + let server = HttpServer.create(InetSocketAddress("localhost", 8081), 0) + + server: createContext("/", |exchange| { + let headers = exchange: getResponseHeaders() + let response = StringBuilder(): + append("Requested URI: "): + append(exchange: getRequestURI()): + append("\n"): + append("Current time: "): + append(java.util.Date()): + append("\n"): + toString() + headers: set("Content-Type", "text/plain") + exchange: sendResponseHeaders(200, response: length()) + exchange: getResponseBody(): write(response: getBytes()) + exchange: close() + }) + + server: createContext("/shutdown", |exchange| { + let response = "Ok, thanks, bye!" + exchange: getResponseHeaders(): set("Content-Type", "text/plain") + exchange: sendResponseHeaders(200, response: length()) + exchange: getResponseBody(): write(response: getBytes()) + exchange: close() + server: stop(5) + }) + + server: start() + println(">>> http://localhost:8081/") +} diff --git a/samples/Golo/logdeco.golo b/samples/Golo/logdeco.golo new file mode 100755 index 00000000..ae42a133 --- /dev/null +++ b/samples/Golo/logdeco.golo @@ -0,0 +1,65 @@ + +module samples.LogDeco + +function log1 = |msg| { + return |fun| { + return |args...| { + println(msg) + return fun: invokeWithArguments(args) + } + } +} + +@log1("calling foo") +function foo = |a| { + println("foo got a " + a) +} + +@log1("I'am a bar") +function bar = |a| -> 2*a + +let sayHello = log1("Hello") + +@sayHello +function baz = -> "Goodbye" + +function log2 = |msgBefore| -> |msgAfter| -> |func| -> |args...| { + println(msgBefore) + let res = func: invokeWithArguments(args) + println(msgAfter) + return res +} + +@log2("enter foo")("exit foo") +function spam = |a| { + println("foo: " + a) +} + +function logEnterExit = |name| -> log2("# enter " + name)("# exit " + name) + +@logEnterExit("bar") +function egg = { println("doing something...") } + +function main = |args| { + + foo("bar") + + println("---") + println(bar(21)) + + println("---") + println(baz()) + + println("---") + spam("bar") + + println("---") + egg() + + println("---") + let strange_use = log2("hello")("goodbye")({println(":p")}) + strange_use() + + println("---") + log2("another")("use")(|a|{println(a)})("strange") +} diff --git a/samples/Golo/matching-operator.golo b/samples/Golo/matching-operator.golo new file mode 100755 index 00000000..380d2259 --- /dev/null +++ b/samples/Golo/matching-operator.golo @@ -0,0 +1,40 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module Matching + +import java.util.LinkedList + +local function data = { + let list = LinkedList() + list: add("foo@bar.com") + list: add("+33.6.11.22.33") + list: add("http://golo-lang.org/") + list: add("def foo = bar(_._) with :> T") + return list +} + +local function what_it_could_be = |item| -> match { + when item: contains("@") then "an email?" + when item: startsWith("+33") then "a French phone number?" + when item: startsWith("http://") then "a website URL?" + otherwise "I have no clue, mate!" +} + +function main = |args| { + foreach item in data() { + println(item + " => " + what_it_could_be(item)) + } +} + diff --git a/samples/Golo/max-int.golo b/samples/Golo/max-int.golo new file mode 100755 index 00000000..457a5dff --- /dev/null +++ b/samples/Golo/max-int.golo @@ -0,0 +1,24 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.MaxInt + +local function max_int = { + return java.lang.Integer.MAX_VALUE() +} + +function main = |args| { + println(max_int()) +} + diff --git a/samples/Golo/memoize.golo b/samples/Golo/memoize.golo new file mode 100755 index 00000000..8fb1b455 --- /dev/null +++ b/samples/Golo/memoize.golo @@ -0,0 +1,55 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.MemoizeDecorator + +import gololang.Decorators + +import java.lang.System + +let memo = memoizer() + +@memo +function fib = |n| { + if n <= 1 { + return n + } else { + return fib(n - 1) + fib(n - 2) + } +} + +@memo +function foo = |n| -> n + +local function run = { + let start = System.currentTimeMillis() + let result = fib(40) + let duration = System.currentTimeMillis() - start + println(">>> fib(40) = " + result + " (took " + duration + "ms)") +} + +local function run2 = { + let start = System.currentTimeMillis() + let result = foo(40) + let duration = System.currentTimeMillis() - start + println(">>> foo(40) = " + result + " (took " + duration + "ms)") +} + +function main = |args| { + foreach i in range(0, 5) { + println("run " + i) + run() + run2() + } +} diff --git a/samples/Golo/null-safety.golo b/samples/Golo/null-safety.golo new file mode 100755 index 00000000..903f5309 --- /dev/null +++ b/samples/Golo/null-safety.golo @@ -0,0 +1,43 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module DealingWithNull + +import java.util + +function main = |args| { + + # Data model + let contacts = map[ + ["mrbean", map[ + ["email", "bean@gmail.com"], + ["url", "http://mrbean.com"] + ]], + ["larry", map[ + ["email", "larry@iamricherthanyou.com"] + ]] + ] + + # MrBean and Larry + let mrbean = contacts: get("mrbean") + let larry = contacts: get("larry") + + # Illustrates orIfNull + println(mrbean: get("url") orIfNull "n/a") + println(larry: get("url") orIfNull "n/a") + + # Querying a non-existent data model because there is no 'address' entry + println(mrbean: get("address")?: street()?: number() orIfNull "n/a") +} + diff --git a/samples/Golo/prepost-decorators.golo b/samples/Golo/prepost-decorators.golo new file mode 100755 index 00000000..a7ea73ca --- /dev/null +++ b/samples/Golo/prepost-decorators.golo @@ -0,0 +1,65 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.PrepostDecorator + +import gololang.Decorators + +let isInteger = isOfType(Integer.class) + +@checkResult(isString(): andThen(lengthIs(2))) +@checkArguments(isInteger: andThen(isPositive()), isString()) +function foo = |a, b| { + return b + a +} + +let myCheck = checkArguments(isInteger: andThen(isPositive())) + +@myCheck +function inv = |v| -> 1.0 / v + +let isPositiveInt = isInteger: andThen(isPositive()) + +@checkArguments(isPositiveInt) +function mul = |v| -> 10 * v + +@checkArguments(isNumber()) +function num = |v| -> "ok" + +@checkArguments(isNotNull()) +function notnull = |v| -> "ok" + +function main = |args| { + try { println(foo(1, "b")) } catch (e) { println(e) } + try { println(foo(-1, "b")) } catch (e) { println(e) } + try { println(foo("a", 2)) } catch (e) { println(e) } + try { println(foo(1, 2)) } catch (e) { println(e) } + try { println(foo(10, "ab")) } catch (e) { println(e) } + + try { println(inv(10)) } catch (e) { println(e) } + try { println(inv(0)) } catch (e) { println(e) } + + try { println(mul(5)) } catch (e) { println(e) } + try { println(mul(0)) } catch (e) { println(e) } + + try { println(num(1)) } catch (e) { println(e) } + try { println(num(1_L)) } catch (e) { println(e) } + try { println(num(1.5)) } catch (e) { println(e) } + try { println(num(1.5_F)) } catch (e) { println(e) } + try { println(num("a")) } catch (e) { println(e) } + try { println(num('a')) } catch (e) { println(e) } + + try { println(notnull('1')) } catch (e) { println(e) } + try { println(notnull(null)) } catch (e) { println(e) } +} diff --git a/samples/Golo/structs.golo b/samples/Golo/structs.golo new file mode 100755 index 00000000..de18836a --- /dev/null +++ b/samples/Golo/structs.golo @@ -0,0 +1,69 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module StructDemo + +struct Point = { x, y } + +augment StructDemo.types.Point { + + function move = |this, offsetX, offsetY| { + this: x(this: x() + offsetX) + this: y(this: y() + offsetY) + return this + } + + function relative = |this, offsetX, offsetY| -> Point(this: x() + offsetX, this: y() + offsetY) +} + +function main = |args| { + + let p1 = Point(1, 2) + let p2 = Point(): x(1): y(2) + let p3 = p1: frozenCopy() + let p4 = p1: frozenCopy() + + println(p1) + println("x = " + p1: x()) + println("y = " + p1: y()) + + println("p1 == p2 " + (p1 == p2)) + println("p1 == p3 " + (p1 == p3)) + println("p3 == p4 " + (p3 == p4)) + + println("#p1 " + p1: hashCode()) + println("#p2 " + p2: hashCode()) + println("#p3 " + p3: hashCode()) + println("#p4 " + p4: hashCode()) + + println("p1: members() " + p1: members()) + println("p1: values() " + p1: values()) + foreach item in p1 { + println(item: get(0) + " -> " + item: get(1)) + } + + println("p1: set(\"x\", 10) " + p1: set("x", 10)) + println("p1: move(10, 5) " + p1: move(10, 5)) + println("p1: relative(11, 6) " + p1: relative(11, 6)) + + let p5 = ImmutablePoint(10, 20) + println("p5: " + p5) + try { + p5: x(100) + } catch (expected) { + println("p5 is immutable, so... " + expected: getMessage()) + } +} + + diff --git a/samples/Golo/swing-actionlistener.golo b/samples/Golo/swing-actionlistener.golo new file mode 100755 index 00000000..61d0f7f3 --- /dev/null +++ b/samples/Golo/swing-actionlistener.golo @@ -0,0 +1,43 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.SwingActionListener + +import java.awt.event +import javax.swing +import javax.swing.WindowConstants + +local function listener = |handler| -> asInterfaceInstance(ActionListener.class, handler) + +function main = |args| { + + let frame = JFrame("Action listeners") + frame: setDefaultCloseOperation(EXIT_ON_CLOSE()) + + let button = JButton("Click me!") + button: setFont(button: getFont(): deriveFont(96.0_F)) + + # Using a helper function + button: addActionListener(listener(|event| -> println("Clicked!"))) + + # Using a standard augmentation: MethodHandle::to(Class) + button: addActionListener((|event| -> println("[click]")): to(ActionListener.class)) + + # Straight closure passing + button: addActionListener(|event| -> println("( )")) + + frame: getContentPane(): add(button) + frame: pack() + frame: setVisible(true) +} diff --git a/samples/Golo/swing-helloworld.golo b/samples/Golo/swing-helloworld.golo new file mode 100755 index 00000000..9d5e0541 --- /dev/null +++ b/samples/Golo/swing-helloworld.golo @@ -0,0 +1,31 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.SwingHelloWorld + +import javax.swing +import javax.swing.WindowConstants + +function main = |args| { + + let frame = JFrame("Hello world") + frame: setDefaultCloseOperation(EXIT_ON_CLOSE()) + + let label = JLabel("Hello world") + label: setFont(label: getFont(): deriveFont(128.0_F)) + + frame: getContentPane(): add(label) + frame: pack() + frame: setVisible(true) +} diff --git a/samples/Golo/templates-chat-webapp.golo b/samples/Golo/templates-chat-webapp.golo new file mode 100755 index 00000000..a5eab98b --- /dev/null +++ b/samples/Golo/templates-chat-webapp.golo @@ -0,0 +1,90 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module samples.TemplatesChatWebapp + +import java.lang +import java.io +import java.net.InetSocketAddress +import com.sun.net.httpserver +import com.sun.net.httpserver.HttpServer + +local function redirect = |exchange, to| { + exchange: getResponseHeaders(): set("Location", to) + exchange: sendResponseHeaders(303, 0) + exchange: close() +} + +local function respond = |exchange, body| { + exchange: getResponseHeaders(): set("Content-Type", "text/html") + exchange: sendResponseHeaders(200, body: length()) + exchange: getResponseBody(): write(body: getBytes()) + exchange: close() +} + +# This is leaky and works with just 1 POST parameter... +local function extract_post = |exchange, posts| { + let reader = BufferedReader(InputStreamReader(exchange: getRequestBody())) + var line = reader: readLine() + while line isnt null { + if line: startsWith("msg=") { + posts: add(java.net.URLDecoder.decode(line: substring(4), "UTF-8")) + } + line = reader: readLine() + } + reader: close() +} + + +local function index = |posts, template, exchange| { + if exchange: getRequestMethod() == "POST" { + extract_post(exchange, posts) + redirect(exchange, "/") + } else { + respond(exchange, template(posts)) + } +} + +local function index_template = -> """ +<%@params posts %> + + + + Golo Chat + + +
+ + +
+
+

Last posts

+ <% foreach post in posts { %> +
+ <%= post %> +
+ <% } %> +
+ + +""" + +function main = |args| { + let index_tpl = gololang.TemplateEngine(): compile(index_template()) + let posts = java.util.concurrent.ConcurrentLinkedDeque() + let server = HttpServer.create(InetSocketAddress("localhost", 8081), 0) + server: createContext("/", ^index: bindTo(posts): bindTo(index_tpl)) + server: start() + println(">>> http://localhost:8081/") +} diff --git a/samples/Golo/util-containers.golo b/samples/Golo/util-containers.golo new file mode 100755 index 00000000..63d09b6a --- /dev/null +++ b/samples/Golo/util-containers.golo @@ -0,0 +1,51 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module MoreCoolContainers + +function main = |args| { + + println(">>> DynamicVariable") + + let dyn = DynamicVariable("Foo") + println(dyn: value()) + + let t1 = Thread({ + dyn: withValue(666, { + println(dyn: value()) + }) + }) + + let t2 = Thread({ + dyn: withValue(69, { + println(dyn: value()) + }) + }) + + t1: start() + t2: start() + t1: join() + t2: join() + println(dyn: value()) + + println(">>> Observable") + + let foo = Observable("Foo") + foo: onChange(|v| -> println("foo = " + v)) + + let mapped = foo: map(|v| -> v + "!") + mapped: onChange(|v| -> println("mapped = " + v)) + + foo: set("69") +} diff --git a/samples/Golo/workers.golo b/samples/Golo/workers.golo new file mode 100755 index 00000000..8c08f650 --- /dev/null +++ b/samples/Golo/workers.golo @@ -0,0 +1,48 @@ +# Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) +# +# 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. + +module Workers + +import java.lang.Thread +import java.util.concurrent +import gololang.concurrent.workers.WorkerEnvironment + +local function pusher = |queue, message| -> queue: offer(message) + +local function generator = |port, message| { + foreach i in range(0, 100) { + port: send(message) + } +} + +function main = |args| { + + let env = WorkerEnvironment.builder(): withFixedThreadPool() + let queue = ConcurrentLinkedQueue() + + let pusherPort = env: spawn(^pusher: bindTo(queue)) + let generatorPort = env: spawn(^generator: bindTo(pusherPort)) + + let finishPort = env: spawn(|any| -> env: shutdown()) + + foreach i in range(0, 10) { + generatorPort: send("[" + i + "]") + } + Thread.sleep(2000_L) + finishPort: send("Die!") + + env: awaitTermination(2000) + println(queue: reduce("", |acc, next| -> acc + " " + next)) +} + diff --git a/samples/Gosu/Ronin.gs b/samples/Gosu/Ronin.gs new file mode 100644 index 00000000..dfbdee7b --- /dev/null +++ b/samples/Gosu/Ronin.gs @@ -0,0 +1,238 @@ +/** + * 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. + */ + +package ronin + +uses gw.util.concurrent.LockingLazyVar +uses gw.lang.reflect.* +uses java.lang.* +uses java.io.* +uses ronin.config.* +uses org.slf4j.* + +/** + * The central location for Ronin utility methods. Controllers and templates should generally access the + * methods and properties they inherit from {@link ronin.IRoninUtils} instead of using the methods and + * properties here. + */ +class Ronin { + + // One static field to rule the all... + static var _CONFIG : IRoninConfig as Config + + // And one thread local to bind them + static var _CURRENT_REQUEST = new ThreadLocal(); + + // That's inconstructable + private construct() {} + + internal static function init(servlet : RoninServlet, m : ApplicationMode, src : File) { + if(_CONFIG != null) { + throw "Cannot initialize a Ronin application multiple times!" + } + var cfg = TypeSystem.getByFullNameIfValid("config.RoninConfig") + var defaultWarning = false + if(cfg != null) { + var ctor = cfg.TypeInfo.getConstructor({ronin.config.ApplicationMode, ronin.RoninServlet}) + if(ctor == null) { + throw "config.RoninConfig must have a constructor with the same signature as ronin.config.RoninConfig" + } + _CONFIG = ctor.Constructor.newInstance({m, servlet}) as IRoninConfig + } else { + _CONFIG = new DefaultRoninConfig(m, servlet) + defaultWarning = true + } + var roninLogger = TypeSystem.getByFullNameIfValid("ronin.RoninLoggerFactory") + if(roninLogger != null) { + roninLogger.TypeInfo.getMethod("init", {ronin.config.LogLevel}).CallHandler.handleCall(null, {LogLevel}) + } + if(defaultWarning) { + log("No configuration was found at config.RoninConfig, using the default configuration...", :level=WARN) + } + Quartz.maybeStart() + ReloadManager.setSourceRoot(src) + } + + internal static property set CurrentRequest(req : RoninRequest) { + _CURRENT_REQUEST.set(req) + } + + //============================================ + // Public API + //============================================ + + /** + * The trace handler for the current request. + */ + static property get CurrentTrace() : Trace { + return CurrentRequest?.Trace + } + + /** + * Ronin's representation of the current request. + */ + static property get CurrentRequest() : RoninRequest { + return _CURRENT_REQUEST.get() + } + + /** + * The mode in which this application is running. + */ + static property get Mode() : ApplicationMode { + return _CONFIG?.Mode ?: TESTING + } + + /** + * The log level at and above which log messages should be displayed. + */ + static property get LogLevel() : LogLevel { + return _CONFIG?.LogLevel ?: DEBUG + } + + /** + * Whether or not to display detailed trace information on each request. + */ + static property get TraceEnabled() : boolean { + return _CONFIG != null ? _CONFIG.TraceEnabled : true + } + + /** + * The default controller method to call when no method name is present in the request URL. + */ + static property get DefaultAction() : String { + return _CONFIG?.DefaultAction + } + + /** + * The default controller to call when no controller name is present in the request URL. + */ + static property get DefaultController() : Type { + return _CONFIG?.DefaultController + } + + /** + * The servlet responsible for handling Ronin requests. + */ + static property get RoninServlet() : RoninServlet { + return _CONFIG?.RoninServlet + } + + /** + * The handler for request processing errors. + */ + static property get ErrorHandler() : IErrorHandler { + return _CONFIG?.ErrorHandler + } + + /** + * The custom handler for logging messages. + */ + static property get LogHandler() : ILogHandler { + return _CONFIG?.LogHandler + } + + /** + * Logs a message using the configured log handler. + * @param msg The text of the message to log, or a block which returns said text. + * @param level (Optional) The level at which to log the message. + * @param component (Optional) The logical component from whence the message originated. + * @param exception (Optional) An exception to associate with the message. + */ + static function log(msg : Object, level : LogLevel = null, component : String = null, exception : java.lang.Throwable = null) { + if(level == null) { + level = INFO + } + if(LogLevel <= level) { + var msgStr : String + if(msg typeis block():String) { + msgStr = (msg as block():String)() + } else { + msgStr = msg as String + } + if(_CONFIG?.LogHandler != null) { + _CONFIG.LogHandler.log(msgStr, level, component, exception) + } else { + switch(level) { + case TRACE: + LoggerFactory.getLogger(component?:Logger.ROOT_LOGGER_NAME).trace(msgStr, exception) + break + case DEBUG: + LoggerFactory.getLogger(component?:Logger.ROOT_LOGGER_NAME).debug(msgStr, exception) + break + case INFO: + LoggerFactory.getLogger(component?:Logger.ROOT_LOGGER_NAME).info(msgStr, exception) + break + case WARN: + LoggerFactory.getLogger(component?:Logger.ROOT_LOGGER_NAME).warn(msgStr, exception) + break + case ERROR: + case FATAL: + LoggerFactory.getLogger(component?:Logger.ROOT_LOGGER_NAME).error(msgStr, exception) + break + } + } + } + } + + /** + * The caches known to Ronin. + */ + static enum CacheStore { + REQUEST, + SESSION, + APPLICATION + } + + /** + * Retrieves a value from a cache, or computes and stores it if it is not in the cache. + * @param value A block which will compute the desired value. + * @param name (Optional) A unique identifier for the value. Default is null, which means one will be + * generated from the type of the value. + * @param store (Optional) The cache store used to retrieve or store the value. Default is the request cache. + * @return The retrieved or computed value. + */ + static function cache(value : block():T, name : String = null, store : CacheStore = null) : T { + if(store == null or store == REQUEST) { + return _CONFIG.RequestCache.getValue(value, name) + } else if (store == SESSION) { + return _CONFIG.SessionCache.getValue(value, name) + } else if (store == APPLICATION) { + return _CONFIG.ApplicationCache.getValue(value, name) + } else { + throw "Don't know about CacheStore ${store}" + } + } + + /** + * Invalidates a cached value in a cache. + * @param name The unique identifier for the value. + * @param store The cache store in which to invalidate the value. + */ + static function invalidate(name : String, store : CacheStore) { + if(store == null or store == REQUEST) { + _CONFIG.RequestCache.invalidate(name) + } else if (store == SESSION) { + _CONFIG.SessionCache.invalidate(name) + } else if (store == APPLICATION) { + _CONFIG.ApplicationCache.invalidate(name) + } else { + throw "Don't know about CacheStore ${store}" + } + } + + + /** + * Detects changes made to resources in the Ronin application and + * reloads them. This function should only be called when Ronin is + * in development mode. + */ + static function loadChanges() { + ReloadManager.detectAndReloadChangedResources() + } + +} diff --git a/samples/Gradle/build.gradle b/samples/Gradle/build.gradle new file mode 100644 index 00000000..190eb3f6 --- /dev/null +++ b/samples/Gradle/build.gradle @@ -0,0 +1,18 @@ +apply plugin: GreetingPlugin + +greeting.message = 'Hi from Gradle' + +class GreetingPlugin implements Plugin { + void apply(Project project) { + // Add the 'greeting' extension object + project.extensions.create("greeting", GreetingPluginExtension) + // Add a task that uses the configuration + project.task('hello') << { + println project.greeting.message + } + } +} + +class GreetingPluginExtension { + def String message = 'Hello from GreetingPlugin' +} diff --git a/samples/Gradle/builder.gradle b/samples/Gradle/builder.gradle new file mode 100644 index 00000000..342be2fd --- /dev/null +++ b/samples/Gradle/builder.gradle @@ -0,0 +1,20 @@ +apply plugin: GreetingPlugin + +greeting { + message = 'Hi' + greeter = 'Gradle' +} + +class GreetingPlugin implements Plugin { + void apply(Project project) { + project.extensions.create("greeting", GreetingPluginExtension) + project.task('hello') << { + println "${project.greeting.message} from ${project.greeting.greeter}" + } + } +} + +class GreetingPluginExtension { + String message + String greeter +} diff --git a/samples/Graphviz (DOT)/annoying.DOT b/samples/Graphviz (DOT)/annoying.DOT new file mode 100644 index 00000000..fd20f4a4 --- /dev/null +++ b/samples/Graphviz (DOT)/annoying.DOT @@ -0,0 +1,50 @@ +/* + Huffman Tree DOT graph. + + DOT Reference : http://www.graphviz.org/doc/info/lang.html + http://en.wikipedia.org/wiki/DOT_language + Timestamp : 1415989074 + Phrase : 'OH GOD WHY IS LINGUIST SO ANAL ABOUT THIS STUFF' + + Generated on http://huffman.ooz.ie/ +*/ + +digraph G { + edge [label=0]; + graph [ranksep=0]; + T [shape=record, label="{{T|4}|000}"]; + S [shape=record, label="{{S|5}|001}"]; + SPACE [shape=record, label="{{SPACE|9}|01}"]; + A [shape=record, label="{{A|3}|1000}"]; + H [shape=record, label="{{H|3}|1001}"]; + U [shape=record, label="{{U|3}|1010}"]; + L [shape=record, label="{{L|2}|10110}"]; + N [shape=record, label="{{N|2}|10111}"]; + I [shape=record, label="{{I|4}|1100}"]; + O [shape=record, label="{{O|4}|1101}"]; + G [shape=record, label="{{G|2}|11100}"]; + F [shape=record, label="{{F|2}|11101}"]; + GF [label=4]; + W [shape=record, label="{{W|1}|111100}"]; + Y [shape=record, label="{{Y|1}|111101}"]; + B [shape=record, label="{{B|1}|111110}"]; + D [shape=record, label="{{D|1}|111111}"]; + BD [label=2]; + WYBD [label=4]; + GFWYBD [label=8]; + 47 -> 18 -> 9 -> T; + 29 -> 13 -> 6 -> A; + 7 -> U; + 4 -> L; + 16 -> 8 -> I; + GFWYBD -> GF -> G; + WYBD -> 2 -> W; + BD -> B;9 -> S [label=1]; + 18 -> SPACE [label=1]; + 6 -> H [label=1]; + 13 -> 7 -> 4 -> N [label=1]; + 8 -> O [label=1]; + GF -> F [label=1]; + 2 -> Y [label=1]; + 47 -> 29 -> 16 -> GFWYBD -> WYBD -> BD -> D [label=1]; +} \ No newline at end of file diff --git a/samples/Graphviz (DOT)/sample.dot b/samples/Graphviz (DOT)/sample.dot new file mode 100644 index 00000000..a55dc093 --- /dev/null +++ b/samples/Graphviz (DOT)/sample.dot @@ -0,0 +1,74 @@ +/* + Huffman Tree DOT graph. + + DOT Reference : http://www.graphviz.org/doc/info/lang.html + http://en.wikipedia.org/wiki/DOT_language + Timestamp : 1415988139 + Phrase : 'SERIAL KILLER AND SEX OFFENDER ANGUS SINCLAIR IS JAILED FOR A MINIMUM OF 37 YEARS FOR THE 1977 WORLDS END MURDERS OF HELEN SCOTT AND CHRISTINE EADIE.' + + Generated on http://huffman.ooz.ie/ +*/ + +digraph G { + edge [label=0]; + graph [ranksep=0]; + node [shape=record]; + U [label="{{U|3}|00000}"]; + G [label="{{G|1}|0000100}"]; + K [label="{{K|1}|0000101}"]; + _3 [label="{{3|1}|0000110}"]; + _9 [label="{{9|1}|0000111}"]; + _39 [label=2]; + L [label="{{L|7}|0001}"]; + O [label="{{O|7}|0010}"]; + Y [label="{{Y|1}|0011000}"]; + X [label="{{X|1}|0011001}"]; + YX [label=2]; + J [label="{{J|1}|0011010}"]; + W [label="{{W|1}|0011011}"]; + JW [label=2]; + YXJW [label=4]; + M [label="{{M|4}|00111}"]; + E [label="{{E|15}|010}"]; + D [label="{{D|8}|0110}"]; + T [label="{{T|4}|01110}"]; + DOT [label="{{DOT|1}|0111100}"]; + _1 [label="{{1|1}|0111101}"]; + DOT1 [label=2]; + _7 [label="{{7|3}|011111}"]; + A [label="{{A|9}|1000}"]; + N [label="{{N|9}|1001}"]; + S [label="{{S|10}|1010}"]; + I [label="{{I|11}|1011}"]; + R [label="{{R|11}|1100}"]; + C [label="{{C|3}|110100}"]; + H [label="{{H|3}|110101}"]; + F [label="{{F|6}|11011}"]; + SPACE [label="{{SPACE|26}|111}"]; + 149 -> 61 -> 29 -> 14 -> 7 -> U; + 4 -> 2 -> G; + _39 -> _3; + 15 -> O; + 8 -> YXJW -> YX -> Y; + JW -> J; + 32 -> E; + 17 -> D; + 9 -> T; + 5 -> DOT1 -> DOT; + 88 -> 39 -> 18 -> A; + 21 -> S; + 49 -> 23 -> R; + 12 -> 6 -> C;2 -> K [label=1]; + 7 -> 4 -> _39 -> _9 [label=1]; + 14 -> L [label=1]; + YX -> X [label=1]; + YXJW -> JW -> W [label=1]; + 29 -> 15 -> 8 -> M [label=1]; + DOT1 -> _1 [label=1]; + 61 -> 32 -> 17 -> 9 -> 5 -> _7 [label=1]; + 18 -> N [label=1]; + 39 -> 21 -> I [label=1]; + 6 -> H [label=1]; + 23 -> 12 -> F [label=1]; + 149 -> 88 -> 49 -> SPACE [label=1]; +} \ No newline at end of file diff --git a/samples/HTML/example.xht b/samples/HTML/example.xht new file mode 100644 index 00000000..a49a0a53 --- /dev/null +++ b/samples/HTML/example.xht @@ -0,0 +1,17 @@ + + + + This is a XHTML sample file + + + +
+ Just a simple XHTML test page. +
+ + + diff --git a/samples/HTML/index.html.hl b/samples/HTML/index.html.hl new file mode 100644 index 00000000..65491957 --- /dev/null +++ b/samples/HTML/index.html.hl @@ -0,0 +1,328 @@ + + + + + + + + +
+

Example 1

+ + + + + +
+ + +
+ +

~{x}

+
+
+
+
+ + +
+

Example 2

+ + + + + +
+ + +
+ +

~{x}

+
+
+
+
+ + +
+

Example 3

+ + + + + +
+ + + +
+ +

~{x}

+
+
+
+
+ + +
+

Example 4

+ + + + + +
+ + +
+
+
+ + +
+

Example 5

+ + + + + +
+ + +
+
+
+ + +
+

Example 6

+ + + + + +
+ + +
+
+ +

~{x}

+
+
+
+
+
+ + +
+

Example 7

+ + + + + +
+ + +
+
+ +

~{x}

+
+
+
+
+
+ + +
+

Example 8

+ + + + + +
+ + +
+
+ +

~{x}

+
+
+
+
+
+ + +
+

Example 9

+ + + + + +
+ + +
+
+ + +
+

Example 10

+ + + + + +
+ + + +
+
+ + diff --git a/samples/Hack/Assert.hh b/samples/Hack/Assert.hh new file mode 100644 index 00000000..c80fc87a --- /dev/null +++ b/samples/Hack/Assert.hh @@ -0,0 +1,55 @@ +( + (function(mixed): T) $fn, + mixed $x, + ): array { + if (is_array($x)) { + return array_map($fn, $x); + } + throw new AssertException('Expected an array'); + } +} diff --git a/samples/Hack/AssertRecipe.hh b/samples/Hack/AssertRecipe.hh new file mode 100644 index 00000000..e2f9eabd --- /dev/null +++ b/samples/Hack/AssertRecipe.hh @@ -0,0 +1,52 @@ +> + protected function getDescription(): ?string { + return 'When you have values with unknown types, it is useful to make '. + 'some runtime assertions and have the type checker understand. This '. + 'recipe demonstrates one approach.'; + } + + protected function getFilenames(): Vector { + return Vector { + 'Assert.php', + }; + } + + protected function getDocs(): Vector<(string, string)> { + return Vector{ + tuple ('Mixed Types', 'hack.annotations.mixedtypes'), + tuple ('Type Inference', 'hack.otherrulesandfeatures.typeinference'), + }; + } + + public function getDemoFilename(): string { + return 'demo.php'; + } + + public function getDemoResult(): string { + return assert_main(); + } + + public function getDemoXHP(): ?:xhp { + return null; + } +} diff --git a/samples/Hack/Controller.hh b/samples/Hack/Controller.hh new file mode 100644 index 00000000..a21aacb2 --- /dev/null +++ b/samples/Hack/Controller.hh @@ -0,0 +1,39 @@ +; + abstract protected function getJS(): Set; + abstract protected function getTitle(): string; + abstract protected function render(): :xhp; + + final protected function getHead(): :xhp { + $css = $this->getCSS()->toVector()->map( + ($css) ==> + ); + $js = $this->getJS()->toVector()->map( + ($js) ==>