lasso.js 5.1 KB

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