Commit 42fcc2a4cced5fe61142e8408635aa84606f0ca7

Golmote 2015-03-21T02:22:34

Merge branch 'master' into prism-textile Conflicts: components.js

diff --git a/components.js b/components.js
index e5c9471..d52b638 100644
--- a/components.js
+++ b/components.js
@@ -320,6 +320,10 @@ var components = {
 			"require": "markup",
 			"owner": "Golmote"
 		},
+		"smalltalk": {
+			"title": "Smalltalk",
+			"owner": "Golmote"
+		},
 		"textile": {
 			"title": "Textile",
 			"require": "markup",
diff --git a/components/prism-smalltalk.js b/components/prism-smalltalk.js
new file mode 100644
index 0000000..0ffc59d
--- /dev/null
+++ b/components/prism-smalltalk.js
@@ -0,0 +1,31 @@
+Prism.languages.smalltalk = {
+	'comment': /"(?:""|[^"])+"/,
+	'string': /'(?:''|[^'])+'/,
+	'symbol': /#[\da-z]+|#(?:-|([+\/\\*~<>=@%|&?!])\1?)|#(?=\()/i,
+	'block-arguments': {
+		pattern: /(\[\s*)(?=:)[^\[|]+?\|/,
+		lookbehind: true,
+		inside: {
+			'variable': /:[\da-z]+/i,
+			'punctuation': /\|/
+		}
+	},
+	'temporary-variables': {
+		pattern: /\|[^|]+\|/,
+		inside: {
+			'variable': /[\da-z]+/i,
+			'punctuation': /\|/
+		}
+	},
+	'keyword': /\b(?:nil|true|false|self|super|new)\b/,
+	'character': {
+		pattern: /\$./,
+		alias: 'string'
+	},
+	'number': [
+		/\d+r-?[\dA-Z]+(?:\.[\dA-Z]+)?(?:e-?\d+)?/,
+		/(?:\B-|\b)\d+(?:\.\d+)?(?:e-?\d+)?/
+	],
+	'operator': /[:=~<>]=|~~|\/\/|\\\\|>>|[!^=<>+\-*\/&|,@]/,
+	'punctuation': /[.;:?\[\](){}]/
+};
\ No newline at end of file
diff --git a/components/prism-smalltalk.min.js b/components/prism-smalltalk.min.js
new file mode 100644
index 0000000..505460c
--- /dev/null
+++ b/components/prism-smalltalk.min.js
@@ -0,0 +1 @@
+Prism.languages.smalltalk={comment:/"(?:""|[^"])+"/,string:/'(?:''|[^'])+'/,symbol:/#[\da-z]+|#(?:-|([+\/\\*~<>=@%|&?!])\1?)|#(?=\()/i,"block-arguments":{pattern:/(\[\s*)(?=:)[^\[|]+?\|/,lookbehind:!0,inside:{variable:/:[\da-z]+/i,punctuation:/\|/}},"temporary-variables":{pattern:/\|[^|]+\|/,inside:{variable:/[\da-z]+/i,punctuation:/\|/}},keyword:/\b(?:nil|true|false|self|super|new)\b/,character:{pattern:/\$./,alias:"string"},number:[/\d+r-?[\dA-Z]+(?:\.[\dA-Z]+)?(?:e-?\d+)?/,/(?:\B-|\b)\d+(?:\.\d+)?(?:e-?\d+)?/],operator:/[:=~<>]=|~~|\/\/|\\\\|>>|[!^=<>+\-*\/&|,@]/,punctuation:/[.;:?\[\](){}]/};
\ No newline at end of file
diff --git a/examples/prism-smalltalk.html b/examples/prism-smalltalk.html
new file mode 100644
index 0000000..63e4edb
--- /dev/null
+++ b/examples/prism-smalltalk.html
@@ -0,0 +1,95 @@
+<h1>Smalltalk</h1>
+<p>To use this language, use the class "language-smalltalk".</p>
+
+<h2>Numbers</h2>
+<pre><code>3
+30.45
+-3
+0.005
+-14.0
+13772
+8r377
+8r153
+8r34.1
+8r-37
+16r106
+16rFF
+16rAC.DC
+16r-1.C
+1.586e5
+1.586e-3
+8r3e2
+2r11e6</code></pre>
+
+<h2>Strings and characters</h2>
+<pre><code>$a
+$M
+$-
+$$
+$1
+'hi'
+'food'
+'the Smalltalk-80 system'
+'can''t'</code></pre>
+
+<h2>Symbols</h2>
+<pre><code>#bill
+#M63
+#+
+#*</code></pre>
+
+<h2>Arrays</h2>
+<pre><code>#(1 2 3)
+#('food' 'utilities' 'rent' 'household' 'transportation' 'taxes' 'recreation')
+#(('one' 1) ('not' 'negative') 0 -1)
+#(9 'nine' $9 (0 'zero' $0 ( ) 'e' $f 'g' $h 'i'))</code></pre>
+
+<h2>Blocks</h2>
+<pre><code>sum := 0.
+#(2 3 5 7 11) do: [ :primel | sum := sum + (prime * prime)]
+
+sizeAdder := [ :array | total := total + array size].
+
+[ :x :y | (x * x) + (y * y)]
+[ :frame :clippingBox | frame intersect: clippingBox]</code></pre>
+
+<h2>Full example</h2>
+<pre><code>Object>>method: num
+    "comment 123"
+    | var1 var2 |
+    (1 to: num) do: [:i | |var| ^i].
+    Klass with: var1.
+    Klass new.
+    arr := #('123' 123.345 #hello Transcript var $@).
+    arr := #().
+    var2 = arr at: 3.
+    ^ self abc
+
+heapExample
+    "HeapTest new heapExample"
+    "Multiline
+    decription"
+    | n rnd array time sorted |
+    n := 5000.
+    "# of elements to sort"
+    rnd := Random new.
+    array := (1 to: n)
+                collect: [:i | rnd next].
+    "First, the heap version"
+    time := Time
+                millisecondsToRun: [sorted := Heap withAll: array.
+    1
+        to: n
+        do: [:i |
+            sorted removeFirst.
+            sorted add: rnd next]].
+    Transcript cr; show: 'Time for Heap: ' , time printString , ' msecs'.
+    "The quicksort version"
+    time := Time
+                millisecondsToRun: [sorted := SortedCollection withAll: array.
+    1
+        to: n
+        do: [:i |
+            sorted removeFirst.
+            sorted add: rnd next]].
+    Transcript cr; show: 'Time for SortedCollection: ' , time printString , ' msecs'</code></pre>
\ No newline at end of file