UNPKG

2.35 kBJavaScriptView Raw
1// Based on Free Pascal
2
3/* TODO
4 Support inline asm ?
5*/
6
7Prism.languages.pascal = {
8 'directive': {
9 pattern: /\{\$[\s\S]*?\}/,
10 greedy: true,
11 alias: ['marco', 'property']
12 },
13 'comment': {
14 pattern: /\(\*[\s\S]*?\*\)|\{[\s\S]*?\}|\/\/.*/,
15 greedy: true
16 },
17 'string': {
18 pattern: /(?:'(?:''|[^'\r\n])*'(?!')|#[&$%]?[a-f\d]+)+|\^[a-z]/i,
19 greedy: true
20 },
21 'asm': {
22 pattern: /(\basm\b)[\s\S]+?(?=\bend\s*[;[])/i,
23 lookbehind: true,
24 greedy: true,
25 inside: null // see below
26 },
27 'keyword': [
28 {
29 // Turbo Pascal
30 pattern: /(^|[^&])\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,
31 lookbehind: true
32 },
33 {
34 // Free Pascal
35 pattern: /(^|[^&])\b(?:dispose|exit|false|new|true)\b/i,
36 lookbehind: true
37 },
38 {
39 // Object Pascal
40 pattern: /(^|[^&])\b(?:class|dispinterface|except|exports|finalization|finally|initialization|inline|library|on|out|packed|property|raise|resourcestring|threadvar|try)\b/i,
41 lookbehind: true
42 },
43 {
44 // Modifiers
45 pattern: /(^|[^&])\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,
46 lookbehind: true
47 }
48 ],
49 'number': [
50 // Hexadecimal, octal and binary
51 /(?:[&%]\d+|\$[a-f\d]+)/i,
52 // Decimal
53 /\b\d+(?:\.\d+)?(?:e[+-]?\d+)?/i
54 ],
55 'operator': [
56 /\.\.|\*\*|:=|<[<=>]?|>[>=]?|[+\-*\/]=?|[@^=]/,
57 {
58 pattern: /(^|[^&])\b(?:and|as|div|exclude|in|include|is|mod|not|or|shl|shr|xor)\b/,
59 lookbehind: true
60 }
61 ],
62 'punctuation': /\(\.|\.\)|[()\[\]:;,.]/
63};
64
65Prism.languages.pascal.asm.inside = Prism.languages.extend('pascal', {
66 'asm': undefined,
67 'keyword': undefined,
68 'operator': undefined
69});
70
71Prism.languages.objectpascal = Prism.languages.pascal;
72
\No newline at end of file