diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/components.js b/components.js index 3c7ea795c2..024b625deb 100644 --- a/components.js +++ b/components.js @@ -281,6 +281,10 @@ var components = { "title": "Ini", "owner": "aviaryan" }, + "io": { + "title": "Io", + "owner": "AlesTsurko" + }, "j": { "title": "J", "owner": "Golmote" diff --git a/components/prism-io.js b/components/prism-io.js new file mode 100644 index 0000000000..54a90a1fef --- /dev/null +++ b/components/prism-io.js @@ -0,0 +1,31 @@ +Prism.languages.io = { + 'comment': [ + { + pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, + lookbehind: true + }, + { + pattern: /(^|[^\\])\/\/.*/, + lookbehind: true + }, + { + pattern: /(^|[^\\])#.*/, + lookbehind: true + } + ], + 'triple-quoted-string': { + pattern: /"""(?:\\[\s\S]|(?!""")[^\\])*"""/, + greedy: true, + alias: 'string' + }, + 'string': { + pattern: /"(?:\\.|[^\\\r\n"])*"/, + greedy: true + }, + 'keyword': /\b(?:activate|activeCoroCount|asString|block|break|catch|clone|collectGarbage|compileString|continue|do|doFile|doMessage|doString|else|elseif|exit|for|foreach|forward|getSlot|getEnvironmentVariable|hasSlot|if|ifFalse|ifNil|ifNilEval|ifTrue|isActive|isNil|isResumable|list|message|method|parent|pass|pause|perform|performWithArgList|print|println|proto|raise|raiseResumable|removeSlot|resend|resume|schedulerSleepSeconds|self|sender|setSchedulerSleepSeconds|setSlot|shallowCopy|slotNames|super|system|then|thisBlock|thisContext|call|try|type|uniqueId|updateSlot|wait|while|write|yield)\b/, + 'builtin':/\b(?:Array|AudioDevice|AudioMixer|Block|Box|Buffer|CFunction|CGI|Color|Curses|DBM|DNSResolver|DOConnection|DOProxy|DOServer|Date|Directory|Duration|DynLib|Error|Exception|FFT|File|Fnmatch|Font|Future|GL|GLE|GLScissor|GLU|GLUCylinder|GLUQuadric|GLUSphere|GLUT|Host|Image|Importer|LinkList|List|Lobby|Locals|MD5|MP3Decoder|MP3Encoder|Map|Message|Movie|Notification|Number|Object|OpenGL|Point|Protos|Regex|SGML|SGMLElement|SGMLParser|SQLite|Server|Sequence|ShowMessage|SleepyCat|SleepyCatCursor|Socket|SocketManager|Sound|Soup|Store|String|Tree|UDPSender|UPDReceiver|URL|User|Warning|WeakLink|Random|BigNum|Sequence)\b/, + 'boolean': /\b(?:true|false|nil)\b/, + 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e-?\d+)?)\b/i, + 'operator': /[=!*/%+-^&|]=|>>?=?|<>?=?|<Io +

To use this language, use the class "language-io".

+ +

Comments

+
//
+// Foobar
+#!/usr/bin/env io
+/* multiline
+comment
+*/
+ +

Strings

+
"this is a \"test\".\nThis is only a test."
+"""this is a "test".
+This is only a test."""
+ +

Numbers

+
123
+123.456
+0.456
+123e-4
+123e4
+123.456e-7
+123.456e2
+
+ +

Full example

+
"Hello, world!" println
+A := Object clone    // creates a new, empty object named "A"
+factorial := method(n,
+    if(n == 0, return 1)
+    res := 1
+    Range 1 to(n) foreach(i, res = res * i)
+)
diff --git a/package.json b/package.json old mode 100644 new mode 100755 diff --git a/tests/languages/io/comment_feature.test b/tests/languages/io/comment_feature.test new file mode 100644 index 0000000000..fb67d07b4d --- /dev/null +++ b/tests/languages/io/comment_feature.test @@ -0,0 +1,19 @@ +// +// Foobar +#!/usr/bin/env io +/* multiline +comment +*/ + +---------------------------------------------------- + +[ + ["comment", "//"], + ["comment", "// Foobar"], + ["comment", "#!/usr/bin/env io"], + ["comment", "/* multiline\ncomment\n*/"] +] + +---------------------------------------------------- + +Checks for comments. diff --git a/tests/languages/io/number_feature.test b/tests/languages/io/number_feature.test new file mode 100644 index 0000000000..371be063de --- /dev/null +++ b/tests/languages/io/number_feature.test @@ -0,0 +1,23 @@ +123 +123.456 +0.456 +123e-4 +123e4 +123.456e-7 +123.456e2 + +------------------------------ + +[ + ["number", "123"], + ["number", "123.456"], + ["number", "0.456"], + ["number", "123e-4"], + ["number", "123e4"], + ["number", "123.456e-7"], + ["number", "123.456e2"] +] + +------------------------------ + +Check numbers. diff --git a/tests/languages/io/operator_feature.test b/tests/languages/io/operator_feature.test new file mode 100644 index 0000000000..5378bc5254 --- /dev/null +++ b/tests/languages/io/operator_feature.test @@ -0,0 +1,26 @@ +::= := = +== != >= <= +&& and || or not +.. ++ - / * ** +%= &= *= += -= /= <<= >>= ^= |= +? ?? @ @@ +return + +------------------------------------------------------------------------------------------------------------------------- + +[ + ["operator", "::=" ] , ["operator", ":=" ] , ["operator", "=" ] , + ["operator", "==" ] , ["operator", "!=" ] , ["operator", ">=" ] , ["operator", "<=" ] , + ["operator", "&&" ] , ["operator", "and" ] , ["operator", "||" ] , ["operator", "or" ] , ["operator", "not" ] , + ["operator", ".." ] , + ["operator", "+" ] , ["operator", "-" ] , ["operator", "/" ] , ["operator", "*" ] , ["operator", "**" ] , + ["operator", "%=" ] , ["operator", "&=" ] , ["operator", "*=" ] , ["operator", "+=" ] , ["operator", "-=" ] , + ["operator", "/=" ] , ["operator", "<<=" ] , ["operator", ">>=" ] , ["operator", "^=" ] , ["operator", "|=" ] , + ["operator", "?" ] , ["operator", "??" ] , ["operator", "@" ] , ["operator", "@@" ] , + ["operator", "return" ] +] + +------------------------------------------------------------------------------------------------------------------------- + +Check operators. diff --git a/tests/languages/io/string_feature.test b/tests/languages/io/string_feature.test new file mode 100644 index 0000000000..5b4f003eb8 --- /dev/null +++ b/tests/languages/io/string_feature.test @@ -0,0 +1,18 @@ +"" +"""""" +"this is a \"test\".\nThis is only a test." +"""this is a "test". +This is only a test.""" + +------------------------------------------------------------------------- + +[ + ["string", "\"\""], + ["triple-quoted-string", "\"\"\"\"\"\""], + ["string", "\"this is a \\\"test\\\".\\nThis is only a test.\""], + ["triple-quoted-string", "\"\"\"this is a \"test\".\nThis is only a test.\"\"\""] +] + +------------------------------------------------------------------------- + +Check strings.