l0bsterssg

node.js static responsive blog post generator
Log | Files | Refs | README

lasso.js (5115B)


      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 
      8 function lasso(hljs) {
      9   var LASSO_IDENT_RE = '[a-zA-Z_][\\w.]*';
     10   var LASSO_ANGLE_RE = '<\\?(lasso(script)?|=)';
     11   var LASSO_CLOSE_RE = '\\]|\\?>';
     12   var 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   var HTML_COMMENT = hljs.COMMENT(
     41     '<!--',
     42     '-->',
     43     {
     44       relevance: 0
     45     }
     46   );
     47   var LASSO_NOPROCESS = {
     48     className: 'meta',
     49     begin: '\\[noprocess\\]',
     50     starts: {
     51       end: '\\[/noprocess\\]',
     52       returnEnd: true,
     53       contains: [HTML_COMMENT]
     54     }
     55   };
     56   var LASSO_START = {
     57     className: 'meta',
     58     begin: '\\[/noprocess|' + LASSO_ANGLE_RE
     59   };
     60   var LASSO_DATAMEMBER = {
     61     className: 'symbol',
     62     begin: '\'' + LASSO_IDENT_RE + '\''
     63   };
     64   var LASSO_CODE = [
     65     hljs.C_LINE_COMMENT_MODE,
     66     hljs.C_BLOCK_COMMENT_MODE,
     67     hljs.inherit(hljs.C_NUMBER_MODE, {begin: hljs.C_NUMBER_RE + '|(-?infinity|NaN)\\b'}),
     68     hljs.inherit(hljs.APOS_STRING_MODE, {illegal: null}),
     69     hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null}),
     70     {
     71       className: 'string',
     72       begin: '`', end: '`'
     73     },
     74     { // variables
     75       variants: [
     76         {
     77           begin: '[#$]' + LASSO_IDENT_RE
     78         },
     79         {
     80           begin: '#', end: '\\d+',
     81           illegal: '\\W'
     82         }
     83       ]
     84     },
     85     {
     86       className: 'type',
     87       begin: '::\\s*', end: LASSO_IDENT_RE,
     88       illegal: '\\W'
     89     },
     90     {
     91       className: 'params',
     92       variants: [
     93         {
     94           begin: '-(?!infinity)' + LASSO_IDENT_RE,
     95           relevance: 0
     96         },
     97         {
     98           begin: '(\\.\\.\\.)'
     99         }
    100       ]
    101     },
    102     {
    103       begin: /(->|\.)\s*/,
    104       relevance: 0,
    105       contains: [LASSO_DATAMEMBER]
    106     },
    107     {
    108       className: 'class',
    109       beginKeywords: 'define',
    110       returnEnd: true, end: '\\(|=>',
    111       contains: [
    112         hljs.inherit(hljs.TITLE_MODE, {begin: LASSO_IDENT_RE + '(=(?!>))?|[-+*/%](?!>)'})
    113       ]
    114     }
    115   ];
    116   return {
    117     name: 'Lasso',
    118     aliases: ['ls', 'lassoscript'],
    119     case_insensitive: true,
    120     keywords: LASSO_KEYWORDS,
    121     contains: [
    122       {
    123         className: 'meta',
    124         begin: LASSO_CLOSE_RE,
    125         relevance: 0,
    126         starts: { // markup
    127           end: '\\[|' + LASSO_ANGLE_RE,
    128           returnEnd: true,
    129           relevance: 0,
    130           contains: [HTML_COMMENT]
    131         }
    132       },
    133       LASSO_NOPROCESS,
    134       LASSO_START,
    135       {
    136         className: 'meta',
    137         begin: '\\[no_square_brackets',
    138         starts: {
    139           end: '\\[/no_square_brackets\\]', // not implemented in the language
    140           keywords: LASSO_KEYWORDS,
    141           contains: [
    142             {
    143               className: 'meta',
    144               begin: LASSO_CLOSE_RE,
    145               relevance: 0,
    146               starts: {
    147                 end: '\\[noprocess\\]|' + LASSO_ANGLE_RE,
    148                 returnEnd: true,
    149                 contains: [HTML_COMMENT]
    150               }
    151             },
    152             LASSO_NOPROCESS,
    153             LASSO_START
    154           ].concat(LASSO_CODE)
    155         }
    156       },
    157       {
    158         className: 'meta',
    159         begin: '\\[',
    160         relevance: 0
    161       },
    162       {
    163         className: 'meta',
    164         begin: '^#!', end:'lasso9$',
    165         relevance: 10
    166       }
    167     ].concat(LASSO_CODE)
    168   };
    169 }
    170 
    171 module.exports = lasso;