Commit 7dd1a6022d68eb49cea779fa7b3d193351df96ba

Golmote 2014-12-19T23:41:20

Add Pascal language

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