-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
1 parent
a9b6785
commit 84ed3ed
Showing
10 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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': /[{}[\];(),.:]/ | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |