1 | 'use strict'
|
---|
2 |
|
---|
3 | module.exports = pascal
|
---|
4 | pascal.displayName = 'pascal'
|
---|
5 | pascal.aliases = ['objectpascal']
|
---|
6 | function pascal(Prism) {
|
---|
7 | // Based on Free Pascal
|
---|
8 | /* TODO
|
---|
9 | Support inline asm ?
|
---|
10 | */
|
---|
11 | Prism.languages.pascal = {
|
---|
12 | directive: {
|
---|
13 | pattern: /\{\$[\s\S]*?\}/,
|
---|
14 | greedy: true,
|
---|
15 | alias: ['marco', 'property']
|
---|
16 | },
|
---|
17 | comment: {
|
---|
18 | pattern: /\(\*[\s\S]*?\*\)|\{[\s\S]*?\}|\/\/.*/,
|
---|
19 | greedy: true
|
---|
20 | },
|
---|
21 | string: {
|
---|
22 | pattern: /(?:'(?:''|[^'\r\n])*'(?!')|#[&$%]?[a-f\d]+)+|\^[a-z]/i,
|
---|
23 | greedy: true
|
---|
24 | },
|
---|
25 | asm: {
|
---|
26 | pattern: /(\basm\b)[\s\S]+?(?=\bend\s*[;[])/i,
|
---|
27 | lookbehind: true,
|
---|
28 | greedy: true,
|
---|
29 | inside: null // see below
|
---|
30 | },
|
---|
31 | keyword: [
|
---|
32 | {
|
---|
33 | // Turbo Pascal
|
---|
34 | pattern:
|
---|
35 | /(^|[^&])\b(?:absolute|array|asm|begin|case|const|constructor|destructor|do|downto|else|end|file|for|function|goto|if|implementation|inherited|inline|interface|label|nil|object|of|operator|packed|procedure|program|record|reintroduce|repeat|self|set|string|then|to|type|unit|until|uses|var|while|with)\b/i,
|
---|
36 | lookbehind: true
|
---|
37 | },
|
---|
38 | {
|
---|
39 | // Free Pascal
|
---|
40 | pattern: /(^|[^&])\b(?:dispose|exit|false|new|true)\b/i,
|
---|
41 | lookbehind: true
|
---|
42 | },
|
---|
43 | {
|
---|
44 | // Object Pascal
|
---|
45 | pattern:
|
---|
46 | /(^|[^&])\b(?:class|dispinterface|except|exports|finalization|finally|initialization|inline|library|on|out|packed|property|raise|resourcestring|threadvar|try)\b/i,
|
---|
47 | lookbehind: true
|
---|
48 | },
|
---|
49 | {
|
---|
50 | // Modifiers
|
---|
51 | pattern:
|
---|
52 | /(^|[^&])\b(?:absolute|abstract|alias|assembler|bitpacked|break|cdecl|continue|cppdecl|cvar|default|deprecated|dynamic|enumerator|experimental|export|external|far|far16|forward|generic|helper|implements|index|interrupt|iochecks|local|message|name|near|nodefault|noreturn|nostackframe|oldfpccall|otherwise|overload|override|pascal|platform|private|protected|public|published|read|register|reintroduce|result|safecall|saveregisters|softfloat|specialize|static|stdcall|stored|strict|unaligned|unimplemented|varargs|virtual|write)\b/i,
|
---|
53 | lookbehind: true
|
---|
54 | }
|
---|
55 | ],
|
---|
56 | number: [
|
---|
57 | // Hexadecimal, octal and binary
|
---|
58 | /(?:[&%]\d+|\$[a-f\d]+)/i, // Decimal
|
---|
59 | /\b\d+(?:\.\d+)?(?:e[+-]?\d+)?/i
|
---|
60 | ],
|
---|
61 | operator: [
|
---|
62 | /\.\.|\*\*|:=|<[<=>]?|>[>=]?|[+\-*\/]=?|[@^=]/,
|
---|
63 | {
|
---|
64 | pattern:
|
---|
65 | /(^|[^&])\b(?:and|as|div|exclude|in|include|is|mod|not|or|shl|shr|xor)\b/,
|
---|
66 | lookbehind: true
|
---|
67 | }
|
---|
68 | ],
|
---|
69 | punctuation: /\(\.|\.\)|[()\[\]:;,.]/
|
---|
70 | }
|
---|
71 | Prism.languages.pascal.asm.inside = Prism.languages.extend('pascal', {
|
---|
72 | asm: undefined,
|
---|
73 | keyword: undefined,
|
---|
74 | operator: undefined
|
---|
75 | })
|
---|
76 | Prism.languages.objectpascal = Prism.languages.pascal
|
---|
77 | }
|
---|