| | """ |
| | pygments.lexers.apl |
| | ~~~~~~~~~~~~~~~~~~~ |
| | |
| | Lexers for APL. |
| | |
| | :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS. |
| | :license: BSD, see LICENSE for details. |
| | """ |
| |
|
| | from pygments.lexer import RegexLexer |
| | from pygments.token import Comment, Operator, Keyword, Name, String, \ |
| | Number, Punctuation, Whitespace |
| |
|
| | __all__ = ['APLLexer'] |
| |
|
| |
|
| | class APLLexer(RegexLexer): |
| | """ |
| | A simple APL lexer. |
| | |
| | .. versionadded:: 2.0 |
| | """ |
| | name = 'APL' |
| | url = 'https://en.m.wikipedia.org/wiki/APL_(programming_language)' |
| | aliases = ['apl'] |
| | filenames = [ |
| | '*.apl', '*.aplf', '*.aplo', '*.apln', |
| | '*.aplc', '*.apli', '*.dyalog', |
| | ] |
| |
|
| | tokens = { |
| | 'root': [ |
| | |
| | |
| | (r'\s+', Whitespace), |
| | |
| | |
| | |
| | |
| | (r'[⍝#].*$', Comment.Single), |
| | |
| | |
| | |
| | (r'\'((\'\')|[^\'])*\'', String.Single), |
| | (r'"(("")|[^"])*"', String.Double), |
| | |
| | |
| | |
| | |
| | |
| | (r'[⋄◇()]', Punctuation), |
| | |
| | |
| | |
| | |
| | |
| | (r'[\[\];]', String.Regex), |
| | |
| | |
| | |
| | |
| | (r'⎕[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*', Name.Function), |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | (r'[A-Za-zΔ∆⍙_][A-Za-zΔ∆⍙_¯0-9]*', Name.Variable), |
| | |
| | |
| | |
| | (r'¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞)' |
| | r'([Jj]¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞))?', |
| | Number), |
| | |
| | |
| | |
| | (r'[\.\\\/⌿⍀¨⍣⍨⍠⍤∘⌸&⌶@⌺⍥⍛⍢]', Name.Attribute), |
| | (r'[+\-×÷⌈⌊∣|⍳?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⌸⍯↗⊆⊇⍸√⌾…⍮]', |
| | Operator), |
| | |
| | |
| | |
| | (r'⍬', Name.Constant), |
| | |
| | |
| | |
| | (r'[⎕⍞]', Name.Variable.Global), |
| | |
| | |
| | |
| | (r'[←→]', Keyword.Declaration), |
| | |
| | |
| | |
| | (r'[⍺⍵⍶⍹∇:]', Name.Builtin.Pseudo), |
| | (r'[{}]', Keyword.Type), |
| | ], |
| | } |
| |
|