Skip to content

Commit fd1081d

Browse files
Added support for Squirrel (#2721)
1 parent 2b355c9 commit fd1081d

17 files changed

+514
-2
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

+5
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,11 @@
11261126
"title": "SQL",
11271127
"owner": "multipetros"
11281128
},
1129+
"squirrel": {
1130+
"title": "Squirrel",
1131+
"require": "clike",
1132+
"owner": "RunDevelopment"
1133+
},
11291134
"stan": {
11301135
"title": "Stan",
11311136
"owner": "RunDevelopment"

components/prism-squirrel.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Prism.languages.squirrel = Prism.languages.extend('clike', {
2+
'comment': [
3+
Prism.languages.clike['comment'][0],
4+
{
5+
pattern: /(^|[^\\:])(?:\/\/|#).*/,
6+
lookbehind: true,
7+
greedy: true
8+
}
9+
],
10+
'string': [
11+
{
12+
pattern: /(^|[^\\"'@])(?:@"(?:[^"]|"")*"(?!")|"(?:[^\\\r\n"]|\\.)*")/,
13+
lookbehind: true,
14+
greedy: true
15+
},
16+
{
17+
pattern: /(^|[^\\"'])'(?:[^\\']|\\(?:[xuU][0-9a-fA-F]{0,8}|[^]))'/,
18+
lookbehind: true,
19+
greedy: true
20+
}
21+
],
22+
23+
'class-name': {
24+
pattern: /(\b(?:class|enum|extends|instanceof)\s+)\w+(?:\.\w+)*/,
25+
lookbehind: true,
26+
inside: {
27+
'punctuation': /\./
28+
}
29+
},
30+
'keyword': /\b(?:base|break|case|catch|class|clone|const|constructor|continue|default|delete|else|enum|extends|for|foreach|function|if|in|instanceof|local|null|resume|return|static|switch|this|throw|try|typeof|while|yield|__LINE__|__FILE__)\b/,
31+
32+
'number': /\b(?:0x[0-9a-fA-F]+|\d+(?:\.(?:\d+|[eE][+-]?\d+))?)\b/,
33+
'operator': /\+\+|--|<=>|<[-<]|>>>?|&&?|\|\|?|[-+*/%!=<>]=?|[~^]|::?/,
34+
'punctuation': /[(){}\[\],;.]/
35+
});
36+
37+
Prism.languages.insertBefore('squirrel', 'operator', {
38+
'attribute-punctuation': {
39+
pattern: /<\/|\/>/,
40+
alias: 'important'
41+
},
42+
'lambda': {
43+
pattern: /@(?=\()/,
44+
alias: 'operator'
45+
}
46+
});

components/prism-squirrel.min.js

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

examples/prism-squirrel.html

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<h2>Full example</h2>
2+
<pre><code> // source: http://www.squirrel-lang.org/#look
3+
4+
local table = {
5+
a = "10"
6+
subtable = {
7+
array = [1,2,3]
8+
},
9+
[10 + 123] = "expression index"
10+
}
11+
12+
local array=[ 1, 2, 3, { a = 10, b = "string" } ];
13+
14+
foreach (i,val in array)
15+
{
16+
::print("the type of val is"+typeof val);
17+
}
18+
19+
/////////////////////////////////////////////
20+
21+
class Entity
22+
{
23+
constructor(etype,entityname)
24+
{
25+
name = entityname;
26+
type = etype;
27+
}
28+
29+
x = 0;
30+
y = 0;
31+
z = 0;
32+
name = null;
33+
type = null;
34+
}
35+
36+
function Entity::MoveTo(newx,newy,newz)
37+
{
38+
x = newx;
39+
y = newy;
40+
z = newz;
41+
}
42+
43+
class Player extends Entity {
44+
constructor(entityname)
45+
{
46+
base.constructor("Player",entityname)
47+
}
48+
function DoDomething()
49+
{
50+
::print("something");
51+
}
52+
53+
}
54+
55+
local newplayer = Player("da playar");
56+
57+
newplayer.MoveTo(100,200,300);</code></pre>

plugins/autoloader/prism-autoloader.js

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
"soy": "markup-templating",
129129
"sparql": "turtle",
130130
"sqf": "clike",
131+
"squirrel": "clike",
131132
"swift": "clike",
132133
"t4-cs": [
133134
"t4-templating",

plugins/autoloader/prism-autoloader.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
class Foo </ test = "I'm a class level attribute" />{
2+
</ test = "freakin attribute" /> //attributes of PrintTesty
3+
function PrintTesty()
4+
{
5+
foreach(i,val in testy)
6+
{
7+
::print("idx = "+i+" = "+val+" \n");
8+
}
9+
}
10+
</ flippy = 10 , second = [1,2,3] /> //attributes of testy
11+
testy = null;
12+
}
13+
14+
----------------------------------------------------
15+
16+
[
17+
["keyword", "class"],
18+
["class-name", ["Foo"]],
19+
["attribute-punctuation", "</"],
20+
" test ",
21+
["operator", "="],
22+
["string", "\"I'm a class level attribute\""],
23+
["attribute-punctuation", "/>"],
24+
["punctuation", "{"],
25+
26+
["attribute-punctuation", "</"],
27+
" test ",
28+
["operator", "="],
29+
["string", "\"freakin attribute\""],
30+
["attribute-punctuation", "/>"],
31+
["comment", "//attributes of PrintTesty"],
32+
33+
["keyword", "function"],
34+
["function", "PrintTesty"],
35+
["punctuation", "("],
36+
["punctuation", ")"],
37+
38+
["punctuation", "{"],
39+
40+
["keyword", "foreach"],
41+
["punctuation", "("],
42+
"i",
43+
["punctuation", ","],
44+
"val ",
45+
["keyword", "in"],
46+
" testy",
47+
["punctuation", ")"],
48+
49+
["punctuation", "{"],
50+
51+
["operator", "::"],
52+
["function", "print"],
53+
["punctuation", "("],
54+
["string", "\"idx = \""],
55+
["operator", "+"],
56+
"i",
57+
["operator", "+"],
58+
["string", "\" = \""],
59+
["operator", "+"],
60+
"val",
61+
["operator", "+"],
62+
["string", "\" \\n\""],
63+
["punctuation", ")"],
64+
["punctuation", ";"],
65+
66+
["punctuation", "}"],
67+
68+
["punctuation", "}"],
69+
70+
["attribute-punctuation", "</"],
71+
" flippy ",
72+
["operator", "="],
73+
["number", "10"],
74+
["punctuation", ","],
75+
" second ",
76+
["operator", "="],
77+
["punctuation", "["],
78+
["number", "1"],
79+
["punctuation", ","],
80+
["number", "2"],
81+
["punctuation", ","],
82+
["number", "3"],
83+
["punctuation", "]"],
84+
["attribute-punctuation", "/>"],
85+
["comment", "//attributes of testy"],
86+
87+
"\r\n testy ",
88+
["operator", "="],
89+
["keyword", "null"],
90+
["punctuation", ";"],
91+
92+
["punctuation", "}"]
93+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
false
2+
true
3+
4+
----------------------------------------------------
5+
6+
[
7+
["boolean", "false"],
8+
["boolean", "true"]
9+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
class Foo {}
2+
class FakeNamespace.Utils.SuperClass {}
3+
class SuperFoo extends Foo {}
4+
log(b instanceof Kid);
5+
enum Stuff {}
6+
7+
----------------------------------------------------
8+
9+
[
10+
["keyword", "class"],
11+
["class-name", ["Foo"]],
12+
["punctuation", "{"],
13+
["punctuation", "}"],
14+
15+
["keyword", "class"],
16+
["class-name", [
17+
"FakeNamespace",
18+
["punctuation", "."],
19+
"Utils",
20+
["punctuation", "."],
21+
"SuperClass"
22+
]],
23+
["punctuation", "{"],
24+
["punctuation", "}"],
25+
26+
["keyword", "class"],
27+
["class-name", ["SuperFoo"]],
28+
["keyword", "extends"],
29+
["class-name", ["Foo"]],
30+
["punctuation", "{"],
31+
["punctuation", "}"],
32+
33+
["function", "log"],
34+
["punctuation", "("],
35+
"b ",
36+
["keyword", "instanceof"],
37+
["class-name", ["Kid"]],
38+
["punctuation", ")"],
39+
["punctuation", ";"],
40+
41+
["keyword", "enum"],
42+
["class-name", ["Stuff"]],
43+
["punctuation", "{"],
44+
["punctuation", "}"]
45+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
this is
3+
a multiline comment.
4+
this lines will be ignored by the compiler
5+
*/
6+
//this is a single line comment. this line will be ignored by the compiler
7+
# this is also a single line comment.
8+
9+
----------------------------------------------------
10+
11+
[
12+
["comment", "/*\r\nthis is\r\na multiline comment.\r\nthis lines will be ignored by the compiler\r\n*/"],
13+
["comment", "//this is a single line comment. this line will be ignored by the compiler"],
14+
["comment", "# this is also a single line comment."]
15+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
function abc(a,b,c) {}
2+
function(a,b,c) {}
3+
local myexp = @(a,b) a + b;
4+
5+
----------------------------------------------------
6+
7+
[
8+
["keyword", "function"],
9+
["function", "abc"],
10+
["punctuation", "("],
11+
"a",
12+
["punctuation", ","],
13+
"b",
14+
["punctuation", ","],
15+
"c",
16+
["punctuation", ")"],
17+
["punctuation", "{"],
18+
["punctuation", "}"],
19+
20+
["keyword", "function"],
21+
["punctuation", "("],
22+
"a",
23+
["punctuation", ","],
24+
"b",
25+
["punctuation", ","],
26+
"c",
27+
["punctuation", ")"],
28+
["punctuation", "{"],
29+
["punctuation", "}"],
30+
31+
["keyword", "local"],
32+
" myexp ",
33+
["operator", "="],
34+
["lambda", "@"],
35+
["punctuation", "("],
36+
"a",
37+
["punctuation", ","],
38+
"b",
39+
["punctuation", ")"],
40+
" a ",
41+
["operator", "+"],
42+
" b",
43+
["punctuation", ";"]
44+
]

0 commit comments

Comments
 (0)