| OLD | NEW |
| (Empty) |
| 1 // Copyright (C) 2008 Google 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 Common Lisp and related languages. | |
| 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-lisp">(my lisp code)</pre> | |
| 25 * The lang-cl class identifies the language as common lisp. | |
| 26 * This file supports the following language extensions: | |
| 27 * lang-cl - Common Lisp | |
| 28 * lang-el - Emacs Lisp | |
| 29 * lang-lisp - Lisp | |
| 30 * lang-scm - Scheme | |
| 31 * lang-lsp - FAT 8.3 filename version of lang-lisp. | |
| 32 * | |
| 33 * | |
| 34 * I used http://www.devincook.com/goldparser/doc/meta-language/grammar-LISP.htm | |
| 35 * as the basis, but added line comments that start with ; and changed the atom | |
| 36 * production to disallow unquoted semicolons. | |
| 37 * | |
| 38 * "Name" = 'LISP' | |
| 39 * "Author" = 'John McCarthy' | |
| 40 * "Version" = 'Minimal' | |
| 41 * "About" = 'LISP is an abstract language that organizes ALL' | |
| 42 * | 'data around "lists".' | |
| 43 * | |
| 44 * "Start Symbol" = [s-Expression] | |
| 45 * | |
| 46 * {Atom Char} = {Printable} - {Whitespace} - [()"\''] | |
| 47 * | |
| 48 * Atom = ( {Atom Char} | '\'{Printable} )+ | |
| 49 * | |
| 50 * [s-Expression] ::= [Quote] Atom | |
| 51 * | [Quote] '(' [Series] ')' | |
| 52 * | [Quote] '(' [s-Expression] '.' [s-Expression] ')' | |
| 53 * | |
| 54 * [Series] ::= [s-Expression] [Series] | |
| 55 * | | |
| 56 * | |
| 57 * [Quote] ::= '' !Quote = do not evaluate | |
| 58 * | | |
| 59 * | |
| 60 * | |
| 61 * I used <a href="http://gigamonkeys.com/book/">Practical Common Lisp</a> as | |
| 62 * the basis for the reserved word list. | |
| 63 * | |
| 64 * | |
| 65 * @author mikesamuel@gmail.com | |
| 66 */ | |
| 67 | |
| 68 PR['registerLangHandler']( | |
| 69 PR['createSimpleLexer']( | |
| 70 [ | |
| 71 ['opn', /^\(+/, null, '('], | |
| 72 ['clo', /^\)+/, null, ')'], | |
| 73 // A line comment that starts with ; | |
| 74 [PR['PR_COMMENT'], /^;[^\r\n]*/, null, ';'], | |
| 75 // Whitespace | |
| 76 [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], | |
| 77 // A double quoted, possibly multi-line, string. | |
| 78 [PR['PR_STRING'], /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"'] | |
| 79 ], | |
| 80 [ | |
| 81 [PR['PR_KEYWORD'], /^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|d
o|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-va
lue|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-fr
om|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, null], | |
| 82 [PR['PR_LITERAL'], | |
| 83 /^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]
?\d+)?)/i], | |
| 84 // A single quote possibly followed by a word that optionally ends with | |
| 85 // = ! or ?. | |
| 86 [PR['PR_LITERAL'], | |
| 87 /^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/], | |
| 88 // A word that optionally ends with = ! or ?. | |
| 89 [PR['PR_PLAIN'], | |
| 90 /^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i], | |
| 91 // A printable non-space non-special character | |
| 92 [PR['PR_PUNCTUATION'], /^[^\w\t\n\r \xA0()\"\\\';]+/] | |
| 93 ]), | |
| 94 ['cl', 'el', 'lisp', 'lsp', 'scm', 'ss', 'rkt']); | |
| OLD | NEW |