Added support for Squirrel (#2721)
This commit is contained in:
parent
2b355c9872
commit
fd1081d256
File diff suppressed because one or more lines are too long
|
@ -1126,6 +1126,11 @@
|
|||
"title": "SQL",
|
||||
"owner": "multipetros"
|
||||
},
|
||||
"squirrel": {
|
||||
"title": "Squirrel",
|
||||
"require": "clike",
|
||||
"owner": "RunDevelopment"
|
||||
},
|
||||
"stan": {
|
||||
"title": "Stan",
|
||||
"owner": "RunDevelopment"
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
Prism.languages.squirrel = Prism.languages.extend('clike', {
|
||||
'comment': [
|
||||
Prism.languages.clike['comment'][0],
|
||||
{
|
||||
pattern: /(^|[^\\:])(?:\/\/|#).*/,
|
||||
lookbehind: true,
|
||||
greedy: true
|
||||
}
|
||||
],
|
||||
'string': [
|
||||
{
|
||||
pattern: /(^|[^\\"'@])(?:@"(?:[^"]|"")*"(?!")|"(?:[^\\\r\n"]|\\.)*")/,
|
||||
lookbehind: true,
|
||||
greedy: true
|
||||
},
|
||||
{
|
||||
pattern: /(^|[^\\"'])'(?:[^\\']|\\(?:[xuU][0-9a-fA-F]{0,8}|[^]))'/,
|
||||
lookbehind: true,
|
||||
greedy: true
|
||||
}
|
||||
],
|
||||
|
||||
'class-name': {
|
||||
pattern: /(\b(?:class|enum|extends|instanceof)\s+)\w+(?:\.\w+)*/,
|
||||
lookbehind: true,
|
||||
inside: {
|
||||
'punctuation': /\./
|
||||
}
|
||||
},
|
||||
'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/,
|
||||
|
||||
'number': /\b(?:0x[0-9a-fA-F]+|\d+(?:\.(?:\d+|[eE][+-]?\d+))?)\b/,
|
||||
'operator': /\+\+|--|<=>|<[-<]|>>>?|&&?|\|\|?|[-+*/%!=<>]=?|[~^]|::?/,
|
||||
'punctuation': /[(){}\[\],;.]/
|
||||
});
|
||||
|
||||
Prism.languages.insertBefore('squirrel', 'operator', {
|
||||
'attribute-punctuation': {
|
||||
pattern: /<\/|\/>/,
|
||||
alias: 'important'
|
||||
},
|
||||
'lambda': {
|
||||
pattern: /@(?=\()/,
|
||||
alias: 'operator'
|
||||
}
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
Prism.languages.squirrel=Prism.languages.extend("clike",{comment:[Prism.languages.clike.comment[0],{pattern:/(^|[^\\:])(?:\/\/|#).*/,lookbehind:!0,greedy:!0}],string:[{pattern:/(^|[^\\"'@])(?:@"(?:[^"]|"")*"(?!")|"(?:[^\\\r\n"]|\\.)*")/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\"'])'(?:[^\\']|\\(?:[xuU][0-9a-fA-F]{0,8}|[^]))'/,lookbehind:!0,greedy:!0}],"class-name":{pattern:/(\b(?:class|enum|extends|instanceof)\s+)\w+(?:\.\w+)*/,lookbehind:!0,inside:{punctuation:/\./}},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/,number:/\b(?:0x[0-9a-fA-F]+|\d+(?:\.(?:\d+|[eE][+-]?\d+))?)\b/,operator:/\+\+|--|<=>|<[-<]|>>>?|&&?|\|\|?|[-+*/%!=<>]=?|[~^]|::?/,punctuation:/[(){}\[\],;.]/}),Prism.languages.insertBefore("squirrel","operator",{"attribute-punctuation":{pattern:/<\/|\/>/,alias:"important"},lambda:{pattern:/@(?=\()/,alias:"operator"}});
|
|
@ -0,0 +1,57 @@
|
|||
<h2>Full example</h2>
|
||||
<pre><code> // source: http://www.squirrel-lang.org/#look
|
||||
|
||||
local table = {
|
||||
a = "10"
|
||||
subtable = {
|
||||
array = [1,2,3]
|
||||
},
|
||||
[10 + 123] = "expression index"
|
||||
}
|
||||
|
||||
local array=[ 1, 2, 3, { a = 10, b = "string" } ];
|
||||
|
||||
foreach (i,val in array)
|
||||
{
|
||||
::print("the type of val is"+typeof val);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////
|
||||
|
||||
class Entity
|
||||
{
|
||||
constructor(etype,entityname)
|
||||
{
|
||||
name = entityname;
|
||||
type = etype;
|
||||
}
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
name = null;
|
||||
type = null;
|
||||
}
|
||||
|
||||
function Entity::MoveTo(newx,newy,newz)
|
||||
{
|
||||
x = newx;
|
||||
y = newy;
|
||||
z = newz;
|
||||
}
|
||||
|
||||
class Player extends Entity {
|
||||
constructor(entityname)
|
||||
{
|
||||
base.constructor("Player",entityname)
|
||||
}
|
||||
function DoDomething()
|
||||
{
|
||||
::print("something");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
local newplayer = Player("da playar");
|
||||
|
||||
newplayer.MoveTo(100,200,300);</code></pre>
|
|
@ -128,6 +128,7 @@
|
|||
"soy": "markup-templating",
|
||||
"sparql": "turtle",
|
||||
"sqf": "clike",
|
||||
"squirrel": "clike",
|
||||
"swift": "clike",
|
||||
"t4-cs": [
|
||||
"t4-templating",
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,93 @@
|
|||
class Foo </ test = "I'm a class level attribute" />{
|
||||
</ test = "freakin attribute" /> //attributes of PrintTesty
|
||||
function PrintTesty()
|
||||
{
|
||||
foreach(i,val in testy)
|
||||
{
|
||||
::print("idx = "+i+" = "+val+" \n");
|
||||
}
|
||||
}
|
||||
</ flippy = 10 , second = [1,2,3] /> //attributes of testy
|
||||
testy = null;
|
||||
}
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["keyword", "class"],
|
||||
["class-name", ["Foo"]],
|
||||
["attribute-punctuation", "</"],
|
||||
" test ",
|
||||
["operator", "="],
|
||||
["string", "\"I'm a class level attribute\""],
|
||||
["attribute-punctuation", "/>"],
|
||||
["punctuation", "{"],
|
||||
|
||||
["attribute-punctuation", "</"],
|
||||
" test ",
|
||||
["operator", "="],
|
||||
["string", "\"freakin attribute\""],
|
||||
["attribute-punctuation", "/>"],
|
||||
["comment", "//attributes of PrintTesty"],
|
||||
|
||||
["keyword", "function"],
|
||||
["function", "PrintTesty"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
|
||||
["punctuation", "{"],
|
||||
|
||||
["keyword", "foreach"],
|
||||
["punctuation", "("],
|
||||
"i",
|
||||
["punctuation", ","],
|
||||
"val ",
|
||||
["keyword", "in"],
|
||||
" testy",
|
||||
["punctuation", ")"],
|
||||
|
||||
["punctuation", "{"],
|
||||
|
||||
["operator", "::"],
|
||||
["function", "print"],
|
||||
["punctuation", "("],
|
||||
["string", "\"idx = \""],
|
||||
["operator", "+"],
|
||||
"i",
|
||||
["operator", "+"],
|
||||
["string", "\" = \""],
|
||||
["operator", "+"],
|
||||
"val",
|
||||
["operator", "+"],
|
||||
["string", "\" \\n\""],
|
||||
["punctuation", ")"],
|
||||
["punctuation", ";"],
|
||||
|
||||
["punctuation", "}"],
|
||||
|
||||
["punctuation", "}"],
|
||||
|
||||
["attribute-punctuation", "</"],
|
||||
" flippy ",
|
||||
["operator", "="],
|
||||
["number", "10"],
|
||||
["punctuation", ","],
|
||||
" second ",
|
||||
["operator", "="],
|
||||
["punctuation", "["],
|
||||
["number", "1"],
|
||||
["punctuation", ","],
|
||||
["number", "2"],
|
||||
["punctuation", ","],
|
||||
["number", "3"],
|
||||
["punctuation", "]"],
|
||||
["attribute-punctuation", "/>"],
|
||||
["comment", "//attributes of testy"],
|
||||
|
||||
"\r\n testy ",
|
||||
["operator", "="],
|
||||
["keyword", "null"],
|
||||
["punctuation", ";"],
|
||||
|
||||
["punctuation", "}"]
|
||||
]
|
|
@ -0,0 +1,9 @@
|
|||
false
|
||||
true
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["boolean", "false"],
|
||||
["boolean", "true"]
|
||||
]
|
|
@ -0,0 +1,45 @@
|
|||
class Foo {}
|
||||
class FakeNamespace.Utils.SuperClass {}
|
||||
class SuperFoo extends Foo {}
|
||||
log(b instanceof Kid);
|
||||
enum Stuff {}
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["keyword", "class"],
|
||||
["class-name", ["Foo"]],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
|
||||
["keyword", "class"],
|
||||
["class-name", [
|
||||
"FakeNamespace",
|
||||
["punctuation", "."],
|
||||
"Utils",
|
||||
["punctuation", "."],
|
||||
"SuperClass"
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
|
||||
["keyword", "class"],
|
||||
["class-name", ["SuperFoo"]],
|
||||
["keyword", "extends"],
|
||||
["class-name", ["Foo"]],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
|
||||
["function", "log"],
|
||||
["punctuation", "("],
|
||||
"b ",
|
||||
["keyword", "instanceof"],
|
||||
["class-name", ["Kid"]],
|
||||
["punctuation", ")"],
|
||||
["punctuation", ";"],
|
||||
|
||||
["keyword", "enum"],
|
||||
["class-name", ["Stuff"]],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"]
|
||||
]
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
this is
|
||||
a multiline comment.
|
||||
this lines will be ignored by the compiler
|
||||
*/
|
||||
//this is a single line comment. this line will be ignored by the compiler
|
||||
# this is also a single line comment.
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["comment", "/*\r\nthis is\r\na multiline comment.\r\nthis lines will be ignored by the compiler\r\n*/"],
|
||||
["comment", "//this is a single line comment. this line will be ignored by the compiler"],
|
||||
["comment", "# this is also a single line comment."]
|
||||
]
|
|
@ -0,0 +1,44 @@
|
|||
function abc(a,b,c) {}
|
||||
function(a,b,c) {}
|
||||
local myexp = @(a,b) a + b;
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["keyword", "function"],
|
||||
["function", "abc"],
|
||||
["punctuation", "("],
|
||||
"a",
|
||||
["punctuation", ","],
|
||||
"b",
|
||||
["punctuation", ","],
|
||||
"c",
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
|
||||
["keyword", "function"],
|
||||
["punctuation", "("],
|
||||
"a",
|
||||
["punctuation", ","],
|
||||
"b",
|
||||
["punctuation", ","],
|
||||
"c",
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
|
||||
["keyword", "local"],
|
||||
" myexp ",
|
||||
["operator", "="],
|
||||
["lambda", "@"],
|
||||
["punctuation", "("],
|
||||
"a",
|
||||
["punctuation", ","],
|
||||
"b",
|
||||
["punctuation", ")"],
|
||||
" a ",
|
||||
["operator", "+"],
|
||||
" b",
|
||||
["punctuation", ";"]
|
||||
]
|
|
@ -0,0 +1,75 @@
|
|||
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__
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["keyword", "base"], ["punctuation", ";"],
|
||||
["keyword", "break"], ["punctuation", ";"],
|
||||
["keyword", "case"], ["punctuation", ";"],
|
||||
["keyword", "catch"], ["punctuation", ";"],
|
||||
["keyword", "class"], ["punctuation", ";"],
|
||||
["keyword", "clone"], ["punctuation", ";"],
|
||||
["keyword", "const"], ["punctuation", ";"],
|
||||
["keyword", "constructor"], ["punctuation", ";"],
|
||||
["keyword", "continue"], ["punctuation", ";"],
|
||||
["keyword", "default"], ["punctuation", ";"],
|
||||
["keyword", "delete"], ["punctuation", ";"],
|
||||
["keyword", "else"], ["punctuation", ";"],
|
||||
["keyword", "enum"], ["punctuation", ";"],
|
||||
["keyword", "extends"], ["punctuation", ";"],
|
||||
["keyword", "for"], ["punctuation", ";"],
|
||||
["keyword", "foreach"], ["punctuation", ";"],
|
||||
["keyword", "function"], ["punctuation", ";"],
|
||||
["keyword", "if"], ["punctuation", ";"],
|
||||
["keyword", "in"], ["punctuation", ";"],
|
||||
["keyword", "instanceof"], ["punctuation", ";"],
|
||||
["keyword", "local"], ["punctuation", ";"],
|
||||
["keyword", "null"], ["punctuation", ";"],
|
||||
["keyword", "resume"], ["punctuation", ";"],
|
||||
["keyword", "return"], ["punctuation", ";"],
|
||||
["keyword", "static"], ["punctuation", ";"],
|
||||
["keyword", "switch"], ["punctuation", ";"],
|
||||
["keyword", "this"], ["punctuation", ";"],
|
||||
["keyword", "throw"], ["punctuation", ";"],
|
||||
["keyword", "try"], ["punctuation", ";"],
|
||||
["keyword", "typeof"], ["punctuation", ";"],
|
||||
["keyword", "while"], ["punctuation", ";"],
|
||||
["keyword", "yield"], ["punctuation", ";"],
|
||||
|
||||
["keyword", "__LINE__"],
|
||||
["keyword", "__FILE__"]
|
||||
]
|
|
@ -0,0 +1,21 @@
|
|||
0
|
||||
34
|
||||
0xFF00A120
|
||||
0753
|
||||
1.52
|
||||
0.234
|
||||
1.e2
|
||||
1.e-2
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["number", "0"],
|
||||
["number", "34"],
|
||||
["number", "0xFF00A120"],
|
||||
["number", "0753"],
|
||||
["number", "1.52"],
|
||||
["number", "0.234"],
|
||||
["number", "1.e2"],
|
||||
["number", "1.e-2"]
|
||||
]
|
|
@ -0,0 +1,46 @@
|
|||
! != || == && >= <= > <=>
|
||||
|
||||
+ - / * %
|
||||
+= -= /= *= %=
|
||||
++ --
|
||||
|
||||
<- =
|
||||
& ^ | ~
|
||||
>> << >>>
|
||||
|
||||
: ::
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["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", "::"]
|
||||
]
|
|
@ -0,0 +1,17 @@
|
|||
{ } [ ] ( )
|
||||
, ; .
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", "["],
|
||||
["punctuation", "]"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
|
||||
["punctuation", ","],
|
||||
["punctuation", ";"],
|
||||
["punctuation", "."]
|
||||
]
|
|
@ -0,0 +1,37 @@
|
|||
""
|
||||
"I'm a string"
|
||||
"I'm a wonderful string\n"
|
||||
|
||||
@""
|
||||
@"I'm a verbatim string"
|
||||
@" I'm a
|
||||
multiline verbatim string
|
||||
"
|
||||
|
||||
@"
|
||||
this is a multiline string
|
||||
it will ""embed"" all the new line
|
||||
characters
|
||||
"
|
||||
|
||||
'w'
|
||||
'\''
|
||||
'\x41' '\u0041' '\U00000041'
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["string", "\"\""],
|
||||
["string", "\"I'm a string\""],
|
||||
["string", "\"I'm a wonderful string\\n\""],
|
||||
|
||||
["string", "@\"\""],
|
||||
["string", "@\"I'm a verbatim string\""],
|
||||
["string", "@\" I'm a\r\nmultiline verbatim string\r\n\""],
|
||||
|
||||
["string", "@\"\r\n this is a multiline string\r\n it will \"\"embed\"\" all the new line\r\n characters\r\n\""],
|
||||
|
||||
["string", "'w'"],
|
||||
["string", "'\\''"],
|
||||
["string", "'\\x41'"], ["string", "'\\u0041'"], ["string", "'\\U00000041'"]
|
||||
]
|
Loading…
Reference in New Issue