lasso.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. module.exports = function(hljs) {
  2. var LASSO_IDENT_RE = '[a-zA-Z_][\\w.]*';
  3. var LASSO_ANGLE_RE = '<\\?(lasso(script)?|=)';
  4. var LASSO_CLOSE_RE = '\\]|\\?>';
  5. var LASSO_KEYWORDS = {
  6. literal:
  7. 'true false none minimal full all void and or not ' +
  8. 'bw nbw ew new cn ncn lt lte gt gte eq neq rx nrx ft',
  9. built_in:
  10. 'array date decimal duration integer map pair string tag xml null ' +
  11. 'boolean bytes keyword list locale queue set stack staticarray ' +
  12. 'local var variable global data self inherited currentcapture givenblock',
  13. keyword:
  14. 'cache database_names database_schemanames database_tablenames ' +
  15. 'define_tag define_type email_batch encode_set html_comment handle ' +
  16. 'handle_error header if inline iterate ljax_target link ' +
  17. 'link_currentaction link_currentgroup link_currentrecord link_detail ' +
  18. 'link_firstgroup link_firstrecord link_lastgroup link_lastrecord ' +
  19. 'link_nextgroup link_nextrecord link_prevgroup link_prevrecord log ' +
  20. 'loop namespace_using output_none portal private protect records ' +
  21. 'referer referrer repeating resultset rows search_args ' +
  22. 'search_arguments select sort_args sort_arguments thread_atomic ' +
  23. 'value_list while abort case else fail_if fail_ifnot fail if_empty ' +
  24. 'if_false if_null if_true loop_abort loop_continue loop_count params ' +
  25. 'params_up return return_value run_children soap_definetag ' +
  26. 'soap_lastrequest soap_lastresponse tag_name ascending average by ' +
  27. 'define descending do equals frozen group handle_failure import in ' +
  28. 'into join let match max min on order parent protected provide public ' +
  29. 'require returnhome skip split_thread sum take thread to trait type ' +
  30. 'where with yield yieldhome'
  31. };
  32. var HTML_COMMENT = hljs.COMMENT(
  33. '<!--',
  34. '-->',
  35. {
  36. relevance: 0
  37. }
  38. );
  39. var LASSO_NOPROCESS = {
  40. className: 'meta',
  41. begin: '\\[noprocess\\]',
  42. starts: {
  43. end: '\\[/noprocess\\]',
  44. returnEnd: true,
  45. contains: [HTML_COMMENT]
  46. }
  47. };
  48. var LASSO_START = {
  49. className: 'meta',
  50. begin: '\\[/noprocess|' + LASSO_ANGLE_RE
  51. };
  52. var LASSO_DATAMEMBER = {
  53. className: 'symbol',
  54. begin: '\'' + LASSO_IDENT_RE + '\''
  55. };
  56. var LASSO_CODE = [
  57. hljs.C_LINE_COMMENT_MODE,
  58. hljs.C_BLOCK_COMMENT_MODE,
  59. hljs.inherit(hljs.C_NUMBER_MODE, {begin: hljs.C_NUMBER_RE + '|(-?infinity|NaN)\\b'}),
  60. hljs.inherit(hljs.APOS_STRING_MODE, {illegal: null}),
  61. hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null}),
  62. {
  63. className: 'string',
  64. begin: '`', end: '`'
  65. },
  66. { // variables
  67. variants: [
  68. {
  69. begin: '[#$]' + LASSO_IDENT_RE
  70. },
  71. {
  72. begin: '#', end: '\\d+',
  73. illegal: '\\W'
  74. }
  75. ]
  76. },
  77. {
  78. className: 'type',
  79. begin: '::\\s*', end: LASSO_IDENT_RE,
  80. illegal: '\\W'
  81. },
  82. {
  83. className: 'params',
  84. variants: [
  85. {
  86. begin: '-(?!infinity)' + LASSO_IDENT_RE,
  87. relevance: 0
  88. },
  89. {
  90. begin: '(\\.\\.\\.)'
  91. }
  92. ]
  93. },
  94. {
  95. begin: /(->|\.)\s*/,
  96. relevance: 0,
  97. contains: [LASSO_DATAMEMBER]
  98. },
  99. {
  100. className: 'class',
  101. beginKeywords: 'define',
  102. returnEnd: true, end: '\\(|=>',
  103. contains: [
  104. hljs.inherit(hljs.TITLE_MODE, {begin: LASSO_IDENT_RE + '(=(?!>))?|[-+*/%](?!>)'})
  105. ]
  106. }
  107. ];
  108. return {
  109. aliases: ['ls', 'lassoscript'],
  110. case_insensitive: true,
  111. lexemes: LASSO_IDENT_RE + '|&[lg]t;',
  112. keywords: LASSO_KEYWORDS,
  113. contains: [
  114. {
  115. className: 'meta',
  116. begin: LASSO_CLOSE_RE,
  117. relevance: 0,
  118. starts: { // markup
  119. end: '\\[|' + LASSO_ANGLE_RE,
  120. returnEnd: true,
  121. relevance: 0,
  122. contains: [HTML_COMMENT]
  123. }
  124. },
  125. LASSO_NOPROCESS,
  126. LASSO_START,
  127. {
  128. className: 'meta',
  129. begin: '\\[no_square_brackets',
  130. starts: {
  131. end: '\\[/no_square_brackets\\]', // not implemented in the language
  132. lexemes: LASSO_IDENT_RE + '|&[lg]t;',
  133. keywords: LASSO_KEYWORDS,
  134. contains: [
  135. {
  136. className: 'meta',
  137. begin: LASSO_CLOSE_RE,
  138. relevance: 0,
  139. starts: {
  140. end: '\\[noprocess\\]|' + LASSO_ANGLE_RE,
  141. returnEnd: true,
  142. contains: [HTML_COMMENT]
  143. }
  144. },
  145. LASSO_NOPROCESS,
  146. LASSO_START
  147. ].concat(LASSO_CODE)
  148. }
  149. },
  150. {
  151. className: 'meta',
  152. begin: '\\[',
  153. relevance: 0
  154. },
  155. {
  156. className: 'meta',
  157. begin: '^#!', end:'lasso9$',
  158. relevance: 10
  159. }
  160. ].concat(LASSO_CODE)
  161. };
  162. };