xl.js 2.4 KB

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