Compare commits

...

43 Commits

Author SHA1 Message Date
Brian Lopez
c1cf7ea825 Merge pull request #1254 from github/cut-release-v2.11.4
v2.11.4 release
2014-06-05 10:03:43 -07:00
Brian Lopez
67f7268a55 bump version for v2.11.4 release 2014-06-05 10:55:32 -05:00
Brian Lopez
a55ee7eb09 Merge pull request #1253 from github/newer-charlock
Use the :ruby_encoding value from charlock 0.7.2
2014-06-05 08:51:46 -07:00
Brian Lopez
203f6d1944 forgot to add the test fixture 2014-06-04 17:15:33 -05:00
Brian Lopez
42c68f21d1 test ruby_encoding 2014-06-04 15:59:42 -05:00
Brian Lopez
7e8be1293e Use the :ruby_encoding value from charlock 0.7.2 2014-06-04 15:51:33 -05:00
Arfon Smith
09c234ec26 Merge pull request #1190 from Madsn/patch-1
Add html5shiv to vendor.yml
2014-06-04 10:30:03 -05:00
Arfon Smith
65a26c3e73 Merge pull request #1248 from github/1035-update
1035 update
2014-06-03 22:06:54 -05:00
Arfon Smith
98f35aefdc Merge branch 'master' into 1035
Conflicts:
	lib/linguist/languages.yml
	lib/linguist/samples.json
2014-06-03 22:03:59 -05:00
Arfon Smith
38a3714514 Samples update 2014-06-03 21:37:25 -05:00
Arfon Smith
491700f925 Merge pull request #1198 from Spirit-of-Oberon/master
Support of the Component Pascal language
2014-06-03 21:36:52 -05:00
Andy Lindeman
4d033e7e83 Merge pull request #1246 from github/cut-release-v2.11.3
Bumps to 2.11.3
2014-06-03 15:15:14 -04:00
Andy Lindeman
efc3638065 Freshens up the release docs 2014-06-03 14:50:27 -04:00
Andy Lindeman
b7685ab317 Bumps to 2.11.3 2014-06-03 14:50:17 -04:00
Andy Lindeman
83c5f6a004 Merge pull request #1245 from alindeman/binarylike_data
Handle case where newline chars don't transcode to detected encoding
2014-06-03 12:55:33 -04:00
Andy Lindeman
aa5a94cc3e Handle case where newline chars don't transcode to detected encoding
We've seen cases where binary files are detected as encodings such as
ISO-8859-8-I. This usually happens when the binary files are short, so
while the detector is mistaken, there is also not very much data for use
in the detection algorithm in the first place so it's understandable
that the detector was wrong.

In these cases, the code to convert ASCII newline characters to
encodings such as ISO-8859-8-I fails because there is no conversion
between them.

We now simply assume that the data is all one line in those cases. In
reality the data is binary, but this obviously difficult to detect
reliably.
2014-06-03 12:26:23 -04:00
Arfon Smith
a5b6331ab5 Merge pull request #1244 from akashivskyy/master
Add orange color to Apple Swift language
2014-06-03 10:53:55 -05:00
Adrian Kashivskyy
2164b28c64 Update Swift color 2014-06-03 16:03:49 +02:00
Adrian Kashivskyy
0fb824b345 Add orange color to Swift 2014-06-03 15:54:15 +02:00
Arfon Smith
29ee094d66 Merge pull request #1241 from github/1239-update
1239 update
2014-06-02 21:11:40 -05:00
Arfon Smith
4a7ae50ec8 Dammit 2014-06-02 21:07:11 -05:00
Arfon Smith
398439a937 Pedantic 2014-06-02 21:04:39 -05:00
Arfon Smith
a3bc3a7615 Merge branch 'master' into 1239-update
Conflicts:
	lib/linguist/samples.json
