1/** 2 * @license 3 * Copyright (C) 2012 Pyrios 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 TCL 21 * 22 * 23 * To use, include prettify.js and this file in your HTML page. 24 * Then put your code in an HTML tag like 25 * <pre class="prettyprint lang-tcl">proc foo {} {puts bar}</pre> 26 * 27 * I copy-pasted lang-lisp.js, so this is probably not 100% accurate. 28 * I used http://wiki.tcl.tk/1019 for the keywords, but tried to only 29 * include as keywords that had more impact on the program flow 30 * rather than providing convenience. For example, I included 'if' 31 * since that provides branching, but left off 'open' since that is more 32 * like a proc. Add more if it makes sense. 33 * 34 * @author pyrios@gmail.com 35 */ 36 37PR['registerLangHandler']( 38 PR['createSimpleLexer']( 39 [ 40 ['opn', /^\{+/, null, '{'], 41 ['clo', /^\}+/, null, '}'], 42 // A line comment that starts with ; 43 [PR['PR_COMMENT'], /^#[^\r\n]*/, null, '#'], 44 // Whitespace 45 [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 46 // A double quoted, possibly multi-line, string. 47 [PR['PR_STRING'], /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"'] 48 ], 49 [ 50 [PR['PR_KEYWORD'], /^(?:after|append|apply|array|break|case|catch|continue|error|eval|exec|exit|expr|for|foreach|if|incr|info|proc|return|set|switch|trace|uplevel|upvar|while)\b/, null], 51 [PR['PR_LITERAL'], 52 /^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i], 53 // A single quote possibly followed by a word that optionally ends with 54 // = ! or ?. 55 [PR['PR_LITERAL'], 56 /^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/], 57 // A word that optionally ends with = ! or ?. 58 [PR['PR_PLAIN'], 59 /^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i], 60 // A printable non-space non-special character 61 [PR['PR_PUNCTUATION'], /^[^\w\t\n\r \xA0()\"\\\';]+/] 62 ]), 63 ['tcl']); 64