mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1cf7ea825 | ||
|
|
67f7268a55 | ||
|
|
a55ee7eb09 | ||
|
|
203f6d1944 | ||
|
|
42c68f21d1 | ||
|
|
7e8be1293e | ||
|
|
09c234ec26 | ||
|
|
65a26c3e73 | ||
|
|
98f35aefdc | ||
|
|
38a3714514 | ||
|
|
491700f925 | ||
|
|
ac2723abe3 | ||
|
|
0d0e219532 | ||
|
|
cf35807709 | ||
|
|
c2b53db96d | ||
|
|
8e6efc3a7d | ||
|
|
4b6f05b4d1 | ||
|
|
7aad5f93e4 | ||
|
|
dcc598442b | ||
|
|
91877056fb | ||
|
|
868e9df434 | ||
|
|
a3aaa1ec4d |
@@ -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'
|
||||
|
||||
@@ -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
|
||||
@@ -258,7 +264,7 @@ module Linguist
|
||||
# large) strings.
|
||||
begin
|
||||
encoded_newlines = ["\r\n", "\r", "\n"].
|
||||
map { |nl| nl.encode(encoding, "ASCII-8BIT").force_encoding(data.encoding) }
|
||||
map { |nl| nl.encode(ruby_encoding, "ASCII-8BIT").force_encoding(data.encoding) }
|
||||
|
||||
data.split(Regexp.union(encoded_newlines), -1)
|
||||
rescue Encoding::ConverterNotFoundError
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -92,6 +92,10 @@
|
||||
".cl",
|
||||
".lisp"
|
||||
],
|
||||
"Component Pascal": [
|
||||
".cp",
|
||||
".cps"
|
||||
],
|
||||
"Coq": [
|
||||
".v"
|
||||
],
|
||||
@@ -562,6 +566,7 @@
|
||||
".nut"
|
||||
],
|
||||
"Standard ML": [
|
||||
".ML",
|
||||
".fun",
|
||||
".sig",
|
||||
".sml"
|
||||
@@ -729,8 +734,8 @@
|
||||
".gemrc"
|
||||
]
|
||||
},
|
||||
"tokens_total": 612725,
|
||||
"languages_total": 799,
|
||||
"tokens_total": 613712,
|
||||
"languages_total": 802,
|
||||
"tokens": {
|
||||
"ABAP": {
|
||||
"*/**": 1,
|
||||
@@ -15336,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,
|
||||
@@ -60661,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,
|
||||
@@ -66642,6 +66822,7 @@
|
||||
"COBOL": 90,
|
||||
"CoffeeScript": 2951,
|
||||
"Common Lisp": 2186,
|
||||
"Component Pascal": 825,
|
||||
"Coq": 18259,
|
||||
"Creole": 134,
|
||||
"Crystal": 1506,
|
||||
@@ -66775,7 +66956,7 @@
|
||||
"SourcePawn": 2080,
|
||||
"SQL": 1485,
|
||||
"Squirrel": 130,
|
||||
"Standard ML": 6405,
|
||||
"Standard ML": 6567,
|
||||
"Stata": 3133,
|
||||
"Stylus": 76,
|
||||
"SuperCollider": 133,
|
||||
@@ -66829,6 +67010,7 @@
|
||||
"COBOL": 4,
|
||||
"CoffeeScript": 9,
|
||||
"Common Lisp": 3,
|
||||
"Component Pascal": 2,
|
||||
"Coq": 12,
|
||||
"Creole": 1,
|
||||
"Crystal": 3,
|
||||
@@ -66962,7 +67144,7 @@
|
||||
"SourcePawn": 1,
|
||||
"SQL": 5,
|
||||
"Squirrel": 1,
|
||||
"Standard ML": 4,
|
||||
"Standard ML": 5,
|
||||
"Stata": 7,
|
||||
"Stylus": 1,
|
||||
"SuperCollider": 1,
|
||||
@@ -66991,5 +67173,5 @@
|
||||
"Zephir": 2,
|
||||
"Zimpl": 1
|
||||
},
|
||||
"md5": "482e5e1de8ec47e0b556809c8fe6f62b"
|
||||
"md5": "4754c31a712c5e22354851fd14d4d4fa"
|
||||
}
|
||||
@@ -168,6 +168,9 @@
|
||||
- (^|/)extjs/src/
|
||||
- (^|/)extjs/welcome/
|
||||
|
||||
# Html5shiv
|
||||
- (^|/)html5shiv(\.min)?\.js$
|
||||
|
||||
# Samples folders
|
||||
- ^[Ss]amples/
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module Linguist
|
||||
VERSION = "2.11.3"
|
||||
VERSION = "2.11.4"
|
||||
end
|
||||
|
||||
130
samples/Component Pascal/Example.cp
Normal file
130
samples/Component Pascal/Example.cp
Normal 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.
|
||||
71
samples/Component Pascal/Example2.cps
Normal file
71
samples/Component Pascal/Example2.cps
Normal 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.
|
||||
75
samples/Standard ML/Foo.ML
Normal file
75
samples/Standard ML/Foo.ML
Normal 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)
|
||||
43
samples/Text/ISO-2022-KR.txt
Normal file
43
samples/Text/ISO-2022-KR.txt
Normal 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
|
||||
@@ -102,10 +102,17 @@ class TestBlob < Test::Unit::TestCase
|
||||
|
||||
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
|
||||
|
||||
@@ -364,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?
|
||||
|
||||
Reference in New Issue
Block a user