| OLD | NEW |
| (Empty) |
| 1 // Copyright (C) 2011 Kitware Inc. | |
| 2 // | |
| 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 | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 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. | |
| 14 | |
| 15 | |
| 16 | |
| 17 /** | |
| 18 * @fileoverview | |
| 19 * Registers a language handler for MUMPS. | |
| 20 * | |
| 21 * | |
| 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> | |
| 25 * | |
| 26 * Commands, intrinsic functions and variables taken from ISO/IEC 11756:1999(E) | |
| 27 * | |
| 28 * @author chris.harris@kitware.com | |
| 29 * | |
| 30 * Known issues: | |
| 31 * | |
| 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. | |
| 35 */ | |
| 36 | |
| 37 (function () { | |
| 38 | |
| 39 | |
| 40 var commands = 'B|BREAK|' + | |
| 41 'C|CLOSE|' + | |
| 42 'D|DO|' + | |
| 43 'E|ELSE|' + | |
| 44 'F|FOR|' + | |
| 45 'G|GOTO|' + | |
| 46 'H|HALT|' + | |
| 47 'H|HANG|' + | |
| 48 'I|IF|' + | |
| 49 'J|JOB|' + | |
| 50 'K|KILL|' + | |
| 51 'L|LOCK|' + | |
| 52 'M|MERGE|' + | |
| 53 'N|NEW|' + | |
| 54 'O|OPEN|' + | |
| 55 'Q|QUIT|' + | |
| 56 'R|READ|' + | |
| 57 'S|SET|' + | |
| 58 'TC|TCOMMIT|' + | |
| 59 'TRE|TRESTART|' + | |
| 60 'TRO|TROLLBACK|' + | |
| 61 'TS|TSTART|' + | |
| 62 'U|USE|' + | |
| 63 'V|VIEW|' + | |
| 64 'W|WRITE|' + | |
| 65 'X|XECUTE'; | |
| 66 | |
| 67 var intrinsicVariables = 'D|DEVICE|' + | |
| 68 'EC|ECODE|' + | |
| 69 'ES|ESTACK|' + | |
| 70 'ET|ETRAP|' + | |
| 71 'H|HOROLOG|' + | |
| 72 'I|IO|' + | |
| 73 'J|JOB|' + | |
| 74 'K|KEY|' + | |
| 75 'P|PRINCIPAL|' + | |
| 76 'Q|QUIT|' + | |
| 77 'ST|STACK|' + | |
| 78 'S|STORAGE|' + | |
| 79 'SY|SYSTEM|' + | |
| 80 'T|TEST|' + | |
| 81 'TL|TLEVEL|' + | |
| 82 'TR|TRESTART|' + | |
| 83 'X|' + | |
| 84 'Y|' + | |
| 85 'Z[A-Z]*|'; | |
| 86 | |
| 87 var intrinsicFunctions = 'A|ASCII|' + | |
| 88 'C|CHAR|' + | |
| 89 'D|DATA|' + | |
| 90 'E|EXTRACT|' + | |
| 91 'F|FIND|' + | |
| 92 'FN|FNUMBER|' + | |
| 93 'G|GET|' + | |
| 94 'J|JUSTIFY|' + | |
| 95 'L|LENGTH|' + | |
| 96 'NA|NAME|' + | |
| 97 'O|ORDER|' + | |
| 98 'P|PIECE|' + | |
| 99 'QL|QLENGTH|' + | |
| 100 'QS|QSUBSCRIPT|' + | |
| 101 'Q|QUERY|' + | |
| 102 'R|RANDOM|' + | |
| 103 'RE|REVERSE|' + | |
| 104 'S|SELECT|' + | |
| 105 'ST|STACK|' + | |
| 106 'T|TEXT|' + | |
| 107 'TR|TRANSLATE|' + | |
| 108 'V|VIEW|' * | |
| 109 'Z[A-Z]*|'; | |
| 110 | |
| 111 var intrinsic = intrinsicVariables + intrinsicFunctions; | |
| 112 | |
| 113 | |
| 114 var shortcutStylePatterns = [ | |
| 115 // Whitespace | |
| 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, '"'] | |
| 119 ]; | |
| 120 | |
| 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 rea
lly 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'), n
ull], | |
| 129 // A number is a decimal real literal or in scientific notation. | |
| 130 [PR['PR_LITERAL'], | |
| 131 /^[+-]?(?:(?:\.\d+|\d+(?:\.\d*)?)(?:E[+\-]?\d+)?)/i], | |
| 132 // An identifier | |
| 133 [PR['PR_PLAIN'], /^[a-z][a-zA-Z0-9]*/i], | |
| 134 // Exclude $ % and ^ | |
| 135 [PR['PR_PUNCTUATION'], /^[^\w\t\n\r\xA0\"\$;%\^]|_/] | |
| 136 ]; | |
| 137 // Can't use m as its already used for MatLab | |
| 138 PR.registerLangHandler(PR.createSimpleLexer(shortcutStylePatterns, fallthroughSt
ylePatterns), ['mumps']); | |
| 139 })(); | |
| OLD | NEW |