From 5fb6f34d8a0eae531974fcc55a7495596481193d Mon Sep 17 00:00:00 2001 From: Pat Pannuto Date: Thu, 5 Dec 2013 14:55:00 -0500 Subject: [PATCH 01/53] Add misser lexer entry for nesC to languages.yml The nesC entry in the languages.yml file was missing a lexer entry and thus wasn't getting picked up. This adds the required lexer line. --- lib/linguist/languages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 8fac5414..14355256 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1734,6 +1734,7 @@ mupad: nesC: type: programming color: "#ffce3b" + lexer: nesc primary_extension: .nc ooc: From a3aaa1ec4d7e91bf7c2c297e9abbe422e3a849f4 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Wed, 2 Apr 2014 12:41:54 +0100 Subject: [PATCH 02/53] included sample and extension .ML extension for Standard ML files --- lib/linguist/languages.yml | 1 + lib/linguist/samples.json | 654 +++++++++++++++++++++++++++++++++---- samples/Standard ML/Foo.ML | 75 +++++ 3 files changed, 668 insertions(+), 62 deletions(-) create mode 100644 samples/Standard ML/Foo.ML diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 6eb2a378..103ab9a9 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1667,6 +1667,7 @@ Standard ML: - sml primary_extension: .sml extensions: + - .ML - .fun Stylus: diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index 6d26388a..35ce56ba 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -237,6 +237,9 @@ "Markdown": [ ".md" ], + "Mask": [ + ".mask" + ], "Matlab": [ ".m" ], @@ -417,6 +420,9 @@ ".sh", ".zsh" ], + "Shen": [ + ".shen" + ], "Slash": [ ".sl" ], @@ -424,6 +430,7 @@ ".nut" ], "Standard ML": [ + ".ML", ".fun", ".sig", ".sml" @@ -488,6 +495,9 @@ ], "Xtend": [ ".xtend" + ], + "YAML": [ + ".yml" ] }, "interpreters": { @@ -551,8 +561,8 @@ ".gemrc" ] }, - "tokens_total": 450556, - "languages_total": 548, + "tokens_total": 454311, + "languages_total": 554, "tokens": { "ABAP": { "*/**": 1, @@ -30365,6 +30375,55 @@ "Markdown": { "Tender": 1 }, + "Mask": { + "header": 1, + "{": 10, + "img": 1, + ".logo": 1, + "src": 1, + "alt": 1, + "logo": 1, + ";": 3, + "h4": 1, + "if": 1, + "(": 3, + "currentUser": 1, + ")": 3, + ".account": 1, + "a": 1, + "href": 1, + "}": 10, + ".view": 1, + "ul": 1, + "for": 1, + "user": 1, + "index": 1, + "of": 1, + "users": 1, + "li.user": 1, + "data": 1, + "-": 3, + "id": 1, + ".name": 1, + ".count": 1, + ".date": 1, + "countdownComponent": 1, + "input": 1, + "type": 1, + "text": 1, + "dualbind": 1, + "value": 1, + "button": 1, + "x": 2, + "signal": 1, + "h5": 1, + "animation": 1, + "slot": 1, + "@model": 1, + "@next": 1, + "footer": 1, + "bazCompo": 1 + }, "Matlab": { "function": 34, "[": 311, @@ -44077,6 +44136,440 @@ "foodforthought.jpg": 1, "name##*fo": 1 }, + "Shen": { + "*": 47, + "graph.shen": 1, + "-": 747, + "a": 30, + "library": 3, + "for": 12, + "graph": 52, + "definition": 1, + "and": 16, + "manipulation": 1, + "Copyright": 2, + "(": 267, + "C": 6, + ")": 250, + "Eric": 2, + "Schulte": 2, + "***": 5, + "License": 2, + "Redistribution": 2, + "use": 2, + "in": 13, + "source": 4, + "binary": 4, + "forms": 2, + "with": 8, + "or": 2, + "without": 2, + "modification": 2, + "are": 7, + "permitted": 2, + "provided": 4, + "that": 3, + "the": 29, + "following": 6, + "conditions": 6, + "met": 2, + "Redistributions": 4, + "of": 20, + "code": 2, + "must": 4, + "retain": 2, + "above": 4, + "copyright": 4, + "notice": 4, + "this": 4, + "list": 32, + "disclaimer.": 2, + "form": 2, + "reproduce": 2, + "disclaimer": 2, + "documentation": 2, + "and/or": 2, + "other": 2, + "materials": 2, + "distribution.": 2, + "THIS": 4, + "SOFTWARE": 4, + "IS": 2, + "PROVIDED": 2, + "BY": 2, + "THE": 10, + "COPYRIGHT": 4, + "HOLDERS": 2, + "AND": 8, + "CONTRIBUTORS": 4, + "ANY": 8, + "EXPRESS": 2, + "OR": 16, + "IMPLIED": 4, + "WARRANTIES": 4, + "INCLUDING": 6, + "BUT": 4, + "NOT": 4, + "LIMITED": 4, + "TO": 4, + "OF": 16, + "MERCHANTABILITY": 2, + "FITNESS": 2, + "FOR": 4, + "A": 32, + "PARTICULAR": 2, + "PURPOSE": 2, + "ARE": 2, + "DISCLAIMED.": 2, + "IN": 6, + "NO": 2, + "EVENT": 2, + "SHALL": 2, + "HOLDER": 2, + "BE": 2, + "LIABLE": 2, + "DIRECT": 2, + "INDIRECT": 2, + "INCIDENTAL": 2, + "SPECIAL": 2, + "EXEMPLARY": 2, + "CONSEQUENTIAL": 2, + "DAMAGES": 2, + "PROCUREMENT": 2, + "SUBSTITUTE": 2, + "GOODS": 2, + "SERVICES": 2, + ";": 12, + "LOSS": 2, + "USE": 4, + "DATA": 2, + "PROFITS": 2, + "BUSINESS": 2, + "INTERRUPTION": 2, + "HOWEVER": 2, + "CAUSED": 2, + "ON": 2, + "THEORY": 2, + "LIABILITY": 4, + "WHETHER": 2, + "CONTRACT": 2, + "STRICT": 2, + "TORT": 2, + "NEGLIGENCE": 2, + "OTHERWISE": 2, + "ARISING": 2, + "WAY": 2, + "OUT": 2, + "EVEN": 2, + "IF": 2, + "ADVISED": 2, + "POSSIBILITY": 2, + "SUCH": 2, + "DAMAGE.": 2, + "Commentary": 2, + "Graphs": 1, + "represented": 1, + "as": 2, + "two": 1, + "dictionaries": 1, + "one": 2, + "vertices": 17, + "edges.": 1, + "It": 1, + "is": 5, + "important": 1, + "to": 16, + "note": 1, + "dictionary": 3, + "implementation": 1, + "used": 2, + "able": 1, + "accept": 1, + "arbitrary": 1, + "data": 17, + "structures": 1, + "keys.": 1, + "This": 1, + "structure": 2, + "technically": 1, + "encodes": 1, + "hypergraphs": 1, + "generalization": 1, + "graphs": 1, + "which": 1, + "each": 1, + "edge": 32, + "may": 1, + "contain": 2, + "any": 1, + "number": 12, + ".": 1, + "Examples": 1, + "regular": 1, + "G": 25, + "hypergraph": 1, + "H": 3, + "corresponding": 1, + "given": 4, + "below.": 1, + "": 3, + "Vertices": 11, + "Edges": 9, + "+": 33, + "Graph": 65, + "hash": 8, + "|": 103, + "key": 9, + "value": 17, + "b": 13, + "c": 11, + "g": 19, + "[": 93, + "]": 91, + "d": 12, + "e": 14, + "f": 10, + "Hypergraph": 1, + "h": 3, + "i": 3, + "j": 2, + "associated": 1, + "edge/vertex": 1, + "@p": 17, + "V": 48, + "#": 4, + "E": 20, + "edges": 17, + "M": 4, + "vertex": 29, + "associations": 1, + "size": 2, + "all": 3, + "stored": 1, + "dict": 39, + "sizeof": 4, + "int": 1, + "indices": 1, + "into": 1, + "&": 1, + "Edge": 11, + "dicts": 3, + "entry": 2, + "storage": 2, + "Vertex": 3, + "Code": 1, + "require": 2, + "sequence": 2, + "datatype": 1, + "dictoinary": 1, + "vector": 4, + "symbol": 1, + "package": 2, + "add": 25, + "has": 5, + "neighbors": 8, + "connected": 21, + "components": 8, + "partition": 7, + "bipartite": 3, + "included": 2, + "from": 3, + "take": 2, + "drop": 2, + "while": 2, + "range": 1, + "flatten": 1, + "filter": 2, + "complement": 1, + "seperate": 1, + "zip": 1, + "indexed": 1, + "reduce": 3, + "mapcon": 3, + "unique": 3, + "frequencies": 1, + "shuffle": 1, + "pick": 1, + "remove": 2, + "first": 2, + "interpose": 1, + "subset": 3, + "cartesian": 1, + "product": 1, + "<-dict>": 5, + "contents": 1, + "keys": 3, + "vals": 1, + "make": 10, + "define": 34, + "X": 4, + "<-address>": 5, + "0": 1, + "create": 1, + "specified": 1, + "sizes": 2, + "}": 22, + "Vertsize": 2, + "Edgesize": 2, + "let": 9, + "absvector": 1, + "do": 8, + "address": 5, + "defmacro": 3, + "macro": 3, + "return": 4, + "taking": 1, + "optional": 1, + "N": 7, + "vert": 12, + "1": 1, + "2": 3, + "{": 15, + "get": 3, + "Value": 3, + "if": 8, + "tuple": 3, + "fst": 3, + "error": 7, + "string": 3, + "resolve": 6, + "Vector": 2, + "Index": 2, + "Place": 6, + "nth": 1, + "<-vector>": 2, + "Vert": 5, + "Val": 5, + "trap": 4, + "snd": 2, + "map": 5, + "lambda": 1, + "w": 4, + "B": 2, + "Data": 2, + "w/o": 5, + "D": 4, + "update": 5, + "an": 3, + "s": 1, + "Vs": 4, + "Store": 6, + "<": 4, + "limit": 2, + "VertLst": 2, + "/.": 4, + "Contents": 5, + "adjoin": 2, + "length": 5, + "EdgeID": 3, + "EdgeLst": 2, + "p": 1, + "boolean": 4, + "Return": 1, + "Already": 5, + "New": 5, + "Reachable": 2, + "difference": 3, + "append": 1, + "including": 1, + "itself": 1, + "fully": 1, + "Acc": 2, + "true": 1, + "_": 1, + "VS": 4, + "Component": 6, + "ES": 3, + "Con": 8, + "verts": 4, + "cons": 1, + "place": 3, + "partitions": 1, + "element": 2, + "simple": 3, + "CS": 3, + "Neighbors": 3, + "empty": 1, + "intersection": 1, + "check": 1, + "tests": 1, + "set": 1, + "chris": 6, + "patton": 2, + "eric": 1, + "nobody": 2, + "fail": 1, + "when": 1, + "wrapper": 1, + "function": 1, + "html.shen": 1, + "html": 2, + "generation": 1, + "functions": 1, + "shen": 1, + "The": 1, + "standard": 1, + "lisp": 1, + "conversion": 1, + "tool": 1, + "suite.": 1, + "Follows": 1, + "some": 1, + "convertions": 1, + "Clojure": 1, + "tasks": 1, + "stuff": 1, + "todo1": 1, + "today": 1, + "attributes": 1, + "AS": 1, + "load": 1, + "JSON": 1, + "Lexer": 1, + "Read": 1, + "stream": 1, + "characters": 4, + "Whitespace": 4, + "not": 1, + "strings": 2, + "should": 2, + "be": 2, + "discarded.": 1, + "preserved": 1, + "Strings": 1, + "can": 1, + "escaped": 1, + "double": 1, + "quotes.": 1, + "e.g.": 2, + "whitespacep": 2, + "ASCII": 2, + "Space.": 1, + "All": 1, + "others": 1, + "whitespace": 7, + "table.": 1, + "Char": 4, + "member": 1, + "replace": 3, + "@s": 4, + "Suffix": 4, + "where": 2, + "Prefix": 2, + "fetch": 1, + "until": 1, + "unescaped": 1, + "doublequote": 1, + "c#34": 5, + "WhitespaceChar": 2, + "Chars": 4, + "strip": 2, + "chars": 2, + "tokenise": 1, + "JSONString": 2, + "CharList": 2, + "explode": 1 + }, "Slash": { "<%>": 1, "class": 11, @@ -44203,67 +44696,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, @@ -48459,7 +48952,7 @@ }, "YAML": { "gem": 1, - "-": 16, + "-": 25, "local": 1, "gen": 1, "rdoc": 2, @@ -48471,7 +48964,40 @@ "numbers": 1, "gempath": 1, "/usr/local/rubygems": 1, - "/home/gavin/.rubygems": 1 + "/home/gavin/.rubygems": 1, + "http_interactions": 1, + "request": 1, + "method": 1, + "get": 1, + "uri": 1, + "http": 1, + "//example.com/": 1, + "body": 3, + "headers": 2, + "{": 1, + "}": 1, + "response": 2, + "status": 1, + "code": 1, + "message": 1, + "OK": 1, + "Content": 2, + "Type": 1, + "text/html": 1, + ";": 1, + "charset": 1, + "utf": 1, + "Length": 1, + "This": 1, + "is": 1, + "the": 1, + "http_version": 1, + "recorded_at": 1, + "Tue": 1, + "Nov": 1, + "GMT": 1, + "recorded_with": 1, + "VCR": 1 } }, "language_tokens": { @@ -48544,6 +49070,7 @@ "M": 23373, "Makefile": 50, "Markdown": 1, + "Mask": 74, "Matlab": 11942, "Max": 714, "MediaWiki": 766, @@ -48594,9 +49121,10 @@ "Scilab": 69, "SCSS": 39, "Shell": 3744, + "Shen": 3472, "Slash": 187, "Squirrel": 130, - "Standard ML": 6405, + "Standard ML": 6567, "Stylus": 76, "SuperCollider": 133, "Tea": 3, @@ -48617,7 +49145,7 @@ "XQuery": 801, "XSLT": 44, "Xtend": 399, - "YAML": 30 + "YAML": 77 }, "languages": { "ABAP": 1, @@ -48689,6 +49217,7 @@ "M": 28, "Makefile": 2, "Markdown": 1, + "Mask": 1, "Matlab": 39, "Max": 3, "MediaWiki": 1, @@ -48739,9 +49268,10 @@ "Scilab": 3, "SCSS": 1, "Shell": 37, + "Shen": 3, "Slash": 1, "Squirrel": 1, - "Standard ML": 4, + "Standard ML": 5, "Stylus": 1, "SuperCollider": 1, "Tea": 1, @@ -48762,7 +49292,7 @@ "XQuery": 1, "XSLT": 1, "Xtend": 2, - "YAML": 1 + "YAML": 2 }, - "md5": "cfe1841f5e4b2ab14a1ad53ad64523b8" + "md5": "4508fdb043a1f43e9a2250f9b4216e5a" } \ No newline at end of file diff --git a/samples/Standard ML/Foo.ML b/samples/Standard ML/Foo.ML new file mode 100644 index 00000000..2bbb789e --- /dev/null +++ b/samples/Standard ML/Foo.ML @@ -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) From 9ae0bdbb434aa8f2a92b4c805712fa0f99e03b1c Mon Sep 17 00:00:00 2001 From: Julian Gehring Date: Thu, 3 Apr 2014 21:29:18 +0200 Subject: [PATCH 03/53] Add R package ignores to vendor.yml Ignore vignette and external data directories which contain no R source code --- lib/linguist/vendor.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index 135f367c..53f66bc0 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -182,3 +182,7 @@ # .DS_Store's - .[Dd][Ss]_[Ss]tore$ + +# R packages +- vignettes/ +- inst/extdata/ From 868e9df4345d7e49556370edb3e09b89b222e764 Mon Sep 17 00:00:00 2001 From: Mikkel Madsen Date: Tue, 13 May 2014 08:56:08 +0200 Subject: [PATCH 04/53] Add html5shiv to vendor.yml --- lib/linguist/vendor.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index 1380cdcb..d614672a 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -168,6 +168,9 @@ - (^|/)extjs/src/ - (^|/)extjs/welcome/ +# Html5shiv +- (^|/)html5shiv\.js$ + # Samples folders - ^[Ss]amples/ From 91877056fb5f246bdf0d14a2c3a592cb72c32cf3 Mon Sep 17 00:00:00 2001 From: Mikkel Madsen Date: Tue, 13 May 2014 09:00:43 +0200 Subject: [PATCH 05/53] Extend vendor test for html5shiv --- test/test_blob.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test_blob.rb b/test/test_blob.rb index ec1443ad..6c6109b9 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -341,6 +341,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? From dcc598442b23bb6179c929b014b28a8d75397fc9 Mon Sep 17 00:00:00 2001 From: Mikkel Madsen Date: Tue, 13 May 2014 09:01:37 +0200 Subject: [PATCH 06/53] Handle minified html5shiv --- lib/linguist/vendor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index d614672a..1058d14d 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -169,7 +169,7 @@ - (^|/)extjs/welcome/ # Html5shiv -- (^|/)html5shiv\.js$ +- (^|/)html5shiv(\.min)?\.js$ # Samples folders - ^[Ss]amples/ From 7aad5f93e4e68c02cc005ceab5110bd2deffcb79 Mon Sep 17 00:00:00 2001 From: ilovb Date: Fri, 16 May 2014 19:36:39 +0400 Subject: [PATCH 07/53] Support of the Component Pascal language http://en.wikipedia.org/wiki/Component_Pascal --- lib/linguist/languages.yml | 13 +++ samples/Component Pascal/Example.cp | 130 ++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 samples/Component Pascal/Example.cp diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 7350bb2a..ea50a4af 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -211,6 +211,11 @@ Befunge: extensions: - .befunge +Component Pascal Document: + type: programming + extensions: + - .odc + BlitzBasic: type: programming aliases: @@ -429,6 +434,14 @@ Common Lisp: - clisp - ecl +Component Pascal: + type: programming + ace_mode: Pascal + color: "#b0ce4e" + extensions: + - .cp + - .cps + Coq: type: programming extensions: diff --git a/samples/Component Pascal/Example.cp b/samples/Component Pascal/Example.cp new file mode 100644 index 00000000..5bace2c4 --- /dev/null +++ b/samples/Component Pascal/Example.cp @@ -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. From 4b6f05b4d12b827075d4721f4cf7dc8717b5f2bb Mon Sep 17 00:00:00 2001 From: ilovb Date: Fri, 16 May 2014 22:17:05 +0400 Subject: [PATCH 08/53] remove ace mode --- lib/linguist/languages.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index ea50a4af..e0c6ad86 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -436,7 +436,6 @@ Common Lisp: Component Pascal: type: programming - ace_mode: Pascal color: "#b0ce4e" extensions: - .cp From 8e6efc3a7de95bb6807393b42713aa2ff28c0d29 Mon Sep 17 00:00:00 2001 From: ilovb Date: Fri, 16 May 2014 22:39:18 +0400 Subject: [PATCH 09/53] remove Component Pascal Document --- lib/linguist/languages.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index e0c6ad86..192be4ff 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -211,11 +211,6 @@ Befunge: extensions: - .befunge -Component Pascal Document: - type: programming - extensions: - - .odc - BlitzBasic: type: programming aliases: From c2b53db96d1d3862d029d673880c8100ad2794bd Mon Sep 17 00:00:00 2001 From: ilovb Date: Fri, 16 May 2014 23:08:28 +0400 Subject: [PATCH 10/53] remove Component Pascal examples --- samples/Component Pascal/Example.cp | 130 ---------------------------- 1 file changed, 130 deletions(-) delete mode 100644 samples/Component Pascal/Example.cp diff --git a/samples/Component Pascal/Example.cp b/samples/Component Pascal/Example.cp deleted file mode 100644 index 5bace2c4..00000000 --- a/samples/Component Pascal/Example.cp +++ /dev/null @@ -1,130 +0,0 @@ -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. From cf358077095d3d50c8b359f386960c1c1e554bc0 Mon Sep 17 00:00:00 2001 From: ilovb Date: Fri, 16 May 2014 23:29:52 +0400 Subject: [PATCH 11/53] add lexer for Component Pascal --- lib/linguist/languages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 192be4ff..ad3668e2 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -431,6 +431,7 @@ Common Lisp: Component Pascal: type: programming + lexer: Delphi color: "#b0ce4e" extensions: - .cp From 0d0e2195323a6917b230cc880270dcde5772b979 Mon Sep 17 00:00:00 2001 From: ilovb Date: Fri, 16 May 2014 23:47:27 +0400 Subject: [PATCH 12/53] add example for Component Pascal --- samples/Component Pascal/Example.cp | 130 ++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 samples/Component Pascal/Example.cp diff --git a/samples/Component Pascal/Example.cp b/samples/Component Pascal/Example.cp new file mode 100644 index 00000000..5bace2c4 --- /dev/null +++ b/samples/Component Pascal/Example.cp @@ -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. From ac2723abe3ded684d79d935b53dc84b6859cd4fa Mon Sep 17 00:00:00 2001 From: ilovb Date: Sat, 17 May 2014 00:02:34 +0400 Subject: [PATCH 13/53] example 2 for Component Pascal --- samples/Component Pascal/Example2.cps | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 samples/Component Pascal/Example2.cps diff --git a/samples/Component Pascal/Example2.cps b/samples/Component Pascal/Example2.cps new file mode 100644 index 00000000..4c4b3930 --- /dev/null +++ b/samples/Component Pascal/Example2.cps @@ -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. \ No newline at end of file From 8f251e6756ead4c1087057a4db3ec1fe8450b6e4 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Mon, 2 Jun 2014 15:51:44 -0400 Subject: [PATCH 14/53] Adds basic support for the Swift programming language Text only lexer for now until Pygments catches up --- lib/linguist/languages.yml | 6 + lib/linguist/samples.json | 265 ++++++++++++++++++++++++++++++++- samples/Swift/section-11.swift | 4 + samples/Swift/section-13.swift | 8 + samples/Swift/section-15.swift | 2 + samples/Swift/section-17.swift | 1 + samples/Swift/section-19.swift | 10 ++ samples/Swift/section-21.swift | 8 + samples/Swift/section-23.swift | 11 ++ samples/Swift/section-25.swift | 14 ++ samples/Swift/section-27.swift | 11 ++ samples/Swift/section-29.swift | 11 ++ samples/Swift/section-3.swift | 1 + samples/Swift/section-31.swift | 4 + samples/Swift/section-33.swift | 4 + samples/Swift/section-35.swift | 9 ++ samples/Swift/section-37.swift | 9 ++ samples/Swift/section-39.swift | 8 + samples/Swift/section-41.swift | 13 ++ samples/Swift/section-43.swift | 5 + samples/Swift/section-45.swift | 1 + samples/Swift/section-47.swift | 1 + samples/Swift/section-49.swift | 6 + samples/Swift/section-5.swift | 3 + samples/Swift/section-51.swift | 3 + samples/Swift/section-53.swift | 12 ++ samples/Swift/section-55.swift | 20 +++ samples/Swift/section-57.swift | 26 ++++ samples/Swift/section-59.swift | 21 +++ samples/Swift/section-61.swift | 8 + samples/Swift/section-63.swift | 2 + samples/Swift/section-65.swift | 21 +++ samples/Swift/section-67.swift | 3 + samples/Swift/section-69.swift | 17 +++ samples/Swift/section-7.swift | 3 + samples/Swift/section-71.swift | 9 ++ samples/Swift/section-73.swift | 14 ++ samples/Swift/section-75.swift | 4 + samples/Swift/section-77.swift | 20 +++ samples/Swift/section-79.swift | 9 ++ samples/Swift/section-81.swift | 3 + samples/Swift/section-83.swift | 8 + samples/Swift/section-85.swift | 7 + samples/Swift/section-87.swift | 11 ++ samples/Swift/section-9.swift | 3 + 45 files changed, 636 insertions(+), 3 deletions(-) create mode 100644 samples/Swift/section-11.swift create mode 100644 samples/Swift/section-13.swift create mode 100644 samples/Swift/section-15.swift create mode 100644 samples/Swift/section-17.swift create mode 100644 samples/Swift/section-19.swift create mode 100644 samples/Swift/section-21.swift create mode 100644 samples/Swift/section-23.swift create mode 100644 samples/Swift/section-25.swift create mode 100644 samples/Swift/section-27.swift create mode 100644 samples/Swift/section-29.swift create mode 100644 samples/Swift/section-3.swift create mode 100644 samples/Swift/section-31.swift create mode 100644 samples/Swift/section-33.swift create mode 100644 samples/Swift/section-35.swift create mode 100644 samples/Swift/section-37.swift create mode 100644 samples/Swift/section-39.swift create mode 100644 samples/Swift/section-41.swift create mode 100644 samples/Swift/section-43.swift create mode 100644 samples/Swift/section-45.swift create mode 100644 samples/Swift/section-47.swift create mode 100644 samples/Swift/section-49.swift create mode 100644 samples/Swift/section-5.swift create mode 100644 samples/Swift/section-51.swift create mode 100644 samples/Swift/section-53.swift create mode 100644 samples/Swift/section-55.swift create mode 100644 samples/Swift/section-57.swift create mode 100644 samples/Swift/section-59.swift create mode 100644 samples/Swift/section-61.swift create mode 100644 samples/Swift/section-63.swift create mode 100644 samples/Swift/section-65.swift create mode 100644 samples/Swift/section-67.swift create mode 100644 samples/Swift/section-69.swift create mode 100644 samples/Swift/section-7.swift create mode 100644 samples/Swift/section-71.swift create mode 100644 samples/Swift/section-73.swift create mode 100644 samples/Swift/section-75.swift create mode 100644 samples/Swift/section-77.swift create mode 100644 samples/Swift/section-79.swift create mode 100644 samples/Swift/section-81.swift create mode 100644 samples/Swift/section-83.swift create mode 100644 samples/Swift/section-85.swift create mode 100644 samples/Swift/section-87.swift create mode 100644 samples/Swift/section-9.swift diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 24e27408..974bde31 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2046,6 +2046,12 @@ SuperCollider: extensions: - .scd +Swift: + type: programming + lexer: Text only + extensions: + - .swift + SystemVerilog: type: programming color: "#343761" diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index e7206004..ac1a92ea 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -581,6 +581,9 @@ "SuperCollider": [ ".scd" ], + "Swift": [ + ".swift" + ], "SystemVerilog": [ ".sv", ".svh", @@ -723,8 +726,8 @@ ".gemrc" ] }, - "tokens_total": 611474, - "languages_total": 755, + "tokens_total": 612602, + "languages_total": 798, "tokens": { "ABAP": { "*/**": 1, @@ -61881,6 +61884,260 @@ "wait": 1, ".fork": 1 }, + "Swift": { + "let": 43, + "apples": 1, + "oranges": 1, + "appleSummary": 1, + "fruitSummary": 1, + "var": 42, + "shoppingList": 3, + "[": 18, + "]": 18, + "occupations": 2, + "emptyArray": 1, + "String": 27, + "(": 89, + ")": 89, + "emptyDictionary": 1, + "Dictionary": 1, + "": 1, + "Float": 1, + "//": 1, + "Went": 1, + "shopping": 1, + "and": 1, + "bought": 1, + "everything.": 1, + "individualScores": 2, + "teamScore": 4, + "for": 10, + "score": 2, + "in": 11, + "{": 77, + "if": 6, + "+": 15, + "}": 77, + "else": 1, + "optionalString": 2, + "nil": 1, + "optionalName": 2, + "greeting": 2, + "name": 21, + "vegetable": 2, + "switch": 4, + "case": 21, + "vegetableComment": 4, + "x": 1, + "where": 2, + "x.hasSuffix": 1, + "default": 2, + "interestingNumbers": 2, + "largest": 4, + "kind": 1, + "numbers": 6, + "number": 13, + "n": 5, + "while": 2, + "<": 4, + "*": 7, + "m": 5, + "do": 1, + "firstForLoop": 3, + "i": 6, + "secondForLoop": 3, + ";": 2, + "println": 1, + "func": 24, + "greet": 2, + "day": 1, + "-": 21, + "return": 30, + "getGasPrices": 2, + "Double": 11, + "sumOf": 3, + "Int...": 1, + "Int": 19, + "sum": 3, + "returnFifteen": 2, + "y": 3, + "add": 2, + "makeIncrementer": 2, + "addOne": 2, + "increment": 2, + "hasAnyMatches": 2, + "list": 2, + "condition": 2, + "Bool": 4, + "item": 4, + "true": 2, + "false": 2, + "lessThanTen": 2, + "numbers.map": 2, + "result": 5, + "sort": 1, + "class": 7, + "Shape": 2, + "numberOfSides": 4, + "simpleDescription": 14, + "myVariable": 2, + "myConstant": 1, + "shape": 1, + "shape.numberOfSides": 1, + "shapeDescription": 1, + "shape.simpleDescription": 1, + "NamedShape": 3, + "init": 4, + "self.name": 1, + "Square": 7, + "sideLength": 17, + "self.sideLength": 2, + "super.init": 2, + "area": 1, + "override": 2, + "test": 1, + "test.area": 1, + "test.simpleDescription": 1, + "EquilateralTriangle": 4, + "perimeter": 1, + "get": 2, + "set": 1, + "newValue": 1, + "/": 1, + "triangle": 3, + "triangle.perimeter": 2, + "triangle.sideLength": 2, + "TriangleAndSquare": 2, + "willSet": 2, + "square.sideLength": 1, + "newValue.sideLength": 2, + "square": 2, + "size": 4, + "triangleAndSquare": 1, + "triangleAndSquare.square.sideLength": 1, + "triangleAndSquare.triangle.sideLength": 2, + "triangleAndSquare.square": 1, + "Counter": 2, + "count": 2, + "incrementBy": 1, + "amount": 2, + "numberOfTimes": 2, + "times": 4, + "counter": 1, + "counter.incrementBy": 1, + "optionalSquare": 2, + ".sideLength": 1, + "enum": 4, + "Rank": 2, + "Ace": 1, + "Two": 1, + "Three": 1, + "Four": 1, + "Five": 1, + "Six": 1, + "Seven": 1, + "Eight": 1, + "Nine": 1, + "Ten": 1, + "Jack": 1, + "Queen": 1, + "King": 1, + "self": 3, + ".Ace": 1, + ".Jack": 1, + ".Queen": 1, + ".King": 1, + "self.toRaw": 1, + "ace": 1, + "Rank.Ace": 1, + "aceRawValue": 1, + "ace.toRaw": 1, + "convertedRank": 1, + "Rank.fromRaw": 1, + "threeDescription": 1, + "convertedRank.simpleDescription": 1, + "Suit": 2, + "Spades": 1, + "Hearts": 1, + "Diamonds": 1, + "Clubs": 1, + ".Spades": 2, + ".Hearts": 1, + ".Diamonds": 1, + ".Clubs": 1, + "hearts": 1, + "Suit.Hearts": 1, + "heartsDescription": 1, + "hearts.simpleDescription": 1, + "implicitInteger": 1, + "implicitDouble": 1, + "explicitDouble": 1, + "struct": 2, + "Card": 2, + "rank": 2, + "suit": 2, + "threeOfSpades": 1, + ".Three": 1, + "threeOfSpadesDescription": 1, + "threeOfSpades.simpleDescription": 1, + "ServerResponse": 1, + "Result": 1, + "Error": 1, + "success": 2, + "ServerResponse.Result": 1, + "failure": 1, + "ServerResponse.Error": 1, + ".Result": 1, + "sunrise": 1, + "sunset": 1, + "serverResponse": 2, + ".Error": 1, + "error": 1, + "protocol": 1, + "ExampleProtocol": 5, + "mutating": 3, + "adjust": 4, + "SimpleClass": 2, + "anotherProperty": 1, + "a": 2, + "a.adjust": 1, + "aDescription": 1, + "a.simpleDescription": 1, + "SimpleStructure": 2, + "b": 1, + "b.adjust": 1, + "bDescription": 1, + "b.simpleDescription": 1, + "extension": 1, + "protocolValue": 1, + "protocolValue.simpleDescription": 1, + "repeat": 2, + "": 1, + "ItemType": 3, + "OptionalValue": 2, + "": 1, + "None": 1, + "Some": 1, + "T": 5, + "possibleInteger": 2, + "": 1, + ".None": 1, + ".Some": 1, + "anyCommonElements": 2, + "": 1, + "U": 4, + "Sequence": 2, + "GeneratorType": 3, + "Element": 3, + "Equatable": 1, + "lhs": 2, + "rhs": 2, + "lhsItem": 2, + "rhsItem": 2, + "label": 2, + "width": 2, + "widthLabel": 1 + }, "SystemVerilog": { "module": 3, "endpoint_phy_wrapper": 2, @@ -66478,6 +66735,7 @@ "Stata": 3133, "Stylus": 76, "SuperCollider": 133, + "Swift": 1128, "SystemVerilog": 541, "Tcl": 1133, "Tea": 3, @@ -66663,6 +66921,7 @@ "Stata": 7, "Stylus": 1, "SuperCollider": 1, + "Swift": 43, "SystemVerilog": 4, "Tcl": 2, "Tea": 1, @@ -66686,5 +66945,5 @@ "YAML": 2, "Zephir": 2 }, - "md5": "a7d557f9fecf06444c92c22e6f32daa7" + "md5": "e41e5530c6efe39b710ace7e1d5d318c" } \ No newline at end of file diff --git a/samples/Swift/section-11.swift b/samples/Swift/section-11.swift new file mode 100644 index 00000000..3be056ab --- /dev/null +++ b/samples/Swift/section-11.swift @@ -0,0 +1,4 @@ +let apples = 3 +let oranges = 5 +let appleSummary = "I have \(apples) apples." +let fruitSummary = "I have \(apples + oranges) pieces of fruit." diff --git a/samples/Swift/section-13.swift b/samples/Swift/section-13.swift new file mode 100644 index 00000000..06589fd7 --- /dev/null +++ b/samples/Swift/section-13.swift @@ -0,0 +1,8 @@ +var shoppingList = ["catfish", "water", "tulips", "blue paint"] +shoppingList[1] = "bottle of water" + +var occupations = [ + "Malcolm": "Captain", + "Kaylee": "Mechanic", + ] +occupations["Jayne"] = "Public Relations" diff --git a/samples/Swift/section-15.swift b/samples/Swift/section-15.swift new file mode 100644 index 00000000..3641de25 --- /dev/null +++ b/samples/Swift/section-15.swift @@ -0,0 +1,2 @@ +let emptyArray = String[]() +let emptyDictionary = Dictionary() diff --git a/samples/Swift/section-17.swift b/samples/Swift/section-17.swift new file mode 100644 index 00000000..e079c3b2 --- /dev/null +++ b/samples/Swift/section-17.swift @@ -0,0 +1 @@ +shoppingList = [] // Went shopping and bought everything. diff --git a/samples/Swift/section-19.swift b/samples/Swift/section-19.swift new file mode 100644 index 00000000..262512fc --- /dev/null +++ b/samples/Swift/section-19.swift @@ -0,0 +1,10 @@ +let individualScores = [75, 43, 103, 87, 12] +var teamScore = 0 +for score in individualScores { + if score > 50 { + teamScore += 3 + } else { + teamScore += 1 + } +} +teamScore diff --git a/samples/Swift/section-21.swift b/samples/Swift/section-21.swift new file mode 100644 index 00000000..fb06bd77 --- /dev/null +++ b/samples/Swift/section-21.swift @@ -0,0 +1,8 @@ +var optionalString: String? = "Hello" +optionalString == nil + +var optionalName: String? = "John Appleseed" +var greeting = "Hello!" +if let name = optionalName { + greeting = "Hello, \(name)" +} diff --git a/samples/Swift/section-23.swift b/samples/Swift/section-23.swift new file mode 100644 index 00000000..09f4747c --- /dev/null +++ b/samples/Swift/section-23.swift @@ -0,0 +1,11 @@ +let vegetable = "red pepper" +switch vegetable { + case "celery": + let vegetableComment = "Add some raisins and make ants on a log." + case "cucumber", "watercress": + let vegetableComment = "That would make a good tea sandwich." + case let x where x.hasSuffix("pepper"): + let vegetableComment = "Is it a spicy \(x)?" + default: + let vegetableComment = "Everything tastes good in soup." +} diff --git a/samples/Swift/section-25.swift b/samples/Swift/section-25.swift new file mode 100644 index 00000000..80e19f9c --- /dev/null +++ b/samples/Swift/section-25.swift @@ -0,0 +1,14 @@ +let interestingNumbers = [ + "Prime": [2, 3, 5, 7, 11, 13], + "Fibonacci": [1, 1, 2, 3, 5, 8], + "Square": [1, 4, 9, 16, 25], +] +var largest = 0 +for (kind, numbers) in interestingNumbers { + for number in numbers { + if number > largest { + largest = number + } + } +} +largest diff --git a/samples/Swift/section-27.swift b/samples/Swift/section-27.swift new file mode 100644 index 00000000..e2feda12 --- /dev/null +++ b/samples/Swift/section-27.swift @@ -0,0 +1,11 @@ +var n = 2 +while n < 100 { + n = n * 2 +} +n + +var m = 2 +do { + m = m * 2 +} while m < 100 +m diff --git a/samples/Swift/section-29.swift b/samples/Swift/section-29.swift new file mode 100644 index 00000000..b269cf97 --- /dev/null +++ b/samples/Swift/section-29.swift @@ -0,0 +1,11 @@ +var firstForLoop = 0 +for i in 0..3 { + firstForLoop += i +} +firstForLoop + +var secondForLoop = 0 +for var i = 0; i < 3; ++i { + secondForLoop += 1 +} +secondForLoop diff --git a/samples/Swift/section-3.swift b/samples/Swift/section-3.swift new file mode 100644 index 00000000..47ea7d53 --- /dev/null +++ b/samples/Swift/section-3.swift @@ -0,0 +1 @@ +println("Hello, world") diff --git a/samples/Swift/section-31.swift b/samples/Swift/section-31.swift new file mode 100644 index 00000000..9b77ea62 --- /dev/null +++ b/samples/Swift/section-31.swift @@ -0,0 +1,4 @@ +func greet(name: String, day: String) -> String { + return "Hello \(name), today is \(day)." +} +greet("Bob", "Tuesday") diff --git a/samples/Swift/section-33.swift b/samples/Swift/section-33.swift new file mode 100644 index 00000000..89361a75 --- /dev/null +++ b/samples/Swift/section-33.swift @@ -0,0 +1,4 @@ +func getGasPrices() -> (Double, Double, Double) { + return (3.59, 3.69, 3.79) +} +getGasPrices() diff --git a/samples/Swift/section-35.swift b/samples/Swift/section-35.swift new file mode 100644 index 00000000..c724746f --- /dev/null +++ b/samples/Swift/section-35.swift @@ -0,0 +1,9 @@ +func sumOf(numbers: Int...) -> Int { + var sum = 0 + for number in numbers { + sum += number + } + return sum +} +sumOf() +sumOf(42, 597, 12) diff --git a/samples/Swift/section-37.swift b/samples/Swift/section-37.swift new file mode 100644 index 00000000..f78fdbe9 --- /dev/null +++ b/samples/Swift/section-37.swift @@ -0,0 +1,9 @@ +func returnFifteen() -> Int { + var y = 10 + func add() { + y += 5 + } + add() + return y +} +returnFifteen() diff --git a/samples/Swift/section-39.swift b/samples/Swift/section-39.swift new file mode 100644 index 00000000..d2fa5fe3 --- /dev/null +++ b/samples/Swift/section-39.swift @@ -0,0 +1,8 @@ +func makeIncrementer() -> (Int -> Int) { + func addOne(number: Int) -> Int { + return 1 + number + } + return addOne +} +var increment = makeIncrementer() +increment(7) diff --git a/samples/Swift/section-41.swift b/samples/Swift/section-41.swift new file mode 100644 index 00000000..e72d410a --- /dev/null +++ b/samples/Swift/section-41.swift @@ -0,0 +1,13 @@ +func hasAnyMatches(list: Int[], condition: Int -> Bool) -> Bool { + for item in list { + if condition(item) { + return true + } + } + return false +} +func lessThanTen(number: Int) -> Bool { + return number < 10 +} +var numbers = [20, 19, 7, 12] +hasAnyMatches(numbers, lessThanTen) diff --git a/samples/Swift/section-43.swift b/samples/Swift/section-43.swift new file mode 100644 index 00000000..5dee10f7 --- /dev/null +++ b/samples/Swift/section-43.swift @@ -0,0 +1,5 @@ +numbers.map({ + (number: Int) -> Int in + let result = 3 * number + return result +}) diff --git a/samples/Swift/section-45.swift b/samples/Swift/section-45.swift new file mode 100644 index 00000000..dbf29eed --- /dev/null +++ b/samples/Swift/section-45.swift @@ -0,0 +1 @@ +numbers.map({ number in 3 * number }) diff --git a/samples/Swift/section-47.swift b/samples/Swift/section-47.swift new file mode 100644 index 00000000..73defb77 --- /dev/null +++ b/samples/Swift/section-47.swift @@ -0,0 +1 @@ +sort([1, 5, 3, 12, 2]) { $0 > $1 } diff --git a/samples/Swift/section-49.swift b/samples/Swift/section-49.swift new file mode 100644 index 00000000..69739b8d --- /dev/null +++ b/samples/Swift/section-49.swift @@ -0,0 +1,6 @@ +class Shape { + var numberOfSides = 0 + func simpleDescription() -> String { + return "A shape with \(numberOfSides) sides." + } +} diff --git a/samples/Swift/section-5.swift b/samples/Swift/section-5.swift new file mode 100644 index 00000000..885d5812 --- /dev/null +++ b/samples/Swift/section-5.swift @@ -0,0 +1,3 @@ +var myVariable = 42 +myVariable = 50 +let myConstant = 42 diff --git a/samples/Swift/section-51.swift b/samples/Swift/section-51.swift new file mode 100644 index 00000000..a84750c8 --- /dev/null +++ b/samples/Swift/section-51.swift @@ -0,0 +1,3 @@ +var shape = Shape() +shape.numberOfSides = 7 +var shapeDescription = shape.simpleDescription() diff --git a/samples/Swift/section-53.swift b/samples/Swift/section-53.swift new file mode 100644 index 00000000..74aac461 --- /dev/null +++ b/samples/Swift/section-53.swift @@ -0,0 +1,12 @@ +class NamedShape { + var numberOfSides: Int = 0 + var name: String + + init(name: String) { + self.name = name + } + + func simpleDescription() -> String { + return "A shape with \(numberOfSides) sides." + } +} diff --git a/samples/Swift/section-55.swift b/samples/Swift/section-55.swift new file mode 100644 index 00000000..6e489078 --- /dev/null +++ b/samples/Swift/section-55.swift @@ -0,0 +1,20 @@ +class Square: NamedShape { + var sideLength: Double + + init(sideLength: Double, name: String) { + self.sideLength = sideLength + super.init(name: name) + numberOfSides = 4 + } + + func area() -> Double { + return sideLength * sideLength + } + + override func simpleDescription() -> String { + return "A square with sides of length \(sideLength)." + } +} +let test = Square(sideLength: 5.2, name: "my test square") +test.area() +test.simpleDescription() diff --git a/samples/Swift/section-57.swift b/samples/Swift/section-57.swift new file mode 100644 index 00000000..90d2e03c --- /dev/null +++ b/samples/Swift/section-57.swift @@ -0,0 +1,26 @@ +class EquilateralTriangle: NamedShape { + var sideLength: Double = 0.0 + + init(sideLength: Double, name: String) { + self.sideLength = sideLength + super.init(name: name) + numberOfSides = 3 + } + + var perimeter: Double { + get { + return 3.0 * sideLength + } + set { + sideLength = newValue / 3.0 + } + } + + override func simpleDescription() -> String { + return "An equilateral triagle with sides of length \(sideLength)." + } +} +var triangle = EquilateralTriangle(sideLength: 3.1, name: "a triangle") +triangle.perimeter +triangle.perimeter = 9.9 +triangle.sideLength diff --git a/samples/Swift/section-59.swift b/samples/Swift/section-59.swift new file mode 100644 index 00000000..21e3b09d --- /dev/null +++ b/samples/Swift/section-59.swift @@ -0,0 +1,21 @@ +class TriangleAndSquare { + var triangle: EquilateralTriangle { + willSet { + square.sideLength = newValue.sideLength + } + } + var square: Square { + willSet { + triangle.sideLength = newValue.sideLength + } + } + init(size: Double, name: String) { + square = Square(sideLength: size, name: name) + triangle = EquilateralTriangle(sideLength: size, name: name) + } +} +var triangleAndSquare = TriangleAndSquare(size: 10, name: "another test shape") +triangleAndSquare.square.sideLength +triangleAndSquare.triangle.sideLength +triangleAndSquare.square = Square(sideLength: 50, name: "larger square") +triangleAndSquare.triangle.sideLength diff --git a/samples/Swift/section-61.swift b/samples/Swift/section-61.swift new file mode 100644 index 00000000..013ded74 --- /dev/null +++ b/samples/Swift/section-61.swift @@ -0,0 +1,8 @@ +class Counter { + var count: Int = 0 + func incrementBy(amount: Int, numberOfTimes times: Int) { + count += amount * times + } +} +var counter = Counter() +counter.incrementBy(2, numberOfTimes: 7) diff --git a/samples/Swift/section-63.swift b/samples/Swift/section-63.swift new file mode 100644 index 00000000..9305cfc7 --- /dev/null +++ b/samples/Swift/section-63.swift @@ -0,0 +1,2 @@ +let optionalSquare: Square? = Square(sideLength: 2.5, name: "optional square") +let sideLength = optionalSquare?.sideLength diff --git a/samples/Swift/section-65.swift b/samples/Swift/section-65.swift new file mode 100644 index 00000000..809c71ce --- /dev/null +++ b/samples/Swift/section-65.swift @@ -0,0 +1,21 @@ +enum Rank: Int { + case Ace = 1 + case Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten + case Jack, Queen, King + func simpleDescription() -> String { + switch self { + case .Ace: + return "ace" + case .Jack: + return "jack" + case .Queen: + return "queen" + case .King: + return "king" + default: + return String(self.toRaw()) + } + } +} +let ace = Rank.Ace +let aceRawValue = ace.toRaw() diff --git a/samples/Swift/section-67.swift b/samples/Swift/section-67.swift new file mode 100644 index 00000000..d5be66c2 --- /dev/null +++ b/samples/Swift/section-67.swift @@ -0,0 +1,3 @@ +if let convertedRank = Rank.fromRaw(3) { + let threeDescription = convertedRank.simpleDescription() +} diff --git a/samples/Swift/section-69.swift b/samples/Swift/section-69.swift new file mode 100644 index 00000000..fc6d7a4c --- /dev/null +++ b/samples/Swift/section-69.swift @@ -0,0 +1,17 @@ +enum Suit { + case Spades, Hearts, Diamonds, Clubs + func simpleDescription() -> String { + switch self { + case .Spades: + return "spades" + case .Hearts: + return "hearts" + case .Diamonds: + return "diamonds" + case .Clubs: + return "clubs" + } + } +} +let hearts = Suit.Hearts +let heartsDescription = hearts.simpleDescription() diff --git a/samples/Swift/section-7.swift b/samples/Swift/section-7.swift new file mode 100644 index 00000000..7d55c034 --- /dev/null +++ b/samples/Swift/section-7.swift @@ -0,0 +1,3 @@ +let implicitInteger = 70 +let implicitDouble = 70.0 +let explicitDouble: Double = 70 diff --git a/samples/Swift/section-71.swift b/samples/Swift/section-71.swift new file mode 100644 index 00000000..f006d0f9 --- /dev/null +++ b/samples/Swift/section-71.swift @@ -0,0 +1,9 @@ +struct Card { + var rank: Rank + var suit: Suit + func simpleDescription() -> String { + return "The \(rank.simpleDescription()) of \(suit.simpleDescription())" + } +} +let threeOfSpades = Card(rank: .Three, suit: .Spades) +let threeOfSpadesDescription = threeOfSpades.simpleDescription() diff --git a/samples/Swift/section-73.swift b/samples/Swift/section-73.swift new file mode 100644 index 00000000..be0cf35f --- /dev/null +++ b/samples/Swift/section-73.swift @@ -0,0 +1,14 @@ +enum ServerResponse { + case Result(String, String) + case Error(String) +} + +let success = ServerResponse.Result("6:00 am", "8:09 pm") +let failure = ServerResponse.Error("Out of cheese.") + +switch success { + case let .Result(sunrise, sunset): + let serverResponse = "Sunrise is at \(sunrise) and sunset is at \(sunset)." + case let .Error(error): + let serverResponse = "Failure... \(error)" +} diff --git a/samples/Swift/section-75.swift b/samples/Swift/section-75.swift new file mode 100644 index 00000000..46dd36da --- /dev/null +++ b/samples/Swift/section-75.swift @@ -0,0 +1,4 @@ +protocol ExampleProtocol { + var simpleDescription: String { get } + mutating func adjust() +} diff --git a/samples/Swift/section-77.swift b/samples/Swift/section-77.swift new file mode 100644 index 00000000..bc052d20 --- /dev/null +++ b/samples/Swift/section-77.swift @@ -0,0 +1,20 @@ +class SimpleClass: ExampleProtocol { + var simpleDescription: String = "A very simple class." + var anotherProperty: Int = 69105 + func adjust() { + simpleDescription += " Now 100% adjusted." + } +} +var a = SimpleClass() +a.adjust() +let aDescription = a.simpleDescription + +struct SimpleStructure: ExampleProtocol { + var simpleDescription: String = "A simple structure" + mutating func adjust() { + simpleDescription += " (adjusted)" + } +} +var b = SimpleStructure() +b.adjust() +let bDescription = b.simpleDescription diff --git a/samples/Swift/section-79.swift b/samples/Swift/section-79.swift new file mode 100644 index 00000000..0e7b831b --- /dev/null +++ b/samples/Swift/section-79.swift @@ -0,0 +1,9 @@ +extension Int: ExampleProtocol { + var simpleDescription: String { + return "The number \(self)" + } + mutating func adjust() { + self += 42 + } + } +7.simpleDescription diff --git a/samples/Swift/section-81.swift b/samples/Swift/section-81.swift new file mode 100644 index 00000000..74e0a000 --- /dev/null +++ b/samples/Swift/section-81.swift @@ -0,0 +1,3 @@ +let protocolValue: ExampleProtocol = a +protocolValue.simpleDescription +// protocolValue.anotherProperty // Uncomment to see the error diff --git a/samples/Swift/section-83.swift b/samples/Swift/section-83.swift new file mode 100644 index 00000000..aa2e6d75 --- /dev/null +++ b/samples/Swift/section-83.swift @@ -0,0 +1,8 @@ +func repeat(item: ItemType, times: Int) -> ItemType[] { + var result = ItemType[]() + for i in 0..times { + result += item + } + return result +} +repeat("knock", 4) diff --git a/samples/Swift/section-85.swift b/samples/Swift/section-85.swift new file mode 100644 index 00000000..b2f52840 --- /dev/null +++ b/samples/Swift/section-85.swift @@ -0,0 +1,7 @@ +// Reimplement the Swift standard library's optional type +enum OptionalValue { + case None + case Some(T) +} +var possibleInteger: OptionalValue = .None +possibleInteger = .Some(100) diff --git a/samples/Swift/section-87.swift b/samples/Swift/section-87.swift new file mode 100644 index 00000000..f9dc7f33 --- /dev/null +++ b/samples/Swift/section-87.swift @@ -0,0 +1,11 @@ +func anyCommonElements (lhs: T, rhs: U) -> Bool { + for lhsItem in lhs { + for rhsItem in rhs { + if lhsItem == rhsItem { + return true + } + } + } + return false +} +anyCommonElements([1, 2, 3], [3]) diff --git a/samples/Swift/section-9.swift b/samples/Swift/section-9.swift new file mode 100644 index 00000000..2e83efa1 --- /dev/null +++ b/samples/Swift/section-9.swift @@ -0,0 +1,3 @@ +let label = "The width is " +let width = 94 +let widthLabel = label + String(width) From 8d2ea90a5ba3b2fe6e1508b7155aa4632eea2985 Mon Sep 17 00:00:00 2001 From: Arfon Smith Date: Mon, 2 Jun 2014 14:59:12 -0500 Subject: [PATCH 15/53] Bumping to 2.11.2 --- lib/linguist/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/version.rb b/lib/linguist/version.rb index d7627292..9e2d4037 100644 --- a/lib/linguist/version.rb +++ b/lib/linguist/version.rb @@ -1,3 +1,3 @@ module Linguist - VERSION = "2.11.1" + VERSION = "2.11.2" end From a6955f4edb10a2ca54b1971bea853e3bbd72a5d2 Mon Sep 17 00:00:00 2001 From: john howard Date: Mon, 2 Jun 2014 15:09:41 -0700 Subject: [PATCH 16/53] added zmpl language declaration --- lib/linguist/languages.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 24e27408..da8180fa 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2406,3 +2406,8 @@ xBase: color: "#3a4040" extensions: - .prg + +Zimpl: + type: programming + extensions: + - .zmpl From 5b3152d99d809495bb0e8b919a3edf9042a98db1 Mon Sep 17 00:00:00 2001 From: john howard Date: Mon, 2 Jun 2014 15:16:00 -0700 Subject: [PATCH 17/53] Create sample.zmpl --- samples/zmpl/sample.zmpl | 355 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 355 insertions(+) create mode 100644 samples/zmpl/sample.zmpl diff --git a/samples/zmpl/sample.zmpl b/samples/zmpl/sample.zmpl new file mode 100644 index 00000000..50b65102 --- /dev/null +++ b/samples/zmpl/sample.zmpl @@ -0,0 +1,355 @@ +# Mini Manitoba Hydro LP Model +# Written for zimpl 3.0.0a +# Licensed under the MIT license +# Developed for fun using publicly available sources. +# This software comes with no guarantees and no claims that it is fit for any purpose. +# john howard, 1 Dec 2009 + +# Inflows: +# CR churchill river +# LT lower nelson tribs +# SL south indian lake +# RR red river +# WR winnipeg river +# +# Major Storages: +# LW lake winnipeg +# CL cedar lake +# +# Controlled Channels: +# MF missi falls +# NT notigi +# EC east channel +# WC west channel +# +# Generation Projects: +# GR grand rapids +# JP jenpeg +# KE kelsey +# LN lower nelson projects + +# variables and constraints are named the following way: +# Type Subtype 2LetterName Kind Modifier +# (v|k) [c] (..) (q|i|o|p|v|e|s|hk|ss|tw|mb|rc|os|ur) [ Start | End | Max | Min | Adj | Fact | Offset ] + +param kTS := 662; +set sTime := { 1 .. kTS }; + +# for 5 day averaging requires indices spaced 3 apart +set sTime5 := { in sTime with t < (kTS - 1) and t mod 3 == 0 }; + +param kCMSd2KCFSdFact := 35.315 / 1000; + +# column 8 is month +param vMONTH[ sTime ] := read "historical.csv" as "8n" skip 1; +set sMonth := { 1 .. 12 }; + +######################### +### Inital Conditions ### + +# South Indian Lake +param kSLeMin := 840.0; +param kSLeMax := 847.9; +param kSLssFactor := 283.7; +param kSLvMax := (kSLeMax - kSLeMin) * kSLssFactor; + +# Grand Rapids Pond (Cedar Lake) +param kGReMin := 830.0; +param kGReMax := 841.5; +param kGRssFactor := 330.9; +param kGRvMax := (kGReMax - kGReMin) * kGRssFactor; + +# Lake Winnipeg +param kLWeMin := 709.0; +param kLWeMax := 714.75; +param kLWssFactor := 3040.0; +param kLWvMax := (kLWeMax - kLWeMin) * kLWssFactor; + +# Kelsey Pond +param kKEeMin := 0.0; +param kKEeMax := 0.1; # as modelled +param kKEssFactor := 902.0; +param kKEvMax := (kKEeMax - kKEeMin) * kKEssFactor; + +# Storage at aggregate Lower Nelson Projects +param kLNeMin := 0.0; +param kLNeMax := 3.0; # as modelled +param kLNssFactor := 200.0; +param kLNvMax := (kLNeMax - kLNeMin) * kLNssFactor; +param kLNvStart := kLNvMax / 2; + +#################################################################### +### Churchill River through South Indian Lake and Notigi Control ### + +param kNToMin := 15; # control discharge limits (KCFS) +param kNToMax := 35; + +param kMFoMin := 0; # control discharge limits (KCFS) +param kMFoMax := 10; # as modelled +param kMFoFact := 0.001; # adjustments (calibrated for 92-94 peroid) + +var vMFo[ sTime ] >= 1 <= kMFoMax; # Missi Falls acts as spill +var vNTo[ sTime ] >= kNToMin <= kNToMax; +var vSLv[ sTime ] >= 0 <= kSLvMax; + +# 2nd column for Churchill River +param vCRq[ sTime ] := read "historical.csv" as "2n" skip 1; + +param kSLiAdj := 2.3; # adjustments (calibrated for 92-94 peroid) +param kSLvStart := kSLvMax / 2; + +# refill +subto kcSLvEnd: vSLv[ kTS ] >= kSLvStart; + +# change-in-storage + outflow == inflow +subto vcSLmb: + forall in sTime do + if ( t == 1 ) then vSLv[ 1 ] - kSLvStart + vMFo[ 1 ] + vNTo[ 1 ] + else vSLv[ t ] - vSLv[ t - 1 ] + vMFo[ t ] + vNTo[ t ] + end + == kCMSd2KCFSdFact * vCRq[ t ] + kSLiAdj; + +# Notigi within-week outflow shaping +param kNTosFact := 0; # as modelled +subto vcNTosA: forall in sTime5 do vNTo[ t - 2 ] >= vNTo[ t ] - kNTosFact; +subto vcNTosB: forall in sTime5 do vNTo[ t - 2 ] <= vNTo[ t ] + kNTosFact; +subto vcNTosC: forall in sTime5 do vNTo[ t - 1 ] >= vNTo[ t ] - kNTosFact; +subto vcNTosD: forall in sTime5 do vNTo[ t - 1 ] <= vNTo[ t ] + kNTosFact; +subto vcNTosE: forall in sTime5 do vNTo[ t + 1 ] >= vNTo[ t ] - kNTosFact; +subto vcNTosF: forall in sTime5 do vNTo[ t + 1 ] <= vNTo[ t ] + kNTosFact; +subto vcNTosG: forall in sTime5 do vNTo[ t + 2 ] >= vNTo[ t ] - kNTosFact; +subto vcNTosH: forall in sTime5 do vNTo[ t + 2 ] <= vNTo[ t ] + kNTosFact; + +########################################################### +### Sask River into Cedar Lake and through Grand Rapids ### + +param kGRoMin := 5; # plant/control discharge limits (KCFS) +param kGRoMax := 53; +param kGRsMin := 0; +param kGRsMax := 40; +param kGRpMax := 472; # generation limits (MW) + +var vGRv[ sTime ] >= 0 <= kGRvMax; +var vGRs[ sTime ] >= kGRsMin <= kGRsMax; +var vGRo[ sTime ] >= kGRoMin <= kGRoMax; +var vGRp[ sTime ] >= 0 <= kGRpMax; + +# 1st column for Sask River +param vSKRq[ sTime ] := read "historical.csv" as "1n" skip 1; + +param kGRhk := 9.2; # plant HK factors (MW/KCFS) +param kGRiAdj := -0.6; # adjustments (calibrated for 92-94 peroid) +param kGRvStart := kGRvMax / 2; + +# refill +subto kcGRvEnd: vGRv[ kTS ] >= kGRvStart; + +# change-in-storage + outflow == inflow +subto vcGRmb: + forall in sTime do + if ( t == 1 ) then vGRv[ 1 ] - kGRvStart + vGRo[ 1 ] + vGRs[ 1 ] + else vGRv[ t ] - vGRv[ t - 1 ] + vGRo[ t ] + vGRs[ t ] + end + == kCMSd2KCFSdFact * vSKRq[ t ] + kGRiAdj; + +# compute power from discharge +subto vcGRp: + forall in sTime do + vGRp[ t ] == kGRhk * vGRo[ t ]; + +# Grand Rapids within-week outflow shaping +param kGRosFact := 10; # as modelled +subto vcGRosA: forall in sTime5 do vGRo[ t - 2 ] >= vGRo[ t ] - kGRosFact; +subto vcGRosB: forall in sTime5 do vGRo[ t - 2 ] <= vGRo[ t ] + kGRosFact; +subto vcGRosC: forall in sTime5 do vGRo[ t - 1 ] >= vGRo[ t ] - kGRosFact; +subto vcGRosD: forall in sTime5 do vGRo[ t - 1 ] <= vGRo[ t ] + kGRosFact; +subto vcGRosE: forall in sTime5 do vGRo[ t + 1 ] >= vGRo[ t ] - kGRosFact; +subto vcGRosF: forall in sTime5 do vGRo[ t + 1 ] <= vGRo[ t ] + kGRosFact; +subto vcGRosG: forall in sTime5 do vGRo[ t + 2 ] >= vGRo[ t ] - kGRosFact; +subto vcGRosH: forall in sTime5 do vGRo[ t + 2 ] <= vGRo[ t ] + kGRosFact; + +############################################################################## +### Lake Winnipeg Storage as operated by JENPEG and effect of Each Channel ### + +param kJPoMin := 0; # plant/control discharge limits (KCFS) +param kJPoMax := 93; +param kJPsMin := 0; # plant/control discharge limits (KCFS) +param kJPsMax := 9e9; # as modelled +param kJPpMax := 97; # generation limits (MW) + +var vLWv[ sTime ] >= 0 <= kLWvMax; +var vECo[ sTime ] >= 0; # upper bound determined by rating curve +var vJPo[ sTime ] >= kJPoMin <= kJPoMax; +var vJPs[ sTime ] >= kJPsMin <= kJPsMax; +var vJPp[ sTime ] >= 0 <= kJPpMax; + +# 3rd column for Red River and 4th column for Winnipeg River +param vRRq[ sTime ] := read "historical.csv" as "3n" skip 1; +param vWRq[ sTime ] := read "historical.csv" as "4n" skip 1; + +param kLWiAdj := 11.7; # adjustments (calibrated for 92-94 peroid) +param kLWvStart := kLWvMax / 2; + +param kJPhk := 1; # plant HK factors (MW/KCFS) +param kJPoNovMaxFact := 0; # curves +param kJPoNovMaxOffset := 0; +param kJPtwFact := 0; # TODO +param kJPtwOffset := 0; + +# refill +subto kcLWvEnd: vLWv[ kTS ] >= kLWvStart; + +# change-in-storage + outflow == inflow +subto vcLWmb: + forall in sTime do + if ( t == 1 ) then vLWv[ 1 ] - kLWvStart + vJPo[ 1 ] + vJPs[ 1 ] + vECo[ 1 ] + else vLWv[ t ] - vLWv[ t - 1 ] + vJPo[ t ] + vJPs[ t ] + vECo[ t ] + end + == kCMSd2KCFSdFact * vRRq[ t ] + kCMSd2KCFSdFact * vWRq[ t ] + vGRo[ t ] + vGRs[ t ] + kLWiAdj; + +# compute power from discharge +subto vcJPp: + forall in sTime do + vJPp[ t ] == kJPhk * vJPo[ t ]; + +# West Channel Max Discharge +param vWCoMax[ sMonth ] := <1> 8.6440678, <2> 7.79661017, <3> 7.11864407, <4> 6.61016949, <11> 10.3389831, <12> 9.3220339 default 12.5423729; +subto vJPoA: + forall in sTime cross sMonth with m == vMONTH[ t ] do + vJPo[ t ] <= vLWv[ t ] * vWCoMax[ m ] / kLWssFactor; + +# East Channel Discharge +subto vcECo: + forall in sTime do + vECo[ t ] == vLWv[ t ] * 4.67463938 / kLWssFactor; # convert q/ft (from historical 92-94 period data) to q/v + +# Jenpeg within-week outflow shaping +param kJPosFact := 2; # as modelled +subto vcJPosA: forall in sTime5 do vJPo[ t - 2 ] >= vJPo[ t ] - kJPosFact; +subto vcJPosB: forall in sTime5 do vJPo[ t - 2 ] <= vJPo[ t ] + kJPosFact; +subto vcJPosC: forall in sTime5 do vJPo[ t - 1 ] >= vJPo[ t ] - kJPosFact; +subto vcJPosD: forall in sTime5 do vJPo[ t - 1 ] <= vJPo[ t ] + kJPosFact; +subto vcJPosE: forall in sTime5 do vJPo[ t + 1 ] >= vJPo[ t ] - kJPosFact; +subto vcJPosF: forall in sTime5 do vJPo[ t + 1 ] <= vJPo[ t ] + kJPosFact; +subto vcJPosG: forall in sTime5 do vJPo[ t + 2 ] >= vJPo[ t ] - kJPosFact; +subto vcJPosH: forall in sTime5 do vJPo[ t + 2 ] <= vJPo[ t ] + kJPosFact; + +# Jenpeg intra-week shaping +subto vcJPosI: forall in sTime5 without { kTS - 2 } do vJPo[ t + 3 ] >= vJPo[ t ] - kJPosFact * 2; +subto vcJPosJ: forall in sTime5 without { kTS - 2 } do vJPo[ t + 3 ] <= vJPo[ t ] + kJPosFact * 2; + +######################### +### Kelsey Operations ### + +param kKEoMin := 0; # plant/control discharge limits (KCFS) +param kKEoMax := 55.4; +param kKEsMin := 0; # as modelled +param kKEsMax := 9e9; # as modelled +param kKEpMax := 211; # generation limits (MW) + +var vKEv[ sTime ] >= 0 <= kKEvMax; +var vKEs[ sTime ] >= kKEsMin <= kKEsMax; +var vKEo[ sTime ] >= kKEoMin <= kKEoMax; +var vKEp[ sTime ] >= 0 <= kKEpMax; + +# 5th column for Gunisao River +param vGUNq[ sTime ] := read "historical.csv" as "5n" skip 1; + +param kKEhk := 3.8; # plant HK factors (MW/KCFS) +param kKEiFact := 1; # adjustments (calibrated for 92-94 peroid) +param kKEtwFact := 0; # curves +param kKEtwOffset := 0; +param kKEiAdj := 3; # adjustments (calibrated for 92-94 peroid) +param kKEvStart := kKEvMax / 2; + +# refill +subto kcKEvEnd: vKEv[ kTS ] >= kKEvStart; + +# change-in-storage + outflow == inflow +subto vcKEmb: + forall in sTime do + if ( t == 1 ) then vKEv[ 1 ] - kKEvStart + vKEo[ 1 ] + vKEs[ 1 ] + else vKEv[ t ] - vKEv[ t - 1 ] + vKEo[ t ] + vKEs[ t ] + end + == kKEiFact * kCMSd2KCFSdFact * vGUNq[ t ] + kKEiAdj + vECo[ t ] + vJPo[ t ] + vJPs[ t ]; + +# compute power from discharge +subto vcKEp: + forall in sTime do + vKEp[ t ] == kKEhk * vKEo[ t ]; + +######################################################################### +### Lower Nelson Operations with inflows from Upper Nelson and Notigi ### + +param kLNoMin := 0; # plant/control discharge limits (KCFS) +param kLNoMax := 165.7; +param kLNsMin := 0; # plant/control discharge limits (KCFS) +param kLNsMax := 150; # kpill limits (KCFS) +param kLNpMax := 3583; # generation limits (MW) + +var vLNv[ sTime ] >= 0 <= kLNvMax; +var vLNs[ sTime ] >= kLNsMin <= kLNsMax; +var vLNo[ sTime ] >= kLNoMin <= kLNoMax; +var vLNp[ sTime ] >= 0 <= kLNpMax; + +# 6th column for Lower Nelson Tribs +param vLTq[ sTime ] := read "historical.csv" as "6n" skip 1; + +param kLNhk := 21.7; # plant HK factors (MW/KCFS) +param kLNiAdj := 5; # adjustments (calibrated for 92-94 peroid) +param kLTiFact := 3; # adjustments (calibrated for 92-94 peroid) + +# refill +subto kcLNvEnd: vLNv[ kTS ] >= kLNvStart; + +# Routed discharges from Notigi to Lower Nelson +var vNTor[ sTime ] >= 0; +set sUIR := { 1, 2, 3, 4 }; +param kNTur[ sUIR ] := <1> 0.0, <2> 0.05, <3> 0.80, <4> 0.15; # as modelled +subto vcNTorA: + forall in sTime without { 1, 2, 3 } do + vNTor[ t ] == vNTo[ t - 0 ] * kNTur[ 1 ] + vNTo[ t - 1 ] * kNTur[ 2 ] + vNTo[ t - 2 ] * kNTur[ 3 ] + vNTo[ t - 3 ] * kNTur[ 4 ]; + +# change-in-storage + outflow == inflow +subto vcLNmb: + forall in sTime do + if ( t == 1 ) then vLNv[ 1 ] - kLNvStart + vLNo[ 1 ] + vLNs[ 1 ] + else vLNv[ t ] - vLNv[ t - 1 ] + vLNo[ t ] + vLNs[ t ] + end + == kLTiFact * kCMSd2KCFSdFact * vLTq[ t ] + kLNiAdj + vNTor[ t ] + vKEo[ t ] + vKEs[ t ]; + +# compute power from discharge +subto vcLNp: + forall in sTime do + vLNp[ t ] == kLNhk * vLNo[ t ]; + +# Lowern Nelson within-week outflow shaping +param kLNosFact := 10; # as modelled +subto vcLNosA: forall in sTime5 do vLNo[ t - 2 ] >= vLNo[ t ] - kLNosFact; +subto vcLNosB: forall in sTime5 do vLNo[ t - 2 ] <= vLNo[ t ] + kLNosFact; +subto vcLNosC: forall in sTime5 do vLNo[ t - 1 ] >= vLNo[ t ] - kLNosFact; +subto vcLNosD: forall in sTime5 do vLNo[ t - 1 ] <= vLNo[ t ] + kLNosFact; +subto vcLNosE: forall in sTime5 do vLNo[ t + 1 ] >= vLNo[ t ] - kLNosFact; +subto vcLNosF: forall in sTime5 do vLNo[ t + 1 ] <= vLNo[ t ] + kLNosFact; +subto vcLNosG: forall in sTime5 do vLNo[ t + 2 ] >= vLNo[ t ] - kLNosFact; +subto vcLNosH: forall in sTime5 do vLNo[ t + 2 ] <= vLNo[ t ] + kLNosFact; + +# Lowern Nelson inter-week outflow shaping +subto vcLNosI: forall in sTime5 without { kTS - 2 } do vLNo[ t + 3 ] >= vLNo[ t ] - kLNosFact * 2; +subto vcLNosJ: forall in sTime5 without { kTS - 2 } do vLNo[ t + 3 ] <= vLNo[ t ] + kLNosFact * 2; + +######################################################## + +# 7th column for Load +param vLOAD[ sTime ] := read "historical.csv" as "7n" skip 1; +var sLOAD >= 0; +subto vcLOAD: + forall in sTime do + vGRp[ t ] + vJPp[ t ] + vKEp[ t ] + vLNp[ t ] >= vLOAD[ t ]; + +minimize kSPILL: + sum in sTime do vMFo[ t ] + + sum in sTime do vGRs[ t ] + + sum in sTime do vJPs[ t ] + + sum in sTime do vKEs[ t ] + + sum in sTime do vLNs[ t ]; From 4e15369f9a65180f83f3d68176850faea5806c48 Mon Sep 17 00:00:00 2001 From: john howard Date: Mon, 2 Jun 2014 17:27:24 -0700 Subject: [PATCH 18/53] added missing lexer for zimpl --- lib/linguist/languages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index da8180fa..6be4c3fd 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2409,5 +2409,6 @@ xBase: Zimpl: type: programming + lexer: Text only extensions: - .zmpl From 3d5a0da62ec47484c959ba1b47aeed97dde9bcf1 Mon Sep 17 00:00:00 2001 From: John Howard Date: Mon, 2 Jun 2014 18:08:54 -0700 Subject: [PATCH 19/53] rename sample directory --- samples/{zmpl => Zimpl}/sample.zmpl | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename samples/{zmpl => Zimpl}/sample.zmpl (100%) diff --git a/samples/zmpl/sample.zmpl b/samples/Zimpl/sample.zmpl similarity index 100% rename from samples/zmpl/sample.zmpl rename to samples/Zimpl/sample.zmpl From cfb9f6f0a4d7b9088c0f12f01c32076371cb3060 Mon Sep 17 00:00:00 2001 From: john howard Date: Mon, 2 Jun 2014 18:14:57 -0700 Subject: [PATCH 20/53] smaller code sample --- samples/Zimpl/sample.zmpl | 362 ++------------------------------------ 1 file changed, 14 insertions(+), 348 deletions(-) diff --git a/samples/Zimpl/sample.zmpl b/samples/Zimpl/sample.zmpl index 50b65102..ade112cd 100644 --- a/samples/Zimpl/sample.zmpl +++ b/samples/Zimpl/sample.zmpl @@ -1,355 +1,21 @@ -# Mini Manitoba Hydro LP Model -# Written for zimpl 3.0.0a -# Licensed under the MIT license -# Developed for fun using publicly available sources. -# This software comes with no guarantees and no claims that it is fit for any purpose. -# john howard, 1 Dec 2009 - -# Inflows: -# CR churchill river -# LT lower nelson tribs -# SL south indian lake -# RR red river -# WR winnipeg river +# $Id: queens3.zpl,v 1.3 2009/09/13 16:15:53 bzfkocht Exp $ # -# Major Storages: -# LW lake winnipeg -# CL cedar lake +# 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. # -# Controlled Channels: -# MF missi falls -# NT notigi -# EC east channel -# WC west channel -# -# Generation Projects: -# GR grand rapids -# JP jenpeg -# KE kelsey -# LN lower nelson projects +param columns := 8; -# variables and constraints are named the following way: -# Type Subtype 2LetterName Kind Modifier -# (v|k) [c] (..) (q|i|o|p|v|e|s|hk|ss|tw|mb|rc|os|ur) [ Start | End | Max | Min | Adj | Fact | Offset ] +set I := { 1 .. columns }; +set IxI := I * I; -param kTS := 662; -set sTime := { 1 .. kTS }; +set TABU[ in IxI] := { in IxI with + (m != i or n != j) and (m == i or n == j or abs(m - i) == abs(n - j)) }; -# for 5 day averaging requires indices spaced 3 apart -set sTime5 := { in sTime with t < (kTS - 1) and t mod 3 == 0 }; +var x[IxI] binary; -param kCMSd2KCFSdFact := 35.315 / 1000; +maximize queens: sum in IxI : x[i,j]; -# column 8 is month -param vMONTH[ sTime ] := read "historical.csv" as "8n" skip 1; -set sMonth := { 1 .. 12 }; - -######################### -### Inital Conditions ### - -# South Indian Lake -param kSLeMin := 840.0; -param kSLeMax := 847.9; -param kSLssFactor := 283.7; -param kSLvMax := (kSLeMax - kSLeMin) * kSLssFactor; - -# Grand Rapids Pond (Cedar Lake) -param kGReMin := 830.0; -param kGReMax := 841.5; -param kGRssFactor := 330.9; -param kGRvMax := (kGReMax - kGReMin) * kGRssFactor; - -# Lake Winnipeg -param kLWeMin := 709.0; -param kLWeMax := 714.75; -param kLWssFactor := 3040.0; -param kLWvMax := (kLWeMax - kLWeMin) * kLWssFactor; - -# Kelsey Pond -param kKEeMin := 0.0; -param kKEeMax := 0.1; # as modelled -param kKEssFactor := 902.0; -param kKEvMax := (kKEeMax - kKEeMin) * kKEssFactor; - -# Storage at aggregate Lower Nelson Projects -param kLNeMin := 0.0; -param kLNeMax := 3.0; # as modelled -param kLNssFactor := 200.0; -param kLNvMax := (kLNeMax - kLNeMin) * kLNssFactor; -param kLNvStart := kLNvMax / 2; - -#################################################################### -### Churchill River through South Indian Lake and Notigi Control ### - -param kNToMin := 15; # control discharge limits (KCFS) -param kNToMax := 35; - -param kMFoMin := 0; # control discharge limits (KCFS) -param kMFoMax := 10; # as modelled -param kMFoFact := 0.001; # adjustments (calibrated for 92-94 peroid) - -var vMFo[ sTime ] >= 1 <= kMFoMax; # Missi Falls acts as spill -var vNTo[ sTime ] >= kNToMin <= kNToMax; -var vSLv[ sTime ] >= 0 <= kSLvMax; - -# 2nd column for Churchill River -param vCRq[ sTime ] := read "historical.csv" as "2n" skip 1; - -param kSLiAdj := 2.3; # adjustments (calibrated for 92-94 peroid) -param kSLvStart := kSLvMax / 2; - -# refill -subto kcSLvEnd: vSLv[ kTS ] >= kSLvStart; - -# change-in-storage + outflow == inflow -subto vcSLmb: - forall in sTime do - if ( t == 1 ) then vSLv[ 1 ] - kSLvStart + vMFo[ 1 ] + vNTo[ 1 ] - else vSLv[ t ] - vSLv[ t - 1 ] + vMFo[ t ] + vNTo[ t ] - end - == kCMSd2KCFSdFact * vCRq[ t ] + kSLiAdj; - -# Notigi within-week outflow shaping -param kNTosFact := 0; # as modelled -subto vcNTosA: forall in sTime5 do vNTo[ t - 2 ] >= vNTo[ t ] - kNTosFact; -subto vcNTosB: forall in sTime5 do vNTo[ t - 2 ] <= vNTo[ t ] + kNTosFact; -subto vcNTosC: forall in sTime5 do vNTo[ t - 1 ] >= vNTo[ t ] - kNTosFact; -subto vcNTosD: forall in sTime5 do vNTo[ t - 1 ] <= vNTo[ t ] + kNTosFact; -subto vcNTosE: forall in sTime5 do vNTo[ t + 1 ] >= vNTo[ t ] - kNTosFact; -subto vcNTosF: forall in sTime5 do vNTo[ t + 1 ] <= vNTo[ t ] + kNTosFact; -subto vcNTosG: forall in sTime5 do vNTo[ t + 2 ] >= vNTo[ t ] - kNTosFact; -subto vcNTosH: forall in sTime5 do vNTo[ t + 2 ] <= vNTo[ t ] + kNTosFact; - -########################################################### -### Sask River into Cedar Lake and through Grand Rapids ### - -param kGRoMin := 5; # plant/control discharge limits (KCFS) -param kGRoMax := 53; -param kGRsMin := 0; -param kGRsMax := 40; -param kGRpMax := 472; # generation limits (MW) - -var vGRv[ sTime ] >= 0 <= kGRvMax; -var vGRs[ sTime ] >= kGRsMin <= kGRsMax; -var vGRo[ sTime ] >= kGRoMin <= kGRoMax; -var vGRp[ sTime ] >= 0 <= kGRpMax; - -# 1st column for Sask River -param vSKRq[ sTime ] := read "historical.csv" as "1n" skip 1; - -param kGRhk := 9.2; # plant HK factors (MW/KCFS) -param kGRiAdj := -0.6; # adjustments (calibrated for 92-94 peroid) -param kGRvStart := kGRvMax / 2; - -# refill -subto kcGRvEnd: vGRv[ kTS ] >= kGRvStart; - -# change-in-storage + outflow == inflow -subto vcGRmb: - forall in sTime do - if ( t == 1 ) then vGRv[ 1 ] - kGRvStart + vGRo[ 1 ] + vGRs[ 1 ] - else vGRv[ t ] - vGRv[ t - 1 ] + vGRo[ t ] + vGRs[ t ] - end - == kCMSd2KCFSdFact * vSKRq[ t ] + kGRiAdj; - -# compute power from discharge -subto vcGRp: - forall in sTime do - vGRp[ t ] == kGRhk * vGRo[ t ]; - -# Grand Rapids within-week outflow shaping -param kGRosFact := 10; # as modelled -subto vcGRosA: forall in sTime5 do vGRo[ t - 2 ] >= vGRo[ t ] - kGRosFact; -subto vcGRosB: forall in sTime5 do vGRo[ t - 2 ] <= vGRo[ t ] + kGRosFact; -subto vcGRosC: forall in sTime5 do vGRo[ t - 1 ] >= vGRo[ t ] - kGRosFact; -subto vcGRosD: forall in sTime5 do vGRo[ t - 1 ] <= vGRo[ t ] + kGRosFact; -subto vcGRosE: forall in sTime5 do vGRo[ t + 1 ] >= vGRo[ t ] - kGRosFact; -subto vcGRosF: forall in sTime5 do vGRo[ t + 1 ] <= vGRo[ t ] + kGRosFact; -subto vcGRosG: forall in sTime5 do vGRo[ t + 2 ] >= vGRo[ t ] - kGRosFact; -subto vcGRosH: forall in sTime5 do vGRo[ t + 2 ] <= vGRo[ t ] + kGRosFact; - -############################################################################## -### Lake Winnipeg Storage as operated by JENPEG and effect of Each Channel ### - -param kJPoMin := 0; # plant/control discharge limits (KCFS) -param kJPoMax := 93; -param kJPsMin := 0; # plant/control discharge limits (KCFS) -param kJPsMax := 9e9; # as modelled -param kJPpMax := 97; # generation limits (MW) - -var vLWv[ sTime ] >= 0 <= kLWvMax; -var vECo[ sTime ] >= 0; # upper bound determined by rating curve -var vJPo[ sTime ] >= kJPoMin <= kJPoMax; -var vJPs[ sTime ] >= kJPsMin <= kJPsMax; -var vJPp[ sTime ] >= 0 <= kJPpMax; - -# 3rd column for Red River and 4th column for Winnipeg River -param vRRq[ sTime ] := read "historical.csv" as "3n" skip 1; -param vWRq[ sTime ] := read "historical.csv" as "4n" skip 1; - -param kLWiAdj := 11.7; # adjustments (calibrated for 92-94 peroid) -param kLWvStart := kLWvMax / 2; - -param kJPhk := 1; # plant HK factors (MW/KCFS) -param kJPoNovMaxFact := 0; # curves -param kJPoNovMaxOffset := 0; -param kJPtwFact := 0; # TODO -param kJPtwOffset := 0; - -# refill -subto kcLWvEnd: vLWv[ kTS ] >= kLWvStart; - -# change-in-storage + outflow == inflow -subto vcLWmb: - forall in sTime do - if ( t == 1 ) then vLWv[ 1 ] - kLWvStart + vJPo[ 1 ] + vJPs[ 1 ] + vECo[ 1 ] - else vLWv[ t ] - vLWv[ t - 1 ] + vJPo[ t ] + vJPs[ t ] + vECo[ t ] - end - == kCMSd2KCFSdFact * vRRq[ t ] + kCMSd2KCFSdFact * vWRq[ t ] + vGRo[ t ] + vGRs[ t ] + kLWiAdj; - -# compute power from discharge -subto vcJPp: - forall in sTime do - vJPp[ t ] == kJPhk * vJPo[ t ]; - -# West Channel Max Discharge -param vWCoMax[ sMonth ] := <1> 8.6440678, <2> 7.79661017, <3> 7.11864407, <4> 6.61016949, <11> 10.3389831, <12> 9.3220339 default 12.5423729; -subto vJPoA: - forall in sTime cross sMonth with m == vMONTH[ t ] do - vJPo[ t ] <= vLWv[ t ] * vWCoMax[ m ] / kLWssFactor; - -# East Channel Discharge -subto vcECo: - forall in sTime do - vECo[ t ] == vLWv[ t ] * 4.67463938 / kLWssFactor; # convert q/ft (from historical 92-94 period data) to q/v - -# Jenpeg within-week outflow shaping -param kJPosFact := 2; # as modelled -subto vcJPosA: forall in sTime5 do vJPo[ t - 2 ] >= vJPo[ t ] - kJPosFact; -subto vcJPosB: forall in sTime5 do vJPo[ t - 2 ] <= vJPo[ t ] + kJPosFact; -subto vcJPosC: forall in sTime5 do vJPo[ t - 1 ] >= vJPo[ t ] - kJPosFact; -subto vcJPosD: forall in sTime5 do vJPo[ t - 1 ] <= vJPo[ t ] + kJPosFact; -subto vcJPosE: forall in sTime5 do vJPo[ t + 1 ] >= vJPo[ t ] - kJPosFact; -subto vcJPosF: forall in sTime5 do vJPo[ t + 1 ] <= vJPo[ t ] + kJPosFact; -subto vcJPosG: forall in sTime5 do vJPo[ t + 2 ] >= vJPo[ t ] - kJPosFact; -subto vcJPosH: forall in sTime5 do vJPo[ t + 2 ] <= vJPo[ t ] + kJPosFact; - -# Jenpeg intra-week shaping -subto vcJPosI: forall in sTime5 without { kTS - 2 } do vJPo[ t + 3 ] >= vJPo[ t ] - kJPosFact * 2; -subto vcJPosJ: forall in sTime5 without { kTS - 2 } do vJPo[ t + 3 ] <= vJPo[ t ] + kJPosFact * 2; - -######################### -### Kelsey Operations ### - -param kKEoMin := 0; # plant/control discharge limits (KCFS) -param kKEoMax := 55.4; -param kKEsMin := 0; # as modelled -param kKEsMax := 9e9; # as modelled -param kKEpMax := 211; # generation limits (MW) - -var vKEv[ sTime ] >= 0 <= kKEvMax; -var vKEs[ sTime ] >= kKEsMin <= kKEsMax; -var vKEo[ sTime ] >= kKEoMin <= kKEoMax; -var vKEp[ sTime ] >= 0 <= kKEpMax; - -# 5th column for Gunisao River -param vGUNq[ sTime ] := read "historical.csv" as "5n" skip 1; - -param kKEhk := 3.8; # plant HK factors (MW/KCFS) -param kKEiFact := 1; # adjustments (calibrated for 92-94 peroid) -param kKEtwFact := 0; # curves -param kKEtwOffset := 0; -param kKEiAdj := 3; # adjustments (calibrated for 92-94 peroid) -param kKEvStart := kKEvMax / 2; - -# refill -subto kcKEvEnd: vKEv[ kTS ] >= kKEvStart; - -# change-in-storage + outflow == inflow -subto vcKEmb: - forall in sTime do - if ( t == 1 ) then vKEv[ 1 ] - kKEvStart + vKEo[ 1 ] + vKEs[ 1 ] - else vKEv[ t ] - vKEv[ t - 1 ] + vKEo[ t ] + vKEs[ t ] - end - == kKEiFact * kCMSd2KCFSdFact * vGUNq[ t ] + kKEiAdj + vECo[ t ] + vJPo[ t ] + vJPs[ t ]; - -# compute power from discharge -subto vcKEp: - forall in sTime do - vKEp[ t ] == kKEhk * vKEo[ t ]; - -######################################################################### -### Lower Nelson Operations with inflows from Upper Nelson and Notigi ### - -param kLNoMin := 0; # plant/control discharge limits (KCFS) -param kLNoMax := 165.7; -param kLNsMin := 0; # plant/control discharge limits (KCFS) -param kLNsMax := 150; # kpill limits (KCFS) -param kLNpMax := 3583; # generation limits (MW) - -var vLNv[ sTime ] >= 0 <= kLNvMax; -var vLNs[ sTime ] >= kLNsMin <= kLNsMax; -var vLNo[ sTime ] >= kLNoMin <= kLNoMax; -var vLNp[ sTime ] >= 0 <= kLNpMax; - -# 6th column for Lower Nelson Tribs -param vLTq[ sTime ] := read "historical.csv" as "6n" skip 1; - -param kLNhk := 21.7; # plant HK factors (MW/KCFS) -param kLNiAdj := 5; # adjustments (calibrated for 92-94 peroid) -param kLTiFact := 3; # adjustments (calibrated for 92-94 peroid) - -# refill -subto kcLNvEnd: vLNv[ kTS ] >= kLNvStart; - -# Routed discharges from Notigi to Lower Nelson -var vNTor[ sTime ] >= 0; -set sUIR := { 1, 2, 3, 4 }; -param kNTur[ sUIR ] := <1> 0.0, <2> 0.05, <3> 0.80, <4> 0.15; # as modelled -subto vcNTorA: - forall in sTime without { 1, 2, 3 } do - vNTor[ t ] == vNTo[ t - 0 ] * kNTur[ 1 ] + vNTo[ t - 1 ] * kNTur[ 2 ] + vNTo[ t - 2 ] * kNTur[ 3 ] + vNTo[ t - 3 ] * kNTur[ 4 ]; - -# change-in-storage + outflow == inflow -subto vcLNmb: - forall in sTime do - if ( t == 1 ) then vLNv[ 1 ] - kLNvStart + vLNo[ 1 ] + vLNs[ 1 ] - else vLNv[ t ] - vLNv[ t - 1 ] + vLNo[ t ] + vLNs[ t ] - end - == kLTiFact * kCMSd2KCFSdFact * vLTq[ t ] + kLNiAdj + vNTor[ t ] + vKEo[ t ] + vKEs[ t ]; - -# compute power from discharge -subto vcLNp: - forall in sTime do - vLNp[ t ] == kLNhk * vLNo[ t ]; - -# Lowern Nelson within-week outflow shaping -param kLNosFact := 10; # as modelled -subto vcLNosA: forall in sTime5 do vLNo[ t - 2 ] >= vLNo[ t ] - kLNosFact; -subto vcLNosB: forall in sTime5 do vLNo[ t - 2 ] <= vLNo[ t ] + kLNosFact; -subto vcLNosC: forall in sTime5 do vLNo[ t - 1 ] >= vLNo[ t ] - kLNosFact; -subto vcLNosD: forall in sTime5 do vLNo[ t - 1 ] <= vLNo[ t ] + kLNosFact; -subto vcLNosE: forall in sTime5 do vLNo[ t + 1 ] >= vLNo[ t ] - kLNosFact; -subto vcLNosF: forall in sTime5 do vLNo[ t + 1 ] <= vLNo[ t ] + kLNosFact; -subto vcLNosG: forall in sTime5 do vLNo[ t + 2 ] >= vLNo[ t ] - kLNosFact; -subto vcLNosH: forall in sTime5 do vLNo[ t + 2 ] <= vLNo[ t ] + kLNosFact; - -# Lowern Nelson inter-week outflow shaping -subto vcLNosI: forall in sTime5 without { kTS - 2 } do vLNo[ t + 3 ] >= vLNo[ t ] - kLNosFact * 2; -subto vcLNosJ: forall in sTime5 without { kTS - 2 } do vLNo[ t + 3 ] <= vLNo[ t ] + kLNosFact * 2; - -######################################################## - -# 7th column for Load -param vLOAD[ sTime ] := read "historical.csv" as "7n" skip 1; -var sLOAD >= 0; -subto vcLOAD: - forall in sTime do - vGRp[ t ] + vJPp[ t ] + vKEp[ t ] + vLNp[ t ] >= vLOAD[ t ]; - -minimize kSPILL: - sum in sTime do vMFo[ t ] + - sum in sTime do vGRs[ t ] + - sum in sTime do vJPs[ t ] + - sum in sTime do vKEs[ t ] + - sum in sTime do vLNs[ t ]; +subto c1: forall in IxI do + card(TABU[i,j]) - card(TABU[i,j]) * x[i,j] >= sum in TABU[i,j] : x[m,n]; + From ed851849db8deefb6f45d0853e24833f5c4f6eb0 Mon Sep 17 00:00:00 2001 From: john howard Date: Mon, 2 Jun 2014 18:23:07 -0700 Subject: [PATCH 21/53] added extra extension for zimpl --- lib/linguist/languages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 6be4c3fd..fe6101c7 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2412,3 +2412,4 @@ Zimpl: lexer: Text only extensions: - .zmpl + - .zpl From 1fd2f921fd36b059256826cd193f829744559f3e Mon Sep 17 00:00:00 2001 From: john howard Date: Mon, 2 Jun 2014 18:28:00 -0700 Subject: [PATCH 22/53] added yet another zimpl extension that is in use --- lib/linguist/languages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index fe6101c7..a52419e6 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2413,3 +2413,4 @@ Zimpl: extensions: - .zmpl - .zpl + - .zimpl From c389c79be9b1ca9c2529672d5e724d66d192d995 Mon Sep 17 00:00:00 2001 From: john howard Date: Mon, 2 Jun 2014 18:30:45 -0700 Subject: [PATCH 23/53] fixed zimpl declaration position collation order problem --- lib/linguist/languages.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index a52419e6..4678f8b8 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2342,6 +2342,14 @@ Zephir: extensions: - .zep +Zimpl: + type: programming + lexer: Text only + extensions: + - .zmpl + - .zpl + - .zimpl + eC: type: programming search_term: ec @@ -2406,11 +2414,3 @@ xBase: color: "#3a4040" extensions: - .prg - -Zimpl: - type: programming - lexer: Text only - extensions: - - .zmpl - - .zpl - - .zimpl From 7989fbd613c139197d62fadf66bfadd2fa606f09 Mon Sep 17 00:00:00 2001 From: Arfon Smith Date: Mon, 2 Jun 2014 21:00:03 -0500 Subject: [PATCH 24/53] Samples --- lib/linguist/samples.json | 56 +++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index e7206004..04c7d729 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -657,6 +657,9 @@ ], "Zephir": [ ".zep" + ], + "Zimpl": [ + ".zmpl" ] }, "interpreters": { @@ -723,8 +726,8 @@ ".gemrc" ] }, - "tokens_total": 611474, - "languages_total": 755, + "tokens_total": 611597, + "languages_total": 756, "tokens": { "ABAP": { "*/**": 1, @@ -66314,6 +66317,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, + "": 3, + "in": 5, + "]": 8, + "": 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": { @@ -66499,7 +66543,8 @@ "XSLT": 44, "Xtend": 399, "YAML": 77, - "Zephir": 1026 + "Zephir": 1026, + "Zimpl": 123 }, "languages": { "ABAP": 1, @@ -66684,7 +66729,8 @@ "XSLT": 1, "Xtend": 2, "YAML": 2, - "Zephir": 2 + "Zephir": 2, + "Zimpl": 1 }, - "md5": "a7d557f9fecf06444c92c22e6f32daa7" + "md5": "941348a2fd9b5529cfbcede9d664e2df" } \ No newline at end of file From 398439a937a82b050e524bab1235b49a7c37720e Mon Sep 17 00:00:00 2001 From: Arfon Smith Date: Mon, 2 Jun 2014 21:04:39 -0500 Subject: [PATCH 25/53] Pedantic --- lib/linguist/languages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 0f512636..0856f26a 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2353,8 +2353,8 @@ Zimpl: lexer: Text only extensions: - .zmpl - - .zpl - .zimpl + - .zpl eC: type: programming From 4a7ae50ec811383bc26fc28279cb764fc9488f15 Mon Sep 17 00:00:00 2001 From: Arfon Smith Date: Mon, 2 Jun 2014 21:07:11 -0500 Subject: [PATCH 26/53] Dammit --- lib/linguist/languages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 0856f26a..fc55a458 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2352,8 +2352,8 @@ Zimpl: type: programming lexer: Text only extensions: - - .zmpl - .zimpl + - .zmpl - .zpl eC: From 0fb824b345b8cc4cdd9f165c9e122ab8d761a107 Mon Sep 17 00:00:00 2001 From: Adrian Kashivskyy Date: Tue, 3 Jun 2014 15:54:15 +0200 Subject: [PATCH 27/53] Add orange color to Swift --- lib/linguist/languages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index fc55a458..1bf2225f 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2048,6 +2048,7 @@ SuperCollider: Swift: type: programming + color: "#f59A37" lexer: Text only extensions: - .swift From 2164b28c64f8a63b88ad82c1ddb5ff290d6944b9 Mon Sep 17 00:00:00 2001 From: Adrian Kashivskyy Date: Tue, 3 Jun 2014 16:03:49 +0200 Subject: [PATCH 28/53] Update Swift color --- lib/linguist/languages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 1bf2225f..1fb8ec51 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2048,7 +2048,7 @@ SuperCollider: Swift: type: programming - color: "#f59A37" + color: "#ffac45" lexer: Text only extensions: - .swift From aa5a94cc3ee144d6a896e7c61183c9fe13f686e2 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Tue, 3 Jun 2014 12:21:07 -0400 Subject: [PATCH 29/53] 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. --- lib/linguist/blob_helper.rb | 12 +++++++++--- samples/Text/iso8859-8-i.txt | 1 + test/test_blob.rb | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 samples/Text/iso8859-8-i.txt diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb index 76eab7ea..67f6eef3 100644 --- a/lib/linguist/blob_helper.rb +++ b/lib/linguist/blob_helper.rb @@ -256,10 +256,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(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 diff --git a/samples/Text/iso8859-8-i.txt b/samples/Text/iso8859-8-i.txt new file mode 100644 index 00000000..ed2bf6c4 --- /dev/null +++ b/samples/Text/iso8859-8-i.txt @@ -0,0 +1 @@ +%┐сщ \ No newline at end of file diff --git a/test/test_blob.rb b/test/test_blob.rb index da13b96e..2109e9b4 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -97,6 +97,7 @@ 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 From b7685ab317c99db012a507180a8afcb36540bd44 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Tue, 3 Jun 2014 14:50:17 -0400 Subject: [PATCH 30/53] Bumps to 2.11.3 --- lib/linguist/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/version.rb b/lib/linguist/version.rb index 9e2d4037..5ded284d 100644 --- a/lib/linguist/version.rb +++ b/lib/linguist/version.rb @@ -1,3 +1,3 @@ module Linguist - VERSION = "2.11.2" + VERSION = "2.11.3" end From efc363806525f382202a474056bcea0080bc0852 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Tue, 3 Jun 2014 14:50:27 -0400 Subject: [PATCH 31/53] Freshens up the release docs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9e68a909..660ac00c 100644 --- a/README.md +++ b/README.md @@ -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 From 38a371451473ac0b8c6b8799256fc7317276990f Mon Sep 17 00:00:00 2001 From: Arfon Smith Date: Tue, 3 Jun 2014 21:37:25 -0500 Subject: [PATCH 32/53] Samples update --- lib/linguist/samples.json | 187 +++++++++++++++++++++++++++++++++++++- 1 file changed, 184 insertions(+), 3 deletions(-) diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index 0e223fd2..20c5460f 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -92,6 +92,10 @@ ".cl", ".lisp" ], + "Component Pascal": [ + ".cp", + ".cps" + ], "Coq": [ ".v" ], @@ -729,8 +733,8 @@ ".gemrc" ] }, - "tokens_total": 612725, - "languages_total": 799, + "tokens_total": 613550, + "languages_total": 801, "tokens": { "ABAP": { "*/**": 1, @@ -15336,6 +15340,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, @@ -66642,6 +66821,7 @@ "COBOL": 90, "CoffeeScript": 2951, "Common Lisp": 2186, + "Component Pascal": 825, "Coq": 18259, "Creole": 134, "Crystal": 1506, @@ -66829,6 +67009,7 @@ "COBOL": 4, "CoffeeScript": 9, "Common Lisp": 3, + "Component Pascal": 2, "Coq": 12, "Creole": 1, "Crystal": 3, @@ -66991,5 +67172,5 @@ "Zephir": 2, "Zimpl": 1 }, - "md5": "482e5e1de8ec47e0b556809c8fe6f62b" + "md5": "900536b7898278f2fd14fa3a8badf215" } \ No newline at end of file From 7e8be1293e72dbe3818ff988e01ca0ba1ea2b245 Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Wed, 4 Jun 2014 15:51:33 -0500 Subject: [PATCH 33/53] Use the :ruby_encoding value from charlock 0.7.2 --- github-linguist.gemspec | 2 +- lib/linguist/blob_helper.rb | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/github-linguist.gemspec b/github-linguist.gemspec index b38abb6f..dbfd58a9 100644 --- a/github-linguist.gemspec +++ b/github-linguist.gemspec @@ -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' diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb index 67f6eef3..15ab2d9f 100644 --- a/lib/linguist/blob_helper.rb +++ b/lib/linguist/blob_helper.rb @@ -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 From 42c68f21d173a659e0d19e97d300f14b0f0812e9 Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Wed, 4 Jun 2014 15:59:42 -0500 Subject: [PATCH 34/53] test ruby_encoding --- test/test_blob.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/test_blob.rb b/test/test_blob.rb index f900e57f..d877cbae 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -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 From 203f6d1944afe5707e7014dadb3e34c970f6e136 Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Wed, 4 Jun 2014 17:15:33 -0500 Subject: [PATCH 35/53] forgot to add the test fixture --- samples/Text/ISO-2022-KR.txt | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 samples/Text/ISO-2022-KR.txt diff --git a/samples/Text/ISO-2022-KR.txt b/samples/Text/ISO-2022-KR.txt new file mode 100644 index 00000000..721d7051 --- /dev/null +++ b/samples/Text/ISO-2022-KR.txt @@ -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 \ No newline at end of file From 67f7268a55a127791250d383e21ea74704eb5944 Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Thu, 5 Jun 2014 10:55:32 -0500 Subject: [PATCH 36/53] bump version for v2.11.4 release --- lib/linguist/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/version.rb b/lib/linguist/version.rb index 5ded284d..b681d0e0 100644 --- a/lib/linguist/version.rb +++ b/lib/linguist/version.rb @@ -1,3 +1,3 @@ module Linguist - VERSION = "2.11.3" + VERSION = "2.11.4" end From f66ffe305fa539369a2a95c12cf3c91532a2d489 Mon Sep 17 00:00:00 2001 From: Julian Gehring Date: Fri, 6 Jun 2014 08:57:11 -0700 Subject: [PATCH 37/53] Change R package ignores to absolute paths --- lib/linguist/vendor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index 53f66bc0..843b5433 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -184,5 +184,5 @@ - .[Dd][Ss]_[Ss]tore$ # R packages -- vignettes/ -- inst/extdata/ +- ^vignettes/ +- ^inst/extdata/ From d3c04d631079c9db1fb784e11b049612c36bae67 Mon Sep 17 00:00:00 2001 From: Arfon Smith Date: Fri, 6 Jun 2014 12:08:38 -0500 Subject: [PATCH 38/53] nesC --- lib/linguist/languages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 14def669..f90e7f17 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2396,7 +2396,7 @@ mupad: nesC: type: programming color: "#ffce3b" - lexer: nesc + lexer: nesC extensions: - .nc From 7cd23036a7d90e82dace6e8f193d28704ef358a2 Mon Sep 17 00:00:00 2001 From: Simon Wistow Date: Fri, 6 Jun 2014 12:59:50 -0700 Subject: [PATCH 39/53] Add support for the Varnish VCL edge scripting language --- lib/linguist/languages.yml | 8 ++ lib/linguist/samples.json | 92 ++++++++++++++++++- samples/VCL/varnish2_default.vcl | 152 +++++++++++++++++++++++++++++++ samples/VCL/varnish3_default.vcl | 149 ++++++++++++++++++++++++++++++ 4 files changed, 398 insertions(+), 3 deletions(-) create mode 100644 samples/VCL/varnish2_default.vcl create mode 100644 samples/VCL/varnish3_default.vcl diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index f90e7f17..795544b8 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2170,6 +2170,14 @@ UnrealScript: extensions: - .uc +VCL: + type: programming + lexer: Perl + ace_mode: perl + color: "#0298c3" + extensions: + - .vcl + VHDL: type: programming lexer: vhdl diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index 939b6403..9cbfceb0 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -615,6 +615,9 @@ "UnrealScript": [ ".uc" ], + "VCL": [ + ".vcl" + ], "Verilog": [ ".v" ], @@ -734,8 +737,8 @@ ".gemrc" ] }, - "tokens_total": 613712, - "languages_total": 802, + "tokens_total": 614257, + "languages_total": 804, "tokens": { "ABAP": { "*/**": 1, @@ -63723,6 +63726,87 @@ "log": 1, "defaultproperties": 1 }, + "VCL": { + "sub": 23, + "vcl_recv": 2, + "{": 50, + "if": 14, + "(": 50, + "req.request": 18, + "&&": 14, + ")": 50, + "return": 33, + "pipe": 4, + ";": 48, + "}": 50, + "pass": 9, + "req.http.Authorization": 2, + "||": 4, + "req.http.Cookie": 2, + "lookup": 2, + "vcl_pipe": 2, + "vcl_pass": 2, + "vcl_hash": 2, + "set": 10, + "req.hash": 3, + "+": 17, + "req.url": 2, + "req.http.host": 4, + "else": 3, + "server.ip": 2, + "hash": 2, + "vcl_hit": 2, + "obj.cacheable": 2, + "deliver": 8, + "vcl_miss": 2, + "fetch": 3, + "vcl_fetch": 2, + "obj.http.Set": 1, + "-": 21, + "Cookie": 2, + "obj.prefetch": 1, + "s": 3, + "vcl_deliver": 2, + "vcl_discard": 1, + "discard": 2, + "vcl_prefetch": 1, + "vcl_timeout": 1, + "vcl_error": 2, + "obj.http.Content": 2, + "Type": 2, + "synthetic": 2, + "utf": 2, + "//W3C//DTD": 2, + "XHTML": 2, + "Strict//EN": 2, + "http": 3, + "//www.w3.org/TR/xhtml1/DTD/xhtml1": 2, + "strict.dtd": 2, + "obj.status": 4, + "obj.response": 6, + "req.xid": 2, + "//www.varnish": 1, + "cache.org/": 1, + "req.restarts": 1, + "req.http.x": 1, + "forwarded": 1, + "for": 1, + "req.http.X": 3, + "Forwarded": 3, + "For": 3, + "client.ip": 2, + "hash_data": 3, + "beresp.ttl": 2, + "<": 1, + "beresp.http.Set": 1, + "beresp.http.Vary": 1, + "hit_for_pass": 1, + "obj.http.Retry": 1, + "After": 1, + "vcl_init": 1, + "ok": 2, + "vcl_fini": 1 + }, "Verilog": { "////////////////////////////////////////////////////////////////////////////////": 14, "//": 117, @@ -66969,6 +67053,7 @@ "TXL": 213, "TypeScript": 109, "UnrealScript": 2873, + "VCL": 545, "Verilog": 3778, "VHDL": 42, "VimL": 20, @@ -67157,6 +67242,7 @@ "TXL": 1, "TypeScript": 3, "UnrealScript": 2, + "VCL": 2, "Verilog": 13, "VHDL": 1, "VimL": 2, @@ -67173,5 +67259,5 @@ "Zephir": 2, "Zimpl": 1 }, - "md5": "4754c31a712c5e22354851fd14d4d4fa" + "md5": "e69777074750ed98faadf08497ba6339" } \ No newline at end of file diff --git a/samples/VCL/varnish2_default.vcl b/samples/VCL/varnish2_default.vcl new file mode 100644 index 00000000..9b01881f --- /dev/null +++ b/samples/VCL/varnish2_default.vcl @@ -0,0 +1,152 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2008 Linpro AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + * The default VCL code. + * + * NB! You do NOT need to copy & paste all of these functions into your + * own vcl code, if you do not provide a definition of one of these + * functions, the compiler will automatically fall back to the default + * code from this file. + * + * This code will be prefixed with a backend declaration built from the + * -b argument. + */ + +sub vcl_recv { + if (req.request != "GET" && + req.request != "HEAD" && + req.request != "PUT" && + req.request != "POST" && + req.request != "TRACE" && + req.request != "OPTIONS" && + req.request != "DELETE") { + /* Non-RFC2616 or CONNECT which is weird. */ + return (pipe); + } + if (req.request != "GET" && req.request != "HEAD") { + /* We only deal with GET and HEAD by default */ + return (pass); + } + if (req.http.Authorization || req.http.Cookie) { + /* Not cacheable by default */ + return (pass); + } + return (lookup); +} + +sub vcl_pipe { + # Note that only the first request to the backend will have + # X-Forwarded-For set. If you use X-Forwarded-For and want to + # have it set for all requests, make sure to have: + # set req.http.connection = "close"; + # here. It is not set by default as it might break some broken web + # applications, like IIS with NTLM authentication. + return (pipe); +} + +sub vcl_pass { + return (pass); +} + +sub vcl_hash { + set req.hash += req.url; + if (req.http.host) { + set req.hash += req.http.host; + } else { + set req.hash += server.ip; + } + return (hash); +} + +sub vcl_hit { + if (!obj.cacheable) { + return (pass); + } + return (deliver); +} + +sub vcl_miss { + return (fetch); +} + +sub vcl_fetch { + if (!obj.cacheable) { + return (pass); + } + if (obj.http.Set-Cookie) { + return (pass); + } + set obj.prefetch = -30s; + return (deliver); +} + +sub vcl_deliver { + return (deliver); +} + +sub vcl_discard { + /* XXX: Do not redefine vcl_discard{}, it is not yet supported */ + return (discard); +} + +sub vcl_prefetch { + /* XXX: Do not redefine vcl_prefetch{}, it is not yet supported */ + return (fetch); +} + +sub vcl_timeout { + /* XXX: Do not redefine vcl_timeout{}, it is not yet supported */ + return (discard); +} + +sub vcl_error { + set obj.http.Content-Type = "text/html; charset=utf-8"; + synthetic {" + + + + + "} obj.status " " obj.response {" + + +

