Commits

Eric Knibbe committed 5970662 Draft

added Lasso mode for google-code-prettify

Comments (0)

Files changed (3)

   Contributed a lexer for the Lasso programming language for highlight.js_, a
   JS-based syntax highlighter. Expect to see it in the next release.
 
+`Lasso lexer for google-code-prettify`_
+  Also wrote a Lasso lexer for google-code-prettify_, another JS-based syntax
+  highlighter. Hoping to eventually get it working on stackoverflow.com.
+
 Lasso
 -----
 
 .. _touch-menus-plus.js: https://bitbucket.org/EricFromCanada/ericfromcanada.bitbucket.org/raw/default/javascript/touch-menus-plus.js
 .. _Lasso lexer for highlight.js: https://github.com/isagalaev/highlight.js
 .. _highlight.js: http://softwaremaniacs.org/soft/highlight/en/
+.. _Lasso lexer for google-code-prettify: https://bitbucket.org/EricFromCanada/ericfromcanada.bitbucket.org/raw/default/javascript/lang-lasso.js
+.. _google-code-prettify: https://code.google.com/p/google-code-prettify/
 .. _sphinxifier.lasso: https://bitbucket.org/EricFromCanada/ericfromcanada.bitbucket.org/raw/default/lasso/sphinxifier.lasso
 .. _Lasso domain for Sphinx: https://pypi.python.org/pypi/sphinxcontrib-lassodomain/
 .. _Lasso lexer for Pygments: https://bitbucket.org/EricFromCanada/pygments-main
 <dt><a class="reference external" href="https://github.com/isagalaev/highlight.js">Lasso lexer for highlight.js</a></dt>
 <dd>Contributed a lexer for the Lasso programming language for <a class="reference external" href="http://softwaremaniacs.org/soft/highlight/en/">highlight.js</a>, a
 JS-based syntax highlighter. Expect to see it in the next release.</dd>
+<dt><a class="reference external" href="https://bitbucket.org/EricFromCanada/ericfromcanada.bitbucket.org/raw/default/javascript/lang-lasso.js">Lasso lexer for google-code-prettify</a></dt>
+<dd>Also wrote a Lasso lexer for <a class="reference external" href="https://code.google.com/p/google-code-prettify/">google-code-prettify</a>, another JS-based syntax
+highlighter. Hoping to eventually get it working on stackoverflow.com.</dd>
 </dl>
 </div>
 <div class="section" id="lasso">

javascript/lang-lasso.js

+// Copyright (C) 2013 Eric Knibbe
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+/**
+ * @fileoverview
+ * Registers a language handler for Lasso. <http://www.lassosoft.com>
+ *
+ * To use, include prettify.js and this file in your HTML page.
+ * Then enclose your code in an HTML tag like so:
+ *      <pre class="prettyprint lang-lasso">[your Lasso code]</pre>
+ *
+ * @author Eric Knibbe
+ */
+
+PR['registerLangHandler'](
+    PR['createSimpleLexer'](
+        [
+          // whitespace
+          [PR['PR_PLAIN'],        /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
+          // single quote strings
+          [PR['PR_STRING'],       /^\'(?:[^\'\\]|\\[\s\S])*(?:\'|$)/, null, "'"],
+          // double quote strings
+          [PR['PR_STRING'],       /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"'],
+          // ticked strings
+          [PR['PR_STRING'],       /^\`[^\`]*(?:\`|$)/, null, '`']
+        ],
+        [
+          // square or angle bracket delimiters
+          [PR['PR_TAG'],          /^\[|\]|<\?(?:lasso(?:script)?|=)|\?>/i],
+          // single-line or block comments
+          [PR['PR_COMMENT'],      /^(?:\/\/[^\r\n]*|\/\*[\s\S]*?\*\/)/],
+          // local, thread, or member variables, or keyword parameters
+          [PR['PR_ATTRIB_NAME'],  /^#\d+|[#$-][a-z_][\w.]*|\.'[a-z_][\w.]*'/i, null, '#$'],
+          // tag literals
+          [PR['PR_ATTRIB_VALUE'], /^::\s*[a-z_][\w.]*/i],
+          // number as hex integer literal, a decimal real literal, or in scientific notation
+          [PR['PR_LITERAL'],      /^(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[-+]?\d+)?))/i, null, '0123456789'],
+          // constants
+          [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],
+          // container or control keywords
+          [PR['PR_KEYWORD'],      /^(?:error_code|error_msg|error_pop|error_push|error_reset|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|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],
+          // standard type or variable declarations
+          [PR['PR_TYPE'],         /^(?:array|date|decimal|duration|integer|map|pair|string|tag|xml|null|bytes|list|queue|set|stack|staticarray|tie|local|var|variable|global|data|self|inherited)\b|^\.\.?/i],
+          // type, method, or parameter names
+          [PR['PR_PLAIN'],        /^[a-z_][\w.]*(?:=\s*(?=\())?/i],
+          // operators
+          [PR['PR_PUNCTUATION'],  /^:=|[-+*\/%=<>&|!?\\]/]
+        ]),
+    ['lasso']);