oxygene.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. Language: Oxygene
  3. Author: Carlo Kok <ck@remobjects.com>
  4. Description: Oxygene is built on the foundation of Object Pascal, revamped and extended to be a modern language for the twenty-first century.
  5. Website: https://www.elementscompiler.com/elements/default.aspx
  6. */
  7. function oxygene(hljs) {
  8. const OXYGENE_KEYWORDS = {
  9. $pattern: /\.?\w+/,
  10. keyword:
  11. 'abstract add and array as asc aspect assembly async begin break block by case class concat const copy constructor continue ' +
  12. 'create default delegate desc distinct div do downto dynamic each else empty end ensure enum equals event except exit extension external false ' +
  13. 'final finalize finalizer finally flags for forward from function future global group has if implementation implements implies in index inherited ' +
  14. 'inline interface into invariants is iterator join locked locking loop matching method mod module namespace nested new nil not notify nullable of ' +
  15. 'old on operator or order out override parallel params partial pinned private procedure property protected public queryable raise read readonly ' +
  16. 'record reintroduce remove repeat require result reverse sealed select self sequence set shl shr skip static step soft take then to true try tuple ' +
  17. 'type union unit unsafe until uses using var virtual raises volatile where while with write xor yield await mapped deprecated stdcall cdecl pascal ' +
  18. 'register safecall overload library platform reference packed strict published autoreleasepool selector strong weak unretained'
  19. };
  20. const CURLY_COMMENT = hljs.COMMENT(
  21. /\{/,
  22. /\}/,
  23. {
  24. relevance: 0
  25. }
  26. );
  27. const PAREN_COMMENT = hljs.COMMENT(
  28. '\\(\\*',
  29. '\\*\\)',
  30. {
  31. relevance: 10
  32. }
  33. );
  34. const STRING = {
  35. className: 'string',
  36. begin: '\'',
  37. end: '\'',
  38. contains: [
  39. {
  40. begin: '\'\''
  41. }
  42. ]
  43. };
  44. const CHAR_STRING = {
  45. className: 'string',
  46. begin: '(#\\d+)+'
  47. };
  48. const FUNCTION = {
  49. className: 'function',
  50. beginKeywords: 'function constructor destructor procedure method',
  51. end: '[:;]',
  52. keywords: 'function constructor|10 destructor|10 procedure|10 method|10',
  53. contains: [
  54. hljs.TITLE_MODE,
  55. {
  56. className: 'params',
  57. begin: '\\(',
  58. end: '\\)',
  59. keywords: OXYGENE_KEYWORDS,
  60. contains: [
  61. STRING,
  62. CHAR_STRING
  63. ]
  64. },
  65. CURLY_COMMENT,
  66. PAREN_COMMENT
  67. ]
  68. };
  69. return {
  70. name: 'Oxygene',
  71. case_insensitive: true,
  72. keywords: OXYGENE_KEYWORDS,
  73. illegal: '("|\\$[G-Zg-z]|\\/\\*|</|=>|->)',
  74. contains: [
  75. CURLY_COMMENT,
  76. PAREN_COMMENT,
  77. hljs.C_LINE_COMMENT_MODE,
  78. STRING,
  79. CHAR_STRING,
  80. hljs.NUMBER_MODE,
  81. FUNCTION,
  82. {
  83. className: 'class',
  84. begin: '=\\bclass\\b',
  85. end: 'end;',
  86. keywords: OXYGENE_KEYWORDS,
  87. contains: [
  88. STRING,
  89. CHAR_STRING,
  90. CURLY_COMMENT,
  91. PAREN_COMMENT,
  92. hljs.C_LINE_COMMENT_MODE,
  93. FUNCTION
  94. ]
  95. }
  96. ]
  97. };
  98. }
  99. module.exports = oxygene;