2014-06-02 21:01:00 -05:00
Arfon Smith
7989fbd613 Samples 2014-06-02 21:00:03 -05:00
john howard
c389c79be9 fixed zimpl declaration position collation order problem 2014-06-02 18:30:45 -07:00
john howard
1fd2f921fd added yet another zimpl extension that is in use 2014-06-02 18:28:00 -07:00
john howard
ed851849db added extra extension for zimpl 2014-06-02 18:23:07 -07:00
john howard
cfb9f6f0a4 smaller code sample 2014-06-02 18:14:57 -07:00
John Howard
3d5a0da62e rename sample directory 2014-06-02 18:08:54 -07:00
john howard
4e15369f9a added missing lexer for zimpl 2014-06-02 17:27:24 -07:00
john howard
5b3152d99d Create sample.zmpl 2014-06-02 15:16:00 -07:00
john howard
a6955f4edb added zmpl language declaration 2014-06-02 15:09:41 -07:00
ilovb
ac2723abe3 example 2 for Component Pascal 2014-05-17 00:02:34 +04:00
ilovb
0d0e219532 add example for Component Pascal 2014-05-16 23:47:27 +04:00
ilovb
cf35807709 add lexer for Component Pascal 2014-05-16 23:29:52 +04:00
ilovb
c2b53db96d remove Component Pascal examples 2014-05-16 23:08:28 +04:00
ilovb
8e6efc3a7d remove Component Pascal Document 2014-05-16 22:39:18 +04:00
ilovb
4b6f05b4d1 remove ace mode 2014-05-16 22:17:05 +04:00
ilovb
7aad5f93e4 Support of the Component Pascal language
http://en.wikipedia.org/wiki/Component_Pascal
2014-05-16 21:36:23 +04:00
Mikkel Madsen
dcc598442b Handle minified html5shiv 2014-05-13 09:01:37 +02:00
Mikkel Madsen
91877056fb Extend vendor test for html5shiv 2014-05-13 09:00:43 +02:00
Mikkel Madsen
868e9df434 Add html5shiv to vendor.yml 2014-05-13 08:56:08 +02:00
Aleks Kissinger
a3aaa1ec4d included sample and extension .ML extension for Standard ML files 2014-04-02 12:41:54 +01:00
14 changed files with 682 additions and 68 deletions

View File