Error "} obj.status " " obj.response {"

+

"} obj.response {"

+

Guru Meditation:

+

XID: "} req.xid {"

+
+
+ Varnish cache server +
+ + +"}; + return (deliver); +} diff --git a/samples/VCL/varnish3_default.vcl b/samples/VCL/varnish3_default.vcl new file mode 100644 index 00000000..412b6e94 --- /dev/null +++ b/samples/VCL/varnish3_default.vcl @@ -0,0 +1,149 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2011 Varnish Software AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The default VCL code. + * + * NB! You do NOT need to copy & paste all of these functions into your + * own vcl code, if you do not provide a definition of one of these + * functions, the compiler will automatically fall back to the default + * code from this file. + * + * This code will be prefixed with a backend declaration built from the + * -b argument. + */ + +sub vcl_recv { + if (req.restarts == 0) { + if (req.http.x-forwarded-for) { + set req.http.X-Forwarded-For = + req.http.X-Forwarded-For + ", " + client.ip; + } else { + set req.http.X-Forwarded-For = client.ip; + } + } + if (req.request != "GET" && + req.request != "HEAD" && + req.request != "PUT" && + req.request != "POST" && + req.request != "TRACE" && + req.request != "OPTIONS" && + req.request != "DELETE") { + /* Non-RFC2616 or CONNECT which is weird. */ + return (pipe); + } + if (req.request != "GET" && req.request != "HEAD") { + /* We only deal with GET and HEAD by default */ + return (pass); + } + if (req.http.Authorization || req.http.Cookie) { + /* Not cacheable by default */ + return (pass); + } + return (lookup); +} + +sub vcl_pipe { + # Note that only the first request to the backend will have + # X-Forwarded-For set. If you use X-Forwarded-For and want to + # have it set for all requests, make sure to have: + # set bereq.http.connection = "close"; + # here. It is not set by default as it might break some broken web + # applications, like IIS with NTLM authentication. + return (pipe); +} + +sub vcl_pass { + return (pass); +} + +sub vcl_hash { + hash_data(req.url); + if (req.http.host) { + hash_data(req.http.host); + } else { + hash_data(server.ip); + } + return (hash); +} + +sub vcl_hit { + return (deliver); +} + +sub vcl_miss { + return (fetch); +} + +sub vcl_fetch { + if (beresp.ttl <= 0s || + beresp.http.Set-Cookie || + beresp.http.Vary == "*") { + /* + * Mark as "Hit-For-Pass" for the next 2 minutes + */ + set beresp.ttl = 120 s; + return (hit_for_pass); + } + return (deliver); +} + +sub vcl_deliver { + return (deliver); +} + +sub vcl_error { + set obj.http.Content-Type = "text/html; charset=utf-8"; + set obj.http.Retry-After = "5"; + synthetic {" + + + + + "} + obj.status + " " + obj.response + {" + + +

