Added support for Odin (#3424)

Co-authored-by: Michael Schmidt <msrd0000@gmail.com>
Co-authored-by: edukisto <52005215+edukisto@users.noreply.github.com>
This commit is contained in:
Michael Schmidt 2022-04-05 18:26:45 +02:00 committed by GitHub
parent cb5229afc4
commit 8a3fef6dcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 1044 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@ -973,6 +973,10 @@
"title": "OCaml",
"owner": "Golmote"
},
"odin": {
"title": "Odin",
"owner": "edukisto"
},
"opencl": {
"title": "OpenCL",
"require": "c",

99
components/prism-odin.js Normal file
View File

@ -0,0 +1,99 @@
(function (Prism) {
var escapes = /\\(?:["'\\abefnrtv]|0[0-7]{2}|U[\dA-Fa-f]{6}|u[\dA-Fa-f]{4}|x[\dA-Fa-f]{2})/;
Prism.languages.odin = {
/**
* The current implementation supports only 1 level of nesting.
*
* @author Michael Schmidt
* @author edukisto
*/
'comment': [
{
pattern: /\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:\*(?!\/)|[^*])*(?:\*\/|$))*(?:\*\/|$)/,
greedy: true
},
{
pattern: /#![^\n\r]*/,
greedy: true
},
{
pattern: /\/\/[^\n\r]*/,
greedy: true
}
],
/**
* Should be found before strings because of '"'"- and '`'`-like sequences.
*/
'char': {
pattern: /'(?:\\(?:.|[0Uux][0-9A-Fa-f]{1,6})|[^\n\r'\\])'/,
greedy: true,
inside: {
'symbol': escapes
}
},
'string': [
{
pattern: /`[^`]*`/,
greedy: true
},
{
pattern: /"(?:\\.|[^\n\r"\\])*"/,
greedy: true,
inside: {
'symbol': escapes
}
}
],
'directive': {
pattern: /#\w+/,
alias: 'property'
},
'number': /\b0(?:b[01_]+|d[\d_]+|h_*(?:(?:(?:[\dA-Fa-f]_*){8}){1,2}|(?:[\dA-Fa-f]_*){4})|o[0-7_]+|x[\dA-F_a-f]+|z[\dAB_ab]+)\b|(?:\b\d+(?:\.(?!\.)\d*)?|\B\.\d+)(?:[Ee][+-]?\d*)?[ijk]?(?!\w)/,
'discard': {
pattern: /\b_\b/,
alias: 'keyword'
},
'procedure-definition': {
pattern: /\b\w+(?=[ \t]*(?::\s*){2}proc\b)/,
alias: 'function'
},
'keyword': /\b(?:asm|auto_cast|bit_set|break|case|cast|context|continue|defer|distinct|do|dynamic|else|enum|fallthrough|for|foreign|if|import|in|map|matrix|not_in|or_else|or_return|package|proc|return|struct|switch|transmute|typeid|union|using|when|where)\b/,
/**
* false, nil, true can be used as procedure names. "_" and keywords can't.
*/
'procedure-name': {
pattern: /\b\w+(?=[ \t]*\()/,
alias: 'function'
},
'boolean': /\b(?:false|nil|true)\b/,
'constant-parameter-sign': {
pattern: /\$/,
alias: 'important'
},
'undefined': {
pattern: /---/,
alias: 'operator'
},
'arrow': {
pattern: /->/,
alias: 'punctuation'
},
'operator': /\+\+|--|\.\.[<=]?|(?:&~|[-!*+/=~]|[%&<>|]{1,2})=?|[?^]/,
'punctuation': /[(),.:;@\[\]{}]/
};
}(Prism));

1
components/prism-odin.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){var t=/\\(?:["'\\abefnrtv]|0[0-7]{2}|U[\dA-Fa-f]{6}|u[\dA-Fa-f]{4}|x[\dA-Fa-f]{2})/;e.languages.odin={comment:[{pattern:/\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:\*(?!\/)|[^*])*(?:\*\/|$))*(?:\*\/|$)/,greedy:!0},{pattern:/#![^\n\r]*/,greedy:!0},{pattern:/\/\/[^\n\r]*/,greedy:!0}],char:{pattern:/'(?:\\(?:.|[0Uux][0-9A-Fa-f]{1,6})|[^\n\r'\\])'/,greedy:!0,inside:{symbol:t}},string:[{pattern:/`[^`]*`/,greedy:!0},{pattern:/"(?:\\.|[^\n\r"\\])*"/,greedy:!0,inside:{symbol:t}}],directive:{pattern:/#\w+/,alias:"property"},number:/\b0(?:b[01_]+|d[\d_]+|h_*(?:(?:(?:[\dA-Fa-f]_*){8}){1,2}|(?:[\dA-Fa-f]_*){4})|o[0-7_]+|x[\dA-F_a-f]+|z[\dAB_ab]+)\b|(?:\b\d+(?:\.(?!\.)\d*)?|\B\.\d+)(?:[Ee][+-]?\d*)?[ijk]?(?!\w)/,discard:{pattern:/\b_\b/,alias:"keyword"},"procedure-definition":{pattern:/\b\w+(?=[ \t]*(?::\s*){2}proc\b)/,alias:"function"},keyword:/\b(?:asm|auto_cast|bit_set|break|case|cast|context|continue|defer|distinct|do|dynamic|else|enum|fallthrough|for|foreign|if|import|in|map|matrix|not_in|or_else|or_return|package|proc|return|struct|switch|transmute|typeid|union|using|when|where)\b/,"procedure-name":{pattern:/\b\w+(?=[ \t]*\()/,alias:"function"},boolean:/\b(?:false|nil|true)\b/,"constant-parameter-sign":{pattern:/\$/,alias:"important"},undefined:{pattern:/---/,alias:"operator"},arrow:{pattern:/->/,alias:"punctuation"},operator:/\+\+|--|\.\.[<=]?|(?:&~|[-!*+/=~]|[%&<>|]{1,2})=?|[?^]/,punctuation:/[(),.:;@\[\]{}]/}}(Prism);

12
examples/prism-odin.html Normal file
View File

@ -0,0 +1,12 @@
<h2>Example</h2>
<pre><code>package main
import "core:fmt"
main :: proc() {
i: int
for i := 0; i &lt; 100; i += 1 {
fmt.println(i, " bottles of beer on the wall.\n")
}
}</code></pre>

View File

@ -0,0 +1,11 @@
false
nil
true
----------------------------------------------------
[
["boolean", "false"],
["boolean", "nil"],
["boolean", "true"]
]

View File

@ -0,0 +1,147 @@
' '
'!'
'"'
'0'
'\"'
'\''
'\000'
'\077'
'\U000000'
'\UFFFFFF'
'\Uffffff'
'\\'
'\a'
'\b'
'\e'
'\f'
'\n'
'\r'
'\t'
'\u0000'
'\uFFFF'
'\uffff'
'\v'
'\x00'
'\xFF'
'\xff'
'a'
----------------------------------------------------
[
["char", ["' '"]],
["char", ["'!'"]],
["char", ["'\"'"]],
["char", ["'0'"]],
["char", [
"'",
["symbol", "\\\""],
"'"
]],
["char", [
"'",
["symbol", "\\'"],
"'"
]],
["char", [
"'",
["symbol", "\\000"],
"'"
]],
["char", [
"'",
["symbol", "\\077"],
"'"
]],
["char", [
"'",
["symbol", "\\U000000"],
"'"
]],
["char", [
"'",
["symbol", "\\UFFFFFF"],
"'"
]],
["char", [
"'",
["symbol", "\\Uffffff"],
"'"
]],
["char", [
"'",
["symbol", "\\\\"],
"'"
]],
["char", [
"'",
["symbol", "\\a"],
"'"
]],
["char", [
"'",
["symbol", "\\b"],
"'"
]],
["char", [
"'",
["symbol", "\\e"],
"'"
]],
["char", [
"'",
["symbol", "\\f"],
"'"
]],
["char", [
"'",
["symbol", "\\n"],
"'"
]],
["char", [
"'",
["symbol", "\\r"],
"'"
]],
["char", [
"'",
["symbol", "\\t"],
"'"
]],
["char", [
"'",
["symbol", "\\u0000"],
"'"
]],
["char", [
"'",
["symbol", "\\uFFFF"],
"'"
]],
["char", [
"'",
["symbol", "\\uffff"],
"'"
]],
["char", [
"'",
["symbol", "\\v"],
"'"
]],
["char", [
"'",
["symbol", "\\x00"],
"'"
]],
["char", [
"'",
["symbol", "\\xFF"],
"'"
]],
["char", [
"'",
["symbol", "\\xff"],
"'"
]],
["char", ["'a'"]]
]

View File

@ -0,0 +1,92 @@
#!
#! A comment
#!!
#!""
#!#!
#!' '
#!/**/
#!//
#!0
#!``
#!false
#!if
/*
*/
/* 1 /* 2 */ 1 */
/* A comment */
/*!*/
/*""*/
/*"\a"*/
/*#!*/
/*' '*/
/*'\a'*/
/**/
/*/**/*/
/*0*/
/*`\a`*/
/*``*/
/*false*/
/*if*/
//
// A comment
//!
//""
//#!
//' '
///**/
////
//0
//``
//false
//if
Not a comment #! A comment
Not a comment /* A comment */
Not a comment // A comment
----------------------------------------------------
[
["comment", "#!"],
["comment", "#! A comment"],
["comment", "#!!"],
["comment", "#!\"\""],
["comment", "#!#!"],
["comment", "#!' '"],
["comment", "#!/**/"],
["comment", "#!//"],
["comment", "#!0"],
["comment", "#!``"],
["comment", "#!false"],
["comment", "#!if"],
["comment", "/*\r\n*/"],
["comment", "/* 1 /* 2 */ 1 */"],
["comment", "/* A comment */"],
["comment", "/*!*/"],
["comment", "/*\"\"*/"],
["comment", "/*\"\\a\"*/"],
["comment", "/*#!*/"],
["comment", "/*' '*/"],
["comment", "/*'\\a'*/"],
["comment", "/**/"],
["comment", "/*/**/*/"],
["comment", "/*0*/"],
["comment", "/*`\\a`*/"],
["comment", "/*``*/"],
["comment", "/*false*/"],
["comment", "/*if*/"],
["comment", "//"],
["comment", "// A comment"],
["comment", "//!"],
["comment", "//\"\""],
["comment", "//#!"],
["comment", "//' '"],
["comment", "///**/"],
["comment", "////"],
["comment", "//0"],
["comment", "//``"],
["comment", "//false"],
["comment", "//if"],
"\r\nNot a comment ", ["comment", "#! A comment"],
"\r\nNot a comment ", ["comment", "/* A comment */"],
"\r\nNot a comment ", ["comment", "// A comment"]
]

View File

@ -0,0 +1,7 @@
$
----------------------------------------------------
[
["constant-parameter-sign", "$"]
]

View File

@ -0,0 +1,9 @@
#assert
#no_bounds_check
----------------------------------------------------
[
["directive", "#assert"],
["directive", "#no_bounds_check"]
]

View File

@ -0,0 +1,7 @@
_
----------------------------------------------------
[
["discard", "_"]
]

View File

@ -0,0 +1,77 @@
asm
auto_cast
bit_set
break
case
cast
context
continue
defer
distinct
do
dynamic
else
enum
fallthrough
for
foreign
if
import
in
map
matrix
not_in
or_else
or_return
package
proc
return
struct
switch
transmute
typeid
union
using
when
where
----------------------------------------------------
[
["keyword", "asm"],
["keyword", "auto_cast"],
["keyword", "bit_set"],
["keyword", "break"],
["keyword", "case"],
["keyword", "cast"],
["keyword", "context"],
["keyword", "continue"],
["keyword", "defer"],
["keyword", "distinct"],
["keyword", "do"],
["keyword", "dynamic"],
["keyword", "else"],
["keyword", "enum"],
["keyword", "fallthrough"],
["keyword", "for"],
["keyword", "foreign"],
["keyword", "if"],
["keyword", "import"],
["keyword", "in"],
["keyword", "map"],
["keyword", "matrix"],
["keyword", "not_in"],
["keyword", "or_else"],
["keyword", "or_return"],
["keyword", "package"],
["keyword", "proc"],
["keyword", "return"],
["keyword", "struct"],
["keyword", "switch"],
["keyword", "transmute"],
["keyword", "typeid"],
["keyword", "union"],
["keyword", "using"],
["keyword", "when"],
["keyword", "where"]
]

View File

@ -0,0 +1,31 @@
0B0
0D0
0I
0O0
0Z0
0b
0b2
0d
0h
0h0
0h00
0h000
0h00000
0h0000000
0h000000000
0h000000000000000
0h00000000000000000
0h_
0o
0o8
0x
0X0
0xG
0z
0zC
----------------------------------------------------
[
"0B0\r\n0D0\r\n0I\r\n0O0\r\n0Z0\r\n0b\r\n0b2\r\n0d\r\n0h\r\n0h0\r\n0h00\r\n0h000\r\n0h00000\r\n0h0000000\r\n0h000000000\r\n0h000000000000000\r\n0h00000000000000000\r\n0h_\r\n0o\r\n0o8\r\n0x\r\n0X0\r\n0xG\r\n0z\r\n0zC"
]

View File

@ -0,0 +1,129 @@
.0
0
0.
0E
0b0
0b00
0b01
0b0_
0b_
0b_0
0b_1
0b__
0d0
0d00
0d01
0d0_
0d_
0d_0
0d_1
0d__
0e
0e+
0e+0
0e+0i
0e+i
0e-
0e-0
0e-0i
0e-i
0ei
0h0000
0h00000000
0h0000000000000000
0i
0o0
0o00
0o01
0o0_
0o_
0o_0
0o_1
0o__
0x0
0x00
0x0_
0x0F
0x0f
0x_
0x_0
0x__
0x_F
0x_f
0z0
0z00
0z0_
0z0B
0z0b
0z_
0z_0
0z__
0z_B
0z_b
----------------------------------------------------
[
["number", ".0"],
["number", "0"],
["number", "0."],
["number", "0E"],
["number", "0b0"],
["number", "0b00"],
["number", "0b01"],
["number", "0b0_"],
["number", "0b_"],
["number", "0b_0"],
["number", "0b_1"],
["number", "0b__"],
["number", "0d0"],
["number", "0d00"],
["number", "0d01"],
["number", "0d0_"],
["number", "0d_"],
["number", "0d_0"],
["number", "0d_1"],
["number", "0d__"],
["number", "0e"],
["number", "0e+"],
["number", "0e+0"],
["number", "0e+0i"],
["number", "0e+i"],
["number", "0e-"],
["number", "0e-0"],
["number", "0e-0i"],
["number", "0e-i"],
["number", "0ei"],
["number", "0h0000"],
["number", "0h00000000"],
["number", "0h0000000000000000"],
["number", "0i"],
["number", "0o0"],
["number", "0o00"],
["number", "0o01"],
["number", "0o0_"],
["number", "0o_"],
["number", "0o_0"],
["number", "0o_1"],
["number", "0o__"],
["number", "0x0"],
["number", "0x00"],
["number", "0x0_"],
["number", "0x0F"],
["number", "0x0f"],
["number", "0x_"],
["number", "0x_0"],
["number", "0x__"],
["number", "0x_F"],
["number", "0x_f"],
["number", "0z0"],
["number", "0z00"],
["number", "0z0_"],
["number", "0z0B"],
["number", "0z0b"],
["number", "0z_"],
["number", "0z_0"],
["number", "0z__"],
["number", "0z_B"],
["number", "0z_b"]
]

View File

@ -0,0 +1,97 @@
!
!=
%
%%
%%=
%=
&
&&
&&=
&=
&~
&~=
*
*=
+
++
+=
-
--
-=
..
..<
..=
/
/=
<
<<
<<=
<=
=
==
>
>=
>>
>>=
?
^
|
|=
||
||=
~
~=
// ranges
0..<10
----------------------------------------------------
[
["operator", "!"],
["operator", "!="],
["operator", "%"],
["operator", "%%"],
["operator", "%%="],
["operator", "%="],
["operator", "&"],
["operator", "&&"],
["operator", "&&="],
["operator", "&="],
["operator", "&~"],
["operator", "&~="],
["operator", "*"],
["operator", "*="],
["operator", "+"],
["operator", "++"],
["operator", "+="],
["operator", "-"],
["operator", "--"],
["operator", "-="],
["operator", ".."],
["operator", "..<"],
["operator", "..="],
["operator", "/"],
["operator", "/="],
["operator", "<"],
["operator", "<<"],
["operator", "<<="],
["operator", "<="],
["operator", "="],
["operator", "=="],
["operator", ">"],
["operator", ">="],
["operator", ">>"],
["operator", ">>="],
["operator", "?"],
["operator", "^"],
["operator", "|"],
["operator", "|="],
["operator", "||"],
["operator", "||="],
["operator", "~"],
["operator", "~="],
["comment", "// ranges"],
["number", "0"], ["operator", "..<"], ["number", "10"]
]

View File

@ -0,0 +1,27 @@
do_math()
fibonacci()
log10()
cross :: proc(a, b: Vector3) -> Vector3
----------------------------------------------------
[
["procedure-name", "do_math"], ["punctuation", "("], ["punctuation", ")"],
["procedure-name", "fibonacci"], ["punctuation", "("], ["punctuation", ")"],
["procedure-name", "log10"], ["punctuation", "("], ["punctuation", ")"],
["procedure-definition", "cross"],
["punctuation", ":"],
["punctuation", ":"],
["keyword", "proc"],
["punctuation", "("],
"a",
["punctuation", ","],
" b",
["punctuation", ":"],
" Vector3",
["punctuation", ")"],
["arrow", "->"],
" Vector3"
]

View File

@ -0,0 +1,29 @@
(
)
,
->
.
:
;
@
[
]
{
}
----------------------------------------------------
[
["punctuation", "("],
["punctuation", ")"],
["punctuation", ","],
["arrow", "->"],
["punctuation", "."],
["punctuation", ":"],
["punctuation", ";"],
["punctuation", "@"],
["punctuation", "["],
["punctuation", "]"],
["punctuation", "{"],
["punctuation", "}"]
]

View File

@ -0,0 +1,79 @@
`
`
`!`
`""`
`"\a"`
`' '`
`'\a'`
`/**/`
`//`
`0`
`\
`
`\"`
`\'`
`\000`
`\077`
`\U000000`
`\UFFFFFF`
`\Uffffff`
`\\`
`\a`
`\b`
`\e`
`\f`
`\n`
`\r`
`\t`
`\u0000`
`\uFFFF`
`\uffff`
`\v`
`\x00`
`\xFF`
`\xff`
`A raw string.`
``
`false`
`if`
----------------------------------------------------
[
["string", "`\r\n`"],
["string", "`!`"],
["string", "`\"\"`"],
["string", "`\"\\a\"`"],
["string", "`' '`"],
["string", "`'\\a'`"],
["string", "`/**/`"],
["string", "`//`"],
["string", "`0`"],
["string", "`\\\r\n`"],
["string", "`\\\"`"],
["string", "`\\'`"],
["string", "`\\000`"],
["string", "`\\077`"],
["string", "`\\U000000`"],
["string", "`\\UFFFFFF`"],
["string", "`\\Uffffff`"],
["string", "`\\\\`"],
["string", "`\\a`"],
["string", "`\\b`"],
["string", "`\\e`"],
["string", "`\\f`"],
["string", "`\\n`"],
["string", "`\\r`"],
["string", "`\\t`"],
["string", "`\\u0000`"],
["string", "`\\uFFFF`"],
["string", "`\\uffff`"],
["string", "`\\v`"],
["string", "`\\x00`"],
["string", "`\\xFF`"],
["string", "`\\xff`"],
["string", "`A raw string.`"],
["string", "``"],
["string", "`false`"],
["string", "`if`"]
]

View File

@ -0,0 +1,178 @@
"!"
""
"' '"
"'\a'"
"/**/"
"//"
"0"
"\""
"\'"
"\000"
"\077"
"\U000000"
"\UFFFFFF"
"\Uffffff"
"\\"
"\a"
"\b"
"\e"
"\f"
"\n"
"\r"
"\t"
"\u0000"
"\uFFFF"
"\uffff"
"\v"
"\x00"
"\xFF"
"\xff"
"Not
a
string"
"Not\
a\
string"
"String"
"String" Not a string"
"`\a`"
"``"
"false"
"if"
----------------------------------------------------
[
["string", ["\"!\""]],
["string", ["\"\""]],
["string", ["\"' '\""]],
["string", [
"\"'",
["symbol", "\\a"],
"'\""
]],
["string", ["\"/**/\""]],
["string", ["\"//\""]],
["string", ["\"0\""]],
["string", [
"\"",
["symbol", "\\\""],
"\""
]],
["string", [
"\"",
["symbol", "\\'"],
"\""
]],
["string", [
"\"",
["symbol", "\\000"],
"\""
]],
["string", [
"\"",
["symbol", "\\077"],
"\""
]],
["string", [
"\"",
["symbol", "\\U000000"],
"\""
]],
["string", [
"\"",
["symbol", "\\UFFFFFF"],
"\""
]],
["string", [
"\"",
["symbol", "\\Uffffff"],
"\""
]],
["string", [
"\"",
["symbol", "\\\\"],
"\""
]],
["string", [
"\"",
["symbol", "\\a"],
"\""
]],
["string", [
"\"",
["symbol", "\\b"],
"\""
]],
["string", [
"\"",
["symbol", "\\e"],
"\""
]],
["string", [
"\"",
["symbol", "\\f"],
"\""
]],
["string", [
"\"",
["symbol", "\\n"],
"\""
]],
["string", [
"\"",
["symbol", "\\r"],
"\""
]],
["string", [
"\"",
["symbol", "\\t"],
"\""
]],
["string", [
"\"",
["symbol", "\\u0000"],
"\""
]],
["string", [
"\"",
["symbol", "\\uFFFF"],
"\""
]],
["string", [
"\"",
["symbol", "\\uffff"],
"\""
]],
["string", [
"\"",
["symbol", "\\v"],
"\""
]],
["string", [
"\"",
["symbol", "\\x00"],
"\""
]],
["string", [
"\"",
["symbol", "\\xFF"],
"\""
]],
["string", [
"\"",
["symbol", "\\xff"],
"\""
]],
"\r\n\"Not\r\na\r\nstring\"\r\n\"Not\\\r\na\\\r\nstring\"\r\n",
["string", ["\"String\""]],
["string", ["\"String\""]], " Not a string\"\r\n",
["string", [
"\"`",
["symbol", "\\a"],
"`\""
]],
["string", ["\"``\""]],
["string", ["\"false\""]],
["string", ["\"if\""]]
]

View File

@ -0,0 +1,7 @@
---
----------------------------------------------------
[
["undefined", "---"]
]