Conflicts:
	lib/linguist/languages.yml
This commit is contained in:
Tim Baumann
2013-11-05 16:55:48 +01:00
32 changed files with 1729 additions and 60 deletions

View File

@@ -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. 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. 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.

View File

@@ -12,8 +12,9 @@ path = ARGV[0] || Dir.pwd
if File.directory?(path) if File.directory?(path)
repo = Linguist::Repository.from_directory(path) repo = Linguist::Repository.from_directory(path)
repo.languages.sort_by { |_, size| size }.reverse.each do |language, size| repo.languages.sort_by { |_, size| size }.reverse.each do |language, size|
percentage = ((size / repo.size.to_f) * 100).round percentage = ((size / repo.size.to_f) * 100)
puts "%-4s %s" % ["#{percentage}%", language] percentage = sprintf '%.2f' % percentage
puts "%-7s %s" % ["#{percentage}%", language]
end end
elsif File.file?(path) elsif File.file?(path)
blob = Linguist::FileBlob.new(path, Dir.pwd) blob = Linguist::FileBlob.new(path, Dir.pwd)

View File

@@ -1,6 +1,6 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = 'github-linguist' s.name = 'github-linguist'
s.version = '2.9.5' s.version = '2.9.7'
s.summary = "GitHub Language detection" s.summary = "GitHub Language detection"
s.authors = "GitHub" s.authors = "GitHub"

View File

@@ -58,7 +58,8 @@ module Linguist
generated_parser? || generated_parser? ||
generated_net_docfile? || generated_net_docfile? ||
generated_net_designer_file? || generated_net_designer_file? ||
generated_protocol_buffer? generated_protocol_buffer? ||
generated_jni_header?
end end
# Internal: Is the blob an XCode project file? # 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!") return lines[0].include?("Generated by the protocol buffer compiler. DO NOT EDIT!")
end 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 <jni.h>")
end
end end
end end

View File

