Skip to content

Commit b48c012

Browse files
luaVolkRunDevelopment
authored andcommitted
Added Vala language (#1658)
Adds support for the Vala language.
1 parent 6e250a5 commit b48c012

13 files changed

+518
-3
lines changed

components.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,11 @@
755755
"alias": "ts",
756756
"owner": "vkbansal"
757757
},
758+
"vala": {
759+
"title": "Vala",
760+
"require": "clike",
761+
"owner": "TemplarVolk"
762+
},
758763
"vbnet": {
759764
"title": "VB.Net",
760765
"require": "basic",

components/prism-vala.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
Prism.languages.vala = Prism.languages.extend('clike', {
2+
// Classes copied from prism-csharp
3+
'class-name': [
4+
{
5+
// (Foo bar, Bar baz)
6+
pattern: /\b[A-Z]\w*(?:\.\w+)*\b(?=(?:\?\s+|\*?\s+\*?)\w+)/,
7+
inside: {
8+
punctuation: /\./
9+
}
10+
},
11+
{
12+
// [Foo]
13+
pattern: /(\[)[A-Z]\w*(?:\.\w+)*\b/,
14+
lookbehind: true,
15+
inside: {
16+
punctuation: /\./
17+
}
18+
},
19+
{
20+
// class Foo : Bar
21+
pattern: /(\b(?:class|interface)\s+[A-Z]\w*(?:\.\w+)*\s*:\s*)[A-Z]\w*(?:\.\w+)*\b/,
22+
lookbehind: true,
23+
inside: {
24+
punctuation: /\./
25+
}
26+
},
27+
{
28+
// class Foo
29+
pattern: /((?:\b(?:class|interface|new|struct|enum)\s+)|(?:catch\s+\())[A-Z]\w*(?:\.\w+)*\b/,
30+
lookbehind: true,
31+
inside: {
32+
punctuation: /\./
33+
}
34+
}
35+
],
36+
'constant': /\b[A-Z0-9_]+\b/,
37+
'function': /\w+(?=\s*\()/,
38+
'keyword': /\b(?:bool|char|double|float|null|size_t|ssize_t|string|unichar|void|int|int8|int16|int32|int64|long|short|uchar|uint|uint8|uint16|uint32|uint64|ulong|ushort|class|delegate|enum|errordomain|interface|namespace|struct|break|continue|do|for|foreach|return|while|else|if|switch|assert|case|default|abstract|const|dynamic|ensures|extern|inline|internal|override|private|protected|public|requires|signal|static|virtual|volatile|weak|async|owned|unowned|try|catch|finally|throw|as|base|construct|delete|get|in|is|lock|new|out|params|ref|sizeof|set|this|throws|typeof|using|value|var|yield)\b/i,
39+
'number': /(?:\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)(?:f|u?l?)?/i,
40+
'operator': /\+\+|--|&&|\|\||<<=?|>>=?|=>|->|~|[+\-*\/%&^|=!<>]=?|\?\??|\.\.\./,
41+
'punctuation': /[{}[\];(),.:]/
42+
});
43+
44+
Prism.languages.insertBefore('vala','string', {
45+
'raw-string': {
46+
pattern: /"""[\s\S]*?"""/,
47+
greedy: true,
48+
alias: 'string'
49+
},
50+
'template-string': {
51+
pattern: /@"[\s\S]*?"/,
52+
greedy: true,
53+
inside: {
54+
'interpolation': {
55+
pattern: /\$(?:\([^)]*\)|[a-zA-Z]\w*)/,
56+
inside: {
57+
'delimiter': {
58+
pattern: /^\$\(?|\)$/,
59+
alias: 'punctuation'
60+
},
61+
rest: Prism.languages.vala
62+
}
63+
},
64+
'string': /[\s\S]+/
65+
}
66+
}
67+
});
68+
69+
Prism.languages.insertBefore('vala', 'keyword', {
70+
'regex': {
71+
pattern: /\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[imsx]{0,4}(?=\s*($|[\r\n,.;})\]]))/,
72+
greedy: true
73+
}
74+
});

components/prism-vala.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-vala.html

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<h2>Comments</h2>
2+
<pre><code">// Single line comment
3+
/** Multi-line
4+
doc comment */</code></pre>
5+
6+
<h2>Strings</h2>
7+
<pre><code">"foo \"bar\" baz"
8+
"Multi-line strings ending with a \
9+
are supported too."
10+
"""Verbatim strings
11+
You can create
12+
multi-line strings like this too."""
13+
@"Template string with variables $var1 $(var2 * 2)"</code></pre>
14+
15+
<h2>Regex</h2>
16+
<pre><code">/foo?[ ]*bar/</code></pre>
17+
18+
<h2>Full example</h2>
19+
<pre><code">using Gtk;
20+
21+
int main (string[] args) {
22+
Gtk.init(ref args);
23+
24+
var window = new Window();
25+
26+
var button = new Button.with_label("Click me!");
27+
28+
window.add(button);
29+
window.show_all();
30+
31+
Gtk.main();
32+
return 0;
33+
}</code></pre>

