1 // Copyright (C) 2011 Kitware Inc.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
19 * Registers a language handler for MUMPS.
22 * To use, include prettify.js and this file in your HTML page.
23 * Then put your code in an HTML tag like
24 * <pre class="prettyprint lang-mumps">(my SQL code)</pre>
26 * Commands, intrinsic functions and variables taken from ISO/IEC 11756:1999(E)
28 * @author chris.harris@kitware.com
32 * - Currently can't distinguish between keywords and local or global variables having the same name
33 * for exampe SET IF="IF?"
34 * - m file are already used for MatLab hence using mumps.
40 var commands
= 'B|BREAK|' +
67 var intrinsicVariables
= 'D|DEVICE|' +
87 var intrinsicFunctions
= 'A|ASCII|' +
111 var intrinsic
= intrinsicVariables
+ intrinsicFunctions
;
114 var shortcutStylePatterns
= [
116 [PR
['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
117 // A double or single quoted, possibly multi-line, string.
118 [PR
['PR_STRING'], /^(?:"(?:[^"]|\\.)*")/, null, '"']
121 var fallthroughStylePatterns
= [
122 // A line comment that starts with ;
123 [PR
['PR_COMMENT'], /^;[^\r\n]*/, null, ';'],
124 // Add intrinsic variables and functions as declarations, there not really but it mean
125 // they will hilighted differently from commands.
126 [PR
['PR_DECLARATION'], new RegExp('^(?:\\$(?:' + intrinsic
+ '))\\b', 'i'), null],
127 // Add commands as keywords
128 [PR
['PR_KEYWORD'], new RegExp('^(?:[^\\$]' + commands
+ ')\\b', 'i'), null],
129 // A number is a decimal real literal or in scientific notation.
131 /^[+-]?(?:(?:\.\d+|\d+(?:\.\d*)?)(?:E[+\-]?\d+)?)/i],
133 [PR
['PR_PLAIN'], /^[a-z][a-zA-Z0-9]*/i],
135 [PR
['PR_PUNCTUATION'], /^[^\w\t\n\r\xA0\"\$;%\^]|_/]
137 // Can't use m as its already used for MatLab
138 PR
.registerLangHandler(PR
.createSimpleLexer(shortcutStylePatterns
, fallthroughStylePatterns
), ['mumps']);