Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Io syntax #1251

Merged
merged 10 commits into from
Jan 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .gitignore
100644 → 100755
Empty file.
4 changes: 4 additions & 0 deletions components.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ var components = {
"title": "Ini",
"owner": "aviaryan"
},
"io": {
"title": "Io",
"owner": "AlesTsurko"
},
"j": {
"title": "J",
"owner": "Golmote"
Expand Down
31 changes: 31 additions & 0 deletions components/prism-io.js
Original file line number Diff line number Diff line change
@@ -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': /[{}[\];(),.:]/
};
1 change: 1 addition & 0 deletions components/prism-io.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions examples/prism-io.html
Original file line number Diff line number Diff line change
@@ -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>
Empty file modified package.json
100644 → 100755
Empty file.
19 changes: 19 additions & 0 deletions tests/languages/io/comment_feature.test
Original file line number Diff line number Diff line change
@@ -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.
23 changes: 23 additions & 0 deletions tests/languages/io/number_feature.test
Original file line number Diff line number Diff line change
@@ -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.
26 changes: 26 additions & 0 deletions tests/languages/io/operator_feature.test
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 18 additions & 0 deletions tests/languages/io/string_feature.test
Original file line number Diff line number Diff line change
@@ -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.