zephir.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. Language: Zephir
  3. Author: Oleg Efimov <[email protected]>
  4. */
  5. function(hljs) {
  6. var STRING = {
  7. className: 'string',
  8. contains: [hljs.BACKSLASH_ESCAPE],
  9. variants: [
  10. {
  11. begin: 'b"', end: '"'
  12. },
  13. {
  14. begin: 'b\'', end: '\''
  15. },
  16. hljs.inherit(hljs.APOS_STRING_MODE, {illegal: null}),
  17. hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null})
  18. ]
  19. };
  20. var NUMBER = {variants: [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE]};
  21. return {
  22. aliases: ['zep'],
  23. case_insensitive: true,
  24. keywords:
  25. 'and include_once list abstract global private echo interface as static endswitch ' +
  26. 'array null if endwhile or const for endforeach self var let while isset public ' +
  27. 'protected exit foreach throw elseif include __FILE__ empty require_once do xor ' +
  28. 'return parent clone use __CLASS__ __LINE__ else break print eval new ' +
  29. 'catch __METHOD__ case exception default die require __FUNCTION__ ' +
  30. 'enddeclare final try switch continue endfor endif declare unset true false ' +
  31. 'trait goto instanceof insteadof __DIR__ __NAMESPACE__ ' +
  32. 'yield finally int uint long ulong char uchar double float bool boolean string' +
  33. 'likely unlikely',
  34. contains: [
  35. hljs.C_LINE_COMMENT_MODE,
  36. hljs.HASH_COMMENT_MODE,
  37. hljs.COMMENT(
  38. '/\\*',
  39. '\\*/',
  40. {
  41. contains: [
  42. {
  43. className: 'doctag',
  44. begin: '@[A-Za-z]+'
  45. }
  46. ]
  47. }
  48. ),
  49. hljs.COMMENT(
  50. '__halt_compiler.+?;',
  51. false,
  52. {
  53. endsWithParent: true,
  54. keywords: '__halt_compiler',
  55. lexemes: hljs.UNDERSCORE_IDENT_RE
  56. }
  57. ),
  58. {
  59. className: 'string',
  60. begin: '<<<[\'"]?\\w+[\'"]?$', end: '^\\w+;',
  61. contains: [hljs.BACKSLASH_ESCAPE]
  62. },
  63. {
  64. // swallow composed identifiers to avoid parsing them as keywords
  65. begin: /(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/
  66. },
  67. {
  68. className: 'function',
  69. beginKeywords: 'function', end: /[;{]/, excludeEnd: true,
  70. illegal: '\\$|\\[|%',
  71. contains: [
  72. hljs.UNDERSCORE_TITLE_MODE,
  73. {
  74. className: 'params',
  75. begin: '\\(', end: '\\)',
  76. contains: [
  77. 'self',
  78. hljs.C_BLOCK_COMMENT_MODE,
  79. STRING,
  80. NUMBER
  81. ]
  82. }
  83. ]
  84. },
  85. {
  86. className: 'class',
  87. beginKeywords: 'class interface', end: '{', excludeEnd: true,
  88. illegal: /[:\(\$"]/,
  89. contains: [
  90. {beginKeywords: 'extends implements'},
  91. hljs.UNDERSCORE_TITLE_MODE
  92. ]
  93. },
  94. {
  95. beginKeywords: 'namespace', end: ';',
  96. illegal: /[\.']/,
  97. contains: [hljs.UNDERSCORE_TITLE_MODE]
  98. },
  99. {
  100. beginKeywords: 'use', end: ';',
  101. contains: [hljs.UNDERSCORE_TITLE_MODE]
  102. },
  103. {
  104. begin: '=>' // No markup, just a relevance booster
  105. },
  106. STRING,
  107. NUMBER
  108. ]
  109. };
  110. }