xl.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. Language: XL
  3. Author: Christophe de Dinechin <christophe@taodyne.com>
  4. Description: An extensible programming language, based on parse tree rewriting
  5. Website: http://xlr.sf.net
  6. */
  7. function xl(hljs) {
  8. const BUILTIN_MODULES =
  9. 'ObjectLoader Animate MovieCredits Slides Filters Shading Materials LensFlare Mapping VLCAudioVideo ' +
  10. 'StereoDecoder PointCloud NetworkAccess RemoteControl RegExp ChromaKey Snowfall NodeJS Speech Charts';
  11. const XL_KEYWORDS = {
  12. $pattern: /[a-zA-Z][a-zA-Z0-9_?]*/,
  13. keyword:
  14. 'if then else do while until for loop import with is as where when by data constant ' +
  15. 'integer real text name boolean symbol infix prefix postfix block tree',
  16. literal:
  17. 'true false nil',
  18. built_in:
  19. 'in mod rem and or xor not abs sign floor ceil sqrt sin cos tan asin ' +
  20. 'acos atan exp expm1 log log2 log10 log1p pi at text_length text_range ' +
  21. 'text_find text_replace contains page slide basic_slide title_slide ' +
  22. 'title subtitle fade_in fade_out fade_at clear_color color line_color ' +
  23. 'line_width texture_wrap texture_transform texture scale_?x scale_?y ' +
  24. 'scale_?z? translate_?x translate_?y translate_?z? rotate_?x rotate_?y ' +
  25. 'rotate_?z? rectangle circle ellipse sphere path line_to move_to ' +
  26. 'quad_to curve_to theme background contents locally time mouse_?x ' +
  27. 'mouse_?y mouse_buttons ' +
  28. BUILTIN_MODULES
  29. };
  30. const DOUBLE_QUOTE_TEXT = {
  31. className: 'string',
  32. begin: '"',
  33. end: '"',
  34. illegal: '\\n'
  35. };
  36. const SINGLE_QUOTE_TEXT = {
  37. className: 'string',
  38. begin: '\'',
  39. end: '\'',
  40. illegal: '\\n'
  41. };
  42. const LONG_TEXT = {
  43. className: 'string',
  44. begin: '<<',
  45. end: '>>'
  46. };
  47. const BASED_NUMBER = {
  48. className: 'number',
  49. begin: '[0-9]+#[0-9A-Z_]+(\\.[0-9-A-Z_]+)?#?([Ee][+-]?[0-9]+)?'
  50. };
  51. const IMPORT = {
  52. beginKeywords: 'import',
  53. end: '$',
  54. keywords: XL_KEYWORDS,
  55. contains: [ DOUBLE_QUOTE_TEXT ]
  56. };
  57. const FUNCTION_DEFINITION = {
  58. className: 'function',
  59. begin: /[a-z][^\n]*->/,
  60. returnBegin: true,
  61. end: /->/,
  62. contains: [
  63. hljs.inherit(hljs.TITLE_MODE, {
  64. starts: {
  65. endsWithParent: true,
  66. keywords: XL_KEYWORDS
  67. }
  68. })
  69. ]
  70. };
  71. return {
  72. name: 'XL',
  73. aliases: [ 'tao' ],
  74. keywords: XL_KEYWORDS,
  75. contains: [
  76. hljs.C_LINE_COMMENT_MODE,
  77. hljs.C_BLOCK_COMMENT_MODE,
  78. DOUBLE_QUOTE_TEXT,
  79. SINGLE_QUOTE_TEXT,
  80. LONG_TEXT,
  81. FUNCTION_DEFINITION,
  82. IMPORT,
  83. BASED_NUMBER,
  84. hljs.NUMBER_MODE
  85. ]
  86. };
  87. }
  88. module.exports = xl;