Error "} + obj.status + " " + obj.response + {"

+

"} + obj.response + {"

+

Guru Meditation:

+

XID: "} + req.xid + {"

+
+

Varnish cache server

+ + +"}; + return (deliver); +} + +sub vcl_init { + return (ok); +} + +sub vcl_fini { + return (ok); +} From e17ebec098dddcedf3591330cbbab65fd3df1c5a Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Sat, 7 Jun 2014 15:25:44 -0500 Subject: [PATCH 40/53] Bump charlock to 0.7.3 This version includes a fix for the encoding lookup table for some encoding aliases in the ICU detection API --- github-linguist.gemspec | 2 +- test/test_blob.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/github-linguist.gemspec b/github-linguist.gemspec index dbfd58a9..c17525f4 100644 --- a/github-linguist.gemspec +++ b/github-linguist.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |s| s.files = Dir['lib/**/*'] s.executables << 'linguist' - s.add_dependency 'charlock_holmes', '~> 0.7.2' + s.add_dependency 'charlock_holmes', '~> 0.7.3' s.add_dependency 'escape_utils', '~> 1.0.1' s.add_dependency 'mime-types', '~> 1.19' s.add_dependency 'pygments.rb', '~> 0.5.4' diff --git a/test/test_blob.rb b/test/test_blob.rb index d877cbae..23a649ec 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -114,6 +114,9 @@ class TestBlob < Test::Unit::TestCase 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 + + assert_equal "windows-1252", blob("Text/Visual_Battlers.rb").encoding + assert_equal "Windows-1252", blob("Text/Visual_Battlers.rb").ruby_encoding end def test_binary From bc04232f879c2b543a98b9e5d7ff856d3ca28112 Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Sat, 7 Jun 2014 15:32:29 -0500 Subject: [PATCH 41/53] add the fixture --- samples/Text/Visual_Battlers.rb | 703 ++++++++++++++++++++++++++++++++ 1 file changed, 703 insertions(+) create mode 100644 samples/Text/Visual_Battlers.rb diff --git a/samples/Text/Visual_Battlers.rb b/samples/Text/Visual_Battlers.rb new file mode 100644 index 00000000..74bb0f2c --- /dev/null +++ b/samples/Text/Visual_Battlers.rb @@ -0,0 +1,703 @@ +#============================================================================== +# +# Бе Yanfly Engine Ace - Visual Battlers v1.01 +# -- Last Updated: 2012.07.24 +# -- Level: Easy +# -- Requires: n/a +# +# Бе Modified by: +# -- Yami +# -- Kread-Ex +# -- Archeia_Nessiah +#============================================================================== + +$imported = {} if $imported.nil? +$imported["YEA-VisualBattlers"] = true + +#============================================================================== +# Бе Updates +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# 2012.12.18 - Added preset views and able to change direction in-game. +# 2012.07.24 - Finished Script. +# 2012.01.05 - Started Script. +# +#============================================================================== +# Бе Introduction +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# This script provides a visual for all actors by default charsets. The actions +# and movements are alike Final Fantasy 1, only move forward and backward when +# start and finish actions. +# +#============================================================================== +# Бе Instructions +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# To change the player direction in-game, use the snippet below in a script +# call: +# +# $game_system.party_direction = n +# +# To install this script, open up your script editor and copy/paste this script +# to an open slot below Бе Materials but above Бе Main. Remember to save. +# +#============================================================================== +# Бе Compatibility +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that +# it will run with RPG Maker VX without adjusting. +# +#============================================================================== + +module YEA + module VISUAL_BATTLERS + + #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + # - Party Location Setting - + #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + # These settings are adjusted for Party Location. Each Actor will have + # coordinates calculated by below formula. There are two samples coordinates + # below, change PARTY_DIRECTION to the base index you want to use. + #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + PARTY_DIRECTION = 6 # This direction is opposite from actual direction. + + PARTY_LOCATION_BASE_COORDINATES ={ + # Index => [base_x, base_y, mod_x, mod_y], + 2 => [ 250, 290, 40, 0], #UP + 4 => [ 150, 280, 20, -20], #LEFT + 3 => [ 460, 280, 30, -10], #RIGHT + 6 => [ 460, 230, 20, 20], #DEFAULT RIGHT + 8 => [ 260, 230, 40, 0], #DOWN + } # Do not remove this. + + PARTY_LOCATION_FORMULA_X = "base_x + index * mod_x" + PARTY_LOCATION_FORMULA_Y = "base_y + index * mod_y" + + end # VISUAL_BATTLERS +end # YEA + +#============================================================================== +# Бе Editting anything past this point may potentially result in causing +# computer damage, incontinence, explosion of user's head, coma, death, and/or +# halitosis so edit at your own risk. +#============================================================================== + +#============================================================================== +# ? Бе Direction +#============================================================================== + +module Direction + + #-------------------------------------------------------------------------- + # self.correct + #-------------------------------------------------------------------------- + def self.correct(direction) + case direction + when 1; return 4 + when 3; return 6 + when 7; return 4 + when 9; return 6 + else; return direction + end + end + + #-------------------------------------------------------------------------- + # self.opposite + #-------------------------------------------------------------------------- + def self.opposite(direction) + case direction + when 1; return 6 + when 2; return 8 + when 3; return 4 + when 4; return 6 + when 6; return 4 + when 7; return 6 + when 8; return 2 + when 9; return 4 + else; return direction + end + end + +end # Direction + +#============================================================================== +# ? Бе Game_System +#============================================================================== + +class Game_System; attr_accessor :party_direction; end + +#============================================================================== +# ? Бе Game_BattleCharacter +#============================================================================== + +class Game_BattleCharacter < Game_Character + + #-------------------------------------------------------------------------- + # initialize + #-------------------------------------------------------------------------- + def initialize(actor) + super() + setup_actor(actor) + @move_x_rate = 0 + @move_y_rate = 0 + end + + #-------------------------------------------------------------------------- + # setup_actor + #-------------------------------------------------------------------------- + def setup_actor(actor) + @actor = actor + @step_anime = true + set_graphic(@actor.character_name, @actor.character_index) + setup_coordinates + dr = $game_system.party_direction || YEA::VISUAL_BATTLERS::PARTY_DIRECTION + direction = Direction.opposite(dr) + set_direction(Direction.correct(direction)) + end + + #-------------------------------------------------------------------------- + # sprite= + #-------------------------------------------------------------------------- + def sprite=(sprite) + @sprite = sprite + end + + #-------------------------------------------------------------------------- + # setup_coordinates + #-------------------------------------------------------------------------- + def setup_coordinates + location = ($game_system.party_direction || + YEA::VISUAL_BATTLERS::PARTY_DIRECTION) + base_x = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][0] + base_y = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][1] + mod_x = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][2] + mod_y = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][3] + @actor.screen_x = eval(YEA::VISUAL_BATTLERS::PARTY_LOCATION_FORMULA_X) + @actor.screen_y = eval(YEA::VISUAL_BATTLERS::PARTY_LOCATION_FORMULA_Y) + @actor.origin_x = @actor.screen_x + @actor.origin_y = @actor.screen_y + @actor.create_move_to(screen_x, screen_y, 1) + end + + #-------------------------------------------------------------------------- + # index + #-------------------------------------------------------------------------- + def index + return @actor.index + end + + #-------------------------------------------------------------------------- + # screen_x + #-------------------------------------------------------------------------- + def screen_x + return @actor.screen_x + end + + #-------------------------------------------------------------------------- + # screen_y + #-------------------------------------------------------------------------- + def screen_y + return @actor.screen_y + end + + #-------------------------------------------------------------------------- + # screen_z + #-------------------------------------------------------------------------- + def screen_z + return @actor.screen_z + end + +end # Game_BattleCharacter + +#============================================================================== +# ? Бе Game_Battler +#============================================================================== + +class Game_Battler < Game_BattlerBase + + #-------------------------------------------------------------------------- + # public instance variables + #-------------------------------------------------------------------------- + attr_accessor :moved_back + attr_accessor :origin_x + attr_accessor :origin_y + attr_accessor :screen_x + attr_accessor :screen_y + attr_accessor :started_turn + + #-------------------------------------------------------------------------- + # alias method: execute_damage + #-------------------------------------------------------------------------- + alias game_battler_execute_damage_vb execute_damage + def execute_damage(user) + game_battler_execute_damage_vb(user) + if @result.hp_damage > 0 + move_backward(24, 6) unless @moved_back + @moved_back = true + end + end + + #-------------------------------------------------------------------------- + # face_opposing_party + #-------------------------------------------------------------------------- + def face_opposing_party + direction = ($game_system.party_direction || + YEA::VISUAL_BATTLERS::PARTY_DIRECTION) + character.set_direction(Direction.correct(direction)) rescue 0 + end + + #-------------------------------------------------------------------------- + # new method: face_coordinate + #-------------------------------------------------------------------------- + def face_coordinate(destination_x, destination_y) + x1 = Integer(@screen_x) + x2 = Integer(destination_x) + y1 = Graphics.height - Integer(@screen_y) + y2 = Graphics.height - Integer(destination_y) + return if x1 == x2 and y1 == y2 + #--- + angle = Integer(Math.atan2((y2-y1),(x2-x1)) * 1800 / Math::PI) + if (0..225) === angle or (-225..0) === angle + direction = 6 + elsif (226..675) === angle + direction = 9 + elsif (676..1125) === angle + direction = 8 + elsif (1126..1575) === angle + direction = 7 + elsif (1576..1800) === angle or (-1800..-1576) === angle + direction = 4 + elsif (-1575..-1126) === angle + direction = 1 + elsif (-1125..-676) === angle + direction = 2 + elsif (-675..-226) === angle + direction = 3 + end + #--- + character.set_direction(Direction.correct(direction)) rescue 0 + end + + #-------------------------------------------------------------------------- + # create_move_to + #-------------------------------------------------------------------------- + def create_move_to(destination_x, destination_y, frames = 12) + @destination_x = destination_x + @destination_y = destination_y + frames = [frames, 1].max + @move_x_rate = [(@screen_x - @destination_x).abs / frames, 2].max + @move_y_rate = [(@screen_y - @destination_y).abs / frames, 2].max + end + + #-------------------------------------------------------------------------- + # update_move_to + #-------------------------------------------------------------------------- + def update_move_to + @move_x_rate = 0 if @screen_x == @destination_x || @move_x_rate.nil? + @move_y_rate = 0 if @screen_y == @destination_y || @move_y_rate.nil? + value = [(@screen_x - @destination_x).abs, @move_x_rate].min + @screen_x += (@destination_x > @screen_x) ? value : -value + value = [(@screen_y - @destination_y).abs, @move_y_rate].min + @screen_y += (@destination_y > @screen_y) ? value : -value + end + + #-------------------------------------------------------------------------- + # move_forward + #-------------------------------------------------------------------------- + def move_forward(distance = 24, frames = 12) + direction = forward_direction + move_direction(direction, distance, frames) + end + + #-------------------------------------------------------------------------- + # move_backward + #-------------------------------------------------------------------------- + def move_backward(distance = 24, frames = 12) + direction = Direction.opposite(forward_direction) + move_direction(direction, distance, frames) + end + + #-------------------------------------------------------------------------- + # move_direction + #-------------------------------------------------------------------------- + def move_direction(direction, distance = 24, frames = 12) + case direction + when 1; move_x = distance / -2; move_y = distance / 2 + when 2; move_x = distance * 0; move_y = distance * 1 + when 3; move_x = distance / -2; move_y = distance / 2 + when 4; move_x = distance * -1; move_y = distance * 0 + when 6; move_x = distance * 1; move_y = distance * 0 + when 7; move_x = distance / -2; move_y = distance / -2 + when 8; move_x = distance * 0; move_y = distance * -1 + when 9; move_x = distance / 2; move_y = distance / -2 + else; return + end + destination_x = @screen_x + move_x + destination_y = @screen_y + move_y + create_move_to(destination_x, destination_y, frames) + end + + #-------------------------------------------------------------------------- + # forward_direction + #-------------------------------------------------------------------------- + def forward_direction + return ($game_system.party_direction || + YEA::VISUAL_BATTLERS::PARTY_DIRECTION) + end + + #-------------------------------------------------------------------------- + # move_origin + #-------------------------------------------------------------------------- + def move_origin + create_move_to(@origin_x, @origin_y) + face_coordinate(@origin_x, @origin_y) + @moved_back = false + end + + #-------------------------------------------------------------------------- + # moving? + #-------------------------------------------------------------------------- + def moving? + return false if dead? || !exist? + return @move_x_rate != 0 || @move_y_rate != 0 + end + +end # Game_Battler + +#============================================================================== +# ? Бе Game_Actor +#============================================================================== + +class Game_Actor < Game_Battler + + #-------------------------------------------------------------------------- + # overwrite method: use_sprite? + #-------------------------------------------------------------------------- + def use_sprite? + return true + end + + #-------------------------------------------------------------------------- + # new method: screen_x + #-------------------------------------------------------------------------- + def screen_x + return @screen_x rescue 0 + end + + #-------------------------------------------------------------------------- + # new method: screen_y + #-------------------------------------------------------------------------- + def screen_y + return @screen_y rescue 0 + end + + #-------------------------------------------------------------------------- + # new method: screen_z + #-------------------------------------------------------------------------- + def screen_z + return 100 + end + + #-------------------------------------------------------------------------- + # new method: sprite + #-------------------------------------------------------------------------- + def sprite + index = $game_party.battle_members.index(self) + return SceneManager.scene.spriteset.actor_sprites[index] + end + + #-------------------------------------------------------------------------- + # new method: character + #-------------------------------------------------------------------------- + def character + return sprite.character_base + end + + #-------------------------------------------------------------------------- + # face_opposing_party + #-------------------------------------------------------------------------- + def face_opposing_party + dr = $game_system.party_direction || YEA::VISUAL_BATTLERS::PARTY_DIRECTION + direction = Direction.opposite(dr) + character.set_direction(Direction.correct(direction)) rescue 0 + end + + #-------------------------------------------------------------------------- + # forward_direction + #-------------------------------------------------------------------------- + def forward_direction + return Direction.opposite(($game_system.party_direction || + YEA::VISUAL_BATTLERS::PARTY_DIRECTION)) + end + +end # Game_Actor + +#============================================================================== +# ? Бе Game_Enemy +#============================================================================== + +class Game_Enemy < Game_Battler + + #-------------------------------------------------------------------------- + # new method: sprite + #-------------------------------------------------------------------------- + def sprite + return SceneManager.scene.spriteset.enemy_sprites.reverse[self.index] + end + + #-------------------------------------------------------------------------- + # new method: character + #-------------------------------------------------------------------------- + def character + return sprite + end + +end # Game_Enemy + +#============================================================================== +# ? Бе Game_Troop +#============================================================================== + +class Game_Troop < Game_Unit + + #-------------------------------------------------------------------------- + # alias method: setup + #-------------------------------------------------------------------------- + alias game_troop_setup_vb setup + def setup(troop_id) + game_troop_setup_vb(troop_id) + set_coordinates + end + + #-------------------------------------------------------------------------- + # new method: set_coordinates + #-------------------------------------------------------------------------- + def set_coordinates + for member in members + member.origin_x = member.screen_x + member.origin_y = member.screen_y + member.create_move_to(member.screen_x, member.screen_y, 1) + end + end + +end # Game_Troop + +#============================================================================== +# ? Бе Sprite_Battler +#============================================================================== + +class Sprite_Battler < Sprite_Base + + #-------------------------------------------------------------------------- + # public instance_variable + #-------------------------------------------------------------------------- + attr_accessor :character_base + attr_accessor :character_sprite + + #-------------------------------------------------------------------------- + # alias method: dispose + #-------------------------------------------------------------------------- + alias sprite_battler_dispose_vb dispose + def dispose + dispose_character_sprite + sprite_battler_dispose_vb + end + + #-------------------------------------------------------------------------- + # new method: dispose_character_sprite + #-------------------------------------------------------------------------- + def dispose_character_sprite + @character_sprite.dispose unless @character_sprite.nil? + end + + #-------------------------------------------------------------------------- + # alias method: update + #-------------------------------------------------------------------------- + alias sprite_battler_update_vb update + def update + sprite_battler_update_vb + return if @battler.nil? + update_move_to + update_character_base + update_character_sprite + end + + #-------------------------------------------------------------------------- + # new method: update_character_base + #-------------------------------------------------------------------------- + def update_character_base + return if @character_base.nil? + @character_base.update + end + + #-------------------------------------------------------------------------- + # new method: update_character_sprite + #-------------------------------------------------------------------------- + def update_character_sprite + return if @character_sprite.nil? + @character_sprite.update + end + + #-------------------------------------------------------------------------- + # new method: update_move_to + #-------------------------------------------------------------------------- + def update_move_to + @battler.update_move_to + end + + #-------------------------------------------------------------------------- + # new method: moving? + #-------------------------------------------------------------------------- + def moving? + return false if @battler.nil? + return @battler.moving? + end + +end # Sprite_Battler + +#============================================================================== +# ? Бе Sprite_BattleCharacter +#============================================================================== + +class Sprite_BattleCharacter < Sprite_Character + + #-------------------------------------------------------------------------- + # initialize + #-------------------------------------------------------------------------- + def initialize(viewport, character = nil) + super(viewport, character) + character.sprite = self + end + +end # Sprite_BattleCharacter + +#============================================================================== +# ? Бе Spriteset_Battle +#============================================================================== + +class Spriteset_Battle + + #-------------------------------------------------------------------------- + # public instance_variable + #-------------------------------------------------------------------------- + attr_accessor :actor_sprites + attr_accessor :enemy_sprites + + #-------------------------------------------------------------------------- + # overwrite method: create_actors + #-------------------------------------------------------------------------- + def create_actors + total = $game_party.max_battle_members + @current_party = $game_party.battle_members.clone + @actor_sprites = Array.new(total) { Sprite_Battler.new(@viewport1) } + for actor in $game_party.battle_members + @actor_sprites[actor.index].battler = actor + create_actor_sprite(actor) + end + end + + #-------------------------------------------------------------------------- + # new method: create_actor_sprite + #-------------------------------------------------------------------------- + def create_actor_sprite(actor) + character = Game_BattleCharacter.new(actor) + character_sprite = Sprite_BattleCharacter.new(@viewport1, character) + @actor_sprites[actor.index].character_base = character + @actor_sprites[actor.index].character_sprite = character_sprite + actor.face_opposing_party + end + + #-------------------------------------------------------------------------- + # alias method: update_actors + #-------------------------------------------------------------------------- + alias spriteset_battle_update_actors_vb update_actors + def update_actors + if @current_party != $game_party.battle_members + dispose_actors + create_actors + end + spriteset_battle_update_actors_vb + end + + #-------------------------------------------------------------------------- + # new method: moving? + #-------------------------------------------------------------------------- + def moving? + return battler_sprites.any? {|sprite| sprite.moving? } + end + +end # Spriteset_Battle + +#============================================================================== +# ? Бе Scene_Battle +#============================================================================== + +class Scene_Battle < Scene_Base + + #-------------------------------------------------------------------------- + # public instance variables + #-------------------------------------------------------------------------- + attr_accessor :spriteset + + #-------------------------------------------------------------------------- + # alias method: process_action_end + #-------------------------------------------------------------------------- + alias scene_battle_process_action_end_vb process_action_end + def process_action_end + start_battler_move_origin + scene_battle_process_action_end_vb + end + + #-------------------------------------------------------------------------- + # alias method: execute_action + #-------------------------------------------------------------------------- + alias scene_battle_execute_action_vb execute_action + def execute_action + start_battler_move_forward + scene_battle_execute_action_vb + end + + #-------------------------------------------------------------------------- + # new method: start_battler_move_forward + #-------------------------------------------------------------------------- + def start_battler_move_forward + return if @subject.started_turn + @subject.started_turn = true + @subject.move_forward + wait_for_moving + end + + #-------------------------------------------------------------------------- + # new method: start_battler_move_origin + #-------------------------------------------------------------------------- + def start_battler_move_origin + @subject.started_turn = nil + move_battlers_origin + wait_for_moving + @subject.face_opposing_party rescue 0 + end + + #-------------------------------------------------------------------------- + # new method: move_battlers_origin + #-------------------------------------------------------------------------- + def move_battlers_origin + for member in all_battle_members + next if member.dead? + next unless member.exist? + member.move_origin + end + end + + #-------------------------------------------------------------------------- + # new method: wait_for_moving + #-------------------------------------------------------------------------- + def wait_for_moving + update_for_wait + update_for_wait while @spriteset.moving? + end + +end # Scene_Battle + +#============================================================================== +# +# Бе End of File +# +#============================================================================== From 9d940755e7883a7a1dbef9639e6a6890e9cf1057 Mon Sep 17 00:00:00 2001 From: Dale Henrichs Date: Sat, 7 Jun 2014 14:49:39 -0700 Subject: [PATCH 42/53] .ston extension for "Smalltalk Object Notation" See https://github.com/svenvc/ston --- lib/linguist/languages.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index f90e7f17..342daa3f 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2041,6 +2041,14 @@ Stata: - .matah - .sthlp +STON: + type: data + group: Smalltalk + lexer: JavaScript + extensions: + - .ston + + Stylus: type: markup group: CSS From ff791f5a3939b80f0b0457bc530425d2a3d59ed8 Mon Sep 17 00:00:00 2001 From: Dale Henrichs Date: Sun, 8 Jun 2014 20:41:41 -0700 Subject: [PATCH 43/53] "looks like I should have used JSON lexer - let's see what travis has to say --- lib/linguist/languages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 342daa3f..2ab39b30 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2044,7 +2044,7 @@ Stata: STON: type: data group: Smalltalk - lexer: JavaScript + lexer: JSON extensions: - .ston From 539256b08e9a016fb9bb36e7d6b40fd06ea665bc Mon Sep 17 00:00:00 2001 From: Dale Henrichs Date: Sun, 8 Jun 2014 20:49:45 -0700 Subject: [PATCH 44/53] send to travis --- lib/linguist/languages.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 2ab39b30..80eb3440 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2048,7 +2048,6 @@ STON: extensions: - .ston - Stylus: type: markup group: CSS From 00e1a3f8fd925e7319f17ba1d318c2a7df631780 Mon Sep 17 00:00:00 2001 From: Dale Henrichs Date: Sun, 8 Jun 2014 20:56:09 -0700 Subject: [PATCH 45/53] ahhh, caps are sorted before lower case ... --- lib/linguist/languages.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 80eb3440..1138ebbe 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1903,6 +1903,13 @@ SQL: - .udf - .viw +STON: + type: data + group: Smalltalk + lexer: JSON + extensions: + - .ston + Sage: type: programming lexer: Python @@ -2041,13 +2048,6 @@ Stata: - .matah - .sthlp -STON: - type: data - group: Smalltalk - lexer: JSON - extensions: - - .ston - Stylus: type: markup group: CSS From 625e0aa1affc91ee9fc4e9832cf12017d5002e40 Mon Sep 17 00:00:00 2001 From: Dale Henrichs Date: Sun, 8 Jun 2014 21:21:29 -0700 Subject: [PATCH 46/53] add sample files --- samples/STON/Array.ston | 1 + samples/STON/Dictionary.ston | 1 + samples/STON/Rectangle.ston | 4 ++++ samples/STON/TestDomainObject.ston | 15 +++++++++++++++ samples/STON/ZNResponse.ston | 30 ++++++++++++++++++++++++++++++ samples/STON/methodProperties.ston | 24 ++++++++++++++++++++++++ samples/STON/properties.ston | 19 +++++++++++++++++++ 7 files changed, 94 insertions(+) create mode 100644 samples/STON/Array.ston create mode 100644 samples/STON/Dictionary.ston create mode 100644 samples/STON/Rectangle.ston create mode 100644 samples/STON/TestDomainObject.ston create mode 100644 samples/STON/ZNResponse.ston create mode 100644 samples/STON/methodProperties.ston create mode 100644 samples/STON/properties.ston diff --git a/samples/STON/Array.ston b/samples/STON/Array.ston new file mode 100644 index 00000000..b5d8bb58 --- /dev/null +++ b/samples/STON/Array.ston @@ -0,0 +1 @@ +[1, 2, 3] diff --git a/samples/STON/Dictionary.ston b/samples/STON/Dictionary.ston new file mode 100644 index 00000000..ae4e2731 --- /dev/null +++ b/samples/STON/Dictionary.ston @@ -0,0 +1 @@ +{#a : 1, #b : 2} diff --git a/samples/STON/Rectangle.ston b/samples/STON/Rectangle.ston new file mode 100644 index 00000000..f9c81b33 --- /dev/null +++ b/samples/STON/Rectangle.ston @@ -0,0 +1,4 @@ +Rectangle { + #origin : Point [ -40, -15 ], + #corner : Point [ 60, 35 ] + } diff --git a/samples/STON/TestDomainObject.ston b/samples/STON/TestDomainObject.ston new file mode 100644 index 00000000..d054f4c5 --- /dev/null +++ b/samples/STON/TestDomainObject.ston @@ -0,0 +1,15 @@ +TestDomainObject { + #created : DateAndTime [ '2012-02-14T16:40:15+01:00' ], + #modified : DateAndTime [ '2012-02-14T16:40:18+01:00' ], + #integer : 39581, + #float : 73.84789359463944, + #description : 'This is a test', + #color : #green, + #tags : [ + #two, + #beta, + #medium + ], + #bytes : ByteArray [ 'afabfdf61d030f43eb67960c0ae9f39f' ], + #boolean : false +} diff --git a/samples/STON/ZNResponse.ston b/samples/STON/ZNResponse.ston new file mode 100644 index 00000000..66378370 --- /dev/null +++ b/samples/STON/ZNResponse.ston @@ -0,0 +1,30 @@ +ZnResponse { + #headers : ZnHeaders { + #headers : ZnMultiValueDictionary { + 'Date' : 'Fri, 04 May 2012 20:09:23 GMT', + 'Modification-Date' : 'Thu, 10 Feb 2011 08:32:30 GMT', + 'Content-Length' : '113', + 'Server' : 'Zinc HTTP Components 1.0', + 'Vary' : 'Accept-Encoding', + 'Connection' : 'close', + 'Content-Type' : 'text/html;charset=utf-8' + } + }, + #entity : ZnStringEntity { + #contentType : ZnMimeType { + #main : 'text', + #sub : 'html', + #parameters : { + 'charset' : 'utf-8' + } + }, + #contentLength : 113, + #string : '\nSmall\n