@@ -143,8 +143,8 @@ If you are the current maintainer of this gem:
0. Make sure your local dependencies are up to date: `bundle install`
0. Ensure that samples are updated: `bundle exec rake samples`
0. Ensure that tests are green: `bundle exec rake test`
0. Bump gem version in github-linguist.gemspec. For example, [like this](https://github.com/github/linguist/commit/97908204a385940e47251af9ecb689e8f6515c48).
0. Make a PR to github/linguist. For example, [#1075](https://github.com/github/linguist/pull/1075).
0. Bump gem version in `lib/linguist/version.rb`. For example, [like this](https://github.com/github/linguist/commit/8d2ea90a5ba3b2fe6e1508b7155aa4632eea2985).
0. Make a PR to github/linguist. For example, [#1238](https://github.com/github/linguist/pull/1238).
0. Build a local gem: `gem build github-linguist.gemspec`
0. Testing:
0. Bump the Gemfile and Gemfile.lock versions for an app which relies on this gem

View File

@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.files = Dir['lib/**/*']
s.executables << 'linguist'
s.add_dependency 'charlock_holmes', '~> 0.7.1'
s.add_dependency 'charlock_holmes', '~> 0.7.2'
s.add_dependency 'escape_utils', '~> 1.0.1'
s.add_dependency 'mime-types', '~> 1.19'
s.add_dependency 'pygments.rb', '~> 0.5.4'

View File

@@ -112,6 +112,12 @@ module Linguist
end
end
def ruby_encoding
if hash = detect_encoding
hash[:ruby_encoding]
end
end
# Try to guess the encoding
#
# Returns: a Hash, with :encoding, :confidence, :type
@@ -256,10 +262,16 @@ module Linguist
# without changing the encoding of `data`, and
# also--importantly--without having to duplicate many (potentially
# large) strings.
encoded_newlines = ["\r\n", "\r", "\n"].
map { |nl| nl.encode(encoding).force_encoding(data.encoding) }
begin
encoded_newlines = ["\r\n", "\r", "\n"].
map { |nl| nl.encode(ruby_encoding, "ASCII-8BIT").force_encoding(data.encoding) }
data.split(Regexp.union(encoded_newlines), -1)
data.split(Regexp.union(encoded_newlines), -1)
rescue Encoding::ConverterNotFoundError
# The data is not splittable in the detected encoding. Assume it's
# one big line.
[data]
end
else
[]
end

View File

@@ -430,6 +430,14 @@ Common Lisp:
- clisp
- ecl
Component Pascal:
type: programming
lexer: Delphi
color: "#b0ce4e"
extensions:
- .cp
- .cps
Coq:
type: programming
extensions:
@@ -2017,8 +2025,9 @@ Standard ML:
aliases:
- sml
extensions:
- .sml
- .ML
- .fun
- .sml
Stata:
type: programming
@@ -2048,6 +2057,7 @@ SuperCollider:
Swift:
type: programming
color: "#ffac45"
lexer: Text only
extensions:
- .swift
@@ -2348,6 +2358,14 @@ Zephir:
extensions:
- .zep
Zimpl:
type: programming
lexer: Text only
extensions:
- .zimpl
- .zmpl
- .zpl
eC:
type: programming
search_term: ec

View File

@@ -92,6 +92,10 @@
".cl",
".lisp"
],
"Component Pascal": [
".cp",
".cps"
],
"Coq": [
".v"
],
@@ -562,6 +566,7 @@
".nut"
],
"Standard ML": [
".ML",
".fun",
".sig",
".sml"
@@ -660,6 +665,9 @@
],
"Zephir": [
".zep"
],
"Zimpl": [
".zmpl"
]
},
"interpreters": {
@@ -726,8 +734,8 @@
".gemrc"
]
},
"tokens_total": 612602,
"languages_total": 798,
"tokens_total": 613712,
"languages_total": 802,
"tokens": {
"ABAP": {
"*/**": 1,
@@ -15333,6 +15341,181 @@
"line": 2,
"After": 1
},
"Component Pascal": {
"MODULE": 2,
"ObxControls": 1,
";": 123,
"IMPORT": 2,
"Dialog": 1,
"Ports": 1,
"Properties": 1,
"Views": 1,
"CONST": 1,
"beginner": 5,
"advanced": 3,
"expert": 1,
"guru": 2,
"TYPE": 1,
"View": 6,
"POINTER": 2,
"TO": 2,
"RECORD": 2,
"(": 91,
"Views.View": 2,
")": 94,
"size": 1,
"INTEGER": 10,
"END": 31,
"VAR": 9,
"data*": 1,
"class*": 1,
"list*": 1,
"Dialog.List": 1,
"width*": 1,
"predef": 12,
"ARRAY": 2,
"OF": 2,
"PROCEDURE": 12,
"SetList": 4,
"BEGIN": 13,
"IF": 11,
"data.class": 5,
"THEN": 12,
"data.list.SetLen": 3,
"data.list.SetItem": 11,
"ELSIF": 1,
"ELSE": 3,
"v": 6,
"CopyFromSimpleView": 2,
"source": 2,
"v.size": 10,
".size": 1,
"Restore": 2,
"f": 1,
"Views.Frame": 1,
"l": 1,
"t": 1,
"r": 7,
"b": 1,
"[": 13,
"]": 13,
"f.DrawRect": 1,
"Ports.fill": 1,
"Ports.red": 1,
"HandlePropMsg": 2,
"msg": 2,
"Views.PropMessage": 1,
"WITH": 1,
"Properties.SizePref": 1,
"DO": 4,
"msg.w": 1,
"msg.h": 1,
"ClassNotify*": 1,
"op": 4,
"from": 2,
"to": 5,
"Dialog.changed": 2,
"OR": 4,
"&": 8,
"data.list.index": 3,
"data.width": 4,
"Dialog.Update": 2,
"data": 2,
"Dialog.UpdateList": 1,
"data.list": 1,
"ClassNotify": 1,
"ListNotify*": 1,
"ListNotify": 1,
"ListGuard*": 1,
"par": 2,
"Dialog.Par": 2,
"par.disabled": 1,
"ListGuard": 1,
"WidthGuard*": 1,
"par.readOnly": 1,
"#": 3,
"WidthGuard": 1,
"Open*": 1,
"NEW": 2,
"*": 1,
"Ports.mm": 1,
"Views.OpenAux": 1,
"Open": 1,
"ObxControls.": 1,
"ObxFact": 1,
"Stores": 1,
"Models": 1,
"TextModels": 1,
"TextControllers": 1,
"Integers": 1,
"Read": 3,
"TextModels.Reader": 2,
"x": 15,
"Integers.Integer": 3,
"i": 17,
"len": 5,
"beg": 11,
"ch": 14,
"CHAR": 3,
"buf": 5,
"r.ReadChar": 5,
"WHILE": 3,
"r.eot": 4,
"<=>": 1,
"ReadChar": 1,
"ASSERT": 1,
"eot": 1,
"<": 8,
"r.Pos": 2,
"-": 1,
"REPEAT": 3,
"INC": 4,
"UNTIL": 3,
"+": 1,
"r.SetPos": 2,
"X": 1,
"Integers.ConvertFromString": 1,
"Write": 3,
"w": 4,
"TextModels.Writer": 2,
"Integers.Sign": 2,
"w.WriteChar": 3,
"Integers.Digits10Of": 1,
"DEC": 1,
"Integers.ThisDigit10": 1,
"Compute*": 1,
"end": 6,
"n": 3,
"s": 3,
"Stores.Operation": 1,
"attr": 3,
"TextModels.Attributes": 1,
"c": 3,
"TextControllers.Controller": 1,
"TextControllers.Focus": 1,
"NIL": 3,
"c.HasSelection": 1,
"c.GetSelection": 1,
"c.text.NewReader": 1,
"r.ReadPrev": 2,
"r.attr": 1,
"Integers.Compare": 1,
"Integers.Long": 3,
"MAX": 1,
"LONGINT": 1,
"SHORT": 1,
"Integers.Short": 1,
"Integers.Product": 1,
"Models.BeginScript": 1,
"c.text": 2,
"c.text.Delete": 1,
"c.text.NewWriter": 1,
"w.SetPos": 1,
"w.SetAttr": 1,
"Models.EndScript": 1,
"Compute": 1,
"ObxFact.": 1
},
"Coq": {
"Inductive": 41,
"day": 9,
@@ -60658,67 +60841,67 @@
"newplayer.MoveTo": 1
},
"Standard ML": {
"structure": 15,
"LazyBase": 4,
"LAZY_BASE": 5,
"struct": 13,
"type": 6,
"a": 78,
"exception": 2,
"Undefined": 6,
"fun": 60,
"delay": 6,
"f": 46,
"force": 18,
"(": 840,
")": 845,
"val": 147,
"undefined": 2,
"fn": 127,
"raise": 6,
"end": 55,
"LazyMemoBase": 4,
"datatype": 29,
"|": 226,
"Done": 2,
"of": 91,
"lazy": 13,
"unit": 7,
"-": 20,
"let": 44,
"open": 9,
"B": 2,
"inject": 5,
"x": 74,
"isUndefined": 4,
"ignore": 3,
";": 21,
"false": 32,
"handle": 4,
"true": 36,
"toString": 4,
"if": 51,
"then": 51,
"else": 51,
"eqBy": 5,
"p": 10,
"y": 50,
"eq": 3,
"op": 2,
"compare": 8,
"Ops": 3,
"map": 3,
"Lazy": 2,
"LazyFn": 4,
"LazyMemo": 2,
"signature": 2,
"LAZY_BASE": 3,
"sig": 2,
"type": 5,
"a": 74,
"lazy": 12,
"-": 19,
")": 826,
"end": 52,
"LAZY": 1,
"bool": 9,
"val": 143,
"inject": 3,
"toString": 3,
"(": 822,
"string": 14,
"eq": 2,
"*": 9,
"eqBy": 3,
"compare": 7,
"order": 2,
"map": 2,
"b": 58,
"structure": 10,
"Ops": 2,
"LazyBase": 2,
"struct": 9,
"exception": 1,
"Undefined": 3,
"fun": 51,
"delay": 3,
"f": 37,
"force": 9,
"undefined": 1,
"fn": 124,
"raise": 5,
"LazyMemoBase": 2,
"datatype": 28,
"|": 225,
"Done": 1,
"of": 90,
"unit": 6,
"let": 43,
"open": 8,
"B": 1,
"x": 59,
"isUndefined": 2,
"ignore": 2,
";": 20,
"false": 31,
"handle": 3,
"true": 35,
"if": 50,
"then": 50,
"else": 50,
"p": 6,
"y": 44,
"op": 1,
"Lazy": 1,
"LazyFn": 2,
"LazyMemo": 1,
"functor": 2,
"Main": 1,
"S": 2,
@@ -66571,6 +66754,47 @@
"convert": 1,
"converter": 2,
"getConverters": 1
},
"Zimpl": {
"#": 2,
"param": 1,
"columns": 2,
";": 7,
"set": 3,
"I": 3,
"{": 2,
"..": 1,
"}": 2,
"IxI": 6,
"*": 2,
"TABU": 4,
"[": 8,
"<i,j>": 3,
"in": 5,
"]": 8,
"<m,n>": 2,
"with": 1,
"(": 6,
"m": 4,
"i": 8,
"or": 3,
"n": 4,
"j": 8,
")": 6,
"and": 1,
"abs": 2,
"-": 3,
"var": 1,
"x": 4,
"binary": 1,
"maximize": 1,
"queens": 1,
"sum": 2,
"subto": 1,
"c1": 1,
"forall": 1,
"do": 1,
"card": 2
}
},
"language_tokens": {
@@ -66598,6 +66822,7 @@
"COBOL": 90,
"CoffeeScript": 2951,
"Common Lisp": 2186,
"Component Pascal": 825,
"Coq": 18259,
"Creole": 134,
"Crystal": 1506,
@@ -66731,7 +66956,7 @@
"SourcePawn": 2080,
"SQL": 1485,
"Squirrel": 130,
"Standard ML": 6405,
"Standard ML": 6567,
"Stata": 3133,
"Stylus": 76,
"SuperCollider": 133,
@@ -66757,7 +66982,8 @@
"XSLT": 44,
"Xtend": 399,
"YAML": 77,
"Zephir": 1026
"Zephir": 1026,
"Zimpl": 123
},
"languages": {
"ABAP": 1,
@@ -66784,6 +67010,7 @@
"COBOL": 4,
"CoffeeScript": 9,
"Common Lisp": 3,
"Component Pascal": 2,
"Coq": 12,
"Creole": 1,
"Crystal": 3,
@@ -66917,7 +67144,7 @@
"SourcePawn": 1,
"SQL": 5,
"Squirrel": 1,
"Standard ML": 4,
"Standard ML": 5,
"Stata": 7,
"Stylus": 1,
"SuperCollider": 1,
@@ -66943,7 +67170,8 @@
"XSLT": 1,
"Xtend": 2,
"YAML": 2,
"Zephir": 2
"Zephir": 2,
"Zimpl": 1
},
"md5": "e41e5530c6efe39b710ace7e1d5d318c"
"md5": "4754c31a712c5e22354851fd14d4d4fa"
}

