Merge branch 'master' into prism-textile Conflicts: components.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
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