xl.js 2.3 KB

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