eric6/ThirdParty/Pygments/pygments/lexers/apl.py

changeset 7701
25f42e208e08
parent 7547
21b0534faebc
child 7983
54c5cfbb1e29
equal deleted inserted replaced
7700:a3cf077a8db3 7701:25f42e208e08
3 pygments.lexers.apl 3 pygments.lexers.apl
4 ~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for APL. 6 Lexers for APL.
7 7
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 from pygments.lexer import RegexLexer 12 from pygments.lexer import RegexLexer
13 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ 13 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
16 __all__ = ['APLLexer'] 16 __all__ = ['APLLexer']
17 17
18 18
19 class APLLexer(RegexLexer): 19 class APLLexer(RegexLexer):
20 """ 20 """
21 A simple APL lexer. 21 A simple `APL <https://en.m.wikipedia.org/wiki/APL_(programming_language)>`_ lexer.
22 22
23 .. versionadded:: 2.0 23 .. versionadded:: 2.0
24 """ 24 """
25 name = 'APL' 25 name = 'APL'
26 aliases = ['apl'] 26 aliases = ['apl']
33 (r'\s+', Text), 33 (r'\s+', Text),
34 # 34 #
35 # Comment 35 # Comment
36 # ======= 36 # =======
37 # '⍝' is traditional; '#' is supported by GNU APL and NGN (but not Dyalog) 37 # '⍝' is traditional; '#' is supported by GNU APL and NGN (but not Dyalog)
38 (u'[⍝#].*$', Comment.Single), 38 (r'[⍝#].*$', Comment.Single),
39 # 39 #
40 # Strings 40 # Strings
41 # ======= 41 # =======
42 (r'\'((\'\')|[^\'])*\'', String.Single), 42 (r'\'((\'\')|[^\'])*\'', String.Single),
43 (r'"(("")|[^"])*"', String.Double), # supported by NGN APL 43 (r'"(("")|[^"])*"', String.Double), # supported by NGN APL
44 # 44 #
45 # Punctuation 45 # Punctuation
46 # =========== 46 # ===========
47 # This token type is used for diamond and parenthesis 47 # This token type is used for diamond and parenthesis
48 # but not for bracket and ; (see below) 48 # but not for bracket and ; (see below)
49 (u'[⋄◇()]', Punctuation), 49 (r'[⋄◇()]', Punctuation),
50 # 50 #
51 # Array indexing 51 # Array indexing
52 # ============== 52 # ==============
53 # Since this token type is very important in APL, it is not included in 53 # Since this token type is very important in APL, it is not included in
54 # the punctuation token type but rather in the following one 54 # the punctuation token type but rather in the following one
55 (r'[\[\];]', String.Regex), 55 (r'[\[\];]', String.Regex),
56 # 56 #
57 # Distinguished names 57 # Distinguished names
58 # =================== 58 # ===================
59 # following IBM APL2 standard 59 # following IBM APL2 standard
60 (u'⎕[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*', Name.Function), 60 (r'⎕[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*', Name.Function),
61 # 61 #
62 # Labels 62 # Labels
63 # ====== 63 # ======
64 # following IBM APL2 standard 64 # following IBM APL2 standard
65 # (u'[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*:', Name.Label), 65 # (r'[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*:', Name.Label),
66 # 66 #
67 # Variables 67 # Variables
68 # ========= 68 # =========
69 # following IBM APL2 standard 69 # following IBM APL2 standard
70 (u'[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*', Name.Variable), 70 (r'[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*', Name.Variable),
71 # 71 #
72 # Numbers 72 # Numbers
73 # ======= 73 # =======
74 (u'¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞)' 74 (r'¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞)'
75 u'([Jj]¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞))?', 75 r'([Jj]¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞))?',
76 Number), 76 Number),
77 # 77 #
78 # Operators 78 # Operators
79 # ========== 79 # ==========
80 (u'[\\.\\\\\\/⌿⍀¨⍣⍨⍠⍤∘]', Name.Attribute), # closest token type 80 (r'[\.\\\/⌿⍀¨⍣⍨⍠⍤∘⌸&⌶@⌺⍥⍛⍢]', Name.Attribute), # closest token type
81 (u'[+\\-×÷⌈⌊∣|⍳?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⌸⍯↗]', 81 (r'[+\-×÷⌈⌊∣|⍳?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⌸⍯↗⊆⊇⍸√⌾…⍮]',
82 Operator), 82 Operator),
83 # 83 #
84 # Constant 84 # Constant
85 # ======== 85 # ========
86 (u'⍬', Name.Constant), 86 (r'⍬', Name.Constant),
87 # 87 #
88 # Quad symbol 88 # Quad symbol
89 # =========== 89 # ===========
90 (u'[⎕⍞]', Name.Variable.Global), 90 (r'[⎕⍞]', Name.Variable.Global),
91 # 91 #
92 # Arrows left/right 92 # Arrows left/right
93 # ================= 93 # =================
94 (u'[←→]', Keyword.Declaration), 94 (r'[←→]', Keyword.Declaration),
95 # 95 #
96 # D-Fn 96 # D-Fn
97 # ==== 97 # ====
98 (u'[⍺⍵⍶⍹∇:]', Name.Builtin.Pseudo), 98 (r'[⍺⍵⍶⍹∇:]', Name.Builtin.Pseudo),
99 (r'[{}]', Keyword.Type), 99 (r'[{}]', Keyword.Type),
100 ], 100 ],
101 } 101 }

eric ide

mercurial