Add Pascal language
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
diff --git a/components.js b/components.js
index 7bae569..f6ebab3 100644
--- a/components.js
+++ b/components.js
@@ -206,6 +206,10 @@ var components = {
"handlebars": {
"title": "Handlebars",
"owner": "Golmote"
+ },
+ "pascal": {
+ "title": "Pascal",
+ "owner": "Golmote"
}
},
"plugins": {
diff --git a/components/prism-pascal.js b/components/prism-pascal.js
new file mode 100644
index 0000000..fa7123a
--- /dev/null
+++ b/components/prism-pascal.js
@@ -0,0 +1,60 @@
+// Based on Free Pascal
+
+/* TODO
+ Support inline asm ?
+ Use accurate unsigned integer regexp for control string (#...)
+*/
+
+Prism.languages.pascal = {
+ 'comment': [
+ /\(\*.+?\*\)/,
+ /\{.+?\}/,
+ /\/\/.*/
+ ],
+ // The unsigned integer after the # is quite inaccurate...
+ 'string': [
+ /(?:'(?:''|[^'\n])*'|#[&$%]?[a-f\d]+)+/i,
+ // Char
+ /\^[a-z]/i
+ ],
+ 'keyword': [
+ {
+ // Turbo Pascal
+ 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,
+ lookbehind: true
+ },
+ {
+ // Free Pascal
+ pattern: /(^|(?!&).)\b(?:dispose|exit|false|new|true)\b/i,
+ lookbehind: true
+ },
+ {
+ // Object Pascal
+ pattern: /(^|(?!&).)\b(?:class|dispinterface|except|exports|finalization|finally|initialization|inline|library|on|out|packed|property|raise|resourcestring|threadvar|try)\b/i,
+ lookbehind: true
+ },
+ {
+ // Modifiers
+ 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,
+ lookbehind: true
+ }
+ ],
+ 'number': [
+ // Hexadecimal
+ /[+-]?\$[a-f\d]+/i,
+ // Octal
+ /[+-]?&[0-7]+/,
+ // Binary
+ /[+-]?%[01]+/,
+ // Decimal
+ /([+-]|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?/i
+ ],
+ 'operator': [
+ /\.\.|\*\*|:=|[<>]{2}|[<>+\-*\/]=?|[@^=]/i,
+ {
+ pattern: /(^|(?!&).)\b(?:and|as|div|exclude|in|include|is|mod|not|or|shl|shr|xor)\b/,
+ lookbehind: true
+ }
+ ],
+ 'punctuation': /\(\.|\.\)|[()\[\]:;,.]/
+};
\ No newline at end of file
diff --git a/components/prism-pascal.min.js b/components/prism-pascal.min.js
new file mode 100644
index 0000000..07846a1
--- /dev/null
+++ b/components/prism-pascal.min.js
@@ -0,0 +1 @@
+Prism.languages.pascal={comment:[/\(\*.+?\*\)/,/\{.+?\}/,/\/\/.*/],string:[/(?:'(?:''|[^'\n])*'|#[&$%]?[a-f\d]+)+/i,/\^[a-z]/i],keyword:[{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,lookbehind:!0},{pattern:/(^|(?!&).)\b(?:dispose|exit|false|new|true)\b/i,lookbehind:!0},{pattern:/(^|(?!&).)\b(?:class|dispinterface|except|exports|finalization|finally|initialization|inline|library|on|out|packed|property|raise|resourcestring|threadvar|try)\b/i,lookbehind:!0},{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,lookbehind:!0}],number:[/[+-]?\$[a-f\d]+/i,/[+-]?&[0-7]+/,/[+-]?%[01]+/,/([+-]|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?/i],operator:[/\.\.|\*\*|:=|[<>]{2}|[<>+\-*\/]=?|[@^=]/i,{pattern:/(^|(?!&).)\b(?:and|as|div|exclude|in|include|is|mod|not|or|shl|shr|xor)\b/,lookbehind:!0}],punctuation:/\(\.|\.\)|[()\[\]:;,.]/};
\ No newline at end of file