UNPKG

2.51 kBJavaScriptView Raw
1hljs.registerLanguage("wren",(()=>{"use strict";function e(e){
2return e?"string"==typeof e?e:e.source:null}function s(...s){
3return s.map((s=>e(s))).join("")}function a(...s){return"("+((e=>{
4const s=e[e.length-1]
5;return"object"==typeof s&&s.constructor===Object?(e.splice(e.length-1,1),s):{}
6})(s).capture?"":"?:")+s.map((s=>e(s))).join("|")+")"}return e=>{
7const n=/[a-zA-Z]\w*/,t=["as","break","class","construct","continue","else","for","foreign","if","import","in","is","return","static","var","while"],c=["true","false","null"],r=["this","super"],i=["-","~",/\*/,"%",/\.\.\./,/\.\./,/\+/,"<<",">>",">=","<=","<",">",/\^/,/!=/,/!/,/\bis\b/,"==","&&","&",/\|\|/,/\|/,/\?:/,"="],o={
8relevance:0,match:s(/\b(?!(if|while|for|else|super)\b)/,n,/(?=\s*[({])/),
9className:"title.function"},l={
10match:s(a(s(/\b(?!(if|while|for|else|super)\b)/,n),a(...i)),/(?=\s*\([^)]+\)\s*\{)/),
11className:"title.function",starts:{contains:[{begin:/\(/,end:/\)/,contains:[{
12relevance:0,scope:"params",match:n}]}]}},u={variants:[{
13match:[/class\s+/,n,/\s+is\s+/,n]},{match:[/class\s+/,n]}],scope:{
142:"title.class",4:"title.class.inherited"},keywords:t},m={relevance:0,
15match:a(...i),className:"operator"},p={className:"property",
16begin:s(/\./,(b=n,s("(?=",b,")"))),end:n,excludeBegin:!0,relevance:0};var b
17;const h={relevance:0,match:s(/\b_/,n),scope:"variable"},g={relevance:0,
18match:/[A-Z]+[a-z]+([A-Z]+[a-z]+)*/,scope:"title.class",keywords:{
19_:["Bool","Class","Fiber","Fn","List","Map","Null","Num","Object","Range","Sequence","String","System"]
20}},f=e.C_NUMBER_MODE,v={match:[n,/\s*/,/=/,/\s*/,/\(/,n,/\)\s*\{/],scope:{
211:"title.function",3:"operator",6:"params"}},d=e.COMMENT(/\/\*\*/,/\*\//,{
22contains:[{match:/@[a-z]+/,scope:"doctag"},"self"]}),N={scope:"subst",
23begin:/%\(/,end:/\)/,contains:[f,g,o,h,m]},_={scope:"string",begin:/"/,end:/"/,
24contains:[N,{scope:"char.escape",variants:[{match:/\\\\|\\["0%abefnrtv]/},{
25match:/\\x[0-9A-F]{2}/},{match:/\\u[0-9A-F]{4}/},{match:/\\U[0-9A-F]{8}/}]}]}
26;N.contains.push(_);const w={relevance:0,
27match:s("\\b(?!",[...t,...r,...c].join("|"),"\\b)",/[a-zA-Z_]\w*(?:[?!]|\b)/),
28className:"variable"};return{name:"Wren",keywords:{keyword:t,
29"variable.language":r,literal:c},contains:[{scope:"comment",variants:[{
30begin:[/#!?/,/[A-Za-z_]+(?=\()/],beginScope:{},keywords:{literal:c},contains:[],
31end:/\)/},{begin:[/#!?/,/[A-Za-z_]+/],beginScope:{},end:/$/}]},f,_,{
32className:"string",begin:/"""/,end:/"""/
33},d,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,g,u,v,l,o,m,h,p,w]}}})());
\No newline at end of file