@@ -15,8 +15,10 @@ module Linguist
@index = {} @index = {}
@name_index = {} @name_index = {}
@alias_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 # Valid Languages types
TYPES = [:data, :markup, :programming] TYPES = [:data, :markup, :programming]
@@ -63,6 +65,12 @@ module Linguist
@extension_index[extension] << language @extension_index[extension] << language
end 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| language.filenames.each do |filename|
@filename_index[filename] << language @filename_index[filename] << language
end end
@@ -148,7 +156,10 @@ module Linguist
# Returns all matching Languages or [] if none were found. # Returns all matching Languages or [] if none were found.
def self.find_by_filename(filename) def self.find_by_filename(filename)
basename, extname = File.basename(filename), File.extname(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 end
# Public: Look up Language by its name or lexer. # Public: Look up Language by its name or lexer.

View File

@@ -29,6 +29,12 @@ ABAP:
lexer: ABAP lexer: ABAP
primary_extension: .abap primary_extension: .abap
ANTLR:
type: programming
color: "#9DC3FF"
lexer: ANTLR
primary_extension: .g4
ASP: ASP:
type: programming type: programming
color: "#6a40fd" color: "#6a40fd"
@@ -143,6 +149,11 @@ Befunge:
BlitzMax: BlitzMax:
primary_extension: .bmx primary_extension: .bmx
Bluespec:
type: programming
lexer: verilog
primary_extension: .bsv
Boo: Boo:
type: programming type: programming
color: "#d4bec1" color: "#d4bec1"
@@ -190,8 +201,10 @@ C++:
- .H - .H
- .h++ - .h++
- .hh - .hh
- .hpp
- .hxx - .hxx
- .tcc - .tcc
- .tpp
C-ObjDump: C-ObjDump:
type: data type: data
@@ -241,14 +254,26 @@ ChucK:
lexer: Java lexer: Java
primary_extension: .ck primary_extension: .ck
Clean:
type: programming
color: "#3a81ad"
lexer: Text only
primary_extension: .icl
extensions:
- .dcl
Clojure: Clojure:
type: programming type: programming
ace_mode: clojure ace_mode: clojure
color: "#db5855" color: "#db5855"
primary_extension: .clj primary_extension: .clj
extensions: extensions:
- .cl2
- .cljc
- .cljs - .cljs
- .cljscm
- .cljx - .cljx
- .hic
filenames: filenames:
- riemann.config - riemann.config
@@ -287,6 +312,7 @@ Common Lisp:
primary_extension: .lisp primary_extension: .lisp
extensions: extensions:
- .asd - .asd
- .cl
- .lsp - .lsp
- .ny - .ny
- .podsl - .podsl
@@ -327,6 +353,14 @@ D-ObjDump:
lexer: d-objdump lexer: d-objdump
primary_extension: .d-objdump primary_extension: .d-objdump
DM:
type: programming
color: "#075ff1"
lexer: Text only
primary_extension: .dm
aliases:
- byond
DOT: DOT:
type: programming type: programming
lexer: Text only lexer: Text only
@@ -393,7 +427,6 @@ Elixir:
Elm: Elm:
type: programming type: programming
lexer: Haskell lexer: Haskell
group: Haskell
primary_extension: .elm primary_extension: .elm
Emacs Lisp: Emacs Lisp:
@@ -519,6 +552,12 @@ Gettext Catalog:
extensions: extensions:
- .pot - .pot
Glyph:
type: programming
color: "#e4cc98"
lexer: Tcl
primary_extension: .glf
Go: Go:
type: programming type: programming
color: "#a89b4d" color: "#a89b4d"
@@ -605,6 +644,10 @@ Handlebars:
type: markup type: markup
lexer: Text only lexer: Text only
primary_extension: .handlebars primary_extension: .handlebars
extensions:
- .hbs
- .html.handlebars
- .html.hbs
Haskell: Haskell:
type: programming type: programming
@@ -615,7 +658,6 @@ Haskell:
Haxe: Haxe:
type: programming type: programming
lexer: haXe
ace_mode: haxe ace_mode: haxe
color: "#346d51" color: "#346d51"
primary_extension: .hx primary_extension: .hx
@@ -630,6 +672,17 @@ INI:
- .properties - .properties
primary_extension: .ini primary_extension: .ini
Idris:
type: programming
lexer: Text only
primary_extension: .idr
extensions:
- .lidr
Inno Setup:
primary_extension: .iss
lexer: Text only
IRC log: IRC log:
lexer: IRC logs lexer: IRC logs
search_term: irc search_term: irc
@@ -649,12 +702,30 @@ Ioke:
color: "#078193" color: "#078193"
primary_extension: .ik primary_extension: .ik
J:
type: programming
lexer: Text only
primary_extension: .ijs
JSON: JSON:
type: data type: data
group: JavaScript group: JavaScript
ace_mode: json ace_mode: json
searchable: false searchable: false
primary_extension: .json 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: Java:
type: programming type: programming
@@ -695,6 +766,13 @@ JavaScript:
Julia: Julia:
type: programming type: programming
primary_extension: .jl primary_extension: .jl
color: "#a270ba"
KRL:
lexer: Text only
type: programming
color: "#f5c800"
primary_extension: .krl
Kotlin: Kotlin:
type: programming type: programming
@@ -799,7 +877,9 @@ M:
lexer: Common Lisp lexer: Common Lisp
aliases: aliases:
- mumps - mumps
primary_extension: .m primary_extension: .mumps
extensions:
- .m
Makefile: Makefile:
aliases: aliases:
@@ -1058,6 +1138,9 @@ PowerShell:
aliases: aliases:
- posh - posh
primary_extension: .ps1 primary_extension: .ps1
extensions:
- .psd1
- .psm1
Processing: Processing:
type: programming type: programming
@@ -1072,6 +1155,13 @@ Prolog:
extensions: extensions:
- .pro - .pro
Protocol Buffer:
type: markup
aliases:
- protobuf
- Protocol Buffers
primary_extension: .proto
Puppet: Puppet:
type: programming type: programming
color: "#cc5555" color: "#cc5555"
@@ -1108,11 +1198,31 @@ Python traceback:
searchable: false searchable: false
primary_extension: .pytb primary_extension: .pytb
QML:
type: markup
color: "#44a51c"
primary_extension: .qml
R: R:
type: programming type: programming
color: "#198ce7" color: "#198ce7"
lexer: S lexer: S
primary_extension: .r primary_extension: .r
extensions:
- .R
filenames:
- .Rprofile
REALbasic:
type: programming
lexer: VB.net
primary_extension: .rbbas
extensions:
- .rbfrm
- .rbmnu
- .rbres
- .rbtbar
- .rbuistate
RHTML: RHTML:
type: markup type: markup
@@ -1152,6 +1262,12 @@ Rebol:
Redcode: Redcode:
primary_extension: .cw primary_extension: .cw
RobotFramework:
type: programming
primary_extension: .robot
# extensions:
# - .txt
Rouge: Rouge:
type: programming type: programming
lexer: Clojure lexer: Clojure
@@ -1175,6 +1291,7 @@ Ruby:
- .gemspec - .gemspec
- .god - .god
- .irbrc - .irbrc
- .mspec
- .podspec - .podspec
- .rbuild - .rbuild
- .rbw - .rbw
@@ -1224,6 +1341,11 @@ Scala:
color: "#7dd3b0" color: "#7dd3b0"
primary_extension: .scala primary_extension: .scala
Scaml:
group: HTML
type: markup
primary_extension: .scaml
Scheme: Scheme:
type: programming type: programming
color: "#1e4aec" color: "#1e4aec"
@@ -1253,6 +1375,7 @@ Shell:
- zsh - zsh
primary_extension: .sh primary_extension: .sh
extensions: extensions:
- .bats
- .tmux - .tmux
filenames: filenames:
- Dockerfile - Dockerfile
@@ -1301,6 +1424,8 @@ Tcl:
type: programming type: programming
color: "#e4cc98" color: "#e4cc98"
primary_extension: .tcl primary_extension: .tcl
extensions:
- .adp
Tcsh: Tcsh:
type: programming type: programming
@@ -1317,9 +1442,13 @@ TeX:
primary_extension: .tex primary_extension: .tex
extensions: extensions:
- .aux - .aux
- .bib
- .dtx - .dtx
- .ins - .ins
- .ltx - .ltx
- .mkii
- .mkiv
- .mkvi
- .sty - .sty
- .toc - .toc
@@ -1351,7 +1480,6 @@ Twig:
TypeScript: TypeScript:
type: programming type: programming
color: "#31859c" color: "#31859c"
lexer: Text only
aliases: aliases:
- ts - ts
primary_extension: .ts primary_extension: .ts
@@ -1395,6 +1523,7 @@ VimL:
- vim - vim
primary_extension: .vim primary_extension: .vim
filenames: filenames:
- .vimrc
- vimrc - vimrc
- gvimrc - gvimrc
@@ -1405,6 +1534,7 @@ Visual Basic:
primary_extension: .vb primary_extension: .vb
extensions: extensions:
- .bas - .bas
- .frm
- .frx - .frx
- .vba - .vba
- .vbs - .vbs
@@ -1431,14 +1561,19 @@ XML:
extensions: extensions:
- .axml - .axml
- .ccxml - .ccxml
- .clixml
- .cproject
- .dita - .dita
- .ditamap - .ditamap
- .ditaval - .ditaval
- .glade - .glade
- .grxml - .grxml
- .jelly
- .kml - .kml
- .mxml - .mxml
- .plist - .plist
- .ps1xml
- .psc1
- .pt - .pt
- .rdf - .rdf
- .rss - .rss
@@ -1481,6 +1616,8 @@ XQuery:
primary_extension: .xquery primary_extension: .xquery
extensions: extensions:
- .xq - .xq
- .xql
- .xqm
- .xqy - .xqy
XS: XS:

View File

@@ -18,6 +18,9 @@
"Awk": [ "Awk": [
".awk" ".awk"
], ],
"Bluespec": [
".bsv"
],
"C": [ "C": [
".c", ".c",
".h" ".h"
@@ -41,6 +44,9 @@
"CoffeeScript": [ "CoffeeScript": [
".coffee" ".coffee"
], ],
"Common Lisp": [
".lisp"
],
"Coq": [ "Coq": [
".v" ".v"
], ],
@@ -135,6 +141,9 @@
"Less": [ "Less": [
".less" ".less"
], ],
"LFE": [
".lfe"
],
"Literate CoffeeScript": [ "Literate CoffeeScript": [
".litcoffee" ".litcoffee"
], ],
@@ -296,6 +305,9 @@
"Slash": [ "Slash": [
".sl" ".sl"
], ],
"Squirrel": [
".nut"
],
"Standard ML": [ "Standard ML": [
".sig", ".sig",
".sml" ".sml"
@@ -412,8 +424,8 @@
".gemrc" ".gemrc"
] ]
}, },
"tokens_total": 411886, "tokens_total": 415313,
"languages_total": 447, "languages_total": 458,
"tokens": { "tokens": {
"ABAP": { "ABAP": {
"*/**": 1, "*/**": 1,
@@ -1902,20 +1914,215 @@
"fragments": 1, "fragments": 1,
"END": 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": { "C": {
"#include": 149, "#include": 150,
"const": 357, "const": 358,
"char": 529, "char": 529,
"*blob_type": 2, "*blob_type": 2,
";": 5439, ";": 5446,
"struct": 359, "struct": 359,
"blob": 6, "blob": 6,
"*lookup_blob": 2, "*lookup_blob": 2,
"(": 6213, "(": 6225,
"unsigned": 140, "unsigned": 140,
"*sha1": 16, "*sha1": 16,
")": 6215, ")": 6227,
"{": 1528, "{": 1530,
"object": 10, "object": 10,
"*obj": 9, "*obj": 9,
"lookup_object": 2, "lookup_object": 2,
@@ -1932,22 +2139,22 @@
"sha1_to_hex": 8, "sha1_to_hex": 8,
"typename": 2, "typename": 2,
"NULL": 330, "NULL": 330,
"}": 1544, "}": 1546,
"*": 253, "*": 259,
"int": 446, "int": 446,
"parse_blob_buffer": 2, "parse_blob_buffer": 2,
"*item": 10, "*item": 10,
"void": 279, "void": 284,
"*buffer": 6, "*buffer": 6,
"long": 105, "long": 105,
"size": 120, "size": 120,
"item": 24, "item": 24,
"object.parsed": 4, "object.parsed": 4,
"#ifndef": 84, "#ifndef": 85,
"BLOB_H": 2, "BLOB_H": 2,
"#define": 911, "#define": 912,
"extern": 37, "extern": 38,
"#endif": 236, "#endif": 239,
"git_cache_init": 1, "git_cache_init": 1,
"git_cache": 4, "git_cache": 4,
"*cache": 4, "*cache": 4,
@@ -1973,8 +2180,8 @@
"i": 410, "i": 410,
"for": 88, "for": 88,
"+": 551, "+": 551,
"[": 597, "[": 601,
"]": 597, "]": 601,
"git_cached_obj_decref": 3, "git_cached_obj_decref": 3,
"git__free": 15, "git__free": 15,
"*git_cache_get": 1, "*git_cache_get": 1,
@@ -2002,7 +2209,7 @@
"else": 190, "else": 190,
"save_commit_buffer": 3, "save_commit_buffer": 3,
"*commit_type": 2, "*commit_type": 2,
"static": 454, "static": 455,
"commit": 59, "commit": 59,
"*check_commit": 1, "*check_commit": 1,
"quiet": 5, "quiet": 5,
@@ -2280,7 +2487,7 @@
"<linux/mutex.h>": 1, "<linux/mutex.h>": 1,
"<linux/gfp.h>": 1, "<linux/gfp.h>": 1,
"<linux/suspend.h>": 1, "<linux/suspend.h>": 1,
"#ifdef": 64, "#ifdef": 66,
"CONFIG_SMP": 1, "CONFIG_SMP": 1,
"DEFINE_MUTEX": 1, "DEFINE_MUTEX": 1,
"cpu_add_remove_lock": 3, "cpu_add_remove_lock": 3,
@@ -3329,7 +3536,7 @@
"paused": 3, "paused": 3,
"HPE_PAUSED": 2, "HPE_PAUSED": 2,
"http_parser_h": 2, "http_parser_h": 2,
"__cplusplus": 18, "__cplusplus": 20,
"HTTP_PARSER_VERSION_MAJOR": 1, "HTTP_PARSER_VERSION_MAJOR": 1,
"HTTP_PARSER_VERSION_MINOR": 1, "HTTP_PARSER_VERSION_MINOR": 1,
"<sys/types.h>": 2, "<sys/types.h>": 2,
@@ -3420,6 +3627,22 @@
"*http_method_str": 1, "*http_method_str": 1,
"*http_errno_name": 1, "*http_errno_name": 1,
"*http_errno_description": 1, "*http_errno_description": 1,
"<jni.h>": 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, "strncasecmp": 2,
"_strnicmp": 1, "_strnicmp": 1,
"REF_TABLE_SIZE": 1, "REF_TABLE_SIZE": 1,
@@ -6455,6 +6678,13 @@
"__pyx_pf_7sklearn_12linear_model_8sgd_fast_10Regression_loss": 1, "__pyx_pf_7sklearn_12linear_model_8sgd_fast_10Regression_loss": 1,
"__pyx_base.__pyx_vtab": 1, "__pyx_base.__pyx_vtab": 1,
"__pyx_base.loss": 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__": 2,
"__WGLEW_H__": 1, "__WGLEW_H__": 1,
"__wglext_h_": 2, "__wglext_h_": 2,
@@ -10603,6 +10833,49 @@
"xFF": 1, "xFF": 1,
"ip.join": 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": { "Coq": {
"Inductive": 41, "Inductive": 41,
"day": 9, "day": 9,
@@ -22937,6 +23210,338 @@
"/": 2, "/": 2,
"margin": 1 "margin": 1
}, },
"LFE": {
";": 213,
"Copyright": 4,
"(": 217,
"c": 4,
")": 231,
"Duncan": 4,
"McGreggor": 4,
"<oubiwann@cogitat.io>": 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,
"<lfe_eval.10.91765564>": 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": { "Literate CoffeeScript": {
"The": 2, "The": 2,
"**Scope**": 2, "**Scope**": 2,
@@ -30546,23 +31151,23 @@
"OpenCL": { "OpenCL": {
"double": 3, "double": 3,
"run_fftw": 1, "run_fftw": 1,
"(": 11, "(": 18,
"int": 3, "int": 3,
"n": 2, "n": 4,
"const": 2, "const": 4,
"float": 2, "float": 3,
"*": 4, "*": 5,
"x": 2, "x": 5,
"y": 2, "y": 4,
")": 11, ")": 18,
"{": 2, "{": 4,
"fftwf_plan": 1, "fftwf_plan": 1,
"p1": 3, "p1": 3,
"fftwf_plan_dft_1d": 1, "fftwf_plan_dft_1d": 1,
"fftwf_complex": 2, "fftwf_complex": 2,
"FFTW_FORWARD": 1, "FFTW_FORWARD": 1,
"FFTW_ESTIMATE": 1, "FFTW_ESTIMATE": 1,
";": 9, ";": 12,
"nops": 3, "nops": 3,
"t": 4, "t": 4,
"cl": 2, "cl": 2,
@@ -30570,13 +31175,30 @@
"for": 1, "for": 1,
"op": 3, "op": 3,
"<": 1, "<": 1,
"+": 2, "+": 4,
"fftwf_execute": 1, "fftwf_execute": 1,
"}": 2, "}": 4,
"-": 1, "-": 1,
"/": 1, "/": 1,
"fftwf_destroy_plan": 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": { "OpenEdge ABL": {
"USING": 3, "USING": 3,
@@ -37994,6 +38616,57 @@
"ast.eval": 1, "ast.eval": 1,
"Env.new": 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": { "Standard ML": {
"signature": 2, "signature": 2,
"LAZY_BASE": 3, "LAZY_BASE": 3,
@@ -38516,17 +39189,17 @@
"Animal": 4, "Animal": 4,
"{": 9, "{": 9,
"constructor": 3, "constructor": 3,
"(": 17, "(": 18,
"public": 1, "public": 1,
"name": 5, "name": 5,
")": 17, ")": 18,
"}": 9, "}": 9,
"move": 3, "move": 3,
"meters": 2, "meters": 2,
"alert": 3, "alert": 3,
"this.name": 1, "this.name": 1,
"+": 3, "+": 3,
";": 7, ";": 8,
"Snake": 2, "Snake": 2,
"extends": 2, "extends": 2,
"super": 2, "super": 2,
@@ -40854,11 +41527,13 @@
"Arduino": 20, "Arduino": 20,
"AutoHotkey": 3, "AutoHotkey": 3,
"Awk": 544, "Awk": 544,
"C": 58732, "Bluespec": 1298,
"C": 58858,
"C++": 21480, "C++": 21480,
"Ceylon": 50, "Ceylon": 50,
"COBOL": 90, "COBOL": 90,
"CoffeeScript": 2951, "CoffeeScript": 2951,
"Common Lisp": 103,
"Coq": 18259, "Coq": 18259,
"CSS": 43867, "CSS": 43867,
"Dart": 68, "Dart": 68,
@@ -40886,6 +41561,7 @@
"Kotlin": 155, "Kotlin": 155,
"Lasso": 9849, "Lasso": 9849,
"Less": 39, "Less": 39,
"LFE": 1711,
"Literate CoffeeScript": 275, "Literate CoffeeScript": 275,
"LiveScript": 123, "LiveScript": 123,
"Logos": 93, "Logos": 93,
@@ -40907,7 +41583,7 @@
"OCaml": 382, "OCaml": 382,
"Omgrofl": 57, "Omgrofl": 57,
"Opa": 28, "Opa": 28,
"OpenCL": 88, "OpenCL": 144,
"OpenEdge ABL": 762, "OpenEdge ABL": 762,
"Parrot Assembly": 6, "Parrot Assembly": 6,
"Parrot Internal Representation": 5, "Parrot Internal Representation": 5,
@@ -40932,13 +41608,14 @@
"SCSS": 39, "SCSS": 39,
"Shell": 3744, "Shell": 3744,
"Slash": 187, "Slash": 187,
"Squirrel": 130,
"Standard ML": 243, "Standard ML": 243,
"SuperCollider": 268, "SuperCollider": 268,
"Tea": 3, "Tea": 3,
"TeX": 1155, "TeX": 1155,
"Turing": 44, "Turing": 44,
"TXL": 213, "TXL": 213,
"TypeScript": 106, "TypeScript": 109,
"Verilog": 3778, "Verilog": 3778,
"VHDL": 42, "VHDL": 42,
"VimL": 20, "VimL": 20,
@@ -40961,11 +41638,13 @@
"Arduino": 1, "Arduino": 1,
"AutoHotkey": 1, "AutoHotkey": 1,
"Awk": 1, "Awk": 1,
"C": 24, "Bluespec": 2,
"C": 26,
"C++": 20, "C++": 20,
"Ceylon": 1, "Ceylon": 1,
"COBOL": 4, "COBOL": 4,
"CoffeeScript": 9, "CoffeeScript": 9,
"Common Lisp": 1,
"Coq": 12, "Coq": 12,
"CSS": 2, "CSS": 2,
"Dart": 1, "Dart": 1,
@@ -40993,6 +41672,7 @@
"Kotlin": 1, "Kotlin": 1,
"Lasso": 4, "Lasso": 4,
"Less": 1, "Less": 1,
"LFE": 4,
"Literate CoffeeScript": 1, "Literate CoffeeScript": 1,
"LiveScript": 1, "LiveScript": 1,
"Logos": 1, "Logos": 1,
@@ -41014,7 +41694,7 @@
"OCaml": 2, "OCaml": 2,
"Omgrofl": 1, "Omgrofl": 1,
"Opa": 2, "Opa": 2,
"OpenCL": 1, "OpenCL": 2,
"OpenEdge ABL": 5, "OpenEdge ABL": 5,
"Parrot Assembly": 1, "Parrot Assembly": 1,
"Parrot Internal Representation": 1, "Parrot Internal Representation": 1,
@@ -41039,6 +41719,7 @@
"SCSS": 1, "SCSS": 1,
"Shell": 37, "Shell": 37,
"Slash": 1, "Slash": 1,
"Squirrel": 1,
"Standard ML": 2, "Standard ML": 2,
"SuperCollider": 2, "SuperCollider": 2,
"Tea": 1, "Tea": 1,
@@ -41060,5 +41741,5 @@
"Xtend": 2, "Xtend": 2,
"YAML": 1 "YAML": 1
}, },
"md5": "04aab6477c2dc5ef1be1c9de1886c3f3" "md5": "e1daa29f986e203ade56a02091d24c99"
} }

View File

@@ -12,6 +12,9 @@
# Caches # Caches
- cache/ - cache/
# Dependencies
- ^[Dd]ependencies/
# C deps # C deps
# https://github.com/joyent/node # https://github.com/joyent/node
- ^deps/ - ^deps/
@@ -27,8 +30,12 @@
# Erlang bundles # Erlang bundles
- ^rebar$ - ^rebar$
# Bootstrap minified css and js
- (^|/)bootstrap([^.]*)(\.min)\.(js|css)$
# Vendored dependencies # Vendored dependencies
- vendor/ - thirdparty/
- vendors?/
# Debian packaging # Debian packaging
- ^debian/ - ^debian/
@@ -37,7 +44,7 @@
# jQuery # jQuery
- (^|/)jquery([^.]*)(\.min)?\.js$ - (^|/)jquery([^.]*)(\.min)?\.js$
- (^|/)jquery\-\d\.\d(\.\d)?(\.min)?\.js$ - (^|/)jquery\-\d\.\d+(\.\d+)?(\.min)?\.js$
# jQuery UI # jQuery UI
- (^|/)jquery\-ui(\-\d\.\d+(\.\d+)?)?(\.\w+)?(\.min)?\.(js|css)$ - (^|/)jquery\-ui(\-\d\.\d+(\.\d+)?)?(\.\w+)?(\.min)?\.(js|css)$
@@ -86,6 +93,8 @@
# WAF # WAF
- ^waf$ - ^waf$
# .osx
- ^.osx$
## Obj-C ## ## Obj-C ##
@@ -108,7 +117,22 @@
- ^[Pp]ackages/ - ^[Pp]ackages/
# ExtJS # 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 # Samples folders
- ^[Ss]amples/ - ^[Ss]amples/
@@ -125,5 +149,12 @@
# Test fixtures # Test fixtures
- ^[Tt]est/fixtures/ - ^[Tt]est/fixtures/
# PhoneGap/Cordova
- (^|/)cordova([^.]*)(\.min)?\.js$
- (^|/)cordova\-\d\.\d(\.\d)?(\.min)?\.js$
# Vagrant
- ^Vagrantfile$
# .DS_Store's # .DS_Store's
- .[Dd][Ss]_[Ss]tore$ - .[Dd][Ss]_[Ss]tore$

167
samples/Bluespec/TL.bsv Normal file
View File

@@ -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

109
samples/Bluespec/TbTL.bsv Normal file
View File

@@ -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

61
samples/C/jni_layer.h Normal file
View File

@@ -0,0 +1,61 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* 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

5
samples/C/syscalldefs.h Normal file
View File

@@ -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),
};

