1/**
2 * @license
3 * Copyright (C) 2013 Peter Kofler
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// Contributed by peter dot kofler at code minus cop dot org
19
20/**
21 * @fileoverview
22 * Registers a language handler for (Turbo) Pascal.
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-pascal">(my Pascal code)</pre>
27 *
28 * @author peter dot kofler at code minus cop dot org
29 */
30
31PR.registerLangHandler(
32    PR.createSimpleLexer(
33        [ // shortcutStylePatterns
34          // 'single-line-string'
35          [PR.PR_STRING,        /^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$))/, null, '\''],
36          // Whitespace
37          [PR.PR_PLAIN,         /^\s+/, null, ' \r\n\t\xA0']
38        ],
39        [ // fallthroughStylePatterns
40          // A cStyleComments comment (* *) or {}
41          [PR.PR_COMMENT,       /^\(\*[\s\S]*?(?:\*\)|$)|^\{[\s\S]*?(?:\}|$)/, null],
42          [PR.PR_KEYWORD,       /^(?:ABSOLUTE|AND|ARRAY|ASM|ASSEMBLER|BEGIN|CASE|CONST|CONSTRUCTOR|DESTRUCTOR|DIV|DO|DOWNTO|ELSE|END|EXTERNAL|FOR|FORWARD|FUNCTION|GOTO|IF|IMPLEMENTATION|IN|INLINE|INTERFACE|INTERRUPT|LABEL|MOD|NOT|OBJECT|OF|OR|PACKED|PROCEDURE|PROGRAM|RECORD|REPEAT|SET|SHL|SHR|THEN|TO|TYPE|UNIT|UNTIL|USES|VAR|VIRTUAL|WHILE|WITH|XOR)\b/i, null],
43          [PR.PR_LITERAL,       /^(?:true|false|self|nil)/i, null],
44          [PR.PR_PLAIN,         /^[a-z][a-z0-9]*/i, null],
45          // Literals .0, 0, 0.0 0E13
46          [PR.PR_LITERAL,       /^(?:\$[a-f0-9]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?)/i,  null, '0123456789'],
47          [PR.PR_PUNCTUATION,   /^.[^\s\w\.$@\'\/]*/, null]
48        ]),
49    ['pascal']);
50