Skip to content

Commit 8a3fef6

Browse files
RunDevelopmentedukisto
andauthoredApr 5, 2022
Added support for Odin (#3424)
Co-authored-by: Michael Schmidt <msrd0000@gmail.com> Co-authored-by: edukisto <52005215+edukisto@users.noreply.github.com>
1 parent cb5229a commit 8a3fef6

20 files changed

+1044
-1
lines changed
 

‎components.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎components.json

+4
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,10 @@
973973
"title": "OCaml",
974974
"owner": "Golmote"
975975
},
976+
"odin": {
977+
"title": "Odin",
978+
"owner": "edukisto"
979+
},
976980
"opencl": {
977981
"title": "OpenCL",
978982
"require": "c",

‎components/prism-odin.js

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
(function (Prism) {
2+
var escapes = /\\(?:["'\\abefnrtv]|0[0-7]{2}|U[\dA-Fa-f]{6}|u[\dA-Fa-f]{4}|x[\dA-Fa-f]{2})/;
3+
4+
Prism.languages.odin = {
5+
/**
6+
* The current implementation supports only 1 level of nesting.
7+
*
8+
* @author Michael Schmidt
9+
* @author edukisto
10+
*/
11+
'comment': [
12+
{
13+
pattern: /\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:\*(?!\/)|[^*])*(?:\*\/|$))*(?:\*\/|$)/,
14+
greedy: true
15+
},
16+
{
17+
pattern: /#![^\n\r]*/,
18+
greedy: true
19+
},
20+
{
21+
pattern: /\/\/[^\n\r]*/,
22+
greedy: true
23+
}
24+
],
25+
26+
/**
27+
* Should be found before strings because of '"'"- and '`'`-like sequences.
28+
*/
29+
'char': {
30+
pattern: /'(?:\\(?:.|[0Uux][0-9A-Fa-f]{1,6})|[^\n\r'\\])'/,
31+
greedy: true,
32+
inside: {
33+
'symbol': escapes
34+
}
35+
},
36+
37+
'string': [
38+
{
39+
pattern: /`[^`]*`/,
40+
greedy: true
41+
},
42+
{
43+
pattern: /"(?:\\.|[^\n\r"\\])*"/,
44+
greedy: true,
45+
inside: {
46+
'symbol': escapes
47+
}
48+
}
49+
],
50+
51+
'directive': {
52+
pattern: /#\w+/,
53+
alias: 'property'
54+
},
55+
56+
'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)/,
57+
58+
'discard': {
59+
pattern: /\b_\b/,
60+
alias: 'keyword'
61+
},
62+
63+
'procedure-definition': {
64+
pattern: /\b\w+(?=[ \t]*(?::\s*){2}proc\b)/,
65+
alias: 'function'
66+
},
67+
68+
'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/,
69+
70+
/**
71+
* false, nil, true can be used as procedure names. "_" and keywords can't.
72+
*/
73+
'procedure-name': {
74+
pattern: /\b\w+(?=[ \t]*\()/,
75+
alias: 'function'
76+
},
77+
78+
'boolean': /\b(?:false|nil|true)\b/,
79+
80+
'constant-parameter-sign': {
81+
pattern: /\$/,
82+
alias: 'important'
83+
},
84+
85+
'undefined': {
86+
pattern: /---/,
87+
alias: 'operator'
88+
},
89+
90+
'arrow': {
91+
pattern: /->/,
92+
alias: 'punctuation'
93+
},
94+
95+
'operator': /\+\+|--|\.\.[<=]?|(?:&~|[-!*+/=~]|[%&<>|]{1,2})=?|[?^]/,
96+
97+
'punctuation': /[(),.:;@\[\]{}]/
98+
};
99+
}(Prism));

‎components/prism-odin.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/prism-odin.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<h2>Example</h2>
2+
3+
<pre><code>package main
4+
5+
import "core:fmt"
6+
7+
main :: proc() {
8+
i: int
9+
for i := 0; i &lt; 100; i += 1 {
10+
fmt.println(i, " bottles of beer on the wall.\n")
11+
}
12+
}</code></pre>
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
false
2+
nil
3+
true
4+
5+
----------------------------------------------------
6+
7+
[
8+
["boolean", "false"],
9+
["boolean", "nil"],
10+
["boolean", "true"]
11+
]
+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
' '
2+
'!'
3+
'"'
4+
'0'
5+
'\"'
6+
'\''
7+
'\000'
8+
'\077'
9+
'\U000000'
10+
'\UFFFFFF'
11+
'\Uffffff'
12+
'\\'
13+
'\a'
14+
'\b'
15+
'\e'
16+
'\f'
17+
'\n'
18+
'\r'
19+
'\t'
20+
'\u0000'
21+
'\uFFFF'
22+
'\uffff'
23+
'\v'
24+
'\x00'
25+
'\xFF'
26+
'\xff'
27+
'a'
28+
29+
----------------------------------------------------
30+
31+
[
32+
["char", ["' '"]],
33+
["char", ["'!'"]],
34+
["char", ["'\"'"]],
35+
["char", ["'0'"]],
36+
["char", [
37+
"'",
38+
["symbol", "\\\""],
39+
"'"
40+
]],
41+
["char", [
42+
"'",
43+
["symbol", "\\'"],
44+
"'"
45+
]],
46+
["char", [
47+
"'",
48+
["symbol", "\\000"],
49+
"'"
50+
]],
51+
["char", [
52+
"'",
53+
["symbol", "\\077"],
54+
"'"
55+
]],
56+
["char", [
57+
"'",
58+
["symbol", "\\U000000"],
59+
"'"
60+
]],
61+
["char", [
62+
"'",
63+
["symbol", "\\UFFFFFF"],
64+
"'"
65+
]],
66+
["char", [
67+
"'",
68+
["symbol", "\\Uffffff"],
69+
"'"
70+
]],
71+
["char", [
72+
"'",
73+
["symbol", "\\\\"],
74+
"'"
75+
]],
76+
["char", [
77+
"'",
78+
["symbol", "\\a"],
79+
"'"
80+
]],
81+
["char", [
82+
"'",
83+
["symbol", "\\b"],
84+
"'"
85+
]],
86+
["char", [
87+
"'",
88+
["symbol", "\\e"],
89+
"'"
90+
]],
91+
["char", [
92+
"'",
93+
["symbol", "\\f"],
94+
"'"
95+
]],
96+
["char", [
97+
"'",
98+
["symbol", "\\n"],
99+
"'"
100+
]],
101+
["char", [
102+
"'",
103+
["symbol", "\\r"],
104+
"'"
105+
]],
106+
["char", [
107+
"'",
108+
["symbol", "\\t"],
109+
"'"
110+
]],
111+
["char", [
112+
"'",
113+
["symbol", "\\u0000"],
114+
"'"
115+
]],
116+
["char", [
117+
"'",
118+
["symbol", "\\uFFFF"],
119+
"'"
120+
]],
121+
["char", [
122+
"'",
123+
["symbol", "\\uffff"],
124+
"'"
125+
]],
126+
["char", [
127+
"'",
128+
["symbol", "\\v"],
129+
"'"
130+
]],
131+
["char", [
132+
"'",
133+
["symbol", "\\x00"],
134+
"'"
135+
]],
136+
["char", [
137+
"'",
138+
["symbol", "\\xFF"],
139+
"'"
140+
]],
141+
["char", [
142+
"'",
143+
["symbol", "\\xff"],
144+
"'"
145+
]],
146+
["char", ["'a'"]]
147+
]
+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!
2+
#! A comment
3+
#!!
4+
#!""
5+
#!#!
6+
#!' '
7+
#!/**/
8+
#!//
9+
#!0
10+
#!``
11+
#!false
12+
#!if
13+
/*
14+
*/
15+
/* 1 /* 2 */ 1 */
16+
/* A comment */
17+
/*!*/
18+
/*""*/
19+
/*"\a"*/
20+
/*#!*/
21+
/*' '*/
22+
/*'\a'*/
23+
/**/
24+
/*/**/*/
25+
/*0*/
26+
/*`\a`*/
27+
/*``*/
28+
/*false*/
29+
/*if*/
30+
//
31+
// A comment
32+
//!
33+
//""
34+
//#!
35+
//' '
36+
///**/
37+
////
38+
//0
39+
//``
40+
//false
41+
//if
42+
Not a comment #! A comment
43+
Not a comment /* A comment */
44+
Not a comment // A comment
45+
46+
----------------------------------------------------
47+
48+
[
49+
["comment", "#!"],
50+
["comment", "#! A comment"],
51+
["comment", "#!!"],
52+
["comment", "#!\"\""],
53+
["comment", "#!#!"],
54+
["comment", "#!' '"],
55+
["comment", "#!/**/"],
56+
["comment", "#!//"],
57+
["comment", "#!0"],
58+
["comment", "#!``"],
59+
["comment", "#!false"],
60+
["comment", "#!if"],
61+
["comment", "/*\r\n*/"],
62+
["comment", "/* 1 /* 2 */ 1 */"],
63+
["comment", "/* A comment */"],
64+
["comment", "/*!*/"],
65+
["comment", "/*\"\"*/"],
66+
["comment", "/*\"\\a\"*/"],
67+
["comment", "/*#!*/"],
68+
["comment", "/*' '*/"],
69+
["comment", "/*'\\a'*/"],
70+
["comment", "/**/"],
71+
["comment", "/*/**/*/"],
72+
["comment", "/*0*/"],
73+
["comment", "/*`\\a`*/"],
74+
["comment", "/*``*/"],
75+
["comment", "/*false*/"],
76+
["comment", "/*if*/"],
77+
["comment", "//"],
78+
["comment", "// A comment"],
79+
["comment", "//!"],
80+
["comment", "//\"\""],
81+
["comment", "//#!"],
82+
["comment", "//' '"],
83+
["comment", "///**/"],
84+
["comment", "////"],
85+
["comment", "//0"],
86+
["comment", "//``"],
87+
["comment", "//false"],
88+
["comment", "//if"],
89+
"\r\nNot a comment ", ["comment", "#! A comment"],
90+
"\r\nNot a comment ", ["comment", "/* A comment */"],
91+
"\r\nNot a comment ", ["comment", "// A comment"]
92+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
$
2+
3+
----------------------------------------------------
4+
5+
[
6+
["constant-parameter-sign", "$"]
7+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#assert
2+
#no_bounds_check
3+
4+
----------------------------------------------------
5+
6+
[
7+
["directive", "#assert"],
8+
["directive", "#no_bounds_check"]
9+
]

0 commit comments

Comments
 (0)
Please sign in to comment.