oxygene.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. { relevance: 0 }
  24. );
  25. const PAREN_COMMENT = hljs.COMMENT(
  26. '\\(\\*',
  27. '\\*\\)',
  28. { relevance: 10 }
  29. );
  30. const STRING = {
  31. className: 'string',
  32. begin: '\'',
  33. end: '\'',
  34. contains: [ { begin: '\'\'' } ]
  35. };
  36. const CHAR_STRING = {
  37. className: 'string',
  38. begin: '(#\\d+)+'
  39. };
  40. const FUNCTION = {
  41. beginKeywords: 'function constructor destructor procedure method',
  42. end: '[:;]',
  43. keywords: 'function constructor|10 destructor|10 procedure|10 method|10',
  44. contains: [
  45. hljs.inherit(hljs.TITLE_MODE, { scope: "title.function" }),
  46. {
  47. className: 'params',
  48. begin: '\\(',
  49. end: '\\)',
  50. keywords: OXYGENE_KEYWORDS,
  51. contains: [
  52. STRING,
  53. CHAR_STRING
  54. ]
  55. },
  56. CURLY_COMMENT,
  57. PAREN_COMMENT
  58. ]
  59. };
  60. const SEMICOLON = {
  61. scope: "punctuation",
  62. match: /;/,
  63. relevance: 0
  64. };
  65. return {
  66. name: 'Oxygene',
  67. case_insensitive: true,
  68. keywords: OXYGENE_KEYWORDS,
  69. illegal: '("|\\$[G-Zg-z]|\\/\\*|</|=>|->)',
  70. contains: [
  71. CURLY_COMMENT,
  72. PAREN_COMMENT,
  73. hljs.C_LINE_COMMENT_MODE,
  74. STRING,
  75. CHAR_STRING,
  76. hljs.NUMBER_MODE,
  77. FUNCTION,
  78. SEMICOLON
  79. ]
  80. };
  81. }
  82. module.exports = oxygene;