Small

This is a small HTML document

\n\n', + #encoder : ZnUTF8Encoder { } + }, + #statusLine : ZnStatusLine { + #version : 'HTTP/1.1', + #code : 200, + #reason : 'OK' + } + } diff --git a/samples/STON/methodProperties.ston b/samples/STON/methodProperties.ston new file mode 100644 index 00000000..40a1a0fe --- /dev/null +++ b/samples/STON/methodProperties.ston @@ -0,0 +1,24 @@ +{ + "class" : { + }, + "instance" : { + "clientList:listElement:" : "dkh 03/20/2014 16:27", + "copyObjectMenuAction:selectionIndex:" : "dkh 10/13/2013 10:20", + "definitionForSelection:" : "dkh 10/13/2013 10:15", + "editMenuActionSpec" : "dkh 10/13/2013 10:19", + "itemSelected:listElement:selectedIndex:shiftPressed:" : "dkh 10/20/2013 11:06", + "menuActionSpec:" : "dkh 10/19/2013 17:12", + "repository:" : "dkh 10/19/2013 17:36", + "theList" : "dkh 10/12/2013 15:51", + "versionInfoBlock:" : "dkh 10/19/2013 17:08", + "versionInfoDiffVsSelection:selectedIndex:" : "dkh 10/19/2013 17:48", + "versionInfoDiffVsWorkingCopy:selectedIndex:" : "dkh 10/20/2013 12:36", + "versionInfoSelect:selectedIndex:" : "dkh 10/12/2013 17:04", + "versionInfos" : "dkh 10/19/2013 17:13", + "versionSummaryIsClosing" : "dkh 10/20/2013 10:19", + "windowIsClosing:" : "dkh 10/20/2013 10:39", + "windowLabel" : "dkh 05/20/2014 11:00", + "windowLocation" : "dkh 05/23/2014 10:17", + "windowName" : "dkh 10/12/2013 16:00", + "workingCopy" : "dkh 10/12/2013 16:16", + "workingCopy:" : "dkh 10/12/2013 16:17" } } diff --git a/samples/STON/properties.ston b/samples/STON/properties.ston new file mode 100644 index 00000000..b4aa0206 --- /dev/null +++ b/samples/STON/properties.ston @@ -0,0 +1,19 @@ +{ + "category" : "Topez-Server-Core", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "workingCopy", + "repository", + "versionInfos", + "versionInfoBlock", + "selectedVersionInfo", + "versionInfoSummaryWindowId" ], + "name" : "TDVersionInfoBrowser", + "pools" : [ + ], + "super" : "TDAbstractMonticelloToolBuilder", + "type" : "normal" } From e709ce7d56ddaa42ba75d7409ebf3482ed8a7d61 Mon Sep 17 00:00:00 2001 From: Arfon Smith Date: Mon, 9 Jun 2014 06:27:26 -0500 Subject: [PATCH 47/53] Samples --- lib/linguist/samples.json | 61 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index 9cbfceb0..91c30ab5 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -580,6 +580,9 @@ ".matah", ".sthlp" ], + "STON": [ + ".ston" + ], "Stylus": [ ".styl" ], @@ -737,8 +740,8 @@ ".gemrc" ] }, - "tokens_total": 614257, - "languages_total": 804, + "tokens_total": 614357, + "languages_total": 811, "tokens": { "ABAP": { "*/**": 1, @@ -61981,6 +61984,56 @@ "return": 1, "/": 1 }, + "STON": { + "[": 11, + "]": 11, + "{": 15, + "#a": 1, + "#b": 1, + "}": 15, + "Rectangle": 1, + "#origin": 1, + "Point": 2, + "-": 2, + "#corner": 1, + "TestDomainObject": 1, + "#created": 1, + "DateAndTime": 2, + "#modified": 1, + "#integer": 1, + "#float": 1, + "#description": 1, + "#color": 1, + "#green": 1, + "#tags": 1, + "#two": 1, + "#beta": 1, + "#medium": 1, + "#bytes": 1, + "ByteArray": 1, + "#boolean": 1, + "false": 1, + "ZnResponse": 1, + "#headers": 2, + "ZnHeaders": 1, + "ZnMultiValueDictionary": 1, + "#entity": 1, + "ZnStringEntity": 1, + "#contentType": 1, + "ZnMimeType": 1, + "#main": 1, + "#sub": 1, + "#parameters": 1, + "#contentLength": 1, + "#string": 1, + "#encoder": 1, + "ZnUTF8Encoder": 1, + "#statusLine": 1, + "ZnStatusLine": 1, + "#version": 1, + "#code": 1, + "#reason": 1 + }, "Stylus": { "border": 6, "-": 10, @@ -67042,6 +67095,7 @@ "Squirrel": 130, "Standard ML": 6567, "Stata": 3133, + "STON": 100, "Stylus": 76, "SuperCollider": 133, "Swift": 1128, @@ -67231,6 +67285,7 @@ "Squirrel": 1, "Standard ML": 5, "Stata": 7, + "STON": 7, "Stylus": 1, "SuperCollider": 1, "Swift": 43, @@ -67259,5 +67314,5 @@ "Zephir": 2, "Zimpl": 1 }, - "md5": "e69777074750ed98faadf08497ba6339" + "md5": "92c117f774abe712958bb369c4e1dde9" } \ No newline at end of file From 878fe95ec38f08e4b253b5194f015df791a97a6c Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Tue, 10 Jun 2014 15:54:48 -0400 Subject: [PATCH 48/53] Upgrades to pygments.rb 0.6.0 --- github-linguist.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-linguist.gemspec b/github-linguist.gemspec index c17525f4..d4c2337a 100644 --- a/github-linguist.gemspec +++ b/github-linguist.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |s| s.add_dependency 'charlock_holmes', '~> 0.7.3' s.add_dependency 'escape_utils', '~> 1.0.1' s.add_dependency 'mime-types', '~> 1.19' - s.add_dependency 'pygments.rb', '~> 0.5.4' + s.add_dependency 'pygments.rb', '~> 0.6.0' s.add_development_dependency 'json' s.add_development_dependency 'mocha' From 3ad4eb2b59def80cf443b350d19f3d6a15b2a53f Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Mon, 9 Jun 2014 11:28:26 -0400 Subject: [PATCH 49/53] Adds supports for Slim --- lib/linguist/languages.yml | 7 ++++ lib/linguist/samples.json | 75 ++++++++++++++++++++++++++++++++++++-- samples/Slim/sample.slim | 31 ++++++++++++++++ 3 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 samples/Slim/sample.slim diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 233fa3e1..42112de1 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2002,6 +2002,13 @@ Slash: extensions: - .sl +Slim: + group: HTML + type: markup + color: "#ff8877" + extensions: + - .slim + Smalltalk: type: programming color: "#596706" diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index 91c30ab5..1f3db02c 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -549,6 +549,9 @@ "Slash": [ ".sl" ], + "Slim": [ + ".slim" + ], "Smalltalk": [ ".st" ], @@ -740,8 +743,8 @@ ".gemrc" ] }, - "tokens_total": 614357, - "languages_total": 811, + "tokens_total": 614434, + "languages_total": 812, "tokens": { "ABAP": { "*/**": 1, @@ -60170,6 +60173,70 @@ "ast.eval": 1, "Env.new": 1 }, + "Slim": { + "doctype": 1, + "html": 2, + "head": 1, + "title": 1, + "Slim": 2, + "Examples": 1, + "meta": 2, + "name": 2, + "content": 2, + "author": 2, + "javascript": 1, + "alert": 1, + "(": 1, + ")": 1, + "body": 1, + "h1": 1, + "Markup": 1, + "examples": 1, + "#content": 1, + "p": 2, + "This": 1, + "example": 1, + "shows": 1, + "you": 2, + "how": 1, + "a": 1, + "basic": 1, + "file": 1, + "looks": 1, + "like.": 1, + "yield": 1, + "-": 3, + "unless": 1, + "items.empty": 1, + "table": 1, + "for": 1, + "item": 1, + "in": 1, + "items": 2, + "do": 1, + "tr": 1, + "td.name": 1, + "item.name": 1, + "td.price": 1, + "item.price": 1, + "else": 1, + "|": 2, + "No": 1, + "found.": 1, + "Please": 1, + "add": 1, + "some": 1, + "inventory.": 1, + "Thank": 1, + "div": 1, + "id": 1, + "render": 1, + "Copyright": 1, + "#": 2, + "{": 2, + "year": 1, + "}": 2 + }, "Smalltalk": { "Object": 1, "subclass": 2, @@ -67089,6 +67156,7 @@ "ShellSession": 233, "Shen": 3472, "Slash": 187, + "Slim": 77, "Smalltalk": 423, "SourcePawn": 2080, "SQL": 1485, @@ -67279,6 +67347,7 @@ "ShellSession": 3, "Shen": 3, "Slash": 1, + "Slim": 1, "Smalltalk": 3, "SourcePawn": 1, "SQL": 5, @@ -67314,5 +67383,5 @@ "Zephir": 2, "Zimpl": 1 }, - "md5": "92c117f774abe712958bb369c4e1dde9" + "md5": "3e0901633ee5729c6dac371442522f33" } \ No newline at end of file diff --git a/samples/Slim/sample.slim b/samples/Slim/sample.slim new file mode 100644 index 00000000..9480a9ff --- /dev/null +++ b/samples/Slim/sample.slim @@ -0,0 +1,31 @@ +doctype html +html + head + title Slim Examples + meta name="keywords" content="template language" + meta name="author" content=author + javascript: + alert('Slim supports embedded javascript!') + + body + h1 Markup examples + + #content + p This example shows you how a basic Slim file looks like. + + == yield + + - unless items.empty? + table + - for item in items do + tr + td.name = item.name + td.price = item.price + - else + p + | No items found. Please add some inventory. + Thank you! + + div id="footer" + = render 'footer' + | Copyright ┬й #{year} #{author} From 85479cc2dedcce28a2ad1f181ede499c31686db0 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Mon, 9 Jun 2014 11:30:01 -0400 Subject: [PATCH 50/53] Swift has a lexer now --- lib/linguist/languages.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 42112de1..504a9cd5 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2072,7 +2072,6 @@ SuperCollider: Swift: type: programming color: "#ffac45" - lexer: Text only extensions: - .swift From 09b9a8b4410009d1ef2ca4f3a4737ea05de428ea Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Tue, 10 Jun 2014 16:00:08 -0500 Subject: [PATCH 51/53] bump version for 2.11.5 release --- lib/linguist/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/version.rb b/lib/linguist/version.rb index b681d0e0..fba87ba8 100644 --- a/lib/linguist/version.rb +++ b/lib/linguist/version.rb @@ -1,3 +1,3 @@ module Linguist - VERSION = "2.11.4" + VERSION = "2.11.5" end From 607185ac6111378a93d74c6815944779ef54137f Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Wed, 11 Jun 2014 13:56:40 -0400 Subject: [PATCH 52/53] Be explicit about lexer --- lib/linguist/languages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 504a9cd5..d9c3f4f2 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2005,6 +2005,7 @@ Slash: Slim: group: HTML type: markup + lexer: Slim color: "#ff8877" extensions: - .slim @@ -2071,6 +2072,7 @@ SuperCollider: Swift: type: programming + lexer: Swift color: "#ffac45" extensions: - .swift From a707587182642159d37ac4752ed1abeae2ba3888 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Wed, 11 Jun 2014 14:00:46 -0400 Subject: [PATCH 53/53] Bumps to 2.12.0 --- lib/linguist/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/version.rb b/lib/linguist/version.rb index fba87ba8..6704b3fb 100644 --- a/lib/linguist/version.rb +++ b/lib/linguist/version.rb @@ -1,3 +1,3 @@ module Linguist - VERSION = "2.11.5" + VERSION = "2.12.0" end