lasso.js 5.0 KB

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