crystal.min.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*! `crystal` grammar compiled for Highlight.js 11.7.0 */
  2. (()=>{var e=(()=>{"use strict";return e=>{
  3. const n="(_?[ui](8|16|32|64|128))?",i="[a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|[=!]~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~|]|//|//=|&[-+*]=?|&\\*\\*|\\[\\][=?]?",s="[A-Za-z_]\\w*(::\\w+)*(\\?|!)?",a={
  4. $pattern:"[a-zA-Z_]\\w*[!?=]?",
  5. keyword:"abstract alias annotation as as? asm begin break case class def do else elsif end ensure enum extend for fun if include instance_sizeof is_a? lib macro module next nil? of out pointerof private protected rescue responds_to? return require select self sizeof struct super then type typeof union uninitialized unless until verbatim when while with yield __DIR__ __END_LINE__ __FILE__ __LINE__",
  6. literal:"false nil true"},t={className:"subst",begin:/#\{/,end:/\}/,keywords:a
  7. },c={className:"template-variable",variants:[{begin:"\\{\\{",end:"\\}\\}"},{
  8. begin:"\\{%",end:"%\\}"}],keywords:a};function r(e,n){const i=[{begin:e,end:n}]
  9. ;return i[0].contains=i,i}const l={className:"string",
  10. contains:[e.BACKSLASH_ESCAPE,t],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/
  11. },{begin:/`/,end:/`/},{begin:"%[Qwi]?\\(",end:"\\)",contains:r("\\(","\\)")},{
  12. begin:"%[Qwi]?\\[",end:"\\]",contains:r("\\[","\\]")},{begin:"%[Qwi]?\\{",
  13. end:/\}/,contains:r(/\{/,/\}/)},{begin:"%[Qwi]?<",end:">",contains:r("<",">")},{
  14. begin:"%[Qwi]?\\|",end:"\\|"},{begin:/<<-\w+$/,end:/^\s*\w+$/}],relevance:0},b={
  15. className:"string",variants:[{begin:"%q\\(",end:"\\)",contains:r("\\(","\\)")},{
  16. begin:"%q\\[",end:"\\]",contains:r("\\[","\\]")},{begin:"%q\\{",end:/\}/,
  17. contains:r(/\{/,/\}/)},{begin:"%q<",end:">",contains:r("<",">")},{begin:"%q\\|",
  18. end:"\\|"},{begin:/<<-'\w+'$/,end:/^\s*\w+$/}],relevance:0},o={
  19. begin:"(?!%\\})("+e.RE_STARTERS_RE+"|\\n|\\b(case|if|select|unless|until|when|while)\\b)\\s*",
  20. keywords:"case if select unless until when while",contains:[{className:"regexp",
  21. contains:[e.BACKSLASH_ESCAPE,t],variants:[{begin:"//[a-z]*",relevance:0},{
  22. begin:"/(?!\\/)",end:"/[a-z]*"}]}],relevance:0},g=[c,l,b,{className:"regexp",
  23. contains:[e.BACKSLASH_ESCAPE,t],variants:[{begin:"%r\\(",end:"\\)",
  24. contains:r("\\(","\\)")},{begin:"%r\\[",end:"\\]",contains:r("\\[","\\]")},{
  25. begin:"%r\\{",end:/\}/,contains:r(/\{/,/\}/)},{begin:"%r<",end:">",
  26. contains:r("<",">")},{begin:"%r\\|",end:"\\|"}],relevance:0},o,{
  27. className:"meta",begin:"@\\[",end:"\\]",
  28. contains:[e.inherit(e.QUOTE_STRING_MODE,{className:"string"})]},{
  29. className:"variable",
  30. begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"
  31. },e.HASH_COMMENT_MODE,{className:"class",beginKeywords:"class module struct",
  32. end:"$|;",illegal:/=/,contains:[e.HASH_COMMENT_MODE,e.inherit(e.TITLE_MODE,{
  33. begin:s}),{begin:"<"}]},{className:"class",beginKeywords:"lib enum union",
  34. end:"$|;",illegal:/=/,contains:[e.HASH_COMMENT_MODE,e.inherit(e.TITLE_MODE,{
  35. begin:s})]},{beginKeywords:"annotation",end:"$|;",illegal:/=/,
  36. contains:[e.HASH_COMMENT_MODE,e.inherit(e.TITLE_MODE,{begin:s})],relevance:2},{
  37. className:"function",beginKeywords:"def",end:/\B\b/,
  38. contains:[e.inherit(e.TITLE_MODE,{begin:i,endsParent:!0})]},{
  39. className:"function",beginKeywords:"fun macro",end:/\B\b/,
  40. contains:[e.inherit(e.TITLE_MODE,{begin:i,endsParent:!0})],relevance:2},{
  41. className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{
  42. className:"symbol",begin:":",contains:[l,{begin:i}],relevance:0},{
  43. className:"number",variants:[{begin:"\\b0b([01_]+)"+n},{begin:"\\b0o([0-7_]+)"+n
  44. },{begin:"\\b0x([A-Fa-f0-9_]+)"+n},{
  45. begin:"\\b([1-9][0-9_]*[0-9]|[0-9])(\\.[0-9][0-9_]*)?([eE]_?[-+]?[0-9_]*)?(_?f(32|64))?(?!_)"
  46. },{begin:"\\b([1-9][0-9_]*|0)"+n}],relevance:0}]
  47. ;return t.contains=g,c.contains=g.slice(1),{name:"Crystal",aliases:["cr"],
  48. keywords:a,contains:g}}})();hljs.registerLanguage("crystal",e)})();