add Io syntax (#1251) * add Io * Io: fix strings and operators, add tests * fix indent * add package-lock.json to gitignore * exclude gitignore and package.json changes * use tabs * io: apply requested changes * fix indent * fix indent * io: add example file
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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
diff --git a/.gitignore b/.gitignore
old mode 100644
new mode 100755
diff --git a/components.js b/components.js
index 3c7ea79..024b625 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 0000000..54a90a1
--- /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': /[=!*/%+-^&|]=|>>?=?|<<?=?|:?:?=|\+\+?|--?|\*\*?|\/\/?|%|\|\|?|&&?|(\b(?:return|and|or|not)\b)|@@?|\?\??|\.\./,
+ 'punctuation': /[{}[\];(),.:]/
+};
diff --git a/components/prism-io.min.js b/components/prism-io.min.js
new file mode 100644
index 0000000..ef921f0
--- /dev/null
+++ b/components/prism-io.min.js
@@ -0,0 +1 @@
+Prism.languages.io={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0},{pattern:/(^|[^\\:])#.*/,lookbehind:!0}],"triple-quoted-string":{pattern:/"""(?:\\.|(?!""")[^\\])*"""/,greedy:!0,alias:"string"},string:{pattern:/"(?:\\.|(?!")[^\\\r\n])*"/,greedy:!0},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:/==|\!=|\*=|\/=|%=|\+=|-=|\^=|>>?=?|<<?=?|&=|\|=|:?:?=|\+\+?|--?|\*\*?|\/\/?|%|\|\|?|&&?|return|and|or|not|@@?|\?\??|\.\./,punctuation:/[{}[\];(),.:]/};
\ No newline at end of file
diff --git a/examples/prism-io.html b/examples/prism-io.html
new file mode 100644
index 0000000..7397639
--- /dev/null
+++ b/examples/prism-io.html
@@ -0,0 +1,34 @@
+<h1>Io</h1>
+<p>To use this language, use the class "language-io".</p>
+
+<h2>Comments</h2>
+<pre><code>//
+// Foobar
+#!/usr/bin/env io
+/* multiline
+comment
+*/</code></pre>
+
+<h2>Strings</h2>
+<pre><code>"this is a \"test\".\nThis is only a test."
+"""this is a "test".
+This is only a test."""</code></pre>
+
+<h2>Numbers</h2>
+<pre><code>123
+123.456
+0.456
+123e-4
+123e4
+123.456e-7
+123.456e2
+</code></pre>
+
+<h2>Full example</h2>
+<pre><code>"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)
+)</code></pre>
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 0000000..fb67d07
--- /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 0000000..371be06
--- /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 0000000..5378bc5
--- /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 0000000..5b4f003
--- /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.