oxygene.js 2.9 KB

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