1/**
2 * @license
3 * Copyright (C) 2013 Eric Knibbe
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/**
19 * @fileoverview
20 * Registers a language handler for Lasso. <http://www.lassosoft.com>
21 *
22 * To use, include prettify.js and this file in your HTML page.
23 * Then enclose your code in an HTML tag like so:
24 *      <pre class="prettyprint lang-lasso">[your Lasso code]</pre>
25 *
26 * @author Eric Knibbe
27 */
28
29PR['registerLangHandler'](
30    PR['createSimpleLexer'](
31        [
32          // whitespace
33          [PR['PR_PLAIN'],        /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
34          // single quote strings
35          [PR['PR_STRING'],       /^\'[^\'\\]*(?:\\[\s\S][^\'\\]*)*(?:\'|$)/, null, "'"],
36          // double quote strings
37          [PR['PR_STRING'],       /^\"[^\"\\]*(?:\\[\s\S][^\"\\]*)*(?:\"|$)/, null, '"'],
38          // ticked strings
39          [PR['PR_STRING'],       /^\`[^\`]*(?:\`|$)/, null, '`'],
40          // numeral as integer or hexidecimal
41          [PR['PR_LITERAL'],      /^0x[\da-f]+|\d+/i, null, '0123456789'],
42          // local or thread variables, or hashbang
43          [PR['PR_ATTRIB_NAME'],  /^[#$][a-z_][\w.]*|#\d+\b|#![ \S]+lasso9\b/i, null, '#$']
44        ],
45        [
46          // square or angle bracket delimiters
47          [PR['PR_TAG'],          /^[[\]]|<\?(?:lasso(?:script)?|=)|\?>|(no_square_brackets|noprocess)\b/i],
48          // single-line or block comments
49          [PR['PR_COMMENT'],      /^\/\/[^\r\n]*|\/\*[\s\S]*?\*\//],
50          // member variables or keyword parameters
51          [PR['PR_ATTRIB_NAME'],  /^-(?!infinity)[a-z_][\w.]*|\.\s*'[a-z_][\w.]*'|\.{3}/i],
52          // numeral as decimal or scientific notation
53          [PR['PR_LITERAL'],      /^\d*\.\d+(?:e[-+]?\d+)?|(infinity|NaN)\b/i],
54          // tag literals
55          [PR['PR_ATTRIB_VALUE'], /^::\s*[a-z_][\w.]*/i],
56          // constants
57          [PR['PR_LITERAL'],      /^(?:true|false|none|minimal|full|all|void|and|or|not|bw|nbw|ew|new|cn|ncn|lt|lte|gt|gte|eq|neq|rx|nrx|ft)\b/i],
58          // standard type or variable declarations
59          [PR['PR_TYPE'],         /^(?:array|date|decimal|duration|integer|map|pair|string|tag|xml|null|boolean|bytes|keyword|list|locale|queue|set|stack|staticarray|local|var|variable|global|data|self|inherited|currentcapture|givenblock)\b|^\.\.?/i],
60          // container or control keywords
61          [PR['PR_KEYWORD'],      /^(?:cache|database_names|database_schemanames|database_tablenames|define_tag|define_type|email_batch|encode_set|html_comment|handle|handle_error|header|if|inline|iterate|ljax_target|link|link_currentaction|link_currentgroup|link_currentrecord|link_detail|link_firstgroup|link_firstrecord|link_lastgroup|link_lastrecord|link_nextgroup|link_nextrecord|link_prevgroup|link_prevrecord|log|loop|namespace_using|output_none|portal|private|protect|records|referer|referrer|repeating|resultset|rows|search_args|search_arguments|select|sort_args|sort_arguments|thread_atomic|value_list|while|abort|case|else|fail_if|fail_ifnot|fail|if_empty|if_false|if_null|if_true|loop_abort|loop_continue|loop_count|params|params_up|return|return_value|run_children|soap_definetag|soap_lastrequest|soap_lastresponse|tag_name|ascending|average|by|define|descending|do|equals|frozen|group|handle_failure|import|in|into|join|let|match|max|min|on|order|parent|protected|provide|public|require|returnhome|skip|split_thread|sum|take|thread|to|trait|type|where|with|yield|yieldhome)\b/i],
62          // type, method, or parameter names
63          [PR['PR_PLAIN'],        /^[a-z_][\w.]*(?:=\s*(?=\())?/i],
64          // operators
65          [PR['PR_PUNCTUATION'],  /^:=|[-+*\/%=<>&|!?\\]+/]
66        ]),
67    ['lasso', 'ls', 'lassoscript']);
68