plugins/autoloader/prism-autoloader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
}
55

66
// The dependencies map is built automatically with gulp
7-
var lang_dependencies = /*languages_placeholder[*/{"javascript":"clike","actionscript":"javascript","arduino":"cpp","aspnet":["markup","csharp"],"bison":"c","c":"clike","csharp":"clike","cpp":"c","coffeescript":"javascript","crystal":"ruby","css-extras":"css","d":"clike","dart":"clike","django":"markup","erb":["ruby","markup-templating"],"fsharp":"clike","flow":"javascript","glsl":"clike","gml":"clike","go":"clike","groovy":"clike","haml":"ruby","handlebars":"markup-templating","haxe":"clike","java":"clike","jolie":"clike","kotlin":"clike","less":"css","markdown":"markup","markup-templating":"markup","n4js":"javascript","nginx":"clike","objectivec":"c","opencl":"cpp","parser":"markup","php":["clike","markup-templating"],"php-extras":"php","plsql":"sql","processing":"clike","protobuf":"clike","pug":"javascript","qore":"clike","jsx":["markup","javascript"],"tsx":["jsx","typescript"],"reason":"clike","ruby":"clike","sass":"css","scss":"css","scala":"java","smarty":"markup-templating","soy":"markup-templating","swift":"clike","tap":"yaml","textile":"markup","tt2":["clike","markup-templating"],"twig":"markup","typescript":"javascript","vbnet":"basic","velocity":"markup","wiki":"markup","xeora":"markup","xquery":"markup"}/*]*/;
7+
var lang_dependencies = /*languages_placeholder[*/{"javascript":"clike","actionscript":"javascript","arduino":"cpp","aspnet":["markup","csharp"],"bison":"c","c":"clike","csharp":"clike","cpp":"c","coffeescript":"javascript","crystal":"ruby","css-extras":"css","d":"clike","dart":"clike","django":"markup","erb":["ruby","markup-templating"],"fsharp":"clike","flow":"javascript","glsl":"clike","gml":"clike","go":"clike","groovy":"clike","haml":"ruby","handlebars":"markup-templating","haxe":"clike","java":"clike","jolie":"clike","kotlin":"clike","less":"css","markdown":"markup","markup-templating":"markup","n4js":"javascript","nginx":"clike","objectivec":"c","opencl":"cpp","parser":"markup","php":["clike","markup-templating"],"php-extras":"php","plsql":"sql","processing":"clike","protobuf":"clike","pug":"javascript","qore":"clike","jsx":["markup","javascript"],"tsx":["jsx","typescript"],"reason":"clike","ruby":"clike","sass":"css","scss":"css","scala":"java","smarty":"markup-templating","soy":"markup-templating","swift":"clike","tap":"yaml","textile":"markup","tt2":["clike","markup-templating"],"twig":"markup","typescript":"javascript","vala":"clike","vbnet":"basic","velocity":"markup","wiki":"markup","xeora":"markup","xquery":"markup"}/*]*/;
88

99
var lang_data = {};
1010

