Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 4 commits
  • 4 files changed
  • 0 commit comments
  • 2 contributors
Showing with 173 additions and 0 deletions.
  1. +1 −0 README.md
  2. +42 −0 js/language/smalltalk.js
  3. +1 −0 tests/index.html
  4. +129 −0 tests/language/smalltalk-test.js
View
1 README.md
@@ -65,6 +65,7 @@ Currently supported languages are:
- Scheme
- Lua
- C#
+- Smalltalk
## More Info
View
42 js/language/smalltalk.js
@@ -0,0 +1,42 @@
+/**
+ * Smalltalk patterns
+ *
+ * @author Frank Shearar <frank@angband.za.org>
+ * @version 1.0
+ */
+Rainbow.extend('smalltalk', [
+ {'name': 'keyword.pseudovariable',
+ 'pattern': /self|thisContext/g
+ },
+ {'name': 'keyword.constant',
+ 'pattern': /false|nil|true/g
+ },
+ {'name': 'string',
+ 'pattern': /'([^']|'')*'/g
+ },
+ {'name': 'string.symbol',
+ 'pattern': /#\w+|#'([^']|'')*'/g
+ },
+ {'name': 'string.character',
+ 'pattern': /\$\w+/g
+ },
+ {
+ 'name': 'comment',
+ "pattern": /"([^"]|"")*"/g
+ },
+ {'name': 'constant.numeric',
+ 'pattern': /-?\d+(\.\d+)?((r-?|s)[A-Za-z0-9]+|e-?[0-9]+)?/g
+ },
+ {'name': 'entity.name.class',
+ 'pattern': /\b[A-Z]\w*/g
+ },
+ {'name': 'entity.name.function',
+ 'pattern': /\b[a-z]\w*:?/g
+ },
+ {'name': 'entity.name.binary',
+ 'pattern': /(&lt;|&gt;|&amp;|[=~\|\\\/!@*\-_+])+/g
+ },
+ {'name': 'operator.delimiter',
+ 'pattern': /;[\(\)\[\]\{\}]|#\[|#\(^\./g
+ }
+], true);
View
1 tests/index.html
@@ -18,6 +18,7 @@
<option selected value="python">python</option>
<option selected value="ruby">ruby</option>
<option selected value="shell">shell</option>
+ <option selected value="smalltalk">smalltalk</option>
</select>
<label><input type="checkbox" name="min"> Use rainbow.min.js</label>
<input type="button" id="run_tests" value="Run Tests">
View
129 tests/language/smalltalk-test.js
@@ -0,0 +1,129 @@
+/**
+ * Smalltalk tests
+ *
+ * @author Frank Shearar
+ */
+RainbowTester.startTest('smalltalk');
+
+RainbowTester.run(
+ 'constant true',
+ 'true',
+ '<span class="keyword constant">true</span>');
+RainbowTester.run(
+ 'constant false',
+ 'false',
+ '<span class="keyword constant">false</span>');
+RainbowTester.run(
+ 'constant nil',
+ 'nil',
+ '<span class="keyword constant">nil</span>');
+RainbowTester.run(
+ 'self pseudovariable',
+ 'self',
+ '<span class="keyword pseudovariable">self</span>');
+RainbowTester.run(
+ 'thisContext pseudovariable',
+ 'thisContext',
+ '<span class="keyword pseudovariable">thisContext</span>');
+RainbowTester.run(
+ 'two-character operator !!',
+ '!!',
+ '<span class="entity name binary">!!</span>');
+RainbowTester.run(
+ 'two-character operator //',
+ '//',
+ '<span class="entity name binary">//</span>');
+RainbowTester.run(
+ '| delimiter',
+ '|',
+ '<span class="entity name binary">|</span>');
+RainbowTester.run(
+ '|| binary selector',
+ '||',
+ '<span class="entity name binary">||</span>');
+RainbowTester.run(
+ 'HTML-unfriendly operator',
+ '&',
+ '<span class="entity name binary">&amp;</span>');
+RainbowTester.run(
+ 'three-character operator',
+ '>>=',
+ '<span class="entity name binary">&gt;&gt;=</span>');
+RainbowTester.run(
+ 'String-like Symbol',
+ "#'this is a symbol'",
+ "<span class=\"string symbol\">#'this is a symbol'</span>");
+RainbowTester.run(
+ 'Symbol',
+ "#thisIsaSymbol0",
+ "<span class=\"string symbol\">#thisIsaSymbol0</span>");
+RainbowTester.run(
+ 'String',
+ "'This is a string'",
+ '<span class="string">\'This is a string\'</span>');
+RainbowTester.run(
+ 'Comment',
+ '"This is a comment"',
+ '<span class="comment">"This is a comment"</span>');
+RainbowTester.run(
+ 'Comment in between message sends',
+ 'self "this is a comment" foo',
+ '<span class="keyword pseudovariable">self</span> <span class="comment">"this is a comment"</span> <span class="entity name function">foo</span>');
+RainbowTester.run(
+ 'Integer',
+ '987654321',
+ '<span class="constant numeric">987654321</span>');
+RainbowTester.run(
+ 'Negative integer',
+ '-987654321',
+ '<span class="constant numeric">-987654321</span>');
+RainbowTester.run(
+ 'Exponent integer',
+ '987654321e10',
+ '<span class="constant numeric">987654321e10</span>');
+RainbowTester.run(
+ 'Negative exponent integer',
+ '-987654321e10',
+ '<span class="constant numeric">-987654321e10</span>');
+RainbowTester.run(
+ 'Radix Integer',
+ '16r987654321deadbeef',
+ '<span class="constant numeric">16r987654321deadbeef</span>');
+RainbowTester.run(
+ 'Negative radix Integer',
+ '16r-987654321deadbeef',
+ '<span class="constant numeric">16r-987654321deadbeef</span>');
+RainbowTester.run(
+ 'Float',
+ '987654321.0',
+ '<span class="constant numeric">987654321.0</span>');
+RainbowTester.run(
+ 'Negative float',
+ '-987654321.0',
+ '<span class="constant numeric">-987654321.0</span>');
+RainbowTester.run(
+ 'Exponent float',
+ '1.0e10',
+ '<span class="constant numeric">1.0e10</span>');
+RainbowTester.run(
+ 'Negative exponent float',
+ '1.0e-10',
+ '<span class="constant numeric">1.0e-10</span>');
+RainbowTester.run(
+ 'Negative exponent negative float',
+ '-1.0e-10',
+ '<span class="constant numeric">-1.0e-10</span>');
+RainbowTester.run(
+ 'Scaled decimal',
+ '1.0s10',
+ '<span class="constant numeric">1.0s10</span>');
+RainbowTester.run(
+ 'Class name, normal',
+ 'Class',
+ '<span class="entity name class">Class</span>');
+RainbowTester.run(
+ 'Class name, with digits',
+ 'Class0zero',
+ '<span class="entity name class">Class0zero</span>');
+
+RainbowTester.endTest('smalltalk');

No commit comments for this range

Something went wrong with that request. Please try again.