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