View File

@@ -168,6 +168,9 @@
- (^|/)extjs/src/
- (^|/)extjs/welcome/
# Html5shiv
- (^|/)html5shiv(\.min)?\.js$
# Samples folders
- ^[Ss]amples/

View File

@@ -1,3 +1,3 @@
module Linguist
VERSION = "2.11.2"
VERSION = "2.11.4"
end

View File

@@ -0,0 +1,130 @@
MODULE ObxControls;
(**
project = "BlackBox"
organization = "www.oberon.ch"
contributors = "Oberon microsystems"
version = "System/Rsrc/About"
copyright = "System/Rsrc/About"
license = "Docu/BB-License"
changes = ""
issues = ""
**)
IMPORT Dialog, Ports, Properties, Views;
CONST beginner = 0; advanced = 1; expert = 2; guru = 3; (* user classes *)
TYPE
View = POINTER TO RECORD (Views.View)
size: INTEGER (* border size in mm *)
END;
VAR
data*: RECORD
class*: INTEGER; (* current user class *)
list*: Dialog.List; (* list of currently available sizes, derived from class *)
width*: INTEGER (* width of next view to be opened. Derived from
class, or entered through a text entry field *)
END;
predef: ARRAY 6 OF INTEGER; (* table of predefined sizes *)
PROCEDURE SetList;
BEGIN
IF data.class = beginner THEN
data.list.SetLen(1);
data.list.SetItem(0, "default")
ELSIF data.class = advanced THEN
data.list.SetLen(4);
data.list.SetItem(0, "default");
data.list.SetItem(1, "small");
data.list.SetItem(2, "medium");
data.list.SetItem(3, "large");
ELSE
data.list.SetLen(6);
data.list.SetItem(0, "default");
data.list.SetItem(1, "small");
data.list.SetItem(2, "medium");
data.list.SetItem(3, "large");
data.list.SetItem(4, "tiny");
data.list.SetItem(5, "huge");
END
END SetList;
(* View *)
PROCEDURE (v: View) CopyFromSimpleView (source: Views.View);
BEGIN
v.size := source(View).size
END CopyFromSimpleView;
PROCEDURE (v: View) Restore (f: Views.Frame; l, t, r, b: INTEGER);
BEGIN (* fill view with a red square of size v.size *)
IF v.size = 0 THEN v.size := predef[0] END; (* lazy initialization of size *)
f.DrawRect(0, 0, v.size, v.size, Ports.fill, Ports.red)
END Restore;
PROCEDURE (v: View) HandlePropMsg (VAR msg: Views.PropMessage);
BEGIN
WITH msg: Properties.SizePref DO
IF v.size = 0 THEN v.size := predef[0] END; (* lazy initialization of size *)
msg.w := v.size; msg.h := v.size (* tell environment about desired width and height *)
ELSE (* ignore other messages *)
END
END HandlePropMsg;
(* notifiers *)
PROCEDURE ClassNotify* (op, from, to: INTEGER);
BEGIN (* react to change in data.class *)
IF op = Dialog.changed THEN
IF (to = beginner) OR (to = advanced) & (data.list.index > 3) THEN
(* if class is reduced, make sure that selection contains legal elements *)
data.list.index := 0; data.width := predef[0]; (* modify interactor *)
Dialog.Update(data) (* redraw controls where necessary *)
END;
SetList;
Dialog.UpdateList(data.list) (* reconstruct list box contents *)
END
END ClassNotify;
PROCEDURE ListNotify* (op, from, to: INTEGER);
BEGIN (* reacto to change in data.list (index to was selected) *)
IF op = Dialog.changed THEN
data.width := predef[to]; (* modify interactor *)
Dialog.Update(data) (* redraw controls where necessary *)
END
END ListNotify;
(* guards *)
PROCEDURE ListGuard* (VAR par: Dialog.Par);
BEGIN (* disable list box for a beginner *)
par.disabled := data.class = beginner
END ListGuard;
PROCEDURE WidthGuard* (VAR par: Dialog.Par);
BEGIN (* make text entry field read-only if user is not guru *)
par.readOnly := data.class # guru
END WidthGuard;
(* commands *)
PROCEDURE Open*;
VAR v: View;
BEGIN
NEW(v); (* create and initialize a new view *)
v.size := data.width * Ports.mm; (* define view's size in function of class *)
Views.OpenAux(v, "Example") (* open the view in a window *)
END Open;
BEGIN (* initialization of global variables *)
predef[0] := 40; predef[1] := 30; predef[2] := 50; (* predefined sizes *)
predef[3] := 70; predef[4] := 20; predef[5] := 100;
data.class := beginner; (* default values *)
data.list.index := 0;
data.width := predef[0];
SetList
END ObxControls.

View File

@@ -0,0 +1,71 @@
MODULE ObxFact;
(**
project = "BlackBox"
organization = "www.oberon.ch"
contributors = "Oberon microsystems"
version = "System/Rsrc/About"
copyright = "System/Rsrc/About"
license = "Docu/BB-License"
changes = ""
issues = ""
**)
IMPORT
Stores, Models, TextModels, TextControllers, Integers;
PROCEDURE Read(r: TextModels.Reader; VAR x: Integers.Integer);
VAR i, len, beg: INTEGER; ch: CHAR; buf: POINTER TO ARRAY OF CHAR;
BEGIN
r.ReadChar(ch);
WHILE ~r.eot & (ch <= " ") DO r.ReadChar(ch) END;
ASSERT(~r.eot & (((ch >= "0") & (ch <= "9")) OR (ch = "-")));
beg := r.Pos() - 1; len := 0;
REPEAT INC(len); r.ReadChar(ch) UNTIL r.eot OR (ch < "0") OR (ch > "9");
NEW(buf, len + 1);
i := 0; r.SetPos(beg);
REPEAT r.ReadChar(buf[i]); INC(i) UNTIL i = len;
buf[i] := 0X;
Integers.ConvertFromString(buf^, x)
END Read;
PROCEDURE Write(w: TextModels.Writer; x: Integers.Integer);
VAR i: INTEGER;
BEGIN
IF Integers.Sign(x) < 0 THEN w.WriteChar("-") END;
i := Integers.Digits10Of(x);
IF i # 0 THEN
REPEAT DEC(i); w.WriteChar(Integers.ThisDigit10(x, i)) UNTIL i = 0
ELSE w.WriteChar("0")
END
END Write;
PROCEDURE Compute*;
VAR beg, end, i, n: INTEGER; ch: CHAR;
s: Stores.Operation;
r: TextModels.Reader; w: TextModels.Writer; attr: TextModels.Attributes;
c: TextControllers.Controller;
x: Integers.Integer;
BEGIN
c := TextControllers.Focus();
IF (c # NIL) & c.HasSelection() THEN
c.GetSelection(beg, end);
r := c.text.NewReader(NIL); r.SetPos(beg); r.ReadChar(ch);
WHILE ~r.eot & (beg < end) & (ch <= " ") DO r.ReadChar(ch); INC(beg) END;
IF ~r.eot & (beg < end) THEN
r.ReadPrev; Read(r, x);
end := r.Pos(); r.ReadPrev; attr :=r.attr;
IF (Integers.Sign(x) > 0) & (Integers.Compare(x, Integers.Long(MAX(LONGINT))) <= 0) THEN
n := SHORT(Integers.Short(x)); i := 2; x := Integers.Long(1);
WHILE i <= n DO x := Integers.Product(x, Integers.Long(i)); INC(i) END;
Models.BeginScript(c.text, "computation", s);
c.text.Delete(beg, end);
w := c.text.NewWriter(NIL); w.SetPos(beg); w.SetAttr(attr);
Write(w, x);
Models.EndScript(c.text, s)
END
END
END
END Compute;
END ObxFact.

View File

@@ -0,0 +1,75 @@
structure LazyBase:> LAZY_BASE =
struct
type 'a lazy = unit -> 'a
exception Undefined
fun delay f = f
fun force f = f()
val undefined = fn () => raise Undefined
end
structure LazyMemoBase:> LAZY_BASE =
struct
datatype 'a susp = NotYet of unit -> 'a
| Done of 'a
type 'a lazy = unit -> 'a susp ref
exception Undefined
fun delay f =
let
val r = ref (NotYet f)
in
fn () => r
end
fun force f =
case f() of
ref (Done x) => x
| r as ref (NotYet f') =>
let
val a = f'()
in
r := Done a
; a
end
val undefined = fn () => raise Undefined
end
functor LazyFn(B: LAZY_BASE): LAZY' =
struct
open B
fun inject x = delay (fn () => x)
fun isUndefined x =
(ignore (force x)
; false)
handle Undefined => true
fun toString f x = if isUndefined x then "_|_" else f (force x)
fun eqBy p (x,y) = p(force x,force y)
fun eq (x,y) = eqBy op= (x,y)
fun compare p (x,y) = p(force x,force y)
structure Ops =
struct
val ! = force
val ? = inject
end
fun map f x = delay (fn () => f (force x))
end
structure Lazy' = LazyFn(LazyBase)
structure LazyMemo = LazyFn(LazyMemoBase)

View File

@@ -0,0 +1,43 @@
$)C#
# Out-AnsiGraph.psm1
# Author: xcud
# History:
# v0.1 September 21, 2009 initial version
#
# PS Example> ps | select -first 5 | sort -property VM |
# Out-AnsiGraph ProcessName, VM
# AEADISRV  14508032
# audiodg  50757632
# conhost  73740288
# AppleMobileDeviceService  92061696
# btdna  126443520
#
function Out-AnsiGraph($Parameter1=$null) {
BEGIN {
$q = new-object Collections.queue
$max = 0; $namewidth = 0;
}
PROCESS {
if($_) {
$name = $_.($Parameter1[0]);
$val = $_.($Parameter1[1])
if($max -lt $val) { $max = $val}
if($namewidth -lt $name.length) {
$namewidth = $name.length }
$q.enqueue(@($name, $val))
}
}
END {
$q | %{
$graph = ""; 0..($_[1]/$max*20) |
%{ $graph += "" }
$name = "{0,$namewidth}" -f $_[0]
"$name $graph " + $_[1]
}
}
}
Export-ModuleMember Out-AnsiGraph

View File

@@ -0,0 +1 @@
%<25><><EFBFBD>

21
samples/Zimpl/sample.zmpl Normal file
View File

@@ -0,0 +1,21 @@
# $Id: queens3.zpl,v 1.3 2009/09/13 16:15:53 bzfkocht Exp $
#
# This is a formulation of the n queens problem using binary variables.
# variables. Since the number of queens is maximized, the size of the
# board can be set arbitrarily.
#
param columns := 8;
set I := { 1 .. columns };
set IxI := I * I;
set TABU[<i,j> in IxI] := { <m,n> in IxI with
(m != i or n != j) and (m == i or n == j or abs(m - i) == abs(n - j)) };
var x[IxI] binary;
maximize queens: sum <i,j> in IxI : x[i,j];
subto c1: forall <i,j> in IxI do
card(TABU[i,j]) - card(TABU[i,j]) * x[i,j] >= sum <m,n> in TABU[i,j] : x[m,n];

View File

@@ -97,14 +97,22 @@ class TestBlob < Test::Unit::TestCase
def test_sloc
assert_equal 2, blob("Ruby/foo.rb").sloc
assert_equal 3, blob("Text/utf16le-windows.txt").sloc
assert_equal 1, blob("Text/iso8859-8-i.txt").sloc
end
def test_encoding
assert_equal "ISO-8859-2", blob("Text/README").encoding
assert_equal "ISO-8859-2", blob("Text/README").ruby_encoding
assert_equal "ISO-8859-1", blob("Text/dump.sql").encoding
assert_equal "ISO-8859-1", blob("Text/dump.sql").ruby_encoding
assert_equal "UTF-8", blob("Text/foo.txt").encoding
assert_equal "UTF-8", blob("Text/foo.txt").ruby_encoding
assert_equal "UTF-16LE", blob("Text/utf16le.txt").encoding
assert_equal "UTF-16LE", blob("Text/utf16le.txt").ruby_encoding
assert_equal "UTF-16LE", blob("Text/utf16le-windows.txt").encoding
assert_equal "UTF-16LE", blob("Text/utf16le-windows.txt").ruby_encoding
assert_equal "ISO-2022-KR", blob("Text/ISO-2022-KR.txt").encoding
assert_equal "binary", blob("Text/ISO-2022-KR.txt").ruby_encoding
assert_nil blob("Binary/dog.o").encoding
end
@@ -363,6 +371,10 @@ class TestBlob < Test::Unit::TestCase
# NuGet Packages
assert blob("packages/Modernizr.2.0.6/Content/Scripts/modernizr-2.0.6-development-only.js").vendored?
# Html5shiv
assert blob("Scripts/html5shiv.js").vendored?
assert blob("Scripts/html5shiv.min.js").vendored?
# Test fixtures
assert blob("test/fixtures/random.rkt").vendored?