Skip to content

Commit

Permalink
Add support for APL. Closes #308
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Sep 4, 2015
1 parent b2f14d9 commit 1f45942
Show file tree
Hide file tree
Showing 16 changed files with 247 additions and 2 deletions.
4 changes: 4 additions & 0 deletions components.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ var components = {
"title": "Apache Configuration",
"owner": "GuiTeK"
},
"apl": {
"title": "APL",
"owner": "ngn"
},
"applescript": {
"title": "AppleScript",
"owner": "Golmote"
Expand Down
29 changes: 29 additions & 0 deletions components/prism-apl.js
Original file line number Diff line number Diff line change
@@ -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'
}
};
1 change: 1 addition & 0 deletions components/prism-apl.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions tests/languages/apl/assignment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
a←1 2 3

----------------------------------------------------

[
"a",
["assignment", "←"],
["number", "1"], ["number", "2"], ["number", "3"]
]

----------------------------------------------------

Checks for assignment.
15 changes: 15 additions & 0 deletions tests/languages/apl/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
⍝ Foobar
#!/usr/bin/env runapl

----------------------------------------------------

[
["comment", "⍝"],
["comment", "⍝ Foobar"],
["comment", "#!/usr/bin/env runapl"]
]

----------------------------------------------------

Checks for comments.
19 changes: 19 additions & 0 deletions tests/languages/apl/constant_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#

----------------------------------------------------

[
["constant", "⍬"],
["constant", "⌾"],
["constant", "#"],
["constant", "⎕"],
["constant", "⍞"]
]

----------------------------------------------------

Checks for constants.
23 changes: 23 additions & 0 deletions tests/languages/apl/dfn_feature.test
Original file line number Diff line number Diff line change
@@ -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.
13 changes: 13 additions & 0 deletions tests/languages/apl/dyadic-operator_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
. ⍣ ⍠
⍤ ∘ ⌸

----------------------------------------------------

[
["dyadic-operator", "."], ["dyadic-operator", "⍣"], ["dyadic-operator", "⍠"],
["dyadic-operator", "⍤"], ["dyadic-operator", "∘"], ["dyadic-operator", "⌸"]
]

----------------------------------------------------

Checks for dyadic operators.
41 changes: 41 additions & 0 deletions tests/languages/apl/function_feature.test
Original file line number Diff line number Diff line change
@@ -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.
15 changes: 15 additions & 0 deletions tests/languages/apl/monadic-operator_feature.test
Original file line number Diff line number Diff line change
@@ -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.
27 changes: 27 additions & 0 deletions tests/languages/apl/number_feature.test
Original file line number Diff line number Diff line change
@@ -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.
13 changes: 13 additions & 0 deletions tests/languages/apl/statement_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
:Ab
:FooBar

----------------------------------------------------

[
["statement", ":Ab"],
["statement", ":FooBar"]
]

----------------------------------------------------

Checks for statements.
15 changes: 15 additions & 0 deletions tests/languages/apl/string_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
''
'foobar'
'fo''obar'

----------------------------------------------------

[
["string", "''"],
["string", "'foobar'"],
["string", "'fo''obar'"]
]

----------------------------------------------------

Checks for strings.
17 changes: 17 additions & 0 deletions tests/languages/apl/system-function_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
⎕IO
⎕WA
⎕CR
⎕TCNL

----------------------------------------------------

[
["system-function", "⎕IO"],
["system-function", "⎕WA"],
["system-function", "⎕CR"],
["system-function", "⎕TCNL"]
]

----------------------------------------------------

Checks for system functions.

0 comments on commit 1f45942

Please sign in to comment.