plugins/autoloader/prism-autoloader.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
class Foo
2+
enum Bar
3+
interface BarBaz
4+
class Foo : Bar
5+
[Foobar]
6+
void Foo(Bar bar, Baz baz)
7+
8+
----------------------------------------------------
9+
10+
[
11+
["keyword", "class"],
12+
["class-name", ["Foo"]],
13+
["keyword", "enum"],
14+
["class-name", ["Bar"]],
15+
["keyword", "interface"],
16+
["class-name", ["BarBaz"]],
17+
["keyword", "class"],
18+
["class-name", ["Foo"]],
19+
["punctuation", ":"],
20+
["class-name", ["Bar"]],
21+
["punctuation", "["],
22+
["class-name", ["Foobar"]],
23+
["punctuation", "]"],
24+
["keyword", "void"],
25+
["function", "Foo"],
26+
["punctuation", "("],
27+
["class-name", ["Bar"]],
28+
" bar",
29+
["punctuation", ","],
30+
["class-name", ["Baz"]],
31+
" baz",
32+
["punctuation", ")"]
33+
]
34+
35+
----------------------------------------------------
36+
37+
Checks for class names.
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
bool
2+
char
3+
double
4+
float
5+
null
6+
size_t
7+
ssize_t
8+
string
9+
unichar
10+
void
11+
int
12+
int8
13+
int16
14+
int32
15+
int64
16+
long
17+
short
18+
uchar
19+
uint
20+
uint8
21+
uint16
22+
uint32
23+
uint64
24+
ulong
25+
ushort
26+
class
27+
delegate
28+
enum
29+
errordomain
30+
interface
31+
namespace
32+
struct
33+
break
34+
continue
35+
do
36+
for
37+
foreach
38+
return
39+
while
40+
else
41+
if
42+
switch
43+
assert
44+
case
45+
default
46+
abstract
47+
const
48+
dynamic
49+
ensures
50+
extern
51+
inline
52+
internal
53+
override
54+
private
55+
protected
56+
public
57+
requires
58+
signal
59+
static
60+
virtual
61+
volatile
62+
weak
63+
async
64+
owned
65+
unowned
66+
try
67+
catch
68+
finally
69+
throw
70+
as
71+
base
72+
construct
73+
delete
74+
get
75+
in
76+
is
77+
lock
78+
new
79+
out
80+
params
81+
ref
82+
sizeof
83+
set
84+
this
85+
throws
86+
typeof
87+
using
88+
value
89+
var
90+
yield
91+
92+
----------------------------------------------------
93+
94+
[
95+
["keyword", "bool"],
96+
["keyword", "char"],
97+
["keyword", "double"],
98+
["keyword", "float"],
99+
["keyword", "null"],
100+
["keyword", "size_t"],
101+
["keyword", "ssize_t"],
102+
["keyword", "string"],
103+
["keyword", "unichar"],
104+
["keyword", "void"],
105+
["keyword", "int"],
106+
["keyword", "int8"],
107+
["keyword", "int16"],
108+
["keyword", "int32"],
109+
["keyword", "int64"],
110+
["keyword", "long"],
111+
["keyword", "short"],
112+
["keyword", "uchar"],
113+
["keyword", "uint"],
114+
["keyword", "uint8"],
115+
["keyword", "uint16"],
116+
["keyword", "uint32"],
117+
["keyword", "uint64"],
118+
["keyword", "ulong"],
119+
["keyword", "ushort"],
120+
["keyword", "class"],
121+
["keyword", "delegate"],
122+
["keyword", "enum"],
123+
["keyword", "errordomain"],
124+
["keyword", "interface"],
125+
["keyword", "namespace"],
126+
["keyword", "struct"],
127+
["keyword", "break"],
128+
["keyword", "continue"],
129+
["keyword", "do"],
130+
["keyword", "for"],
131+
["keyword", "foreach"],
132+
["keyword", "return"],
133+
["keyword", "while"],
134+
["keyword", "else"],
135+
["keyword", "if"],
136+
["keyword", "switch"],
137+
["keyword", "assert"],
138+
["keyword", "case"],
139+
["keyword", "default"],
140+
["keyword", "abstract"],
141+
["keyword", "const"],
142+
["keyword", "dynamic"],
143+
["keyword", "ensures"],
144+
["keyword", "extern"],
145+
["keyword", "inline"],
146+
["keyword", "internal"],
147+
["keyword", "override"],
148+
["keyword", "private"],
149+
["keyword", "protected"],
150+
["keyword", "public"],
151+
["keyword", "requires"],
152+
["keyword", "signal"],
153+
["keyword", "static"],
154+
["keyword", "virtual"],
155+
["keyword", "volatile"],
156+
["keyword", "weak"],
157+
["keyword", "async"],
158+
["keyword", "owned"],
159+
["keyword", "unowned"],
160+
["keyword", "try"],
161+
["keyword", "catch"],
162+
["keyword", "finally"],
163+
["keyword", "throw"],
164+
["keyword", "as"],
165+
["keyword", "base"],
166+
["keyword", "construct"],
167+
["keyword", "delete"],
168+
["keyword", "get"],
169+
["keyword", "in"],
170+
["keyword", "is"],
171+
["keyword", "lock"],
172+
["keyword", "new"],
173+
["keyword", "out"],
174+
["keyword", "params"],
175+
["keyword", "ref"],
176+
["keyword", "sizeof"],
177+
["keyword", "set"],
178+
["keyword", "this"],
179+
["keyword", "throws"],
180+
["keyword", "typeof"],
181+
["keyword", "using"],
182+
["keyword", "value"],
183+
["keyword", "var"],
184+
["keyword", "yield"]
185+
]
186+
187+
----------------------------------------------------
188+
189+
Checks for all keywords.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
42
2+
3.14159
3+
5ul
4+
0.75f
5+
4e10
6+
2.1e-10
7+
0.4e+2
8+
0xbabe
9+
0xBABE
10+
11+
----------------------------------------------------
12+
13+
[
14+
["number", "42"],
15+
["number", "3.14159"],
16+
["number", "5ul"],
17+
["number", "0.75f"],
18+
["number", "4e10"],
19+
["number", "2.1e-10"],
20+
["number", "0.4e+2"],
21+
["number", "0xbabe"],
22+
["number", "0xBABE"]
23+
]
24+
25+
----------------------------------------------------
26+
27+
Checks for decimal numbers and hexadecimal numbers.

0 commit comments

Comments
 (0)