diff --git a/README.md b/README.md index 472fdb29..8a084513 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ To run the tests: The majority of patches 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 configuration file. -We try to only add languages once they have a some usage on GitHub, so please note in-the-wild usage examples in your pull request. +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. diff --git a/bin/linguist b/bin/linguist index d28aaf7b..c428fa67 100755 --- a/bin/linguist +++ b/bin/linguist @@ -12,8 +12,9 @@ path = ARGV[0] || Dir.pwd if File.directory?(path) repo = Linguist::Repository.from_directory(path) repo.languages.sort_by { |_, size| size }.reverse.each do |language, size| - percentage = ((size / repo.size.to_f) * 100).round - puts "%-4s %s" % ["#{percentage}%", language] + percentage = ((size / repo.size.to_f) * 100) + percentage = sprintf '%.2f' % percentage + puts "%-7s %s" % ["#{percentage}%", language] end elsif File.file?(path) blob = Linguist::FileBlob.new(path, Dir.pwd) diff --git a/github-linguist.gemspec b/github-linguist.gemspec index 71846285..396149f1 100644 --- a/github-linguist.gemspec +++ b/github-linguist.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'github-linguist' - s.version = '2.9.5' + s.version = '2.9.7' s.summary = "GitHub Language detection" s.authors = "GitHub" diff --git a/lib/linguist/generated.rb b/lib/linguist/generated.rb index 424ffbec..db591ae0 100644 --- a/lib/linguist/generated.rb +++ b/lib/linguist/generated.rb @@ -58,7 +58,8 @@ module Linguist generated_parser? || generated_net_docfile? || generated_net_designer_file? || - generated_protocol_buffer? + generated_protocol_buffer? || + generated_jni_header? end # Internal: Is the blob an XCode project file? @@ -181,5 +182,16 @@ module Linguist return lines[0].include?("Generated by the protocol buffer compiler. DO NOT EDIT!") end + + # Internal: Is the blob a C/C++ header generated by the Java JNI tool javah? + # + # Returns true of false. + def generated_jni_header? + return false unless extname == '.h' + return false unless lines.count > 2 + + return lines[0].include?("/* DO NOT EDIT THIS FILE - it is machine generated */") + return lines[1].include?("#include ") + end end end diff --git a/lib/linguist/language.rb b/lib/linguist/language.rb index 0a8d3d54..e043be78 100644 --- a/lib/linguist/language.rb +++ b/lib/linguist/language.rb @@ -15,8 +15,10 @@ module Linguist @index = {} @name_index = {} @alias_index = {} - @extension_index = Hash.new { |h,k| h[k] = [] } - @filename_index = Hash.new { |h,k| h[k] = [] } + + @extension_index = Hash.new { |h,k| h[k] = [] } + @filename_index = Hash.new { |h,k| h[k] = [] } + @primary_extension_index = {} # Valid Languages types TYPES = [:data, :markup, :programming] @@ -63,6 +65,12 @@ module Linguist @extension_index[extension] << language end + if @primary_extension_index.key?(language.primary_extension) + raise ArgumentError, "Duplicate primary extension: #{language.primary_extension}" + end + + @primary_extension_index[language.primary_extension] = language + language.filenames.each do |filename| @filename_index[filename] << language end @@ -148,7 +156,10 @@ module Linguist # Returns all matching Languages or [] if none were found. def self.find_by_filename(filename) basename, extname = File.basename(filename), File.extname(filename) - @filename_index[basename] + @extension_index[extname] + langs = [@primary_extension_index[extname]] + + @filename_index[basename] + + @extension_index[extname] + langs.compact.uniq end # Public: Look up Language by its name or lexer. diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 474f1c79..7afedf3f 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -28,7 +28,13 @@ ABAP: type: programming lexer: ABAP primary_extension: .abap - + +ANTLR: + type: programming + color: "#9DC3FF" + lexer: ANTLR + primary_extension: .g4 + ASP: type: programming color: "#6a40fd" @@ -143,6 +149,11 @@ Befunge: BlitzMax: primary_extension: .bmx +Bluespec: + type: programming + lexer: verilog + primary_extension: .bsv + Boo: type: programming color: "#d4bec1" @@ -190,8 +201,10 @@ C++: - .H - .h++ - .hh + - .hpp - .hxx - .tcc + - .tpp C-ObjDump: type: data @@ -241,14 +254,26 @@ ChucK: lexer: Java primary_extension: .ck +Clean: + type: programming + color: "#3a81ad" + lexer: Text only + primary_extension: .icl + extensions: + - .dcl + Clojure: type: programming ace_mode: clojure color: "#db5855" primary_extension: .clj extensions: + - .cl2 + - .cljc - .cljs + - .cljscm - .cljx + - .hic filenames: - riemann.config @@ -287,6 +312,7 @@ Common Lisp: primary_extension: .lisp extensions: - .asd + - .cl - .lsp - .ny - .podsl @@ -326,6 +352,14 @@ D-ObjDump: type: data lexer: d-objdump primary_extension: .d-objdump + +DM: + type: programming + color: "#075ff1" + lexer: Text only + primary_extension: .dm + aliases: + - byond DOT: type: programming @@ -354,7 +388,7 @@ DCPU-16 ASM: - .dasm aliases: - dasm16 - + Diff: primary_extension: .diff @@ -393,7 +427,6 @@ Elixir: Elm: type: programming lexer: Haskell - group: Haskell primary_extension: .elm Emacs Lisp: @@ -519,6 +552,12 @@ Gettext Catalog: extensions: - .pot +Glyph: + type: programming + color: "#e4cc98" + lexer: Tcl + primary_extension: .glf + Go: type: programming color: "#a89b4d" @@ -605,6 +644,10 @@ Handlebars: type: markup lexer: Text only primary_extension: .handlebars + extensions: + - .hbs + - .html.handlebars + - .html.hbs Haskell: type: programming @@ -615,7 +658,6 @@ Haskell: Haxe: type: programming - lexer: haXe ace_mode: haxe color: "#346d51" primary_extension: .hx @@ -630,6 +672,17 @@ INI: - .properties primary_extension: .ini +Idris: + type: programming + lexer: Text only + primary_extension: .idr + extensions: + - .lidr + +Inno Setup: + primary_extension: .iss + lexer: Text only + IRC log: lexer: IRC logs search_term: irc @@ -649,12 +702,30 @@ Ioke: color: "#078193" primary_extension: .ik +J: + type: programming + lexer: Text only + primary_extension: .ijs + JSON: type: data group: JavaScript ace_mode: json searchable: false primary_extension: .json + extensions: + - .sublime-keymap + - .sublime_metrics + - .sublime-mousemap + - .sublime-project + - .sublime_session + - .sublime-settings + - .sublime-workspace + +Jade: + group: HTML + type: markup + primary_extension: .jade Java: type: programming @@ -695,6 +766,13 @@ JavaScript: Julia: type: programming primary_extension: .jl + color: "#a270ba" + +KRL: + lexer: Text only + type: programming + color: "#f5c800" + primary_extension: .krl Kotlin: type: programming @@ -799,7 +877,9 @@ M: lexer: Common Lisp aliases: - mumps - primary_extension: .m + primary_extension: .mumps + extensions: + - .m Makefile: aliases: @@ -1058,6 +1138,9 @@ PowerShell: aliases: - posh primary_extension: .ps1 + extensions: + - .psd1 + - .psm1 Processing: type: programming @@ -1072,6 +1155,13 @@ Prolog: extensions: - .pro +Protocol Buffer: + type: markup + aliases: + - protobuf + - Protocol Buffers + primary_extension: .proto + Puppet: type: programming color: "#cc5555" @@ -1108,11 +1198,31 @@ Python traceback: searchable: false primary_extension: .pytb +QML: + type: markup + color: "#44a51c" + primary_extension: .qml + R: type: programming color: "#198ce7" lexer: S primary_extension: .r + extensions: + - .R + filenames: + - .Rprofile + +REALbasic: + type: programming + lexer: VB.net + primary_extension: .rbbas + extensions: + - .rbfrm + - .rbmnu + - .rbres + - .rbtbar + - .rbuistate RHTML: type: markup @@ -1152,6 +1262,12 @@ Rebol: Redcode: primary_extension: .cw +RobotFramework: + type: programming + primary_extension: .robot + # extensions: + # - .txt + Rouge: type: programming lexer: Clojure @@ -1175,6 +1291,7 @@ Ruby: - .gemspec - .god - .irbrc + - .mspec - .podspec - .rbuild - .rbw @@ -1224,6 +1341,11 @@ Scala: color: "#7dd3b0" primary_extension: .scala +Scaml: + group: HTML + type: markup + primary_extension: .scaml + Scheme: type: programming color: "#1e4aec" @@ -1253,6 +1375,7 @@ Shell: - zsh primary_extension: .sh extensions: + - .bats - .tmux filenames: - Dockerfile @@ -1301,6 +1424,8 @@ Tcl: type: programming color: "#e4cc98" primary_extension: .tcl + extensions: + - .adp Tcsh: type: programming @@ -1317,9 +1442,13 @@ TeX: primary_extension: .tex extensions: - .aux + - .bib - .dtx - .ins - .ltx + - .mkii + - .mkiv + - .mkvi - .sty - .toc @@ -1351,7 +1480,6 @@ Twig: TypeScript: type: programming color: "#31859c" - lexer: Text only aliases: - ts primary_extension: .ts @@ -1395,6 +1523,7 @@ VimL: - vim primary_extension: .vim filenames: + - .vimrc - vimrc - gvimrc @@ -1405,6 +1534,7 @@ Visual Basic: primary_extension: .vb extensions: - .bas + - .frm - .frx - .vba - .vbs @@ -1431,14 +1561,19 @@ XML: extensions: - .axml - .ccxml + - .clixml + - .cproject - .dita - .ditamap - .ditaval - .glade - .grxml + - .jelly - .kml - .mxml - .plist + - .ps1xml + - .psc1 - .pt - .rdf - .rss @@ -1481,6 +1616,8 @@ XQuery: primary_extension: .xquery extensions: - .xq + - .xql + - .xqm - .xqy XS: diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index 56a3d875..32d17697 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -18,6 +18,9 @@ "Awk": [ ".awk" ], + "Bluespec": [ + ".bsv" + ], "C": [ ".c", ".h" @@ -41,6 +44,9 @@ "CoffeeScript": [ ".coffee" ], + "Common Lisp": [ + ".lisp" + ], "Coq": [ ".v" ], @@ -135,6 +141,9 @@ "Less": [ ".less" ], + "LFE": [ + ".lfe" + ], "Literate CoffeeScript": [ ".litcoffee" ], @@ -296,6 +305,9 @@ "Slash": [ ".sl" ], + "Squirrel": [ + ".nut" + ], "Standard ML": [ ".sig", ".sml" @@ -412,8 +424,8 @@ ".gemrc" ] }, - "tokens_total": 411886, - "languages_total": 447, + "tokens_total": 415313, + "languages_total": 458, "tokens": { "ABAP": { "*/**": 1, @@ -1902,20 +1914,215 @@ "fragments": 1, "END": 1 }, + "Bluespec": { + "package": 2, + "TbTL": 1, + ";": 156, + "import": 1, + "TL": 6, + "*": 1, + "interface": 2, + "Lamp": 3, + "method": 42, + "Bool": 32, + "changed": 2, + "Action": 17, + "show_offs": 2, + "show_ons": 2, + "reset": 2, + "endinterface": 2, + "module": 3, + "mkLamp#": 1, + "(": 158, + "String": 1, + "name": 3, + "lamp": 5, + ")": 163, + "Reg#": 15, + "prev": 5, + "<": 44, + "-": 29, + "mkReg": 15, + "False": 9, + "if": 9, + "&&": 3, + "write": 2, + "+": 7, + "endmethod": 8, + "endmodule": 3, + "mkTest": 1, + "let": 1, + "dut": 2, + "sysTL": 3, + "Bit#": 1, + "ctr": 8, + "carN": 4, + "carS": 2, + "carE": 2, + "carW": 2, + "lamps": 15, + "[": 17, + "]": 17, + "mkLamp": 12, + "dut.lampRedNS": 1, + "dut.lampAmberNS": 1, + "dut.lampGreenNS": 1, + "dut.lampRedE": 1, + "dut.lampAmberE": 1, + "dut.lampGreenE": 1, + "dut.lampRedW": 1, + "dut.lampAmberW": 1, + "dut.lampGreenW": 1, + "dut.lampRedPed": 1, + "dut.lampAmberPed": 1, + "dut.lampGreenPed": 1, + "rule": 10, + "start": 1, + "dumpvars": 1, + "endrule": 10, + "detect_cars": 1, + "dut.set_car_state_N": 1, + "dut.set_car_state_S": 1, + "dut.set_car_state_E": 1, + "dut.set_car_state_W": 1, + "go": 1, + "True": 6, + "<=>": 3, + "12_000": 1, + "ped_button_push": 4, + "stop": 1, + "display": 2, + "finish": 1, + "function": 10, + "do_offs": 2, + "l": 3, + "l.show_offs": 1, + "do_ons": 2, + "l.show_ons": 1, + "do_reset": 2, + "l.reset": 1, + "do_it": 4, + "f": 2, + "action": 3, + "for": 3, + "Integer": 3, + "i": 15, + "endaction": 3, + "endfunction": 7, + "any_changes": 2, + "b": 12, + "||": 7, + ".changed": 1, + "return": 9, + "show": 1, + "time": 1, + "endpackage": 2, + "set_car_state_N": 2, + "x": 8, + "set_car_state_S": 2, + "set_car_state_E": 2, + "set_car_state_W": 2, + "lampRedNS": 2, + "lampAmberNS": 2, + "lampGreenNS": 2, + "lampRedE": 2, + "lampAmberE": 2, + "lampGreenE": 2, + "lampRedW": 2, + "lampAmberW": 2, + "lampGreenW": 2, + "lampRedPed": 2, + "lampAmberPed": 2, + "lampGreenPed": 2, + "typedef": 3, + "enum": 1, + "{": 1, + "AllRed": 4, + "GreenNS": 9, + "AmberNS": 5, + "GreenE": 8, + "AmberE": 5, + "GreenW": 8, + "AmberW": 5, + "GreenPed": 4, + "AmberPed": 3, + "}": 1, + "TLstates": 11, + "deriving": 1, + "Eq": 1, + "Bits": 1, + "UInt#": 2, + "Time32": 9, + "CtrSize": 3, + "allRedDelay": 2, + "amberDelay": 2, + "nsGreenDelay": 2, + "ewGreenDelay": 3, + "pedGreenDelay": 1, + "pedAmberDelay": 1, + "clocks_per_sec": 2, + "state": 21, + "next_green": 8, + "secs": 7, + "ped_button_pushed": 4, + "car_present_N": 3, + "car_present_S": 3, + "car_present_E": 4, + "car_present_W": 4, + "car_present_NS": 3, + "cycle_ctr": 6, + "dec_cycle_ctr": 1, + "Rules": 5, + "low_priority_rule": 2, + "rules": 4, + "inc_sec": 1, + "endrules": 4, + "next_state": 8, + "ns": 4, + "0": 2, + "green_seq": 7, + "case": 2, + "endcase": 2, + "car_present": 4, + "make_from_green_rule": 5, + "green_state": 2, + "delay": 2, + "car_is_present": 2, + "from_green": 1, + "make_from_amber_rule": 5, + "amber_state": 2, + "ng": 2, + "from_amber": 1, + "hprs": 10, + "7": 1, + "1": 1, + "2": 1, + "3": 1, + "4": 1, + "5": 1, + "6": 1, + "fromAllRed": 2, + "else": 4, + "noAction": 1, + "high_priority_rules": 4, + "rJoin": 1, + "addRules": 1, + "preempts": 1 + }, "C": { - "#include": 149, - "const": 357, + "#include": 150, + "const": 358, "char": 529, "*blob_type": 2, - ";": 5439, + ";": 5446, "struct": 359, "blob": 6, "*lookup_blob": 2, - "(": 6213, + "(": 6225, "unsigned": 140, "*sha1": 16, - ")": 6215, - "{": 1528, + ")": 6227, + "{": 1530, "object": 10, "*obj": 9, "lookup_object": 2, @@ -1932,22 +2139,22 @@ "sha1_to_hex": 8, "typename": 2, "NULL": 330, - "}": 1544, - "*": 253, + "}": 1546, + "*": 259, "int": 446, "parse_blob_buffer": 2, "*item": 10, - "void": 279, + "void": 284, "*buffer": 6, "long": 105, "size": 120, "item": 24, "object.parsed": 4, - "#ifndef": 84, + "#ifndef": 85, "BLOB_H": 2, - "#define": 911, - "extern": 37, - "#endif": 236, + "#define": 912, + "extern": 38, + "#endif": 239, "git_cache_init": 1, "git_cache": 4, "*cache": 4, @@ -1973,8 +2180,8 @@ "i": 410, "for": 88, "+": 551, - "[": 597, - "]": 597, + "[": 601, + "]": 601, "git_cached_obj_decref": 3, "git__free": 15, "*git_cache_get": 1, @@ -2002,7 +2209,7 @@ "else": 190, "save_commit_buffer": 3, "*commit_type": 2, - "static": 454, + "static": 455, "commit": 59, "*check_commit": 1, "quiet": 5, @@ -2280,7 +2487,7 @@ "": 1, "": 1, "": 1, - "#ifdef": 64, + "#ifdef": 66, "CONFIG_SMP": 1, "DEFINE_MUTEX": 1, "cpu_add_remove_lock": 3, @@ -3329,7 +3536,7 @@ "paused": 3, "HPE_PAUSED": 2, "http_parser_h": 2, - "__cplusplus": 18, + "__cplusplus": 20, "HTTP_PARSER_VERSION_MAJOR": 1, "HTTP_PARSER_VERSION_MINOR": 1, "": 2, @@ -3420,6 +3627,22 @@ "*http_method_str": 1, "*http_errno_name": 1, "*http_errno_description": 1, + "": 1, + "_Included_jni_JniLayer": 2, + "JNIEXPORT": 6, + "jlong": 6, + "JNICALL": 6, + "Java_jni_JniLayer_jni_1layer_1initialize": 1, + "JNIEnv": 6, + "jobject": 6, + "jintArray": 1, + "jint": 7, + "Java_jni_JniLayer_jni_1layer_1mainloop": 1, + "Java_jni_JniLayer_jni_1layer_1set_1button": 1, + "Java_jni_JniLayer_jni_1layer_1set_1analog": 1, + "jfloat": 1, + "Java_jni_JniLayer_jni_1layer_1report_1analog_1chg": 1, + "Java_jni_JniLayer_jni_1layer_1kill": 1, "strncasecmp": 2, "_strnicmp": 1, "REF_TABLE_SIZE": 1, @@ -6455,6 +6678,13 @@ "__pyx_pf_7sklearn_12linear_model_8sgd_fast_10Regression_loss": 1, "__pyx_base.__pyx_vtab": 1, "__pyx_base.loss": 1, + "syscalldef": 1, + "syscalldefs": 1, + "SYSCALL_OR_NUM": 3, + "SYS_restart_syscall": 1, + "MAKE_UINT16": 3, + "SYS_exit": 1, + "SYS_fork": 1, "__wglew_h__": 2, "__WGLEW_H__": 1, "__wglext_h_": 2, @@ -10603,6 +10833,49 @@ "xFF": 1, "ip.join": 1 }, + "Common Lisp": { + ";": 10, + "-": 10, + "*": 2, + "lisp": 1, + "(": 14, + "in": 1, + "package": 1, + "foo": 2, + ")": 14, + "Header": 1, + "comment.": 4, + "defvar": 1, + "*foo*": 1, + "eval": 1, + "when": 1, + "execute": 1, + "compile": 1, + "toplevel": 2, + "load": 1, + "defun": 1, + "add": 1, + "x": 5, + "&": 3, + "optional": 1, + "y": 2, + "key": 1, + "z": 2, + "declare": 1, + "ignore": 1, + "Inline": 1, + "+": 2, + "or": 1, + "#": 2, + "|": 2, + "Multi": 1, + "line": 2, + "defmacro": 1, + "body": 1, + "b": 1, + "if": 1, + "After": 1 + }, "Coq": { "Inductive": 41, "day": 9, @@ -22937,6 +23210,338 @@ "/": 2, "margin": 1 }, + "LFE": { + ";": 213, + "Copyright": 4, + "(": 217, + "c": 4, + ")": 231, + "Duncan": 4, + "McGreggor": 4, + "": 2, + "Licensed": 3, + "under": 9, + "the": 36, + "Apache": 3, + "License": 12, + "Version": 3, + "you": 3, + "may": 6, + "not": 5, + "use": 6, + "this": 3, + "file": 6, + "except": 3, + "in": 10, + "compliance": 3, + "with": 8, + "License.": 6, + "You": 3, + "obtain": 3, + "a": 8, + "copy": 3, + "of": 10, + "at": 4, + "http": 4, + "//www.apache.org/licenses/LICENSE": 3, + "-": 98, + "Unless": 3, + "required": 3, + "by": 4, + "applicable": 3, + "law": 3, + "or": 6, + "agreed": 3, + "to": 10, + "writing": 3, + "software": 3, + "distributed": 6, + "is": 5, + "on": 4, + "an": 5, + "BASIS": 3, + "WITHOUT": 3, + "WARRANTIES": 3, + "OR": 3, + "CONDITIONS": 3, + "OF": 3, + "ANY": 3, + "KIND": 3, + "either": 3, + "express": 3, + "implied.": 3, + "See": 3, + "for": 5, + "specific": 3, + "language": 3, + "governing": 3, + "permissions": 3, + "and": 7, + "limitations": 3, + "File": 4, + "church.lfe": 1, + "Author": 3, + "Purpose": 3, + "Demonstrating": 2, + "church": 20, + "numerals": 1, + "from": 2, + "lambda": 18, + "calculus": 1, + "The": 4, + "code": 2, + "below": 3, + "was": 1, + "used": 1, + "create": 4, + "section": 1, + "user": 1, + "guide": 1, + "here": 1, + "//lfe.github.io/user": 1, + "guide/recursion/5.html": 1, + "Here": 1, + "some": 2, + "example": 2, + "usage": 1, + "slurp": 2, + "five/0": 2, + "int2": 1, + "get": 21, + "defmodule": 2, + "export": 2, + "all": 1, + "defun": 20, + "zero": 2, + "s": 19, + "x": 12, + "one": 1, + "funcall": 23, + "two": 1, + "three": 1, + "four": 1, + "five": 1, + "int": 2, + "successor": 3, + "n": 4, + "+": 2, + "int1": 1, + "numeral": 8, + "#": 3, + "successor/1": 1, + "count": 7, + "limit": 4, + "cond": 1, + "/": 1, + "integer": 2, + "*": 6, + "Mode": 1, + "LFE": 4, + "Code": 1, + "Paradigms": 1, + "Artificial": 1, + "Intelligence": 1, + "Programming": 1, + "Peter": 1, + "Norvig": 1, + "gps1.lisp": 1, + "First": 1, + "version": 1, + "GPS": 1, + "General": 1, + "Problem": 1, + "Solver": 1, + "Converted": 1, + "Robert": 3, + "Virding": 3, + "Define": 1, + "macros": 1, + "global": 2, + "variable": 2, + "access.": 1, + "This": 2, + "hack": 1, + "very": 1, + "naughty": 1, + "defsyntax": 2, + "defvar": 2, + "[": 3, + "name": 8, + "val": 2, + "]": 3, + "let": 6, + "v": 3, + "put": 1, + "getvar": 3, + "solved": 1, + "gps": 1, + "state": 4, + "goals": 2, + "Set": 1, + "variables": 1, + "but": 1, + "existing": 1, + "*ops*": 1, + "*state*": 5, + "current": 1, + "list": 13, + "conditions.": 1, + "if": 1, + "every": 1, + "fun": 1, + "achieve": 1, + "op": 8, + "action": 3, + "setvar": 2, + "set": 1, + "difference": 1, + "del": 5, + "union": 1, + "add": 3, + "drive": 1, + "son": 2, + "school": 2, + "preconds": 4, + "shop": 6, + "installs": 1, + "battery": 1, + "car": 1, + "works": 1, + "make": 2, + "communication": 2, + "telephone": 1, + "have": 3, + "phone": 1, + "book": 1, + "give": 1, + "money": 3, + "has": 1, + "mnesia_demo.lfe": 1, + "A": 1, + "simple": 4, + "Mnesia": 2, + "demo": 2, + "LFE.": 1, + "contains": 1, + "using": 1, + "access": 1, + "tables.": 1, + "It": 1, + "shows": 2, + "how": 2, + "emp": 1, + "XXXX": 1, + "macro": 1, + "ETS": 1, + "match": 5, + "pattern": 1, + "together": 1, + "mnesia": 8, + "match_object": 1, + "specifications": 1, + "select": 1, + "Query": 2, + "List": 2, + "Comprehensions.": 1, + "mnesia_demo": 1, + "new": 2, + "by_place": 1, + "by_place_ms": 1, + "by_place_qlc": 2, + "defrecord": 1, + "person": 8, + "place": 7, + "job": 3, + "Start": 1, + "table": 2, + "we": 1, + "will": 1, + "memory": 1, + "only": 1, + "schema.": 1, + "start": 1, + "create_table": 1, + "attributes": 1, + "Initialise": 1, + "table.": 1, + "people": 1, + "spec": 1, + "p": 2, + "j": 2, + "when": 1, + "tuple": 1, + "transaction": 2, + "f": 3, + "Use": 1, + "Comprehensions": 1, + "records": 1, + "q": 2, + "qlc": 2, + "lc": 1, + "<": 1, + "e": 1, + "object.lfe": 1, + "OOP": 1, + "closures": 1, + "object": 16, + "system": 1, + "demonstrated": 1, + "do": 2, + "following": 2, + "objects": 2, + "call": 2, + "methods": 5, + "those": 1, + "which": 1, + "can": 1, + "other": 1, + "update": 1, + "instance": 2, + "Note": 1, + "however": 1, + "that": 1, + "his": 1, + "does": 1, + "demonstrate": 1, + "inheritance.": 1, + "To": 1, + "cd": 1, + "examples": 1, + "../bin/lfe": 1, + "pa": 1, + "../ebin": 1, + "Load": 1, + "fish": 6, + "class": 3, + "#Fun": 1, + "": 1, + "Execute": 1, + "basic": 1, + "species": 7, + "mommy": 3, + "move": 4, + "Carp": 1, + "swam": 1, + "feet": 1, + "ok": 1, + "id": 9, + "Now": 1, + "strictly": 1, + "necessary.": 1, + "When": 1, + "isn": 1, + "children": 10, + "formatted": 1, + "verb": 2, + "self": 6, + "distance": 2, + "erlang": 1, + "length": 1, + "method": 7, + "define": 1, + "info": 1, + "reproduce": 1 + }, "Literate CoffeeScript": { "The": 2, "**Scope**": 2, @@ -30546,23 +31151,23 @@ "OpenCL": { "double": 3, "run_fftw": 1, - "(": 11, + "(": 18, "int": 3, - "n": 2, - "const": 2, - "float": 2, - "*": 4, - "x": 2, - "y": 2, - ")": 11, - "{": 2, + "n": 4, + "const": 4, + "float": 3, + "*": 5, + "x": 5, + "y": 4, + ")": 18, + "{": 4, "fftwf_plan": 1, "p1": 3, "fftwf_plan_dft_1d": 1, "fftwf_complex": 2, "FFTW_FORWARD": 1, "FFTW_ESTIMATE": 1, - ";": 9, + ";": 12, "nops": 3, "t": 4, "cl": 2, @@ -30570,13 +31175,30 @@ "for": 1, "op": 3, "<": 1, - "+": 2, + "+": 4, "fftwf_execute": 1, - "}": 2, + "}": 4, "-": 1, "/": 1, "fftwf_destroy_plan": 1, - "return": 1 + "return": 1, + "typedef": 1, + "foo_t": 3, + "#ifndef": 1, + "ZERO": 3, + "#define": 2, + "#endif": 1, + "FOO": 1, + "__kernel": 1, + "void": 1, + "foo": 1, + "__global": 1, + "__local": 1, + "uint": 1, + "barrier": 1, + "CLK_LOCAL_MEM_FENCE": 1, + "if": 1, + "*x": 1 }, "OpenEdge ABL": { "USING": 3, @@ -37994,6 +38616,57 @@ "ast.eval": 1, "Env.new": 1 }, + "Squirrel": { + "//example": 1, + "from": 1, + "http": 1, + "//www.squirrel": 1, + "-": 1, + "lang.org/#documentation": 1, + "local": 3, + "table": 1, + "{": 10, + "a": 2, + "subtable": 1, + "array": 3, + "[": 3, + "]": 3, + "}": 10, + "+": 2, + "b": 1, + ";": 15, + "foreach": 1, + "(": 10, + "i": 1, + "val": 2, + "in": 1, + ")": 10, + "print": 2, + "typeof": 1, + "/////////////////////////////////////////////": 1, + "class": 2, + "Entity": 3, + "constructor": 2, + "etype": 2, + "entityname": 4, + "name": 2, + "type": 2, + "x": 2, + "y": 2, + "z": 2, + "null": 2, + "function": 2, + "MoveTo": 1, + "newx": 2, + "newy": 2, + "newz": 2, + "Player": 2, + "extends": 1, + "base.constructor": 1, + "DoDomething": 1, + "newplayer": 1, + "newplayer.MoveTo": 1 + }, "Standard ML": { "signature": 2, "LAZY_BASE": 3, @@ -38516,17 +39189,17 @@ "Animal": 4, "{": 9, "constructor": 3, - "(": 17, + "(": 18, "public": 1, "name": 5, - ")": 17, + ")": 18, "}": 9, "move": 3, "meters": 2, "alert": 3, "this.name": 1, "+": 3, - ";": 7, + ";": 8, "Snake": 2, "extends": 2, "super": 2, @@ -40854,11 +41527,13 @@ "Arduino": 20, "AutoHotkey": 3, "Awk": 544, - "C": 58732, + "Bluespec": 1298, + "C": 58858, "C++": 21480, "Ceylon": 50, "COBOL": 90, "CoffeeScript": 2951, + "Common Lisp": 103, "Coq": 18259, "CSS": 43867, "Dart": 68, @@ -40886,6 +41561,7 @@ "Kotlin": 155, "Lasso": 9849, "Less": 39, + "LFE": 1711, "Literate CoffeeScript": 275, "LiveScript": 123, "Logos": 93, @@ -40907,7 +41583,7 @@ "OCaml": 382, "Omgrofl": 57, "Opa": 28, - "OpenCL": 88, + "OpenCL": 144, "OpenEdge ABL": 762, "Parrot Assembly": 6, "Parrot Internal Representation": 5, @@ -40932,13 +41608,14 @@ "SCSS": 39, "Shell": 3744, "Slash": 187, + "Squirrel": 130, "Standard ML": 243, "SuperCollider": 268, "Tea": 3, "TeX": 1155, "Turing": 44, "TXL": 213, - "TypeScript": 106, + "TypeScript": 109, "Verilog": 3778, "VHDL": 42, "VimL": 20, @@ -40961,11 +41638,13 @@ "Arduino": 1, "AutoHotkey": 1, "Awk": 1, - "C": 24, + "Bluespec": 2, + "C": 26, "C++": 20, "Ceylon": 1, "COBOL": 4, "CoffeeScript": 9, + "Common Lisp": 1, "Coq": 12, "CSS": 2, "Dart": 1, @@ -40993,6 +41672,7 @@ "Kotlin": 1, "Lasso": 4, "Less": 1, + "LFE": 4, "Literate CoffeeScript": 1, "LiveScript": 1, "Logos": 1, @@ -41014,7 +41694,7 @@ "OCaml": 2, "Omgrofl": 1, "Opa": 2, - "OpenCL": 1, + "OpenCL": 2, "OpenEdge ABL": 5, "Parrot Assembly": 1, "Parrot Internal Representation": 1, @@ -41039,6 +41719,7 @@ "SCSS": 1, "Shell": 37, "Slash": 1, + "Squirrel": 1, "Standard ML": 2, "SuperCollider": 2, "Tea": 1, @@ -41060,5 +41741,5 @@ "Xtend": 2, "YAML": 1 }, - "md5": "04aab6477c2dc5ef1be1c9de1886c3f3" + "md5": "e1daa29f986e203ade56a02091d24c99" } \ No newline at end of file diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index 8967c266..1e106812 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -12,6 +12,9 @@ # Caches - cache/ +# Dependencies +- ^[Dd]ependencies/ + # C deps # https://github.com/joyent/node - ^deps/ @@ -27,8 +30,12 @@ # Erlang bundles - ^rebar$ +# Bootstrap minified css and js +- (^|/)bootstrap([^.]*)(\.min)\.(js|css)$ + # Vendored dependencies -- vendor/ +- thirdparty/ +- vendors?/ # Debian packaging - ^debian/ @@ -37,7 +44,7 @@ # jQuery - (^|/)jquery([^.]*)(\.min)?\.js$ -- (^|/)jquery\-\d\.\d(\.\d)?(\.min)?\.js$ +- (^|/)jquery\-\d\.\d+(\.\d+)?(\.min)?\.js$ # jQuery UI - (^|/)jquery\-ui(\-\d\.\d+(\.\d+)?)?(\.\w+)?(\.min)?\.(js|css)$ @@ -86,6 +93,8 @@ # WAF - ^waf$ +# .osx +- ^.osx$ ## Obj-C ## @@ -108,7 +117,22 @@ - ^[Pp]ackages/ # ExtJS -- (^|/)extjs/ +- (^|/)extjs/.*?\.js$ +- (^|/)extjs/.*?\.xml$ +- (^|/)extjs/.*?\.txt$ +- (^|/)extjs/.*?\.html$ +- (^|/)extjs/.*?\.properties$ +- (^|/)extjs/.sencha/ +- (^|/)extjs/docs/ +- (^|/)extjs/builds/ +- (^|/)extjs/cmd/ +- (^|/)extjs/examples/ +- (^|/)extjs/locale/ +- (^|/)extjs/packages/ +- (^|/)extjs/plugins/ +- (^|/)extjs/resources/ +- (^|/)extjs/src/ +- (^|/)extjs/welcome/ # Samples folders - ^[Ss]amples/ @@ -125,5 +149,12 @@ # Test fixtures - ^[Tt]est/fixtures/ +# PhoneGap/Cordova +- (^|/)cordova([^.]*)(\.min)?\.js$ +- (^|/)cordova\-\d\.\d(\.\d)?(\.min)?\.js$ + +# Vagrant +- ^Vagrantfile$ + # .DS_Store's - .[Dd][Ss]_[Ss]tore$ diff --git a/samples/Bluespec/TL.bsv b/samples/Bluespec/TL.bsv new file mode 100644 index 00000000..2d6af5c1 --- /dev/null +++ b/samples/Bluespec/TL.bsv @@ -0,0 +1,167 @@ +package TL; + +interface TL; + method Action ped_button_push(); + + (* always_enabled *) + method Action set_car_state_N(Bool x); + (* always_enabled *) + method Action set_car_state_S(Bool x); + (* always_enabled *) + method Action set_car_state_E(Bool x); + (* always_enabled *) + method Action set_car_state_W(Bool x); + + method Bool lampRedNS(); + method Bool lampAmberNS(); + method Bool lampGreenNS(); + + method Bool lampRedE(); + method Bool lampAmberE(); + method Bool lampGreenE(); + + method Bool lampRedW(); + method Bool lampAmberW(); + method Bool lampGreenW(); + + method Bool lampRedPed(); + method Bool lampAmberPed(); + method Bool lampGreenPed(); +endinterface: TL + +typedef enum { + AllRed, + GreenNS, AmberNS, + GreenE, AmberE, + GreenW, AmberW, + GreenPed, AmberPed} TLstates deriving (Eq, Bits); + +typedef UInt#(5) Time32; +typedef UInt#(20) CtrSize; + +(* synthesize *) +module sysTL(TL); + Time32 allRedDelay = 2; + Time32 amberDelay = 4; + Time32 nsGreenDelay = 20; + Time32 ewGreenDelay = 10; + Time32 pedGreenDelay = 10; + Time32 pedAmberDelay = 6; + + CtrSize clocks_per_sec = 100; + + Reg#(TLstates) state <- mkReg(AllRed); + Reg#(TLstates) next_green <- mkReg(GreenNS); + Reg#(Time32) secs <- mkReg(0); + Reg#(Bool) ped_button_pushed <- mkReg(False); + Reg#(Bool) car_present_N <- mkReg(True); + Reg#(Bool) car_present_S <- mkReg(True); + Reg#(Bool) car_present_E <- mkReg(True); + Reg#(Bool) car_present_W <- mkReg(True); + Bool car_present_NS = car_present_N || car_present_S; + Reg#(CtrSize) cycle_ctr <- mkReg(0); + + rule dec_cycle_ctr (cycle_ctr != 0); + cycle_ctr <= cycle_ctr - 1; + endrule + + Rules low_priority_rule = (rules + rule inc_sec (cycle_ctr == 0); + secs <= secs + 1; + cycle_ctr <= clocks_per_sec; + endrule endrules); + + function Action next_state(TLstates ns); + action + state <= ns; + secs <= 0; + endaction + endfunction: next_state + + function TLstates green_seq(TLstates x); + case (x) + GreenNS: return (GreenE); + GreenE: return (GreenW); + GreenW: return (GreenNS); + endcase + endfunction + + function Bool car_present(TLstates x); + case (x) + GreenNS: return (car_present_NS); + GreenE: return (car_present_E); + GreenW: return (car_present_W); + endcase + endfunction + + function Rules make_from_green_rule(TLstates green_state, Time32 delay, Bool car_is_present, TLstates ns); + return (rules + rule from_green (state == green_state && (secs >= delay || !car_is_present)); + next_state(ns); + endrule endrules); + endfunction: make_from_green_rule + + function Rules make_from_amber_rule(TLstates amber_state, TLstates ng); + return (rules + rule from_amber (state == amber_state && secs >= amberDelay); + next_state(AllRed); + next_green <= ng; + endrule endrules); + endfunction: make_from_amber_rule + + Rules hprs[7]; + + hprs[1] = make_from_green_rule(GreenNS, nsGreenDelay, car_present_NS, AmberNS); + hprs[2] = make_from_amber_rule(AmberNS, GreenE); + hprs[3] = make_from_green_rule(GreenE, ewGreenDelay, car_present_E, AmberE); + hprs[4] = make_from_amber_rule(AmberE, GreenW); + hprs[5] = make_from_green_rule(GreenW, ewGreenDelay, car_present_W, AmberW); + hprs[6] = make_from_amber_rule(AmberW, GreenNS); + + hprs[0] = (rules + rule fromAllRed (state == AllRed && secs >= allRedDelay); + if (ped_button_pushed) action + ped_button_pushed <= False; + next_state(GreenPed); + endaction else if (car_present(next_green)) + next_state(next_green); + else if (car_present(green_seq(next_green))) + next_state(green_seq(next_green)); + else if (car_present(green_seq(green_seq(next_green)))) + next_state(green_seq(green_seq(next_green))); + else + noAction; + endrule: fromAllRed endrules); + + Rules high_priority_rules = hprs[0]; + for (Integer i = 1; i<7; i=i+1) + high_priority_rules = rJoin(hprs[i], high_priority_rules); + + addRules(preempts(high_priority_rules, low_priority_rule)); + + method Action ped_button_push(); + ped_button_pushed <= True; + endmethod: ped_button_push + + method Action set_car_state_N(b) ; car_present_N <= b; endmethod + method Action set_car_state_S(b) ; car_present_S <= b; endmethod + method Action set_car_state_E(b) ; car_present_E <= b; endmethod + method Action set_car_state_W(b) ; car_present_W <= b; endmethod + + method lampRedNS() = (!(state == GreenNS || state == AmberNS)); + method lampAmberNS() = (state == AmberNS); + method lampGreenNS() = (state == GreenNS); + method lampRedE() = (!(state == GreenE || state == AmberE)); + method lampAmberE() = (state == AmberE); + method lampGreenE() = (state == GreenE); + method lampRedW() = (!(state == GreenW || state == AmberW)); + method lampAmberW() = (state == AmberW); + method lampGreenW() = (state == GreenW); + + method lampRedPed() = (!(state == GreenPed || state == AmberPed)); + method lampAmberPed() = (state == AmberPed); + method lampGreenPed() = (state == GreenPed); + +endmodule: sysTL + +endpackage: TL diff --git a/samples/Bluespec/TbTL.bsv b/samples/Bluespec/TbTL.bsv new file mode 100644 index 00000000..d5dbabf0 --- /dev/null +++ b/samples/Bluespec/TbTL.bsv @@ -0,0 +1,109 @@ +package TbTL; + +import TL::*; + +interface Lamp; + method Bool changed; + method Action show_offs; + method Action show_ons; + method Action reset; +endinterface + +module mkLamp#(String name, Bool lamp)(Lamp); + Reg#(Bool) prev <- mkReg(False); + + method changed = (prev != lamp); + + method Action show_offs; + if (prev && !lamp) + $write (name + " off, "); + endmethod + + method Action show_ons; + if (!prev && lamp) + $write (name + " on, "); + endmethod + + method Action reset; + prev <= lamp; + endmethod +endmodule + + +(* synthesize *) +module mkTest(); + let dut <- sysTL; + + Reg#(Bit#(16)) ctr <- mkReg(0); + + Reg#(Bool) carN <- mkReg(False); + Reg#(Bool) carS <- mkReg(False); + Reg#(Bool) carE <- mkReg(False); + Reg#(Bool) carW <- mkReg(False); + + Lamp lamps[12]; + + lamps[0] <- mkLamp("0: NS red ", dut.lampRedNS); + lamps[1] <- mkLamp("1: NS amber", dut.lampAmberNS); + lamps[2] <- mkLamp("2: NS green", dut.lampGreenNS); + lamps[3] <- mkLamp("3: E red ", dut.lampRedE); + lamps[4] <- mkLamp("4: E amber", dut.lampAmberE); + lamps[5] <- mkLamp("5: E green", dut.lampGreenE); + lamps[6] <- mkLamp("6: W red ", dut.lampRedW); + lamps[7] <- mkLamp("7: W amber", dut.lampAmberW); + lamps[8] <- mkLamp("8: W green", dut.lampGreenW); + + lamps[9] <- mkLamp("9: Ped red ", dut.lampRedPed); + lamps[10] <- mkLamp("10: Ped amber", dut.lampAmberPed); + lamps[11] <- mkLamp("11: Ped green", dut.lampGreenPed); + + rule start (ctr == 0); + $dumpvars; + endrule + + rule detect_cars; + dut.set_car_state_N(carN); + dut.set_car_state_S(carS); + dut.set_car_state_E(carE); + dut.set_car_state_W(carW); + endrule + + rule go; + ctr <= ctr + 1; + if (ctr == 5000) carN <= True; + if (ctr == 6500) carN <= False; + if (ctr == 12_000) dut.ped_button_push; + endrule + + rule stop (ctr > 32768); + $display("TESTS FINISHED"); + $finish(0); + endrule + + function do_offs(l) = l.show_offs; + function do_ons(l) = l.show_ons; + function do_reset(l) = l.reset; + + function do_it(f); + action + for (Integer i=0; i<12; i=i+1) + f(lamps[i]); + endaction + endfunction + + function any_changes(); + Bool b = False; + for (Integer i=0; i<12; i=i+1) + b = b || lamps[i].changed; + return b; + endfunction + + rule show (any_changes()); + do_it(do_offs); + do_it(do_ons); + do_it(do_reset); + $display("(at time %d)", $time); + endrule +endmodule + +endpackage diff --git a/samples/C/jni_layer.h b/samples/C/jni_layer.h new file mode 100644 index 00000000..ededf805 --- /dev/null +++ b/samples/C/jni_layer.h @@ -0,0 +1,61 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class jni_JniLayer */ + +#ifndef _Included_jni_JniLayer +#define _Included_jni_JniLayer +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: jni_JniLayer + * Method: jni_layer_initialize + * Signature: ([II)J + */ +JNIEXPORT jlong JNICALL Java_jni_JniLayer_jni_1layer_1initialize + (JNIEnv *, jobject, jintArray, jint, jint); + +/* + * Class: jni_JniLayer + * Method: jni_layer_mainloop + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_jni_JniLayer_jni_1layer_1mainloop + (JNIEnv *, jobject, jlong); + +/* + * Class: jni_JniLayer + * Method: jni_layer_set_button + * Signature: (JII)V + */ +JNIEXPORT void JNICALL Java_jni_JniLayer_jni_1layer_1set_1button + (JNIEnv *, jobject, jlong, jint, jint); + +/* + * Class: jni_JniLayer + * Method: jni_layer_set_analog + * Signature: (JIIF)V + */ +JNIEXPORT void JNICALL Java_jni_JniLayer_jni_1layer_1set_1analog + (JNIEnv *, jobject, jlong, jint, jint, jfloat); + +/* + * Class: jni_JniLayer + * Method: jni_layer_report_analog_chg + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_jni_JniLayer_jni_1layer_1report_1analog_1chg + (JNIEnv *, jobject, jlong, jint); + +/* + * Class: jni_JniLayer + * Method: jni_layer_kill + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_jni_JniLayer_jni_1layer_1kill + (JNIEnv *, jobject, jlong); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/samples/C/syscalldefs.h b/samples/C/syscalldefs.h new file mode 100644 index 00000000..a29c867e --- /dev/null +++ b/samples/C/syscalldefs.h @@ -0,0 +1,5 @@ +static const syscalldef syscalldefs[] = { + [SYSCALL_OR_NUM(0, SYS_restart_syscall)] = MAKE_UINT16(0, 1), + [SYSCALL_OR_NUM(1, SYS_exit)] = MAKE_UINT16(1, 17), + [SYSCALL_OR_NUM(2, SYS_fork)] = MAKE_UINT16(0, 22), +}; diff --git a/samples/Clojure/for.clj b/samples/Clojure/for.clj new file mode 100644 index 00000000..725f7b2d --- /dev/null +++ b/samples/Clojure/for.clj @@ -0,0 +1,17 @@ +(defn prime? [n] + (not-any? zero? (map #(rem n %) (range 2 n)))) + +(range 3 33 2) +'(3 5 7 9 11 13 15 17 19 21 23 25 27 29 31) + +;; :when continues through the collection even if some have the +;; condition evaluate to false, like filter +(for [x (range 3 33 2) :when (prime? x)] + x) +'(3 5 7 11 13 17 19 23 29 31) + +;; :while stops at the first collection element that evaluates to +;; false, like take-while +(for [x (range 3 33 2) :while (prime? x)] + x) +'(3 5 7) diff --git a/samples/Clojure/hiccup.hic b/samples/Clojure/hiccup.hic new file mode 100644 index 00000000..318f03da --- /dev/null +++ b/samples/Clojure/hiccup.hic @@ -0,0 +1,8 @@ +[:html + [:head + [:meta {:charset "utf-8"}] + [:link {:rel "stylesheet" :href "css/bootstrap.min.css"}] + [:script {:src "app.js"}]] + [:body + [:div.nav + [:p "Hello world!"]]]] diff --git a/samples/Clojure/into-array.cljc b/samples/Clojure/into-array.cljc new file mode 100644 index 00000000..a1c9fa29 --- /dev/null +++ b/samples/Clojure/into-array.cljc @@ -0,0 +1,13 @@ +(defn into-array + ([aseq] + (into-array nil aseq)) + ([type aseq] + (let [n (count aseq) + a (make-array n)] + (loop [aseq (seq aseq) + i 0] + (if (< i n) + (do + (aset a i (first aseq)) + (recur (next aseq) (inc i))) + a))))) diff --git a/samples/Clojure/protocol.cljs b/samples/Clojure/protocol.cljs new file mode 100644 index 00000000..5496ac0c --- /dev/null +++ b/samples/Clojure/protocol.cljs @@ -0,0 +1,15 @@ +(defprotocol ISound (sound [])) + +(deftype Cat [] + ISound + (sound [_] "Meow!")) + +(deftype Dog [] + ISound + (sound [_] "Woof!")) + +(extend-type default + ISound + (sound [_] "... silence ...")) + +(sound 1) ;; => "... silence ..." diff --git a/samples/Clojure/rand.cljscm b/samples/Clojure/rand.cljscm new file mode 100644 index 00000000..ca07579d --- /dev/null +++ b/samples/Clojure/rand.cljscm @@ -0,0 +1,5 @@ +(defn rand + "Returns a random floating point number between 0 (inclusive) and + n (default 1) (exclusive)." + ([] (scm* [n] (random-real))) + ([n] (* (rand) n))) \ No newline at end of file diff --git a/samples/Clojure/svg.cljx b/samples/Clojure/svg.cljx new file mode 100644 index 00000000..dd2206d4 --- /dev/null +++ b/samples/Clojure/svg.cljx @@ -0,0 +1,20 @@ +^:clj (ns c2.svg + (:use [c2.core :only [unify]] + [c2.maths :only [Pi Tau radians-per-degree + sin cos mean]])) + +^:cljs (ns c2.svg + (:use [c2.core :only [unify]] + [c2.maths :only [Pi Tau radians-per-degree + sin cos mean]]) + (:require [c2.dom :as dom])) + +;;Stub for float fn, which does not exist on cljs runtime +^:cljs (def float identity) + +(defn ->xy + "Convert coordinates (potentially map of `{:x :y}`) to 2-vector." + [coordinates] + (cond + (and (vector? coordinates) (= 2 (count coordinates))) coordinates + (map? coordinates) [(:x coordinates) (:y coordinates)])) diff --git a/samples/Clojure/unit-test.cl2 b/samples/Clojure/unit-test.cl2 new file mode 100644 index 00000000..bac21586 --- /dev/null +++ b/samples/Clojure/unit-test.cl2 @@ -0,0 +1,20 @@ +(deftest function-tests + (is (= 3 + (count [1 2 3]))) + (is (= false + (not true))) + (is (= true + (contains? {:foo 1 :bar 2} :foo))) + + (is (= {"foo" 1, "baz" 3} + (select-keys {:foo 1 :bar 2 :baz 3} [:foo :baz]))) + + (is (= [1 2 3] + (vals {:foo 1 :bar 2 :baz 3}))) + + (is (= ["foo" "bar" "baz"] + (keys {:foo 1 :bar 2 :baz 3}))) + + (is (= [2 4 6] + (filter (fn [x] (=== (rem x 2) 0)) [1 2 3 4 5 6])))) + diff --git a/samples/Common Lisp/sample.lisp b/samples/Common Lisp/sample.lisp new file mode 100644 index 00000000..9bef6781 --- /dev/null +++ b/samples/Common Lisp/sample.lisp @@ -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/DM/example.dm b/samples/DM/example.dm new file mode 100644 index 00000000..b8f1fad4 --- /dev/null +++ b/samples/DM/example.dm @@ -0,0 +1,87 @@ +// This is a single line comment. +/* + This is a multi-line comment +*/ + +// Pre-processor keywords + +#define PI 3.1415 + +#if PI == 4 + +#define G 5 + +#elif PI == 3 + +#define I 6 + +#else + +#define K 7 + +#endif + + +var/GlobalCounter = 0 +var/const/CONST_VARIABLE = 2 +var/list/MyList = list("anything", 1, new /datum/entity) +var/list/EmptyList[99] // creates a list of 99 null entries +var/list/NullList = null + +/* + Entity Class +*/ + +/datum/entity + var/name = "Entity" + var/number = 0 + +/datum/entity/proc/myFunction() + world.log << "Entity has called myFunction" + +/datum/entity/New() + number = GlobalCounter++ + +/* + Unit Class, Extends from Entity +*/ + +/datum/entity/unit + name = "Unit" + +/datum/entity/unit/New() + ..() // calls the parent's proc; equal to super() and base() in other languages + number = rand(1, 99) + +/datum/entity/unit/myFunction() + world.log << "Unit has overriden and called myFunction" + +// Global Function +/proc/ReverseList(var/list/input) + var/list/output = list() + for(var/i = input.len; i >= 1; i--) // IMPORTANT: List Arrays count from 1. + output += input[i] // "+= x" is ".Add(x)" + return output + +// Bitflags +/proc/DoStuff() + var/bitflag = 0 + bitflag |= 8 + return bitflag + +/proc/DoOtherStuff() + var/bitflag = 65535 // 16 bits is the maximum amount + bitflag &= ~8 + return bitflag + +// Logic +/proc/DoNothing() + var/pi = PI + if(pi == 4) + world.log << "PI is 4" + else if(pi == CONST_VARIABLE) + world.log << "PI is [CONST_VARIABLE]!" + else + world.log << "PI is approximety [pi]" + +#undef PI // Undefine PI \ No newline at end of file diff --git a/samples/Idris/Chars.idr b/samples/Idris/Chars.idr new file mode 100644 index 00000000..7e3e3e86 --- /dev/null +++ b/samples/Idris/Chars.idr @@ -0,0 +1,42 @@ +module Prelude.Char + +import Builtins + +isUpper : Char -> Bool +isUpper x = x >= 'A' && x <= 'Z' + +isLower : Char -> Bool +isLower x = x >= 'a' && x <= 'z' + +isAlpha : Char -> Bool +isAlpha x = isUpper x || isLower x + +isDigit : Char -> Bool +isDigit x = (x >= '0' && x <= '9') + +isAlphaNum : Char -> Bool +isAlphaNum x = isDigit x || isAlpha x + +isSpace : Char -> Bool +isSpace x = x == ' ' || x == '\t' || x == '\r' || + x == '\n' || x == '\f' || x == '\v' || + x == '\xa0' + +isNL : Char -> Bool +isNL x = x == '\r' || x == '\n' + +toUpper : Char -> Char +toUpper x = if (isLower x) + then (prim__intToChar (prim__charToInt x - 32)) + else x + +toLower : Char -> Char +toLower x = if (isUpper x) + then (prim__intToChar (prim__charToInt x + 32)) + else x + +isHexDigit : Char -> Bool +isHexDigit x = elem (toUpper x) hexChars where + hexChars : List Char + hexChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F'] diff --git a/samples/Jade/hello.jade b/samples/Jade/hello.jade new file mode 100644 index 00000000..32c72739 --- /dev/null +++ b/samples/Jade/hello.jade @@ -0,0 +1,3 @@ +p. + Hello, + World! diff --git a/samples/KRL/helloworld.krl b/samples/KRL/helloworld.krl new file mode 100644 index 00000000..0daf048b --- /dev/null +++ b/samples/KRL/helloworld.krl @@ -0,0 +1,15 @@ +ruleset sample { + meta { + name "Hello World" + description << +Hello world +>> + author "Phil Windley" + } + + // just one rule + rule hello { + select when web pageview + notify("Hello world!", "Just a note to say hello"); + } +} diff --git a/samples/OpenCL/sample.cl b/samples/OpenCL/sample.cl new file mode 100644 index 00000000..9360b8e3 --- /dev/null +++ b/samples/OpenCL/sample.cl @@ -0,0 +1,23 @@ +/* Old-style comment. */ + +// New-style comment. + +typedef float foo_t; + +#ifndef ZERO +#define ZERO (0.0) +#endif + +#define FOO(x) ((x) + \ + ZERO) + +__kernel +void foo(__global const foo_t * x, __local foo_t y, const uint n) +{ + barrier(CLK_LOCAL_MEM_FENCE); + + if (n > 42) { + *x += y; + } +} + diff --git a/samples/Protocol Buffer/addressbook.proto b/samples/Protocol Buffer/addressbook.proto new file mode 100644 index 00000000..2dee2965 --- /dev/null +++ b/samples/Protocol Buffer/addressbook.proto @@ -0,0 +1,27 @@ +package tutorial; + +option java_package = "com.example.tutorial"; +option java_outer_classname = "AddressBookProtos"; + +message Person { + required string name = 1; + required int32 id = 2; + optional string email = 3; + + enum PhoneType { + MOBILE = 0; + HOME = 1; + WORK = 2; + } + + message PhoneNumber { + required string number = 1; + optional PhoneType type = 2 [default = HOME]; + } + + repeated PhoneNumber phone = 4; +} + +message AddressBook { + repeated Person person = 1; +} diff --git a/samples/RobotFramework/data_driven.robot b/samples/RobotFramework/data_driven.robot new file mode 100644 index 00000000..4f02837a --- /dev/null +++ b/samples/RobotFramework/data_driven.robot @@ -0,0 +1,45 @@ +*** Settings *** +Documentation Example test cases using the data-driven testing approach. +... +... Tests use `Calculate` keyword created in this file, that in +... turn uses keywords in `CalculatorLibrary`. An exception is +... the last test that has a custom _template keyword_. +... +... The data-driven style works well when you need to repeat +... the same workflow multiple times. +... +... Notice that one of these tests fails on purpose to show how +... failures look like. +Test Template Calculate +Library CalculatorLibrary + +*** Test Cases *** Expression Expected +Addition 12 + 2 + 2 16 + 2 + -3 -1 + +Subtraction 12 - 2 - 2 8 + 2 - -3 5 + +Multiplication 12 * 2 * 2 48 + 2 * -3 -6 + +Division 12 / 2 / 2 3 + 2 / -3 -1 + +Failing 1 + 1 3 + +Calculation error [Template] Calculation should fail + kekkonen Invalid button 'k'. + ${EMPTY} Invalid expression. + 1 / 0 Division by zero. + +*** Keywords *** +Calculate + [Arguments] ${expression} ${expected} + Push buttons C${expression}= + Result should be ${expected} + +Calculation should fail + [Arguments] ${expression} ${expected} + ${error} = Should cause error C${expression}= + Should be equal ${expected} ${error} # Using `BuiltIn` keyword diff --git a/samples/RobotFramework/gherkin.robot b/samples/RobotFramework/gherkin.robot new file mode 100644 index 00000000..34b69865 --- /dev/null +++ b/samples/RobotFramework/gherkin.robot @@ -0,0 +1,33 @@ +*** Settings *** +Documentation Example test case using the gherkin syntax. +... +... This test has a workflow similar to the keyword-driven +... examples. The difference is that the keywords use higher +... abstraction level and their arguments are embedded into +... the keyword names. +... +... This kind of _gherkin_ syntax has been made popular by +... [http://cukes.info|Cucumber]. It works well especially when +... tests act as examples that need to be easily understood also +... by the business people. +Library CalculatorLibrary + +*** Test Cases *** +Addition + Given calculator has been cleared + When user types "1 + 1" + and user pushes equals + Then result is "2" + +*** Keywords *** +Calculator has been cleared + Push button C + +User types "${expression}" + Push buttons ${expression} + +User pushes equals + Push button = + +Result is "${result}" + Result should be ${result} diff --git a/samples/RobotFramework/keyword_driven.robot b/samples/RobotFramework/keyword_driven.robot new file mode 100644 index 00000000..6f85c813 --- /dev/null +++ b/samples/RobotFramework/keyword_driven.robot @@ -0,0 +1,37 @@ +*** Settings *** +Documentation Example test cases using the keyword-driven testing approach. +... +... All tests contain a workflow constructed from keywords in +... `CalculatorLibrary`. Creating new tests or editing existing +... is easy even for people without programming skills. +... +... This kind of style works well for normal test automation. +... If also business people need to understand tests, using +... _gherkin_ style may work better. +Library CalculatorLibrary + +*** Test Cases *** +Push button + Push button 1 + Result should be 1 + +Push multiple buttons + Push button 1 + Push button 2 + Result should be 12 + +Simple calculation + Push button 1 + Push button + + Push button 2 + Push button = + Result should be 3 + +Longer calculation + Push buttons 5 + 4 - 3 * 2 / 1 = + Result should be 3 + +Clear + Push button 1 + Push button C + Result should be ${EMPTY} # ${EMPTY} is a built-in variable diff --git a/samples/Scaml/hello.scaml b/samples/Scaml/hello.scaml new file mode 100644 index 00000000..accbf543 --- /dev/null +++ b/samples/Scaml/hello.scaml @@ -0,0 +1,3 @@ +%p + Hello, + World! diff --git a/samples/TypeScript/hello.ts b/samples/TypeScript/hello.ts index 4b65a573..184dfcc9 100644 --- a/samples/TypeScript/hello.ts +++ b/samples/TypeScript/hello.ts @@ -1 +1 @@ -console.log "Hello, World!" +console.log("Hello, World!"); diff --git a/test/test_blob.rb b/test/test_blob.rb index 3dd90a99..7a1821d8 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -198,6 +198,9 @@ class TestBlob < Test::Unit::TestCase assert blob("Java/ProtocolBuffer.java").generated? assert blob("Python/protocol_buffer_pb2.py").generated? + # Generated JNI + assert blob("C/jni_layer.h").generated? + # Minified CSS assert !blob("CSS/bootstrap.css").generated? assert blob("CSS/bootstrap.min.css").generated? @@ -207,12 +210,18 @@ class TestBlob < Test::Unit::TestCase assert !blob("Text/README").vendored? assert !blob("ext/extconf.rb").vendored? + # Dependencies + assert blob("dependencies/windows/headers/GL/glext.h").vendored? + # Node dependencies assert blob("node_modules/coffee-script/lib/coffee-script.js").vendored? # Rails vendor/ assert blob("vendor/plugins/will_paginate/lib/will_paginate.rb").vendored? + # 'thirdparty' directory + assert blob("thirdparty/lib/main.c").vendored? + # C deps assert blob("deps/http_parser/http_parser.c").vendored? assert blob("deps/v8/src/v8.h").vendored? @@ -236,6 +245,8 @@ class TestBlob < Test::Unit::TestCase assert blob("public/javascripts/jquery-1.5.2.js").vendored? assert blob("public/javascripts/jquery-1.6.1.js").vendored? assert blob("public/javascripts/jquery-1.6.1.min.js").vendored? + assert blob("public/javascripts/jquery-1.10.1.js").vendored? + assert blob("public/javascripts/jquery-1.10.1.min.js").vendored? assert !blob("public/javascripts/jquery.github.menu.js").vendored? # jQuery UI @@ -307,6 +318,15 @@ class TestBlob < Test::Unit::TestCase # Test fixtures assert blob("test/fixtures/random.rkt").vendored? assert blob("Test/fixtures/random.rkt").vendored? + + # Cordova/PhoneGap + assert blob("cordova.js").vendored? + assert blob("cordova.min.js").vendored? + assert blob("cordova-2.1.0.js").vendored? + assert blob("cordova-2.1.0.min.js").vendored? + + # Vagrant + assert blob("Vagrantfile").vendored? end def test_language