diff --git a/CHANGELOG b/CHANGELOG index 4ca4c04..9e6e3b1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +Next release... +----------------- +- Enhancements + - new languages: pony + 1.22.0 2014-01-06 ----------------- - Bugfixes diff --git a/README.md b/README.md index 4696070..e91f189 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ for other options. - PowerShell - Objective-C - Lua +- Pony ## Plugins - sunlight-plugin.linenumbers.js (bundled) diff --git a/build.xml b/build.xml index aa6e473..d87dc20 100644 --- a/build.xml +++ b/build.xml @@ -80,6 +80,7 @@ + @@ -194,4 +195,4 @@ - \ No newline at end of file + diff --git a/src/lang/sunlight.pony.js b/src/lang/sunlight.pony.js new file mode 100644 index 0000000..fc8ce11 --- /dev/null +++ b/src/lang/sunlight.pony.js @@ -0,0 +1,53 @@ +(function(sunlight, undefined){ + + if (sunlight === undefined || sunlight["registerLanguage"] === undefined) { + throw "Include sunlight.js before including language files"; + } + + sunlight.registerLanguage("pony", { + keywords: [ + "actor", "addressof", "as", "be", "break", "class", "compiler_intrinsic", "consume", "continue", "do", "else", "elseif", "embed", "end", "error", "for", "fun", "if", "ifdef", "in", "interface", "is", "isnt", "lambda", "let", "match", "new", "not", "object", "primitive", "recover", "repeat", "return", "struct", "then", "this", "trait", "try", "type", "until", "use", "var", "where", "while", "with" + ], + + scopes: { + longString: [ + ["\"\"\"", "\"\"\"", sunlight.util.escapeSequences.concat(["\\\""])], + ["'''", "'''", sunlight.util.escapeSequences.concat(["\\'"])] + ], + string: [ ["\"", "\"", sunlight.util.escapeSequences.concat(["\\\""])] ], + comment: [ ["//", "\n", null, true], ["/*", "*/"] ] + }, + + customTokens: { + binops: { + values: ["or", "and", "isnt"], + boundary: " " + }, + booleans: { + values: ["true", "false"], + boundary: "" + } + }, + + customParseRules: [], + + identFirstLetter: /[@A-Za-z_]/, + identAfterFirstLetter: /\w/, + + namedIdentRules: { + follows: [ + //class names + //function names + [{ token: "keyword", values: ["actor", "be", "class", "fun", "lambda", "new", "use"] }, sunlight.util.whitespace] + ] + }, + + operators: [ + "!", "->", "^", "@", "&", "->", "=>", "~", "?", "'", "<:" + ], + + contextItems: { + heredocQueue: [] + } + }); +}(this["Sunlight"])); \ No newline at end of file diff --git a/src/plugins/sunlight-plugin.doclinks.js b/src/plugins/sunlight-plugin.doclinks.js index 48cf337..3d1ded2 100644 --- a/src/plugins/sunlight-plugin.doclinks.js +++ b/src/plugins/sunlight-plugin.doclinks.js @@ -31,7 +31,14 @@ + word.replace(/!/g, "_bang").replace(/\?/g, "_p"); } }, - + + pony: { + "function": function(word) { + return "http://www.ponylang.org/ponyc/search.html?q=" + word; + } + }, + + python: { "function": function(word) { return "http://docs.python.org/py3k/library/functions.html#" + word; diff --git a/tests/test-pony.html b/tests/test-pony.html new file mode 100644 index 0000000..2126d3b --- /dev/null +++ b/tests/test-pony.html @@ -0,0 +1,55 @@ + + + + + + + + + +
use "collections"
+
+class Circle
+  """Represents a circle."""
+
+  // The radius is a 32-bit floating point number.
+  var _radius: F32
+
+  new create(radius: F32) =>
+    _radius = radius
+
+  fun area(): F32 =>
+    """Return circle area."""
+    F32.pi() * _radius.pow(2)
+
+  fun circumference(): F32 =>
+    """Return circumference."""
+    2 * _radius * F32.pi()
+
+  fun valid(): Bool =>
+    """Return true if radius is > 0."""
+    _radius > 0.0
+
+use @memcmp[I32](dst: Pointer[U8] box, src: Pointer[U8] box, len: USize)
+
+actor Main
+  new create(env: Env) =>
+
+    for i in Range[F32](1.0, 101.0) do
+      let c = Circle(i)
+
+      var str =
+        "Circumference: " + c.circumference().string() + "\n" +
+        "Area: " + c.area().string() + "\n"
+
+      /* This prints out the output to stdout */
+      env.out.print(str)
+    end
+ + + + + +