17
samples/Clojure/for.clj Normal file
View File

@@ -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)

View File

@@ -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!"]]]]

View File

@@ -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)))))

View File

@@ -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 ..."

View File

@@ -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)))

20
samples/Clojure/svg.cljx Normal file
View File

@@ -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)]))

View File

@@ -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]))))

View File

@@ -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))

87
samples/DM/example.dm Normal file
View File

@@ -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

42
samples/Idris/Chars.idr Normal file
View File

@@ -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']

3
samples/Jade/hello.jade Normal file
View File

@@ -0,0 +1,3 @@
p.
Hello,
World!

View File

@@ -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");
}
}

23
samples/OpenCL/sample.cl Normal file
View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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}

View File

@@ -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

View File

@@ -0,0 +1,3 @@
%p
Hello,
World!

View File

@@ -1 +1 @@
console.log "Hello, World!" console.log("Hello, World!");

View File

@@ -198,6 +198,9 @@ class TestBlob < Test::Unit::TestCase
assert blob("Java/ProtocolBuffer.java").generated? assert blob("Java/ProtocolBuffer.java").generated?
assert blob("Python/protocol_buffer_pb2.py").generated? assert blob("Python/protocol_buffer_pb2.py").generated?
# Generated JNI
assert blob("C/jni_layer.h").generated?
# Minified CSS # Minified CSS
assert !blob("CSS/bootstrap.css").generated? assert !blob("CSS/bootstrap.css").generated?
assert blob("CSS/bootstrap.min.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("Text/README").vendored?
assert !blob("ext/extconf.rb").vendored? assert !blob("ext/extconf.rb").vendored?
# Dependencies
assert blob("dependencies/windows/headers/GL/glext.h").vendored?
# Node dependencies # Node dependencies
assert blob("node_modules/coffee-script/lib/coffee-script.js").vendored? assert blob("node_modules/coffee-script/lib/coffee-script.js").vendored?
# Rails vendor/ # Rails vendor/
assert blob("vendor/plugins/will_paginate/lib/will_paginate.rb").vendored? assert blob("vendor/plugins/will_paginate/lib/will_paginate.rb").vendored?
# 'thirdparty' directory
assert blob("thirdparty/lib/main.c").vendored?
# C deps # C deps
assert blob("deps/http_parser/http_parser.c").vendored? assert blob("deps/http_parser/http_parser.c").vendored?
assert blob("deps/v8/src/v8.h").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.5.2.js").vendored?
assert blob("public/javascripts/jquery-1.6.1.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.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? assert !blob("public/javascripts/jquery.github.menu.js").vendored?
# jQuery UI # jQuery UI
@@ -307,6 +318,15 @@ class TestBlob < Test::Unit::TestCase
# Test fixtures # Test fixtures
assert blob("test/fixtures/random.rkt").vendored? assert blob("test/fixtures/random.rkt").vendored?
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 end
def test_language def test_language