Commit 1f45942c86a3cb441323e41dbb690774e02ab38b

Golmote 2015-09-04T08:58:16

Add support for APL. Closes #308

diff --git a/components.js b/components.js
index 43f1536..9130d4f 100644
--- a/components.js
+++ b/components.js
@@ -67,6 +67,10 @@ var components = {
 			"title": "Apache Configuration",
 			"owner": "GuiTeK"
 		},
+		"apl": {
+			"title": "APL",
+			"owner": "ngn"
+		},
 		"applescript": {
 			"title": "AppleScript",
 			"owner": "Golmote"
diff --git a/components/prism-apl.js b/components/prism-apl.js
new file mode 100644
index 0000000..9218331
--- /dev/null
+++ b/components/prism-apl.js
@@ -0,0 +1,29 @@
+Prism.languages.apl = {
+	'comment': /(?:⍝|#[! ]).*$/m,
+	'string': /'(?:[^'\r\n]|'')*'/,
+	'number': /¯?(?:\d*\.?\d+(?:e[+¯]?\d+)?|¯|∞)(?:j¯?(?:\d*\.?\d+(?:e[\+¯]?\d+)?|¯|∞))?/i,
+	'statement': /:[A-Z][a-z][A-Za-z]*\b/,
+	'system-function': {
+		pattern: /⎕[A-Z]+/i,
+		alias: 'function'
+	},
+	'constant': /[⍬⌾#⎕⍞]/,
+	'function': /[-+×÷⌈⌊∣|⍳?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⍯↗¤→]/,
+	'monadic-operator': {
+		pattern: /[\\\/⌿⍀¨⍨⌶&∥]/,
+		alias: 'operator'
+	},
+	'dyadic-operator': {
+		pattern: /[.⍣⍠⍤∘⌸]/,
+		alias: 'operator'
+	},
+	'assignment': {
+		pattern: /←/,
+		alias: 'keyword'
+	},
+	'punctuation': /[\[;\]()◇⋄]/,
+	'dfn': {
+		pattern: /[{}⍺⍵⍶⍹∇⍫:]/,
+		alias: 'builtin'
+	}
+};
\ No newline at end of file
diff --git a/components/prism-apl.min.js b/components/prism-apl.min.js
new file mode 100644
index 0000000..bfd9dc3
--- /dev/null
+++ b/components/prism-apl.min.js
@@ -0,0 +1 @@
+Prism.languages.apl={comment:/(?:⍝|#[! ]).*$/m,string:/'(?:[^'\r\n]|'')*'/,number:/¯?(?:\d*\.?\d+(?:e[+¯]?\d+)?|¯|∞)(?:j¯?(?:\d*\.?\d+(?:e[\+¯]?\d+)?|¯|∞))?/i,statement:/:[A-Z][a-z][A-Za-z]*\b/,"system-function":{pattern:/⎕[A-Z]+/i,alias:"function"},constant:/[⍬⌾#⎕⍞]/,"function":/[-+×÷⌈⌊∣|⍳?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⍯↗¤→]/,"monadic-operator":{pattern:/[\\\/⌿⍀¨⍨⌶&∥]/,alias:"operator"},"dyadic-operator":{pattern:/[.⍣⍠⍤∘⌸]/,alias:"operator"},assignment:{pattern:/←/,alias:"keyword"},punctuation:/[\[;\]()◇⋄]/,dfn:{pattern:/[{}⍺⍵⍶⍹∇⍫:]/,alias:"builtin"}};
\ No newline at end of file
diff --git a/plugins/show-language/prism-show-language.js b/plugins/show-language/prism-show-language.js
index 8d84523..449c9e0 100644
--- a/plugins/show-language/prism-show-language.js
+++ b/plugins/show-language/prism-show-language.js
@@ -5,7 +5,7 @@ if (typeof self === 'undefined' || !self.Prism || !self.document) {
 }
 
 // The languages map is built automatically with gulp
-var Languages = /*languages_placeholder[*/{"css":"CSS","clike":"C-like","javascript":"JavaScript","actionscript":"ActionScript","apacheconf":"Apache Configuration","applescript":"AppleScript","aspnet":"ASP.NET (C#)","autohotkey":"AutoHotkey","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","http":"HTTP","latex":"LaTeX","lolcode":"LOLCODE","matlab":"MATLAB","nasm":"NASM","nsis":"NSIS","objectivec":"Objective-C","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","wiki":"Wiki markup","yaml":"YAML"}/*]*/;
+var Languages = /*languages_placeholder[*/{"css":"CSS","clike":"C-like","javascript":"JavaScript","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","aspnet":"ASP.NET (C#)","autohotkey":"AutoHotkey","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","http":"HTTP","latex":"LaTeX","lolcode":"LOLCODE","matlab":"MATLAB","nasm":"NASM","nsis":"NSIS","objectivec":"Objective-C","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","wiki":"Wiki markup","yaml":"YAML"}/*]*/;
 Prism.hooks.add('before-highlight', function(env) {
 	var pre = env.element.parentNode;
 	if (!pre || !/pre/i.test(pre.nodeName)) {
diff --git a/plugins/show-language/prism-show-language.min.js b/plugins/show-language/prism-show-language.min.js
index 3e2f5ab..3b12881 100644
--- a/plugins/show-language/prism-show-language.min.js
+++ b/plugins/show-language/prism-show-language.min.js
@@ -1 +1 @@
-!function(){if("undefined"!=typeof self&&self.Prism&&self.document){var e={css:"CSS",clike:"C-like",javascript:"JavaScript",actionscript:"ActionScript",apacheconf:"Apache Configuration",applescript:"AppleScript",aspnet:"ASP.NET (C#)",autohotkey:"AutoHotkey",csharp:"C#",cpp:"C++",coffeescript:"CoffeeScript","css-extras":"CSS Extras",fsharp:"F#",http:"HTTP",latex:"LaTeX",lolcode:"LOLCODE",matlab:"MATLAB",nasm:"NASM",nsis:"NSIS",objectivec:"Objective-C",php:"PHP","php-extras":"PHP Extras",powershell:"PowerShell",jsx:"React JSX",rest:"reST (reStructuredText)",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)",sql:"SQL",typescript:"TypeScript",vhdl:"VHDL",wiki:"Wiki markup",yaml:"YAML"};Prism.hooks.add("before-highlight",function(s){var t=s.element.parentNode;if(t&&/pre/i.test(t.nodeName)){var a=e[s.language]||s.language.substring(0,1).toUpperCase()+s.language.substring(1);t.setAttribute("data-language",a)}})}}();
\ No newline at end of file
+!function(){if("undefined"!=typeof self&&self.Prism&&self.document){var e={css:"CSS",clike:"C-like",javascript:"JavaScript",actionscript:"ActionScript",apacheconf:"Apache Configuration",apl:"APL",applescript:"AppleScript",aspnet:"ASP.NET (C#)",autohotkey:"AutoHotkey",csharp:"C#",cpp:"C++",coffeescript:"CoffeeScript","css-extras":"CSS Extras",fsharp:"F#",http:"HTTP",latex:"LaTeX",lolcode:"LOLCODE",matlab:"MATLAB",nasm:"NASM",nsis:"NSIS",objectivec:"Objective-C",php:"PHP","php-extras":"PHP Extras",powershell:"PowerShell",jsx:"React JSX",rest:"reST (reStructuredText)",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)",sql:"SQL",typescript:"TypeScript",vhdl:"VHDL",wiki:"Wiki markup",yaml:"YAML"};Prism.hooks.add("before-highlight",function(s){var t=s.element.parentNode;if(t&&/pre/i.test(t.nodeName)){var a=e[s.language]||s.language.substring(0,1).toUpperCase()+s.language.substring(1);t.setAttribute("data-language",a)}})}}();
\ No newline at end of file
diff --git a/tests/languages/apl/assignment_feature.test b/tests/languages/apl/assignment_feature.test
new file mode 100644
index 0000000..b06cb39
--- /dev/null
+++ b/tests/languages/apl/assignment_feature.test
@@ -0,0 +1,13 @@
+a←1 2 3
+
+----------------------------------------------------
+
+[
+	"a",
+	["assignment", "←"],
+	["number", "1"], ["number", "2"], ["number", "3"]
+]
+
+----------------------------------------------------
+
+Checks for assignment.
\ No newline at end of file
diff --git a/tests/languages/apl/comment_feature.test b/tests/languages/apl/comment_feature.test
new file mode 100644
index 0000000..a308451
--- /dev/null
+++ b/tests/languages/apl/comment_feature.test
@@ -0,0 +1,15 @@
+⍝
+⍝ Foobar
+#!/usr/bin/env runapl
+
+----------------------------------------------------
+
+[
+	["comment", "⍝"],
+	["comment", "⍝ Foobar"],
+	["comment", "#!/usr/bin/env runapl"]
+]
+
+----------------------------------------------------
+
+Checks for comments.
\ No newline at end of file
diff --git a/tests/languages/apl/constant_feature.test b/tests/languages/apl/constant_feature.test
new file mode 100644
index 0000000..9f63162
--- /dev/null
+++ b/tests/languages/apl/constant_feature.test
@@ -0,0 +1,19 @@
+⍬
+⌾
+#
+⎕
+⍞
+
+----------------------------------------------------
+
+[
+	["constant", "⍬"],
+	["constant", "⌾"],
+	["constant", "#"],
+	["constant", "⎕"],
+	["constant", "⍞"]
+]
+
+----------------------------------------------------
+
+Checks for constants.
\ No newline at end of file
diff --git a/tests/languages/apl/dfn_feature.test b/tests/languages/apl/dfn_feature.test
new file mode 100644
index 0000000..ef4be35
--- /dev/null
+++ b/tests/languages/apl/dfn_feature.test
@@ -0,0 +1,23 @@
+{0=⍴⍴⍺:'hello' ⋄ ∇¨⍵}
+
+----------------------------------------------------
+
+[
+	["dfn", "{"],
+	["number", "0"],
+	["function", "="],
+	["function", "⍴"],
+	["function", "⍴"],
+	["dfn", "⍺"],
+	["dfn", ":"],
+	["string", "'hello'"],
+	["punctuation", "⋄"],
+	["dfn", "∇"],
+	["monadic-operator", "¨"],
+	["dfn", "⍵"],
+	["dfn", "}"]
+]
+
+----------------------------------------------------
+
+Checks for Dfns.
\ No newline at end of file
diff --git a/tests/languages/apl/dyadic-operator_feature.test b/tests/languages/apl/dyadic-operator_feature.test
new file mode 100644
index 0000000..8d7424c
--- /dev/null
+++ b/tests/languages/apl/dyadic-operator_feature.test
@@ -0,0 +1,13 @@
+. ⍣ ⍠
+⍤ ∘ ⌸
+
+----------------------------------------------------
+
+[
+	["dyadic-operator", "."], ["dyadic-operator", "⍣"], ["dyadic-operator", "⍠"],
+	["dyadic-operator", "⍤"], ["dyadic-operator", "∘"], ["dyadic-operator", "⌸"]
+]
+
+----------------------------------------------------
+
+Checks for dyadic operators.
\ No newline at end of file
diff --git a/tests/languages/apl/function_feature.test b/tests/languages/apl/function_feature.test
new file mode 100644
index 0000000..d663f0e
--- /dev/null
+++ b/tests/languages/apl/function_feature.test
@@ -0,0 +1,41 @@
+- + × ÷
+⌈ ⌊ ∣ |
+⍳ ? *
+⍟ ○ ! ⌹
+< ≤ = >
+≥ ≠ ≡ ≢
+∊ ⍷ ∪ ∩
+~ ∨ ∧ ⍱
+⍲ ⍴ , ⍪
+⌽ ⊖ ⍉
+↑ ↓ ⊂ ⊃
+⌷ ⍋ ⍒
+⊤ ⊥ ⍕ ⍎
+⊣ ⊢ ⍁ ⍂
+≈ ⍯
+↗ ¤ →
+
+----------------------------------------------------
+
+[
+	["function", "-"], ["function", "+"], ["function", "×"], ["function", "÷"],
+	["function", "⌈"], ["function", "⌊"], ["function", "∣"], ["function", "|"],
+	["function", "⍳"], ["function", "?"], ["function", "*"],
+	["function", "⍟"], ["function", "○"], ["function", "!"], ["function", "⌹"],
+	["function", "<"], ["function", "≤"], ["function", "="], ["function", ">"],
+	["function", "≥"], ["function", "≠"], ["function", "≡"], ["function", "≢"],
+	["function", "∊"], ["function", "⍷"], ["function", "∪"], ["function", "∩"],
+	["function", "~"], ["function", "∨"], ["function", "∧"], ["function", "⍱"],
+	["function", "⍲"], ["function", "⍴"], ["function", ","], ["function", "⍪"],
+	["function", "⌽"], ["function", "⊖"], ["function", "⍉"],
+	["function", "↑"], ["function", "↓"], ["function", "⊂"], ["function", "⊃"],
+	["function", "⌷"], ["function", "⍋"], ["function", "⍒"],
+	["function", "⊤"], ["function", "⊥"], ["function", "⍕"], ["function", "⍎"],
+	["function", "⊣"], ["function", "⊢"], ["function", "⍁"], ["function", "⍂"],
+	["function", "≈"], ["function", "⍯"],
+	["function", "↗"], ["function", "¤"], ["function", "→"]
+]
+
+----------------------------------------------------
+
+Checks for functions.
\ No newline at end of file
diff --git a/tests/languages/apl/monadic-operator_feature.test b/tests/languages/apl/monadic-operator_feature.test
new file mode 100644
index 0000000..0dcc9b0
--- /dev/null
+++ b/tests/languages/apl/monadic-operator_feature.test
@@ -0,0 +1,15 @@
+\ / ⌿ ⍀
+¨ ⍨ ⌶
+& ∥
+
+----------------------------------------------------
+
+[
+	["monadic-operator", "\\"], ["monadic-operator", "/"], ["monadic-operator", "⌿"], ["monadic-operator", "⍀"],
+	["monadic-operator", "¨"], ["monadic-operator", "⍨"], ["monadic-operator", "⌶"],
+	["monadic-operator", "&"], ["monadic-operator", "∥"]
+]
+
+----------------------------------------------------
+
+Checks for monadic operators.
\ No newline at end of file
diff --git a/tests/languages/apl/number_feature.test b/tests/languages/apl/number_feature.test
new file mode 100644
index 0000000..815d1ca
--- /dev/null
+++ b/tests/languages/apl/number_feature.test
@@ -0,0 +1,27 @@
+42
+3.14159
+¯2
+∞
+3E12
+2.8e¯4
+0.1e+7
+2j3
+¯4.3e2J1.9e¯4
+
+----------------------------------------------------
+
+[
+	["number", "42"],
+	["number", "3.14159"],
+	["number", "¯2"],
+	["number", "∞"],
+	["number", "3E12"],
+	["number", "2.8e¯4"],
+	["number", "0.1e+7"],
+	["number", "2j3"],
+	["number", "¯4.3e2J1.9e¯4"]
+]
+
+----------------------------------------------------
+
+Checks for numbers.
\ No newline at end of file
diff --git a/tests/languages/apl/statement_feature.test b/tests/languages/apl/statement_feature.test
new file mode 100644
index 0000000..24c6874
--- /dev/null
+++ b/tests/languages/apl/statement_feature.test
@@ -0,0 +1,13 @@
+:Ab
+:FooBar
+
+----------------------------------------------------
+
+[
+	["statement", ":Ab"],
+	["statement", ":FooBar"]
+]
+
+----------------------------------------------------
+
+Checks for statements.
\ No newline at end of file
diff --git a/tests/languages/apl/string_feature.test b/tests/languages/apl/string_feature.test
new file mode 100644
index 0000000..8bc8dd1
--- /dev/null
+++ b/tests/languages/apl/string_feature.test
@@ -0,0 +1,15 @@
+''
+'foobar'
+'fo''obar'
+
+----------------------------------------------------
+
+[
+	["string", "''"],
+	["string", "'foobar'"],
+	["string", "'fo''obar'"]
+]
+
+----------------------------------------------------
+
+Checks for strings.
\ No newline at end of file
diff --git a/tests/languages/apl/system-function_feature.test b/tests/languages/apl/system-function_feature.test
new file mode 100644
index 0000000..81cbcaa
--- /dev/null
+++ b/tests/languages/apl/system-function_feature.test
@@ -0,0 +1,17 @@
+⎕IO
+⎕WA
+⎕CR
+⎕TCNL
+
+----------------------------------------------------
+
+[
+	["system-function", "⎕IO"],
+	["system-function", "⎕WA"],
+	["system-function", "⎕CR"],
+	["system-function", "⎕TCNL"]
+]
+
+----------------------------------------------------
+
+Checks for system functions.
\ No newline at end of file