1/**
2 * @license
3 * Copyright (C) 2013 Nikhil Dabas
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 LLVM.
21 * From https://gist.github.com/ndabas/2850418
22 *
23 *
24 * To use, include prettify.js and this file in your HTML page.
25 * Then put your code in an HTML tag like
26 *      <pre class="prettyprint lang-llvm">(my LLVM code)</pre>
27 *
28 *
29 * The regular expressions were adapted from:
30 * https://github.com/hansstimer/llvm.tmbundle/blob/76fedd8f50fd6108b1780c51d79fbe3223de5f34/Syntaxes/LLVM.tmLanguage
31 *
32 * http://llvm.org/docs/LangRef.html#constants describes the language grammar.
33 *
34 * @author Nikhil Dabas
35 */
36PR['registerLangHandler'](
37    PR['createSimpleLexer'](
38        [
39         // Whitespace
40         [PR['PR_PLAIN'],       /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
41         // A double quoted, possibly multi-line, string.
42         [PR['PR_STRING'],      /^!?\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"'],
43         // comment.llvm
44         [PR['PR_COMMENT'],     /^;[^\r\n]*/, null, ';']
45        ],
46        [
47         // variable.llvm
48         [PR['PR_PLAIN'],       /^[%@!](?:[-a-zA-Z$._][-a-zA-Z$._0-9]*|\d+)/],
49
50         // According to http://llvm.org/docs/LangRef.html#well-formedness
51         // These reserved words cannot conflict with variable names, because none of them start with a prefix character ('%' or '@').
52         [PR['PR_KEYWORD'],     /^[A-Za-z_][0-9A-Za-z_]*/, null],
53
54         // constant.numeric.float.llvm
55         [PR['PR_LITERAL'],     /^\d+\.\d+/],
56
57         // constant.numeric.integer.llvm
58         [PR['PR_LITERAL'],     /^(?:\d+|0[xX][a-fA-F0-9]+)/],
59
60         // punctuation
61         [PR['PR_PUNCTUATION'], /^[()\[\]{},=*<>:]|\.\.\.$/]
62        ]),
63    ['llvm', 'll']);
64