| OLD | NEW |
| (Empty) |
| 1 // Copyright (C) 2013 Nikhil Dabas | |
| 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 * @fileoverview | |
| 18 * Registers a language handler for LLVM. | |
| 19 * From https://gist.github.com/ndabas/2850418 | |
| 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-llvm">(my LLVM code)</pre> | |
| 25 * | |
| 26 * | |
| 27 * The regular expressions were adapted from: | |
| 28 * https://github.com/hansstimer/llvm.tmbundle/blob/76fedd8f50fd6108b1780c51d79f
be3223de5f34/Syntaxes/LLVM.tmLanguage | |
| 29 * | |
| 30 * http://llvm.org/docs/LangRef.html#constants describes the language grammar. | |
| 31 * | |
| 32 * @author Nikhil Dabas | |
| 33 */ | |
| 34 PR['registerLangHandler']( | |
| 35 PR['createSimpleLexer']( | |
| 36 [ | |
| 37 // Whitespace | |
| 38 [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], | |
| 39 // A double quoted, possibly multi-line, string. | |
| 40 [PR['PR_STRING'], /^!?\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"']
, | |
| 41 // comment.llvm | |
| 42 [PR['PR_COMMENT'], /^;[^\r\n]*/, null, ';'] | |
| 43 ], | |
| 44 [ | |
| 45 // variable.llvm | |
| 46 [PR['PR_PLAIN'], /^[%@!](?:[-a-zA-Z$._][-a-zA-Z$._0-9]*|\d+)/], | |
| 47 | |
| 48 // According to http://llvm.org/docs/LangRef.html#well-formedness | |
| 49 // These reserved words cannot conflict with variable names, because no
ne of them start with a prefix character ('%' or '@'). | |
| 50 [PR['PR_KEYWORD'], /^[A-Za-z_][0-9A-Za-z_]*/, null], | |
| 51 | |
| 52 // constant.numeric.float.llvm | |
| 53 [PR['PR_LITERAL'], /^\d+\.\d+/], | |
| 54 | |
| 55 // constant.numeric.integer.llvm | |
| 56 [PR['PR_LITERAL'], /^(?:\d+|0[xX][a-fA-F0-9]+)/], | |
| 57 | |
| 58 // punctuation | |
| 59 [PR['PR_PUNCTUATION'], /^[()\[\]{},=*<>:]|\.\.\.$/] | |
| 60 ]), | |
| 61 ['llvm', 'll']); | |
| OLD | NEW |